mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user