@gmcb/cli 0.8.12 → 0.8.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
@@ -3,6 +3,14 @@
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.13](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.12...@gmcb/cli@0.8.13) (2026-08-17)
7
+
8
+ **Note:** Version bump only for package @gmcb/cli
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.8.12](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.11...@gmcb/cli@0.8.12) (2026-08-17)
7
15
 
8
16
  **Note:** Version bump only for package @gmcb/cli
package/README.md CHANGED
@@ -103,7 +103,8 @@ gmcb publish -p app --wgt -a
103
103
  |---|---|
104
104
  | `-s, --source <path>` | 源图片路径(必填,支持相对/绝对路径) |
105
105
  | `-r, --radius <number>` | 圆角半径,默认 16 |
106
- | `--size <number>` | 输出 PNG 尺寸(宽高相同),默认原尺寸 |
106
+ | `--size <number>` | 输出 PNG 尺寸(宽高相同),覆盖原图,默认原尺寸 |
107
+ | `--sizes <numbers>` | 输出 PNG 副本,可传一个或多个(逗号分隔),文件名为 原文件名_size |
107
108
  | `--ico` | 是否输出 ICO 文件 |
108
109
  | `-d, --dest <path>` | 输出目录,默认为当前目录 |
109
110
 
@@ -113,9 +114,15 @@ gmcb publish -p app --wgt -a
113
114
  # 生成带圆角的各尺寸 PNG
114
115
  gmcb icon --source logo.png
115
116
 
116
- # 输出 256x256 的圆角 PNG
117
+ # 覆盖原图为 256x256 的圆角 PNG
117
118
  gmcb icon --source logo.png --size 256
118
119
 
120
+ # 输出副本 logo_256.png,不覆盖原图
121
+ gmcb icon --source logo.png --sizes 256
122
+
123
+ # 一次输出多个尺寸副本 logo_64.png、logo_128.png、logo_256.png
124
+ gmcb icon --source logo.png --sizes 64,128,256
125
+
119
126
  # 生成 ICO 文件,圆角半径 24,输出到 out 目录
120
127
  gmcb icon --source logo.png --radius 24 --ico --dest out
121
128
  ```
@@ -16,11 +16,23 @@ async function default_1(opts) {
16
16
  const sourcePath = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.source);
17
17
  const destDir = (0, path_1.resolve)(utils_1.COMMAND_PATH, opts.dest ?? '.');
18
18
  const radius = parseInt(opts.radius ?? '16', 10);
19
+ if (opts.size && opts.sizes) {
20
+ utils_1.log.error('--size 与 --sizes 不能同时使用');
21
+ return;
22
+ }
19
23
  const size = opts.size ? parseInt(opts.size, 10) : undefined;
20
24
  if (opts.size && (!Number.isInteger(size) || size <= 0)) {
21
25
  utils_1.log.error('--size 必须为正整数');
22
26
  return;
23
27
  }
28
+ let sizeList;
29
+ if (opts.sizes) {
30
+ sizeList = opts.sizes.split(',').map((s) => parseInt(s.trim(), 10));
31
+ if (sizeList.some((s) => !Number.isInteger(s) || s <= 0)) {
32
+ utils_1.log.error('--sizes 必须为正整数,多个用英文逗号分隔');
33
+ return;
34
+ }
35
+ }
24
36
  if (!(0, fs_1.existsSync)(sourcePath)) {
25
37
  utils_1.log.error(`源文件不存在: ${sourcePath}`);
26
38
  return;
@@ -29,14 +41,7 @@ async function default_1(opts) {
29
41
  (0, fs_1.mkdirSync)(destDir, { recursive: true });
30
42
  }
31
43
  const nameWithoutExt = (0, path_1.basename)(sourcePath, (0, path_1.extname)(sourcePath));
32
- // 输出圆角 PNG,传 --size 时缩放到指定尺寸,否则保留原尺寸
33
- const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, size, radius);
34
- const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}.png`);
35
- (0, fs_1.writeFileSync)(pngPath, roundedPng);
36
- const pngKb = (roundedPng.length / 1024).toFixed(1);
37
- const pngSizeText = size ? ` (${size}x${size})` : '';
38
- console.log(`圆角 PNG 生成完成: ${pngPath}${pngSizeText} (${pngKb} KB)`);
39
- // 传 --ico 时额外生成 ICO 文件
44
+ // 传 --ico 时先生成 ICO 文件,避免 --size 覆盖原图后读取到缩放后的源文件
40
45
  if (opts.ico) {
41
46
  const pngBuffers = await (0, utils_1.generateRoundedPngs)(sourcePath, utils_1.ICO_SIZES, radius);
42
47
  const icoBuffer = (0, utils_1.packIcoBuffer)(pngBuffers);
@@ -45,4 +50,22 @@ async function default_1(opts) {
45
50
  const icoKb = (icoBuffer.length / 1024).toFixed(1);
46
51
  console.log(`ICO 生成完成: ${icoPath} (${icoKb} KB, sizes: ${utils_1.ICO_SIZES.join(', ')})`);
47
52
  }
53
+ // 未传尺寸时输出原尺寸圆角 PNG;--size 缩放后覆盖原图;--sizes 按 原文件名_size 命名生成副本
54
+ if (sizeList) {
55
+ for (const s of sizeList) {
56
+ const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, s, radius);
57
+ const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}_${s}.png`);
58
+ (0, fs_1.writeFileSync)(pngPath, roundedPng);
59
+ const pngKb = (roundedPng.length / 1024).toFixed(1);
60
+ console.log(`圆角 PNG 生成完成: ${pngPath} (${s}x${s}, ${pngKb} KB)`);
61
+ }
62
+ }
63
+ else {
64
+ const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, size, radius);
65
+ const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}.png`);
66
+ (0, fs_1.writeFileSync)(pngPath, roundedPng);
67
+ const pngKb = (roundedPng.length / 1024).toFixed(1);
68
+ const pngSizeText = size ? ` (${size}x${size})` : '';
69
+ console.log(`圆角 PNG 生成完成: ${pngPath}${pngSizeText} (${pngKb} KB)`);
70
+ }
48
71
  }
