mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
migrate: lazyload scripts
This commit is contained in:
1 parent
80e944ae7e
commit
57796912e4
4 files changed
+44
-51
No files matched your search
@@ -1,14 +1,48 @@
|
||||
import { Context, md5, sha1 } from 'hydrooj';
|
||||
import { apply as hustoj } from './scripts/hustoj';
|
||||
import { apply as syzoj } from './scripts/syzoj';
|
||||
import { apply as vijos } from './scripts/vijos';
|
||||
import {
|
||||
Context, md5, Schema, sha1,
|
||||
} from 'hydrooj';
|
||||
|
||||
const RE_MD5 = /^[\da-f]{32}$/;
|
||||
|
||||
export function apply(ctx: Context) {
|
||||
hustoj(ctx);
|
||||
vijos(ctx);
|
||||
syzoj(ctx);
|
||||
ctx.addScript(
|
||||
'migrateHustoj', 'migrate from hustoj',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
domainId: Schema.string().required(),
|
||||
contestType: Schema.string().required(),
|
||||
dataDir: Schema.string().required(),
|
||||
}),
|
||||
(...args) => require('./scripts/hustoj').run(...args),
|
||||
);
|
||||
ctx.addScript(
|
||||
'migrateSyzoj', 'migrate from syzoj',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
domainId: Schema.string().default('system'),
|
||||
dataDir: Schema.string().default('/opt/syzoj/web/uploads'),
|
||||
}),
|
||||
(...args) => require('./scripts/syzoj').run(...args),
|
||||
);
|
||||
ctx.addScript(
|
||||
'migrateVijos', 'migrate from vijos',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
}),
|
||||
(...args) => require('./scripts/vijos').run(...args),
|
||||
);
|
||||
|
||||
ctx.provideModule('hash', 'hust', ($password, $saved) => {
|
||||
$password = md5($password);
|
||||
|
||||
@@ -4,7 +4,7 @@ import mysql from 'mysql';
|
||||
import TurndownService from 'turndown';
|
||||
import {
|
||||
buildContent, ContestModel, DomainModel, fs, noop, NotFoundError, ObjectID, postJudge, ProblemModel,
|
||||
RecordDoc, RecordModel, Schema, SolutionModel, STATUS, SystemModel, Time, UserModel,
|
||||
RecordDoc, RecordModel, SolutionModel, STATUS, SystemModel, Time, UserModel,
|
||||
} from 'hydrooj';
|
||||
|
||||
const turndown = new TurndownService({
|
||||
@@ -298,18 +298,3 @@ export async function run({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'migrateHustoj', 'migrate from hustoj',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
domainId: Schema.string().required(),
|
||||
contestType: Schema.string().required(),
|
||||
dataDir: Schema.string().required(),
|
||||
}),
|
||||
run,
|
||||
);
|
||||
@@ -3,7 +3,7 @@ import mariadb from 'mariadb';
|
||||
import {
|
||||
buildContent, ContestModel, DiscussionDoc, DiscussionReplyDoc, DocumentModel, DomainModel,
|
||||
fs, noop, NotFoundError, ObjectID, PERM, postJudge, ProblemModel, RecordDoc, RecordModel,
|
||||
Schema, STATUS, SystemModel, Time, UserModel, yaml,
|
||||
STATUS, SystemModel, Time, UserModel, yaml,
|
||||
} from 'hydrooj';
|
||||
|
||||
const contentTypeMap = {
|
||||
@@ -496,17 +496,3 @@ export async function run({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'migrateSyzoj', 'migrate from syzoj',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
domainId: Schema.string().default('system'),
|
||||
dataDir: Schema.string().default('/opt/syzoj/web/uploads'),
|
||||
}),
|
||||
run,
|
||||
);
|
||||
@@ -4,7 +4,7 @@ import mongodb, { Cursor, Db } from 'mongodb';
|
||||
import {
|
||||
db as dst,
|
||||
DiscussionModel, DiscussionTailReplyDoc, DocumentModel,
|
||||
MessageDoc, RecordDoc, Schema, TestCase, TrainingNode,
|
||||
MessageDoc, RecordDoc, TestCase, TrainingNode,
|
||||
} from 'hydrooj';
|
||||
|
||||
const map = {};
|
||||
@@ -503,15 +503,3 @@ export async function run({
|
||||
await global.Hydro.model.system.set('db.ver', 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
export const apply = (ctx) => ctx.addScript(
|
||||
'migrateVijos', 'migrate from vijos',
|
||||
Schema.object({
|
||||
host: Schema.string().required(),
|
||||
port: Schema.number().required(),
|
||||
name: Schema.string().required(),
|
||||
username: Schema.string().required(),
|
||||
password: Schema.string().required(),
|
||||
}),
|
||||
run,
|
||||
);
|
||||
Reference in new issue
Block a user