@gmcb/cli 0.10.2 → 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 +5 -0
- package/lib/apis/index.d.ts +5 -0
- package/lib/apis/index.js +18 -0
- package/lib/scripts/publish.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
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
|
+
|
|
5
10
|
## 0.10.2 [2026-11-22]
|
|
6
11
|
<!-- generated-by: specs -->
|
|
7
12
|
### 优化
|
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/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}`;
|