@gmcb/cli 0.10.3 → 0.10.4

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  <!-- release:insert -->
4
4
 
5
+ ## 0.10.4 [2026-11-29]
6
+ <!-- generated-by: specs -->
7
+ ### 新增
8
+ - Android `--pull` 通过 `gmcb image` 自动生成 `splash_icon.png`(768×768,内部 360px 图标居中)。
9
+ - `gmcb image --bg 255,255,255,0` 支持透明底启动图,`--bg 255,255,255` 等价白色不透明。
10
+ ### 优化
11
+ - Android `icon.png` / `push.png` 保持下载原尺寸,不再强制 512。
12
+
5
13
  ## 0.10.3 [2026-11-23]
6
14
  <!-- generated-by: specs -->
7
15
  ### 优化
@@ -40,6 +40,7 @@ const simple_git_1 = __importDefault(require("simple-git"));
40
40
  const adm_zip_1 = __importDefault(require("adm-zip"));
41
41
  const ora_1 = __importDefault(require("ora"));
42
42
  const delay_1 = __importDefault(require("delay"));
43
+ const image_1 = __importDefault(require("./image"));
43
44
  const platform = __importStar(require("../commands/platform"));
44
45
  const utils_1 = require("../utils");
45
46
  const config_1 = require("../utils/config");
@@ -488,10 +489,22 @@ async function pullRemoteResources(opts) {
488
489
  (0, fs_extra_1.ensureDirSync)(drawableDir);
489
490
  const iconPath = (0, path_1.join)(drawableDir, 'icon.png');
490
491
  const pushPath = (0, path_1.join)(drawableDir, 'push.png');
492
+ const splashIconPath = (0, path_1.join)(drawableDir, 'splash_icon.png');
491
493
  backup(iconPath);
492
- await downloadFile(iconUrl, iconPath);
493
494
  backup(pushPath);
495
+ backup(splashIconPath);
496
+ await downloadFile(iconUrl, iconPath);
494
497
  (0, fs_1.copyFileSync)(iconPath, pushPath);
498
+ await (0, image_1.default)({
499
+ source: iconPath,
500
+ dest: drawableDir,
501
+ name: 'splash_icon',
502
+ width: '768',
503
+ height: '768',
504
+ left: '204',
505
+ top: '204',
506
+ bg: '255,255,255,0',
507
+ });
495
508
  }
496
509
  }
