feat: 完善环境标识配置

This commit was merged in pull request #1.
This commit is contained in:
湛兮
2026-06-05 15:35:51 +08:00
parent c0b561b6cb
commit efa71ede6d
6 changed files with 61 additions and 20 deletions
+14
View File
@@ -0,0 +1,14 @@
NODE_ENV=development
APP_ENV=local
APP_ENV_LABEL=本地环境
PORT=3500
DB_HOST=127.0.0.1
DB_PORT=3307
DB_USER=access_user
DB_PASSWORD=replace-with-local-password
DB_NAME=access_manage
DB_CONNECTION_LIMIT=10
JWT_SECRET=replace-with-at-least-32-characters-local-secret
JWT_EXPIRES_IN=2h
+1 -1
View File
@@ -1,5 +1,5 @@
NODE_ENV=test
APP_ENV=test
APP_ENV=develop
APP_ENV_LABEL=测试环境
PORT=3501
+8 -4
View File
@@ -5,10 +5,12 @@ target_dir="${1:-$(pwd)}"
deploy_env="${2:-production}"
case "${deploy_env}" in
test)
test|develop)
mysql_env="${target_dir}/.env.test.mysql"
app_env="${target_dir}/.env.test"
node_env="test"
app_env_name="develop"
app_env_label="测试环境"
app_port="${ACCESS_MANAGE_TEST_PORT:-3501}"
mysql_port="${ACCESS_MANAGE_TEST_DB_PORT:-3308}"
mysql_database="${ACCESS_MANAGE_TEST_DB_NAME:-access_manage_test}"
@@ -17,12 +19,14 @@ case "${deploy_env}" in
mysql_env="${target_dir}/.env.production.mysql"
app_env="${target_dir}/.env.production"
node_env="production"
app_env_name="production"
app_env_label="生产环境"
app_port="${ACCESS_MANAGE_PRODUCTION_PORT:-3500}"
mysql_port="${ACCESS_MANAGE_PRODUCTION_DB_PORT:-3307}"
mysql_database="${ACCESS_MANAGE_PRODUCTION_DB_NAME:-access_manage}"
;;
*)
echo "Usage: $0 [target_dir] [test|production]" >&2
echo "Usage: $0 [target_dir] [test|develop|production]" >&2
exit 1
;;
esac
@@ -74,8 +78,8 @@ jwt_secret="$(openssl rand -hex 48)"
cat > "${app_env}" <<EOF
NODE_ENV=${node_env}
APP_ENV=${node_env}
APP_ENV_LABEL=$([[ "${deploy_env}" == "test" ]] && echo "测试环境" || echo "生产环境")
APP_ENV=${app_env_name}
APP_ENV_LABEL=${app_env_label}
PORT=${app_port}
DB_HOST=127.0.0.1