react-native-update-cli 2.24.1 → 2.25.0

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.
Files changed (95) hide show
  1. package/README.md +11 -4
  2. package/README.zh-CN.md +11 -4
  3. package/cli.json +7 -1
  4. package/lib/api.d.ts +2 -0
  5. package/lib/api.js +63 -18
  6. package/lib/app.js +25 -3
  7. package/lib/bin.js +39 -45
  8. package/lib/bundle-runner.d.ts +27 -0
  9. package/lib/bundle-runner.js +240 -21
  10. package/lib/bundle.d.ts +1 -1
  11. package/lib/bundle.js +19 -6
  12. package/lib/commands.d.ts +6 -0
  13. package/lib/commands.js +65 -0
  14. package/lib/locales/en.d.ts +5 -14
  15. package/lib/locales/en.js +5 -14
  16. package/lib/locales/zh.d.ts +5 -13
  17. package/lib/locales/zh.js +5 -13
  18. package/lib/package.js +4 -0
  19. package/lib/provider.d.ts +1 -1
  20. package/lib/provider.js +3 -1
  21. package/lib/symbolicate.js +11 -3
  22. package/lib/types.d.ts +1 -0
  23. package/lib/user.js +6 -0
  24. package/lib/utils/add-gitignore.js +7 -1
  25. package/lib/utils/dep-versions.d.ts +7 -0
  26. package/lib/utils/dep-versions.js +78 -26
  27. package/lib/utils/git.js +9 -6
  28. package/lib/utils/hermes-base.js +2 -1
  29. package/lib/utils/i18n.d.ts +5 -0
  30. package/lib/utils/i18n.js +14 -1
  31. package/lib/utils/index.d.ts +2 -1
  32. package/lib/utils/index.js +9 -4
  33. package/lib/utils/latest-version/index.js +8 -0
  34. package/lib/utils/runtime.d.ts +21 -0
  35. package/lib/utils/runtime.js +138 -5
  36. package/lib/utils/slim-sourcemap.d.ts +11 -0
  37. package/lib/utils/slim-sourcemap.js +22 -0
  38. package/lib/utils/zip-range.js +3 -2
  39. package/lib/versions.js +16 -15
  40. package/package.json +4 -2
  41. package/lib/index.d.ts +0 -1
  42. package/lib/index.js +0 -17
  43. package/src/api.ts +0 -470
  44. package/src/app.ts +0 -241
  45. package/src/auto-update.ts +0 -647
  46. package/src/bin-cresc.ts +0 -8
  47. package/src/bin.ts +0 -115
  48. package/src/bundle-pack.ts +0 -61
  49. package/src/bundle-runner.ts +0 -1430
  50. package/src/bundle.ts +0 -371
  51. package/src/cache.ts +0 -20
  52. package/src/diff.ts +0 -1010
  53. package/src/exports.ts +0 -17
  54. package/src/index.ts +0 -1
  55. package/src/install.ts +0 -50
  56. package/src/locales/en.ts +0 -257
  57. package/src/locales/zh.ts +0 -234
  58. package/src/native-package.ts +0 -338
  59. package/src/package.ts +0 -482
  60. package/src/provider.ts +0 -294
  61. package/src/symbolicate.ts +0 -159
  62. package/src/types.ts +0 -150
  63. package/src/user.ts +0 -39
  64. package/src/utils/add-gitignore.ts +0 -35
  65. package/src/utils/app-info-parser/aab.ts +0 -241
  66. package/src/utils/app-info-parser/apk.ts +0 -92
  67. package/src/utils/app-info-parser/app.ts +0 -7
  68. package/src/utils/app-info-parser/index.ts +0 -54
  69. package/src/utils/app-info-parser/ipa.ts +0 -109
  70. package/src/utils/app-info-parser/resource-finder.ts +0 -508
  71. package/src/utils/app-info-parser/utils.ts +0 -161
  72. package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
  73. package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
  74. package/src/utils/app-info-parser/zip.ts +0 -108
  75. package/src/utils/check-lockfile.ts +0 -93
  76. package/src/utils/check-plugin.ts +0 -38
  77. package/src/utils/command-result.ts +0 -24
  78. package/src/utils/constants.ts +0 -25
  79. package/src/utils/dep-versions.ts +0 -83
  80. package/src/utils/git.ts +0 -71
  81. package/src/utils/hbcTransform.ts +0 -649
  82. package/src/utils/hermes-base.ts +0 -1137
  83. package/src/utils/http-helper.ts +0 -152
  84. package/src/utils/i18n.ts +0 -39
  85. package/src/utils/index.ts +0 -698
  86. package/src/utils/latest-version/index.ts +0 -573
  87. package/src/utils/options.ts +0 -78
  88. package/src/utils/plugin-config.ts +0 -32
  89. package/src/utils/runtime.ts +0 -187
  90. package/src/utils/slim-sourcemap.ts +0 -83
  91. package/src/utils/zip-entries.ts +0 -209
  92. package/src/utils/zip-options.ts +0 -178
  93. package/src/utils/zip-range.ts +0 -727
  94. package/src/utils/zip-raw-writer.ts +0 -247
  95. package/src/versions.ts +0 -894
