@gmcb/cli 0.9.6 → 0.9.8

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,15 +3,7 @@
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.9.6](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.5...@gmcb/cli@0.9.6) (2026-11-04)
7
-
8
- **Note:** Version bump only for package @gmcb/cli
9
-
10
-
11
-
12
-
13
-
14
- ## [0.9.5](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.4...@gmcb/cli@0.9.5) (2026-11-04)
6
+ ## [0.9.8](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.7...@gmcb/cli@0.9.8) (2026-11-09)
15
7
 
16
8
  **Note:** Version bump only for package @gmcb/cli
17
9
 
@@ -20,6 +12,31 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
20
12
 
21
13
 
22
14
 
15
+ ## [0.9.7](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.6...@gmcb/cli@0.9.7) (2026-11-05)
16
+
17
+ **Note:** Version bump only for package @gmcb/cli
18
+
19
+
20
+
21
+
22
+
23
+ ## [0.9.6](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.5...@gmcb/cli@0.9.6) (2026-11-04)
24
+
25
+ **Note:** Version bump only for package @gmcb/cli
26
+
27
+
28
+
29
+
30
+
31
+ ## [0.9.5](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.4...@gmcb/cli@0.9.5) (2026-11-04)
32
+
33
+ **Note:** Version bump only for package @gmcb/cli
34
+
35
+
36
+
37
+
38
+
39
+
23
40
  ## [0.9.4](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/cli@0.9.3...@gmcb/cli@0.9.4) (2026-11-04)
24
41
 
25
42
  **Note:** Version bump only for package @gmcb/cli
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gmcb/cli
2
2
 
3
- 工茂草本前端命令行工具
3
+ 工茂草本前端命令行工具:创建、开发、构建、发布、资源复制、图标/启动图与技能同步。
4
4
 
5
5
  ## 安装
6
6
 
@@ -8,249 +8,41 @@
8
8
  npm i @gmcb/cli -g
