react-native-update-cli 2.29.0 → 2.29.2

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 (85) hide show
  1. package/lib/account.js +2 -4
  2. package/lib/api.d.ts +1 -1
  3. package/lib/api.js +35 -73
  4. package/lib/app.js +13 -27
  5. package/lib/auto-update.d.ts +1 -1
  6. package/lib/auto-update.js +6 -16
  7. package/lib/bin.js +4 -6
  8. package/lib/bundle-pack.js +26 -60
  9. package/lib/bundle-runner.js +89 -119
  10. package/lib/bundle.js +18 -26
  11. package/lib/diff.js +43 -133
  12. package/lib/locales/en.d.ts +0 -10
  13. package/lib/locales/en.js +0 -10
  14. package/lib/locales/zh.d.ts +0 -10
  15. package/lib/locales/zh.js +0 -10
  16. package/lib/native-package.js +27 -99
  17. package/lib/package.d.ts +6 -1
  18. package/lib/package.js +56 -108
  19. package/lib/provider.js +3 -5
  20. package/lib/symbolicate.js +1 -16
  21. package/lib/utils/add-gitignore.js +0 -1
  22. package/lib/utils/app-info-parser/aab.d.ts +5 -22
  23. package/lib/utils/app-info-parser/aab.js +89 -226
  24. package/lib/utils/app-info-parser/apk.d.ts +12 -13
  25. package/lib/utils/app-info-parser/apk.js +28 -78
  26. package/lib/utils/app-info-parser/ipa.d.ts +2 -14
  27. package/lib/utils/app-info-parser/ipa.js +9 -70
  28. package/lib/utils/app-info-parser/resource-finder.d.ts +1 -34
  29. package/lib/utils/app-info-parser/resource-finder.js +95 -234
  30. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
  31. package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
  32. package/lib/utils/app-info-parser/zip.d.ts +6 -24
  33. package/lib/utils/app-info-parser/zip.js +19 -86
  34. package/lib/utils/check-plugin.d.ts +7 -5
  35. package/lib/utils/check-plugin.js +15 -25
  36. package/lib/utils/dep-versions.d.ts +0 -6
  37. package/lib/utils/dep-versions.js +2 -27
  38. package/lib/utils/failure-fingerprint.js +3 -4
  39. package/lib/utils/fs-helpers.d.ts +18 -0
  40. package/lib/utils/fs-helpers.js +84 -0
  41. package/lib/utils/git.d.ts +0 -1
  42. package/lib/utils/git.js +0 -8
  43. package/lib/utils/hash.d.ts +3 -0
  44. package/lib/utils/hash.js +19 -0
  45. package/lib/utils/hbcTransform.d.ts +9 -2
  46. package/lib/utils/hbcTransform.js +41 -70
  47. package/lib/utils/hermes-base.d.ts +1 -5
  48. package/lib/utils/hermes-base.js +136 -196
  49. package/lib/utils/hermes-literals.d.ts +5 -3
  50. package/lib/utils/hermes-literals.js +30 -53
  51. package/lib/utils/hermes-raw.d.ts +7 -0
  52. package/lib/utils/hermes-raw.js +26 -9
  53. package/lib/utils/http-helper.d.ts +0 -1
  54. package/lib/utils/http-helper.js +0 -20
  55. package/lib/utils/i18n.js +0 -2
  56. package/lib/utils/index.d.ts +5 -19
  57. package/lib/utils/index.js +95 -189
  58. package/lib/utils/latest-version.d.ts +19 -0
  59. package/lib/utils/latest-version.js +137 -0
  60. package/lib/utils/options.d.ts +2 -1
  61. package/lib/utils/options.js +5 -7
  62. package/lib/utils/runtime.d.ts +1 -1
  63. package/lib/utils/runtime.js +2 -10
  64. package/lib/utils/upload-request.d.ts +33 -0
  65. package/lib/utils/upload-request.js +120 -0
  66. package/lib/utils/zip-entries.d.ts +23 -0
  67. package/lib/utils/zip-entries.js +130 -139
  68. package/lib/utils/zip-options.js +29 -56
  69. package/lib/utils/zip-range.js +29 -69
  70. package/lib/utils/zip-raw-writer.js +6 -5
  71. package/lib/versions.d.ts +5 -0
  72. package/lib/versions.js +86 -153
  73. package/package.json +1 -9
  74. package/lib/utils/app-info-parser/app.d.ts +0 -4
  75. package/lib/utils/app-info-parser/app.js +0 -10
  76. package/lib/utils/app-info-parser/index.d.ts +0 -16
  77. package/lib/utils/app-info-parser/index.js +0 -46
  78. package/lib/utils/app-info-parser/utils.d.ts +0 -31
  79. package/lib/utils/app-info-parser/utils.js +0 -135
  80. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
  81. package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
  82. package/lib/utils/latest-version/index.d.ts +0 -149
  83. package/lib/utils/latest-version/index.js +0 -326
  84. package/lib/utils/plugin-config.d.ts +0 -9
  85. package/lib/utils/plugin-config.js +0 -61
