@gmcb/cli 0.10.1 → 0.10.2

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
@@ -2,6 +2,11 @@
2
2
 
3
3
  <!-- release:insert -->
4
4
 
5
+ ## 0.10.2 [2026-11-22]
6
+ <!-- generated-by: specs -->
7
+ ### 优化
8
+ - 使用 `--latest` 构建或发布时,结束后默认还原被同步改写的 `manifest.json` / `package.json` 等主项目文件,版本号同步结果不再留在工作区;需要保留同步结果时使用新增的 `--no-restore`。
9
+
5
10
  ## 0.10.1 [2026-11-22]
6
11
  <!-- generated-by: specs -->
7
12
  ### 优化
@@ -519,7 +519,10 @@ async function default_1(...args) {
519
519
  const deferRestore = args[args.length - 1] === true;
520
520
  const commands = await getCommands(...args);
521
521
  const command = commands.join(' ');
522
- remoteBackups.clear();
522
+ // publish 的 app / h5 连续构建共用备份表,由 publish 末尾统一还原,不能在这里清空
523
+ if (!deferRestore) {
524
+ remoteBackups.clear();
525
+ }
523
526
  if (opts.latest) {
524
527
  await syncLatestVersion();
525
528
  }
@@ -552,7 +555,7 @@ async function default_1(...args) {
552
555
  }
553
556
  finally {
554
557
  if (!deferRestore) {
555
- await restoreLocalResources(!!opts.restore);
558
+ await restoreLocalResources((0, utils_1.resolveRestore)(opts));
556
559
  }
557
560
  }
558
561
  }
@@ -276,6 +276,6 @@ async function default_1(...args) {
276
276
  }
277
277
  }
278
278
  finally {
279
- await (0, build_1.restoreLocalResources)(!!opts.restore);
279
+ await (0, build_1.restoreLocalResources)((0, utils_1.resolveRestore)(opts));
280
280
  }
281
281
  }
package/lib/bin.js CHANGED
@@ -55,6 +55,7 @@ program
55
55
  .option(...commands_1.pull)
56
56
  .option(...commands_1.latest)
57
57
  .option(...commands_1.restore)
58
+ .option(...commands_1.noRestore)
58
59
  .option(...commands_1.nobuild)
59
60
  .action(build_1.default);
60
61
  program
@@ -87,6 +88,7 @@ program
87
88
  .option(...commands_1.pull)
88
89
  .option(...commands_1.latest)
89
90
  .option(...commands_1.restore)
91
+ .option(...commands_1.noRestore)
90
92
  .option(...commands_1.nobuild)
91
93
  .action(publish_1.default);
92
94
  program
@@ -25,7 +25,8 @@ export declare const apk: readonly ["--apk", "是否构建Android应用"];
25
25
  export declare const skip: readonly ["--skip", "跳过所有确认,自动发布"];
26
26
  export declare const pull: readonly ["--pull", "是否拉取远程代码构建"];
27
27
  export declare const latest: readonly ["--latest", "是否获取最新版本数据"];
28
- export declare const restore: readonly ["--restore", "构建完成后是否还原远程写入的主项目文件"];
28
+ export declare const restore: readonly ["--restore", "构建完成后还原远程写入的主项目文件(--latest 时默认开启)"];
29
+ export declare const noRestore: readonly ["--no-restore", "构建完成后不还原远程写入的主项目文件(覆盖 --latest 的默认还原)"];
29
30
  export declare const nobuild: readonly ["--nobuild", "跳过构建步骤"];
30
31
  export declare const radius: readonly ["-r, --radius <number>", "圆角半径,默认16", "16"];
31
32
  export declare const size: readonly ["--size <number>", "输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸"];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.templateRepo = exports.skillRepo = exports.cosSecretkey = exports.cosSecretid = exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.bg = exports.top = exports.left = exports.height = exports.width = exports.ico = exports.sizes = exports.size = exports.radius = exports.nobuild = exports.restore = exports.latest = exports.pull = exports.skip = exports.apk = exports.res = exports.wgt = exports.pack = exports.custom = exports.zip = exports.linux = exports.mac = exports.win = exports.link = exports.path = exports.name = exports.clean = exports.ignore = exports.dest = exports.source = exports.branch = exports.env = exports.compiler = exports.project = exports.platform = exports.template = exports.version = void 0;
