@gmcb/cli 0.10.4 → 0.10.5
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 +9 -0
- package/lib/actions/build.js +7 -4
- package/lib/apis/index.d.ts +0 -5
- package/lib/apis/index.js +6 -19
- package/lib/scripts/publish.js +5 -14
- package/lib/utils/function.d.ts +1 -2
- package/lib/utils/function.js +1 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- release:insert -->
|
|
4
4
|
|
|
5
|
+
## 0.10.5 [2026-12-01]
|
|
6
|
+
<!-- generated-by: specs -->
|
|
7
|
+
### 修复
|
|
8
|
+
- H5 发布 zip 改为扁平结构(不再包含 `package.appId` 根目录),Electron 子应用解压到 `apps/<env>/<appId>/` 后可直接识别 `manifest.json`。
|
|
9
|
+
- 发布提交时应用列表中找不到 `appId` 对应应用会给出明确错误,不再只看到后端的“请选择关联应用”。
|
|
10
|
+
### 优化
|
|
11
|
+
- 未配置上传路径(`publish.path` / `pub.path`)时,发布上传目录统一使用业务应用 ID(`/app/{appId}/{versionName}.{versionCode}/...`),不再反查应用标识 `identifier`;缺少应用 ID 时直接提示检查 `package.json.appId` / `manifest.appid` 并退出。
|
|
12
|
+
- `--pull` 拉取远程 electron-vite 工程时,`copy:electron` 的复制目标改为业务应用 ID 目录 `out/renderer/{package.appId}/`。
|
|
13
|
+
|
|
5
14
|
## 0.10.4 [2026-11-29]
|
|
6
15
|
<!-- generated-by: specs -->
|
|
7
16
|
### 新增
|
package/lib/actions/build.js
CHANGED
|
@@ -358,13 +358,12 @@ async function generatePackage(opts) {
|
|
|
358
358
|
if ((0, fs_1.existsSync)(dest)) {
|
|
359
359
|
(0, fs_1.unlinkSync)(dest);
|
|
360
360
|
}
|
|
361
|
-
const zipRoot = compiler === 'uni' && platform === 'h5' && pkg.appId ? String(pkg.appId) : '';
|
|
362
361
|
if (compiler === 'uni' && platform === 'h5') {
|
|
363
362
|
const h5ManifestPath = (0, path_1.join)(source, 'manifest.json');
|
|
364
363
|
const h5Manifest = (0, fs_extra_1.readJsonSync)(h5ManifestPath, { throws: false }) || {};
|
|
365
364
|
(0, fs_extra_1.writeJsonSync)(h5ManifestPath, { ...h5Manifest, appid: (0, utils_1.resolveAppId)(manifest, pkg) });
|
|
366
365
|
}
|
|
367
|
-
zip.addLocalFolder(source
|
|
366
|
+
zip.addLocalFolder(source);
|
|
368
367
|
zip.writeZip(dest);
|
|
369
368
|
}
|
|
370
369
|
spinner.stop();
|
|
@@ -393,7 +392,11 @@ function downloadFile(url, dest) {
|
|
|
393
392
|
async function pullRemoteResources(opts) {
|
|
394
393
|
const spinner = (0, ora_1.default)(`正在拉取远程资源...`).start();
|
|
395
394
|
const pkg = (0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH);
|
|
396
|
-
const appId = pkg.appId;
|
|
395
|
+
const appId = String(pkg.appId || '').trim();
|
|
396
|
+
if (!appId) {
|
|
397
|
+
utils_1.log.error('未找到应用ID,请在 package.json 中配置 appId(业务应用ID)后重试');
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
397
400
|
const appInfo = await (0, apis_1.getAppInfo)(appId);
|
|
398
401
|
const { appName, iconUrl, configJson } = appInfo;
|
|
399
402
|
const repoUrl = configJson.repo || config_1.CONFIG_DATA.pull?.repo;
|
|
@@ -438,7 +441,7 @@ async function pullRemoteResources(opts) {
|
|
|
438
441
|
if (!repoPkg.scripts)
|
|
439
442
|
repoPkg.scripts = {};
|
|
440
443
|
if (opts.compiler === 'electron-vite') {
|
|
441
|
-
repoPkg.scripts['copy:electron'] = 'gmcb copy -s ./dist/build/h5 -d ../../out/renderer/{
|
|
444
|
+
repoPkg.scripts['copy:electron'] = 'gmcb copy -s ./dist/build/h5 -d ../../out/renderer/{package.appId}/ --clean';
|
|
442
445
|
}
|
|
443
446
|
if (opts.compiler === 'gradlew') {
|
|
444
447
|
if (isUniappX) {
|
package/lib/apis/index.d.ts
CHANGED
|
@@ -130,11 +130,6 @@ 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>;
|
|
138
133
|
/**
|
|
139
134
|
* 获取应用信息
|
|
140
135
|
*/
|
package/lib/apis/index.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.getVersionHistory = getVersionHistory;
|
|
|
13
13
|
exports.uploadVersion = uploadVersion;
|
|
14
14
|
exports.publishVersion = publishVersion;
|
|
15
15
|
exports.fetchLatestVersion = fetchLatestVersion;
|
|
16
|
-
exports.fetchAppDetail = fetchAppDetail;
|
|
17
16
|
exports.getAppInfo = getAppInfo;
|
|
18
17
|
const http_1 = require("./http");
|
|
19
18
|
const const_1 = require("../utils/const");
|
|
@@ -157,6 +156,10 @@ async function publishVersion(params) {
|
|
|
157
156
|
else {
|
|
158
157
|
const { data: appList } = await getAppList();
|
|
159
158
|
const appItem = appList?.find((item) => item.appId === appId);
|
|
159
|
+
// 后端在 appMofangId 缺失时只报“请选择关联应用”,这里提前给出可定位的提示
|
|
160
|
+
if (!appItem) {
|
|
161
|
+
throw new Error(`未找到应用ID为 ${appId} 的应用,请检查 package.json.appId`);
|
|
162
|
+
}
|
|
160
163
|
const createData = {
|
|
161
164
|
appId,
|
|
162
165
|
appMofangId: appItem?.id,
|
|
@@ -207,7 +210,8 @@ async function publishVersion(params) {
|
|
|
207
210
|
});
|
|
208
211
|
}
|
|
209
212
|
catch (err) {
|
|
210
|
-
|
|
213
|
+
// Error 经 JSON.stringify 会变成 '{}',优先输出 message,避免丢失“未找到应用ID”等可定位提示
|
|
214
|
+
utils_1.log.error(err instanceof Error ? err.message : JSON.stringify(err));
|
|
211
215
|
}
|
|
212
216
|
}
|
|
213
217
|
/**
|
|
@@ -240,23 +244,6 @@ async function fetchLatestVersion(params) {
|
|
|
240
244
|
utils_1.log.error(JSON.stringify(err));
|
|
241
245
|
}
|
|
242
246
|
}
|
|
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
|
-
}
|
|
260
247
|
/**
|
|
261
248
|
* 获取应用信息
|
|
262
249
|
*/
|
package/lib/scripts/publish.js
CHANGED
|
@@ -21,17 +21,6 @@ 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
|
-
}
|
|
35
24
|
async function publish(options) {
|
|
36
25
|
const buildEnv = process.env.BUILD_ENV || '';
|
|
37
26
|
const pkg = (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {};
|
|
@@ -44,9 +33,11 @@ async function publish(options) {
|
|
|
44
33
|
const secretKey = config_1.CONFIG_DATA.cos?.secretkey || '';
|
|
45
34
|
const dir = options.dir || '';
|
|
46
35
|
const configPath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || '';
|
|
47
|
-
// 只看配置路径:未配置 path
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
// 只看配置路径:未配置 path 时用业务应用 ID 作为 COS 应用目录(发布动作会补空 publish 对象,不能按 publish 是否存在判断)
|
|
37
|
+
if (!configPath && !appId) {
|
|
38
|
+
utils_1.log.error('未找到应用ID,请检查 package.json 的 appId 或 manifest.json 的 appid 配置');
|
|
39
|
+
}
|
|
40
|
+
const appPath = configPath || `/app/${appId}`;
|
|
50
41
|
// 接口 path 语义保持不变:默认带平台目录,配置路径时不追加
|
|
51
42
|
const platformPath = !configPath && dir ? `/${dir}` : '';
|
|
52
43
|
const remotePath = `${appPath}${platformPath}`;
|
package/lib/utils/function.d.ts
CHANGED
|
@@ -8,8 +8,7 @@ export declare function readManifest(path: string | undefined, parse: false): st
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function isUniappXManifest(pathOrManifest?: string | Record<string, unknown>): boolean;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* 存量项目可继续使用 package.appId;新项目可删除该字段后依赖 manifest.appid。
|
|
11
|
+
* 解析应用ID:package.json.appId(业务应用ID)优先,缺失时回退 manifest.appid(Uni 应用标识/uniId,仅旧项目兜底;服务端可能匹配不到应用)。
|
|
13
12
|
* @param manifest manifest.json 内容
|
|
14
13
|
* @param pkg package.json 内容
|
|
15
14
|
*/
|
package/lib/utils/function.js
CHANGED
|
@@ -53,8 +53,7 @@ function isUniappXManifest(pathOrManifest = const_1.COMMAND_PATH) {
|
|
|
53
53
|
return Object.prototype.hasOwnProperty.call(manifest, 'uni-app-x');
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* 存量项目可继续使用 package.appId;新项目可删除该字段后依赖 manifest.appid。
|
|
56
|
+
* 解析应用ID:package.json.appId(业务应用ID)优先,缺失时回退 manifest.appid(Uni 应用标识/uniId,仅旧项目兜底;服务端可能匹配不到应用)。
|
|
58
57
|
* @param manifest manifest.json 内容
|
|
59
58
|
* @param pkg package.json 内容
|
|
60
59
|
*/
|