@gmcb/cli 0.8.10 → 0.8.11

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,14 @@
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.11](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.10...@gmcb/cli@0.8.11) (2026-07-16)
7
+
8
+ **Note:** Version bump only for package @gmcb/cli
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.8.10](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.9...@gmcb/cli@0.8.10) (2026-07-16)
7
15
 
8
16
  **Note:** Version bump only for package @gmcb/cli
@@ -74,8 +74,8 @@ async function restoreLocalResources(restore) {
74
74
  }
75
75
  async function syncLatestVersion() {
76
76
  const spinner = (0, ora_1.default)('正在获取最新版本数据...').start();
77
- const appIdPkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
78
- const appId = appIdPkg.appId;
77
+ const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
78
+ const appId = pkg.appId;
79
79
  const { versionName, versionCode, updateMode } = await (0, apis_1.fetchLatestVersion)({
80
80
  appId,
81
81
  platform: config_1.CONFIG_DATA.publish?.platform,
@@ -86,19 +86,24 @@ async function syncLatestVersion() {
86
86
  }
87
87
  if (versionName && versionCode) {
88
88
  if ((0, fs_1.existsSync)(utils_1.MAINFEST_PATH)) {
89
- let content = (0, fs_1.readFileSync)(utils_1.MAINFEST_PATH, 'utf-8');
90
- content = content.replace(/"versionName"\s*:\s*"[^"]*"/, `"versionName": "${versionName}"`);
91
- content = content.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
92
- backup(utils_1.MAINFEST_PATH);
93
- (0, fs_1.writeFileSync)(utils_1.MAINFEST_PATH, content);
89
+ const localVersionCode = Number((0, utils_1.readManifest)().versionCode || 0);
90
+ if (localVersionCode < versionCode) {
91
+ let content = (0, fs_1.readFileSync)(utils_1.MAINFEST_PATH, 'utf-8');
92
+ content = content.replace(/"versionName"\s*:\s*"[^"]*"/, `"versionName": "${versionName}"`);
93
+ content = content.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
94
+ backup(utils_1.MAINFEST_PATH);
95
+ (0, fs_1.writeFileSync)(utils_1.MAINFEST_PATH, content);
96
+ }
94
97
  }
95
98
  else {
96
- // 回退到 package.json
97
- let pkgContent = (0, fs_1.readFileSync)(utils_1.PACKAGE_PATH, 'utf-8');
98
- pkgContent = pkgContent.replace(/"version"\s*:\s*"[^"]*"/, `"version": "${versionName}"`);
99
- pkgContent = pkgContent.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
100
- backup(utils_1.PACKAGE_PATH);
101
- (0, fs_1.writeFileSync)(utils_1.PACKAGE_PATH, pkgContent);
99
+ const localVersionCode = Number(pkg.versionCode || 0);
100
+ if (localVersionCode < versionCode) {
101
+ let pkgContent = (0, fs_1.readFileSync)(utils_1.PACKAGE_PATH, 'utf-8');
102
+ pkgContent = pkgContent.replace(/"version"\s*:\s*"[^"]*"/, `"version": "${versionName}"`);
103
+ pkgContent = pkgContent.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
104
+ backup(utils_1.PACKAGE_PATH);
105
+ (0, fs_1.writeFileSync)(utils_1.PACKAGE_PATH, pkgContent);
106
+ }
102
107
  }
103
108
  }
104
109
  spinner.stop();
@@ -328,17 +333,16 @@ function downloadFile(url, dest) {
328
333
  }
329
334
  async function pullRemoteResources(opts) {
330
335
  const spinner = (0, ora_1.default)(`正在拉取远程资源...`).start();
331
- const appIdPkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
332
- const appId = appIdPkg.appId;
333
336
  const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
337
+ const appId = pkg.appId;
334
338
  // 1. 获取应用信息
335
339
  const appInfo = await (0, apis_1.getAppInfo)(appId);
336
340
  const { appName, iconUrl, configJson } = appInfo;
337
341
  // 2. 确定仓库地址
338
342
  const repoUrl = configJson.repo || config_1.CONFIG_DATA.pull?.repo;
339
343
  // 3. 确定分支:使用 buildEnv,默认 master;prod 对应 master 分支
340
- const buildEnv = process.env.BUILD_ENV || 'prod';
341
- const branch = buildEnv === 'prod' ? 'master' : buildEnv;
344
+ const buildEnv = process.env.BUILD_ENV;
345
+ const branch = buildEnv.startsWith('pro') || !buildEnv ? 'master' : buildEnv;
342
346
  // 4. 拉取代码到 COMMAND_PATH/.repo/{appId}
343
347
  const repoDir = (0, path_1.join)(utils_1.COMMAND_PATH, '.repo', appId);
344
348
  if ((0, fs_1.existsSync)((0, path_1.join)(repoDir, '.git'))) {
@@ -230,7 +230,7 @@ async function default_1(...args) {
230
230
  }
231
231
  // 从 cmds 提取 buildEnv
232
232
  const buildEnv = cmds[2]?.split('=')[1];
233
- if (!buildEnv || !['dev', 'sit', 'uat', 'pre', 'prod'].includes(buildEnv)) {
233
+ if (!buildEnv || !['dev', 'sit', 'uat', 'pre', 'pro', 'prod'].includes(buildEnv)) {
234
234
  utils_1.log.error('没有检测到需要发布的环境,无法完成上传,请切换到dev/sit/uat/pre/master分支再次执行脚本,或者您可以选择手动上传!');
235
235
  }
236
236
  const isHotUpdate = opts.pull && config_1.CONFIG_DATA.publish?.updateMode == 2;
@@ -26,7 +26,7 @@ async function publish(options) {
26
26
  const pkg = (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {};
27
27
  const versionName = options.versionName;
28
28
  const versionCode = (0, function_1.getEnvVersionCode)() || options.versionCode;
29
- const bucket = `${buildEnv === 'prod' ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket ?? ''}`;
29
+ const bucket = `${buildEnv.startsWith('pro') ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket ?? ''}`;
30
30
  const region = config_1.CONFIG_DATA.cos?.region ?? '';
31
31
  const secretId = config_1.CONFIG_DATA.cos?.secretid ?? '';
32
32
  const secretKey = config_1.CONFIG_DATA.cos?.secretkey ?? '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
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": "4c2eb5b872c3a70e3b89e7ed96259a5b62c1bdd8"
62
+ "gitHead": "8a591baa3f70e74c76989b15cec93d34b4734d0d"
63
63
  }