fe-build-cli 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +24 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fe-build-cli",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "前端项目打包部署 CLI 工具,支持多服务器部署、分支管理、回滚、钉钉通知、智能处理本地改动等功能",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/cli.js CHANGED
@@ -236,17 +236,6 @@ async function deployCommand(config) {
236
236
  const skipBuild = args.includes('--skip-build');
237
237
  const noPush = args.includes('--no-push');
238
238
 
239
- // 确定发布模式
240
- let deployMode = config.deployMode || 'main'; // 默认主分支发布
241
-
242
- if (useTestBranch) {
243
- deployMode = 'test';
244
- } else if (useCurrentBranch) {
245
- deployMode = 'current';
246
- } else if (useMainBranch) {
247
- deployMode = 'main';
248
- }
249
-
250
239
  // 获取目标环境(排除 deploy 命令本身)
251
240
  const argEnv = args.find(arg => arg !== 'deploy' && !arg.startsWith('--'));
252
241
  let selectedServers = [];
@@ -279,6 +268,30 @@ async function deployCommand(config) {
279
268
  }
280
269
  }
281
270
 
271
+ // 确定发布模式(根据部署环境自动选择)
272
+ let deployMode = config.deployMode || 'main'; // 默认主分支发布
273
+
274
+ // 命令行参数优先
275
+ if (useTestBranch) {
276
+ deployMode = 'test';
277
+ } else if (useCurrentBranch) {
278
+ deployMode = 'current';
279
+ } else if (useMainBranch) {
280
+ deployMode = 'main';
281
+ } else {
282
+ // 自动根据部署环境选择发布模式
283
+ // test 环境 → test 发布模式
284
+ // production 环境 → main 发布模式
285
+ const targetEnv = selectedServers[0];
286
+ if (targetEnv === 'test') {
287
+ deployMode = 'test';
288
+ console.log('\n📌 自动识别:部署到 test 环境,使用 test 发布模式');
289
+ } else if (targetEnv === 'production') {
290
+ deployMode = 'main';
291
+ console.log('\n📌 自动识别:部署到 production 环境,使用 main 发布模式');
292
+ }
293
+ }
294
+
282
295
  // 执行分支发布流程
283
296
  let branchResult = null;
284
297
  let originalBranch = getCurrentBranch(); // 记录原始分支