package/lib/package.js CHANGED
@@ -1,46 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.packageCommands = void 0;
40
- exports.normalizeUploadBuildTime = normalizeUploadBuildTime;
7
+ exports.toNumericIds = toNumericIds;
8
+ exports.deleteByIds = deleteByIds;
41
9
  exports.listPackage = listPackage;
42
10
  exports.choosePackage = choosePackage;
43
- const fs = __importStar(require("fs-extra"));
11
+ const fs_1 = __importDefault(require("fs"));
44
12
  const os_1 = __importDefault(require("os"));
45
13
  const path_1 = __importDefault(require("path"));
46
14
  const api_1 = require("./api");
@@ -49,18 +17,15 @@ const native_package_1 = require("./native-package");
49
17
  const utils_1 = require("./utils");
50
18
  const constants_1 = require("./utils/constants");
51
19
  const dep_versions_1 = require("./utils/dep-versions");
20
+ const fs_helpers_1 = require("./utils/fs-helpers");
52
21
  const git_1 = require("./utils/git");
53
22
  const hermes_base_1 = require("./utils/hermes-base");
54
23
  const i18n_1 = require("./utils/i18n");
55
24
  const options_1 = require("./utils/options");
56
25
  const zip_range_1 = require("./utils/zip-range");
57
26
  // the AAB parser drags in protobufjs; load it only for the aab commands
