@gmcb/cli 0.9.16 → 0.9.18
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 +14 -0
- package/README.md +2 -2
- package/lib/actions/build.js +24 -16
- package/lib/actions/publish.js +20 -12
- package/lib/scripts/app-wgt.d.ts +1 -1
- package/lib/scripts/app-wgt.js +15 -2
- package/lib/scripts/publish.d.ts +3 -0
- package/lib/scripts/publish.js +7 -2
- package/lib/utils/function.d.ts +27 -0
- package/lib/utils/function.js +61 -0
- package/package.json +1 -1
- package/schema.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- release:insert -->
|
|
4
4
|
|
|
5
|
+
## 0.9.18 [2026-11-20]
|
|
6
|
+
<!-- generated-by: specs -->
|
|
7
|
+
### 修复
|
|
8
|
+
- uni-app x 工程的 wgt / 资源发放改用 HBuilderX 定位形式(`publish app-android --type wgt`、`publish app-ios --type appResource` 等),不再输出对 uni-app x 无效的 `--platform APP`;经典 uni-app 的 `-p app` 仍为 `publish --platform APP`。
|
|
9
|
+
- uni-app x 的 App 平台未确定时(`-p app` 且无显式 `-p app-*`、也未配置 `publish.platform`/`pub.platform`)直接报错提示并退出,不再默认 Android;`--wgt` 与 `--res` 一致。
|
|
10
|
+
- uni-app x 的 wgt 从 `unpackage/release/app-<平台>` 读取,并按平台分目录上传到 COS(`/app/<appId>/android`、`/app/<appId>/ios`、`/app/<appId>/harmony`),避免多平台同名覆盖;找不到文件时直接报错并输出完整路径。
|
|
11
|
+
- 鸿蒙发布/打包按 HBuilderX 文档形态:`publish app-harmony --type appResource|wgt`(经典与 uni-app x 相同)、`pack app-harmony`(仅 `--project`)。
|
|
12
|
+
- `gmcb publish -p app-android|app-ios|app-harmony` 不再重复询问“请选择要发布的平台”,直接采用对应发布平台。
|
|
13
|
+
|
|
14
|
+
## 0.9.17 [2026-11-20]
|
|
15
|
+
<!-- generated-by: specs -->
|
|
16
|
+
### 优化
|
|
17
|
+
- `--pull` 拉取 electron-vite 远程工程时,注入并执行的复制脚本由 `copy:h5` 更名为 `copy:electron`,与 gradlew 的 `copy:android` 命名对齐;远端工程自带的 `copy:h5` 脚本不再被覆盖。
|
|
18
|
+
|
|
5
19
|
## 0.9.16 [2026-11-19]
|
|
6
20
|
<!-- generated-by: specs -->
|
|
7
21
|
### 优化
|
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ npm i @gmcb/cli -g
|
|
|
28
28
|
# H5 构建(web 为 h5 别名)
|
|
29
29
|
gmcb build -p h5
|
|
30
30
|
|
|
31
|
-
# App 热更新资源(uni-app x
|
|
32
|
-
gmcb build -p app --wgt
|
|
31
|
+
# App 热更新资源(uni-app x 蒸汽模式需指定具体平台,或用 -p app + publish.platform)
|
|
32
|
+
gmcb build -p app-android --wgt
|
|
33
33
|
|
|
34
34
|
# 生成圆角应用图标
|
|
35
35
|
gmcb icon --source logo.png
|
package/lib/actions/build.js
CHANGED
|
@@ -199,7 +199,19 @@ async function getCommands(...args) {
|
|
|
199
199
|
const cleanFlags = (flags) => flags.filter((item) => !/^--[\w.]+ (\{\}|\[\]|)$/.test(item));
|
|
200
200
|
if (opts.platform.startsWith('app')) {
|
|
201
201
|
const app = platform.app(opts);
|
|
202
|
-
const
|
|
202
|
+
const publishPlatform = config_1.CONFIG_DATA.publish?.platform ?? config_1.CONFIG_DATA.pub?.platform;
|
|
203
|
+
const appPlatform = (0, utils_1.resolveHBuilderXPlatform)(opts.platform, isUniappX, publishPlatform);
|
|
204
|
+
if ((opts.wgt || opts.res) && !appPlatform) {
|
|
205
|
+
utils_1.log.error(utils_1.UNIAPPX_APP_PLATFORM_REQUIRED);
|
|
206
|
+
return commands;
|
|
207
|
+
}
|
|
208
|
+
const appXPlatformDir = isUniappX ? (appPlatform ?? '') : '';
|
|
209
|
+
// app-* 一律定位形式(publish app-android / app-harmony);只有经典聚合 app 用 --platform APP
|
|
210
|
+
const platformArg = !appPlatform
|
|
211
|
+
? ''
|
|
212
|
+
: appPlatform.startsWith('app-')
|
|
213
|
+
? appPlatform
|
|
214
|
+
: `--platform ${appPlatform}`;
|
|
203
215
|
if (opts.wgt) {
|
|
204
216
|
if (opts.pack) {
|
|
205
217
|
let index = app.wgt.indexOf('--path');
|
|
@@ -207,18 +219,14 @@ async function getCommands(...args) {
|
|
|
207
219
|
index = app.wgt.length;
|
|
208
220
|
app.wgt = [...app.wgt, '--path', (0, path_1.resolve)('unpackage/release')];
|
|
209
221
|
}
|
|
210
|
-
const
|
|
211
|
-
(0,
|
|
222
|
+
const wgtBase = app.wgt[index + 1];
|
|
223
|
+
const wgtDist = (0, utils_1.joinAppXDir)(wgtBase, appXPlatformDir);
|
|
224
|
+
(0, fs_extra_1.ensureDirSync)(wgtBase);
|
|
212
225
|
const manifest = (0, utils_1.readManifest)(projectPath);
|
|
213
226
|
if (manifest.appid) {
|
|
214
227
|
(0, fs_extra_1.removeSync)((0, path_1.join)(wgtDist, `${manifest.appid}.wgt`));
|
|
215
228
|
}
|
|
216
|
-
cmds = [
|
|
217
|
-
'publish',
|
|
218
|
-
isHarmony ? opts.platform : `--platform ${opts.platform === 'app' ? 'APP' : opts.platform}`,
|
|
219
|
-
'--type wgt',
|
|
220
|
-
...app.wgt,
|
|
221
|
-
];
|
|
229
|
+
cmds = ['publish', platformArg, '--type wgt', ...app.wgt];
|
|
222
230
|
}
|
|
223
231
|
else {
|
|
224
232
|
commands = [...commands, bin, 'build -p', opts.platform];
|
|
@@ -226,17 +234,17 @@ async function getCommands(...args) {
|
|
|
226
234
|
}
|
|
227
235
|
}
|
|
228
236
|
else if (opts.res) {
|
|
229
|
-
cmds = [
|
|
230
|
-
'publish',
|
|
231
|
-
isHarmony ? opts.platform : `--platform ${opts.platform === 'app' ? 'APP' : opts.platform}`,
|
|
232
|
-
'--type appResource',
|
|
233
|
-
];
|
|
237
|
+
cmds = ['publish', platformArg, '--type appResource'];
|
|
234
238
|
}
|
|
235
239
|
else {
|
|
236
240
|
cmds = ['pack', '--platform'];
|
|
237
241
|
if (opts.platform === 'app') {
|
|
238
242
|
cmds = [...cmds, 'android,ios', ...cleanFlags([...app.common, ...app.android, ...app.ios])];
|
|
239
243
|
}
|
|
244
|
+
else if (opts.platform === 'app-harmony') {
|
|
245
|
+
// 鸿蒙本地打包:只支持 --project,不再传 --platform harmony 与 --harmony.* 参数
|
|
246
|
+
cmds = ['pack', 'app-harmony'];
|
|
247
|
+
}
|
|
240
248
|
else {
|
|
241
249
|
const _platform = opts.platform.replace('app-', '');
|
|
242
250
|
cmds = [...cmds, _platform, ...cleanFlags([...app.common, ...(app[_platform] || [])])];
|
|
@@ -429,7 +437,7 @@ async function pullRemoteResources(opts) {
|
|
|
429
437
|
if (!repoPkg.scripts)
|
|
430
438
|
repoPkg.scripts = {};
|
|
431
439
|
if (opts.compiler === 'electron-vite') {
|
|
432
|
-
repoPkg.scripts['copy:
|
|
440
|
+
repoPkg.scripts['copy:electron'] = 'gmcb copy -s ./dist/build/h5 -d ../../out/renderer/{manifest.appid}/ --clean';
|
|
433
441
|
}
|
|
434
442
|
if (opts.compiler === 'gradlew') {
|
|
435
443
|
if (isUniappX) {
|
|
@@ -445,7 +453,7 @@ async function pullRemoteResources(opts) {
|
|
|
445
453
|
(0, child_process_1.execSync)('npm install', { cwd: repoDir, stdio: 'inherit' });
|
|
446
454
|
if (opts.compiler === 'electron-vite') {
|
|
447
455
|
(0, child_process_1.execSync)(`npm run build:h5:${buildEnv}`, { cwd: repoDir, stdio: 'inherit' });
|
|
448
|
-
(0, child_process_1.execSync)('npm run copy:
|
|
456
|
+
(0, child_process_1.execSync)('npm run copy:electron', { cwd: repoDir, stdio: 'inherit' });
|
|
449
457
|
const pkgPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'package.json');
|
|
450
458
|
let pkgContent = (0, fs_1.readFileSync)(pkgPath, 'utf-8');
|
|
451
459
|
pkgContent = pkgContent.replace(/"productName":\s*"[^"]*"/, `"productName": "${appName}"`);
|
package/lib/actions/publish.js
CHANGED
|
@@ -37,6 +37,8 @@ async function default_1(...args) {
|
|
|
37
37
|
if (opts.platform === 'web') {
|
|
38
38
|
opts.platform = 'h5';
|
|
39
39
|
}
|
|
40
|
+
// 显式 -p app-android / app-ios / app-harmony 时平台已确定,不再重复提问
|
|
41
|
+
const explicitPlatform = (0, utils_1.resolvePublishPlatform)(opts.platform);
|
|
40
42
|
const isPublishFlow = !!config_1.CONFIG_DATA.publish;
|
|
41
43
|
const isAuto = opts.skip || !!config_1.CONFIG_DATA.skip;
|
|
42
44
|
const pub = { platform: 0, status: 0, updateType: 0, updateMode: 0 };
|
|
@@ -53,7 +55,10 @@ async function default_1(...args) {
|
|
|
53
55
|
}
|
|
54
56
|
if (/^(app|h5)/.test(opts.platform)) {
|
|
55
57
|
if (isPublishFlow) {
|
|
56
|
-
if (
|
|
58
|
+
if (explicitPlatform && config_1.CONFIG_DATA.publish?.publishType == 1) {
|
|
59
|
+
pub.platform = explicitPlatform;
|
|
60
|
+
}
|
|
61
|
+
else if (!config_1.CONFIG_DATA.publish?.platform && config_1.CONFIG_DATA.publish?.publishType == 1) {
|
|
57
62
|
const { platform } = await inquirer_1.default.prompt([
|
|
58
63
|
{
|
|
59
64
|
type: 'list',
|
|
@@ -109,7 +114,10 @@ async function default_1(...args) {
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
else {
|
|
112
|
-
if (
|
|
117
|
+
if (explicitPlatform) {
|
|
118
|
+
pub.platform = explicitPlatform;
|
|
119
|
+
}
|
|
120
|
+
else if (!config_1.CONFIG_DATA.pub?.platform) {
|
|
113
121
|
const { platform } = await inquirer_1.default.prompt([
|
|
114
122
|
{
|
|
115
123
|
type: 'list',
|
|
@@ -228,41 +236,41 @@ async function default_1(...args) {
|
|
|
228
236
|
const isHotUpdate = opts.pull && config_1.CONFIG_DATA.publish?.updateMode == 2;
|
|
229
237
|
if (opts.compiler === 'electron-vite') {
|
|
230
238
|
if (isHotUpdate) {
|
|
231
|
-
await require('../scripts/zip-exe').default();
|
|
239
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/zip-exe')))).default();
|
|
232
240
|
}
|
|
233
241
|
else if (opts.zip) {
|
|
234
|
-
await require('../scripts/asar-zip').default();
|
|
242
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/asar-zip')))).default();
|
|
235
243
|
}
|
|
236
244
|
else if (opts.win) {
|
|
237
|
-
await require('../scripts/h5-exe').default();
|
|
245
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/h5-exe')))).default();
|
|
238
246
|
}
|
|
239
247
|
}
|
|
240
248
|
else if (opts.compiler === 'gradlew') {
|
|
241
249
|
if (isHotUpdate) {
|
|
242
|
-
await require('../scripts/wgt-apk').default();
|
|
250
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/wgt-apk')))).default();
|
|
243
251
|
}
|
|
244
252
|
else if (opts.apk) {
|
|
245
|
-
await require('../scripts/app-apk').default();
|
|
253
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/app-apk')))).default();
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
256
|
else if (opts.compiler === 'uni') {
|
|
249
257
|
if (opts.platform?.startsWith('mp')) {
|
|
250
|
-
await require('../scripts/mp-weixin').default(opts);
|
|
258
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/mp-weixin')))).default(opts);
|
|
251
259
|
}
|
|
252
260
|
else if (opts.platform === 'h5') {
|
|
253
261
|
if (opts.wgt && opts.zip) {
|
|
254
|
-
await require('../scripts/wgt-zip').default();
|
|
262
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/wgt-zip')))).default();
|
|
255
263
|
}
|
|
256
264
|
else if (opts.zip) {
|
|
257
|
-
await require('../scripts/h5-zip').default();
|
|
265
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/h5-zip')))).default();
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
else if (opts.platform?.startsWith('app')) {
|
|
261
269
|
if (opts.wgt && opts.zip) {
|
|
262
|
-
await require('../scripts/wgt-zip').default();
|
|
270
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/wgt-zip')))).default();
|
|
263
271
|
}
|
|
264
272
|
else if (opts.wgt) {
|
|
265
|
-
await require('../scripts/app-wgt').default();
|
|
273
|
+
await (await Promise.resolve().then(() => __importStar(require('../scripts/app-wgt')))).default(opts);
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
276
|
}
|
package/lib/scripts/app-wgt.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function (): Promise<void>;
|
|
1
|
+
export default function (...args: any[]): Promise<void>;
|
package/lib/scripts/app-wgt.js
CHANGED
|
@@ -2,11 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
5
6
|
const publish_1 = require("./publish");
|
|
6
|
-
async function default_1() {
|
|
7
|
+
async function default_1(...args) {
|
|
8
|
+
const opts = (args[0] || {});
|
|
7
9
|
const manifest = (0, utils_1.readManifest)();
|
|
10
|
+
// uni-app x 的 wgt 按平台产出:本地落在 unpackage/release/app-<平台>,远端按短平台名分目录
|
|
11
|
+
const isUniappX = (0, utils_1.isUniappXManifest)(manifest);
|
|
12
|
+
const platform = isUniappX
|
|
13
|
+
? (0, utils_1.resolveAppPlatformName)(opts.platform, config_1.CONFIG_DATA.publish?.platform ?? config_1.CONFIG_DATA.pub?.platform)
|
|
14
|
+
: undefined;
|
|
15
|
+
if (isUniappX && !platform) {
|
|
16
|
+
utils_1.log.error(utils_1.UNIAPPX_APP_PLATFORM_REQUIRED);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const path = isUniappX ? `unpackage/release/app-${platform}` : 'unpackage/release';
|
|
8
20
|
await (0, publish_1.publish)({
|
|
9
|
-
files: [{ ext: 'wgt', name: manifest['appid'], path
|
|
21
|
+
files: [{ ext: 'wgt', name: manifest['appid'], path }],
|
|
22
|
+
dir: platform,
|
|
10
23
|
versionName: manifest['versionName'],
|
|
11
24
|
versionCode: manifest['versionCode'],
|
|
12
25
|
});
|
package/lib/scripts/publish.d.ts
CHANGED
|
@@ -2,11 +2,14 @@ export type PublishExt = 'wgt' | 'zip' | 'wgt-zip' | 'exe' | 'apk';
|
|
|
2
2
|
export interface PublishFile {
|
|
3
3
|
ext: PublishExt;
|
|
4
4
|
name: string;
|
|
5
|
+
/** 本地资源相对目录(脚本负责拼好完整目录,如 unpackage/release/app-android) */
|
|
5
6
|
path: string;
|
|
6
7
|
}
|
|
7
8
|
export interface PublishOptions {
|
|
8
9
|
files: PublishFile[];
|
|
9
10
|
versionName?: string;
|
|
10
11
|
versionCode?: string | number;
|
|
12
|
+
/** 远端平台目录名(android / ios / harmony),仅用于 COS 路径兜底 */
|
|
13
|
+
dir?: string;
|
|
11
14
|
}
|
|
12
15
|
export declare function publish(options: PublishOptions): Promise<void>;
|
package/lib/scripts/publish.js
CHANGED
|
@@ -31,7 +31,8 @@ async function publish(options) {
|
|
|
31
31
|
const region = config_1.CONFIG_DATA.cos?.region || '';
|
|
32
32
|
const secretId = config_1.CONFIG_DATA.cos?.secretid || '';
|
|
33
33
|
const secretKey = config_1.CONFIG_DATA.cos?.secretkey || '';
|
|
34
|
-
const
|
|
34
|
+
const dir = options.dir || '';
|
|
35
|
+
const remotePath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || `/app/${appId}${dir ? `/${dir}` : ''}`;
|
|
35
36
|
const cos = new cos_nodejs_sdk_v5_1.default({
|
|
36
37
|
SecretId: secretId,
|
|
37
38
|
SecretKey: secretKey,
|
|
@@ -41,6 +42,10 @@ async function publish(options) {
|
|
|
41
42
|
const appCfg = PUBLISH_APP_CFG[file.ext];
|
|
42
43
|
const fileName = appCfg?.name || `${file.name}.${file.ext}`;
|
|
43
44
|
const filePath = (0, path_1.join)(const_1.COMMAND_PATH, appCfg?.path || file.path);
|
|
45
|
+
const source = (0, path_1.join)(filePath, fileName);
|
|
46
|
+
if (!(0, fs_1.existsSync)(source)) {
|
|
47
|
+
utils_1.log.error(`未找到待上传文件:${source}`);
|
|
48
|
+
}
|
|
44
49
|
const destName = `${versionName}.${versionCode}.${file.ext}`;
|
|
45
50
|
const path = `${remotePath}/${destName}`;
|
|
46
51
|
const remoteUrl = `https://${bucket}.cos.${region}.myqcloud.com${`/${path}`.replace(/\/+/g, '/')}`;
|
|
@@ -50,7 +55,7 @@ async function publish(options) {
|
|
|
50
55
|
Bucket: bucket,
|
|
51
56
|
Region: region,
|
|
52
57
|
Key: path,
|
|
53
|
-
Body: (0, fs_1.readFileSync)(
|
|
58
|
+
Body: (0, fs_1.readFileSync)(source),
|
|
54
59
|
}, (err) => {
|
|
55
60
|
spinner.stop();
|
|
56
61
|
if (err) {
|
package/lib/utils/function.d.ts
CHANGED
|
@@ -14,6 +14,33 @@ export declare function isUniappXManifest(pathOrManifest?: string | Record<strin
|
|
|
14
14
|
* @param pkg package.json 内容
|
|
15
15
|
*/
|
|
16
16
|
export declare function resolveAppId(manifest?: Record<string, unknown>, pkg?: Record<string, any>): string;
|
|
17
|
+
/**
|
|
18
|
+
* 把 `-p` 的具体 App 平台换算成管理平台枚举:1 Android / 2 iOS / 3 Harmony。
|
|
19
|
+
* `app`、`h5`、`mp-*` 等非具体平台返回 0(表示需要提问或沿用配置)。
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolvePublishPlatform(platform?: string): 0 | 1 | 2 | 3;
|
|
22
|
+
/** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
|
|
23
|
+
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
|
+
/** uni-app x 的 App 平台子目录(unpackage/release、unpackage/resources 下同名目录) */
|
|
25
|
+
export type AppXPlatformDir = 'app-android' | 'app-ios' | 'app-harmony';
|
|
26
|
+
/**
|
|
27
|
+
* 解析 uni-app x 的 App 平台子目录:显式 `-p app-*` 优先,其次按发布平台选择。
|
|
28
|
+
* 两者都没有时返回 undefined,由调用方报错提示(不做 Android 兜底)。
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveAppXPlatformDir(platform?: string, publishPlatform?: number): AppXPlatformDir | undefined;
|
|
31
|
+
/** uni-app x 的短平台名(远端 COS 目录用) */
|
|
32
|
+
export type AppPlatformName = 'android' | 'ios' | 'harmony';
|
|
33
|
+
/**
|
|
34
|
+
* 解析 uni-app x 的短平台名:显式 `-p app-*` 优先,其次按发布平台选择,都缺省时返回 undefined。
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveAppPlatformName(platform?: string, publishPlatform?: number): AppPlatformName | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* 解析 HBuilderX 发布平台:经典 uni-app 的 `app` 归一为 `APP`;
|
|
39
|
+
* uni-app x 的 wgt 与资源包是按平台产出的,`app` 需落到具体平台(无法确定时返回 undefined)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveHBuilderXPlatform(platform: string, isUniappX: boolean, publishPlatform?: number): string | undefined;
|
|
42
|
+
/** 追加子目录;目录已包含该子目录时原样返回,避免重复追加 */
|
|
43
|
+
export declare function joinAppXDir(base: string, subDir?: string): string;
|
|
17
44
|
export declare function objectToCommand(obj?: Record<string, any>): {};
|
|
18
45
|
export declare function filterToArray(obj?: Record<string, any>): any[];
|
|
19
46
|
export declare function spawnSync(command?: string): import("child_process").SpawnSyncReturns<Buffer>;
|
package/lib/utils/function.js
CHANGED
|
@@ -3,10 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UNIAPPX_APP_PLATFORM_REQUIRED = void 0;
|
|
6
7
|
exports.getManifestPath = getManifestPath;
|
|
7
8
|
exports.readManifest = readManifest;
|
|
8
9
|
exports.isUniappXManifest = isUniappXManifest;
|
|
9
10
|
exports.resolveAppId = resolveAppId;
|
|
11
|
+
exports.resolvePublishPlatform = resolvePublishPlatform;
|
|
12
|
+
exports.resolveAppXPlatformDir = resolveAppXPlatformDir;
|
|
13
|
+
exports.resolveAppPlatformName = resolveAppPlatformName;
|
|
14
|
+
exports.resolveHBuilderXPlatform = resolveHBuilderXPlatform;
|
|
15
|
+
exports.joinAppXDir = joinAppXDir;
|
|
10
16
|
exports.objectToCommand = objectToCommand;
|
|
11
17
|
exports.filterToArray = filterToArray;
|
|
12
18
|
exports.spawnSync = spawnSync;
|
|
@@ -54,6 +60,61 @@ function isUniappXManifest(pathOrManifest = const_1.COMMAND_PATH) {
|
|
|
54
60
|
function resolveAppId(manifest = {}, pkg = {}) {
|
|
55
61
|
return String(pkg.appId || manifest.appid || '');
|
|
56
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 把 `-p` 的具体 App 平台换算成管理平台枚举:1 Android / 2 iOS / 3 Harmony。
|
|
65
|
+
* `app`、`h5`、`mp-*` 等非具体平台返回 0(表示需要提问或沿用配置)。
|
|
66
|
+
*/
|
|
67
|
+
function resolvePublishPlatform(platform) {
|
|
68
|
+
if (platform === 'app-android')
|
|
69
|
+
return 1;
|
|
70
|
+
if (platform === 'app-ios')
|
|
71
|
+
return 2;
|
|
72
|
+
if (platform === 'app-harmony')
|
|
73
|
+
return 3;
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
/** uni-app x 的 App 平台无法确定时的提示(不默认 Android) */
|
|
77
|
+
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
|
+
/**
|
|
79
|
+
* 解析 uni-app x 的 App 平台子目录:显式 `-p app-*` 优先,其次按发布平台选择。
|
|
80
|
+
* 两者都没有时返回 undefined,由调用方报错提示(不做 Android 兜底)。
|
|
81
|
+
*/
|
|
82
|
+
function resolveAppXPlatformDir(platform, publishPlatform) {
|
|
83
|
+
if (platform === 'app-android' || platform === 'app-ios' || platform === 'app-harmony') {
|
|
84
|
+
return platform;
|
|
85
|
+
}
|
|
86
|
+
if (publishPlatform === 1)
|
|
87
|
+
return 'app-android';
|
|
88
|
+
if (publishPlatform === 2)
|
|
89
|
+
return 'app-ios';
|
|
90
|
+
if (publishPlatform === 3)
|
|
91
|
+
return 'app-harmony';
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 解析 uni-app x 的短平台名:显式 `-p app-*` 优先,其次按发布平台选择,都缺省时返回 undefined。
|
|
96
|
+
*/
|
|
97
|
+
function resolveAppPlatformName(platform, publishPlatform) {
|
|
98
|
+
const dir = resolveAppXPlatformDir(platform, publishPlatform);
|
|
99
|
+
if (!dir)
|
|
100
|
+
return undefined;
|
|
101
|
+
return dir === 'app-ios' ? 'ios' : dir === 'app-harmony' ? 'harmony' : 'android';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 解析 HBuilderX 发布平台:经典 uni-app 的 `app` 归一为 `APP`;
|
|
105
|
+
* uni-app x 的 wgt 与资源包是按平台产出的,`app` 需落到具体平台(无法确定时返回 undefined)。
|
|
106
|
+
*/
|
|
107
|
+
function resolveHBuilderXPlatform(platform, isUniappX, publishPlatform) {
|
|
108
|
+
if (platform !== 'app')
|
|
109
|
+
return platform;
|
|
110
|
+
return isUniappX ? resolveAppXPlatformDir(platform, publishPlatform) : 'APP';
|
|
111
|
+
}
|
|
112
|
+
/** 追加子目录;目录已包含该子目录时原样返回,避免重复追加 */
|
|
113
|
+
function joinAppXDir(base, subDir) {
|
|
114
|
+
if (!subDir)
|
|
115
|
+
return base;
|
|
116
|
+
return (0, path_1.basename)(base) === subDir ? base : (0, path_1.join)(base, subDir);
|
|
117
|
+
}
|
|
57
118
|
function objectToCommand(obj = {}) {
|
|
58
119
|
const object = (0, flat_1.flatten)(obj);
|
|
59
120
|
const res = {};
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"path": {
|
|
73
73
|
"type": "string",
|
|
74
|
-
"description": "
|
|
74
|
+
"description": "远程路径,默认 /app/{appId}(uni-app x 会追加平台目录 android|ios|harmony);配置后按该路径上传,不再追加平台目录"
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"required": ["brand", "type"]
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"path": {
|
|
104
104
|
"type": "string",
|
|
105
|
-
"description": "
|
|
105
|
+
"description": "远程路径,默认 /app/{appId}(uni-app x 会追加平台目录 android|ios|harmony);配置后按该路径上传,不再追加平台目录"
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
"required": ["publishType"]
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
},
|
|
257
257
|
"path": {
|
|
258
258
|
"type": "string",
|
|
259
|
-
"description": "导出路径,默认unpackage/release"
|
|
259
|
+
"description": "导出路径,默认unpackage/release;uni-app x 未配置时自动使用 unpackage/release/app-android|app-ios|app-harmony,自定义后按填写目录读取(不再追加平台子目录)"
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
},
|