mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fix linting
This commit is contained in:
1 parent
664cc6e6cf
commit
0925113e39
7 files changed
+61
-58
No files matched your search
@@ -31,7 +31,7 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
yarn build --verbose
|
yarn build
|
||||||
yarn build:ui:production
|
yarn build:ui:production
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: yarn lint:ci
|
run: yarn lint:ci
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ const configFlat = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||||
console.log(packages);
|
|
||||||
for (const package of packages) {
|
for (const package of packages) {
|
||||||
if (package === 'ui-default') continue;
|
if (package === 'ui-default') continue;
|
||||||
const basedir = path.resolve(process.cwd(), 'packages', package);
|
const basedir = path.resolve(process.cwd(), 'packages', package);
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"node": "node",
|
"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:watch": "node build/prepare.js && tsc -b --watch",
|
||||||
"build:ui": "node packages/ui-default/build",
|
"build:ui": "node packages/ui-default/build",
|
||||||
"build:ui:dev": "node packages/ui-default/build --dev",
|
"build:ui:dev": "node packages/ui-default/build --dev",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import 'hydrooj';
|
import 'hydrooj';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import cac from 'cac';
|
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const logger = new Logger('setup');
|
|||||||
const listenPort = cac().parse().options.port || 8888;
|
const listenPort = cac().parse().options.port || 8888;
|
||||||
|
|
||||||
async function get(ctx: Context) {
|
async function get(ctx: Context) {
|
||||||
ctx.body = `<!DOCTYPE html>
|
ctx.body = `<!DOCTYPE html>
|
||||||
<html data-page="setup" data-layout="immersive" class="layout--immersive page--setup nojs">
|
<html data-page="setup" data-layout="immersive" class="layout--immersive page--setup nojs">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
@@ -74,63 +74,63 @@ async function get(ctx: Context) {
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
ctx.response.type = 'text/html';
|
ctx.response.type = 'text/html';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function post(ctx: Context) {
|
async function post(ctx: Context) {
|
||||||
const {
|
const {
|
||||||
host, port, name, username, password,
|
host, port, name, username, password,
|
||||||
} = ctx.request.body;
|
} = ctx.request.body;
|
||||||
let mongourl = 'mongodb://';
|
let mongourl = 'mongodb://';
|
||||||
if (username) mongourl += `${username}:${password}@`;
|
if (username) mongourl += `${username}:${password}@`;
|
||||||
mongourl += `${host}:${port}/${name}`;
|
mongourl += `${host}:${port}/${name}`;
|
||||||
try {
|
try {
|
||||||
const Database = await mongodb.MongoClient.connect(mongourl, {
|
const Database = await mongodb.MongoClient.connect(mongourl, {
|
||||||
useNewUrlParser: true, useUnifiedTopology: true,
|
useNewUrlParser: true, useUnifiedTopology: true,
|
||||||
});
|
});
|
||||||
const db = Database.db(name);
|
const db = Database.db(name);
|
||||||
const coll = db.collection('system');
|
const coll = db.collection('system');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
coll.updateOne(
|
coll.updateOne(
|
||||||
{ _id: 'server.url' },
|
{ _id: 'server.url' },
|
||||||
{ $set: { value: ctx.request.href } },
|
{ $set: { value: ctx.request.href } },
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
),
|
),
|
||||||
coll.updateOne(
|
coll.updateOne(
|
||||||
{ _id: 'server.port' },
|
{ _id: 'server.port' },
|
||||||
{ $set: { value: parseInt(listenPort as string, 10) } },
|
{ $set: { value: parseInt(listenPort as string, 10) } },
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
|
fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
|
||||||
fs.writeFileSync(path.resolve(os.homedir(), '.hydro', 'config.json'), JSON.stringify({
|
fs.writeFileSync(path.resolve(os.homedir(), '.hydro', 'config.json'), JSON.stringify({
|
||||||
host, port, name, username, password,
|
host, port, name, username, password,
|
||||||
}));
|
}));
|
||||||
ctx.body = `<h1>This page will reload in 3 secs.</h1>
|
ctx.body = `<h1>This page will reload in 3 secs.</h1>
|
||||||
<script>
|
<script>
|
||||||
setTimeout(function (){
|
setTimeout(function (){
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
}, 3000);
|
}, 3000);
|
||||||
</script>`;
|
</script>`;
|
||||||
setTimeout(() => process.exit(0), 500);
|
setTimeout(() => process.exit(0), 500);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ctx.body = `Error connecting to database: ${e.message}\n${e.stack}`;
|
ctx.body = `Error connecting to database: ${e.message}\n${e.stack}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function load() {
|
export function load() {
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
const server = http.createServer(app.callback());
|
const server = http.createServer(app.callback());
|
||||||
app.keys = ['Hydro'];
|
app.keys = ['Hydro'];
|
||||||
app
|
app
|
||||||
.use(cache(path.join(os.tmpdir(), 'hydro', 'public'), {
|
.use(cache(path.join(os.tmpdir(), 'hydro', 'public'), {
|
||||||
maxAge: 365 * 24 * 60 * 60,
|
maxAge: 365 * 24 * 60 * 60,
|
||||||
}))
|
}))
|
||||||
.use(Body())
|
.use(Body())
|
||||||
.use((ctx) => {
|
.use((ctx) => {
|
||||||
if (ctx.request.method.toLowerCase() === 'post') return post(ctx);
|
if (ctx.request.method.toLowerCase() === 'post') return post(ctx);
|
||||||
return get(ctx);
|
return get(ctx);
|
||||||
});
|
});
|
||||||
server.listen(listenPort);
|
server.listen(listenPort);
|
||||||
logger.success('Server listening at: %d', listenPort);
|
logger.success('Server listening at: %d', listenPort);
|
||||||
}
|
}
|
||||||
@@ -15,22 +15,22 @@ export function get(key: string): any {
|
|||||||
|
|
||||||
export function getMany<
|
export function getMany<
|
||||||
A extends keyof SystemKeys, B extends keyof SystemKeys,
|
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<
|
export function getMany<
|
||||||
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
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<
|
export function getMany<
|
||||||
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
||||||
D 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<
|
export function getMany<
|
||||||
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
||||||
D extends keyof SystemKeys, E 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<
|
export function getMany<
|
||||||
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
|
||||||
D extends keyof SystemKeys, E extends keyof SystemKeys, F 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: (keyof SystemKeys)[]): any[];
|
||||||
export function getMany(keys: string[]): any[] {
|
export function getMany(keys: string[]): any[] {
|
||||||
return keys.map((key) => cache[key]);
|
return keys.map((key) => cache[key]);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
import cac from 'cac';
|
import cac from 'cac';
|
||||||
|
import fs from 'fs-extra';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
import WebpackDevServer from 'webpack-dev-server';
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
@@ -73,6 +74,10 @@ async function main() {
|
|||||||
process.chdir(root());
|
process.chdir(root());
|
||||||
await runGulp();
|
await runGulp();
|
||||||
await runWebpack(argv.options);
|
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);
|
process.chdir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user