diff --git a/package.json b/package.json index 314fead72..0a01a7a6e 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,13 @@ "lint:ci": "eslint packages --ext ts", "lint:ui": "yarn run --cwd=packages/ui-default eslint . --fix", "lint:ui:ci": "yarn run --cwd=packages/ui-default eslint .", - "snowpack": "cd packages/ui-default && snowpack dev", "pub": "node build/publish", "jest": "node build/jest", "typedoc": "cross-env NODE_OPTIONS=--max_old_space_size=8192 typedoc", - "debug": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug --template", - "start": "node build/start", + "debug:all": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug --template", + "debug": "node --async-stack-traces --trace-deprecation --enable-source-maps node_modules/.bin/hydrooj --debug --template", + "start:all": "node build/start", + "start": "node node_modules/.bin/hydrooj", "clean": "zsh -c \"rm -rf tsconfig.build.tsbuildinfo ./packages/*/tsconfig.tsbuildinfo ./packages/*/dist ./.coverage\"" }, "version": "1.0.0", diff --git a/packages/hydrooj/bin/hydrooj.js b/packages/hydrooj/bin/hydrooj.js index 6fa957244..3399ccc05 100755 --- a/packages/hydrooj/bin/hydrooj.js +++ b/packages/hydrooj/bin/hydrooj.js @@ -7,6 +7,14 @@ const fs = require('fs-extra'); const { argv } = require('yargs'); const child = require('child_process'); +function buildUrl(opts) { + let mongourl = `${opts.protocol || 'mongodb'}://`; + if (opts.username) mongourl += `${opts.username}:${opts.password}@`; + mongourl += `${opts.host}:${opts.port}/${opts.name}`; + if (opts.url) mongourl = opts.url; + return mongourl; +} + if (!cluster.isMaster) { const hydro = require('../dist/loader'); // Forked by hydro @@ -22,13 +30,6 @@ if (!cluster.isMaster) { let addons = JSON.parse(fs.readFileSync(addonPath).toString()); if (argv._[0] === 'db') { - function buildUrl(opts) { - let mongourl = `${opts.protocol || 'mongodb'}://`; - if (opts.username) mongourl += `${opts.username}:${opts.password}@`; - mongourl += `${opts.host}:${opts.port}/${opts.name}`; - if (opts.url) mongourl = opts.url; - return mongourl; - } const dbConfig = fs.readFileSync(path.resolve(hydroPath, 'config.json'), 'utf-8'); const url = buildUrl(JSON.parse(dbConfig)); return child.spawn('mongo', [url], { stdio: 'inherit' }); diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 7d6205cad..74a74fcdd 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.26.28", + "version": "2.26.29", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/loader.ts b/packages/hydrooj/src/loader.ts index 06aa89d3a..dd8be8180 100644 --- a/packages/hydrooj/src/loader.ts +++ b/packages/hydrooj/src/loader.ts @@ -135,7 +135,7 @@ process.on('uncaughtException', logger.error); const publicTemp = path.resolve(os.tmpdir(), 'hydro', 'public'); -export function addon(addonPath: string) { +export function addon(addonPath: string, prepend = false) { if (!(fs.existsSync(addonPath) && fs.statSync(addonPath).isFile())) { try { // Is a npm package @@ -143,7 +143,8 @@ export function addon(addonPath: string) { const modulePath = path.dirname(packagejson); const publicPath = path.resolve(modulePath, 'public'); if (fs.existsSync(publicPath)) fs.copySync(publicPath, publicTemp); - global.addons.push(modulePath); + if (prepend) global.addons.unshift(modulePath); + else global.addons.push(modulePath); } catch (e) { logger.error(`Addon not found: ${addonPath}`); } @@ -151,7 +152,7 @@ export function addon(addonPath: string) { } export async function load() { - addon(path.resolve(__dirname, '..')); + addon(path.resolve(__dirname, '..'), true); Error.stackTraceLimit = 50; if (cluster.isMaster || argv.startAsMaster) { logger.info(`Master ${process.pid} Starting`);