9
9
  ```
10
10
 
11
- ## 命令总览
11
+ ## 命令
12
12
 
13
- | 命令 | 描述 |
14
- |---|---|
15
- | `gmcb create` | 创建项目框架 |
16
- | `gmcb dev` | 应用程序开发 |
17
- | `gmcb build` | 应用程序构建 |
18
- | `gmcb publish` | 应用程序发布 |
19
- | `gmcb copy` | 复制资源到指定目录 |
20
- | `gmcb config` | 配置管理 |
21
- | `gmcb icon` | 生成应用图标(圆角 PNG / ICO) |
22
- | `gmcb image` | 按 LOGO 生成启动图(白底 + 可选 9-patch 边框) |
23
- | `gmcb skill sync` | 同步技能到本地项目 |
24
- | `gmcb skill list` | 列出当前项目所有技能 |
13
+ | 命令 | 描述 |
14
+ | ------------------------------------- | ---------------------------------------------- |
15
+ | `gmcb create` | 创建项目框架 |
16
+ | `gmcb dev` | 应用程序开发 |
17
+ | `gmcb build` | 应用程序构建 |
18
+ | `gmcb publish` | 应用程序发布 |
19
+ | `gmcb copy` | 复制资源到指定目录 |
20
+ | `gmcb config` | 配置管理 |
21
+ | `gmcb icon` | 生成应用图标(圆角 PNG / ICO) |
22
+ | `gmcb image` | 按 LOGO 生成启动图(白底 + 可选 9-patch 边框) |
23
+ | `gmcb skill sync` / `gmcb skill list` | 同步 / 列出项目技能 |
25
24
 
26
- ## `gmcb build`
27
-
28
- 应用程序构建。支持以下选项:
29
-
30
- | 选项 | 描述 |
31
- |---|---|
32
- | `-p, --platform` | 编译平台,默认 h5(`web` 为 h5 的别名,HBuilderX 5.x 平台名) |
33
- | `-c, --compiler` | 构建工具,默认 uni |
34
- | `-b, --branch` | Git 分支名称 |
35
- | `-e, --env` | 构建环境,默认 prod |
36
- | `--wgt` | 构建移动应用热更新资源 |
37
- | `--res` | 构建移动应用本地资源(uni-app x 导出 appResource) |
38
- | `--zip` | 构建桌面应用热更新资源 |
39
- | `--apk` | 构建 Android 应用 |
40
- | `--nobuild` | 跳过构建步骤,仅执行后续流程(打包、远程资源拉取等) |
41
-
42
- 使用 `--wgt` 构建移动应用热更新资源时,经典 uni-app 会先通过 vite/uni 正常构建 app,再将构建产物(`dist/build/app` 或 `unpackage/dist/build/app-plus`)打包为 `.wgt` 文件,输出路径默认为 `unpackage/release`;uni-app x 的 wgt 由 HBuilderX 直接导出(见「uni-app x 兼容」)。
43
-
44
- `gmcb build` 与 `gmcb publish` 的 `-p web` 等价 `-p h5`:`web` 是 HBuilderX 5.x 的平台名,CLI 会在构建/发布前统一归一化为 `h5`,经典 uni-app 与 uni-app x 行为一致。
45
-
46
- `uni.build.json` 中可通过 `app.wgt` 配置导出文件名和路径:
47
-
48
- ```json
49
- {
50
- "app": {
51
- "wgt": {
52
- "name": "app.wgt",
53
- "path": "unpackage/release"
54
- }
55
- }
56
- }
57
- ```
58
-
59
- 示例:
60
-
61
- ```bash
62
- # 构建 app 并打包 wgt
63
- gmcb build -p app --wgt
64
- ```
65
-
66
- ## `gmcb publish`
67
-
68
- 应用程序发布。支持以下选项:
69
-
70
- | 选项 | 描述 |
71
- |---|---|
72
- | `-p, --platform` | 编译平台,默认 h5(`web` 为 h5 的别名) |
73
- | `-c, --compiler` | 构建工具,默认 uni |
74
- | `-b, --branch` | Git 分支名称 |
75
- | `-e, --env` | 构建环境,默认 prod |
76
- | `--wgt` | 构建移动应用热更新资源 |
77
- | `--res` | 构建移动应用本地资源 |
78
- | `--zip` | 构建桌面应用热更新资源 |
79
- | `--apk` | 构建 Android 应用 |
80
- | `-a, --auto` | 自动发布,跳过所有确认提示 |
81
- | `--nobuild` | 跳过构建步骤,仅执行后续流程(打包、远程资源拉取等) |
82
-
83
- 示例:
84
-
85
- ```bash
86
- # 交互式发布
87
- gmcb publish -p app --wgt
88
-
89
- # 自动发布(跳过所有确认)
90
- gmcb publish -p app --wgt -a
91
- ```
92
-
93
- ### 配置
94
-
95
- `uni.build.json` 中可配置以下字段:
96
-
97
- - `auto`:是否自动发布,跳过所有确认提示。支持 `true` / `1`(自动发布)或 `false` / `0` / 不传(交互确认)。CLI 传入 `--auto` 时会覆盖此配置
98
- - `install`:安装依赖的命令,默认为 `npm install`,可配置为 `pnpm install`、`yarn` 等
99
- - `pub`:基础发布配置(brand、type、status、platform、path)
100
- - `publish`:魔方发布配置(updateType、versionDesc、publishType、platform、path),配置后走魔方发布流程
101
-
102
- ## uni-app x 兼容
103
-
104
- `gmcb build` / `gmcb publish` 兼容 uni-app x 工程(`src` 布局与 HBuilderX 根目录布局均支持);**经典 uni-app 工程(无论有无 `src`)的打包逻辑保持不变**。uni-app x 的 App 平台一律由 HBuilderX 编译,H5 / 微信小程序保持原有的布局分流。
105
-
106
- ### 识别与前提
107
-
108
- - `src/manifest.json` 或项目根 `manifest.json` 含 `uni-app-x` 字段(如 `"uni-app-x": {}`)即识别为 uni-app x 工程
109
- - **App 平台(`app` / `app-android` / `app-ios` / `app-harmony`)始终使用 `cli.hbuilderx` 编译**:无论工程有没有 `src` 目录,都走 HBuilderX 命令:`app` 用 `publish --platform APP --type appResource|wgt`,`app-android` / `app-ios` 用 `publish --platform app-android|app-ios --type ...`,`app-harmony` 用 `publish app-harmony --type ...`;无参数打包分别走 `pack --platform ...` / `pack --platform harmony`,不需要 `--pack`
110
- - H5 / 微信小程序按布局分流:含 `src` 走本地 npm CLI(`uni build`);无 `src` 走 `cli.hbuilderx publish ...`(传 `--pack` 或 `-P` 时也走 HBuilderX)
111
- - HBuilderX 4.67+(蒸汽模式 wgt 需要 5.33+),需启动 HBuilderX 且项目已导入,CLI 路径用 `gmcb config --cli.hbuilderx <cli-path>` 配置;`src` 布局工程需在 HBuilderX 中被识别为 uni-app x(如 App 导出提示“不支持”,可在 HBuilderX 中调整项目类型)
112
-
113
- ### 平台与命令行映射(HBuilderX 编译分支)
114
-
115
- 下表为 App 平台(有无 `src` 均如此)以及无 `src`(或传 `--pack` / `-P`)时 H5 / 微信小程序实际执行的 HBuilderX 命令(App 平台按 `-p` 平台区分命令):
116
-
117
- | `-p` 平台 | 附加参数 | 执行的 HBuilderX 命令 | 输出目录 |
118
- |---|---|---|---|
119
- | `h5` / `web` | - | `publish --platform h5` | `unpackage/dist/build/web` |
120
- | `mp-weixin` | - | `publish --platform MP-WEIXIN [--appid ...]` | `unpackage/dist/build/mp-weixin` |
121
- | `app` | `--res` | `publish --platform APP --type appResource` | `unpackage/resources/app-*`(`-p app` 同时导出 app-android、app-ios) |
122
- | `app-android` / `app-ios` | `--res` | `publish --platform app-android\|app-ios --type appResource` | `unpackage/resources/app-*` |
123
- | `app` | `--wgt` | `publish --platform APP --type wgt` | `unpackage/release`(名称/路径由 `app.wgt` 配置决定) |
124
- | `app-android` / `app-ios` | `--wgt` | `publish --platform app-android\|app-ios --type wgt` | `unpackage/release`(名称/路径由 `app.wgt` 配置决定) |
125
- | `app` / `app-android` / `app-ios` | 无 | `pack --platform android,ios\|android\|ios` | 云端打包 |
126
- | `app-harmony` | `--res` / `--wgt` / 无 | `publish app-harmony --type appResource\|wgt` / `pack --platform harmony` | 以 HBuilderX 实际输出为准 |
127
-
128
- - uni-app x 的 `--wgt` 仅蒸汽模式(`manifest.json` 的 `"uni-app-x": { "vapor": true }`)支持,由 HBuilderX 校验
129
- - `--res` 产物结构随编译模式不同:VDOM 模式包含 `uniappx/app-android/src/**/*.kt` 等页面 Kotlin 源码;蒸汽模式(vapor)为 `__UNI__xxx/www/bytes/**/*.bytes` + `app-service.js`,不含 Kotlin 源码
130
- - `--wgt` 产物由 HBuilderX 导出,导出路径/文件名由 `uni.build.json` 的 `app.wgt.path` / `app.wgt.name` 控制;`gmcb publish --wgt` 上传时同样读取该配置,或直接手动上传
131
- - `mp-weixin` 的 `appid` 取 `manifest.json` 的 `mp-weixin.appid`,有值时才传 `--appid`;appid 为空时仍可编译出产物,但 HBuilderX 会尝试打开微信开发者工具并提示 appid 不存在,配置 appid 后即可正常使用;发布上传时为空会给出明确错误
132
- - 云打包的证书/包名等配置与经典 uni-app 相同(`uni.build.json` 的 `app.android` / `app.ios`)
133
- - uni-app x 的 HBuilderX 子命令按平台区分:`app` 使用 `--platform APP`,`app-android` / `app-ios` 使用 `--platform app-android|app-ios`,`app-harmony` 使用 `publish app-harmony` / `pack --platform harmony`,后续再按 HBuilderX 版本继续优化
134
- - 含 `src` 的工程执行上表 App 命令时会自动走 HBuilderX(`src` 布局的 H5 / `mp-weixin` 仍为本地 `uni build`,不会走 HBuilderX)
135
- - 完整示例见 `examples/uniapp-x`(`src` 布局的蒸汽模式工程),可直接验证下列命令
136
-
137
- ### 无 package.json 的工程
138
-
139
- uni-app x 的无 `src` 布局(HBuilderX 工程)通常没有 `package.json`,`src` 布局工程通常有:
140
-
141
- - `--latest` 从 `manifest.json` 读取并回写 `versionName` / `versionCode`,找不到 `appid` 时跳过同步
142
- - `gmcb publish` 检测不到 `package.json` 时跳过依赖安装并提示,构建命令也不再依赖 `cross-env`
143
- - 有 `package.json` 时保留原有的 `cross-env NODE_ENV=production BUILD_ENV=<env>` 前缀(与 npm script 用法一致)
144
-
145
- 示例(完整可运行示例见 `examples/uniapp-x`,以下 App 命令在含 `src` 的工程中同样会自动调用 `cli.hbuilderx`,需先导入 HBuilderX 并配置 CLI 路径):
25
+ ## 快速开始
146
26
 
147
27
  ```bash
