From 22bf23b59e9b68adb26b17cc245550cae28542a4 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 13 Sep 2023 12:21:29 +0800 Subject: [PATCH] fix: add env SERVER_TSCONFIG_PATH --- packages/core/cli/bin/index.js | 1 + packages/core/cli/src/commands/dev.js | 5 +++-- packages/core/cli/src/commands/global.js | 4 ++-- packages/core/cli/src/commands/start.js | 2 +- packages/core/cli/src/util.js | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/core/cli/bin/index.js b/packages/core/cli/bin/index.js index b8a3a8e9b..b597fb6af 100755 --- a/packages/core/cli/bin/index.js +++ b/packages/core/cli/bin/index.js @@ -20,6 +20,7 @@ const env = { NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'), PM2_HOME: resolve(process.cwd(), './storage/.pm2'), PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-', + SERVER_TSCONFIG_PATH: './tsconfig.server.json', }; if (!process.env.APP_ENV_PATH && process.argv[2] && process.argv[2] === 'test') { diff --git a/packages/core/cli/src/commands/dev.js b/packages/core/cli/src/commands/dev.js index e37a757f7..98e17f69c 100644 --- a/packages/core/cli/src/commands/dev.js +++ b/packages/core/cli/src/commands/dev.js @@ -18,12 +18,13 @@ module.exports = (cli) => { .allowUnknownOption() .action(async (opts) => { promptForTs(); + const { SERVER_TSCONFIG_PATH } = process.env; process.env.IS_DEV_CMD = true; if (process.argv.includes('-h') || process.argv.includes('--help')) { run('ts-node', [ '-P', - './tsconfig.server.json', + SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`, @@ -62,7 +63,7 @@ module.exports = (cli) => { 'watch', '--ignore=./storage/plugins/**', '--tsconfig', - './tsconfig.server.json', + SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`, diff --git a/packages/core/cli/src/commands/global.js b/packages/core/cli/src/commands/global.js index bf6e93dc2..d3075f4c8 100644 --- a/packages/core/cli/src/commands/global.js +++ b/packages/core/cli/src/commands/global.js @@ -6,7 +6,7 @@ const { run, isDev, isProd, promptForTs } = require('../util'); * @param {Command} cli */ module.exports = (cli) => { - const { APP_PACKAGE_ROOT } = process.env; + const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; cli .allowUnknownOption() .option('-h, --help') @@ -16,7 +16,7 @@ module.exports = (cli) => { promptForTs(); run('tsx', [ '--tsconfig', - './tsconfig.server.json', + SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`, diff --git a/packages/core/cli/src/commands/start.js b/packages/core/cli/src/commands/start.js index a22111a03..db516c2d0 100644 --- a/packages/core/cli/src/commands/start.js +++ b/packages/core/cli/src/commands/start.js @@ -25,7 +25,7 @@ module.exports = (cli) => { promptForTs(); run('ts-node', [ '-P', - './tsconfig.server.json', + process.env.SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`, diff --git a/packages/core/cli/src/util.js b/packages/core/cli/src/util.js index 4ba866ebf..b392f6320 100644 --- a/packages/core/cli/src/util.js +++ b/packages/core/cli/src/util.js @@ -102,12 +102,12 @@ exports.postCheck = async (opts) => { }; exports.runInstall = async () => { - const { APP_PACKAGE_ROOT } = process.env; + const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; if (exports.isDev()) { const argv = [ '--tsconfig', - './tsconfig.server.json', + SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`, @@ -123,12 +123,12 @@ exports.runInstall = async () => { }; exports.runAppCommand = async (command, args = []) => { - const { APP_PACKAGE_ROOT } = process.env; + const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; if (exports.isDev()) { const argv = [ '--tsconfig', - './tsconfig.server.json', + SERVER_TSCONFIG_PATH, '-r', 'tsconfig-paths/register', `${APP_PACKAGE_ROOT}/src/index.ts`,