mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
core: experimental hot reload support
This commit is contained in:
1 parent
632ae27b88
commit
fd7c9cbeb1
26 files changed
+429
-148
No files matched your search
@@ -1,7 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
import { ObjectID } from 'mongodb';
|
||||
import Schema from 'schemastery';
|
||||
import { addScript } from '../loader';
|
||||
import blacklist from '../model/blacklist';
|
||||
import * as discussion from '../model/discussion';
|
||||
import * as document from '../model/document';
|
||||
@@ -61,8 +60,9 @@ async function _user(
|
||||
if (!dryrun) await UserModel.ban(uid);
|
||||
}
|
||||
|
||||
addScript('blacklist', 'Add blacklist by ip, uid')
|
||||
.args(Schema.object({
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'blacklist', 'Add blacklist by ip, uid',
|
||||
Schema.object({
|
||||
address: Schema.string(),
|
||||
discuss: Schema.object({
|
||||
domainId: Schema.string(),
|
||||
@@ -70,8 +70,8 @@ addScript('blacklist', 'Add blacklist by ip, uid')
|
||||
}),
|
||||
user: Schema.number(),
|
||||
dryrun: Schema.boolean(),
|
||||
}))
|
||||
.action(async ({
|
||||
}),
|
||||
async ({
|
||||
address = null, discuss = null, user = null, dryrun = true,
|
||||
}, report) => {
|
||||
if (address) await _address(address, new Set(), new Set(), new Set(), dryrun, report);
|
||||
@@ -83,4 +83,5 @@ addScript('blacklist', 'Add blacklist by ip, uid')
|
||||
}
|
||||
if (user) await _user(user, new Set(), new Set(), new Set(), dryrun, report);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -2,7 +2,6 @@
|
||||
import Schema from 'schemastery';
|
||||
import * as semver from 'semver';
|
||||
import superagent from 'superagent';
|
||||
import { addScript } from '../loader';
|
||||
import MessageModel from '../model/message';
|
||||
import * as system from '../model/system';
|
||||
|
||||
@@ -38,4 +37,4 @@ export async function run(_: {}, report: Function) {
|
||||
return true;
|
||||
}
|
||||
|
||||
addScript('checkUpdate', 'Daily update check').args(Schema.any()).action(run);
|
||||
export const apply = (ctx) => ctx.addScript('checkUpdate', 'Daily update check', Schema.any(), run);
|
||||
@@ -1,5 +1,4 @@
|
||||
import Schema from 'schemastery';
|
||||
import { addScript } from '../loader';
|
||||
import { PRIV } from '../model/builtin';
|
||||
import user from '../model/user';
|
||||
import db from '../service/db';
|
||||
@@ -9,7 +8,7 @@ const collDomainUser = db.collection('domain.user');
|
||||
const collRecord = db.collection('record');
|
||||
const collMessage = db.collection('message');
|
||||
|
||||
addScript('deleteUser', 'Delete a user')
|
||||
export const apply = (ctx) => ctx.addScript('deleteUser', 'Delete a user')
|
||||
.args(Schema.object({
|
||||
uid: Schema.number(),
|
||||
}))
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { ObjectID } from 'mongodb';
|
||||
import Schema from 'schemastery';
|
||||
import { addScript } from '../loader';
|
||||
import { STATUS } from '../model/builtin';
|
||||
import * as document from '../model/document';
|
||||
import db from '../service/db';
|
||||
@@ -153,15 +152,17 @@ export async function pdoc(report) {
|
||||
if (bulk.length) await bulk.execute();
|
||||
}
|
||||
|
||||
addScript('problemStat', 'Recalculates nSubmit and nAccept in problem status.')
|
||||
.args(Schema.object({
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'problemStat', 'Recalculates nSubmit and nAccept in problem status.',
|
||||
Schema.object({
|
||||
udoc: Schema.boolean(),
|
||||
pdoc: Schema.boolean(),
|
||||
psdoc: Schema.boolean(),
|
||||
}))
|
||||
.action(async (arg, report) => {
|
||||
}),
|
||||
async (arg, report) => {
|
||||
if (arg.pdoc === undefined || arg.pdoc) await pdoc(report);
|
||||
if (arg.udoc === undefined || arg.udoc) await udoc(report);
|
||||
if (arg.psdoc === undefined || arg.psdoc) await psdoc(report);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -6,7 +6,6 @@ import Schema from 'schemastery';
|
||||
import { Tdoc, Udoc } from '../interface';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
import rating from '../lib/rating';
|
||||
import { addScript } from '../loader';
|
||||
import { PRIV, STATUS } from '../model/builtin';
|
||||
import * as contest from '../model/contest';
|
||||
import domain from '../model/domain';
|
||||
@@ -184,8 +183,7 @@ export async function run({ domainId }, report: Function) {
|
||||
return true;
|
||||
}
|
||||
|
||||
addScript('rp', 'Calculate rp of a domain, or all domains')
|
||||
.args(Schema.object({
|
||||
domainId: Schema.string(),
|
||||
}))
|
||||
.action(run);
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'rp', 'Calculate rp of a domain, or all domains',
|
||||
Schema.object({ domainId: Schema.string() }), run,
|
||||
);
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import Schema from 'schemastery';
|
||||
import { addScript } from '../loader';
|
||||
import { STATUS } from '../model/builtin';
|
||||
import storage from '../model/storage';
|
||||
|
||||
@@ -37,6 +36,4 @@ export async function run(_, report) {
|
||||
return true;
|
||||
}
|
||||
|
||||
addScript('storageUsage', 'Calculate storage usage')
|
||||
.args(Schema.any())
|
||||
.action(run);
|
||||
export const apply = (ctx) => ctx.addScript('storageUsage', 'Calculate storage usage', Schema.any(), run);
|
||||
Reference in new issue
Block a user