package/src/bundle.ts DELETED
@@ -1,371 +0,0 @@
1
- import path from 'path';
2
- import { AppNotSelectedError, getPlatform, resolveAppId } from './app';
3
- import { packBundle } from './bundle-pack';
4
- import {
5
- copyDebugidForSentry,
6
- runReactNativeBundleCommand,
7
- type SentryUploadOptions,
8
- uploadSourcemapForSentry,
9
- } from './bundle-runner';
10
- import type { Platform } from './types';
11
- import { checkPlugins, question, translateOptions } from './utils';
12
- import { addGitIgnore } from './utils/add-gitignore';
13
- import { checkLockFiles } from './utils/check-lockfile';
14
- import { tempDir } from './utils/constants';
15
- import { depVersions } from './utils/dep-versions';
16
- import {
17
- cleanStaleTmp,
18
- type HermesBaseMeta,
19
- hermesBaseMeta,
20
- } from './utils/hermes-base';
21
- import { t } from './utils/i18n';
22
- import {
23
- getBooleanOption,
24
- getOptionalStringOption,
25
- getStringOption,
26
- } from './utils/options';
27
- import { versionCommands } from './versions';
28
-
29
- type NormalizedBundleOptions = {
30
- bundleName: string;
31
- entryFile: string;
32
- intermediaDir: string;
33
- output: string;
34
- dev: string;
35
- sourcemap: boolean;
36
- taro: boolean;
37
- expo: boolean;
38
- rncli: boolean;
39
- hermes: boolean;
40
- hermesBase: string;
41
- verifyHermesBase: boolean;
42
- resetCache: boolean;
43
- cacheMaxMb?: number;
44
- appId?: string;
45
- config?: string;
46
- name?: string;
47
- description?: string;
48
- metaInfo?: string;
49
- packageId?: string;
50
- packageVersion?: string;
51
- minPackageVersion?: string;
52
- maxPackageVersion?: string;
53
- packageVersionRange?: string;
54
- rollout?: string;
55
- dryRun: boolean;
56
- sentryRelease?: string;
57
- sentryDist?: string;
58
- };
59
-
60
- /** Parse a positive cache-size option expressed in megabytes. */
61
- function parseCacheMaxMb(value: unknown): number | undefined {
62
- const parsed = typeof value === 'string' ? Number(value) : (value as number);
63
- return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
64
- }
65
-
66
- type PublishBundlePayload = {
67
- appId: string;
68
- name?: string;
69
- description?: string;
70
- metaInfo?: string;
71
- packageId?: string;
72
- packageVersion?: string;
73
- minPackageVersion?: string;
74
- maxPackageVersion?: string;
75
- packageVersionRange?: string;
76
- rollout?: string;
77
- dryRun?: boolean;
78
- hermesBase?: HermesBaseMeta;
79
- /** path of the final source map to archive with the version */
80
- sourcemap?: string;
81
- };
82
-
83
- /** Read either spelling of an aliased optional CLI string option. */
84
- function getAliasedOptionalStringOption(
85
- options: Record<string, unknown>,
86
- key: string,
87
- alias: string,
88
- ): string | undefined {
89
- return (
90
- getOptionalStringOption(options, key) ??
91
- getOptionalStringOption(options, alias)
92
- );
93
- }
94
-
95
- /** Normalize translated CLI values into the bundle command's typed options. */
96
- export function normalizeBundleOptions(
97
- translatedOptions: Record<string, unknown>,
98
- platform: string,
99
- ): NormalizedBundleOptions {
100
- return {
101
- // harmony bundles always use this fixed name (runReactNativeBundleCommand
102
- // forces it), so sourcemap paths and Sentry uploads must match
103
- bundleName:
104
- platform === 'harmony'
105
- ? 'bundle.harmony.js'
106
- : getStringOption(translatedOptions, 'bundleName', 'index.bundlejs'),
107
- entryFile: getStringOption(translatedOptions, 'entryFile', 'index.js'),
108
- intermediaDir: getStringOption(
109
- translatedOptions,
110
- 'intermediaDir',
111
- `${tempDir}/intermedia/${platform}`,
112
- ),
113
- output: getStringOption(
114
- translatedOptions,
115
- 'output',
116
- `${tempDir}/output/${platform}.\${time}.ppk`,
117
- ),
118
- dev: getBooleanOption(translatedOptions, 'dev', false) ? 'true' : 'false',
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),
122
- taro: getBooleanOption(translatedOptions, 'taro', false),
123
- expo: getBooleanOption(translatedOptions, 'expo', false),
124
- rncli: getBooleanOption(translatedOptions, 'rncli', false),
125
- hermes: getBooleanOption(translatedOptions, 'hermes', false),
126
- hermesBase: getStringOption(translatedOptions, 'hermesBase', 'auto'),
127
- verifyHermesBase: getBooleanOption(
128
- translatedOptions,
129
- 'verifyHermesBase',
130
- true,
131
- ),
132
- resetCache: getBooleanOption(translatedOptions, 'resetCache', true),
133
- cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
134
- appId: getOptionalStringOption(translatedOptions, 'appId'),
135
- config: getOptionalStringOption(translatedOptions, 'config'),
136
- name: getOptionalStringOption(translatedOptions, 'name'),
137
- description: getOptionalStringOption(translatedOptions, 'description'),
138
- metaInfo: getOptionalStringOption(translatedOptions, 'metaInfo'),
139
- packageId: getOptionalStringOption(translatedOptions, 'packageId'),
140
- packageVersion: getOptionalStringOption(
141
- translatedOptions,
142
- 'packageVersion',
143
- ),
144
- minPackageVersion: getOptionalStringOption(
145
- translatedOptions,
146
- 'minPackageVersion',
147
- ),
148
- maxPackageVersion: getOptionalStringOption(
149
- translatedOptions,
150
- 'maxPackageVersion',
151
- ),
152
- packageVersionRange: getOptionalStringOption(
153
- translatedOptions,
154
- 'packageVersionRange',
155
- ),
156
- rollout: getOptionalStringOption(translatedOptions, 'rollout'),
157
- dryRun: getBooleanOption(translatedOptions, 'dryRun', false),
158
- sentryRelease: getAliasedOptionalStringOption(
159
- translatedOptions,
160
- 'sentry-release',
161
- 'sentryRelease',
162
- ),
163
- sentryDist: getAliasedOptionalStringOption(
164
- translatedOptions,
165
- 'sentry-dist',
166
- 'sentryDist',
167
- ),
168
- };
169
- }
170
-
171
- /** Upload generated Sentry artifacts when the detected plugin requires them. */
172
- async function uploadSentryArtifactsIfNeeded(
173
- shouldUpload: boolean,
174
- bundleName: string,
175
- intermediaDir: string,
176
- sourcemapOutput: string,
177
- platform: Platform,
178
- sentryOptions: SentryUploadOptions,
179
- ): Promise<void> {
180
- if (!shouldUpload) {
181
- return;
182
- }
183
-
184
- await copyDebugidForSentry(bundleName, intermediaDir, sourcemapOutput);
185
- await uploadSourcemapForSentry(
186
- bundleName,
187
- intermediaDir,
188
- sourcemapOutput,
189
- platform,
190
- sentryOptions,
191
- );
192
- }
193
-
194
- /** Publish a packed bundle through the version command implementation. */
195
- async function publishBundleVersion(
196
- outputPath: string,
197
- platform: Platform,
198
- payload: PublishBundlePayload,
199
- ): Promise<string> {
200
- return versionCommands.publish({
201
- args: [outputPath],
202
- options: {
203
- platform,
204
- ...payload,
205
- },
206
- });
207
- }
208
-
209
- export const bundleCommands = {
210
- /** Build a bundle and optionally publish it to one operation-scoped app. */
211
- bundle: async ({
212
- options,
213
- }: {
214
- args?: string[];
215
- options: Record<string, unknown>;
216
- }) => {
217
- const platform = await getPlatform(
218
- typeof options.platform === 'string' ? options.platform : undefined,
219
- );
220
-
221
- const translatedOptions = translateOptions({
222
- ...options,
223
- tempDir,
224
- platform,
225
- });
226
- const normalized = normalizeBundleOptions(translatedOptions, platform);
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
-
263
- checkLockFiles();
264
- addGitIgnore();
265
-
266
- const [bundleParams] = await Promise.all([
267
- checkPlugins(),
268
- cleanStaleTmp().catch(() => {}),
269
- ]);
270
- const sourcemapOutput = path.join(
271
- normalized.intermediaDir,
272
- `${normalized.bundleName}.map`,
273
- );
274
- const realOutput = normalized.output.replace(
275
- /\$\{time\}/g,
276
- `${Date.now()}`,
277
- );
278
-
279
- if (!platform) {
280
- throw new Error(t('platformRequired'));
281
- }
282
-
283
- console.log(t('bundlingWithRN', { version: depVersions['react-native'] }));
284
-
285
- const hermesResult = await runReactNativeBundleCommand({
286
- bundleName: normalized.bundleName,
287
- dev: normalized.dev,
288
- entryFile: normalized.entryFile,
289
- outputFolder: normalized.intermediaDir,
290
- platform,
291
- sourcemapOutput:
292
- normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
293
- forceHermes: normalized.hermes,
294
- hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
295
- resetCache: normalized.resetCache,
296
- cli: {
297
- taro: normalized.taro,
298
- expo: normalized.expo,
299
- rncli: normalized.rncli,
300
- },
301
- isSentry: bundleParams.sentry,
302
- });
303
-
304
- await packBundle(
305
- path.resolve(normalized.intermediaDir),
306
- realOutput,
307
- normalized.bundleName,
308
- );
309
- const baseMeta = hermesResult
310
- ? hermesBaseMeta(hermesResult.base, hermesResult.bytecodeVersion)
311
- : undefined;
312
-
313
- if (normalized.name) {
314
- await publishBundleVersion(realOutput, platform, {
315
- appId: await getAppId(),
316
- name: normalized.name,
317
- description: normalized.description,
318
- metaInfo: normalized.metaInfo,
319
- packageId: normalized.packageId,
320
- packageVersion: normalized.packageVersion,
321
- minPackageVersion: normalized.minPackageVersion,
322
- maxPackageVersion: normalized.maxPackageVersion,
323
- packageVersionRange: normalized.packageVersionRange,
324
- rollout: normalized.rollout,
325
- dryRun: normalized.dryRun,
326
- hermesBase: baseMeta,
327
- sourcemap:
328
- normalized.sourcemap || bundleParams.sourcemap
329
- ? sourcemapOutput
330
- : undefined,
331
- });
332
- await uploadSentryArtifactsIfNeeded(
333
- bundleParams.sentry,
334
- normalized.bundleName,
335
- normalized.intermediaDir,
336
- sourcemapOutput,
337
- platform,
338
- {
339
- sentryRelease: normalized.sentryRelease,
340
- sentryDist: normalized.sentryDist,
341
- },
342
- );
343
- return;
344
- }
345
-
346
- if (!getBooleanOption(options, 'no-interactive', false)) {
347
- const v = await question(t('uploadBundlePrompt'));
348
- if (v.toLowerCase() === 'y') {
349
- await publishBundleVersion(realOutput, platform, {
350
- appId: await getAppId(),
351
- hermesBase: baseMeta,
352
- sourcemap:
353
- normalized.sourcemap || bundleParams.sourcemap
354
- ? sourcemapOutput
355
- : undefined,
356
- });
357
- await uploadSentryArtifactsIfNeeded(
358
- bundleParams.sentry,
359
- normalized.bundleName,
360
- normalized.intermediaDir,
361
- sourcemapOutput,
362
- platform,
363
- {
364
- sentryRelease: normalized.sentryRelease,
365
- sentryDist: normalized.sentryDist,
366
- },
367
- );
368
- }
369
- }
370
- },
371
- };
package/src/cache.ts DELETED
@@ -1,20 +0,0 @@
1
- import { cacheStats, cleanCache } from './utils/hermes-base';
2
- import { t } from './utils/i18n';
3
-
4
- export const cacheCommands = {
5
- cache: async ({ args }: { args?: string[] }) => {
6
- if (args?.[0] === 'clean') {
7
- const removed = await cleanCache();
8
- console.log(t('cacheCleaned', { count: removed }));
9
- return;
10
- }
11
- const stats = await cacheStats();
12
- console.log(
13
- t('cacheStats', {
14
- dir: stats.dir,
15
- files: stats.files,
16
- mb: (stats.bytes / 1024 / 1024).toFixed(1),
17
- }),
18
- );
19
- },
20
- };