@gmcb/cli 0.10.1 → 0.10.3
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 +10 -0
- package/lib/actions/build.js +5 -2
- package/lib/actions/publish.js +1 -1
- package/lib/apis/index.d.ts +5 -0
- package/lib/apis/index.js +18 -0
- package/lib/bin.js +2 -0
- package/lib/commands/option.d.ts +2 -1
- package/lib/commands/option.js +6 -2
- package/lib/scripts/publish.js +14 -1
- package/lib/utils/function.d.ts +8 -0
- package/lib/utils/function.js +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- release:insert -->
|
|
4
4
|
|
|
5
|
+
## 0.10.3 [2026-11-23]
|
|
6
|
+
<!-- generated-by: specs -->
|
|
7
|
+
### 优化
|
|
8
|
+
- 未配置上传路径(`publish.path` / `pub.path`)时,发布上传目录优先使用应用标识 `identifier`(`/app/{identifier}/{version}/...`),取不到时回退应用ID。
|
|
9
|
+
|
|
10
|
+
## 0.10.2 [2026-11-22]
|
|
11
|
+
<!-- generated-by: specs -->
|
|
12
|
+
### 优化
|
|
13
|
+
- 使用 `--latest` 构建或发布时,结束后默认还原被同步改写的 `manifest.json` / `package.json` 等主项目文件,版本号同步结果不再留在工作区;需要保留同步结果时使用新增的 `--no-restore`。
|
|
14
|
+
|
|
5
15
|
## 0.10.1 [2026-11-22]
|
|
6
16
|
<!-- generated-by: specs -->
|
|
7
17
|
### 优化
|
package/lib/actions/build.js
CHANGED
|
@@ -519,7 +519,10 @@ async function default_1(...args) {
|
|
|
519
519
|
const deferRestore = args[args.length - 1] === true;
|
|
520
520
|
const commands = await getCommands(...args);
|
|
521
521
|
const command = commands.join(' ');
|
|
522
|
-
|
|
522
|
+
// publish 的 app / h5 连续构建共用备份表,由 publish 末尾统一还原,不能在这里清空
|
|
523
|
+
if (!deferRestore) {
|
|
524
|
+
remoteBackups.clear();
|
|
525
|
+
}
|
|
523
526
|
if (opts.latest) {
|
|
524
527
|
await syncLatestVersion();
|
|
525
528
|
}
|
|
@@ -552,7 +555,7 @@ async function default_1(...args) {
|
|
|
552
555
|
}
|
|
553
556
|
finally {
|
|
554
557
|
if (!deferRestore) {
|
|
555
|
-
await restoreLocalResources(
|
|
558
|
+
await restoreLocalResources((0, utils_1.resolveRestore)(opts));
|
|
556
559
|
}
|
|
557
560
|
}
|
|
558
561
|
}
|
package/lib/actions/publish.js
CHANGED
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/bin.js
CHANGED
|
@@ -55,6 +55,7 @@ program
|
|
|
55
55
|
.option(...commands_1.pull)
|
|
56
56
|
.option(...commands_1.latest)
|
|
57
57
|
.option(...commands_1.restore)
|
|
58
|
+
.option(...commands_1.noRestore)
|
|
58
59
|
.option(...commands_1.nobuild)
|
|
59
60
|
.action(build_1.default);
|
|
60
61
|
program
|
|
@@ -87,6 +88,7 @@ program
|
|
|
87
88
|
.option(...commands_1.pull)
|
|
88
89
|
.option(...commands_1.latest)
|
|
89
90
|
.option(...commands_1.restore)
|
|
91
|
+
.option(...commands_1.noRestore)
|
|
90
92
|
.option(...commands_1.nobuild)
|
|
91
93
|
.action(publish_1.default);
|
|
92
94
|
program
|
package/lib/commands/option.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export declare const apk: readonly ["--apk", "是否构建Android应用"];
|
|
|
25
25
|
export declare const skip: readonly ["--skip", "跳过所有确认,自动发布"];
|
|
26
26
|
export declare const pull: readonly ["--pull", "是否拉取远程代码构建"];
|
|
27
27
|
export declare const latest: readonly ["--latest", "是否获取最新版本数据"];
|
|
28
|
-
export declare const restore: readonly ["--restore", "
|
|
28
|
+
export declare const restore: readonly ["--restore", "构建完成后还原远程写入的主项目文件(--latest 时默认开启)"];
|
|
29
|
+
export declare const noRestore: readonly ["--no-restore", "构建完成后不还原远程写入的主项目文件(覆盖 --latest 的默认还原)"];
|
|
29
30
|
export declare const nobuild: readonly ["--nobuild", "跳过构建步骤"];
|
|
30
31
|
export declare const radius: readonly ["-r, --radius <number>", "圆角半径,默认16", "16"];
|
|
31
32
|
export declare const size: readonly ["--size <number>", "输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸"];
|
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.bg = exports.top = exports.left = exports.height = exports.width = 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;
|
|
3
|
+
exports.templateRepo = exports.skillRepo = exports.cosSecretkey = exports.cosSecretid = exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.bg = exports.top = exports.left = exports.height = exports.width = exports.ico = exports.sizes = exports.size = exports.radius = exports.nobuild = exports.noRestore = 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(web 等价 h5)', 'h5'];
|
|
@@ -27,7 +27,11 @@ exports.apk = ['--apk', '是否构建Android应用'];
|
|
|
27
27
|
exports.skip = ['--skip', '跳过所有确认,自动发布'];
|
|
28
28
|
exports.pull = ['--pull', '是否拉取远程代码构建'];
|
|
29
29
|
exports.latest = ['--latest', '是否获取最新版本数据'];
|
|
30
|
-
exports.restore = ['--restore', '
|
|
30
|
+
exports.restore = ['--restore', '构建完成后还原远程写入的主项目文件(--latest 时默认开启)'];
|
|
31
|
+
exports.noRestore = [
|
|
32
|
+
'--no-restore',
|
|
33
|
+
'构建完成后不还原远程写入的主项目文件(覆盖 --latest 的默认还原)',
|
|
34
|
+
];
|
|
31
35
|
exports.nobuild = ['--nobuild', '跳过构建步骤'];
|
|
32
36
|
exports.radius = ['-r, --radius <number>', '圆角半径,默认16', '16'];
|
|
33
37
|
exports.size = ['--size <number>', '输出PNG尺寸(宽高相同),覆盖原图,默认原尺寸'];
|
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/function.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ export declare function resolveAppId(manifest?: Record<string, unknown>, pkg?: R
|
|
|
19
19
|
* `app`、`h5`、`mp-*` 等非具体平台返回 0(表示需要提问或沿用配置)。
|
|
20
20
|
*/
|
|
21
21
|
export declare function resolvePublishPlatform(platform?: string): 0 | 1 | 2 | 3;
|
|
22
|
+
/**
|
|
23
|
+
* 构建/发布结束后是否还原主项目文件:显式 `--restore` / `--no-restore` 优先,未指定时在 `--latest` 下默认还原。
|
|
24
|
+
* @param opts 命令选项,只读取 restore / latest
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveRestore(opts?: {
|
|
27
|
+
restore?: boolean;
|
|
28
|
+
latest?: boolean;
|
|
29
|
+
}): boolean;
|
|
22
30
|
/** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
|
|
23
31
|
export declare const UNIAPPX_APP_PLATFORM_REQUIRED = "uni-app x \u7684 App \u5E73\u53F0\u672A\u786E\u5B9A\uFF1A\u8BF7\u4F7F\u7528 -p app-android / -p app-ios / -p app-harmony\uFF0C\u6216\u5728 uni.build.json \u914D\u7F6E publish.platform / pub.platform";
|
|
24
32
|
/** uni-app x 的 App 平台子目录(unpackage/release、unpackage/resources 下同名目录) */
|
package/lib/utils/function.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.readManifest = readManifest;
|
|
|
9
9
|
exports.isUniappXManifest = isUniappXManifest;
|
|
10
10
|
exports.resolveAppId = resolveAppId;
|
|
11
11
|
exports.resolvePublishPlatform = resolvePublishPlatform;
|
|
12
|
+
exports.resolveRestore = resolveRestore;
|
|
12
13
|
exports.resolveAppXPlatformDir = resolveAppXPlatformDir;
|
|
13
14
|
exports.resolveAppPlatformName = resolveAppPlatformName;
|
|
14
15
|
exports.resolveHBuilderXPlatform = resolveHBuilderXPlatform;
|
|
@@ -73,6 +74,13 @@ function resolvePublishPlatform(platform) {
|
|
|
73
74
|
return 3;
|
|
74
75
|
return 0;
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* 构建/发布结束后是否还原主项目文件:显式 `--restore` / `--no-restore` 优先,未指定时在 `--latest` 下默认还原。
|
|
79
|
+
* @param opts 命令选项,只读取 restore / latest
|
|
80
|
+
*/
|
|
81
|
+
function resolveRestore(opts = {}) {
|
|
82
|
+
return opts.restore ?? !!opts.latest;
|
|
83
|
+
}
|
|
76
84
|
/** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
|
|
77
85
|
exports.UNIAPPX_APP_PLATFORM_REQUIRED = 'uni-app x 的 App 平台未确定:请使用 -p app-android / -p app-ios / -p app-harmony,或在 uni.build.json 配置 publish.platform / pub.platform';
|
|
78
86
|
/**
|