@gmcb/cli 0.8.0 → 0.8.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.8.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.1...@gmcb/cli@0.8.2) (2026-07-15)
7
+
8
+ **Note:** Version bump only for package @gmcb/cli
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.8.1](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.0...@gmcb/cli@0.8.1) (2026-07-14)
15
+
16
+ **Note:** Version bump only for package @gmcb/cli
17
+
18
+
19
+
20
+
21
+
6
22
  # [0.8.0](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.7.12...@gmcb/cli@0.8.0) (2026-07-14)
7
23
 
8
24
 
package/README.md CHANGED
@@ -93,7 +93,7 @@ gmcb publish -p app --wgt -a
93
93
  - `auto`:是否自动发布,跳过所有确认提示。支持 `true` / `1`(自动发布)或 `false` / `0` / 不传(交互确认)。CLI 传入 `--auto` 时会覆盖此配置
94
94
  - `install`:安装依赖的命令,默认为 `npm install`,可配置为 `pnpm install`、`yarn` 等
95
95
  - `pub`:基础发布配置(brand、type、status、platform、path)
96
- - `publish`:魔方发布配置(brandName、brandId、channel、updateType、versionDesc、publishType、platform、path),配置后走魔方发布流程
96
+ - `publish`:魔方发布配置(updateType、versionDesc、publishType、platform、path),配置后走魔方发布流程
97
97
 
98
98
  ## `gmcb icon`
99
99
 
@@ -273,15 +273,10 @@ async function fetchRemoteResources(opts) {
273
273
  // 查询版本数据,更新 package.json
274
274
  const appIdPkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
275
275
  const appId = appIdPkg.appId;
276
- const { versionName, versionCode, brandId } = await (0, apis_1.fetchLatestVersion)({
276
+ const { versionName, versionCode } = await (0, apis_1.fetchLatestVersion)({
277
277
  appId,
278
- brandId: config_1.CONFIG_DATA.publish?.brandId,
279
- brandName: config_1.CONFIG_DATA.publish?.brandName,
280
278
  platform: config_1.CONFIG_DATA.publish?.platform,
281
279
  });
282
- if (brandId) {
283
- config_1.CONFIG_DATA.publish.brandId = brandId;
284
- }
285
280
  if (versionName && versionCode) {
286
281
  let pkgContent = (0, fs_1.readFileSync)(utils_1.PACKAGE_PATH, 'utf-8');
287
282
  pkgContent = pkgContent.replace(/"version"\s*:\s*"[^"]*"/, `"version": "${versionName}"`);
@@ -9,6 +9,10 @@ async function default_1(opts) {
9
9
  utils_1.log.error('请使用 -s 或 --source 设置源图片路径');
10
10
  return;
11
11
  }
12
+ if ((0, path_1.extname)(opts.source).toLowerCase() !== '.png') {
13
+ utils_1.log.error('源文件必须为 .png 格式');
14
+ return;
15
+ }
12
16
  const sourcePath = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.source);
13
17
  const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest ?? '.');
14
18
  const radius = parseInt(opts.radius ?? '16', 10);
@@ -20,22 +24,19 @@ async function default_1(opts) {
20
24
  (0, fs_1.mkdirSync)(destDir, { recursive: true });
21
25
  }
22
26
  const nameWithoutExt = (0, path_1.basename)(sourcePath, (0, path_1.extname)(sourcePath));
23
- // 生成各尺寸的带圆角 PNG
24
- const pngBuffers = await (0, utils_1.generateRoundedPngs)(sourcePath, utils_1.ICO_SIZES, radius);
27
+ // 始终输出原尺寸的圆角 PNG
28
+ const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, radius);
29
+ const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}.png`);
30
+ (0, fs_1.writeFileSync)(pngPath, roundedPng);
31
+ const pngKb = (roundedPng.length / 1024).toFixed(1);
32
+ console.log(`圆角 PNG 生成完成: ${pngPath} (${pngKb} KB)`);
33
+ // 传 --ico 时额外生成 ICO 文件
25
34
  if (opts.ico) {
26
- // 打包为 ICO 格式
35
+ const pngBuffers = await (0, utils_1.generateRoundedPngs)(sourcePath, utils_1.ICO_SIZES, radius);
27
36
  const icoBuffer = (0, utils_1.packIcoBuffer)(pngBuffers);
28
37
  const icoPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}.ico`);