3
+ exports.templateRepo = exports.skillRepo = exports.cosSecretkey = exports.cosSecretid = exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.bg = exports.top = exports.left = exports.height = exports.width = exports.ico = exports.sizes = exports.size = exports.radius = exports.nobuild = exports.noRestore = exports.restore = exports.latest = exports.pull = exports.skip = exports.apk = exports.res = exports.wgt = exports.pack = exports.custom = exports.zip = exports.linux = exports.mac = exports.win = exports.link = exports.path = exports.name = exports.clean = exports.ignore = exports.dest = exports.source = exports.branch = exports.env = exports.compiler = exports.project = exports.platform = exports.template = exports.version = void 0;
4
4
  exports.version = ['-v, --version', '输出版本号'];
5
5
  exports.template = ['-t, --template <template-name>', '模版仓库名称'];
6
6
  exports.platform = ['-p, --platform <platform-name>', '编译平台,默认h5(web 等价 h5)', 'h5'];
@@ -27,7 +27,11 @@ exports.apk = ['--apk', '是否构建Android应用'];
27
27
  exports.skip = ['--skip', '跳过所有确认,自动发布'];
28
28
  exports.pull = ['--pull', '是否拉取远程代码构建'];
29
29
  exports.latest = ['--latest', '是否获取最新版本数据'];
30
- exports.restore = ['--restore', '构建完成后是否还原远程写入的主项目文件'];
30
+ exports.restore = ['--restore', '构建完成后还原远程写入的主项目文件(--latest 时默认开启)'];
31
+ exports.noRestore = [
32
+ '--no-restore',
33
+ '构建完成后不还原远程写入的主项目文件(覆盖 --latest 的默认还原)',
34
+ ];
31
35
  exports.nobuild = ['--nobuild', '跳过构建步骤'];
32
36
  exports.radius = ['-r, --radius <number>', '圆角半径,默认16', '16'];
33
37
  exports.size = ['--size <number>', '输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸'];
@@ -19,6 +19,14 @@ export declare function resolveAppId(manifest?: Record<string, unknown>, pkg?: R
19
19
  * `app`、`h5`、`mp-*` 等非具体平台返回 0(表示需要提问或沿用配置)。
20
20
  */
21
21
  export declare function resolvePublishPlatform(platform?: string): 0 | 1 | 2 | 3;
22
+ /**
23
+ * 构建/发布结束后是否还原主项目文件:显式 `--restore` / `--no-restore` 优先,未指定时在 `--latest` 下默认还原。
24
+ * @param opts 命令选项,只读取 restore / latest
25
+ */
26
+ export declare function resolveRestore(opts?: {
27
+ restore?: boolean;
28
+ latest?: boolean;
29
+ }): boolean;
22
30
  /** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
23
31
  export declare const UNIAPPX_APP_PLATFORM_REQUIRED = "uni-app x \u7684 App \u5E73\u53F0\u672A\u786E\u5B9A\uFF1A\u8BF7\u4F7F\u7528 -p app-android / -p app-ios / -p app-harmony\uFF0C\u6216\u5728 uni.build.json \u914D\u7F6E publish.platform / pub.platform";
24
32
  /** uni-app x 的 App 平台子目录(unpackage/release、unpackage/resources 下同名目录) */
@@ -9,6 +9,7 @@ exports.readManifest = readManifest;
9
9
  exports.isUniappXManifest = isUniappXManifest;
10
10
  exports.resolveAppId = resolveAppId;
11
11
  exports.resolvePublishPlatform = resolvePublishPlatform;
12
+ exports.resolveRestore = resolveRestore;
12
13
  exports.resolveAppXPlatformDir = resolveAppXPlatformDir;
13
14
  exports.resolveAppPlatformName = resolveAppPlatformName;
14
15
  exports.resolveHBuilderXPlatform = resolveHBuilderXPlatform;
@@ -73,6 +74,13 @@ function resolvePublishPlatform(platform) {
73
74
  return 3;
74
75
  return 0;
75
76
  }
77
+ /**
78
+ * 构建/发布结束后是否还原主项目文件:显式 `--restore` / `--no-restore` 优先,未指定时在 `--latest` 下默认还原。
79
+ * @param opts 命令选项,只读取 restore / latest
80
+ */
81
+ function resolveRestore(opts = {}) {
82
+ return opts.restore ?? !!opts.latest;
83
+ }
76
84
  /** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
77
85
  exports.UNIAPPX_APP_PLATFORM_REQUIRED = 'uni-app x 的 App 平台未确定:请使用 -p app-android / -p app-ios / -p app-harmony,或在 uni.build.json 配置 publish.platform / pub.platform';
78
86
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "UNLICENSED",