react-native-update-cli 2.22.9 → 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/README.md +3 -2
- package/README.zh-CN.md +3 -2
- package/cli.json +21 -1
- package/lib/app.d.ts +28 -0
- package/lib/app.js +71 -9
- package/lib/bin.js +2 -0
- package/lib/bundle.d.ts +4 -0
- package/lib/bundle.js +57 -24
- package/lib/locales/en.d.ts +9 -0
- package/lib/locales/en.js +16 -7
- package/lib/locales/zh.d.ts +9 -0
- package/lib/locales/zh.js +16 -7
- package/lib/package.d.ts +1 -0
- package/lib/package.js +7 -13
- package/lib/provider.d.ts +3 -2
- package/lib/provider.js +19 -2
- package/lib/symbolicate.d.ts +30 -0
- package/lib/symbolicate.js +117 -0
- package/lib/types.d.ts +22 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +3 -1
- package/lib/versions.js +56 -44
- package/package.json +2 -1
- package/src/app.ts +89 -16
- package/src/bin.ts +2 -0
- package/src/bundle.ts +67 -29
- package/src/locales/en.ts +23 -7
- package/src/locales/zh.ts +20 -7
- package/src/package.ts +12 -23
- package/src/provider.ts +28 -1
- package/src/symbolicate.ts +159 -0
- package/src/types.ts +23 -0
- package/src/utils/constants.ts +3 -1
- package/src/versions.ts +66 -53
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/bin.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { cacheCommands } from './cache';
|
|
|
7
7
|
import { diffCommands } from './diff';
|
|
8
8
|
import { installCommands } from './install';
|
|
9
9
|
import { packageCommands } from './package';
|
|
10
|
+
import { symbolicateCommands } from './symbolicate';
|
|
10
11
|
import { userCommands } from './user';
|
|
11
12
|
import { printVersionCommand } from './utils';
|
|
12
13
|
import { t } from './utils/i18n';
|
|
@@ -52,6 +53,7 @@ const commandHandlers: Record<string, CliCommandHandler> = {
|
|
|
52
53
|
...getAppCommands(),
|
|
53
54
|
...packageCommands,
|
|
54
55
|
...versionCommands,
|
|
56
|
+
...symbolicateCommands,
|
|
55
57
|
...installCommands,
|
|
56
58
|
help: printUsage,
|
|
57
59
|
};
|
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;
|
|
@@ -72,8 +76,11 @@ type PublishBundlePayload = {
|
|
|
72
76
|
rollout?: string;
|
|
73
77
|
dryRun?: boolean;
|
|
74
78
|
hermesBase?: HermesBaseMeta;
|
|
79
|
+
/** path of the final source map to archive with the version */
|
|
80
|
+
sourcemap?: string;
|
|
75
81
|
};
|
|
76
82
|
|
|
83
|
+
/** Read either spelling of an aliased optional CLI string option. */
|
|
77
84
|
function getAliasedOptionalStringOption(
|
|
78
85
|
options: Record<string, unknown>,
|
|
79
86
|
key: string,
|
|
@@ -85,6 +92,7 @@ function getAliasedOptionalStringOption(
|
|
|
85
92
|
);
|
|
86
93
|
}
|
|
87
94
|
|
|
95
|
+
/** Normalize translated CLI values into the bundle command's typed options. */
|
|
88
96
|
export function normalizeBundleOptions(
|
|
89
97
|
translatedOptions: Record<string, unknown>,
|
|
90
98
|
platform: string,
|
|
@@ -108,7 +116,9 @@ export function normalizeBundleOptions(
|
|
|
108
116
|
`${tempDir}/output/${platform}.\${time}.ppk`,
|
|
109
117
|
),
|
|
110
118
|
dev: getBooleanOption(translatedOptions, 'dev', false) ? 'true' : 'false',
|
|
111
|
-
|
|
119
|
+
// On by default since 2.23: the map is archived with the published
|
|
120
|
+
// version (pushy symbolicate). --no-sourcemap / --sourcemap=false opts out.
|
|
121
|
+
sourcemap: getBooleanOption(translatedOptions, 'sourcemap', true),
|
|
112
122
|
taro: getBooleanOption(translatedOptions, 'taro', false),
|
|
113
123
|
expo: getBooleanOption(translatedOptions, 'expo', false),
|
|
114
124
|
rncli: getBooleanOption(translatedOptions, 'rncli', false),
|
|
@@ -121,6 +131,8 @@ export function normalizeBundleOptions(
|
|
|
121
131
|
),
|
|
122
132
|
resetCache: getBooleanOption(translatedOptions, 'resetCache', true),
|
|
123
133
|
cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
|
|
134
|
+
appId: getOptionalStringOption(translatedOptions, 'appId'),
|
|
135
|
+
config: getOptionalStringOption(translatedOptions, 'config'),
|
|
124
136
|
name: getOptionalStringOption(translatedOptions, 'name'),
|
|
125
137
|
description: getOptionalStringOption(translatedOptions, 'description'),
|
|
126
138
|
metaInfo: getOptionalStringOption(translatedOptions, 'metaInfo'),
|
|
@@ -156,6 +168,7 @@ export function normalizeBundleOptions(
|
|
|
156
168
|
};
|
|
157
169
|
}
|
|
158
170
|
|
|
171
|
+
/** Upload generated Sentry artifacts when the detected plugin requires them. */
|
|
159
172
|
async function uploadSentryArtifactsIfNeeded(
|
|
160
173
|
shouldUpload: boolean,
|
|
161
174
|
bundleName: string,
|
|
@@ -178,6 +191,7 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
178
191
|
);
|
|
179
192
|
}
|
|
180
193
|
|
|
194
|
+
/** Publish a packed bundle through the version command implementation. */
|
|
181
195
|
async function publishBundleVersion(
|
|
182
196
|
outputPath: string,
|
|
183
197
|
platform: Platform,
|
|
@@ -193,6 +207,7 @@ async function publishBundleVersion(
|
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
export const bundleCommands = {
|
|
210
|
+
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
196
211
|
bundle: async ({
|
|
197
212
|
options,
|
|
198
213
|
}: {
|
|
@@ -210,10 +225,48 @@ export const bundleCommands = {
|
|
|
210
225
|
});
|
|
211
226
|
const normalized = normalizeBundleOptions(translatedOptions, platform);
|
|
212
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
|
+
|
|
213
263
|
checkLockFiles();
|
|
214
264
|
addGitIgnore();
|
|
215
265
|
|
|
216
|
-
const bundleParams = await
|
|
266
|
+
const [bundleParams] = await Promise.all([
|
|
267
|
+
checkPlugins(),
|
|
268
|
+
cleanStaleTmp().catch(() => {}),
|
|
269
|
+
]);
|
|
217
270
|
const sourcemapOutput = path.join(
|
|
218
271
|
normalized.intermediaDir,
|
|
219
272
|
`${normalized.bundleName}.map`,
|
|
@@ -229,23 +282,6 @@ export const bundleCommands = {
|
|
|
229
282
|
|
|
230
283
|
console.log(t('bundlingWithRN', { version: depVersions['react-native'] }));
|
|
231
284
|
|
|
232
|
-
await cleanStaleTmp().catch(() => {});
|
|
233
|
-
// the hermes base lookup needs the app; resolve it up front but never
|
|
234
|
-
// fail the bundle over it (publishing resolves it again and reports)
|
|
235
|
-
let appIdForBase: string | undefined =
|
|
236
|
-
typeof options.appId === 'string' && options.appId
|
|
237
|
-
? options.appId
|
|
238
|
-
: undefined;
|
|
239
|
-
if (!appIdForBase && normalized.hermesBase === 'auto') {
|
|
240
|
-
try {
|
|
241
|
-
appIdForBase = (
|
|
242
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
243
|
-
).appId;
|
|
244
|
-
} catch {
|
|
245
|
-
appIdForBase = undefined;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
285
|
const hermesResult = await runReactNativeBundleCommand({
|
|
250
286
|
bundleName: normalized.bundleName,
|
|
251
287
|
dev: normalized.dev,
|
|
@@ -255,15 +291,7 @@ export const bundleCommands = {
|
|
|
255
291
|
sourcemapOutput:
|
|
256
292
|
normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
|
|
257
293
|
forceHermes: normalized.hermes,
|
|
258
|
-
hermesBase:
|
|
259
|
-
normalized.dev === 'true'
|
|
260
|
-
? undefined
|
|
261
|
-
: {
|
|
262
|
-
option: normalized.hermesBase,
|
|
263
|
-
appId: appIdForBase,
|
|
264
|
-
verify: normalized.verifyHermesBase,
|
|
265
|
-
cacheMaxMb: normalized.cacheMaxMb,
|
|
266
|
-
},
|
|
294
|
+
hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
|
|
267
295
|
resetCache: normalized.resetCache,
|
|
268
296
|
cli: {
|
|
269
297
|
taro: normalized.taro,
|
|
@@ -284,6 +312,7 @@ export const bundleCommands = {
|
|
|
284
312
|
|
|
285
313
|
if (normalized.name) {
|
|
286
314
|
await publishBundleVersion(realOutput, platform, {
|
|
315
|
+
appId: await getAppId(),
|
|
287
316
|
name: normalized.name,
|
|
288
317
|
description: normalized.description,
|
|
289
318
|
metaInfo: normalized.metaInfo,
|
|
@@ -295,6 +324,10 @@ export const bundleCommands = {
|
|
|
295
324
|
rollout: normalized.rollout,
|
|
296
325
|
dryRun: normalized.dryRun,
|
|
297
326
|
hermesBase: baseMeta,
|
|
327
|
+
sourcemap:
|
|
328
|
+
normalized.sourcemap || bundleParams.sourcemap
|
|
329
|
+
? sourcemapOutput
|
|
330
|
+
: undefined,
|
|
298
331
|
});
|
|
299
332
|
await uploadSentryArtifactsIfNeeded(
|
|
300
333
|
bundleParams.sentry,
|
|
@@ -314,7 +347,12 @@ export const bundleCommands = {
|
|
|
314
347
|
const v = await question(t('uploadBundlePrompt'));
|
|
315
348
|
if (v.toLowerCase() === 'y') {
|
|
316
349
|
await publishBundleVersion(realOutput, platform, {
|
|
350
|
+
appId: await getAppId(),
|
|
317
351
|
hermesBase: baseMeta,
|
|
352
|
+
sourcemap:
|
|
353
|
+
normalized.sourcemap || bundleParams.sourcemap
|
|
354
|
+
? sourcemapOutput
|
|
355
|
+
: undefined,
|
|
318
356
|
});
|
|
319
357
|
await uploadSentryArtifactsIfNeeded(
|
|
320
358
|
bundleParams.sentry,
|
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}}',
|
|
@@ -130,6 +132,20 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
130
132
|
processingStringPool: 'Processing the string pool ...',
|
|
131
133
|
publishUsage:
|
|
132
134
|
'Usage: pushy publish <ppk file> --platform ios|android|harmony',
|
|
135
|
+
sourceMapNotFound: 'Source map not found: {{path}}',
|
|
136
|
+
sourceMapMissingWarning:
|
|
137
|
+
'No source map was archived with this version: crashes cannot be symbolicated later. Bundle with the default --sourcemap, or pass --sourcemap <file> to publish.',
|
|
138
|
+
sourceMapArchived: 'Source map archived with version {{id}}',
|
|
139
|
+
sourceMapUploadFailedWarning:
|
|
140
|
+
'Source map upload failed ({{error}}); publishing without an archived map. Upgrade the update server to archive source maps.',
|
|
141
|
+
symbolicateUsage:
|
|
142
|
+
'Usage: pushy symbolicate <stack file | -> --hash <updateHash> [--platform ios|android|harmony] [--output <file>]',
|
|
143
|
+
symbolicateVersionNotFound:
|
|
144
|
+
'No published version with hash {{hash}} found for this app',
|
|
145
|
+
symbolicateNoSourceMap:
|
|
146
|
+
'Version {{id}} was published without a source map; nothing to symbolicate against',
|
|
147
|
+
symbolicateDone:
|
|
148
|
+
'Symbolicated {{count}} frame(s) against version {{id}} ({{hash}})',
|
|
133
149
|
rnuVersionNotFound:
|
|
134
150
|
'react-native-update: Cannot get the version number. Please run the command in the project directory',
|
|
135
151
|
rolloutConfigSet:
|
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}}',
|
|
@@ -118,6 +120,17 @@ export default {
|
|
|
118
120
|
processingError: '处理文件时出错:{{error}}',
|
|
119
121
|
processingPackage: '正在处理包 {{count}}...',
|
|
120
122
|
processingStringPool: '正在处理字符串池...',
|
|
123
|
+
sourceMapNotFound: '找不到 source map:{{path}}',
|
|
124
|
+
sourceMapMissingWarning:
|
|
125
|
+
'本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
|
|
126
|
+
sourceMapArchived: 'source map 已随版本 {{id}} 归档',
|
|
127
|
+
sourceMapUploadFailedWarning:
|
|
128
|
+
'source map 上传失败({{error}}),本次发布不归档 map。升级更新服务端后可归档 source map。',
|
|
129
|
+
symbolicateUsage:
|
|
130
|
+
'用法:pushy symbolicate <堆栈文件 | -> --hash <热更 hash> [--platform ios|android|harmony] [--output <文件>]',
|
|
131
|
+
symbolicateVersionNotFound: '当前应用下找不到 hash 为 {{hash}} 的已发布版本',
|
|
132
|
+
symbolicateNoSourceMap: '版本 {{id}} 发布时未归档 source map,无法还原',
|
|
133
|
+
symbolicateDone: '已按版本 {{id}}({{hash}})还原 {{count}} 个堆栈帧',
|
|
121
134
|
publishUsage:
|
|
122
135
|
'使用方法: pushy publish ppk后缀文件 --platform ios|android|harmony',
|
|
123
136
|
rnuVersionNotFound:
|
package/src/package.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from 'fs-extra';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { doDelete, getAllPackages, post, uploadFile } from './api';
|
|
5
|
-
import {
|
|
5
|
+
import { getSelectedApp, resolveAppId } from './app';
|
|
6
6
|
import { createSlimNativePackage } from './native-package';
|
|
7
7
|
import type { Package, Platform } from './types';
|
|
8
8
|
import {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
loadTtyTable,
|
|
14
14
|
question,
|
|
15
15
|
} from './utils';
|
|
16
|
+
import { updateJson } from './utils/constants';
|
|
16
17
|
import { getDepVersions } from './utils/dep-versions';
|
|
17
18
|
import { getCommitInfo } from './utils/git';
|
|
18
19
|
import { bundleEntryMatcher, cachePut } from './utils/hermes-base';
|
|
@@ -23,6 +24,7 @@ import { bundleLocationFields, locateZipEntry } from './utils/zip-range';
|
|
|
23
24
|
type PackageCommandOptions = Record<string, unknown> & {
|
|
24
25
|
appId?: string;
|
|
25
26
|
appKey?: string;
|
|
27
|
+
config?: string;
|
|
26
28
|
platform?: Platform;
|
|
27
29
|
version?: string;
|
|
28
30
|
packageId?: string;
|
|
@@ -130,18 +132,19 @@ async function uploadNativePackage(
|
|
|
130
132
|
appId: String(options.appId),
|
|
131
133
|
appKey: typeof options.appKey === 'string' ? options.appKey : undefined,
|
|
132
134
|
}
|
|
133
|
-
: await getSelectedApp(
|
|
134
|
-
config.platform,
|
|
135
|
-
options.config as string | undefined,
|
|
136
|
-
);
|
|
135
|
+
: await getSelectedApp(config.platform, options.config);
|
|
137
136
|
const { appId, appKey } = selectedApp;
|
|
137
|
+
// where the expected app came from, for the mismatch messages
|
|
138
|
+
const source = options.appId ? '--appId' : options.config || updateJson;
|
|
138
139
|
|
|
139
140
|
if (appIdInPkg && String(appIdInPkg) !== appId) {
|
|
140
|
-
throw new Error(t(config.appIdMismatchKey, { appIdInPkg, appId }));
|
|
141
|
+
throw new Error(t(config.appIdMismatchKey, { appIdInPkg, appId, source }));
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
|
|
144
|
-
throw new Error(
|
|
145
|
+
throw new Error(
|
|
146
|
+
t(config.appKeyMismatchKey, { appKeyInPkg, appKey, source }),
|
|
147
|
+
);
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
const customVersion =
|
|
@@ -407,28 +410,14 @@ export const packageCommands = {
|
|
|
407
410
|
}: {
|
|
408
411
|
options: { platform: Platform; appId?: string; config?: string };
|
|
409
412
|
}) => {
|
|
410
|
-
|
|
411
|
-
if (!appId) {
|
|
412
|
-
const platform = await getPlatform(options.platform);
|
|
413
|
-
appId = (
|
|
414
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
415
|
-
).appId;
|
|
416
|
-
}
|
|
417
|
-
await listPackage(String(appId));
|
|
413
|
+
await listPackage(await resolveAppId(options));
|
|
418
414
|
},
|
|
419
415
|
deletePackage: async ({ options }: { options: PackageCommandOptions }) => {
|
|
420
|
-
|
|
416
|
+
const appId = await resolveAppId(options);
|
|
421
417
|
let packageIds =
|
|
422
418
|
getStringListOption(options, 'packageIds') ??
|
|
423
419
|
getStringListOption(options, 'packageId');
|
|
424
420
|
|
|
425
|
-
if (!appId) {
|
|
426
|
-
const platform = await getPlatform(options.platform);
|
|
427
|
-
appId = (
|
|
428
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
429
|
-
).appId;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
421
|
if (!packageIds) {
|
|
433
422
|
const packageVersions = getStringListOption(options, 'packageVersion');
|
|
434
423
|
if (!packageVersions) {
|