29
38
  (0, fs_1.writeFileSync)(icoPath, icoBuffer);
30
- const kb = (icoBuffer.length / 1024).toFixed(1);
31
- console.log(`ICO 生成完成: ${icoPath} (${kb} KB, sizes: ${utils_1.ICO_SIZES.join(', ')})`);
32
- }
33
- else {
34
- // 仅输出各尺寸 PNG
35
- for (const { size, data } of pngBuffers) {
36
- const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}-${size}.png`);
37
- (0, fs_1.writeFileSync)(pngPath, data);
38
- console.log(`PNG 生成完成: ${pngPath}`);
39
- }
39
+ const icoKb = (icoBuffer.length / 1024).toFixed(1);
40
+ console.log(`ICO 生成完成: ${icoPath} (${icoKb} KB, sizes: ${utils_1.ICO_SIZES.join(', ')})`);
40
41
  }
41
42
  }
@@ -60,7 +60,6 @@ export declare function postVersion(data: any): Promise<{
60
60
  export declare function getVersionPage(params: {
61
61
  appId: string;
62
62
  publishType: number;
63
- brandId?: number | string;
64
63
  platform?: number;
65
64
  pageNo?: number;
66
65
  pageSize?: number;
@@ -84,15 +83,18 @@ export declare function getAppPage(params: {
84
83
  /**
85
84
  * 查询版本历史
86
85
  */
87
- export declare function getVersionHistory(params: Record<string, any>): Promise<{
86
+ export declare function getVersionHistory(params: {
87
+ publishType: number;
88
+ appMofangId: string;
89
+ pageNo?: number;
90
+ pageSize?: number;
91
+ }): Promise<{
88
92
  code?: number;
89
93
  data?: any;
90
94
  msg?: string;
91
95
  }>;
92
96
  export interface VersionParams {
93
97
  brand?: string;
94
- brandId?: string;
95
- brandName?: string;
96
98
  appId?: string;
97
99
  username?: string;
98
100
  password?: string;
@@ -103,7 +105,6 @@ export interface VersionParams {
103
105
  remoteUrl?: string | string[];
104
106
  versionName?: string;
105
107
  versionCode?: string | number;
106
- channel?: string | number;
107
108
  updateType?: number | string;
108
109
  updateMode?: number | string;
109
110
  versionDesc?: string;
@@ -122,13 +123,10 @@ export declare function publishVersion(params: VersionParams): Promise<void>;
122
123
  */
123
124
  export declare function fetchLatestVersion(params: {
124
125
  appId: string;
125
- brandId?: string;
126
- brandName?: string;
127
126
  platform?: number;
128
127
  }): Promise<{
129
128
  versionName: any;
130
129
  versionCode: number;
131
- brandId: string;
132
130
  }>;
133
131
  /**
134
132
  * 获取应用信息(自动登录)
package/lib/apis/index.js CHANGED
@@ -122,14 +122,13 @@ async function uploadVersion(params) {
122
122
  */
123
123
  async function publishVersion(params) {
124
124
  try {
125
- const { brandName, brandId, appId, remoteUrl, versionName, versionCode, channel, versionDesc, platform, ...rest } = params;
125
+ const { appId, remoteUrl, versionName, versionCode, versionDesc, platform, ...rest } = params;
126
126
  const publishType = Number(rest.publishType || 3);
127
127
  const updateType = Number(rest.updateType || 2);
128
128
  const updateMode = Number(rest.updateMode || 0);
129
129
  await ensureLoggedIn();
130
130
  const pageParams = { appId, publishType, pageNo: 1, pageSize: 1 };
131
131
  if (publishType == 1) {
132
- pageParams.brandId = config_1.CONFIG_DATA.publish?.brandId;
133
132
  pageParams.platform = platform;
134
133
  }
135
134
  const { data: pageData } = await getVersionPage(pageParams);
@@ -138,21 +137,10 @@ async function publishVersion(params) {
138
137
  let latest;
139
138
  const firstPage = pageList[0];
140
139
  if (firstPage) {
141
- let historyParams;
142
- if (firstPage.publishType == 1) {
143
- historyParams = {
144
- publishType: firstPage.publishType,
145
- appName: firstPage.appName,
146
- channelType: firstPage.channelType,
147
- platformType: firstPage.platformType,
148
- };
149
- }
150
- else {
151
- historyParams = {
152
- publishType,
153
- appMofangId: firstPage.appMofangId,
154
- };
155
- }
140
+ const historyParams = {
141
+ publishType: firstPage.publishType,
142
+ appMofangId: firstPage.appMofangId,
143
+ };
156
144
  const { data: historyData } = await getVersionHistory({ ...historyParams, pageNo: 1, pageSize: 1 });
157
145
  latest = (Array.isArray(historyData) ? historyData : historyData?.list)?.[0];
158
146
  }
@@ -164,50 +152,22 @@ async function publishVersion(params) {
164
152
  versionId = existingVersion.id;
165
153
  }
166
154
  else {
167
- let createData;
168
155
  const { data: appList } = await getAppList();
169
156
  const appItem = appList?.find((item) => item.appId === appId);
170
- if (publishType == 1) {
171
- let resolvedBrandId = config_1.CONFIG_DATA.publish?.brandId || brandId;
172
- if (!resolvedBrandId && brandName) {
173
- const { data: brandList } = await getBrandList();
174
- const matched = brandList?.find(({ name, id }) => {
175
- return Number(id) > 10000 && name === brandName;
176
- });
177
- resolvedBrandId = matched?.id;
178
- }
179
- createData = {
180
- brandId: resolvedBrandId,
181
- appName: appItem?.name,
182
- channelType: const_1.CHANNEL_TYPE[channel],
157
+ const createData = {
158
+ appId,
159
+ appMofangId: appItem?.id,
160
+ appName: appItem?.name,
161
+ updateType,
162
+ updateMode,
163
+ versionName,
164
+ versionNum: versionCode,
165
+ versionDesc: versionDesc || '修复一些已知问题',
166
+ publishType,
167
+ ...(publishType == 1 && {
183
168
  platformType: const_1.PLATFORM_TYPE[platform],
184
- updateType,
185
- updateMode,
186
- versionName,
187
- versionNum: versionCode,
188
- versionDesc: versionDesc || '修复一些已知问题',
189
- fullPackageUrl: '',
190
- fullPackageFileName: '',
191
- resourcePackageUrl: '',
192
- resourcePackageFileName: '',
193
- publishType,
194
- };
195
- }
196
- else {
197
- createData = {
198
- appId,
199
- appMofangId: appItem?.id,
200
- appName: appItem?.name,
201
- updateType,
202
- updateMode,
203
- versionName,
204
- versionNum: versionCode,
205
- versionDesc: versionDesc || '修复一些已知问题',
206
- resourcePackageUrl: '',
207
- resourcePackageFileName: '',
208
- publishType,
209
- };
210
- }
169
+ }),
170
+ };
211
171
  const { data: newId } = await createVersion(createData);
212
172
  versionId = newId;
213
173
  }
@@ -243,20 +203,11 @@ async function publishVersion(params) {
243
203
  * 获取最新版本信息(自动登录)
244
204
  */
245
205
  async function fetchLatestVersion(params) {
246
- const { appId, brandId, brandName, platform } = params;
206
+ const { appId, platform } = params;
247
207
  await ensureLoggedIn();
248
- let resolvedBrandId = brandId;
249
- if (!resolvedBrandId && brandName) {
250
- const { data: brandList } = await getBrandList();
251
- const matched = brandList?.find(({ name, id }) => {
252
- return Number(id) > 10000 && name === brandName;
253
- });
254
- resolvedBrandId = matched?.id;
255
- }
256
208
  const { data: versionPage } = await getVersionPage({
257
209
  appId,
258
210
  publishType: 1,
259
- brandId: resolvedBrandId,
260
211
  platform,
261
212
  pageNo: 1,
262
213
  pageSize: 1,
@@ -266,7 +217,6 @@ async function fetchLatestVersion(params) {
266
217
  return {
267
218
  versionName: latestVersion?.versionName ?? '',
268
219
  versionCode: Number(latestVersion?.versionNum ?? 0),
269
- brandId: resolvedBrandId ?? '',
270
220
  };
271
221
  }
272
222
  /**
@@ -71,8 +71,6 @@ async function publish(options) {
71
71
  const cfg = isPublish ? config_1.CONFIG_DATA.publish : config_1.CONFIG_DATA.pub;
72
72
  if (isPublish) {
73
73
  await (0, apis_1.publishVersion)({
74
- brandName: cfg?.brandName,
75
- brandId: cfg?.brandId,
76
74
  appId: pkg['appId'],
77
75
  username,
78
76
  password,
@@ -82,7 +80,6 @@ async function publish(options) {
82
80
  remoteUrl: remoteUrls.length === 1 ? remoteUrls[0] : remoteUrls,
83
81
  versionName: versionName,
84
82
  versionCode: versionCode,
85
- channel: cfg?.channel,
86
83
  updateType: cfg?.updateType,
87
84
  updateMode: cfg?.updateMode,
88
85
  versionDesc: cfg?.versionDesc,
@@ -62,9 +62,6 @@ interface Publish {
62
62
  platform?: number;
63
63
  }
64
64
  interface PublishConfig {
65
- brandName?: string;
66
- brandId?: string;
67
- channel?: number;
68
65
  updateType?: number;
69
66
  updateMode?: number;
70
67
  versionDesc?: string;
@@ -1,4 +1,10 @@
1
1
  export declare const ICO_SIZES: number[];
2
+ /**
3
+ * 生成单张原尺寸的带圆角 PNG Buffer(不缩放,保留原始尺寸)
4
+ * @param srcPath 源图片路径
5
+ * @param radius 圆角半径
6
+ */
7
+ export declare function generateRoundedPng(srcPath: string, radius: number): Promise<Buffer>;
2
8
  /**
3
9
  * 生成各尺寸带圆角的 PNG Buffer
4
10
  * @param srcPath 源图片路径
@@ -4,12 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ICO_SIZES = void 0;
7
+ exports.generateRoundedPng = generateRoundedPng;
7
8
  exports.generateRoundedPngs = generateRoundedPngs;
8
9
  exports.packIcoBuffer = packIcoBuffer;
9
10
  exports.png2ico = png2ico;
10
11
  const sharp_1 = __importDefault(require("sharp"));
11
12
  const fs_1 = require("fs");
12
13
  exports.ICO_SIZES = [16, 24, 32, 48, 64, 128, 256];
14
+ /**
15
+ * 生成单张原尺寸的带圆角 PNG Buffer(不缩放,保留原始尺寸)
16
+ * @param srcPath 源图片路径
17
+ * @param radius 圆角半径
18
+ */
19
+ async function generateRoundedPng(srcPath, radius) {
20
+ const { width, height } = await (0, sharp_1.default)(srcPath).metadata();
21
+ const w = width ?? 0;
22
+ const h = height ?? 0;
23
+ const mask = Buffer.from(`<svg><rect x="0" y="0" width="${w}" height="${h}" rx="${radius}" ry="${radius}" fill="white"/></svg>`);
24
+ return (0, sharp_1.default)(srcPath).composite([{ input: mask, blend: 'dest-in' }]).png().toBuffer();
25
+ }
13
26
  /**
14
27
  * 生成各尺寸带圆角的 PNG Buffer
15
28
  * @param srcPath 源图片路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -59,5 +59,5 @@
59
59
  "@types/rimraf": "^4.0.5",
60
60
  "@types/user-home": "^2.0.2"
61
61
  },
62
- "gitHead": "a899a5c6c8a29b67811d87f27f632c0812650988"
62
+ "gitHead": "2db6e52d994781c86d7efdd15423f32c18001d4d"
63
63
  }
package/schema.json CHANGED
@@ -80,18 +80,6 @@
80
80
  "type": "object",
81
81
  "description": "魔方发布配置",
82
82
  "properties": {
83
- "brandName": {
84
- "type": "string",
85
- "description": "品牌全称"
86
- },
87
- "brandId": {
88
- "type": ["string"],
89
- "description": "品牌ID"
90
- },
91
- "channel": {
92
- "type": "number",
93
- "description": "渠道类型"
94
- },
95
83
  "updateMode": {
96
84
  "type": "number",
97
85
  "description": "更新方式"