@gmcb/cli 0.8.4 → 0.8.6

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.8.6](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.5...@gmcb/cli@0.8.6) (2026-07-15)
7
+
8
+ **Note:** Version bump only for package @gmcb/cli
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.8.5](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.4...@gmcb/cli@0.8.5) (2026-07-15)
15
+
16
+ **Note:** Version bump only for package @gmcb/cli
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.8.4](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.3...@gmcb/cli@0.8.4) (2026-07-15)
7
23
 
8
24
  **Note:** Version bump only for package @gmcb/cli
@@ -60,8 +60,8 @@ async function getCommands(...args) {
60
60
  utils_1.log.error(`请将分支切换为“${opts.branch}”分支,并重新构建!`);
61
61
  }
62
62
  }
63
- catch (e) {
64
- utils_1.log.warning(e?.message);
63
+ catch (err) {
64
+ utils_1.log.warning(JSON.stringify(err));
65
65
  opts.branch = false;
66
66
  }
67
67
  }
@@ -305,15 +305,20 @@ async function fetchRemoteResources(opts) {
305
305
  // 4. 拉取代码到 COMMAND_PATH/.repo/{appId}
306
306
  const repoDir = (0, path_1.join)(utils_1.COMMAND_PATH, '.repo', appId);
307
307
  if ((0, fs_1.existsSync)((0, path_1.join)(repoDir, '.git'))) {
308
- // 已有目录:fetch + 强制切换分支 + pull
309
- const repoGit = (0, simple_git_1.default)(repoDir);
310
- await repoGit.fetch('origin');
311
- const remoteBranches = await repoGit.branch(['-r']);
312
- if (!remoteBranches.all.includes(`origin/${branch}`)) {
313
- utils_1.log.error(`远程分支 origin/${branch} 不存在,请检查仓库 ${repoUrl}`);
308
+ try {
309
+ // 已有目录:fetch 目标分支 + 校验远程分支 + 切换 + pull
310
+ const repoGit = (0, simple_git_1.default)(repoDir);
311
+ // 1. 拉取目标分支(显式指定,不受 --single-branch refspec 限制)
312
+ // --prune 确保远程已删除的分支不会残留在本地引用中
313
+ await repoGit.fetch('origin', `+refs/heads/${branch}:refs/remotes/origin/${branch}`, ['--prune']);
314
+ // 2. 切换分支:-B 强制创建/重置本地分支指向 origin/{branch}
315
+ await repoGit.checkout(['-B', branch, `origin/${branch}`, '-f']);
316
+ // 3. 拉取最新代码
317
+ await repoGit.pull('origin', branch);
318
+ }
319
+ catch (err) {
320
+ utils_1.log.error(JSON.stringify(err));
314
321
  }
315
- await repoGit.checkout(branch, ['-f']);
316
- await repoGit.pull('origin', branch);
317
322
  }
318
323
  else {
319
324
  // 新克隆:直接使用 branch 分支,失败则抛出异常
@@ -323,7 +328,7 @@ async function fetchRemoteResources(opts) {
323
328
  await cloneGit.clone(repoUrl, repoDir, ['--branch', branch, '--single-branch']);
324
329
  }
325
330
  catch (err) {
326
- utils_1.log.error(err.message);
331
+ utils_1.log.error(JSON.stringify(err));
327
332
  }
328
333
  }
329
334
  spinner.stop();
package/lib/apis/index.js CHANGED
@@ -113,8 +113,7 @@ async function uploadVersion(params) {
113
113
  });
114
114
  }
115
115
  catch (err) {
116
- console.error(err);
117
- process.exit(1);
116
+ utils_1.log.error(JSON.stringify(err));
118
117
  }
119
118
  }
120
119
  /**
@@ -198,30 +197,34 @@ async function publishVersion(params) {
198
197
  });
199
198
  }
200
199
  catch (err) {
201
- console.error(err);
202
- process.exit(1);
200
+ utils_1.log.error(JSON.stringify(err));
203
201
  }
204
202
  }
205
203
  /**
206
204
  * 获取最新版本信息(自动登录)
207
205
  */
208
206
  async function fetchLatestVersion(params) {
209
- const { appId, platform } = params;
210
- await ensureLoggedIn();
211
- const { data: versionPage } = await getVersionPage({
212
- appId,
213
- publishType: 1,
214
- platform,
215
- pageNo: 1,
216
- pageSize: 1,
217
- });
218
- const versionList = (versionPage?.list || []).filter((item) => item.status < 2);
219
- const latestVersion = versionList[0];
220
- return {
221
- versionName: latestVersion?.versionName ?? '',
222
- versionCode: Number(latestVersion?.versionNum ?? 0),
223
- updateMode: latestVersion?.updateMode ?? 0,
224
- };
207
+ try {
208
+ const { appId, platform } = params;
209
+ await ensureLoggedIn();
210
+ const { data: versionPage } = await getVersionPage({
211
+ appId,
212
+ publishType: 1,
213
+ platform,
214
+ pageNo: 1,
215
+ pageSize: 1,
216
+ });
217
+ const versionList = (versionPage?.list || []).filter((item) => item.status < 2);
218
+ const latestVersion = versionList[0];
219
+ return {
220
+ versionName: latestVersion?.versionName ?? '',
221
+ versionCode: Number(latestVersion?.versionNum ?? 0),
222
+ updateMode: latestVersion?.updateMode ?? 0,
223
+ };
224
+ }
225
+ catch (err) {
226
+ utils_1.log.error(JSON.stringify(err));
227
+ }
225
228
  }
226
229
  /**
227
230
  * 获取应用信息(自动登录)
@@ -245,7 +248,6 @@ async function getAppInfo(appId) {
245
248
  };
246
249
  }
247
250
  catch (err) {
248
- console.error(err);
249
- process.exit(1);
251
+ utils_1.log.error(JSON.stringify(err));
250
252
  }
251
253
  }
@@ -13,6 +13,7 @@ const apis_1 = require("../apis");
13
13
  const const_1 = require("../utils/const");
14
14
  const config_1 = require("../utils/config");
15
15
  const function_1 = require("../utils/function");
16
+ const utils_1 = require("../utils");
16
17
  const PUBLISH_APP_CFG = {
17
18
  wgt: config_1.CONFIG_DATA.app?.wgt,
18
19
  zip: config_1.CONFIG_DATA.h5?.zip,
@@ -103,8 +104,7 @@ async function publish(options) {
103
104
  spinner.succeed('新版本提交成功');
104
105
  }
105
106
  catch (err) {
106
- console.error(err);
107
107
  spinner.fail('提交失败');
108
- process.exit(1);
108
+ utils_1.log.error(JSON.stringify(err));
109
109
  }
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -59,5 +59,5 @@
59
59
  "@types/rimraf": "^4.0.5",
60
60
  "@types/user-home": "^2.0.2"
61
61
  },
62
- "gitHead": "7dc381685eea613e6abc5dc1c9cc8f7dd23b045b"
62
+ "gitHead": "4cfd3ea258348ac8b8a2d3fcfda42d152fa38de5"
63
63
  }