remove snyk (its making the project huge)

pull/10/head
undefined 4 years ago
parent 67cb68a9c0
commit 2aa962350f

12
.snyk

@ -1,12 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.15.0
ignore: {}
# patches apply the minimum changes required to fix a vulnerability
patch:
SNYK-JS-LODASH-567746:
- eslint > lodash:
patched: '2020-06-20T05:33:18.901Z'
- eslint > inquirer > lodash:
patched: '2020-06-20T05:33:18.901Z'
- eslint > table > lodash:
patched: '2020-06-20T05:33:18.901Z'

@ -2,16 +2,15 @@
const hydro = require('../dist/loader');
hydro.addon('.');
try {
const uiDefault = require.resolve('@hydrooj/ui-default');
hydro.addon(uiDefault);
require.resolve('@hydrooj/ui-default');
} catch (e) {
console.error('Please also install @hydrooj/ui-default');
process.exit(1);
}
hydro.addon('@hydrooj/ui-default');
hydro.load().catch((e) => {
console.error(e);
process.exit(1);

@ -9,7 +9,6 @@ import {
Route, Connection, Handler, ConnectionHandler, param, Types,
} from '../service/server';
import { validate } from '../lib/validator';
import * as hpm from '../lib/hpm';
function set(key, value) {
if (setting.SYSTEM_SETTINGS_BY_KEY[key]) {
@ -81,19 +80,6 @@ class SystemDashboardHandler extends SystemHandler {
}
}
class SystemModuleHandler extends SystemHandler {
async get() {
this.response.body.path.push(['manage_module', null]);
this.response.body.installed = await hpm.getDetail();
this.response.template = 'manage_module.html';
}
async postInstall({ url }) {
await hpm.install(url);
this.back();
}
}
class SystemScriptHandler extends SystemHandler {
async get() {
this.response.template = 'manage_script.html';
@ -187,7 +173,6 @@ async function apply() {
Route('manage', '/manage', SystemMainHandler);
Route('manage_dashboard', '/manage/dashboard', SystemDashboardHandler);
Route('manage_script', '/manage/script', SystemScriptHandler);
Route('manage_module', '/manage/module', SystemModuleHandler);
Route('manage_setting', '/manage/setting', SystemSettingHandler);
Connection('manage_check', '/manage/check-conn', SystemCheckConnHandler);
}

@ -259,7 +259,6 @@ declare global {
lib: {
download: typeof import('./lib/download').default,
'hash.hydro': typeof import('./lib/hash.hydro').default,
hpm: typeof import('./lib/hpm'),
i18n: typeof import('./lib/i18n').default,
'import.syzoj': typeof import('./lib/import.syzoj').syzoj,
jwt: typeof import('./lib/jwt'),

@ -1,45 +0,0 @@
/* eslint-disable import/no-dynamic-require */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-eval */
import fs from 'fs';
import os from 'os';
import path from 'path';
import download from './download';
import { folderSize } from '../utils';
const moduleRoots = Array.from(new Set([
path.resolve(process.cwd(), 'node_modules', '@hydrooj'),
path.resolve(__dirname, 'node_modules', '@hydrooj'),
path.resolve(os.tmpdir(), 'hydro', 'module'),
]));
export async function getDetail() {
const modules = [];
for (const moduleRoot of moduleRoots) {
if (fs.existsSync(moduleRoot)) {
const files = fs.readdirSync(moduleRoot);
for (const file of files) {
const info = path.resolve(moduleRoot, file, 'package.json');
if (fs.existsSync(info)) {
const i = JSON.parse(fs.readFileSync(info).toString());
const size = folderSize(path.resolve(moduleRoot, file));
modules.push({
id: i.name,
version: i.version,
description: i.description,
size,
});
}
}
}
}
return modules;
}
export function install(url: string, name: string = '') {
return download(url, path.resolve(process.cwd(), `${name || String.random(16)}.hydro`));
}
global.Hydro.lib.hpm = {
getDetail, install,
};

@ -129,7 +129,7 @@ const tmp = path.resolve(os.tmpdir(), 'hydro', '__');
export function addon(addonPath: string) {
let modulePath = path.resolve(addonPath);
if (!(fs.existsSync(addonPath) && fs.statSync(addonPath).isFile())) {
if (modulePath.endsWith('.hydro') && !(fs.existsSync(addonPath) && fs.statSync(addonPath).isFile())) {
try {
// Is a npm package
const packagejson = require.resolve(`${addonPath}/package.json`);

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.9.0",
"version": "2.9.1",
"main": "entry.js",
"bin": "bin/hydrooj.js",
"repository": "https://github.com/hydro-dev/Hydro.git",
@ -35,7 +35,6 @@
"nodemailer": "^6.4.10",
"nunjucks": "^3.2.1",
"prismjs": "^1.20.0",
"saslprep": "^1.0.3",
"serialize-javascript": "^4.0.0",
"sockjs": "^0.3.20",
"superagent": "^5.2.2",
@ -70,15 +69,11 @@
"eslint-config-airbnb-base": "^14.2.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.20.2",
"snyk": "^1.354.0",
"typescript": "^3.9.7"
},
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"lint": "eslint build hydro tool --ext ts,js --fix",
"snyk-protect": "snyk protect",
"prepare": "yarn run snyk-protect"
},
"snyk": true
"lint": "eslint build hydro tool --ext ts,js --fix"
}
}

@ -14,12 +14,12 @@ const LOCALE_ROOT = path.resolve(__dirname, '..', 'locales');
const texts = {};
const result = {};
const locales = fs.readdirSync(LOCALE_ROOT);
let currentFile = '';
const currentFile = 'setting.ts';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function Setting(str, format) {
if (!texts[str]) texts[str] = [currentFile];
else texts[str].push(currentFile);
else if (!texts[str].includes(currentFile)) texts[str].push(currentFile);
}
function scanSetting() {

@ -16,13 +16,22 @@ Hydro 依赖于 MongoDB 与 NodeJS您应该先安装它们。
提示:推荐使用 [nvm](https://nvm.sh/) 安装 NodeJS。
clone 本项目到一个空文件夹,并进行编译
安装 yarn
```sh
git clone https://github.com/hydro-dev/Hydro.git
cd Hydro
yarn build:all
node .build/app.js
npm install yarn -g
```
使用 yarn 安装 Hydro
```sh
yarn global add hydro @hydro/ui-default
```
运行:
```sh
hydrooj
```
注意单个Hydro实例需要约100MB的运行内存但在载入时可能需要较多内存取决于安装的模块数量与大小

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save