From eff22e15069a9c50f42e505555c210560689eacf Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 22 Jan 2023 19:27:32 +0800 Subject: [PATCH] workspace: add additional folder `modules` --- .gitignore | 1 + build/prepare.js | 19 ++++++++----------- package.json | 7 ++++--- pnpm-workspace.yaml | 3 ++- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index ef9c4f15..6cab8f6f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ packages/ui-default/public packages/ui-default/misc/.iconfont packages/ui-default/static/locale plugins/ +modules/ # Data files *.mmdb diff --git a/build/prepare.js b/build/prepare.js index 849cbcc5..5ba4e5bf 100644 --- a/build/prepare.js +++ b/build/prepare.js @@ -56,27 +56,24 @@ const configFlat = (name) => ({ exclude: ['public'], }); -if (!fs.existsSync(path.resolve(process.cwd(), 'plugins'))) { - fs.mkdirSync(path.resolve(process.cwd(), 'plugins')); - // Write an empty file to make eslint happy - fs.writeFileSync(path.resolve(process.cwd(), 'plugins/eslint.ts'), ''); +for (const name of ['plugins', 'modules']) { + if (!fs.existsSync(path.resolve(process.cwd(), name))) { + fs.mkdirSync(path.resolve(process.cwd(), name)); + // Write an empty file to make eslint happy + fs.writeFileSync(path.resolve(process.cwd(), name, 'eslint.ts'), ''); + } } const modules = [ 'packages/hydrooj', - ...fs.readdirSync(path.resolve(process.cwd(), 'packages')).map((i) => `packages/${i}`), - ...fs.readdirSync(path.resolve(process.cwd(), 'plugins')).map((i) => `plugins/${i}`), + ...['packages', 'plugins', 'modules'].flatMap((i) => fs.readdirSync(path.resolve(process.cwd(), i)).map((j) => `${i}/${j}`)), ].filter((i) => !i.includes('/.') && !i.includes('ui-default')).filter((i) => fs.statSync(path.resolve(process.cwd(), i)).isDirectory()); const UIConfig = { exclude: [ 'packages/ui-default/public', ], - include: ['ts', 'tsx'].flatMap((i) => [ - `packages/ui-default/**/*.${i}`, - `packages/**/public/**/*.${i}`, - `plugins/**/public/**/*.${i}`, - ]), + include: ['ts', 'tsx'].flatMap((ext) => [].map((name) => `${name}/**/public/**/*.${ext}`).concat(`packages/ui-default/**/*.${ext}`)), compilerOptions: { experimentalDecorators: true, esModuleInterop: true, diff --git a/package.json b/package.json index cd0918e3..b7eb2cd0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "private": true, "workspaces": [ "packages/*", - "plugins/*" + "plugins/*", + "modules/*" ], "main": "package.json", "scripts": { @@ -17,8 +18,8 @@ "build:ui:production:webpack": "cross-env NODE_OPTIONS=--max_old_space_size=8192 node packages/ui-default/build --production", "test": "node test/entry.js", "benchmark": "cross-env BENCHMARK=true node test/entry.js", - "lint": "eslint packages plugins --ext ts --fix", - "lint:ci": "eslint packages plugins --ext ts", + "lint": "eslint packages plugins modules --ext ts --fix", + "lint:ci": "eslint packages plugins modules --ext ts", "lint:ui": "yarn workspace @hydrooj/ui-default lint --ext .js,.ts,.jsx,.tsx . --fix", "lint:ui:ci": "yarn workspace @hydrooj/ui-default lint --ext .js,.ts,.jsx,.tsx .", "debug": "node --trace-warnings --async-stack-traces --trace-deprecation packages/hydrooj/bin/hydrooj --debug --template", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8897423b..c14be1de 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - packages/* -- plugins/* \ No newline at end of file +- plugins/* +- modules/*