mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:15:19 +00:00
fix: yarn start error in windows system (#1177)
* feat: add .env.test.example * fix: yarn start error in windows system
This commit is contained in:
parent
591f0f7b69
commit
c64e32945e
69
.env.test.example
Normal file
69
.env.test.example
Normal file
@ -0,0 +1,69 @@
|
||||
################# NOCOBASE APPLICATION #################
|
||||
|
||||
APP_ENV=development
|
||||
APP_PORT=13000
|
||||
APP_KEY=test-key
|
||||
|
||||
API_BASE_PATH=/api/
|
||||
API_BASE_URL=
|
||||
|
||||
PROXY_TARGET_URL=
|
||||
|
||||
################# DATABASE #################
|
||||
|
||||
DB_DIALECT=sqlite
|
||||
DB_STORAGE=storage/db/nocobase-test.sqlite
|
||||
# DB_HOST=localhost
|
||||
# DB_PORT=5432
|
||||
# DB_DATABASE=nocobase-test
|
||||
# DB_USER=nocobase
|
||||
# DB_PASSWORD=nocobase
|
||||
# DB_LOGGING=on
|
||||
|
||||
################# CACHE #################
|
||||
# default is memory cache, when develop mode,code's change will be clear memory cache, so can use 'cache-manager-fs-hash'
|
||||
# CACHE_CONFIG={"storePackage":"cache-manager-fs-hash","ttl":86400,"max":1000}
|
||||
|
||||
################# STORAGE (Initialization only) #################
|
||||
|
||||
INIT_ROOT_EMAIL=admin@nocobase.com
|
||||
INIT_ROOT_PASSWORD=admin123
|
||||
INIT_ROOT_NICKNAME=Super Admin
|
||||
|
||||
# local or ali-oss
|
||||
DEFAULT_STORAGE_TYPE=local
|
||||
|
||||
# LOCAL STORAGE
|
||||
LOCAL_STORAGE_BASE_URL=
|
||||
LOCAL_STORAGE_DEST=storage/uploads
|
||||
|
||||
# ALI OSS STORAGE
|
||||
ALI_OSS_STORAGE_BASE_URL=
|
||||
ALI_OSS_REGION=oss-cn-beijing
|
||||
ALI_OSS_ACCESS_KEY_ID=
|
||||
ALI_OSS_ACCESS_KEY_SECRET=
|
||||
ALI_OSS_BUCKET=
|
||||
|
||||
# Tencent COS STORAGE
|
||||
TX_COS_STORAGE_BASE_URL=
|
||||
TX_COS_REGION=ap-guangzhou
|
||||
TX_COS_SECRET_ID=
|
||||
TX_COS_SECRET_KEY=
|
||||
TX_COS_BUCKET=
|
||||
|
||||
# AWS
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_S3_REGION=
|
||||
AWS_S3_BUCKET=
|
||||
AWS_S3_STORAGE_BASE_URL=
|
||||
|
||||
# ALI SMS VERIFY CODE CONFIG
|
||||
INIT_ALI_SMS_ACCESS_KEY=
|
||||
INIT_ALI_SMS_ACCESS_KEY_SECRET=
|
||||
INIT_ALI_SMS_ENDPOINT=
|
||||
INIT_ALI_SMS_VERIFY_CODE_TEMPLATE=
|
||||
INIT_ALI_SMS_VERIFY_CODE_SIGN=
|
||||
|
||||
# use any string name (no space)
|
||||
DEFAULT_SMS_VERIFY_CODE_PROVIDER=
|
@ -2,6 +2,10 @@
|
||||
|
||||
测试基于 [Jest](https://jestjs.io/) 测试框架。为了方便的编写测试,提供了 `mockDatabase()` 和 `mockServer()` 用于数据库和服务端应用的测试。
|
||||
|
||||
<Alert>
|
||||
避免破坏生产环境数据,建议使用 `.env.test` 文件来配置测试环境的环境变量,并使用独立的测试数据库进行测试。
|
||||
</Alert>
|
||||
|
||||
## `mockDatabase()`
|
||||
|
||||
默认提供一种完全隔离的 db 测试环境
|
||||
|
@ -16,6 +16,7 @@ const env = {
|
||||
DEFAULT_STORAGE_TYPE: 'local',
|
||||
LOCAL_STORAGE_DEST: 'storage/uploads',
|
||||
MFSU_AD: 'none',
|
||||
PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
|
||||
};
|
||||
|
||||
if (!process.env.APP_ENV_PATH && process.argv[2] && process.argv[2] === 'test') {
|
||||
|
@ -21,6 +21,10 @@ module.exports = (cli) => {
|
||||
const content = await readFile(resolve(cwd, '.env.example'), 'utf-8');
|
||||
await writeFile(resolve(cwd, '.env'), content, 'utf-8');
|
||||
}
|
||||
if (!existsSync(resolve(cwd, '.env.test')) && existsSync(resolve(cwd, '.env.test.example'))) {
|
||||
const content = await readFile(resolve(cwd, '.env.test.example'), 'utf-8');
|
||||
await writeFile(resolve(cwd, '.env.test'), content, 'utf-8');
|
||||
}
|
||||
if (!isPackageValid('umi')) {
|
||||
return;
|
||||
}
|
||||
|
@ -20,12 +20,6 @@ module.exports = (cli) => {
|
||||
if (opts.port) {
|
||||
process.env.APP_PORT = opts.port;
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
console.log(
|
||||
chalk.yellow(`It is not supported on win platform, please use \`${chalk.green('yarn dev')}\` instead`),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
||||
promptForTs();
|
||||
run('ts-node', [
|
||||
|
@ -101,7 +101,8 @@ export class ClientPlugin extends Plugin {
|
||||
root = resolve(process.cwd(), root);
|
||||
}
|
||||
if (process.env.APP_ENV !== 'production' && root) {
|
||||
this.app.middleware.nodes.unshift(async (ctx, next) => {
|
||||
this.app.use(
|
||||
async (ctx, next) => {
|
||||
if (ctx.path.startsWith(this.app.resourcer.options.prefix)) {
|
||||
return next();
|
||||
}
|
||||
@ -110,7 +111,9 @@ export class ClientPlugin extends Plugin {
|
||||
if (ctx.status == 404) {
|
||||
return send(ctx, 'index.html', { root });
|
||||
}
|
||||
});
|
||||
},
|
||||
{ tag: 'clientStatic', before: 'cors' },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
storage/.gitignore
vendored
1
storage/.gitignore
vendored
@ -0,0 +1 @@
|
||||
.pm2
|
Loading…
Reference in New Issue
Block a user