@gmcb/cli 0.8.10 → 0.8.12
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 +16 -0
- package/README.md +4 -0
- package/lib/actions/build.js +21 -17
- package/lib/actions/icon.js +9 -3
- package/lib/actions/publish.js +1 -1
- package/lib/bin.js +1 -0
- package/lib/commands/option.d.ts +2 -0
- package/lib/commands/option.js +2 -1
- package/lib/scripts/publish.js +1 -1
- package/lib/utils/png2ico.d.ts +3 -2
- package/lib/utils/png2ico.js +17 -6
- package/package.json +2 -2
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.12](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.11...@gmcb/cli@0.8.12) (2026-08-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.8.11](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.10...@gmcb/cli@0.8.11) (2026-07-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.8.10](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.8.9...@gmcb/cli@0.8.10) (2026-07-16)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @gmcb/cli
|
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ gmcb publish -p app --wgt -a
|
|
|
103
103
|
|---|---|
|
|
104
104
|
| `-s, --source <path>` | 源图片路径(必填,支持相对/绝对路径) |
|
|
105
105
|
| `-r, --radius <number>` | 圆角半径,默认 16 |
|
|
106
|
+
| `--size <number>` | 输出 PNG 尺寸(宽高相同),默认原尺寸 |
|
|
106
107
|
| `--ico` | 是否输出 ICO 文件 |
|
|
107
108
|
| `-d, --dest <path>` | 输出目录,默认为当前目录 |
|
|
108
109
|
|
|
@@ -112,6 +113,9 @@ gmcb publish -p app --wgt -a
|
|
|
112
113
|
# 生成带圆角的各尺寸 PNG
|
|
113
114
|
gmcb icon --source logo.png
|
|
114
115
|
|
|
116
|
+
# 输出 256x256 的圆角 PNG
|
|
117
|
+
gmcb icon --source logo.png --size 256
|
|
118
|
+
|
|
115
119
|
# 生成 ICO 文件,圆角半径 24,输出到 out 目录
|
|
116
120
|
gmcb icon --source logo.png --radius 24 --ico --dest out
|
|
117
121
|
```
|
package/lib/actions/build.js
CHANGED
|
@@ -74,8 +74,8 @@ async function restoreLocalResources(restore) {
|
|
|
74
74
|
}
|
|
75
75
|
async function syncLatestVersion() {
|
|
76
76
|
const spinner = (0, ora_1.default)('正在获取最新版本数据...').start();
|
|
77
|
-
const
|
|
78
|
-
const appId =
|
|
77
|
+
const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
|
|
78
|
+
const appId = pkg.appId;
|
|
79
79
|
const { versionName, versionCode, updateMode } = await (0, apis_1.fetchLatestVersion)({
|
|
80
80
|
appId,
|
|
81
81
|
platform: config_1.CONFIG_DATA.publish?.platform,
|
|
@@ -86,19 +86,24 @@ async function syncLatestVersion() {
|
|
|
86
86
|
}
|
|
87
87
|
if (versionName && versionCode) {
|
|
88
88
|
if ((0, fs_1.existsSync)(utils_1.MAINFEST_PATH)) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
const localVersionCode = Number((0, utils_1.readManifest)().versionCode || 0);
|
|
90
|
+
if (localVersionCode < versionCode) {
|
|
91
|
+
let content = (0, fs_1.readFileSync)(utils_1.MAINFEST_PATH, 'utf-8');
|
|
92
|
+
content = content.replace(/"versionName"\s*:\s*"[^"]*"/, `"versionName": "${versionName}"`);
|
|
93
|
+
content = content.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
|
|
94
|
+
backup(utils_1.MAINFEST_PATH);
|
|
95
|
+
(0, fs_1.writeFileSync)(utils_1.MAINFEST_PATH, content);
|
|
96
|
+
}
|
|
94
97
|
}
|
|
95
98
|
else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const localVersionCode = Number(pkg.versionCode || 0);
|
|
100
|
+
if (localVersionCode < versionCode) {
|
|
101
|
+
let pkgContent = (0, fs_1.readFileSync)(utils_1.PACKAGE_PATH, 'utf-8');
|
|
102
|
+
pkgContent = pkgContent.replace(/"version"\s*:\s*"[^"]*"/, `"version": "${versionName}"`);
|
|
103
|
+
pkgContent = pkgContent.replace(/"versionCode"\s*:\s*"?[^",]*"?/, `"versionCode": ${versionCode}`);
|
|
104
|
+
backup(utils_1.PACKAGE_PATH);
|
|
105
|
+
(0, fs_1.writeFileSync)(utils_1.PACKAGE_PATH, pkgContent);
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
spinner.stop();
|
|
@@ -328,17 +333,16 @@ function downloadFile(url, dest) {
|
|
|
328
333
|
}
|
|
329
334
|
async function pullRemoteResources(opts) {
|
|
330
335
|
const spinner = (0, ora_1.default)(`正在拉取远程资源...`).start();
|
|
331
|
-
const appIdPkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
|
|
332
|
-
const appId = appIdPkg.appId;
|
|
333
336
|
const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
|
|
337
|
+
const appId = pkg.appId;
|
|
334
338
|
// 1. 获取应用信息
|
|
335
339
|
const appInfo = await (0, apis_1.getAppInfo)(appId);
|
|
336
340
|
const { appName, iconUrl, configJson } = appInfo;
|
|
337
341
|
// 2. 确定仓库地址
|
|
338
342
|
const repoUrl = configJson.repo || config_1.CONFIG_DATA.pull?.repo;
|
|
339
343
|
// 3. 确定分支:使用 buildEnv,默认 master;prod 对应 master 分支
|
|
340
|
-
const buildEnv = process.env.BUILD_ENV
|
|
341
|
-
const branch = buildEnv
|
|
344
|
+
const buildEnv = process.env.BUILD_ENV;
|
|
345
|
+
const branch = buildEnv.startsWith('pro') || !buildEnv ? 'master' : buildEnv;
|
|
342
346
|
// 4. 拉取代码到 COMMAND_PATH/.repo/{appId}
|
|
343
347
|
const repoDir = (0, path_1.join)(utils_1.COMMAND_PATH, '.repo', appId);
|
|
344
348
|
if ((0, fs_1.existsSync)((0, path_1.join)(repoDir, '.git'))) {
|
package/lib/actions/icon.js
CHANGED
|
@@ -16,6 +16,11 @@ 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
|
+
const size = opts.size ? parseInt(opts.size, 10) : undefined;
|
|
20
|
+
if (opts.size && (!Number.isInteger(size) || size <= 0)) {
|
|
21
|
+
utils_1.log.error('--size 必须为正整数');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
19
24
|
if (!(0, fs_1.existsSync)(sourcePath)) {
|
|
20
25
|
utils_1.log.error(`源文件不存在: ${sourcePath}`);
|
|
21
26
|
return;
|
|
@@ -24,12 +29,13 @@ async function default_1(opts) {
|
|
|
24
29
|
(0, fs_1.mkdirSync)(destDir, { recursive: true });
|
|
25
30
|
}
|
|
26
31
|
const nameWithoutExt = (0, path_1.basename)(sourcePath, (0, path_1.extname)(sourcePath));
|
|
27
|
-
//
|
|
28
|
-
const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, radius);
|
|
32
|
+
// 输出圆角 PNG,传 --size 时缩放到指定尺寸,否则保留原尺寸
|
|
33
|
+
const roundedPng = await (0, utils_1.generateRoundedPng)(sourcePath, size, radius);
|
|
29
34
|
const pngPath = (0, path_1.resolve)(destDir, `${nameWithoutExt}.png`);
|
|
30
35
|
(0, fs_1.writeFileSync)(pngPath, roundedPng);
|
|
31
36
|
const pngKb = (roundedPng.length / 1024).toFixed(1);
|
|
32
|
-
|
|
37
|
+
const pngSizeText = size ? ` (${size}x${size})` : '';
|
|
38
|
+
console.log(`圆角 PNG 生成完成: ${pngPath}${pngSizeText} (${pngKb} KB)`);
|
|
33
39
|
// 传 --ico 时额外生成 ICO 文件
|
|
34
40
|
if (opts.ico) {
|
|
35
41
|
const pngBuffers = await (0, utils_1.generateRoundedPngs)(sourcePath, utils_1.ICO_SIZES, radius);
|
package/lib/actions/publish.js
CHANGED
|
@@ -230,7 +230,7 @@ async function default_1(...args) {
|
|
|
230
230
|
}
|
|
231
231
|
// 从 cmds 提取 buildEnv
|
|
232
232
|
const buildEnv = cmds[2]?.split('=')[1];
|
|
233
|
-
if (!buildEnv || !['dev', 'sit', 'uat', 'pre', 'prod'].includes(buildEnv)) {
|
|
233
|
+
if (!buildEnv || !['dev', 'sit', 'uat', 'pre', 'pro', 'prod'].includes(buildEnv)) {
|
|
234
234
|
utils_1.log.error('没有检测到需要发布的环境,无法完成上传,请切换到dev/sit/uat/pre/master分支再次执行脚本,或者您可以选择手动上传!');
|
|
235
235
|
}
|
|
236
236
|
const isHotUpdate = opts.pull && config_1.CONFIG_DATA.publish?.updateMode == 2;
|
package/lib/bin.js
CHANGED
package/lib/commands/option.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ 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
32
|
export declare const ico: readonly ["--ico", "是否输出ICO文件"];
|
|
32
33
|
export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
|
|
33
34
|
export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
|
|
@@ -65,6 +66,7 @@ export interface Options {
|
|
|
65
66
|
restore?: boolean;
|
|
66
67
|
nobuild?: boolean;
|
|
67
68
|
radius?: string;
|
|
69
|
+
size?: string;
|
|
68
70
|
ico?: boolean;
|
|
69
71
|
'skill.repo'?: string;
|
|
70
72
|
'template.repo'?: string;
|
package/lib/commands/option.js
CHANGED
|
@@ -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.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.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,6 +30,7 @@ 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
34
|
exports.ico = ['--ico', '是否输出ICO文件'];
|
|
34
35
|
exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
|
|
35
36
|
exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
|
package/lib/scripts/publish.js
CHANGED
|
@@ -26,7 +26,7 @@ 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
|
|
29
|
+
const bucket = `${buildEnv.startsWith('pro') ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket ?? ''}`;
|
|
30
30
|
const region = config_1.CONFIG_DATA.cos?.region ?? '';
|
|
31
31
|
const secretId = config_1.CONFIG_DATA.cos?.secretid ?? '';
|
|
32
32
|
const secretKey = config_1.CONFIG_DATA.cos?.secretkey ?? '';
|
package/lib/utils/png2ico.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare const ICO_SIZES: number[];
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 生成单张带圆角的 PNG Buffer
|
|
4
4
|
* @param srcPath 源图片路径
|
|
5
|
+
* @param size 目标尺寸(宽高相同),不传则保留原始尺寸
|
|
5
6
|
* @param radius 圆角半径
|
|
6
7
|
*/
|
|
7
|
-
export declare function generateRoundedPng(srcPath: string, radius: number): Promise<Buffer>;
|
|
8
|
+
export declare function generateRoundedPng(srcPath: string, size: number | undefined, radius: number): Promise<Buffer>;
|
|
8
9
|
/**
|
|
9
10
|
* 生成各尺寸带圆角的 PNG Buffer
|
|
10
11
|
* @param srcPath 源图片路径
|
package/lib/utils/png2ico.js
CHANGED
|
@@ -12,16 +12,27 @@ const sharp_1 = __importDefault(require("sharp"));
|
|
|
12
12
|
const fs_1 = require("fs");
|
|
13
13
|
exports.ICO_SIZES = [16, 24, 32, 48, 64, 128, 256];
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 生成单张带圆角的 PNG Buffer
|
|
16
16
|
* @param srcPath 源图片路径
|
|
17
|
+
* @param size 目标尺寸(宽高相同),不传则保留原始尺寸
|
|
17
18
|
* @param radius 圆角半径
|
|
18
19
|
*/
|
|
19
|
-
async function generateRoundedPng(srcPath, radius) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
async function generateRoundedPng(srcPath, size, radius) {
|
|
21
|
+
let w;
|
|
22
|
+
let h;
|
|
23
|
+
if (size) {
|
|
24
|
+
w = h = size;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const { width, height } = await (0, sharp_1.default)(srcPath).metadata();
|
|
28
|
+
w = width ?? 0;
|
|
29
|
+
h = height ?? 0;
|
|
30
|
+
}
|
|
23
31
|
const mask = Buffer.from(`<svg><rect x="0" y="0" width="${w}" height="${h}" rx="${radius}" ry="${radius}" fill="white"/></svg>`);
|
|
24
|
-
|
|
32
|
+
const pipeline = (0, sharp_1.default)(srcPath);
|
|
33
|
+
if (size)
|
|
34
|
+
pipeline.resize(size, size);
|
|
35
|
+
return pipeline.composite([{ input: mask, blend: 'dest-in' }]).png().toBuffer();
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* 生成各尺寸带圆角的 PNG Buffer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmcb/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
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": "
|
|
62
|
+
"gitHead": "26edf845af9daec654c55c8d793213862f3b4bef"
|
|
63
63
|
}
|