mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
remove ui
This commit is contained in:
1 parent
9dd370fa72
commit
87123659aa
546 files changed
+180
-33522
No files matched your search
@@ -246,6 +246,7 @@ export async function wiki(pending: string[], fail: string[]) {
|
||||
} catch (e) {
|
||||
fail.push(i);
|
||||
console.error(`Wiki Load Fail: ${i}`);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
builtinLib, builtinHandler, builtinModel,
|
||||
} from './common';
|
||||
|
||||
export async function load(call) {
|
||||
let pending = await require('../lib/hpm').getInstalled();
|
||||
export async function load(call, args) {
|
||||
let pending = args;
|
||||
const fail = [];
|
||||
require('../lib/i18n');
|
||||
require('../utils');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import http from 'http';
|
||||
import fs from 'fs-extra';
|
||||
import Koa from 'koa';
|
||||
import Body from 'koa-body';
|
||||
import Router from 'koa-router';
|
||||
@@ -89,7 +89,7 @@ const env = new nunjucks.Environment(new Loader(), { autoescape: true, trimBlock
|
||||
function render(name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
env.render(name, {
|
||||
_: (str) => str,
|
||||
_: (str: string) => str,
|
||||
}, (err, res) => {
|
||||
if (err) reject(err);
|
||||
else resolve(res);
|
||||
@@ -145,7 +145,8 @@ export function load() {
|
||||
{ upsert: true },
|
||||
),
|
||||
]);
|
||||
fs.writeFileSync(path.resolve(process.cwd(), 'config.json'), JSON.stringify({
|
||||
fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
|
||||
fs.writeFileSync(path.resolve(os.homedir(), '.hydro', 'config.json'), JSON.stringify({
|
||||
host, port, name, username, password,
|
||||
}));
|
||||
ctx.body = `<h1>This page will reload in 3 secs.</h1>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/* eslint-disable no-continue */
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import AdmZip from 'adm-zip';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
const moduleRoots = [];
|
||||
const _moduleRoots = Array.from(new Set([
|
||||
path.resolve(process.cwd(), 'node_modules', '@hydrooj'),
|
||||
path.resolve(process.cwd(), 'modules'),
|
||||
path.resolve(process.cwd(), 'module'),
|
||||
path.resolve(process.cwd(), '.build'),
|
||||
process.cwd(),
|
||||
path.resolve(__dirname, 'node_modules', '@hydrooj'),
|
||||
path.resolve(__dirname, 'modules'),
|
||||
path.resolve(__dirname, 'module'),
|
||||
path.resolve(__dirname, '.build'),
|
||||
__dirname,
|
||||
path.resolve(os.homedir(), '.hydro', 'module'),
|
||||
// TODO add npm global path
|
||||
'/usr/local/share/.config/yarn/global/node_modules/@hydrooj',
|
||||
path.resolve(os.homedir(), 'AppData', 'Local', 'Yarn', 'Data', 'global', 'node_modules', '@hydrooj'),
|
||||
]));
|
||||
for (const moduleRoot of _moduleRoots) {
|
||||
if (fs.existsSync(moduleRoot)) moduleRoots.push(moduleRoot);
|
||||
}
|
||||
|
||||
if (process.env.debug) console.log('Module roots: ', moduleRoots);
|
||||
|
||||
const moduleTemp = path.resolve(os.tmpdir(), 'hydro', 'module');
|
||||
const publicTemp = path.resolve(os.tmpdir(), 'hydro', 'public');
|
||||
const tmp = path.resolve(os.tmpdir(), 'hydro', '__');
|
||||
|
||||
process.on('unhandledRejection', (e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export async function load() {
|
||||
fs.ensureDirSync(moduleTemp);
|
||||
fs.ensureDirSync(publicTemp);
|
||||
for (const moduleRoot of moduleRoots) {
|
||||
if (fs.existsSync(moduleRoot)) {
|
||||
const files = fs.readdirSync(moduleRoot);
|
||||
for (const file of files) {
|
||||
try {
|
||||
const modulePath = path.join(moduleRoot, file);
|
||||
const packagejson = path.join(modulePath, 'package.json');
|
||||
if (fs.statSync(modulePath).isFile() && file.endsWith('.hydro')) {
|
||||
// Is *.hydro module
|
||||
const zip = new AdmZip(modulePath);
|
||||
const targetPath = path.resolve(moduleTemp, file.split('.')[0]);
|
||||
zip.extractAllTo(targetPath, true);
|
||||
const content = fs.readdirSync(targetPath);
|
||||
const ipath = path.join(targetPath, content[0]);
|
||||
if (content.length === 1 && fs.statSync(ipath).isDirectory()) {
|
||||
fs.moveSync(ipath, tmp);
|
||||
fs.rmdirSync(targetPath);
|
||||
fs.moveSync(tmp, targetPath);
|
||||
}
|
||||
const publicPath = path.resolve(moduleTemp, file.split('.')[0], 'public');
|
||||
if (fs.existsSync(publicPath)) fs.copySync(publicPath, publicTemp);
|
||||
} else if (fs.existsSync(packagejson)) {
|
||||
// Is a npm package
|
||||
const q = fs.readFileSync(packagejson).toString();
|
||||
if (!JSON.parse(q).name.startsWith('@hydrooj/')) continue;
|
||||
const publicPath = path.resolve(modulePath, 'public');
|
||||
if (fs.existsSync(publicPath)) fs.copySync(publicPath, publicTemp);
|
||||
} else continue;
|
||||
} catch (e) {
|
||||
console.error('Module extract fail:', file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('Unzip done.');
|
||||
process.exit(0);
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
builtinLib, builtinScript, builtinHandler, builtinModel,
|
||||
} from './common';
|
||||
|
||||
export async function load() {
|
||||
let pending = await require('../lib/hpm').getInstalled();
|
||||
export async function load(call, args) {
|
||||
let pending = args;
|
||||
const fail = [];
|
||||
const active = [];
|
||||
require('../lib/i18n');
|
||||
|
||||
Reference in new issue
Block a user