@gmcb/cli 0.5.0 → 0.5.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
@@ -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.5.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.6.0...@gmcb/cli@0.5.2) (2026-06-28)
7
+
8
+ **Note:** Version bump only for package @gmcb/cli
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.5.1](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.0...@gmcb/cli@0.5.1) (2026-06-22)
15
+
16
+ **Note:** Version bump only for package @gmcb/cli
17
+
18
+
19
+
20
+
21
+
6
22
  # [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
23
 
8
24
 
package/README.md CHANGED
@@ -21,17 +21,49 @@ npm i @gmcb/cli -g
21
21
  | `gmcb skill sync` | 同步技能到本地项目 |
22
22
  | `gmcb skill list` | 列出当前项目所有技能 |
23
23
 
24
+ ## `gmcb publish`
25
+
26
+ 应用程序发布。支持以下选项:
27
+
28
+ | 选项 | 描述 |
29
+ |---|---|
30
+ | `-p, --platform` | 编译平台,默认 h5 |
31
+ | `-c, --compiler` | 构建工具,默认 uni |
32
+ | `-b, --branch` | Git 分支名称 |
33
+ | `-e, --env` | 构建环境,默认 prod |
34
+ | `--wgt` | 构建移动应用热更新资源 |
35
+ | `--res` | 构建移动应用本地资源 |
36
+ | `--zip` | 构建桌面应用热更新资源 |
37
+ | `-a, --auto` | 自动发布,跳过所有确认提示 |
38
+
39
+ 示例:
40
+
41
+ ```bash
42
+ # 交互式发布
43
+ gmcb publish -p app --wgt
44
+
45
+ # 自动发布(跳过所有确认)
46
+ gmcb publish -p app --wgt -a
47
+ ```
48
+
49
+ ### 配置
50
+
51
+ `uni.build.json` 中可配置 `pub` 和 `publish` 两个发布节:
52
+
53
+ - `pub`:基础发布配置(brand、type、status、platform、path)
54
+ - `publish`:魔方发布配置(brandName、brandId、channel、updateType、versionDesc、publishType、platform、path),配置后走魔方发布流程
55
+
24
56
  ## `gmcb copy`
25
57
 
26
58
  将资源从源目录复制到目标目录,支持 `{...}` 占位符自动解析:
27
59
 
28
60
  - `{build.*}` 取自已合并的 `uni.build.json` 配置(扁平化键),例如 `{build.h5.windows.appid}`
29
61
  - `{manifest.*}` 取自项目根目录的 `manifest.json`(扁平化键),例如 `{manifest.appid}`
30
- - `{package.*}` 取自项目根目录的 `package.json`(扁平化键),例如 `{package.appid}`
62
+ - `{package.*}` 取自项目根目录的 `package.json`(扁平化键),例如 `{package.appId}`
31
63
 
32
64
  示例:
33
65
 
34
66
  ```bash
35
- gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{package.appid}/
67
+ gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{package.appId}/
36
68
  gmcb copy -s ./dist/build/app -d ../android/app/src/main/assets/apps/{manifest.appid}/www/
37
69
  ```
@@ -54,6 +54,16 @@ interface Publish {
54
54
  status?: string;
55
55
  platform?: string;
56
56
  }