148
- # H5 / web
28
+ # H5 构建(web 为 h5 别名)
149
29
  gmcb build -p h5
150
- gmcb build -p web
151
-
152
- # App 本地打包资源(-p app 同时导出 android/ios;app-android 只导出 Android)
153
- gmcb build -p app --res
154
- gmcb build -p app-android --res
155
-
156
- # 蒸汽模式 wgt(产物在 unpackage/release/app-android、app-ios 平台子目录)
157
- gmcb build -p app-android --wgt
158
-
159
- # H5 资源 zip(unpackage/release/<AppID>.zip)
160
- gmcb build -p h5 --zip
161
-
162
- # App 云打包
163
- gmcb build -p app-android -e prod
164
-
165
- # 微信小程序
166
- gmcb build -p mp-weixin
167
-
168
- # 鸿蒙本地打包
169
- gmcb build -p app-harmony
170
- ```
171
30
 
172
- ## `gmcb icon`
173
-
174
- 根据源图片生成带圆角的应用图标,可选输出 ICO 文件。
175
-
176
- | 选项 | 描述 |
177
- |---|---|
178
- | `-s, --source <path>` | 源图片路径(必填,支持相对/绝对路径) |
179
- | `-r, --radius <number>` | 圆角半径,默认 16 |
180
- | `--size <number>` | 输出 PNG 尺寸(宽高相同),覆盖原图,默认原尺寸 |
181
- | `--sizes <numbers>` | 输出 PNG 副本,可传一个或多个(逗号分隔),文件名为 原文件名_size |
182
- | `--ico` | 是否输出 ICO 文件 |
183
- | `-d, --dest <path>` | 输出目录,默认为当前目录 |
31
+ # App 热更新资源(uni-app x 蒸汽模式)
32
+ gmcb build -p app --wgt
184
33
 
185
- 示例:
34
+ # 自动发布(跳过确认)
35
+ gmcb publish -p app --wgt -a
186
36
 
187
- ```bash
188
- # 生成带圆角的各尺寸 PNG
37
+ # 生成圆角应用图标
189
38
  gmcb icon --source logo.png