package/lib/bin.js CHANGED
@@ -104,6 +104,7 @@ program
104
104
  .option(...commands_1.source)
105
105
  .option(...commands_1.radius)
106
106
  .option(...commands_1.size)
107
+ .option(...commands_1.sizes)
107
108
  .option(...commands_1.ico)
108
109
  .option(...commands_1.dest)
109
110
  .action(icon_1.default);
@@ -28,7 +28,8 @@ export declare const latest: readonly ["--latest", "是否获取最新版本数
28
28
  export declare const restore: readonly ["--restore", "构建完成后是否还原远程写入的主项目文件"];
29
29
  export declare const nobuild: readonly ["--nobuild", "跳过构建步骤"];
30
30
  export declare const radius: readonly ["-r, --radius <number>", "圆角半径,默认16", "16"];
31
- export declare const size: readonly ["--size <number>", "输出PNG尺寸(宽高相同),默认原尺寸"];
31
+ export declare const size: readonly ["--size <number>", "输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸"];
32
+ export declare const sizes: readonly ["--sizes <numbers>", "输出PNG副本(宽高相同),可传一个或多个用英文逗号分隔,文件名为 原文件名_size"];
32
33
  export declare const ico: readonly ["--ico", "是否输出ICO文件"];
33
34
  export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
34
35
  export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
@@ -67,6 +68,7 @@ export interface Options {
67
68
  nobuild?: boolean;
68
69
  radius?: string;
69
70
  size?: string;
71
+ sizes?: string;
70
72
  ico?: boolean;
71
73
  'skill.repo'?: string;
72
74
  'template.repo'?: 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.ico = exports.size = exports.radius = exports.nobuild = exports.restore = exports.latest = exports.pull = exports.skip = exports.apk = exports.res = exports.wgt = exports.pack = 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.ico = exports.sizes = exports.size = exports.radius = exports.nobuild = exports.restore = exports.latest = exports.pull = exports.skip = exports.apk = exports.res = exports.wgt = exports.pack = 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'];
@@ -30,7 +30,11 @@ exports.latest = ['--latest', '是否获取最新版本数据'];
30
30
  exports.restore = ['--restore', '构建完成后是否还原远程写入的主项目文件'];
31
31
  exports.nobuild = ['--nobuild', '跳过构建步骤'];
32
32
  exports.radius = ['-r, --radius <number>', '圆角半径,默认16', '16'];
33
- exports.size = ['--size <number>', '输出PNG尺寸(宽高相同),默认原尺寸'];
33
+ exports.size = ['--size <number>', '输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸'];
34
+ exports.sizes = [
35
+ '--sizes <numbers>',
36
+ '输出PNG副本(宽高相同),可传一个或多个用英文逗号分隔,文件名为 原文件名_size',
37
+ ];
34
38
  exports.ico = ['--ico', '是否输出ICO文件'];
35
39
  exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
36
40
  exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.8.12",
3
+ "version": "0.8.13",
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": "26edf845af9daec654c55c8d793213862f3b4bef"
62
+ "gitHead": "d2426e75b0edc8280476bec2bb357c5fe257504d"
63
63
  }