2022-05-18 16:40:55 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
const { resolve } = require('path');
|
2022-06-14 07:46:48 +00:00
|
|
|
const { existsSync } = require('fs');
|
2023-09-03 02:59:33 +00:00
|
|
|
const chalk = require('chalk');
|
2022-05-18 16:40:55 +00: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 04:25:21 +00:00
|
|
|
DB_TIMEZONE: '+00:00',
|
2022-05-18 16:40:55 +00:00
|
|
|
DEFAULT_STORAGE_TYPE: 'local',
|
|
|
|
LOCAL_STORAGE_DEST: 'storage/uploads',
|
2022-09-26 15:47:07 +00:00
|
|
|
MFSU_AD: 'none',
|
2022-12-02 06:23:07 +00:00
|
|
|
PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
|
2023-08-01 16:07:52 +00:00
|
|
|
PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
|
2022-05-18 16:40:55 +00:00
|
|
|
};
|
|
|
|
|
2022-06-14 07:46:48 +00: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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 16:40:55 +00: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 02:59:33 +00: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 03:16:36 +00: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-18 16:40:55 +00:00
|
|
|
const cli = require('../src/cli');
|
|
|
|
|
|
|
|
cli.parse(process.argv);
|