190
-
191
- # 覆盖原图为 256x256 的圆角 PNG
192
- gmcb icon --source logo.png --size 256
193
-
194
- # 输出副本 logo_256.png,不覆盖原图
195
- gmcb icon --source logo.png --sizes 256
196
-
197
- # 一次输出多个尺寸副本 logo_64.png、logo_128.png、logo_256.png
198
- gmcb icon --source logo.png --sizes 64,128,256
199
-
200
- # 生成 ICO 文件,圆角半径 24,输出到 out 目录
201
- gmcb icon --source logo.png --radius 24 --ico --dest out
202
39
  ```
203
40
 
204
- ## `gmcb image`
205
-
206
- 按品牌 LOGO 生成启动图:默认白底、LOGO 水平居中,按画布比例计算 LOGO 尺寸,不依赖项目模板。适用于白标项目换品牌时生成/更新 `splash.9.png`。
207
-
208
- | 选项 | 描述 |
209
- |---|---|
210
- | `-s, --source <path>` | 品牌 LOGO 图片路径(必填,支持 PNG/JPG/WebP) |
211
- | `-d, --dest <dir>` | 输出目录,默认与源 LOGO 图片同目录 |
212
- | `--name <name>` | 输出文件名(不含 `.png`),默认 `splash.9`;以 `.9` 结尾生成 9-patch,否则生成普通 PNG |
213
- | `--width <px>` | 画布宽度,默认取输出目录已有启动图宽度,否则 1082 |
214
- | `--height <px>` | 画布高度,默认取输出目录已有启动图高度,否则 1884 |
215
- | `--left <px\|%>` | LOGO 左右边距(右=左,水平居中),支持 px 或百分比;默认按 1082 画布 421px 等比换算 |
216
- | `--top <px\|%>` | LOGO 距画布顶部距离,支持 px 或百分比;默认按 1884 画布 451px 等比换算 |
217
- | `--bg <color>` | 背景色,默认 `#ffffff` |
218
-
219
- 规则说明:
220
-
221
- - LOGO 尺寸不单独设置:可见宽度 = `画布宽 - 2 × left`,高度按 LOGO 内容宽高比自动计算,不拉伸。
222
- - `--left 40%` 表示左右各留 40% 边距,LOGO 宽度为画布 20%。
223
- - 输出名以 `.9` 结尾时生成 1px 透明边框与拉伸标记(与现有 `splash.9.png` 约定一致);不带 `.9` 则输出普通 PNG。
224
- - 画布尺寸默认读取输出目录中已有的启动图(先目标文件,再 `splash.9.png`、`splash.png`)。
225
- - LOGO 建议使用透明底或与 `--bg` 同色的背景;若 LOGO 自带不透明背景色且与 `--bg` 不一致,输出会保留 LOGO 自身背景(命令会给出提示)。
226
-
227
- 示例:
228
-
229
- ```bash
230
- # uni-app 项目:直接生成/更新 static/splash.9.png
231
- gmcb image -s ./static/appIcon.png
232
-
233
- # 生成普通 PNG(无 9-patch 边框)
234
- gmcb image -s ./logo.png --name splash
41
+ - 构建环境用 `-e <env>` 选择,默认 `prod`。
42
+ - HBuilderX CLI 路径用 `gmcb config --cli.hbuilderx <path>` 配置。
43
+ - `uni.build.json` 可配置 wgt 文件名/输出路径与发布参数。
235
44
 
236
- # 左右各留 40%,LOGO 宽度为画布 20%,距顶部 20%
237
- gmcb image -s ./logo.png --left 40% --top 20%
45
+ ## 文档
238
46
 
239
- # 自定义画布与位置
240
- gmcb image -s ./logo.png --width 2050 --height 1538 --left 500 --top 200 --bg '#f7f7f7'
241
- ```
242
-
243
- ## `gmcb copy`
244
-
245
- 将资源从源目录复制到目标目录,支持 `{...}` 占位符自动解析:
246
-
247
- - `{build.*}` 取自已合并的 `uni.build.json` 配置(扁平化键),例如 `{build.h5.windows.appid}`
248
- - `{manifest.*}` 取自项目根目录的 `manifest.json`(扁平化键),例如 `{manifest.appid}`
249
- - `{package.*}` 取自项目根目录的 `package.json`(扁平化键),例如 `{package.appId}`
250
-
251
- 示例:
252
-
253
- ```bash
254
- gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{package.appId}/
255
- gmcb copy -s ./dist/build/app -d ../android/app/src/main/assets/apps/{manifest.appid}/www/
256
- ```
47
+ - 完整命令选项、uni-app x 兼容、平台映射与 icon/image/copy 规则:[AGENTS.md](AGENTS.md)
48
+ - 变更记录:[CHANGELOG.md](CHANGELOG.md)
@@ -234,7 +234,7 @@ async function getCommands(...args) {
234
234
  }
