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');
|
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',
|
2022-09-26 23:47:07 +08:00
|
|
|
MFSU_AD: 'none',
|
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-',
|
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';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-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);
|