mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: 支持修改tags & workspace: upgrade to js-yaml@4
This commit is contained in:
1 parent
87a4bc8bfa
commit
3d9acf2c1a
18 files changed
+38
-36
No files matched your search
+4
-4
@@ -20,17 +20,17 @@
|
||||
"devDependencies": {
|
||||
"@shelf/jest-mongodb": "^1.2.3",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^26.0.19",
|
||||
"@types/node": "^14.14.16",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.20",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||
"@typescript-eslint/parser": "^3.9.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"eslint": "^7.16.0",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-import-resolver-typescript": "^2.3.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"globby": "^11.0.1",
|
||||
"globby": "^11.0.2",
|
||||
"jest": "^26.6.3",
|
||||
"latest-version": "^5.1.0",
|
||||
"ora": "^5.2.0",
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
"axios": "^0.21.1",
|
||||
"bson": "^4.2.2",
|
||||
"fs-extra": "^9.0.1",
|
||||
"js-yaml": "^3.14.1",
|
||||
"js-yaml": "^4.0.0",
|
||||
"lodash": "^4.17.20",
|
||||
"p-queue": "^6.6.1",
|
||||
"shell-quote": "^1.7.2",
|
||||
"systeminformation": "^4.33.4",
|
||||
"systeminformation": "^4.34.5",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
@@ -24,7 +24,7 @@
|
||||
"devDependencies": {
|
||||
"@types/bson": "^4.0.2",
|
||||
"@types/fs-extra": "^9.0.6",
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/js-yaml": "^4.0.0",
|
||||
"@types/shell-quote": "^1.7.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -299,7 +299,7 @@ export default async function readCases(folder: string, cfg: Record<string, any>
|
||||
const yamlConfig = path.resolve(folder, 'config.yaml');
|
||||
let config;
|
||||
if (fs.existsSync(yamlConfig)) {
|
||||
config = { ...yaml.safeLoad(fs.readFileSync(yamlConfig).toString()) as object, ...cfg };
|
||||
config = { ...yaml.load(fs.readFileSync(yamlConfig).toString()) as object, ...cfg };
|
||||
} else if (fs.existsSync(iniConfig)) {
|
||||
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg };
|
||||
} else config = cfg;
|
||||
|
||||
@@ -9,7 +9,7 @@ export = async function compile(
|
||||
lang: string, code: string, target: string, copyIn: any, next?: Function,
|
||||
): Promise<Execute> {
|
||||
const LANGS = global.Hydro
|
||||
? yaml.safeLoad(await global.Hydro.model.system.get('hydrojudge.langs'))
|
||||
? yaml.load(global.Hydro.model.system.get('hydrojudge.langs'))
|
||||
: require('./config').LANGS;
|
||||
if (!LANGS[lang]) throw new SystemError('Unsupported language {0}.', [lang]);
|
||||
const info = LANGS[lang];
|
||||
|
||||
@@ -47,12 +47,12 @@ if (process.env.EXECUTION_HOST || argv.execute) {
|
||||
EXECUTION_HOST = path.resolve(process.env.EXECUTION_HOST || argv.execute as string);
|
||||
}
|
||||
if (!global.Hydro) {
|
||||
if (fs.existsSync(LANGS_FILE)) LANGS = yaml.safeLoad(fs.readFileSync(LANGS_FILE).toString());
|
||||
if (fs.existsSync(LANGS_FILE)) LANGS = yaml.load(fs.readFileSync(LANGS_FILE).toString());
|
||||
else {
|
||||
log.error('Language file not found, using default.');
|
||||
const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml');
|
||||
const content = yaml.safeLoad(fs.readFileSync(file).toString()) as any;
|
||||
LANGS = yaml.safeLoad(content.langs.default) as any;
|
||||
const content = yaml.load(fs.readFileSync(file).toString()) as any;
|
||||
LANGS = yaml.load(content.langs.default) as any;
|
||||
}
|
||||
if (!(fs.existsSync(LANGS_FILE) || global.Hydro)) {
|
||||
fs.ensureDirSync(path.dirname(LANGS_FILE));
|
||||
|
||||
@@ -57,7 +57,7 @@ async function daemon() {
|
||||
if (CONFIG) config = CONFIG;
|
||||
else {
|
||||
config = (await fs.readFile(CONFIG_FILE)).toString();
|
||||
config = yaml.safeLoad(config);
|
||||
config = yaml.load(config);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('配置文件无效或未找到。');
|
||||
@@ -85,7 +85,7 @@ async function daemon() {
|
||||
if (hosts[i].config.cookie) cfg.hosts[i].cookie = hosts[i].config.cookie;
|
||||
if (hosts[i].config.detail) cfg.hosts[i].detail = hosts[i].config.detail;
|
||||
}
|
||||
await fs.writeFile(CONFIG_FILE, yaml.safeDump(cfg));
|
||||
await fs.writeFile(CONFIG_FILE, yaml.dump(cfg));
|
||||
});
|
||||
}
|
||||
while ('Orz twd2') {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.15.15",
|
||||
"version": "2.15.16",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -16,8 +16,8 @@
|
||||
"cookies": "^0.8.0",
|
||||
"detect-browser": "^5.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"js-yaml": "^3.14.1",
|
||||
"koa": "^2.13.0",
|
||||
"js-yaml": "^4.0.0",
|
||||
"koa": "^2.13.1",
|
||||
"koa-body": "^4.2.0",
|
||||
"koa-proxies": "^0.11.0",
|
||||
"koa-router": "^10.0.0",
|
||||
@@ -32,18 +32,18 @@
|
||||
"serialize-javascript": "^5.0.1",
|
||||
"sockjs": "^0.3.20",
|
||||
"superagent": "^6.1.0",
|
||||
"systeminformation": "^4.33.4",
|
||||
"systeminformation": "^4.34.5",
|
||||
"terminal-kit": "^1.44.3",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.4.33",
|
||||
"@types/fs-extra": "^9.0.6",
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/js-yaml": "^4.0.0",
|
||||
"@types/koa": "^2.11.4",
|
||||
"@types/koa-router": "^7.4.1",
|
||||
"@types/koa-static-cache": "^5.1.0",
|
||||
"@types/lodash": "^4.14.166",
|
||||
"@types/lodash": "^4.14.167",
|
||||
"@types/lru-cache": "^5.1.0",
|
||||
"@types/minio": "^7.0.6",
|
||||
"@types/mongodb": "^3.5.33",
|
||||
|
||||
@@ -70,7 +70,7 @@ export async function locale(pending: string[], fail: string[]) {
|
||||
const locales = {};
|
||||
for (const file of files) {
|
||||
const content = fs.readFileSync(path.resolve(p, file)).toString();
|
||||
locales[file.split('.')[0]] = yaml.safeLoad(content);
|
||||
locales[file.split('.')[0]] = yaml.load(content);
|
||||
}
|
||||
global.Hydro.lib.i18n(locales);
|
||||
logger.info('Locale init: %s', i);
|
||||
@@ -97,7 +97,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
|
||||
if (!fs.existsSync(p)) p = path.resolve(i, 'settings.yaml');
|
||||
if (fs.existsSync(p) && !fail.includes(i)) {
|
||||
try {
|
||||
const cfg: any = yaml.safeLoad(fs.readFileSync(p).toString());
|
||||
const cfg: any = yaml.load(fs.readFileSync(p).toString());
|
||||
for (const key in cfg) {
|
||||
map[cfg[key].category || 'system'](
|
||||
modelSetting.Setting(
|
||||
|
||||
@@ -24,7 +24,7 @@ import paginate from '../lib/paginate';
|
||||
import { isTitle, isContent } from '../lib/validator';
|
||||
|
||||
const validatePenaltyRules = (input: string) => {
|
||||
const s = yaml.safeLoad(input);
|
||||
const s = yaml.load(input);
|
||||
return s;
|
||||
};
|
||||
const convertPenaltyRules = validatePenaltyRules;
|
||||
@@ -281,7 +281,7 @@ class HomeworkEditHandler extends HomeworkHandler {
|
||||
datePenaltyText: penaltySince.format('YYYY-M-D'),
|
||||
timePenaltyText: penaltySince.format('hh:mm'),
|
||||
extensionDays,
|
||||
penaltyRules: yaml.safeDump(tdoc.penaltyRules),
|
||||
penaltyRules: yaml.dump(tdoc.penaltyRules),
|
||||
pids: tdoc.pids.join(','),
|
||||
path,
|
||||
};
|
||||
|
||||
@@ -363,7 +363,7 @@ export class ProblemSettingsHandler extends ProblemManageHandler {
|
||||
['problem_settings', null],
|
||||
];
|
||||
if (this.response.body.pdoc.config) {
|
||||
this.response.body.pdoc.config = yaml.safeDump(this.response.body.pdoc.config);
|
||||
this.response.body.pdoc.config = yaml.dump(this.response.body.pdoc.config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ export class ProblemSettingsHandler extends ProblemManageHandler {
|
||||
async postConfig(domainId: string, pid: string | number, cfg: string) {
|
||||
const pdoc = await problem.get(domainId, pid);
|
||||
// TODO validate
|
||||
const config = yaml.safeLoad(cfg) as any;
|
||||
const config = yaml.load(cfg) as any;
|
||||
await problem.edit(domainId, pdoc.docId, { config });
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ function convert(ini: string) {
|
||||
if (!Number.isNaN(parseInt(memory, 10))) cur.memory = `${Math.floor(parseInt(memory, 10) / 1024)}m`;
|
||||
res.subtasks.push(cur);
|
||||
}
|
||||
return yaml.safeDump(res);
|
||||
return yaml.dump(res);
|
||||
}
|
||||
|
||||
global.Hydro.lib['testdata.convert.ini'] = convert;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Zip from 'adm-zip';
|
||||
import { safeLoad } from 'js-yaml';
|
||||
import { load } from 'js-yaml';
|
||||
import { LocalProblemConfig } from '../interface';
|
||||
|
||||
export async function readConfig(file: string | Buffer) {
|
||||
@@ -37,7 +37,7 @@ export async function parseConfig(config: string | LocalProblemConfig) {
|
||||
let cfg: LocalProblemConfig = {};
|
||||
if (typeof config === 'string') {
|
||||
// TODO should validate here?
|
||||
cfg = safeLoad(config) as LocalProblemConfig;
|
||||
cfg = load(config) as LocalProblemConfig;
|
||||
} else cfg = config;
|
||||
if (cfg.cases) {
|
||||
for (const c of cfg.cases) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import moment from 'moment-timezone';
|
||||
import { Dictionary } from 'lodash';
|
||||
import yaml from 'js-yaml';
|
||||
import * as builtin from './builtin';
|
||||
import { Setting as _Setting } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
@@ -142,6 +143,7 @@ SystemSetting(
|
||||
Setting('setting_server', 'server.port', null, 8888, 'number', 'Server Port'),
|
||||
Setting('setting_server', 'server.xff', null, null, 'text', 'IP Header', 'e.g. x-forwarded-for (lowercase)'),
|
||||
Setting('setting_server', 'server.language', langRange, 'zh_CN', 'select', 'Default display language'),
|
||||
Setting('setting_basic', 'problem.categories', null, yaml.dump(builtin.CATEGORIES), 'textarea', 'Problem Categories'),
|
||||
Setting('setting_session', 'session.keys', null, [String.random(32)], 'text', 'session.keys', null, FLAG_HIDDEN),
|
||||
Setting('setting_session', 'session.secure', null, false, 'boolean', 'session.secure'),
|
||||
Setting('setting_session', 'session.saved_expire_seconds', null, 3600 * 24 * 30, 'number', 'Saved session expire seconds'),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import cluster from 'cluster';
|
||||
import crypto from 'crypto';
|
||||
import axios from 'axios';
|
||||
import { safeDump } from 'js-yaml';
|
||||
import { dump } from 'js-yaml';
|
||||
import db from './db';
|
||||
import * as bus from './bus';
|
||||
import * as sysinfo from '../lib/sysinfo';
|
||||
@@ -33,7 +33,7 @@ export async function feedback() {
|
||||
document.coll.find({ docType: document.TYPE_DISCUSSION }).count(),
|
||||
record.coll.find().count(),
|
||||
]);
|
||||
const payload = crypt(safeDump({
|
||||
const payload = crypt(dump({
|
||||
_id: installid + mid.toString(),
|
||||
version,
|
||||
name,
|
||||
|
||||
@@ -98,7 +98,7 @@ class ImportQduojHandler extends Handler {
|
||||
}
|
||||
await storage.put(
|
||||
`problem/${domainId}/${pid}/testdata/config.yaml`,
|
||||
Buffer.from(yaml.safeDump(config)),
|
||||
Buffer.from(yaml.dump(config)),
|
||||
);
|
||||
const data = await storage.list(`problem/${domainId}/${pid}/testdata/`, true);
|
||||
await problem.edit(domainId, pid, { html: true, data });
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"hydrooj": "^2.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": "^7.4.1"
|
||||
"ws": "^7.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^7.4.0"
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/js-yaml": "^4.0.0",
|
||||
"@types/mongodb": "^3.5.33"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "2.14.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.14.1",
|
||||
"js-yaml": "^4.0.0",
|
||||
"mongodb": "^3.6.3"
|
||||
}
|
||||
}
|
||||
@@ -346,7 +346,7 @@ async function fix(doc) {
|
||||
w.on('error', reject);
|
||||
r.pipe(w);
|
||||
});
|
||||
const config = yaml.safeLoad(await testdataConfig.readConfig(p));
|
||||
const config = yaml.load(await testdataConfig.readConfig(p));
|
||||
await dst.collection('document').updateOne(
|
||||
{ _id: doc._id },
|
||||
{ $set: { config } },
|
||||
|
||||
Reference in new issue
Block a user