diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7889cf84f..3b1871dc3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,7 +31,7 @@ jobs:
run: yarn
- name: Build
run: |
- yarn build --verbose
+ yarn build
yarn build:ui:production
- name: Lint
run: yarn lint:ci
diff --git a/build/prepare.js b/build/prepare.js
index adf06187c..1a835d7bc 100644
--- a/build/prepare.js
+++ b/build/prepare.js
@@ -44,7 +44,6 @@ const configFlat = {
};
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
-console.log(packages);
for (const package of packages) {
if (package === 'ui-default') continue;
const basedir = path.resolve(process.cwd(), 'packages', package);
diff --git a/package.json b/package.json
index fd712def0..6c90e0938 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"main": "package.json",
"scripts": {
"node": "node",
- "build": "node build/prepare.js && tsc -b",
+ "build": "node build/prepare.js && tsc -b --verbose",
"build:watch": "node build/prepare.js && tsc -b --watch",
"build:ui": "node packages/ui-default/build",
"build:ui:dev": "node packages/ui-default/build --dev",
diff --git a/packages/hydrojudge/src/service.ts b/packages/hydrojudge/src/service.ts
index 3cac272f1..75e095878 100644
--- a/packages/hydrojudge/src/service.ts
+++ b/packages/hydrojudge/src/service.ts
@@ -2,7 +2,6 @@
/* eslint-disable no-await-in-loop */
import 'hydrooj';
import path from 'path';
-import cac from 'cac';
import { ObjectID } from 'mongodb';
import fs from 'fs-extra';
import { noop } from 'lodash';
diff --git a/packages/hydrooj/src/entry/setup.ts b/packages/hydrooj/src/entry/setup.ts
index 40bb12c87..3bd5f19d7 100644
--- a/packages/hydrooj/src/entry/setup.ts
+++ b/packages/hydrooj/src/entry/setup.ts
@@ -13,7 +13,7 @@ const logger = new Logger('setup');
const listenPort = cac().parse().options.port || 8888;
async function get(ctx: Context) {
- ctx.body = `
+ ctx.body = `
@@ -74,63 +74,63 @@ async function get(ctx: Context) {
`;
- ctx.response.type = 'text/html';
+ ctx.response.type = 'text/html';
}
async function post(ctx: Context) {
- const {
- host, port, name, username, password,
- } = ctx.request.body;
- let mongourl = 'mongodb://';
- if (username) mongourl += `${username}:${password}@`;
- mongourl += `${host}:${port}/${name}`;
- try {
- const Database = await mongodb.MongoClient.connect(mongourl, {
- useNewUrlParser: true, useUnifiedTopology: true,
- });
- const db = Database.db(name);
- const coll = db.collection('system');
- await Promise.all([
- coll.updateOne(
- { _id: 'server.url' },
- { $set: { value: ctx.request.href } },
- { upsert: true },
- ),
- coll.updateOne(
- { _id: 'server.port' },
- { $set: { value: parseInt(listenPort as string, 10) } },
- { upsert: true },
- ),
- ]);
- fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
- fs.writeFileSync(path.resolve(os.homedir(), '.hydro', 'config.json'), JSON.stringify({
- host, port, name, username, password,
- }));
- ctx.body = `This page will reload in 3 secs.
+ const {
+ host, port, name, username, password,
+ } = ctx.request.body;
+ let mongourl = 'mongodb://';
+ if (username) mongourl += `${username}:${password}@`;
+ mongourl += `${host}:${port}/${name}`;
+ try {
+ const Database = await mongodb.MongoClient.connect(mongourl, {
+ useNewUrlParser: true, useUnifiedTopology: true,
+ });
+ const db = Database.db(name);
+ const coll = db.collection('system');
+ await Promise.all([
+ coll.updateOne(
+ { _id: 'server.url' },
+ { $set: { value: ctx.request.href } },
+ { upsert: true },
+ ),
+ coll.updateOne(
+ { _id: 'server.port' },
+ { $set: { value: parseInt(listenPort as string, 10) } },
+ { upsert: true },
+ ),
+ ]);
+ fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
+ fs.writeFileSync(path.resolve(os.homedir(), '.hydro', 'config.json'), JSON.stringify({
+ host, port, name, username, password,
+ }));
+ ctx.body = `This page will reload in 3 secs.
`;
- setTimeout(() => process.exit(0), 500);
- } catch (e) {
- ctx.body = `Error connecting to database: ${e.message}\n${e.stack}`;
- }
+ setTimeout(() => process.exit(0), 500);
+ } catch (e) {
+ ctx.body = `Error connecting to database: ${e.message}\n${e.stack}`;
+ }
}
export function load() {
- const app = new Koa();
- const server = http.createServer(app.callback());
- app.keys = ['Hydro'];
- app
- .use(cache(path.join(os.tmpdir(), 'hydro', 'public'), {
- maxAge: 365 * 24 * 60 * 60,
- }))
- .use(Body())
- .use((ctx) => {
- if (ctx.request.method.toLowerCase() === 'post') return post(ctx);
- return get(ctx);
- });
- server.listen(listenPort);
- logger.success('Server listening at: %d', listenPort);
+ const app = new Koa();
+ const server = http.createServer(app.callback());
+ app.keys = ['Hydro'];
+ app
+ .use(cache(path.join(os.tmpdir(), 'hydro', 'public'), {
+ maxAge: 365 * 24 * 60 * 60,
+ }))
+ .use(Body())
+ .use((ctx) => {
+ if (ctx.request.method.toLowerCase() === 'post') return post(ctx);
+ return get(ctx);
+ });
+ server.listen(listenPort);
+ logger.success('Server listening at: %d', listenPort);
}
diff --git a/packages/hydrooj/src/model/system.ts b/packages/hydrooj/src/model/system.ts
index b96f89541..3d3f610fd 100644
--- a/packages/hydrooj/src/model/system.ts
+++ b/packages/hydrooj/src/model/system.ts
@@ -15,22 +15,22 @@ export function get(key: string): any {
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys,
- >(keys: [A, B]): [SystemKeys[A], SystemKeys[B]];
+>(keys: [A, B]): [SystemKeys[A], SystemKeys[B]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
- >(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]];
+>(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys,
- >(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]];
+>(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys,
- >(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]];
+>(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys, F extends keyof SystemKeys,
- >(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]];
+>(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]];
export function getMany(keys: (keyof SystemKeys)[]): any[];
export function getMany(keys: string[]): any[] {
return keys.map((key) => cache[key]);
diff --git a/packages/ui-default/build/main.js b/packages/ui-default/build/main.js
index d387da2b9..c96350b85 100644
--- a/packages/ui-default/build/main.js
+++ b/packages/ui-default/build/main.js
@@ -1,5 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import cac from 'cac';
+import fs from 'fs-extra';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import gulp from 'gulp';
@@ -73,6 +74,10 @@ async function main() {
process.chdir(root());
await runGulp();
await runWebpack(argv.options);
+ if (argv.options.production) {
+ fs.removeSync('public/vditor/dist/js/mathjax');
+ fs.removeSync('public/vditor/dist/js/abcjs');
+ }
process.chdir(dir);
}