update cli

This commit is contained in:
undefined committed 2020-07-20 18:06:14 +08:00
1 parent c4a13f2e27
commit 8b5107fefa
7 files changed
+36 -35

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
FROM mhart/alpine-node:slim-10
WORKDIR /app
COPY .build /app
EXPOSE 8888
CMD ["node", ".build/app.js"]
+1 -3
View File
@@ -5,13 +5,11 @@ Hydro是一个高效的信息学在线测评系统。
[中文文档](docs/deploy.md)
Hydro 的界面基于 Vijos 二次开发。
如果您认为本项目有价值,欢迎 star 。
## 联系我们
QQ [3402182471](tencent://AddContact/?uin=3402182471&subcmd=all)
QQ [3402182471](https://wpa.qq.com/msgrd?v=3&uin=3402182471&site=qq&menu=yes)
Telegram [@webpack_exports_undefined](https://t.me/webpack_exports_undefined)
## 鸣谢
-1
View File
@@ -10,4 +10,3 @@ model.setting.ui.name
pdoc.secretConfig?
在线IDE 更换颜色主题, fix resize
move to @hydrooj/core?
remove koa-router
+33 -8
View File
@@ -1,20 +1,45 @@
#!/usr/bin/env node
const os = require('os');
const path = require('path');
const fs = require('fs-extra');
const { argv } = require('yargs');
const hydro = require('../dist/loader');
const ui = argv.ui || '@hydrooj/ui-default';
fs.ensureDirSync(path.resolve(os.homedir(), '.hydro'));
const addonPath = path.resolve(os.homedir(), '.hydro', 'addon.json');
if (!fs.existsSync(addonPath)) fs.writeFileSync(addonPath, '[]');
const addons = JSON.parse(fs.readFileSync(addonPath).toString());
try {
const ui = argv.ui || '@hydrooj/ui-default';
require.resolve(ui);
addons.push(ui);
} catch (e) {
console.error('Please also install @hydrooj/ui-default');
process.exit(1);
}
hydro.addon(ui);
hydro.load().catch((e) => {
console.error(e);
process.exit(1);
});
if (argv._[0]) {
const operation = argv._[0];
const arg1 = argv._[1];
const arg2 = argv._[2];
if (operation === 'addon') {
if (arg1 === 'add') addons.push(arg2);
else if (arg1 === 'remove') {
for (let i = 0; i < addons.length; i++) {
if (addons[i] === arg2) {
addons.splice(i, 1);
break;
}
}
}
console.log('Current Addons: ', addons);
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
}
} else {
for (const addon of addons) hydro.addon(addon);
hydro.load().catch((e) => {
console.error(e);
process.exit(1);
});
}
-16
View File
@@ -1,16 +0,0 @@
version: '3'
services:
hydro:
image: hydrooj/hydro:latest
restart: always
links:
- mongo
volumes:
- ./data/config:/config
ports:
- 8888:8888
mongo:
image: mongo:latest
restart: always
volumes:
- ./data/db:/data/db
+1 -1
View File
@@ -137,7 +137,7 @@ export function getStatus(domainId: string, did: ObjectID, uid: number) {
return document.getStatus(domainId, document.TYPE_DISCUSSION, did, uid);
}
export function addNode(domainId: string, _id: string, category: string, args: any) {
export function addNode(domainId: string, _id: string, category: string, args: any = {}) {
return document.add(
domainId, category, 1, document.TYPE_DISCUSSION_NODE,
_id, null, null, args,
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.9.3",
"version": "2.9.4",
"main": "dist/loader.js",
"bin": "bin/hydrooj.js",
"repository": "https://github.com/hydro-dev/Hydro.git",