2022-05-19 00:40:55 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
const { resolve } = require('path');
|
2022-06-14 15:46:48 +08:00
|
|
|
const { existsSync } = require('fs');
|
2023-09-03 10:59:33 +08:00
|
|
|
const chalk = require('chalk');
|
2023-09-15 08:51:20 +08:00
|
|
|
const { genTsConfigPaths } = require('../src/util');
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
const env = {
|
|
|
|
APP_ENV: 'development',
|
|
|
|
APP_KEY: 'test-jwt-secret',
|
|
|
|
APP_PORT: 13000,
|
|
|
|
API_BASE_PATH: '/api/',
|
|
|
|
DB_DIALECT: 'sqlite',
|
|
|
|
DB_STORAGE: 'storage/db/nocobase.sqlite',
|
2022-06-01 12:25:21 +08:00
|
|
|
DB_TIMEZONE: '+00:00',
|
2022-05-19 00:40:55 +08:00
|
|
|
DEFAULT_STORAGE_TYPE: 'local',
|
|
|
|
LOCAL_STORAGE_DEST: 'storage/uploads',
|
2023-09-12 22:39:23 +08:00
|
|
|
PLUGIN_STORAGE_PATH: resolve(process.cwd(), 'storage/plugins'),
|
2022-09-26 23:47:07 +08:00
|
|
|
MFSU_AD: 'none',
|
2023-09-12 22:39:23 +08:00
|
|
|
NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'),
|
2022-12-02 14:23:07 +08:00
|
|
|
PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
|
2023-08-02 00:07:52 +08:00
|
|
|
PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
|
2023-09-13 12:21:29 +08:00
|
|
|
SERVER_TSCONFIG_PATH: './tsconfig.server.json',
|
2022-05-19 00:40:55 +08:00
|
|
|
};
|
|
|
|
|
2022-06-14 15:46:48 +08:00
|
|
|
if (!process.env.APP_ENV_PATH && process.argv[2] && process.argv[2] === 'test') {
|
|
|
|
if (existsSync(resolve(process.cwd(), '.env.test'))) {
|
|
|
|
process.env.APP_ENV_PATH = '.env.test';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-15 08:51:20 +08:00
|
|
|
genTsConfigPaths();
|
|
|
|
|
2022-05-19 00:40:55 +08:00
|
|
|
dotenv.config({
|
|
|
|
path: resolve(process.cwd(), process.env.APP_ENV_PATH || '.env'),
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const key in env) {
|
|
|
|
if (!process.env[key]) {
|
|
|
|
process.env[key] = env[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-03 10:59:33 +08:00
|
|
|
if (require('semver').satisfies(process.version, '<16')) {
|
|
|
|
console.error(chalk.red('[nocobase cli]: Node.js version must be >= 16'));
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2023-02-10 11:16:36 +08:00
|
|
|
if (require('semver').satisfies(process.version, '>16') && !process.env.UNSET_NODE_OPTIONS) {
|
|
|
|
if (process.env.NODE_OPTIONS) {
|
|
|
|
let opts = process.env.NODE_OPTIONS;
|
|
|
|
if (!opts.includes('--openssl-legacy-provider')) {
|
|
|
|
opts = opts + ' --openssl-legacy-provider';
|
|
|
|
}
|
|
|
|
if (!opts.includes('--no-experimental-fetch')) {
|
|
|
|
opts = opts + ' --no-experimental-fetch';
|
|
|
|
}
|
|
|
|
process.env.NODE_OPTIONS = opts;
|
|
|
|
} else {
|
|
|
|
process.env.NODE_OPTIONS = '--openssl-legacy-provider --no-experimental-fetch';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-19 00:40:55 +08:00
|
|
|
const cli = require('../src/cli');
|
|
|
|
|
|
|
|
cli.parse(process.argv);
|