mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
remove snyk (its making the project huge)
This commit is contained in:
1 parent
67cb68a9c0
commit
2aa962350f
10 files changed
+53
-2624
No files matched your search
@@ -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'
|
|
||||||
+3
-4
@@ -2,16 +2,15 @@
|
|||||||
|
|
||||||
const hydro = require('../dist/loader');
|
const hydro = require('../dist/loader');
|
||||||
|
|
||||||
hydro.addon('.');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const uiDefault = require.resolve('@hydrooj/ui-default');
|
require.resolve('@hydrooj/ui-default');
|
||||||
hydro.addon(uiDefault);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Please also install @hydrooj/ui-default');
|
console.error('Please also install @hydrooj/ui-default');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hydro.addon('@hydrooj/ui-default');
|
||||||
|
|
||||||
hydro.load().catch((e) => {
|
hydro.load().catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
Route, Connection, Handler, ConnectionHandler, param, Types,
|
Route, Connection, Handler, ConnectionHandler, param, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
import { validate } from '../lib/validator';
|
import { validate } from '../lib/validator';
|
||||||
import * as hpm from '../lib/hpm';
|
|
||||||
|
|
||||||
function set(key, value) {
|
function set(key, value) {
|
||||||
if (setting.SYSTEM_SETTINGS_BY_KEY[key]) {
|
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 {
|
class SystemScriptHandler extends SystemHandler {
|
||||||
async get() {
|
async get() {
|
||||||
this.response.template = 'manage_script.html';
|
this.response.template = 'manage_script.html';
|
||||||
@@ -187,7 +173,6 @@ async function apply() {
|
|||||||
Route('manage', '/manage', SystemMainHandler);
|
Route('manage', '/manage', SystemMainHandler);
|
||||||
Route('manage_dashboard', '/manage/dashboard', SystemDashboardHandler);
|
Route('manage_dashboard', '/manage/dashboard', SystemDashboardHandler);
|
||||||
Route('manage_script', '/manage/script', SystemScriptHandler);
|
Route('manage_script', '/manage/script', SystemScriptHandler);
|
||||||
Route('manage_module', '/manage/module', SystemModuleHandler);
|
|
||||||
Route('manage_setting', '/manage/setting', SystemSettingHandler);
|
Route('manage_setting', '/manage/setting', SystemSettingHandler);
|
||||||
Connection('manage_check', '/manage/check-conn', SystemCheckConnHandler);
|
Connection('manage_check', '/manage/check-conn', SystemCheckConnHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ declare global {
|
|||||||
lib: {
|
lib: {
|
||||||
download: typeof import('./lib/download').default,
|
download: typeof import('./lib/download').default,
|
||||||
'hash.hydro': typeof import('./lib/hash.hydro').default,
|
'hash.hydro': typeof import('./lib/hash.hydro').default,
|
||||||
hpm: typeof import('./lib/hpm'),
|
|
||||||
i18n: typeof import('./lib/i18n').default,
|
i18n: typeof import('./lib/i18n').default,
|
||||||
'import.syzoj': typeof import('./lib/import.syzoj').syzoj,
|
'import.syzoj': typeof import('./lib/import.syzoj').syzoj,
|
||||||
jwt: typeof import('./lib/jwt'),
|
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,
|
|
||||||
};
|
|
||||||
+1
-1
@@ -129,7 +129,7 @@ const tmp = path.resolve(os.tmpdir(), 'hydro', '__');
|
|||||||
|
|
||||||
export function addon(addonPath: string) {
|
export function addon(addonPath: string) {
|
||||||
let modulePath = path.resolve(addonPath);
|
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 {
|
try {
|
||||||
// Is a npm package
|
// Is a npm package
|
||||||
const packagejson = require.resolve(`${addonPath}/package.json`);
|
const packagejson = require.resolve(`${addonPath}/package.json`);
|
||||||
|
|||||||
+3
-8
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.9.0",
|
"version": "2.9.1",
|
||||||
"main": "entry.js",
|
"main": "entry.js",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
"nodemailer": "^6.4.10",
|
"nodemailer": "^6.4.10",
|
||||||
"nunjucks": "^3.2.1",
|
"nunjucks": "^3.2.1",
|
||||||
"prismjs": "^1.20.0",
|
"prismjs": "^1.20.0",
|
||||||
"saslprep": "^1.0.3",
|
|
||||||
"serialize-javascript": "^4.0.0",
|
"serialize-javascript": "^4.0.0",
|
||||||
"sockjs": "^0.3.20",
|
"sockjs": "^0.3.20",
|
||||||
"superagent": "^5.2.2",
|
"superagent": "^5.2.2",
|
||||||
@@ -70,15 +69,11 @@
|
|||||||
"eslint-config-airbnb-base": "^14.2.0",
|
"eslint-config-airbnb-base": "^14.2.0",
|
||||||
"eslint-import-resolver-typescript": "^2.0.0",
|
"eslint-import-resolver-typescript": "^2.0.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"snyk": "^1.354.0",
|
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.7"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"build:watch": "tsc --watch",
|
"build:watch": "tsc --watch",
|
||||||
"lint": "eslint build hydro tool --ext ts,js --fix",
|
"lint": "eslint build hydro tool --ext ts,js --fix"
|
||||||
"snyk-protect": "snyk protect",
|
}
|
||||||
"prepare": "yarn run snyk-protect"
|
|
||||||
},
|
|
||||||
"snyk": true
|
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,12 @@ const LOCALE_ROOT = path.resolve(__dirname, '..', 'locales');
|
|||||||
const texts = {};
|
const texts = {};
|
||||||
const result = {};
|
const result = {};
|
||||||
const locales = fs.readdirSync(LOCALE_ROOT);
|
const locales = fs.readdirSync(LOCALE_ROOT);
|
||||||
let currentFile = '';
|
const currentFile = 'setting.ts';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
function Setting(str, format) {
|
function Setting(str, format) {
|
||||||
if (!texts[str]) texts[str] = [currentFile];
|
if (!texts[str]) texts[str] = [currentFile];
|
||||||
else texts[str].push(currentFile);
|
else if (!texts[str].includes(currentFile)) texts[str].push(currentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scanSetting() {
|
function scanSetting() {
|
||||||
|
|||||||
+14
-5
@@ -16,13 +16,22 @@ Hydro 依赖于 MongoDB 与 NodeJS,您应该先安装它们。
|
|||||||
|
|
||||||
提示:推荐使用 [nvm](https://nvm.sh/) 安装 NodeJS。
|
提示:推荐使用 [nvm](https://nvm.sh/) 安装 NodeJS。
|
||||||
|
|
||||||
clone 本项目到一个空文件夹,并进行编译:
|
安装 yarn:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/hydro-dev/Hydro.git
|
npm install yarn -g
|
||||||
cd Hydro
|
```
|
||||||
yarn build:all
|
|
||||||
node .build/app.js
|
使用 yarn 安装 Hydro:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn global add hydro @hydro/ui-default
|
||||||
|
```
|
||||||
|
|
||||||
|
运行:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
hydrooj
|
||||||
```
|
```
|
||||||
|
|
||||||
注意:单个Hydro实例需要约100MB的运行内存,但在载入时可能需要较多内存(取决于安装的模块数量与大小)
|
注意:单个Hydro实例需要约100MB的运行内存,但在载入时可能需要较多内存(取决于安装的模块数量与大小)
|
||||||
|
|||||||
Reference in new issue
Block a user