react-native-update-cli 2.23.0 → 2.23.1
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/lib/app.d.ts +28 -0
- package/lib/app.js +71 -9
- package/lib/bundle.d.ts +4 -0
- package/lib/bundle.js +48 -23
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +8 -7
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +8 -7
- package/lib/package.d.ts +1 -0
- package/lib/package.js +7 -13
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +4 -2
- package/lib/types.d.ts +5 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +3 -1
- package/lib/versions.js +18 -43
- package/package.json +1 -1
- package/src/app.ts +89 -16
- package/src/bundle.ts +54 -28
- package/src/locales/en.ts +9 -7
- package/src/locales/zh.ts +9 -7
- package/src/package.ts +12 -23
- package/src/provider.ts +4 -1
- package/src/types.ts +5 -0
- package/src/utils/constants.ts +3 -1
- package/src/versions.ts +19 -52
package/lib/versions.js
CHANGED
|
@@ -367,10 +367,7 @@ exports.versionCommands = {
|
|
|
367
367
|
throw new Error((0, i18n_1.t)('publishUsage'));
|
|
368
368
|
}
|
|
369
369
|
const platform = await (0, app_1.getPlatform)(options.platform);
|
|
370
|
-
|
|
371
|
-
if (!appId) {
|
|
372
|
-
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
373
|
-
}
|
|
370
|
+
const appId = await (0, app_1.resolveAppId)({ ...options, platform });
|
|
374
371
|
const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
|
|
375
372
|
// The source map is archived with the version so `pushy symbolicate` can
|
|
376
373
|
// map crashes back to source. An explicit path that does not exist is a
|
|
@@ -444,6 +441,7 @@ exports.versionCommands = {
|
|
|
444
441
|
options: {
|
|
445
442
|
versionId: id,
|
|
446
443
|
platform,
|
|
444
|
+
appId,
|
|
447
445
|
packageId,
|
|
448
446
|
packageVersion,
|
|
449
447
|
packageVersionRange,
|
|
@@ -463,6 +461,7 @@ exports.versionCommands = {
|
|
|
463
461
|
options: {
|
|
464
462
|
versionId: id,
|
|
465
463
|
platform,
|
|
464
|
+
appId,
|
|
466
465
|
versionDeps: depVersions,
|
|
467
466
|
warnDepsChanges: true,
|
|
468
467
|
},
|
|
@@ -472,31 +471,19 @@ exports.versionCommands = {
|
|
|
472
471
|
return versionName;
|
|
473
472
|
},
|
|
474
473
|
versions: async ({ options }) => {
|
|
475
|
-
|
|
476
|
-
if (!appId) {
|
|
477
|
-
const platform = await (0, app_1.getPlatform)(options.platform);
|
|
478
|
-
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
479
|
-
}
|
|
474
|
+
const appId = await (0, app_1.resolveAppId)(options);
|
|
480
475
|
const interactive = !((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
|
|
481
|
-
await listVersions(
|
|
476
|
+
await listVersions(appId, interactive);
|
|
482
477
|
},
|
|
483
478
|
update: async ({ options }) => {
|
|
484
479
|
const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
|
|
485
|
-
|
|
486
|
-
let platform = options.platform;
|
|
487
|
-
if (!appId) {
|
|
488
|
-
platform = await (0, app_1.getPlatform)(platform);
|
|
489
|
-
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
490
|
-
}
|
|
491
|
-
else if (platform) {
|
|
492
|
-
platform = await (0, app_1.getPlatform)(platform);
|
|
493
|
-
}
|
|
480
|
+
const appId = await (0, app_1.resolveAppId)(options);
|
|
494
481
|
let versionId = options.versionId;
|
|
495
482
|
if (!versionId) {
|
|
496
483
|
if (nonInteractive) {
|
|
497
484
|
throw new Error((0, i18n_1.t)('versionIdRequired'));
|
|
498
485
|
}
|
|
499
|
-
versionId = String((await chooseVersion(
|
|
486
|
+
versionId = String((await chooseVersion(appId)).id);
|
|
500
487
|
}
|
|
501
488
|
if (versionId === 'null') {
|
|
502
489
|
versionId = null;
|
|
@@ -513,7 +500,7 @@ exports.versionCommands = {
|
|
|
513
500
|
throw new Error((0, i18n_1.t)('rolloutRangeError'));
|
|
514
501
|
}
|
|
515
502
|
}
|
|
516
|
-
const allPkgs = await (0, api_1.getAllPackages)(
|
|
503
|
+
const allPkgs = await (0, api_1.getAllPackages)(appId);
|
|
517
504
|
if (!allPkgs) {
|
|
518
505
|
throw new Error((0, i18n_1.t)('noPackagesFound', { appId }));
|
|
519
506
|
}
|
|
@@ -572,7 +559,7 @@ exports.versionCommands = {
|
|
|
572
559
|
throw new Error((0, i18n_1.t)('packageIdRequired'));
|
|
573
560
|
}
|
|
574
561
|
// the package list was already fetched above: no second round trip
|
|
575
|
-
pkgId = String((await (0, package_1.choosePackage)(
|
|
562
|
+
pkgId = String((await (0, package_1.choosePackage)(appId, allPkgs)).id);
|
|
576
563
|
}
|
|
577
564
|
if (!pkgId) {
|
|
578
565
|
throw new Error((0, i18n_1.t)('packageIdRequired'));
|
|
@@ -587,14 +574,14 @@ exports.versionCommands = {
|
|
|
587
574
|
}
|
|
588
575
|
if (options.warnDepsChanges && versionId) {
|
|
589
576
|
await printDepsChangesForPublish({
|
|
590
|
-
appId
|
|
577
|
+
appId,
|
|
591
578
|
versionId: String(versionId),
|
|
592
579
|
pkgs: pkgsToBind,
|
|
593
580
|
providedVersionDeps: options.versionDeps,
|
|
594
581
|
});
|
|
595
582
|
}
|
|
596
583
|
await (0, exports.bindVersionToPackages)({
|
|
597
|
-
appId
|
|
584
|
+
appId,
|
|
598
585
|
// keep null as-is: `--versionId null` means unbinding the version
|
|
599
586
|
versionId: versionId ?? null,
|
|
600
587
|
pkgs: pkgsToBind,
|
|
@@ -604,21 +591,13 @@ exports.versionCommands = {
|
|
|
604
591
|
},
|
|
605
592
|
updateVersionInfo: async ({ options, }) => {
|
|
606
593
|
const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
|
|
607
|
-
|
|
608
|
-
let platform = options.platform;
|
|
609
|
-
if (!appId) {
|
|
610
|
-
platform = await (0, app_1.getPlatform)(platform);
|
|
611
|
-
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
612
|
-
}
|
|
613
|
-
else if (platform) {
|
|
614
|
-
await (0, app_1.getPlatform)(platform);
|
|
615
|
-
}
|
|
594
|
+
const appId = await (0, app_1.resolveAppId)(options);
|
|
616
595
|
let versionId = options.versionId;
|
|
617
596
|
if (!versionId) {
|
|
618
597
|
if (nonInteractive) {
|
|
619
598
|
throw new Error((0, i18n_1.t)('versionIdRequired'));
|
|
620
599
|
}
|
|
621
|
-
versionId = String((await chooseVersion(
|
|
600
|
+
versionId = String((await chooseVersion(appId)).id);
|
|
622
601
|
}
|
|
623
602
|
const updateParams = {};
|
|
624
603
|
if (options.name)
|
|
@@ -627,16 +606,12 @@ exports.versionCommands = {
|
|
|
627
606
|
updateParams.description = options.description;
|
|
628
607
|
if (options.metaInfo)
|
|
629
608
|
updateParams.metaInfo = options.metaInfo;
|
|
630
|
-
await (0, api_1.put)(`/app/${
|
|
609
|
+
await (0, api_1.put)(`/app/${appId}/version/${versionId}`, updateParams);
|
|
631
610
|
console.log((0, i18n_1.t)('operationSuccess'));
|
|
632
611
|
},
|
|
633
612
|
deleteVersion: async ({ options }) => {
|
|
634
613
|
const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
|
|
635
|
-
|
|
636
|
-
if (!appId) {
|
|
637
|
-
const platform = await (0, app_1.getPlatform)(options.platform);
|
|
638
|
-
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
639
|
-
}
|
|
614
|
+
const appId = await (0, app_1.resolveAppId)(options);
|
|
640
615
|
const parsedVersionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
|
|
641
616
|
(0, options_1.getStringListOption)(options, 'versionId');
|
|
642
617
|
let versionIds = parsedVersionIds;
|
|
@@ -644,16 +619,16 @@ exports.versionCommands = {
|
|
|
644
619
|
if (nonInteractive) {
|
|
645
620
|
throw new Error((0, i18n_1.t)('versionIdRequired'));
|
|
646
621
|
}
|
|
647
|
-
versionIds = [String((await chooseVersion(
|
|
622
|
+
versionIds = [String((await chooseVersion(appId)).id)];
|
|
648
623
|
}
|
|
649
624
|
try {
|
|
650
625
|
if (versionIds.length === 1) {
|
|
651
626
|
const [versionId] = versionIds;
|
|
652
|
-
await (0, api_1.doDelete)(`/app/${
|
|
627
|
+
await (0, api_1.doDelete)(`/app/${appId}/version/${versionId}`);
|
|
653
628
|
console.log((0, i18n_1.t)('deleteVersionSuccess', { versionId }));
|
|
654
629
|
}
|
|
655
630
|
else {
|
|
656
|
-
await (0, api_1.doDelete)(`/app/${
|
|
631
|
+
await (0, api_1.doDelete)(`/app/${appId}/version`, {
|
|
657
632
|
versionIds: toNumericIds(versionIds),
|
|
658
633
|
});
|
|
659
634
|
console.log((0, i18n_1.t)('deleteVersionsSuccess', {
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import { doDelete, get, post } from './api';
|
|
3
3
|
import type { Platform } from './types';
|
|
4
4
|
import { loadTtyTable, question } from './utils';
|
|
5
|
+
import { updateJson } from './utils/constants';
|
|
5
6
|
import { t } from './utils/i18n';
|
|
6
7
|
|
|
7
8
|
interface AppSummary {
|
|
@@ -10,12 +11,29 @@ interface AppSummary {
|
|
|
10
11
|
platform: Platform;
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export interface AppTargetOptions {
|
|
15
|
+
appId?: string;
|
|
16
|
+
config?: string;
|
|
17
|
+
platform?: Platform | '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The selected-app config file was missing or has no entry for the platform. */
|
|
21
|
+
export class AppNotSelectedError extends Error {
|
|
22
|
+
readonly code = 'APP_NOT_SELECTED';
|
|
23
|
+
constructor(platform: Platform) {
|
|
24
|
+
super(t('appNotSelected', { platform }));
|
|
25
|
+
this.name = 'AppNotSelectedError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Resolve an explicit platform or prompt for one interactively. */
|
|
13
30
|
export async function getPlatform(platform?: string) {
|
|
14
31
|
return assertPlatform(
|
|
15
32
|
platform || (await question(t('platformQuestion'))),
|
|
16
33
|
) as Platform;
|
|
17
34
|
}
|
|
18
35
|
|
|
36
|
+
/** Validate that a string names a platform supported by the update service. */
|
|
19
37
|
export function assertPlatform(platform: string): Platform {
|
|
20
38
|
if (platform !== 'ios' && platform !== 'android' && platform !== 'harmony') {
|
|
21
39
|
throw new Error(t('unsupportedPlatform', { platform }));
|
|
@@ -23,27 +41,34 @@ export function assertPlatform(platform: string): Platform {
|
|
|
23
41
|
return platform as Platform;
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
/** Read the selected app for a platform from the requested config file. */
|
|
26
45
|
export async function getSelectedApp(
|
|
27
46
|
platform: Platform,
|
|
28
47
|
configPath?: string,
|
|
29
48
|
): Promise<{ appId: string; appKey: string; platform: Platform }> {
|
|
30
49
|
assertPlatform(platform);
|
|
31
50
|
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
const resolvedConfigPath = configPath || updateJson;
|
|
52
|
+
let raw: string;
|
|
34
53
|
try {
|
|
35
|
-
|
|
36
|
-
await fs.promises.readFile(configPath || 'update.json', 'utf8'),
|
|
37
|
-
);
|
|
54
|
+
raw = await fs.promises.readFile(resolvedConfigPath, 'utf8');
|
|
38
55
|
} catch (e: any) {
|
|
39
56
|
if (e.code === 'ENOENT') {
|
|
40
|
-
throw new
|
|
57
|
+
throw new AppNotSelectedError(platform);
|
|
41
58
|
}
|
|
42
59
|
throw e;
|
|
43
60
|
}
|
|
61
|
+
let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>>;
|
|
62
|
+
try {
|
|
63
|
+
updateInfo = JSON.parse(raw);
|
|
64
|
+
} catch {
|
|
65
|
+
throw new Error(
|
|
66
|
+
t('failedToParseUpdateJson', { configPath: resolvedConfigPath }),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
44
69
|
const info = updateInfo[platform];
|
|
45
70
|
if (!info) {
|
|
46
|
-
throw new
|
|
71
|
+
throw new AppNotSelectedError(platform);
|
|
47
72
|
}
|
|
48
73
|
return {
|
|
49
74
|
appId: String(info.appId),
|
|
@@ -52,6 +77,45 @@ export async function getSelectedApp(
|
|
|
52
77
|
};
|
|
53
78
|
}
|
|
54
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Fail fast when an explicit `--appId` names an app of another platform.
|
|
82
|
+
* The server accepts a bundle for any app the account owns and never sees
|
|
83
|
+
* the platform it was built for, so this is the only place the mistake can
|
|
84
|
+
* be caught before it reaches devices. A missing or foreign app fails here
|
|
85
|
+
* too (403/404) instead of after the expensive work.
|
|
86
|
+
*/
|
|
87
|
+
async function assertAppPlatform(appId: string, platform: Platform) {
|
|
88
|
+
const app = (await get(`/app/${appId}`)) as { platform?: Platform };
|
|
89
|
+
if (app.platform && app.platform !== platform) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
t('appPlatformMismatch', { appId, appPlatform: app.platform, platform }),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve the app an operation targets: an explicit `--appId` wins, otherwise
|
|
98
|
+
* the app selected for the platform in `--config` (default: update.json).
|
|
99
|
+
* Prompts for the platform only when it is needed and not given.
|
|
100
|
+
*/
|
|
101
|
+
export async function resolveAppId(
|
|
102
|
+
options: AppTargetOptions = {},
|
|
103
|
+
): Promise<string> {
|
|
104
|
+
if (options.platform) {
|
|
105
|
+
assertPlatform(options.platform);
|
|
106
|
+
}
|
|
107
|
+
if (options.appId) {
|
|
108
|
+
const appId = String(options.appId);
|
|
109
|
+
if (options.platform) {
|
|
110
|
+
await assertAppPlatform(appId, options.platform);
|
|
111
|
+
}
|
|
112
|
+
return appId;
|
|
113
|
+
}
|
|
114
|
+
const platform = await getPlatform(options.platform || undefined);
|
|
115
|
+
return (await getSelectedApp(platform, options.config)).appId;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** List apps, optionally filtering them to one platform. */
|
|
55
119
|
export async function listApp(platform: Platform | '' = '') {
|
|
56
120
|
const { data } = await get('/app/list');
|
|
57
121
|
const allApps = data as AppSummary[];
|
|
@@ -77,6 +141,7 @@ export async function listApp(platform: Platform | '' = '') {
|
|
|
77
141
|
return list;
|
|
78
142
|
}
|
|
79
143
|
|
|
144
|
+
/** Prompt until the user chooses an app belonging to the target platform. */
|
|
80
145
|
export async function chooseApp(platform: Platform) {
|
|
81
146
|
const list = await listApp(platform);
|
|
82
147
|
|
|
@@ -89,28 +154,27 @@ export async function chooseApp(platform: Platform) {
|
|
|
89
154
|
}
|
|
90
155
|
}
|
|
91
156
|
|
|
157
|
+
/** Persist an app selection in the requested brand-aware config file. */
|
|
92
158
|
async function selectApp({
|
|
93
159
|
args,
|
|
94
160
|
options,
|
|
95
161
|
}: {
|
|
96
162
|
args: string[];
|
|
97
|
-
options: { platform?: Platform | '' };
|
|
163
|
+
options: { platform?: Platform | ''; config?: string };
|
|
98
164
|
}) {
|
|
99
165
|
const platform = await getPlatform(options.platform);
|
|
100
166
|
const id = args[0]
|
|
101
167
|
? Number.parseInt(args[0], 10)
|
|
102
168
|
: (await chooseApp(platform)).id;
|
|
103
169
|
|
|
104
|
-
const configPath =
|
|
170
|
+
const configPath = options.config || updateJson;
|
|
105
171
|
let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
|
|
106
172
|
{};
|
|
107
173
|
try {
|
|
108
|
-
updateInfo = JSON.parse(
|
|
109
|
-
await fs.promises.readFile(configPath || 'update.json', 'utf8'),
|
|
110
|
-
);
|
|
174
|
+
updateInfo = JSON.parse(await fs.promises.readFile(configPath, 'utf8'));
|
|
111
175
|
} catch (e: any) {
|
|
112
176
|
if (e.code !== 'ENOENT') {
|
|
113
|
-
console.error(t('failedToParseUpdateJson'));
|
|
177
|
+
console.error(t('failedToParseUpdateJson', { configPath }));
|
|
114
178
|
throw e;
|
|
115
179
|
}
|
|
116
180
|
}
|
|
@@ -120,18 +184,25 @@ async function selectApp({
|
|
|
120
184
|
appKey,
|
|
121
185
|
};
|
|
122
186
|
await fs.promises.writeFile(
|
|
123
|
-
configPath
|
|
187
|
+
configPath,
|
|
124
188
|
JSON.stringify(updateInfo, null, 4),
|
|
125
189
|
'utf8',
|
|
126
190
|
);
|
|
127
191
|
}
|
|
128
192
|
|
|
193
|
+
/** Build the application-management command handlers used by the CLI. */
|
|
129
194
|
export function getAppCommands() {
|
|
130
195
|
return {
|
|
196
|
+
/** Create an app and select it in the same configuration file. */
|
|
131
197
|
createApp: async ({
|
|
132
198
|
options,
|
|
133
199
|
}: {
|
|
134
|
-
options: {
|
|
200
|
+
options: {
|
|
201
|
+
name: string;
|
|
202
|
+
downloadUrl: string;
|
|
203
|
+
platform?: Platform | '';
|
|
204
|
+
config?: string;
|
|
205
|
+
};
|
|
135
206
|
}) => {
|
|
136
207
|
const name = options.name || (await question(t('appNameQuestion')));
|
|
137
208
|
const { downloadUrl } = options;
|
|
@@ -140,9 +211,10 @@ export function getAppCommands() {
|
|
|
140
211
|
console.log(t('createAppSuccess', { id }));
|
|
141
212
|
await selectApp({
|
|
142
213
|
args: [String(id)],
|
|
143
|
-
options: { platform },
|
|
214
|
+
options: { platform, config: options.config },
|
|
144
215
|
});
|
|
145
216
|
},
|
|
217
|
+
/** Delete the specified app, or prompt for one when no ID is supplied. */
|
|
146
218
|
deleteApp: async ({
|
|
147
219
|
args,
|
|
148
220
|
options,
|
|
@@ -159,6 +231,7 @@ export function getAppCommands() {
|
|
|
159
231
|
await doDelete(`/app/${id}`);
|
|
160
232
|
console.log(t('operationSuccess'));
|
|
161
233
|
},
|
|
234
|
+
/** List apps through the command interface. */
|
|
162
235
|
apps: async ({ options }: { options: { platform?: Platform | '' } }) => {
|
|
163
236
|
const { platform = '' } = options;
|
|
164
237
|
return listApp(platform);
|
package/src/bundle.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { getPlatform,
|
|
2
|
+
import { AppNotSelectedError, getPlatform, resolveAppId } from './app';
|
|
3
3
|
import { packBundle } from './bundle-pack';
|
|
4
4
|
import {
|
|
5
5
|
copyDebugidForSentry,
|
|
@@ -41,6 +41,8 @@ type NormalizedBundleOptions = {
|
|
|
41
41
|
verifyHermesBase: boolean;
|
|
42
42
|
resetCache: boolean;
|
|
43
43
|
cacheMaxMb?: number;
|
|
44
|
+
appId?: string;
|
|
45
|
+
config?: string;
|
|
44
46
|
name?: string;
|
|
45
47
|
description?: string;
|
|
46
48
|
metaInfo?: string;
|
|
@@ -55,12 +57,14 @@ type NormalizedBundleOptions = {
|
|
|
55
57
|
sentryDist?: string;
|
|
56
58
|
};
|
|
57
59
|
|
|
60
|
+
/** Parse a positive cache-size option expressed in megabytes. */
|
|
58
61
|
function parseCacheMaxMb(value: unknown): number | undefined {
|
|
59
62
|
const parsed = typeof value === 'string' ? Number(value) : (value as number);
|
|
60
63
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
type PublishBundlePayload = {
|
|
67
|
+
appId: string;
|
|
64
68
|
name?: string;
|
|
65
69
|
description?: string;
|
|
66
70
|
metaInfo?: string;
|
|
@@ -76,6 +80,7 @@ type PublishBundlePayload = {
|
|
|
76
80
|
sourcemap?: string;
|
|
77
81
|
};
|
|
78
82
|
|
|
83
|
+
/** Read either spelling of an aliased optional CLI string option. */
|
|
79
84
|
function getAliasedOptionalStringOption(
|
|
80
85
|
options: Record<string, unknown>,
|
|
81
86
|
key: string,
|
|
@@ -87,6 +92,7 @@ function getAliasedOptionalStringOption(
|
|
|
87
92
|
);
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
/** Normalize translated CLI values into the bundle command's typed options. */
|
|
90
96
|
export function normalizeBundleOptions(
|
|
91
97
|
translatedOptions: Record<string, unknown>,
|
|
92
98
|
platform: string,
|
|
@@ -125,6 +131,8 @@ export function normalizeBundleOptions(
|
|
|
125
131
|
),
|
|
126
132
|
resetCache: getBooleanOption(translatedOptions, 'resetCache', true),
|
|
127
133
|
cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
|
|
134
|
+
appId: getOptionalStringOption(translatedOptions, 'appId'),
|
|
135
|
+
config: getOptionalStringOption(translatedOptions, 'config'),
|
|
128
136
|
name: getOptionalStringOption(translatedOptions, 'name'),
|
|
129
137
|
description: getOptionalStringOption(translatedOptions, 'description'),
|
|
130
138
|
metaInfo: getOptionalStringOption(translatedOptions, 'metaInfo'),
|
|
@@ -160,6 +168,7 @@ export function normalizeBundleOptions(
|
|
|
160
168
|
};
|
|
161
169
|
}
|
|
162
170
|
|
|
171
|
+
/** Upload generated Sentry artifacts when the detected plugin requires them. */
|
|
163
172
|
async function uploadSentryArtifactsIfNeeded(
|
|
164
173
|
shouldUpload: boolean,
|
|
165
174
|
bundleName: string,
|
|
@@ -182,6 +191,7 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
182
191
|
);
|
|
183
192
|
}
|
|
184
193
|
|
|
194
|
+
/** Publish a packed bundle through the version command implementation. */
|
|
185
195
|
async function publishBundleVersion(
|
|
186
196
|
outputPath: string,
|
|
187
197
|
platform: Platform,
|
|
@@ -197,6 +207,7 @@ async function publishBundleVersion(
|
|
|
197
207
|
}
|
|
198
208
|
|
|
199
209
|
export const bundleCommands = {
|
|
210
|
+
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
200
211
|
bundle: async ({
|
|
201
212
|
options,
|
|
202
213
|
}: {
|
|
@@ -214,10 +225,48 @@ export const bundleCommands = {
|
|
|
214
225
|
});
|
|
215
226
|
const normalized = normalizeBundleOptions(translatedOptions, platform);
|
|
216
227
|
|
|
228
|
+
// One app per operation: the Hermes base lookup and the publish step must
|
|
229
|
+
// never see different apps, so the target is resolved once and reused.
|
|
230
|
+
let appId: string | undefined;
|
|
231
|
+
const getAppId = async () =>
|
|
232
|
+
(appId ??= await resolveAppId({
|
|
233
|
+
appId: normalized.appId,
|
|
234
|
+
config: normalized.config,
|
|
235
|
+
platform,
|
|
236
|
+
}));
|
|
237
|
+
const hermesBase =
|
|
238
|
+
normalized.dev === 'true'
|
|
239
|
+
? undefined
|
|
240
|
+
: {
|
|
241
|
+
option: normalized.hermesBase,
|
|
242
|
+
verify: normalized.verifyHermesBase,
|
|
243
|
+
cacheMaxMb: normalized.cacheMaxMb,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Resolve before any side effect or expensive work. A named bundle is
|
|
247
|
+
// published, so a missing app fails right here; a bundle-only run only
|
|
248
|
+
// needs the app for the remote Hermes base lookup and may go on without
|
|
249
|
+
// one (it then compiles a full bundle). Any other config error (e.g.
|
|
250
|
+
// malformed JSON) is reported immediately either way.
|
|
251
|
+
if (normalized.name) {
|
|
252
|
+
await getAppId();
|
|
253
|
+
} else if (hermesBase?.option === 'auto') {
|
|
254
|
+
try {
|
|
255
|
+
await getAppId();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
if (!(error instanceof AppNotSelectedError)) {
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
217
263
|
checkLockFiles();
|
|
218
264
|
addGitIgnore();
|
|
219
265
|
|
|
220
|
-
const bundleParams = await
|
|
266
|
+
const [bundleParams] = await Promise.all([
|
|
267
|
+
checkPlugins(),
|
|
268
|
+
cleanStaleTmp().catch(() => {}),
|
|
269
|
+
]);
|
|
221
270
|
const sourcemapOutput = path.join(
|
|
222
271
|
normalized.intermediaDir,
|
|
223
272
|
`${normalized.bundleName}.map`,
|
|
@@ -233,23 +282,6 @@ export const bundleCommands = {
|
|
|
233
282
|
|
|
234
283
|
console.log(t('bundlingWithRN', { version: depVersions['react-native'] }));
|
|
235
284
|
|
|
236
|
-
await cleanStaleTmp().catch(() => {});
|
|
237
|
-
// the hermes base lookup needs the app; resolve it up front but never
|
|
238
|
-
// fail the bundle over it (publishing resolves it again and reports)
|
|
239
|
-
let appIdForBase: string | undefined =
|
|
240
|
-
typeof options.appId === 'string' && options.appId
|
|
241
|
-
? options.appId
|
|
242
|
-
: undefined;
|
|
243
|
-
if (!appIdForBase && normalized.hermesBase === 'auto') {
|
|
244
|
-
try {
|
|
245
|
-
appIdForBase = (
|
|
246
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
247
|
-
).appId;
|
|
248
|
-
} catch {
|
|
249
|
-
appIdForBase = undefined;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
285
|
const hermesResult = await runReactNativeBundleCommand({
|
|
254
286
|
bundleName: normalized.bundleName,
|
|
255
287
|
dev: normalized.dev,
|
|
@@ -259,15 +291,7 @@ export const bundleCommands = {
|
|
|
259
291
|
sourcemapOutput:
|
|
260
292
|
normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
|
|
261
293
|
forceHermes: normalized.hermes,
|
|
262
|
-
hermesBase:
|
|
263
|
-
normalized.dev === 'true'
|
|
264
|
-
? undefined
|
|
265
|
-
: {
|
|
266
|
-
option: normalized.hermesBase,
|
|
267
|
-
appId: appIdForBase,
|
|
268
|
-
verify: normalized.verifyHermesBase,
|
|
269
|
-
cacheMaxMb: normalized.cacheMaxMb,
|
|
270
|
-
},
|
|
294
|
+
hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
|
|
271
295
|
resetCache: normalized.resetCache,
|
|
272
296
|
cli: {
|
|
273
297
|
taro: normalized.taro,
|
|
@@ -288,6 +312,7 @@ export const bundleCommands = {
|
|
|
288
312
|
|
|
289
313
|
if (normalized.name) {
|
|
290
314
|
await publishBundleVersion(realOutput, platform, {
|
|
315
|
+
appId: await getAppId(),
|
|
291
316
|
name: normalized.name,
|
|
292
317
|
description: normalized.description,
|
|
293
318
|
metaInfo: normalized.metaInfo,
|
|
@@ -322,6 +347,7 @@ export const bundleCommands = {
|
|
|
322
347
|
const v = await question(t('uploadBundlePrompt'));
|
|
323
348
|
if (v.toLowerCase() === 'y') {
|
|
324
349
|
await publishBundleVersion(realOutput, platform, {
|
|
350
|
+
appId: await getAppId(),
|
|
325
351
|
hermesBase: baseMeta,
|
|
326
352
|
sourcemap:
|
|
327
353
|
normalized.sourcemap || bundleParams.sourcemap
|
package/src/locales/en.ts
CHANGED
|
@@ -16,19 +16,21 @@ export default {
|
|
|
16
16
|
aabParseResourcesError: 'Parser resources.arsc error: {{error}}',
|
|
17
17
|
appId: 'App ID',
|
|
18
18
|
appIdMismatchApk:
|
|
19
|
-
'App ID mismatch! Current APK: {{appIdInPkg}}, current
|
|
19
|
+
'App ID mismatch! Current APK: {{appIdInPkg}}, current {{- source}}: {{appId}}',
|
|
20
20
|
appIdMismatchApp:
|
|
21
|
-
'App ID mismatch! Current APP: {{appIdInPkg}}, current
|
|
21
|
+
'App ID mismatch! Current APP: {{appIdInPkg}}, current {{- source}}: {{appId}}',
|
|
22
22
|
appIdMismatchIpa:
|
|
23
|
-
'App ID mismatch! Current IPA: {{appIdInPkg}}, current
|
|
23
|
+
'App ID mismatch! Current IPA: {{appIdInPkg}}, current {{- source}}: {{appId}}',
|
|
24
24
|
appKeyMismatchApk:
|
|
25
|
-
'App Key mismatch! Current APK: {{appKeyInPkg}}, current
|
|
25
|
+
'App Key mismatch! Current APK: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
|
|
26
26
|
appKeyMismatchApp:
|
|
27
|
-
'App Key mismatch! Current APP: {{appKeyInPkg}}, current
|
|
27
|
+
'App Key mismatch! Current APP: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
|
|
28
28
|
appKeyMismatchIpa:
|
|
29
|
-
'App Key mismatch! Current IPA: {{appKeyInPkg}}, current
|
|
29
|
+
'App Key mismatch! Current IPA: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
|
|
30
30
|
appName: 'App Name',
|
|
31
31
|
appNameQuestion: 'App Name:',
|
|
32
|
+
appPlatformMismatch:
|
|
33
|
+
'App {{appId}} is a {{appPlatform}} app, but this command targets {{platform}}',
|
|
32
34
|
appNotSelected:
|
|
33
35
|
'App not selected. run `cresc selectApp --platform {{platform}}` first!',
|
|
34
36
|
appUploadSuccess:
|
|
@@ -57,7 +59,7 @@ export default {
|
|
|
57
59
|
expiredStatus: '(Expired)',
|
|
58
60
|
failedToParseIcon: '[Warning] failed to parse icon: {{error}}',
|
|
59
61
|
failedToParseUpdateJson:
|
|
60
|
-
'Failed to parse file `
|
|
62
|
+
'Failed to parse file `{{- configPath}}`. Try to remove it manually.',
|
|
61
63
|
fileGenerated: '{{- file}} generated.',
|
|
62
64
|
fileSizeExceeded:
|
|
63
65
|
'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
|
package/src/locales/zh.ts
CHANGED
|
@@ -14,19 +14,21 @@ export default {
|
|
|
14
14
|
aabParseResourcesError: '解析 resources.arsc 出错:{{error}}',
|
|
15
15
|
appId: '应用 id',
|
|
16
16
|
appIdMismatchApk:
|
|
17
|
-
'appId不匹配!当前apk: {{appIdInPkg}}, 当前
|
|
17
|
+
'appId不匹配!当前apk: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
|
|
18
18
|
appIdMismatchApp:
|
|
19
|
-
'appId不匹配!当前app: {{appIdInPkg}}, 当前
|
|
19
|
+
'appId不匹配!当前app: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
|
|
20
20
|
appIdMismatchIpa:
|
|
21
|
-
'appId不匹配!当前ipa: {{appIdInPkg}}, 当前
|
|
21
|
+
'appId不匹配!当前ipa: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
|
|
22
22
|
appKeyMismatchApk:
|
|
23
|
-
'appKey不匹配!当前apk: {{appKeyInPkg}}, 当前
|
|
23
|
+
'appKey不匹配!当前apk: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
|
|
24
24
|
appKeyMismatchApp:
|
|
25
|
-
'appKey不匹配!当前app: {{appKeyInPkg}}, 当前
|
|
25
|
+
'appKey不匹配!当前app: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
|
|
26
26
|
appKeyMismatchIpa:
|
|
27
|
-
'appKey不匹配!当前ipa: {{appKeyInPkg}}, 当前
|
|
27
|
+
'appKey不匹配!当前ipa: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
|
|
28
28
|
appName: '应用名称',
|
|
29
29
|
appNameQuestion: '应用名称:',
|
|
30
|
+
appPlatformMismatch:
|
|
31
|
+
'应用 {{appId}} 是 {{appPlatform}} 平台的应用,但当前命令的平台是 {{platform}}',
|
|
30
32
|
appNotSelected:
|
|
31
33
|
'尚未选择应用。请先运行 `pushy selectApp --platform {{platform}}` 来选择应用',
|
|
32
34
|
appUploadSuccess:
|
|
@@ -53,7 +55,7 @@ export default {
|
|
|
53
55
|
errorInHarmonyApp: '获取 Harmony 应用入口时出错:{{error}}',
|
|
54
56
|
expiredStatus: '(已过期)',
|
|
55
57
|
failedToParseIcon: '[警告] 解析图标失败:{{error}}',
|
|
56
|
-
failedToParseUpdateJson: '无法解析文件 `
|
|
58
|
+
failedToParseUpdateJson: '无法解析文件 `{{- configPath}}`。请手动删除它。',
|
|
57
59
|
fileGenerated: '已生成 {{- file}}',
|
|
58
60
|
fileSizeExceeded:
|
|
59
61
|
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
|