497
510
  if (config_1.CONFIG_DATA.publish?.updateMode == 2) {
@@ -48,7 +48,7 @@ async function default_1(...args) {
48
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
- const background = opts.bg ? (0, utils_1.parseHexColor)(opts.bg) : { r: 255, g: 255, b: 255, a: 255 };
51
+ const background = (0, utils_1.parseBackgroundColor)(opts.bg);
52
52
  const { buffer, info } = await (0, utils_1.generateSplash)({
53
53
  logo: (0, fs_1.readFileSync)(sourcePath),
54
54
  width,
@@ -59,12 +59,9 @@ async function default_1(...args) {
59
59
  ninePatch,
60
60
  });
61
61
  (0, fs_1.writeFileSync)(destPath, buffer);
62
- console.log(`画布:${info.width}×${info.height},背景 ${info.background}`);
62
+ console.log(`画布:${info.width}×${info.height},背景 ${info.transparent ? '透明' : info.background}`);
63
63
  console.log(`LOGO:可见区 ${info.logoBox.width}×${info.logoBox.height},left=${info.logoBox.x}, top=${info.logoBox.y}`);
64
64
  console.log(`输出:${destPath}(${(buffer.length / 1024).toFixed(1)} KB,${ninePatch ? '9-patch' : '普通 PNG'})`);
65
- if (info.logoBackground && info.logoBackground.toLowerCase() !== info.background.toLowerCase()) {
66
- utils_1.log.warning(`LOGO 自带不透明背景色 ${info.logoBackground},与画布背景 ${info.background} 不一致,输出会保留 LOGO 自身背景`);
67
- }
68
65
  utils_1.log.success('启动图生成完成');
69
66
  }
70
67
  catch (err) {
@@ -36,7 +36,7 @@ export declare const width: readonly ["--width <number>", "宽度(px)"];
36
36
  export declare const height: readonly ["--height <number>", "高度(px)"];
37
37
  export declare const left: readonly ["--left <value>", "左边距,支持 px 或百分比(如 421、38.9%)"];
38
38
  export declare const top: readonly ["--top <value>", "顶部距离,支持 px 或百分比(如 451、23.9%)"];
39
- export declare const bg: readonly ["--bg <color>", "背景色(如 #ffffff)"];
39
+ export declare const bg: readonly ["--bg <color>", "背景色(#ffffff 或 255,255,255,0)"];
40
40
  export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
41
41
  export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
42
42
  export declare const alipayCli: readonly ["--cli.alipay <cli-path>", "支付宝开发者工具 Cli路径"];
@@ -44,7 +44,7 @@ exports.width = ['--width <number>', '宽度(px)'];
44
44
  exports.height = ['--height <number>', '高度(px)'];
45
45
  exports.left = ['--left <value>', '左边距,支持 px 或百分比(如 421、38.9%)'];
46
46
  exports.top = ['--top <value>', '顶部距离,支持 px 或百分比(如 451、23.9%)'];
47
- exports.bg = ['--bg <color>', '背景色(如 #ffffff)'];
47
+ exports.bg = ['--bg <color>', '背景色(#ffffff 或 255,255,255,0)'];
48
48
  exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
49
49
  exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
50
50
  exports.alipayCli = ['--cli.alipay <cli-path>', '支付宝开发者工具 Cli路径'];
@@ -33,6 +33,8 @@ export interface SplashGenerateInfo {
33
33
  height: number;
34
34
  /** 背景色 */
35
35
  background: string;
36
+ /** 是否透明背景 */
37
+ transparent: boolean;
36
38
  ninePatch: boolean;
37
39
  /** LOGO 在输出图中的位置 */
38
40
  logoBox: SplashBox;
@@ -60,6 +62,11 @@ export declare function parsePositiveInt(value: string, label: string): number;
60
62
  export declare function parseLength(value: string, base: number, label: string): number;
61
63
  /** 解析 #rgb / #rrggbb 颜色 */
62
64
  export declare function parseHexColor(value: string): SplashRgba;
65
+ /**
66
+ * 解析启动图背景色。
67
+ * 支持 `#rgb` / `#rrggbb`,以及 `r,g,b` / `r,g,b,a`(0~255)。
68
+ */
69
+ export declare function parseBackgroundColor(value?: string): SplashRgba;
63
70
  /** 颜色转 #rrggbb */
64
71
  export declare function colorToHex(color: SplashRgba): string;
65
72
  /**
@@ -7,6 +7,7 @@ exports.DEFAULT_SPLASH_TOP = exports.DEFAULT_SPLASH_LEFT = exports.DEFAULT_SPLAS
7
7
  exports.parsePositiveInt = parsePositiveInt;
8
8
  exports.parseLength = parseLength;
9
9
  exports.parseHexColor = parseHexColor;
10
+ exports.parseBackgroundColor = parseBackgroundColor;
10
11
  exports.colorToHex = colorToHex;
11
12
  exports.normalizeSplashName = normalizeSplashName;
12
13
  exports.defaultSplashLeft = defaultSplashLeft;
@@ -85,6 +86,35 @@ function parseHexColor(value) {
85
86
  a: 255,
86
87
  };
87
88
  }
89
+ /**
90
+ * 解析启动图背景色。
91
+ * 支持 `#rgb` / `#rrggbb`,以及 `r,g,b` / `r,g,b,a`(0~255)。
92
+ */
93
+ function parseBackgroundColor(value) {
94
+ const text = String(value ?? '').trim();
95
+ if (!text) {
96
+ return { r: 255, g: 255, b: 255, a: 255 };
97
+ }
98
+ if (!text.includes(',')) {
99
+ return parseHexColor(text);
100
+ }
101
+ const parts = text.split(',').map((part) => part.trim());
102
+ if (parts.length !== 3 && parts.length !== 4) {
103
+ throw new Error(`--bg 颜色格式无效:${value},请使用 #rgb / #rrggbb 或 r,g,b / r,g,b,a`);
104
+ }
105
+ const channels = parts.map((part) => {
106
+ if (!/^\d+$/.test(part)) {
107
+ throw new Error(`--bg 颜色格式无效:${value},请使用 0~255 的整数`);
108
+ }
109
+ const channel = parseInt(part, 10);
110
+ if (channel > 255) {
111
+ throw new Error(`--bg 颜色格式无效:${value},每个通道必须在 0~255 之间`);
112
+ }
113
+ return channel;
114
+ });
115
+ const [r, g, b, a = 255] = channels;
116
+ return { r, g, b, a };
117
+ }
88
118
  /** 颜色转 #rrggbb */
89
119
  function colorToHex(color) {
90
120
  const hex = [color.r, color.g, color.b]
@@ -205,6 +235,13 @@ function compositeRaw(canvas, width, height, source, sourceWidth, sourceHeight,
205
235
  if (alpha === 0)
206
236
  continue;
207
237
  const targetIndex = (targetY * width + targetX) * 4;
238
+ if (canvas[targetIndex + 3] === 0) {
239
+ canvas[targetIndex] = source[sourceIndex];
240
+ canvas[targetIndex + 1] = source[sourceIndex + 1];
241
+ canvas[targetIndex + 2] = source[sourceIndex + 2];
242
+ canvas[targetIndex + 3] = alpha;
243
+ continue;
244
+ }
208
245
  if (alpha === 255) {
209
246
  canvas[targetIndex] = source[sourceIndex];
210
247
  canvas[targetIndex + 1] = source[sourceIndex + 1];
@@ -404,10 +441,12 @@ async function validateOutput(buffer, options, expected, tolerance, strictBox, p
404
441
  if (inPaste)
405
442
  continue;
406
443
  const idx = (y * raw.width + x) * 4;
407
- const isBackground = raw.data[idx] === options.background.r &&
408
- raw.data[idx + 1] === options.background.g &&
409
- raw.data[idx + 2] === options.background.b &&
410
- raw.data[idx + 3] === 255;
444
+ const isBackground = options.background.a === 0
445
+ ? raw.data[idx + 3] === 0
446
+ : raw.data[idx] === options.background.r &&
447
+ raw.data[idx + 1] === options.background.g &&
448
+ raw.data[idx + 2] === options.background.b &&
449
+ raw.data[idx + 3] === 255;
411
450
  if (!isBackground) {
412
451
  throw new Error('启动图生成结果校验失败:背景色异常');
413
452
  }
@@ -432,7 +471,13 @@ async function generateSplash(options) {
432
471
  if (!Number.isInteger(top) || top < 0) {
433
472
  throw new Error('--top 必须为非负整数');
434
473
  }
474
+ if (background.a !== 0 && background.a !== 255) {
475
+ throw new Error('背景透明度仅支持 0(透明)或 255(不透明)');
476
+ }
435
477
  if (ninePatch) {
478
+ if (background.a === 0) {
479
+ throw new Error('9-patch 启动图不支持透明背景');
480
+ }
436
481
  if (width < MIN_NINE_PATCH_SIZE || height < MIN_NINE_PATCH_SIZE) {
437
482
  throw new Error(`9-patch 启动图尺寸不能小于 ${MIN_NINE_PATCH_SIZE}×${MIN_NINE_PATCH_SIZE}`);
438
483
  }
@@ -463,7 +508,7 @@ async function generateSplash(options) {
463
508
  canvas[idx] = background.r;
464
509
  canvas[idx + 1] = background.g;
465
510
  canvas[idx + 2] = background.b;
466
- canvas[idx + 3] = 255;
511
+ canvas[idx + 3] = background.a;
467
512
  }
468
513
  const scaledWidth = Math.max(1, Math.round(logoRaw.width * logoScale));
469
514
  const scaledHeight = Math.max(1, Math.round(logoRaw.height * logoScale));
@@ -503,6 +548,7 @@ async function generateSplash(options) {
503
548
  width,
504
549
  height,
505
550
  background: colorToHex(background),
551
+ transparent: background.a === 0,
506
552
  ninePatch,
507
553
  logoBox: expectedBox,
508
554
  logoBackground: logoBackground ? colorToHex(logoBackground) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "UNLICENSED",