@gmcb/cli 0.4.6 → 0.5.0

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,25 @@
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.5.0](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.7...@gmcb/cli@0.5.0) (2026-06-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * uni.build.json结构调整 ([4e2b3dc](http://10.10.10.16/caoben/front-end/commits/4e2b3dc10f0ad3a230a8b38f1b3704747abc9c74))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.4.7](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.6...@gmcb/cli@0.4.7) (2026-06-15)
18
+
19
+ **Note:** Version bump only for package @gmcb/cli
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.4.6](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.5...@gmcb/cli@0.4.6) (2026-06-15)
7
26
 
8
27
  **Note:** Version bump only for package @gmcb/cli
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 aniu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -25,12 +25,13 @@ npm i @gmcb/cli -g
25
25
 
26
26
  将资源从源目录复制到目标目录,支持 `{...}` 占位符自动解析:
27
27
 
28
- - `{build.*}` 取自已合并的 `uni.build.json` 配置(扁平化键),例如 `{build.app.windows.packagename}`
28
+ - `{build.*}` 取自已合并的 `uni.build.json` 配置(扁平化键),例如 `{build.h5.windows.appid}`
29
29
  - `{manifest.*}` 取自项目根目录的 `manifest.json`(扁平化键),例如 `{manifest.appid}`
30
+ - `{package.*}` 取自项目根目录的 `package.json`(扁平化键),例如 `{package.appid}`
30
31
 
31
32
  示例:
32
33
 
33
34
  ```bash
34
- gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{build.app.windows.packagename}/
35
+ gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{package.appid}/
35
36
  gmcb copy -s ./dist/build/app -d ../android/app/src/main/assets/apps/{manifest.appid}/www/
36
37
  ```
@@ -179,6 +179,18 @@ async function getCommands(...args) {
179
179
  }
180
180
  return commands;
181
181
  }
182
+ function generateH5Manifest() {
183
+ const manifest = (0, utils_1.readManifest)();
184
+ const source = (0, path_1.join)(utils_1.COMMAND_PATH, utils_1.HAS_SRC ? 'dist/build/h5' : 'unpackage/dist/build/web');
185
+ if (!(0, fs_1.existsSync)(source)) {
186
+ utils_1.log.warning('H5 构建输出目录不存在,跳过生成 manifest.json');
187
+ return;
188
+ }
189
+ (0, fs_extra_1.writeJsonSync)((0, path_1.join)(source, 'manifest.json'), {
190
+ versionName: manifest['versionName'] || '',
191
+ versionCode: manifest['versionCode'] || '',
192
+ });
193
+ }
182
194
  async function createZip(compiler, platform) {
183
195
  const spinner = (0, ora_1.default)(`正在生成资源文件...`).start();
184
196
  await (0, delay_1.default)(1000);
@@ -192,7 +204,7 @@ async function createZip(compiler, platform) {
192
204
  defaultSource = utils_1.HAS_SRC ? 'dist/build/h5' : 'unpackage/dist/build/web';
193
205
  }
194
206
  else {
195
- zipConfig = config.app?.zip || {};
207
+ zipConfig = config.h5?.zip || {};
196
208
  defaultSource = 'dist/win-unpacked/resources';
197
209
  }
198
210
  const name = zipConfig.name || `${manifest['appid'] || pkg.name}.zip`;
@@ -201,13 +213,7 @@ async function createZip(compiler, platform) {
201
213
  if ((0, fs_1.existsSync)(dest)) {
202
214
  (0, fs_1.unlinkSync)(dest);
203
215
  }
204
- if (compiler === 'uni' && platform === 'h5') {
205
- (0, fs_extra_1.writeJsonSync)((0, path_1.join)(source, 'manifest.json'), {
206
- versionName: manifest['versionName'] || '',
207
- versionCode: manifest['versionCode'] || '',
208
- });
209
- }
210
- const zipRoot = compiler === 'uni' && platform === 'h5' ? (config.app?.windows?.packagename || '') : '';
216
+ const zipRoot = compiler === 'uni' && platform === 'h5' ? (config.h5?.windows?.appid || '') : '';
211
217
  zip.addLocalFolder(source, zipRoot);
212
218
  zip.writeZip(dest);
213
219
  spinner.stop();
@@ -227,6 +233,10 @@ async function default_1(...args) {
227
233
  utils_1.log.error('检测到您的HbuilderX未启动或项目管理器中未发现构建项目,请检查后重试!');
228
234
  }
229
235
  }
236
+ // H5 构建完成后立即生成 manifest.json
237
+ if (opts.compiler === 'uni' && opts.platform === 'h5') {
238
+ generateH5Manifest();
239
+ }
230
240
  if ((opts.compiler === 'electron-vite' && opts.zip) ||
231
241
  (opts.compiler === 'uni' && opts.platform === 'h5' && opts.zip)) {
232
242
  await createZip(opts.compiler, opts.platform);
@@ -9,6 +9,9 @@ interface Cos {
9
9
  path?: string;
10
10
  }
11
11
  interface App {
12
+ harmony?: {
13
+ packagename?: string;
14
+ };
12
15
  android?: {
13
16
  packagename?: string;
14
17
  androidpacktype?: number;
@@ -23,21 +26,10 @@ interface App {
23
26
  certfile?: string;
24
27
  certpassword?: string;
25
28
  };
26
- windows?: {
27
- packagename?: string;
28
- };
29
- macos?: {
30
- packagename?: string;
31
- };
32
29
  wgt?: {
33
30
  name?: string;
34
31
  path?: string;
35
32
  };
36
- zip?: {
37
- name?: string;
38
- path?: string;
39
- source?: string;
40
- };
41
33
  custom?: App;
42
34
  }
43
35
  interface Mp {
@@ -63,6 +55,12 @@ interface Publish {
63
55
  platform?: string;
64
56
  }
65
57
  interface H5 {
58
+ windows?: {
59
+ appid?: string;
60
+ };
61
+ macos?: {
62
+ appid?: string;
63
+ };
66
64
  zip?: {
67
65
  name?: string;
68
66
  path?: string;
@@ -35,10 +35,34 @@ function getConfig() {
35
35
  return (0, fs_extra_1.readJsonSync)(utils_1.CONFIG_PATH, { throws: false }) || {};
36
36
  }
37
37
  function getLocalConfig() {
38
+ let config = {};
38
39
  if ((0, fs_1.existsSync)(utils_1.LOCAL_CONFIG_PATH)) {
39
- return (0, fs_extra_1.readJsonSync)(utils_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
40
+ config = (0, fs_extra_1.readJsonSync)(utils_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
40
41
  }
41
- return {};
42
+ const pkg = (0, fs_1.existsSync)(utils_1.PACKAGE_PATH) ? ((0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH, { throws: false }) || {}) : {};
43
+ const appid = pkg.appid;
44
+ if (appid) {
45
+ if (!config.app)
46
+ config.app = {};
47
+ if (!config.app.android)
48
+ config.app.android = {};
49
+ if (!config.app.ios)
50
+ config.app.ios = {};
51
+ if (!config.app.harmony)
52
+ config.app.harmony = {};
53
+ if (!config.h5)
54
+ config.h5 = {};
55
+ if (!config.h5.windows)
56
+ config.h5.windows = {};
57
+ if (!config.h5.macos)
58
+ config.h5.macos = {};
59
+ config.app.android.packagename ??= appid;
60
+ config.app.ios.bundle ??= appid;
61
+ config.app.harmony.packagename ??= appid;
62
+ config.h5.windows.appid ??= appid;
63
+ config.h5.macos.appid ??= appid;
64
+ }
65
+ return config;
42
66
  }
43
67
  function getMergeConfig() {
44
68
  return (0, lodash_1.merge)({}, getConfig(), getLocalConfig());
@@ -23,12 +23,16 @@ async function default_1(...args) {
23
23
  const data = {};
24
24
  const flatConfig = (0, flat_1.flatten)((0, config_1.getMergeConfig)());
25
25
  const flatManifest = (0, flat_1.flatten)((0, utils_1.readManifest)());
26
+ const flatPackage = (0, flat_1.flatten)((0, fs_1.existsSync)(utils_1.PACKAGE_PATH) ? ((0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH, { throws: false }) || {}) : {});
26
27
  Object.keys(flatConfig).forEach((k) => {
27
28
  data[`build.${k}`] = flatConfig[k];
28
29
  });
29
30
  Object.keys(flatManifest).forEach((k) => {
30
31
  data[`manifest.${k}`] = flatManifest[k];
31
32
  });
33
+ Object.keys(flatPackage).forEach((k) => {
34
+ data[`package.${k}`] = flatPackage[k];
35
+ });
32
36
  const resolvedSource = (0, utils_1.resolvePlaceholder)(opts.source, data);
33
37
  const resolvedDest = (0, utils_1.resolvePlaceholder)(opts.dest, data);
34
38
  const sourcePath = (0, path_1.join)(utils_1.COMMAND_PATH, resolvedSource);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -53,5 +53,6 @@
53
53
  "@types/inquirer": "^9.0.7",
54
54
  "@types/rimraf": "^4.0.5",
55
55
  "@types/user-home": "^2.0.2"
56
- }
56
+ },
57
+ "gitHead": "157b2a8fd65346813e9995b40212b8568e2197e1"
57
58
  }
package/schema.json CHANGED
@@ -125,30 +125,7 @@
125
125
  "type": "string",
126
126
  "description": "包名"
127
127
  }
128
- },
129
- "required": ["packagename"]
130
- },
131
- "windows": {
132
- "type": "object",
133
- "description": "windows配置",
134
- "properties": {
135
- "packagename": {
136
- "type": "string",
137
- "description": "包名"
138
- }
139
- },
140
- "required": ["packagename"]
141
- },
142
- "macos": {
143
- "type": "object",
144
- "description": "macos配置",
145
- "properties": {
146
- "packagename": {
147
- "type": "string",
148
- "description": "包名"
149
- }
150
- },
151
- "required": ["packagename"]
128
+ }
152
129
  },
153
130
  "android": {
154
131
  "type": "object",
@@ -175,7 +152,7 @@
175
152
  "description": "打包证书密码"
176
153
  }
177
154
  },
178
- "required": ["packagename", "androidpacktype", "certalias", "certfile", "certpassword"]
155
+ "required": ["androidpacktype", "certalias", "certfile", "certpassword"]
179
156
  },
180
157
  "ios": {
181
158
  "type": "object",
@@ -202,7 +179,7 @@
202
179
  "description": "使用自定义证书打包的证书密码"
203
180
  }
204
181
  },
205
- "required": ["bundle", "supporteddevice", "profile", "certfile", "certpassword"]
182
+ "required": ["supporteddevice", "profile", "certfile", "certpassword"]
206
183
  },