58
- function createAabParser(source) {
59
- const { AabParser } = require('./utils/app-info-parser/aab');
60
- return new AabParser(source);
61
- }
62
- function normalizeUploadBuildTime(value) {
63
- return String(value);
27
+ function loadExtractApk() {
28
+ return require('./utils/app-info-parser/aab').extractApk;
64
29
  }
65
30
  function ensureFileByExt(filePath, extension, usageKey) {
66
31
  if (!filePath?.endsWith(extension)) {
@@ -68,19 +33,6 @@ function ensureFileByExt(filePath, extension, usageKey) {
68
33
  }
69
34
  return filePath;
70
35
  }
71
- function parseBooleanOption(value) {
72
- return value === true || value === 'true';
73
- }
74
- function parseCsvOption(value) {
75
- if (typeof value !== 'string') {
76
- return null;
77
- }
78
- const parsed = value
79
- .split(',')
80
- .map((item) => item.trim())
81
- .filter(Boolean);
82
- return parsed.length > 0 ? parsed : null;
83
- }
84
36
  function toNumericIds(ids) {
85
37
  return ids.map((id) => {
86
38
  const numericId = Number(id);
@@ -90,6 +42,42 @@ function toNumericIds(ids) {
90
42
  return numericId;
91
43
  });
92
44
  }
45
+ const deleteMessages = {
46
+ version: {
47
+ one: 'deleteVersionSuccess',
48
+ many: 'deleteVersionsSuccess',
49
+ error: 'deleteVersionError',
50
+ },
51
+ package: {
52
+ one: 'deletePackageSuccess',
53
+ many: 'deletePackagesSuccess',
54
+ error: 'deletePackageError',
55
+ },
56
+ };
57
+ /**
58
+ * Delete versions or packages of an app: one id through
59
+ * `DELETE /app/:appId/<kind>/:id`, several in one `DELETE /app/:appId/<kind>`.
60
+ */
61
+ async function deleteByIds(appId, kind, ids) {
62
+ const messages = deleteMessages[kind];
63
+ try {
64
+ if (ids.length === 1) {
65
+ const [id] = ids;
66
+ await (0, api_1.doDelete)(`/app/${appId}/${kind}/${id}`);
67
+ console.log((0, i18n_1.t)(messages.one, { [`${kind}Id`]: id }));
68
+ }
69
+ else {
70
+ await (0, api_1.doDelete)(`/app/${appId}/${kind}`, {
71
+ [`${kind}Ids`]: toNumericIds(ids),
72
+ });
73
+ console.log((0, i18n_1.t)(messages.many, { count: ids.length, [`${kind}Ids`]: ids.join(', ') }));
74
+ }
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : String(error);
78
+ throw new Error((0, i18n_1.t)(messages.error, { [`${kind}Id`]: ids.join(', '), error: message }));
79
+ }
80
+ }
93
81
  function getVersionBinding(version) {
94
82
  if (!version || typeof version !== 'object') {
95
83
  return undefined;
@@ -124,11 +112,11 @@ async function uploadNativePackage(filePath, options, config) {
124
112
  if (customVersion !== undefined) {
125
113
  console.log((0, i18n_1.t)('usingCustomVersion', { version: versionName }));
126
114
  }
127
- const tempRoot = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-native-package-upload-'));
115
+ const tempRoot = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-native-package-upload-'));
128
116
  const slimPackagePath = path_1.default.join(tempRoot, `package${config.extension}`);
129
117
  try {
130
118
  await (0, native_package_1.createSlimNativePackage)(filePath, slimPackagePath, config.platform);
131
- const { hash } = await (0, api_1.uploadFile)(slimPackagePath, undefined, appId);
119
+ const { hash } = await (0, api_1.uploadFile)(slimPackagePath, appId);
132
120
  // where the bundle sits inside the uploaded (slim) archive, so a later
133
121
  // `bundle` that falls back to this package as hermes base fetches only
134
122
  // the bundle with one HTTP Range request. Harmony .app nests a second
@@ -142,14 +130,10 @@ async function uploadNativePackage(filePath, options, config) {
142
130
  // already hashed the bundle, so pass that hash instead of hashing twice
143
131
  await (0, hermes_base_1.cachePut)(bundleFile, undefined, bundleHash).catch(() => { });
144
132
  }
145
- const normalizedBuildTime = config.normalizeBuildTime
146
- ? config.normalizeBuildTime(buildTime)
147
- : buildTime;
148
- const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
149
133
  const { id } = await (0, api_1.post)(`/app/${appId}/package/create`, {
150
134
  name: versionName,
151
135
  hash,
152
- buildTime: uploadBuildTime,
136
+ buildTime: String(buildTime),
153
137
  // Content identity of the embedded JS bundle; the server matches it
154
138
  // against the client-reported bundleHash to decide pdiff applicability.
155
139
  // Old servers strip unknown fields, so this is forward-compatible.
@@ -166,11 +150,11 @@ async function uploadNativePackage(filePath, options, config) {
166
150
  console.log((0, i18n_1.t)(config.successKey, {
167
151
  id,
168
152
  version: versionName,
169
- buildTime: uploadBuildTime,
153
+ buildTime: String(buildTime),
170
154
  }));
171
155
  }
172
156
  finally {
173
- await fs.remove(tempRoot);
157
+ await (0, fs_helpers_1.remove)(tempRoot);
174
158
  }
175
159
  }
176
160
  /**
@@ -252,13 +236,12 @@ exports.packageCommands = {
252
236
  const source = ensureFileByExt(args[0], '.aab', 'usageUploadAab');
253
237
  // private temp dir: unpredictable path, safe against symlink squatting in
254
238
  // the shared tmpdir and against concurrent uploads of same-named AABs
255
- const tempRoot = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-aab-upload-'));
239
+ const tempRoot = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-aab-upload-'));
256
240
  const output = path_1.default.join(tempRoot, 'universal.apk');
257
- const includeAllSplits = parseBooleanOption(options.includeAllSplits);
258
- const splits = parseCsvOption(options.splits);
259
- const parser = createAabParser(source);
241
+ const includeAllSplits = (0, options_1.getBooleanOption)(options, 'includeAllSplits');
242
+ const splits = (0, options_1.getStringListOption)(options, 'splits');
260
243
  try {
261
- await parser.extractApk(output, {
244
+ await loadExtractApk()(source, output, {
262
245
  includeAllSplits,
263
246
  splits,
264
247
  });
@@ -268,7 +251,7 @@ exports.packageCommands = {
268
251
  });
269
252
  }
270
253
  finally {
271
- await fs.remove(tempRoot);
254
+ await (0, fs_helpers_1.remove)(tempRoot);
272
255
  }
273
256
  },
274
257
  uploadApp: async ({ args, options, }) => {
@@ -280,7 +263,6 @@ exports.packageCommands = {
280
263
  appKeyMismatchKey: 'appKeyMismatchApp',
281
264
  successKey: 'appUploadSuccess',
282
265
  getInfo: (filePath) => (0, utils_1.getAppInfo)(filePath),
283
- normalizeBuildTime: (buildTime) => String(buildTime),
284
266
  });
285
267
  },
286
268
  parseApp: async ({ args }) => {
@@ -315,10 +297,9 @@ exports.packageCommands = {
315
297
  const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
316
298
  const output = options.output ||
317
299
  path_1.default.join(path_1.default.dirname(source), `${path_1.default.basename(source, path_1.default.extname(source))}.apk`);
318
- const includeAllSplits = parseBooleanOption(options.includeAllSplits);
319
- const splits = parseCsvOption(options.splits);
320
- const parser = createAabParser(source);
321
- await parser.extractApk(output, {
300
+ const includeAllSplits = (0, options_1.getBooleanOption)(options, 'includeAllSplits');
301
+ const splits = (0, options_1.getStringListOption)(options, 'splits');
302
+ await loadExtractApk()(source, output, {
322
303
  includeAllSplits,
323
304
  splits,
324
305
  });
@@ -349,39 +330,6 @@ exports.packageCommands = {
349
330
  return String(selectedPackage.id);
350
331
  });
351
332
  }
352
- // Confirm deletion
353
- // const confirmDelete = await question(
354
- // t('confirmDeletePackage', { packageId }),
355
- // );
356
- // if (
357
- // confirmDelete.toLowerCase() !== 'y' &&
358
- // confirmDelete.toLowerCase() !== 'yes'
359
- // ) {
360
- // console.log(t('cancelled'));
361
- // return;
362
- // }
363
- try {
364
- if (packageIds.length === 1) {
365
- const [packageId] = packageIds;
366
- await (0, api_1.doDelete)(`/app/${appId}/package/${packageId}`);
367
- console.log((0, i18n_1.t)('deletePackageSuccess', { packageId }));
368
- }
369
- else {
370
- await (0, api_1.doDelete)(`/app/${appId}/package`, {
371
- packageIds: toNumericIds(packageIds),
372
- });
373
- console.log((0, i18n_1.t)('deletePackagesSuccess', {
374
- count: packageIds.length,
375
- packageIds: packageIds.join(', '),
376
- }));
377
- }
378
- }
379
- catch (error) {
380
- const message = error instanceof Error ? error.message : String(error);
381
- throw new Error((0, i18n_1.t)('deletePackageError', {
382
- packageId: packageIds.join(', '),
383
- error: message,
384
- }));
385
- }
333
+ await deleteByIds(appId, 'package', packageIds);
386
334
  },
387
335
  };
package/lib/provider.js CHANGED
@@ -60,12 +60,10 @@ class CLIProviderImpl {
60
60
  await this.sessionInitPromise;
61
61
  }
62
62
  runMessageCommand(task, fallbackError, successMessage, requireSession = true) {
63
- return (0, command_result_1.runAsCommandResult)(async () => {
64
- if (requireSession) {
65
- await this.ensureInitialized();
66
- }
63
+ return this.runDataCommand(async () => {
67
64
  await task();
68
- }, fallbackError, () => ({ message: successMessage }));
65
+ return { message: successMessage };
66
+ }, fallbackError, requireSession);
69
67
  }
70
68
  runDataCommand(task, fallbackError, requireSession = true) {
71
69
  return (0, command_result_1.runAsCommandResult)(async () => {
@@ -42,21 +42,6 @@ function symbolicateStack(stack, consumer) {
42
42
  });
43
43
  return { text, mapped };
44
44
  }
45
- async function findVersionByHash(appId, hash) {
46
- const limit = 100;
47
- // The list is newest-first; crashes are usually about recent versions.
48
- for (let offset = 0; offset < 100 * limit; offset += limit) {
49
- const page = await (0, versions_1.fetchVersions)(appId, offset, limit);
50
- const found = page.find((version) => version.hash === hash);
51
- if (found) {
52
- return found;
53
- }
54
- if (page.length < limit) {
55
- return undefined;
56
- }
57
- }
58
- return undefined;
59
- }
60
45
  async function readStack(source) {
61
46
  if (!source || source === '-') {
62
47
  // No file and an interactive terminal: nothing is piped in, so waiting on
@@ -89,7 +74,7 @@ exports.symbolicateCommands = {
89
74
  .appId;
90
75
  let versionId = versionIdOption;
91
76
  if (!versionId) {
92
- const version = await findVersionByHash(appId, hash);
77
+ const version = await (0, versions_1.findVersion)(appId, (item) => item.hash === hash);
93
78
  if (!version) {
94
79
  throw new Error((0, i18n_1.t)('symbolicateVersionNotFound', { hash }));
95
80
  }
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addGitIgnore = addGitIgnore;
7
7
  const fs_1 = __importDefault(require("fs"));
8
- // import path from 'path';
9
8
  const constants_1 = require("./constants");
10
9
  const i18n_1 = require("./i18n");
11
10
  function addGitIgnore() {
@@ -1,22 +1,5 @@
1
- import { Zip } from './zip';
2
- export declare class AabParser extends Zip {
3
- extractApk(outputPath: string, { includeAllSplits, splits, }: {
4
- includeAllSplits?: boolean;
5
- splits?: string[] | null;
6
- }): Promise<void>;
7
- /**
8
- * 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
9
- * 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
10
- */
11
- parse(): Promise<Record<string, any>>;
12
- /**
13
- * Parse manifest
14
- * @param {Buffer} buffer // manifest file's buffer
15
- */
16
- private _parseManifest;
17
- /**
18
- * Parse resourceMap
19
- * @param {Buffer} buffer // resourceMap file's buffer
20
- */
21
- private _parseResourceMap;
22
- }
1
+ /** Build a universal APK from an .aab with bundletool (or npx node-bundletool). */
2
+ export declare function extractApk(aabPath: string, outputPath: string, { includeAllSplits, splits, }: {
3
+ includeAllSplits?: boolean;
4
+ splits?: string[] | null;
5
+ }): Promise<void>;