235
235
  else {
236
236
  const _platform = opts.platform.replace('app-', '');
237
- cmds = [...cmds, _platform, ...cleanFlags([...app.common, ...(app[_platform] ?? [])])];
237
+ cmds = [...cmds, _platform, ...cleanFlags([...app.common, ...(app[_platform] || [])])];
238
238
  }
239
239
  }
240
240
  }
@@ -312,11 +312,11 @@ async function generatePackage(opts) {
312
312
  let dest;
313
313
  if (compiler === 'electron-vite' && win) {
314
314
  const exeCfg = config_1.CONFIG_DATA.h5?.windows;
315
- dest = (0, path_1.join)(utils_1.COMMAND_PATH, exeCfg?.path ?? 'dist', exeCfg?.name ?? 'app-release.exe');
315
+ dest = (0, path_1.join)(utils_1.COMMAND_PATH, exeCfg?.path || 'dist', exeCfg?.name || 'app-release.exe');
316
316
  }
317
317
  else if (compiler === 'gradlew') {
318
318
  const apkCfg = config_1.CONFIG_DATA.app?.android;
319
- dest = (0, path_1.join)(utils_1.COMMAND_PATH, apkCfg?.path ?? 'app/build/outputs/apk/release', apkCfg?.name ?? 'app-release.apk');
319
+ dest = (0, path_1.join)(utils_1.COMMAND_PATH, apkCfg?.path || 'app/build/outputs/apk/release', apkCfg?.name || 'app-release.apk');
320
320
  }
321
321
  else {
322
322
  const zip = new adm_zip_1.default();
@@ -338,8 +338,8 @@ async function generatePackage(opts) {
338
338
  }
339
339
  const ext = platform?.startsWith('app') ? '.wgt' : '.zip';
340
340
  const name = zipConfig.name || `${manifest['appid'] || pkg.name}${ext}`;
341
- const source = (0, path_1.join)(utils_1.COMMAND_PATH, zipConfig.source ?? defaultSource);
342
- dest = (0, path_1.join)(utils_1.COMMAND_PATH, `${zipConfig.path ?? 'unpackage/release'}/${name}`);
341
+ const source = (0, path_1.join)(utils_1.COMMAND_PATH, zipConfig.source || defaultSource);
342
+ dest = (0, path_1.join)(utils_1.COMMAND_PATH, `${zipConfig.path || 'unpackage/release'}/${name}`);
343
343
  if ((0, fs_1.existsSync)(dest)) {
344
344
  (0, fs_1.unlinkSync)(dest);
345
345
  }
@@ -37,8 +37,6 @@ async function default_1(...args) {
37
37
  const resolvedDest = (0, utils_1.resolvePlaceholder)(opts.dest, data);
38
38
  const sourcePath = (0, path_1.join)(utils_1.COMMAND_PATH, resolvedSource);
39
39
  const destPath = (0, path_1.join)(utils_1.COMMAND_PATH, resolvedDest);
40
- const srcPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'src');
41
- const indexPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'index.html');
42
40
  let ignore = [];
43
41
  if (opts.clean) {
44
42
  (0, fs_extra_1.removeSync)(destPath);
@@ -63,8 +61,10 @@ async function default_1(...args) {
63
61
  'buildenv',
64
62
  'license',
65
63
  'readme.md',
64
+ 'agents.md',
66
65
  'vite.config.js',
67
66
  'vite.config.ts',
67
+ 'uni.build.json',
68
68
  'tsconfig.json',
69
69
  'package.json',
70
70
  'package-lock.json',
@@ -88,12 +88,5 @@ async function default_1(...args) {
88
88
  }
89
89
  }
90
90
  });