57
+ interface PublishConfig {
58
+ brandName?: string;
59
+ brandId?: string | number;
60
+ channel?: number;
61
+ updateType?: number;
62
+ versionDesc?: string;
63
+ publishType?: number;
64
+ platform?: number;
65
+ path?: string;
66
+ }
57
67
  interface H5 {
58
68
  windows?: {
59
69
  appid?: string;
@@ -80,6 +90,7 @@ export interface Config extends BaseConfig {
80
90
  mp?: Mp;
81
91
  h5?: H5;
82
92
  pub?: Publish;
93
+ publish?: PublishConfig;
83
94
  }
84
95
  export declare function getConfig(): BaseConfig;
85
96
  export declare function getLocalConfig(): Config;
@@ -40,8 +40,8 @@ function getLocalConfig() {
40
40
  config = (0, fs_extra_1.readJsonSync)(utils_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
41
41
  }
42
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) {
43
+ const appId = pkg.appId;
44
+ if (appId) {
45
45
  if (!config.app)
46
46
  config.app = {};
47
47
  if (!config.app.android)
@@ -56,11 +56,11 @@ function getLocalConfig() {
56
56
  config.h5.windows = {};
57
57
  if (!config.h5.macos)
58
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;
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
64
  }
65
65
  return config;
66
66
  }
@@ -16,102 +16,129 @@ async function default_1(...args) {
16
16
  }
17
17
  const config = (0, config_1.getMergeConfig)();
18
18
  const opts = args[0];
19
- const { start } = await inquirer_1.default.prompt({
20
- type: 'confirm',
21
- message: '您当前正在执行发布操作,是否继续?',
22
- name: 'start',
23
- default: true,
24
- });
25
- if (!start) {
26
- process.exit(1);
27
- }
28
- const pub = { platform: 0, status: 0 };
29
- if (opts.platform?.startsWith('app')) {
30
- if (!config.pub?.platform) {
31
- const { platform } = await inquirer_1.default.prompt([
32
- {
33
- type: 'list',
34
- name: 'platform',
35
- message: '请选择要发布的平台',
36
- choices: opts.wgt
37
- ? [
38
- {
39
- name: 'android',
40
- value: 1,
41
- },
42
- {
43
- name: 'ios',
44
- value: 2,
45
- },
46
- {
47
- name: 'harmony',
48
- value: 3,
49
- },
50
- ]
51
- : opts.zip
52
- ? [
53
- {
54
- name: 'windows',
55
- value: 4,
56
- },
57
- {
58
- name: 'macos',
59
- value: 5,
60
- },
61
- ]
62
- : [],
63
- },
64
- ]);
65
- pub.platform = platform;
19
+ const isPublishFlow = !!config.publish;
20
+ const isAuto = opts.auto;
21
+ const pub = { platform: 0, status: 0, updateType: 0 };
22
+ let install = true;
23
+ if (!isAuto) {
24
+ const { start } = await inquirer_1.default.prompt({
25
+ type: 'confirm',
26
+ message: '您当前正在执行发布操作,是否继续?',
27
+ name: 'start',
28
+ default: true,
29
+ });
30
+ if (!start) {
31
+ process.exit(1);
66
32
  }
67
- if (!config.pub?.status) {
68
- const { status } = await inquirer_1.default.prompt([
69
- {
70
- type: 'list',
71
- name: 'status',
72
- message: '请选择应用更新状态',
73
- choices: [
33
+ if (/^(app|h5)/.test(opts.platform)) {
34
+ if (isPublishFlow) {
35
+ // publish 流程
36
+ if (!config.publish?.platform && config.publish?.publishType == 1) {
37
+ const { platform } = await inquirer_1.default.prompt([
38
+ {
39
+ type: 'list',
40
+ name: 'platform',
41
+ message: '请选择要发布的平台',
42
+ choices: opts.wgt
43
+ ? [
44
+ { name: 'android', value: 1 },
45
+ { name: 'ios', value: 2 },
46
+ { name: 'harmony', value: 3 },
47
+ ]
48
+ : opts.zip
49
+ ? [
50
+ { name: 'windows', value: 4 },
51
+ { name: 'macos', value: 5 },
52
+ ]
53
+ : [],
54
+ },
55
+ ]);
56
+ pub.platform = platform;
57
+ }
58
+ if (!config.publish?.updateType) {
59
+ const { updateType } = await inquirer_1.default.prompt([
74
60
  {
75
- name: '强制更新',
76
- value: 4,
61
+ type: 'list',
62
+ name: 'updateType',
63
+ message: '请选择应用更新方式',
64
+ choices: [
65
+ { name: '强制更新', value: 2 },
66
+ { name: '提示升级', value: 1 },
67
+ ],
77
68
  },
69
+ ]);
70
+ pub.updateType = updateType;
71
+ }
72
+ }
73
+ else {
74
+ // pub 流程
75
+ if (!config.pub?.platform) {
76
+ const { platform } = await inquirer_1.default.prompt([
78
77
  {
79
- name: '提示升级',
80
- value: 3,
78
+ type: 'list',
79
+ name: 'platform',
80
+ message: '请选择要发布的平台',
81
+ choices: opts.wgt
82
+ ? [
83
+ { name: 'android', value: 1 },
84
+ { name: 'ios', value: 2 },
85
+ { name: 'harmony', value: 3 },
86
+ ]
87
+ : opts.zip
88
+ ? [
89
+ { name: 'windows', value: 4 },
90
+ { name: 'macos', value: 5 },
91
+ ]
92
+ : [],
81
93
  },
94
+ ]);
95
+ pub.platform = platform;
96
+ }
97
+ if (!config.pub?.status) {
98
+ const { status } = await inquirer_1.default.prompt([
82
99
  {
83
- name: '不提示升级',
84
- value: 2,
100
+ type: 'list',
101
+ name: 'status',
102
+ message: '请选择应用更新状态',
103
+ choices: [
104
+ { name: '强制更新', value: 4 },
105
+ { name: '提示升级', value: 3 },
106
+ { name: '不提示升级', value: 2 },
107
+ ],
85
108
  },
86
- ],
87
- },
88
- ]);
89
- pub.status = status;
109
+ ]);
110
+ pub.status = status;
111
+ }
112
+ }
113
+ }
114
+ const { update } = await inquirer_1.default.prompt({
115
+ type: 'confirm',
116
+ message: '是否已更新版本号?',
117
+ name: 'update',
118
+ default: true,
119
+ });
120
+ if (!update) {
121
+ process.exit(1);
122
+ }
123
+ const result = await inquirer_1.default.prompt({
124
+ type: 'confirm',
125
+ message: '是否需要安装依赖?',
126
+ name: 'install',
127
+ default: true,
128
+ });
129
+ install = result.install;
130
+ const { publish } = await inquirer_1.default.prompt({
131
+ type: 'confirm',
132
+ message: '是否确定执行发布?',
133
+ name: 'publish',
134
+ default: true,
135
+ });
136
+ if (!publish) {
137
+ process.exit(1);
90
138
  }
91
139
  }
92
- const { update } = await inquirer_1.default.prompt({
93
- type: 'confirm',
94
- message: '是否已更新版本号?',
95
- name: 'update',
96
- default: true,
97
- });
98
- if (!update) {
99
- process.exit(1);
100
- }
101
- const { install } = await inquirer_1.default.prompt({
102
- type: 'confirm',
103
- message: '是否需要安装依赖?',
104
- name: 'install',
105
- default: true,
106
- });
107
- const { publish } = await inquirer_1.default.prompt({
108
- type: 'confirm',
109
- message: '是否确定执行发布?',
110
- name: 'publish',
111
- default: true,
112
- });
113
- if (!publish) {
114
- process.exit(1);
140
+ else {
141
+ install = false;
115
142
  }
116
143
  if (install) {
117
144
  (0, utils_1.spawnSync)('npm install');
@@ -124,11 +151,21 @@ async function default_1(...args) {
124
151
  if (!['dev', 'sit', 'uat', 'pre', 'prod'].includes(commands[2].split('=')[1])) {
125
152
  utils_1.log.error('没有检测到需要发布的环境,无法完成上传,请切换到dev/sit/uat/pre/master分支再次执行脚本,或者您可以选择手动上传!');
126
153
  }
127
- if (pub.platform) {
128
- commands.push(`PUBLISH_PLATFORM=${pub.platform}`);
154
+ if (isPublishFlow) {
155
+ if (pub.updateType) {
156
+ commands.push(`UPDATE_TYPE=${pub.updateType}`);
157
+ }
158
+ if (pub.platform) {
159
+ commands.push(`PUBLISH_PLATFORM=${pub.platform}`);
160
+ }
129
161
  }
130
- if (pub.status) {
131
- commands.push(`PUBLISH_STATUS=${pub.status}`);
162
+ else {
163
+ if (pub.platform) {
164
+ commands.push(`PUBLISH_PLATFORM=${pub.platform}`);
165
+ }
166
+ if (pub.status) {
167
+ commands.push(`PUBLISH_STATUS=${pub.status}`);
168
+ }
132
169
  }
133
170
  commands.push('node');
134
171
  const scriptPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'node_modules/@gmcb/publish/lib');
package/lib/bin.js CHANGED
@@ -73,6 +73,7 @@ program
73
73
  .option(...commands_1.win)
74
74
  .option(...commands_1.mac)
75
75
  .option(...commands_1.linux)
76
+ .option(...commands_1.auto)
76
77
  .action(publish_1.default);
77
78
  program
78
79
  .command('config [name]')
@@ -20,6 +20,7 @@ export declare const zip: readonly ["--zip", "是否构建桌面应用热更新
20
20
  export declare const custom: readonly ["--custom", "是否构建自定义基座"];
21
21
  export declare const wgt: readonly ["--wgt", "是否构建移动应用热更新资源"];
22
22
  export declare const res: readonly ["--res", "是否构建移动应用本地资源"];
23
+ export declare const auto: readonly ["-a, --auto", "自动发布,跳过所有确认"];
23
24
  export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
24
25
  export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
25
26
  export declare const alipayCli: readonly ["--cli.alipay <cli-path>", "支付宝开发者工具 Cli路径"];
@@ -37,6 +38,7 @@ export interface Options {
37
38
  wgt?: boolean;
38
39
  custom?: boolean;
39
40
  res?: boolean;
41
+ auto?: boolean;
40
42
  ignore?: string;
41
43
  clean: boolean;
42
44
  source?: string;
@@ -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.res = exports.wgt = 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.auto = exports.res = exports.wgt = 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', 'h5'];
@@ -22,6 +22,7 @@ exports.zip = ['--zip', '是否构建桌面应用热更新资源'];
22
22
  exports.custom = ['--custom', '是否构建自定义基座'];
23
23
  exports.wgt = ['--wgt', '是否构建移动应用热更新资源'];
24
24
  exports.res = ['--res', '是否构建移动应用本地资源'];
25
+ exports.auto = ['-a, --auto', '自动发布,跳过所有确认'];
25
26
  exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
26
27
  exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
27
28
  exports.alipayCli = ['--cli.alipay <cli-path>', '支付宝开发者工具 Cli路径'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -54,5 +54,5 @@
54
54
  "@types/rimraf": "^4.0.5",
55
55
  "@types/user-home": "^2.0.2"
56
56
  },
57
- "gitHead": "157b2a8fd65346813e9995b40212b8568e2197e1"
57
+ "gitHead": "d8ca81d3d5d1f59be3026fe591bad4a8fd2a6b0e"
58
58
  }
package/schema.json CHANGED
@@ -58,6 +58,45 @@
58
58
  },
59
59
  "required": ["brand", "type", "path"]
60
60
  },
61
+ "publish": {
62
+ "type": "object",
63
+ "description": "魔方发布配置",
64
+ "properties": {
65
+ "brandName": {
66
+ "type": "string",
67
+ "description": "品牌全称"
68
+ },
69
+ "brandId": {
70
+ "type": ["string", "number"],
71
+ "description": "品牌ID"
72
+ },
73
+ "channel": {
74
+ "type": "number",
75
+ "description": "渠道类型"
76
+ },
77
+ "updateType": {
78
+ "type": "number",
79
+ "description": "更新方式"
80
+ },
81
+ "versionDesc": {
82
+ "type": "string",
83
+ "description": "版本描述"
84
+ },
85
+ "publishType": {
86
+ "type": "number",
87
+ "description": "发布类型"
88
+ },
89
+ "platform": {
90
+ "type": "number",
91
+ "description": "平台类型,1:android、2:ios、3:harmonyos、4:windows、5:macos"
92
+ },
93
+ "path": {
94
+ "type": "string",
95
+ "description": "远程路径"
96
+ }
97
+ },
98
+ "required": ["path", "publishType"]
99
+ },
61
100
  "cos": {
62
101
  "type": "object",
63
102
  "description": "腾讯云对象存储配置",