@gmcb/cli 0.10.2 → 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 +13 -0
- package/lib/actions/build.js +14 -1
- package/lib/actions/image.js +2 -5
- package/lib/apis/index.d.ts +5 -0
- package/lib/apis/index.js +18 -0
- package/lib/commands/option.d.ts +1 -1
- package/lib/commands/option.js +1 -1
- package/lib/scripts/publish.js +14 -1
- package/lib/utils/image.d.ts +7 -0
- package/lib/utils/image.js +51 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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
|
+
|
|
13
|
+
## 0.10.3 [2026-11-23]
|
|
14
|
+
<!-- generated-by: specs -->
|
|
15
|
+
### 优化
|
|
16
|
+
- 未配置上传路径(`publish.path` / `pub.path`)时,发布上传目录优先使用应用标识 `identifier`(`/app/{identifier}/{version}/...`),取不到时回退应用ID。
|
|
17
|
+
|
|
5
18
|
## 0.10.2 [2026-11-22]
|
|
6
19
|
<!-- generated-by: specs -->
|
|
7
20
|
### 优化
|
package/lib/actions/build.js
CHANGED
|
@@ -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) {
|
package/lib/actions/image.js
CHANGED
|
@@ -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 =
|
|
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) {
|
package/lib/apis/index.d.ts
CHANGED
|
@@ -130,6 +130,11 @@ export declare function fetchLatestVersion(params: {
|
|
|
130
130
|
versionCode: number;
|
|
131
131
|
updateMode: any;
|
|
132
132
|
}>;
|
|
133
|
+
/**
|
|
134
|
+
* 按 manifest appId 查询应用详情(含 identifier),用于拼 COS 上传目录。
|
|
135
|
+
* 未查询到或请求失败时返回 null 并告警,由调用方回退 appId,不中断发布。
|
|
136
|
+
*/
|
|
137
|
+
export declare function fetchAppDetail(appId: string): Promise<Record<string, any> | null>;
|
|
133
138
|
/**
|
|
134
139
|
* 获取应用信息
|
|
135
140
|
*/
|
package/lib/apis/index.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.getVersionHistory = getVersionHistory;
|
|
|
13
13
|
exports.uploadVersion = uploadVersion;
|
|
14
14
|
exports.publishVersion = publishVersion;
|
|
15
15
|
exports.fetchLatestVersion = fetchLatestVersion;
|
|
16
|
+
exports.fetchAppDetail = fetchAppDetail;
|
|
16
17
|
exports.getAppInfo = getAppInfo;
|
|
17
18
|
const http_1 = require("./http");
|
|
18
19
|
const const_1 = require("../utils/const");
|
|
@@ -239,6 +240,23 @@ async function fetchLatestVersion(params) {
|
|
|
239
240
|
utils_1.log.error(JSON.stringify(err));
|
|
240
241
|
}
|
|
241
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* 按 manifest appId 查询应用详情(含 identifier),用于拼 COS 上传目录。
|
|
245
|
+
* 未查询到或请求失败时返回 null 并告警,由调用方回退 appId,不中断发布。
|
|
246
|
+
*/
|
|
247
|
+
async function fetchAppDetail(appId) {
|
|
248
|
+
if (!appId)
|
|
249
|
+
return null;
|
|
250
|
+
try {
|
|
251
|
+
await ensureLoggedIn();
|
|
252
|
+
const { data } = await http_1.http.get('/admin-api/system/app-mofang/app/get', { appId });
|
|
253
|
+
return data || null;
|
|
254
|
+
}
|
|
255
|
+
catch (err) {
|
|
256
|
+
utils_1.log.warning(`获取应用详情失败,将使用应用ID:${appId}`);
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
242
260
|
/**
|
|
243
261
|
* 获取应用信息
|
|
244
262
|
*/
|
package/lib/commands/option.d.ts
CHANGED
|
@@ -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>", "
|
|
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路径"];
|
package/lib/commands/option.js
CHANGED
|
@@ -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>', '
|
|
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路径'];
|
package/lib/scripts/publish.js
CHANGED
|
@@ -21,6 +21,17 @@ const PUBLISH_APP_CFG = {
|
|
|
21
21
|
exe: config_1.CONFIG_DATA.h5?.windows,
|
|
22
22
|
apk: config_1.CONFIG_DATA.app?.android,
|
|
23
23
|
};
|
|
24
|
+
/** appId → 远端应用目录名,同一次构建的多次上传(wgt + zip)只查询一次 */
|
|
25
|
+
const remoteAppKeyCache = new Map();
|
|
26
|
+
/** 未配置上传路径时以应用标识作为 COS 应用目录,取不到时回退 appId */
|
|
27
|
+
async function resolveRemoteAppKey(appId) {
|
|
28
|
+
if (!remoteAppKeyCache.has(appId)) {
|
|
29
|
+
const detail = await (0, apis_1.fetchAppDetail)(appId);
|
|
30
|
+
const identifier = String(detail?.identifier || '').trim();
|
|
31
|
+
remoteAppKeyCache.set(appId, identifier || appId);
|
|
32
|
+
}
|
|
33
|
+
return remoteAppKeyCache.get(appId);
|
|
34
|
+
}
|
|
24
35
|
async function publish(options) {
|
|
25
36
|
const buildEnv = process.env.BUILD_ENV || '';
|
|
26
37
|
const pkg = (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {};
|
|
@@ -33,7 +44,9 @@ async function publish(options) {
|
|
|
33
44
|
const secretKey = config_1.CONFIG_DATA.cos?.secretkey || '';
|
|
34
45
|
const dir = options.dir || '';
|
|
35
46
|
const configPath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || '';
|
|
36
|
-
|
|
47
|
+
// 只看配置路径:未配置 path 时按 appId 查 identifier(发布动作会补空 publish 对象,不能按 publish 是否存在判断)
|
|
48
|
+
const remoteAppKey = !configPath && appId ? await resolveRemoteAppKey(appId) : appId;
|
|
49
|
+
const appPath = configPath || `/app/${remoteAppKey}`;
|
|
37
50
|
// 接口 path 语义保持不变:默认带平台目录,配置路径时不追加
|
|
38
51
|
const platformPath = !configPath && dir ? `/${dir}` : '';
|
|
39
52
|
const remotePath = `${appPath}${platformPath}`;
|
package/lib/utils/image.d.ts
CHANGED
|
@@ -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
|
/**
|
package/lib/utils/image.js
CHANGED
|
@@ -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 =
|
|
408
|
-
raw.data[idx +
|
|
409
|
-
raw.data[idx
|
|
410
|
-
|
|
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] =
|
|
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,
|