@gmcb/cli 0.9.11 → 0.9.13

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,18 @@
2
2
 
3
3
  <!-- release:insert -->
4
4
 
5
+ ## 0.9.13 [2026-11-16]
6
+ <!-- generated-by: specs -->
7
+ ### 优化
8
+ - H5 zip 默认不再包含 appId 目录;仅在 `package.json.appId` 存在时保留该目录,并在压缩包 `manifest.json` 中写入 `appid`,兼容存量环境。
9
+
10
+ ## 0.9.12 [2026-11-16]
11
+ <!-- generated-by: specs -->
12
+ ### 优化
13
+ - appId 优先取 `package.json.appId`,缺失时回退 `manifest.appid`;存量项目保持原行为,新项目可删除 `package.appId`,发布目录、版本接口与 H5 zip 根目录同步。
14
+ ### 破坏性变更
15
+ - HBuilderX App/H5 打包参数不再从 `package.json` 的 `appId` 自动补齐;`app.android.packagename`、`app.ios.bundle`、`app.harmony.packagename`、`h5.windows.appid`、`h5.macos.appid` 需在本地 `uni.build.json` 显式配置。
16
+
5
17
  ## 0.9.11 [2026-11-14]
6
18
  <!-- generated-by: specs -->
7
19
  ### 优化
package/README.md CHANGED
@@ -40,10 +40,12 @@ gmcb icon --source logo.png
40
40
 
41
41
  - 构建环境用 `-e <env>` 选择,默认 `prod`。
42
42
  - HBuilderX CLI 路径用 `gmcb config --cli.hbuilderx <path>` 配置。
43
- - `uni.build.json` 可配置 wgt 文件名/输出路径与发布参数。
43
+ - `uni.build.json` 可配置 wgt 文件名/输出路径与发布参数;App/H5 包名、bundle、appid(`app.android.packagename`、`app.ios.bundle`、`app.harmony.packagename`、`h5.windows.appid`、`h5.macos.appid`)需显式配置,CLI 不再从 `package.json` 的 `appId` 自动补齐。
44
+ - appId 优先取 `package.json` 的 `appId`,缺失时回退 `manifest.json` 的 `appid`;存量项目无需调整,新项目可删除 `package.json.appId`。
45
+ - H5 zip 默认不包含 appId 目录;仅 `package.json.appId` 存在时保留该目录,zip 内 `manifest.json` 会写入 `appid`。
44
46
  - 项目模板仓库与技能仓库需显式配置(无内置默认值):`gmcb config --template.repo <repo-url>`、`gmcb config --skill.repo <repo-url>`;未配置时 `gmcb create` / `gmcb skill sync` 会提示先添加。
45
47
 
46
48
  ## 文档
47
49
 
48
50
  - 操作约束与命令:[AGENTS.md](AGENTS.md)