91
- if (srcPath === destPath && utils_1.COMMAND_PATH === sourcePath) {
92
- if ((0, fs_1.existsSync)(indexPath)) {
93
- (0, fs_extra_1.writeFileSync)(indexPath, (0, fs_extra_1.readFileSync)(indexPath)
94
- .toString()
95
- .replace(/(=['"])\.?(\/main\.)/i, '$1/src$2'));
96
- }
97
- }
98
91
  spinner.stop();
99
92
  }
@@ -14,8 +14,8 @@ async function default_1(opts) {
14
14
  return;
15
15
  }
16
16
  const sourcePath = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.source);
17
- const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest ?? '.');
18
- const radius = parseInt(opts.radius ?? '16', 10);
17
+ const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest || '.');
18
+ const radius = parseInt(opts.radius || '16', 10);
19
19
  if (opts.size && opts.sizes) {
20
20
  utils_1.log.error('--size 与 --sizes 不能同时使用');
21
21
  return;
@@ -18,11 +18,11 @@ async function default_1(...args) {
18
18
  if ((0, fs_1.statSync)(sourcePath).isDirectory()) {
19
19
  throw new Error(`-s/--source 需要是图片文件: ${sourcePath}`);
20
20
  }
21
- const { fileName, ninePatch } = (0, utils_1.normalizeSplashName)(opts.name ?? 'splash.9');
21
+ const { fileName, ninePatch } = (0, utils_1.normalizeSplashName)(opts.name || 'splash.9');
22
22
  if (opts.dest && /\.png$/i.test(opts.dest.trim())) {
23
23
  throw new Error('--dest 需要是输出目录(文件名请用 --name 指定)');
24
24
  }
25
- const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest ?? (0, path_1.dirname)(opts.source));
25
+ const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest || (0, path_1.dirname)(opts.source));
26
26
  if ((0, fs_1.existsSync)(destDir) && (0, fs_1.statSync)(destDir).isFile()) {
27
27
  throw new Error(`--dest 需要是目录: ${destDir}`);
28
28
  }
