2026-03-23 13:21:07 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 将 app-expo/.env.<name> 复制为 .env,供 Metro/Expo 读取 EXPO_PUBLIC_*。
|
|
|
|
|
|
*
|
|
|
|
|
|
* 参数 name → 源文件:
|
|
|
|
|
|
* development → .env.development(本地默认:npm start / prestart)
|
|
|
|
|
|
* staging → .env.staging
|
|
|
|
|
|
* production → .env.production
|
|
|
|
|
|
*
|
|
|
|
|
|
* CI:.github/workflows/app-expo-deploy.yml 按分支/tag 调用本脚本,与后端 env 策略对齐。
|
|
|
|
|
|
*/
|
2026-03-20 15:15:35 +08:00
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
const env = process.argv[2] || 'development';
|
|
|
|
|
|
const src = path.join(__dirname, '..', `.env.${env}`);
|
|
|
|
|
|
const dest = path.join(__dirname, '..', '.env');
|
|
|
|
|
|
if (fs.existsSync(src)) {
|
|
|
|
|
|
fs.copyFileSync(src, dest);
|
|
|
|
|
|
console.log(`Switched to .env.${env}`);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(`Missing .env.${env}`);
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|