49
- - 完整命令选项、uni-app x 兼容、平台映射与 icon/image/copy 规则:[specs/implementation.md](specs/implementation.md)
51
+ - 完整命令选项、uni-app x 兼容、平台映射与 icon/image/copy 规则:[.specs/implementation.md](.specs/implementation.md)
@@ -75,7 +75,7 @@ async function syncLatestVersion() {
75
75
  const hasPackage = (0, fs_1.existsSync)(utils_1.PACKAGE_PATH);
76
76
  const pkg = hasPackage ? (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH) : {};
77
77
  const manifest = (0, utils_1.readManifest)();
78
- const appId = pkg.appId || manifest.appid;
78
+ const appId = (0, utils_1.resolveAppId)(manifest, pkg);
79
79
  if (!appId) {
80
80
  spinner.warn('未在 package.json 或 manifest.json 中找到 appId/appid,跳过版本号同步');
81
81
  return;
@@ -288,6 +288,7 @@ async function getCommands(...args) {
288
288
  }
289
289
  function generateH5Manifest() {
290
290
  const manifest = (0, utils_1.readManifest)();
291
+ const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH, { throws: false }) || {};
291
292
  const source = (0, path_1.join)(utils_1.COMMAND_PATH, utils_1.HAS_SRC ? 'dist/build/h5' : 'unpackage/dist/build/web');
292
293
  if (!(0, fs_1.existsSync)(source)) {
293
294
  utils_1.log.warning('H5 构建输出目录不存在,跳过生成 manifest.json');
@@ -296,6 +297,7 @@ function generateH5Manifest() {
296
297
  (0, fs_extra_1.writeJsonSync)((0, path_1.join)(source, 'manifest.json'), {
297
298
  versionName: manifest['versionName'] || '',
298
299
  versionCode: manifest['versionCode'] || '',
300
+ appid: (0, utils_1.resolveAppId)(manifest, pkg),
299
301
  });
300
302
  }
301
303
  async function generatePackage(opts) {
@@ -332,13 +334,18 @@ async function generatePackage(opts) {
332
334
  defaultSource = 'dist/win-unpacked/resources';
333
335
  }
334
336
  const ext = platform?.startsWith('app') ? '.wgt' : '.zip';
335
- const name = zipConfig.name || `${manifest['appid'] || pkg.name}${ext}`;
337
+ const name = zipConfig.name || `${manifest.appid || pkg.name}${ext}`;
336
338
  const source = (0, path_1.join)(utils_1.COMMAND_PATH, zipConfig.source || defaultSource);
337
339
  dest = (0, path_1.join)(utils_1.COMMAND_PATH, `${zipConfig.path || 'unpackage/release'}/${name}`);
338
340
  if ((0, fs_1.existsSync)(dest)) {
339
341
  (0, fs_1.unlinkSync)(dest);
340
342
  }
341
- const zipRoot = compiler === 'uni' && platform === 'h5' ? pkg.appId || '' : '';
343
+ const zipRoot = compiler === 'uni' && platform === 'h5' && pkg.appId ? String(pkg.appId) : '';
344
+ if (compiler === 'uni' && platform === 'h5') {
345
+ const h5ManifestPath = (0, path_1.join)(source, 'manifest.json');
346
+ const h5Manifest = (0, fs_extra_1.readJsonSync)(h5ManifestPath, { throws: false }) || {};
347
+ (0, fs_extra_1.writeJsonSync)(h5ManifestPath, { ...h5Manifest, appid: (0, utils_1.resolveAppId)(manifest, pkg) });
348
+ }
342
349
  zip.addLocalFolder(source, zipRoot);
343
350
  zip.writeZip(dest);
344
351
  }
@@ -412,9 +419,8 @@ async function pullRemoteResources(opts) {
412
419
  const repoPkg = (0, fs_extra_1.readJsonSync)(repoPkgPath);
413
420
  if (!repoPkg.scripts)
414
421
  repoPkg.scripts = {};
415
- repoPkg.appId = appId;
416
422
  if (opts.compiler === 'electron-vite') {
417
- repoPkg.scripts['copy:h5'] = 'gmcb copy -s ./dist/build/h5 -d ../../out/renderer/{package.appId}/ --clean';
423
+ repoPkg.scripts['copy:h5'] = 'gmcb copy -s ./dist/build/h5 -d ../../out/renderer/{manifest.appid}/ --clean';
418
424
  }
419
425
  if (opts.compiler === 'gradlew') {
420
426
  if (isUniappX) {
package/lib/bin.js CHANGED
File without changes
@@ -24,13 +24,14 @@ const PUBLISH_APP_CFG = {
24
24
  async function publish(options) {
25
25
  const buildEnv = process.env.BUILD_ENV || '';
26
26
  const pkg = (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {};
27
+ const appId = (0, function_1.resolveAppId)((0, function_1.readManifest)(), pkg);
27
28
  const versionName = options.versionName;
28
29
  const versionCode = (0, function_1.getEnvVersionCode)() || options.versionCode;
29
30
  const bucket = `${buildEnv.startsWith('pro') ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket || ''}`;
30
31
  const region = config_1.CONFIG_DATA.cos?.region || '';
31
32
  const secretId = config_1.CONFIG_DATA.cos?.secretid || '';
32
33
  const secretKey = config_1.CONFIG_DATA.cos?.secretkey || '';
33
- const remotePath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || `/app/${pkg['appId'] || ''}`;
34
+ const remotePath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || `/app/${appId}`;
34
35
  const cos = new cos_nodejs_sdk_v5_1.default({
35
36
  SecretId: secretId,
36
37
  SecretKey: secretKey,
@@ -72,7 +73,7 @@ async function publish(options) {
72
73
  const cfg = isPublish ? config_1.CONFIG_DATA.publish : config_1.CONFIG_DATA.pub;
73
74
  if (isPublish) {
74
75
  await (0, apis_1.publishVersion)({
75
- appId: pkg['appId'],
76
+ appId,
76
77
  username,
77
78
  password,
78
79
  type: cfg?.type,
@@ -32,29 +32,6 @@ function getLocalConfig() {
32
32
  if ((0, fs_1.existsSync)(const_1.LOCAL_CONFIG_PATH)) {
33
33
  config = (0, fs_extra_1.readJsonSync)(const_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
34
34
  }
35
- const pkg = (0, fs_1.existsSync)(const_1.PACKAGE_PATH) ? (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {} : {};
36
- const appId = pkg.appId;
37
- if (appId) {
38
- if (!config.app)
39
- config.app = {};
40
- if (!config.app.android)
41
- config.app.android = {};
42
- if (!config.app.ios)
43
- config.app.ios = {};
44
- if (!config.app.harmony)
45
- config.app.harmony = {};
46
- if (!config.h5)
47
- config.h5 = {};
48
- if (!config.h5.windows)
49
- config.h5.windows = {};
50
- if (!config.h5.macos)
51
- config.h5.macos = {};
52
- config.app.android.packagename ||= appId;
53
- config.app.ios.bundle ||= appId;
54
- config.app.harmony.packagename ||= appId;
55
- config.h5.windows.appid ||= appId;
56
- config.h5.macos.appid ||= appId;
57
- }
58
35
  return config;
59
36
  }
60
37
  function getMergeConfig(conf = {}) {
@@ -7,6 +7,13 @@ export declare function readManifest(path: string | undefined, parse: false): st
7
7
  * @param pathOrManifest 工程目录或已解析的 manifest 对象
8
8
  */
9
9
  export declare function isUniappXManifest(pathOrManifest?: string | Record<string, unknown>): boolean;
10
+ /**
11
+ * 解析应用标识:package.json.appId 优先,缺失时回退 manifest.appid。
12
+ * 存量项目可继续使用 package.appId;新项目可删除该字段后依赖 manifest.appid。
13
+ * @param manifest manifest.json 内容
14
+ * @param pkg package.json 内容
15
+ */
16
+ export declare function resolveAppId(manifest?: Record<string, unknown>, pkg?: Record<string, any>): string;
10
17
  export declare function objectToCommand(obj?: Record<string, any>): {};
11
18
  export declare function filterToArray(obj?: Record<string, any>): any[];
12
19
  export declare function spawnSync(command?: string): import("child_process").SpawnSyncReturns<Buffer>;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getManifestPath = getManifestPath;
7
7
  exports.readManifest = readManifest;
8
8
  exports.isUniappXManifest = isUniappXManifest;
9
+ exports.resolveAppId = resolveAppId;
9
10
  exports.objectToCommand = objectToCommand;
10
11
  exports.filterToArray = filterToArray;
11
12
  exports.spawnSync = spawnSync;
@@ -44,6 +45,15 @@ function isUniappXManifest(pathOrManifest = const_1.COMMAND_PATH) {
44
45
  const manifest = typeof pathOrManifest === 'string' ? readManifest(pathOrManifest) : pathOrManifest;
45
46
  return Object.prototype.hasOwnProperty.call(manifest, 'uni-app-x');
46
47
  }
48
+ /**
49
+ * 解析应用标识:package.json.appId 优先,缺失时回退 manifest.appid。
50
+ * 存量项目可继续使用 package.appId;新项目可删除该字段后依赖 manifest.appid。
51
+ * @param manifest manifest.json 内容
52
+ * @param pkg package.json 内容
53
+ */
54
+ function resolveAppId(manifest = {}, pkg = {}) {
55
+ return String(pkg.appId || manifest.appid || '');
56
+ }
47
57
  function objectToCommand(obj = {}) {
48
58
  const object = (0, flat_1.flatten)(obj);
49
59
  const res = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "UNLICENSED",
@@ -11,10 +11,6 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "scripts": {
15
- "tsc": "vue-tsc",
16
- "tsc:dev": "vue-tsc --watch"
17
- },
18
14
  "keywords": [
19
15
  "gmcb",
20
16
  "zfqh"
@@ -58,5 +54,8 @@
58
54
  "@types/rimraf": "^4.0.5",
59
55
  "@types/user-home": "^2.0.2"
60
56
  },
61
- "gitHead": "6d73cae02f6a090c013660439f697066db426d4b"
62
- }
57
+ "scripts": {
58
+ "tsc": "vue-tsc",
59
+ "tsc:dev": "vue-tsc --watch"
60
+ }
61
+ }