remove snyk (its making the project huge)

This commit is contained in:
undefined committed 2020-07-19 19:12:44 +08:00
1 parent 67cb68a9c0
commit 2aa962350f
10 files changed
+53 -2624

No files matched your search

-15
View File
@@ -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);
}
-1
View File
@@ -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'),
-45
View File
@@ -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
View File
@@ -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`);