mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +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 {
|
||||||
import { apply as hustoj } from './scripts/hustoj';
|
Context, md5, Schema, sha1,
|
||||||
import { apply as syzoj } from './scripts/syzoj';
|
} from 'hydrooj';
|
||||||
import { apply as vijos } from './scripts/vijos';
|
|
||||||
|
|
||||||
const RE_MD5 = /^[\da-f]{32}$/;
|
const RE_MD5 = /^[\da-f]{32}$/;
|
||||||
|
|
||||||
export function apply(ctx: Context) {
|
export function apply(ctx: Context) {
|
||||||
hustoj(ctx);
|
ctx.addScript(
|
||||||
vijos(ctx);
|
'migrateHustoj', 'migrate from hustoj',
|
||||||
syzoj(ctx);
|
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) => {
|
ctx.provideModule('hash', 'hust', ($password, $saved) => {
|
||||||
$password = md5($password);
|
$password = md5($password);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import mysql from 'mysql';
|
|||||||
import TurndownService from 'turndown';
|
import TurndownService from 'turndown';
|
||||||
import {
|
import {
|
||||||
buildContent, ContestModel, DomainModel, fs, noop, NotFoundError, ObjectID, postJudge, ProblemModel,
|
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';
|
} from 'hydrooj';
|
||||||
|
|
||||||
const turndown = new TurndownService({
|
const turndown = new TurndownService({
|
||||||
@@ -298,18 +298,3 @@ export async function run({
|
|||||||
}
|
}
|
||||||
return true;
|
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 {
|
import {
|
||||||
buildContent, ContestModel, DiscussionDoc, DiscussionReplyDoc, DocumentModel, DomainModel,
|
buildContent, ContestModel, DiscussionDoc, DiscussionReplyDoc, DocumentModel, DomainModel,
|
||||||
fs, noop, NotFoundError, ObjectID, PERM, postJudge, ProblemModel, RecordDoc, RecordModel,
|
fs, noop, NotFoundError, ObjectID, PERM, postJudge, ProblemModel, RecordDoc, RecordModel,
|
||||||
Schema, STATUS, SystemModel, Time, UserModel, yaml,
|
STATUS, SystemModel, Time, UserModel, yaml,
|
||||||
} from 'hydrooj';
|
} from 'hydrooj';
|
||||||
|
|
||||||
const contentTypeMap = {
|
const contentTypeMap = {
|
||||||
@@ -496,17 +496,3 @@ export async function run({
|
|||||||
}
|
}
|
||||||
return true;
|
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 {
|
import {
|
||||||
db as dst,
|
db as dst,
|
||||||
DiscussionModel, DiscussionTailReplyDoc, DocumentModel,
|
DiscussionModel, DiscussionTailReplyDoc, DocumentModel,
|
||||||
MessageDoc, RecordDoc, Schema, TestCase, TrainingNode,
|
MessageDoc, RecordDoc, TestCase, TrainingNode,
|
||||||
} from 'hydrooj';
|
} from 'hydrooj';
|
||||||
|
|
||||||
const map = {};
|
const map = {};
|
||||||
@@ -503,15 +503,3 @@ export async function run({
|
|||||||
await global.Hydro.model.system.set('db.ver', 1);
|
await global.Hydro.model.system.set('db.ver', 1);
|
||||||
return true;
|
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