207
184
  "wgt": {
208
185
  "type": "object",
@@ -218,24 +195,6 @@
218
195
  }
219
196
  }
220
197
  },
221
- "zip": {
222
- "type": "object",
223
- "description": "桌面应用热更新资源配置,仅在compiler为electron-vite且开启--zip时生效",
224
- "properties": {
225
- "name": {
226
- "type": "string",
227
- "description": "导出文件名称,例如app.zip,默认为[name].zip"
228
- },
229
- "path": {
230
- "type": "string",
231
- "description": "导出路径,默认unpackage/release"
232
- },
233
- "source": {
234
- "type": "string",
235
- "description": "资源路径,默认dist/win-unpacked/resources"
236
- }
237
- }
238
- },
239
198
  "custom": {
240
199
  "type": "object",
241
200
  "description": "自定义基座配置",
@@ -301,9 +260,29 @@
301
260
  "type": "object",
302
261
  "description": "h5配置",
303
262
  "properties": {
263
+ "windows": {
264
+ "type": "object",
265
+ "description": "windows配置",
266
+ "properties": {
267
+ "appid": {
268
+ "type": "string",
269
+ "description": "应用ID"
270
+ }
271
+ }
272
+ },
273
+ "macos": {
274
+ "type": "object",
275
+ "description": "macos配置",
276
+ "properties": {
277
+ "appid": {
278
+ "type": "string",
279
+ "description": "应用ID"
280
+ }
281
+ }
282
+ },
304
283
  "zip": {
305
284
  "type": "object",
306
- "description": "h5打包资源配置,仅在compiler为uni且platform为h5且开启--zip时生效",
285
+ "description": "打包资源配置,开启--zip时生效",
307
286
  "properties": {
308
287
  "name": {
309
288
  "type": "string",
@@ -315,7 +294,7 @@
315
294
  },
316
295
  "source": {
317
296
  "type": "string",
318
- "description": "资源路径,默认dist/build/h5(有src目录)或unpackage/dist/build/web(无src目录)"
297
+ "description": "资源路径,h5默认dist/build/h5unpackage/dist/build/web,electron-vite默认dist/win-unpacked/resources"
319
298
  }
320
299
  }
321
300
  }