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,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,
|
||||
};
|
||||
Reference in new issue
Block a user