@@ -42,10 +42,10 @@ async function default_1(...args) {
42
42
  else {
43
43
  console.log(`参考启动图:未找到,使用默认尺寸 ${utils_1.DEFAULT_SPLASH_WIDTH}×${utils_1.DEFAULT_SPLASH_HEIGHT}`);
44
44
  }
45
- const width = opts.width ? (0, utils_1.parsePositiveInt)(opts.width, '--width') : (referenceSize?.width ?? utils_1.DEFAULT_SPLASH_WIDTH);
45
+ const width = opts.width ? (0, utils_1.parsePositiveInt)(opts.width, '--width') : referenceSize?.width || utils_1.DEFAULT_SPLASH_WIDTH;
46
46
  const height = opts.height
47
47
  ? (0, utils_1.parsePositiveInt)(opts.height, '--height')
48
- : (referenceSize?.height ?? utils_1.DEFAULT_SPLASH_HEIGHT);
48
+ : referenceSize?.height || utils_1.DEFAULT_SPLASH_HEIGHT;
49
49
  const left = opts.left ? (0, utils_1.parseLength)(opts.left, width, '--left') : (0, utils_1.defaultSplashLeft)(width);
50
50
  const top = opts.top ? (0, utils_1.parseLength)(opts.top, height, '--top') : (0, utils_1.defaultSplashTop)(height);
51
51
  const background = opts.bg ? (0, utils_1.parseHexColor)(opts.bg) : { r: 255, g: 255, b: 255, a: 255 };
@@ -6,7 +6,7 @@ const utils_1 = require("../utils");
6
6
  const config_1 = require("../utils/config");
7
7
  const config = (0, config_1.getLocalConfig)();
8
8
  const app = (opts) => {
9
- const { android: _android, ios: _ios, wgt: _wgt, custom, ...rest } = config?.app ?? {};
9
+ const { android: _android, ios: _ios, wgt: _wgt, custom, ...rest } = config?.app || {};
10
10
  if (opts.custom) {
11
11
  rest['iscustom'] = true;
12
12
  }
@@ -45,7 +45,7 @@ const app = (opts) => {
45
45
  };
46
46
  exports.app = app;
47
47
  const mp = () => {
48
- const { weixin: _weixin, alipay: _alipay, ...rest } = config?.mp ?? {};
48
+ const { weixin: _weixin, alipay: _alipay, ...rest } = config?.mp || {};
49
49
  const commonCommand = (0, utils_1.objectToCommand)(rest);
50
50
  const weixinCommand = (0, utils_1.objectToCommand)(_weixin);
51
51
  const alipayCommand = (0, utils_1.objectToCommand)(_alipay);
@@ -16,9 +16,9 @@ async function default_1() {
16
16
  }
17
17
  const project = new miniprogram_ci_1.Project({
18
18
  appid,
19
- type: config_1.CONFIG_DATA?.mp?.weixin?.type ?? 'miniProgram',
19
+ type: config_1.CONFIG_DATA?.mp?.weixin?.type || 'miniProgram',
20
20
  projectPath: (0, path_1.join)(process.cwd(), const_1.HAS_SRC ? '' : 'unpackage', 'dist/build/mp-weixin'),
21
- privateKeyPath: (0, path_1.resolve)(config_1.CONFIG_DATA?.mp?.weixin?.privatekey ?? ''),
21
+ privateKeyPath: (0, path_1.resolve)(config_1.CONFIG_DATA?.mp?.weixin?.privatekey || ''),
22
22
  ignores: ['node_modules/**/*'],
23
23
  });
24
24
  try {
@@ -26,10 +26,10 @@ 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.startsWith('pro') ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket ?? ''}`;
30
- const region = config_1.CONFIG_DATA.cos?.region ?? '';
31
- const secretId = config_1.CONFIG_DATA.cos?.secretid ?? '';
32
- const secretKey = config_1.CONFIG_DATA.cos?.secretkey ?? '';
29
+ const bucket = `${buildEnv.startsWith('pro') ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket || ''}`;
30
+ const region = config_1.CONFIG_DATA.cos?.region || '';
31
+ const secretId = config_1.CONFIG_DATA.cos?.secretid || '';
32
+ const secretKey = config_1.CONFIG_DATA.cos?.secretkey || '';
33
33
  const remotePath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || `/app/${pkg['appId'] || ''}`;
34
34
  const cos = new cos_nodejs_sdk_v5_1.default({
35
35
  SecretId: secretId,
@@ -38,8 +38,8 @@ async function publish(options) {
38
38
  const remoteUrls = [];
39
39
  for (const file of options.files) {
40
40
  const appCfg = PUBLISH_APP_CFG[file.ext];
41
- const fileName = appCfg?.name ?? `${file.name}.${file.ext}`;
42
- const filePath = (0, path_1.join)(const_1.COMMAND_PATH, appCfg?.path ?? file.path);
41
+ const fileName = appCfg?.name || `${file.name}.${file.ext}`;
42
+ const filePath = (0, path_1.join)(const_1.COMMAND_PATH, appCfg?.path || file.path);
43
43
  const destName = `${versionName}.${versionCode}.${file.ext}`;
44
44
  const path = `${remotePath}/${destName}`;
45
45
  const remoteUrl = `https://${bucket}.cos.${region}.myqcloud.com${`/${path}`.replace(/\/+/g, '/')}`;
@@ -38,7 +38,7 @@ function getLocalConfig() {
38
38
  if ((0, fs_1.existsSync)(const_1.LOCAL_CONFIG_PATH)) {
39
39
  config = (0, fs_extra_1.readJsonSync)(const_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
40
40
  }
41
- const pkg = (0, fs_1.existsSync)(const_1.PACKAGE_PATH) ? ((0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {}) : {};
41
+ const pkg = (0, fs_1.existsSync)(const_1.PACKAGE_PATH) ? (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {} : {};
42
42
  const appId = pkg.appId;
43
43
  if (appId) {
44
44
  if (!config.app)
@@ -55,11 +55,11 @@ function getLocalConfig() {
55
55
  config.h5.windows = {};
56
56
  if (!config.h5.macos)
57
57
  config.h5.macos = {};
58
- config.app.android.packagename ??= appId;
59
- config.app.ios.bundle ??= appId;
60
- config.app.harmony.packagename ??= appId;
61
- config.h5.windows.appid ??= appId;
62
- config.h5.macos.appid ??= appId;
58
+ config.app.android.packagename ||= appId;
59
+ config.app.ios.bundle ||= appId;
60
+ config.app.harmony.packagename ||= appId;
61
+ config.h5.windows.appid ||= appId;
62
+ config.h5.macos.appid ||= appId;
63
63
  }
64
64
  return config;
65
65
  }
@@ -98,7 +98,7 @@ function colorToHex(color) {
98
98
  * - 兼容传入 splash.9.png
99
99
  */
100
100
  function normalizeSplashName(value = 'splash.9') {
101
- let name = String(value ?? '').trim();
101
+ let name = String(value || '').trim();
102
102
  if (/\.png$/i.test(name)) {
103
103
  name = name.slice(0, -4);
104
104
  }
@@ -25,14 +25,17 @@ async function generateRoundedPng(srcPath, size, radius) {
25
25
  }
26
26
  else {
27
27
  const { width, height } = await (0, sharp_1.default)(srcPath).metadata();
28
- w = width ?? 0;
29
- h = height ?? 0;
28
+ w = width || 0;
29
+ h = height || 0;
30
30
  }
31
31
  const mask = Buffer.from(`<svg><rect x="0" y="0" width="${w}" height="${h}" rx="${radius}" ry="${radius}" fill="white"/></svg>`);
32
32
  const pipeline = (0, sharp_1.default)(srcPath);
33
33
  if (size)
34
34
  pipeline.resize(size, size);
35
- return pipeline.composite([{ input: mask, blend: 'dest-in' }]).png().toBuffer();
35
+ return pipeline
36
+ .composite([{ input: mask, blend: 'dest-in' }])
37
+ .png()
38
+ .toBuffer();
36
39
  }
37
40
  /**
38
41
  * 生成各尺寸带圆角的 PNG Buffer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -58,5 +58,5 @@
58
58
  "@types/rimraf": "^4.0.5",
59
59
  "@types/user-home": "^2.0.2"
60
60
  },
61
- "gitHead": "2dd2ec551cda9a22e709e05f6e3ad5803551d762"
61
+ "gitHead": "6ffb8b8188f29e8d4af167895737c9cb7bc0997f"
62
62
  }