react-native-update-cli 2.18.0 → 2.20.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 (56) hide show
  1. package/lib/api.d.ts +1 -1
  2. package/lib/api.js +143 -134
  3. package/lib/app.d.ts +2 -2
  4. package/lib/app.js +60 -107
  5. package/lib/bin.js +38 -35
  6. package/lib/bundle-pack.js +57 -77
  7. package/lib/bundle-runner.js +249 -312
  8. package/lib/bundle.js +71 -89
  9. package/lib/diff.js +190 -240
  10. package/lib/exports.js +14 -37
  11. package/lib/index.js +16 -17
  12. package/lib/install.js +24 -37
  13. package/lib/locales/en.js +3 -11
  14. package/lib/locales/zh.js +3 -11
  15. package/lib/native-package.d.ts +17 -0
  16. package/lib/native-package.js +232 -0
  17. package/lib/package.js +180 -225
  18. package/lib/provider.js +85 -107
  19. package/lib/types.js +1 -3
  20. package/lib/user.d.ts +1 -1
  21. package/lib/user.js +26 -39
  22. package/lib/utils/add-gitignore.js +16 -29
  23. package/lib/utils/app-info-parser/aab.js +133 -157
  24. package/lib/utils/app-info-parser/apk.js +42 -39
  25. package/lib/utils/app-info-parser/app.js +5 -11
  26. package/lib/utils/app-info-parser/index.js +21 -31
  27. package/lib/utils/app-info-parser/ipa.js +35 -35
  28. package/lib/utils/app-info-parser/resource-finder.js +84 -71
  29. package/lib/utils/app-info-parser/utils.js +52 -77
  30. package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
  31. package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
  32. package/lib/utils/app-info-parser/zip.js +43 -51
  33. package/lib/utils/check-lockfile.js +28 -37
  34. package/lib/utils/check-plugin.js +16 -32
  35. package/lib/utils/command-result.js +7 -20
  36. package/lib/utils/constants.js +23 -63
  37. package/lib/utils/dep-versions.js +21 -27
  38. package/lib/utils/git.js +20 -64
  39. package/lib/utils/hbcTransform.js +133 -246
  40. package/lib/utils/http-helper.js +33 -44
  41. package/lib/utils/i18n.js +17 -26
  42. package/lib/utils/index.js +137 -179
  43. package/lib/utils/latest-version/index.js +128 -137
  44. package/lib/utils/options.js +13 -34
  45. package/lib/utils/plugin-config.js +43 -56
  46. package/lib/utils/runtime.js +50 -108
  47. package/lib/utils/zip-entries.js +70 -97
  48. package/lib/utils/zip-options.js +80 -181
  49. package/lib/versions.js +231 -265
  50. package/package.json +19 -21
  51. package/src/api.ts +47 -3
  52. package/src/diff.ts +12 -20
  53. package/src/native-package.ts +248 -0
  54. package/src/package.ts +29 -19
  55. package/src/user.ts +1 -1
  56. package/src/versions.ts +1 -1
@@ -1,118 +1,79 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
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;
4
17
  });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get buildSentrySourcemapsUploadArgs () {
13
- return buildSentrySourcemapsUploadArgs;
14
- },
15
- get copyDebugidForSentry () {
16
- return copyDebugidForSentry;
17
- },
18
- get hasProjectDependency () {
19
- return hasProjectDependency;
20
- },
21
- get prepareSentryUploadArtifacts () {
22
- return prepareSentryUploadArtifacts;
23
- },
24
- get readSourcemapDebugId () {
25
- return readSourcemapDebugId;
26
- },
27
- get resolveExpoCli () {
28
- return resolveExpoCli;
29
- },
30
- get resolveHermesCommand () {
31
- return resolveHermesCommand;
32
- },
33
- get resolveSentryUploadMode () {
34
- return resolveSentryUploadMode;
35
- },
36
- get runReactNativeBundleCommand () {
37
- return runReactNativeBundleCommand;
38
- },
39
- get uploadSourcemapForSentry () {
40
- return uploadSourcemapForSentry;
41
- }
42
- });
43
- const _child_process = require("child_process");
44
- const _compareversions = require("compare-versions");
45
- const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
46
- const _os = /*#__PURE__*/ _interop_require_default(require("os"));
47
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
48
- const _i18n = require("./utils/i18n");
49
- const _runtime = require("./utils/runtime");
50
- function _interop_require_default(obj) {
51
- return obj && obj.__esModule ? obj : {
52
- default: obj
53
- };
54
- }
55
- function _getRequireWildcardCache(nodeInterop) {
56
- if (typeof WeakMap !== "function") return null;
57
- var cacheBabelInterop = new WeakMap();
58
- var cacheNodeInterop = new WeakMap();
59
- return (_getRequireWildcardCache = function(nodeInterop) {
60
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
61
- })(nodeInterop);
62
- }
63
- function _interop_require_wildcard(obj, nodeInterop) {
64
- if (!nodeInterop && obj && obj.__esModule) {
65
- return obj;
66
- }
67
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
68
- return {
69
- default: obj
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;
70
24
  };
71
- }
72
- var cache = _getRequireWildcardCache(nodeInterop);
73
- if (cache && cache.has(obj)) {
74
- return cache.get(obj);
75
- }
76
- var newObj = {
77
- __proto__: null
25
+ return ownKeys(o);
78
26
  };
79
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
80
- for(var key in obj){
81
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
82
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
83
- if (desc && (desc.get || desc.set)) {
84
- Object.defineProperty(newObj, key, desc);
85
- } else {
86
- newObj[key] = obj[key];
87
- }
88
- }
89
- }
90
- newObj.default = obj;
91
- if (cache) {
92
- cache.set(obj, newObj);
93
- }
94
- return newObj;
95
- }
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.hasProjectDependency = hasProjectDependency;
40
+ exports.resolveExpoCli = resolveExpoCli;
41
+ exports.runReactNativeBundleCommand = runReactNativeBundleCommand;
42
+ exports.resolveHermesCommand = resolveHermesCommand;
43
+ exports.copyDebugidForSentry = copyDebugidForSentry;
44
+ exports.prepareSentryUploadArtifacts = prepareSentryUploadArtifacts;
45
+ exports.readSourcemapDebugId = readSourcemapDebugId;
46
+ exports.resolveSentryUploadMode = resolveSentryUploadMode;
47
+ exports.buildSentrySourcemapsUploadArgs = buildSentrySourcemapsUploadArgs;
48
+ exports.uploadSourcemapForSentry = uploadSourcemapForSentry;
49
+ const child_process_1 = require("child_process");
50
+ const compare_versions_1 = require("compare-versions");
51
+ const fs = __importStar(require("fs-extra"));
52
+ const os_1 = __importDefault(require("os"));
53
+ const path_1 = __importDefault(require("path"));
54
+ const i18n_1 = require("./utils/i18n");
55
+ const runtime_1 = require("./utils/runtime");
96
56
  const g2js = require('gradle-to-js/lib/parser');
97
57
  const properties = require('properties');
98
58
  const dependencyFields = [
99
59
  'dependencies',
100
60
  'devDependencies',
101
61
  'peerDependencies',
102
- 'optionalDependencies'
62
+ 'optionalDependencies',
103
63
  ];
104
64
  const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
105
65
  function hasProjectDependency(dependencyName, projectRoot = process.cwd()) {
106
66
  try {
107
- const packageJson = JSON.parse(_fsextra.readFileSync(_path.default.join(projectRoot, 'package.json'), 'utf8'));
108
- return dependencyFields.some((field)=>{
67
+ const packageJson = JSON.parse(fs.readFileSync(path_1.default.join(projectRoot, 'package.json'), 'utf8'));
68
+ return dependencyFields.some((field) => {
109
69
  const dependencies = packageJson[field];
110
70
  if (typeof dependencies !== 'object' || dependencies === null) {
111
71
  return false;
112
72
  }
113
73
  return dependencyName in dependencies;
114
74
  });
115
- } catch (unused) {
75
+ }
76
+ catch {
116
77
  return false;
117
78
  }
118
79
  }
@@ -120,52 +81,50 @@ function resolveExpoCli(projectRoot = process.cwd()) {
120
81
  if (!hasProjectDependency('expo', projectRoot)) {
121
82
  return {
122
83
  cliPath: '',
123
- usingExpo: false
84
+ usingExpo: false,
124
85
  };
125
86
  }
126
87
  try {
127
- const searchPaths = [
128
- projectRoot
129
- ];
88
+ const searchPaths = [projectRoot];
130
89
  try {
131
90
  const expoPackageJsonPath = require.resolve('expo/package.json', {
132
- paths: [
133
- projectRoot
134
- ]
91
+ paths: [projectRoot],
135
92
  });
136
- searchPaths.push(_path.default.dirname(expoPackageJsonPath));
137
- } catch (unused) {
138
- // expo 包不存在,忽略
93
+ searchPaths.push(path_1.default.dirname(expoPackageJsonPath));
94
+ }
95
+ catch {
96
+ // expo 包不存在,忽略
139
97
  }
140
98
  const cliPath = require.resolve('@expo/cli', {
141
- paths: searchPaths
99
+ paths: searchPaths,
142
100
  });
143
- const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
144
- paths: searchPaths
101
+ const expoCliVersion = JSON.parse(fs.readFileSync(require.resolve('@expo/cli/package.json', {
102
+ paths: searchPaths,
145
103
  }), 'utf8')).version;
146
- if (!(0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
104
+ if (!(0, compare_versions_1.satisfies)(expoCliVersion, '>= 0.10.17')) {
147
105
  return {
148
106
  cliPath: '',
149
- usingExpo: false
107
+ usingExpo: false,
150
108
  };
151
109
  }
152
110
  return {
153
111
  cliPath,
154
- usingExpo: true
112
+ usingExpo: true,
155
113
  };
156
- } catch (unused) {
114
+ }
115
+ catch {
157
116
  return {
158
117
  cliPath: '',
159
- usingExpo: false
118
+ usingExpo: false,
160
119
  };
161
120
  }
162
121
  }
163
- async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry }) {
122
+ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }) {
164
123
  let gradleConfig = {};
165
124
  if (platform === 'android') {
166
125
  gradleConfig = await checkGradleConfig();
167
126
  if (gradleConfig.crunchPngs !== false) {
168
- console.warn((0, _i18n.t)('androidCrunchPngsWarning'));
127
+ console.warn((0, i18n_1.t)('androidCrunchPngsWarning'));
169
128
  }
170
129
  }
171
130
  const reactNativeBundleArgs = [];
@@ -173,45 +132,43 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
173
132
  if (envArgs) {
174
133
  reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
175
134
  }
176
- _fsextra.emptyDirSync(outputFolder);
135
+ fs.emptyDirSync(outputFolder);
177
136
  let cliPath = '';
178
137
  let usingExpo = false;
179
- const getExpoCli = ()=>{
138
+ const getExpoCli = () => {
180
139
  const resolvedExpoCli = resolveExpoCli();
181
140
  cliPath = resolvedExpoCli.cliPath;
182
141
  usingExpo = resolvedExpoCli.usingExpo;
183
142
  };
184
- const getRnCli = ()=>{
143
+ const getRnCli = () => {
185
144
  try {
186
145
  cliPath = require.resolve('react-native/local-cli/cli.js', {
187
- paths: [
188
- process.cwd()
189
- ]
146
+ paths: [process.cwd()],
190
147
  });
191
- } catch (unused) {
148
+ }
149
+ catch {
192
150
  cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
193
- paths: [
194
- process.cwd()
195
- ]
151
+ paths: [process.cwd()],
196
152
  });
197
153
  }
198
154
  };
199
- const getTaroCli = ()=>{
155
+ const getTaroCli = () => {
200
156
  try {
201
157
  cliPath = require.resolve('@tarojs/cli/bin/taro', {
202
- paths: [
203
- process.cwd()
204
- ]
158
+ paths: [process.cwd()],
205
159
  });
206
- } catch (unused) {
207
- // fallback 到 RN CLI
160
+ }
161
+ catch {
162
+ // fallback 到 RN CLI
208
163
  }
209
164
  };
210
165
  if (cli.expo) {
211
166
  getExpoCli();
212
- } else if (cli.taro) {
167
+ }
168
+ else if (cli.taro) {
213
169
  getTaroCli();
214
- } else if (cli.rncli) {
170
+ }
171
+ else if (cli.rncli) {
215
172
  getRnCli();
216
173
  }
217
174
  if (!cliPath) {
@@ -223,18 +180,23 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
223
180
  if (isSentry) {
224
181
  if (platform === 'ios') {
225
182
  process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
226
- } else if (platform === 'android') {
183
+ }
184
+ else if (platform === 'android') {
227
185
  process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
228
- } else if (platform === 'harmony' && _fsextra.existsSync('harmony/sentry.properties')) {
186
+ }
187
+ else if (platform === 'harmony' &&
188
+ fs.existsSync('harmony/sentry.properties')) {
229
189
  process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
230
190
  }
231
191
  }
232
192
  let bundleCommand = 'bundle';
233
193
  if (usingExpo) {
234
194
  bundleCommand = 'export:embed';
235
- } else if (platform === 'harmony') {
195
+ }
196
+ else if (platform === 'harmony') {
236
197
  bundleCommand = 'bundle-harmony';
237
- } else if (cli.taro) {
198
+ }
199
+ else if (cli.taro) {
238
200
  bundleCommand = 'build';
239
201
  }
240
202
  if (platform === 'harmony') {
@@ -243,13 +205,14 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
243
205
  forceHermes = true;
244
206
  }
245
207
  }
246
- reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName));
208
+ reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', path_1.default.join(outputFolder, bundleName));
247
209
  if (platform !== 'harmony') {
248
210
  reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
249
211
  }
250
212
  if (cli.taro) {
251
213
  reactNativeBundleArgs.push('--type', 'rn');
252
- } else {
214
+ }
215
+ else {
253
216
  reactNativeBundleArgs.push('--dev', dev, '--entry-file', entryFile);
254
217
  }
255
218
  if (sourcemapOutput) {
@@ -258,34 +221,31 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
258
221
  if (config) {
259
222
  reactNativeBundleArgs.push('--config', config);
260
223
  }
261
- const jsRuntime = (0, _runtime.getJavaScriptRuntime)();
262
- const reactNativeBundleProcess = (0, _runtime.spawnJavaScript)(reactNativeBundleArgs);
224
+ const jsRuntime = (0, runtime_1.getJavaScriptRuntime)();
225
+ const reactNativeBundleProcess = (0, runtime_1.spawnJavaScript)(reactNativeBundleArgs);
263
226
  console.log(`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`);
264
- await new Promise((resolve, reject)=>{
265
- reactNativeBundleProcess.stdout.on('data', (data)=>{
227
+ await new Promise((resolve, reject) => {
228
+ reactNativeBundleProcess.stdout.on('data', (data) => {
266
229
  console.log(data.toString().trim());
267
230
  });
268
- reactNativeBundleProcess.stderr.on('data', (data)=>{
231
+ reactNativeBundleProcess.stderr.on('data', (data) => {
269
232
  console.error(data.toString().trim());
270
233
  });
271
234
  reactNativeBundleProcess.once('error', reject);
272
- reactNativeBundleProcess.on('close', async (exitCode)=>{
235
+ reactNativeBundleProcess.on('close', async (exitCode) => {
273
236
  if (exitCode) {
274
- reject(new Error((0, _i18n.t)('bundleCommandError', {
275
- code: exitCode
276
- })));
237
+ reject(new Error((0, i18n_1.t)('bundleCommandError', { code: exitCode })));
277
238
  return;
278
239
  }
279
240
  try {
280
241
  let hermesEnabled = false;
281
242
  if (forceHermes) {
282
243
  hermesEnabled = true;
283
- console.log((0, _i18n.t)('forceHermes'));
284
- } else if (platform === 'android') {
285
- const gradleProperties = await new Promise((resolve)=>{
286
- properties.parse('./android/gradle.properties', {
287
- path: true
288
- }, (error, props = {})=>{
244
+ console.log((0, i18n_1.t)('forceHermes'));
245
+ }
246
+ else if (platform === 'android') {
247
+ const gradleProperties = await new Promise((resolve) => {
248
+ properties.parse('./android/gradle.properties', { path: true }, (error, props = {}) => {
289
249
  if (error) {
290
250
  console.error(error);
291
251
  resolve({});
@@ -298,7 +258,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
298
258
  if (typeof hermesEnabled !== 'boolean') {
299
259
  hermesEnabled = gradleConfig.enableHermes;
300
260
  }
301
- } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
261
+ }
262
+ else if (platform === 'ios' &&
263
+ fs.existsSync('ios/Pods/hermes-engine')) {
302
264
  hermesEnabled = true;
303
265
  }
304
266
  if (hermesEnabled) {
@@ -306,36 +268,36 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
306
268
  }
307
269
  if (platform === 'harmony') {
308
270
  const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
309
- _fsextra.ensureDirSync(harmonyRawAssetsPath);
310
- _fsextra.copySync(outputFolder, harmonyRawAssetsPath, {
271
+ fs.ensureDirSync(harmonyRawAssetsPath);
272
+ fs.copySync(outputFolder, harmonyRawAssetsPath, {
311
273
  overwrite: true,
312
274
  // sourcemaps must not ship inside the native package
313
- filter: (src)=>!src.endsWith('.map')
314
- });
315
- _fsextra.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, {
316
- overwrite: true
275
+ filter: (src) => !src.endsWith('.map'),
317
276
  });
277
+ fs.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, { overwrite: true });
318
278
  }
319
279
  resolve();
320
- } catch (error) {
280
+ }
281
+ catch (error) {
321
282
  reject(error);
322
283
  }
323
284
  });
324
285
  });
325
286
  }
326
287
  function getHermesOSBin() {
327
- if (_os.default.platform() === 'win32') return 'win64-bin';
328
- if (_os.default.platform() === 'darwin') return 'osx-bin';
329
- if (_os.default.platform() === 'linux') return 'linux64-bin';
288
+ if (os_1.default.platform() === 'win32')
289
+ return 'win64-bin';
290
+ if (os_1.default.platform() === 'darwin')
291
+ return 'osx-bin';
292
+ if (os_1.default.platform() === 'linux')
293
+ return 'linux64-bin';
330
294
  }
331
295
  function getHermesExecutableName() {
332
- return _os.default.platform() === 'win32' ? 'hermesc.exe' : 'hermesc';
296
+ return os_1.default.platform() === 'win32' ? 'hermesc.exe' : 'hermesc';
333
297
  }
334
298
  function dirnameOfPackage(packageJsonPath, projectRoot = process.cwd()) {
335
- return _path.default.dirname(require.resolve(packageJsonPath, {
336
- paths: [
337
- projectRoot
338
- ]
299
+ return path_1.default.dirname(require.resolve(packageJsonPath, {
300
+ paths: [projectRoot],
339
301
  }));
340
302
  }
341
303
  function assertSuccessfulSyncProcess(result, command) {
@@ -343,46 +305,49 @@ function assertSuccessfulSyncProcess(result, command) {
343
305
  throw result.error;
344
306
  }
345
307
  if (result.status !== 0) {
346
- throw new Error(`${command} failed with ${result.status === null ? `signal ${result.signal}` : `exit code ${result.status}`}`);
308
+ throw new Error(`${command} failed with ${result.status === null
309
+ ? `signal ${result.signal}`
310
+ : `exit code ${result.status}`}`);
347
311
  }
348
312
  }
349
313
  function normalizeString(value) {
350
- const normalized = value == null ? void 0 : value.trim();
314
+ const normalized = value?.trim();
351
315
  return normalized ? normalized : undefined;
352
316
  }
353
317
  function resolveHermesCommand(projectRoot = process.cwd()) {
354
318
  const osBin = getHermesOSBin();
355
319
  if (!osBin) {
356
- throw new Error((0, _i18n.t)('unsupportedPlatformForHermes', {
357
- platform: _os.default.platform()
358
- }));
320
+ throw new Error((0, i18n_1.t)('unsupportedPlatformForHermes', { platform: os_1.default.platform() }));
359
321
  }
360
322
  const executableName = getHermesExecutableName();
361
323
  const candidates = [];
362
324
  try {
363
325
  const rnDir = dirnameOfPackage('react-native/package.json', projectRoot);
364
- candidates.push(_path.default.join(rnDir, 'sdks', 'hermesc', osBin, executableName));
365
- } catch (unused) {
366
- // react-native is required for normal RN projects; keep looking so the
367
- // final error can include all candidates we were able to infer.
326
+ candidates.push(path_1.default.join(rnDir, 'sdks', 'hermesc', osBin, executableName));
327
+ }
328
+ catch {
329
+ // react-native is required for normal RN projects; keep looking so the
330
+ // final error can include all candidates we were able to infer.
368
331
  }
369
332
  try {
370
333
  const hermesCompilerDir = dirnameOfPackage('hermes-compiler/package.json', projectRoot);
371
- candidates.push(_path.default.join(hermesCompilerDir, 'hermesc', osBin, executableName));
372
- } catch (unused) {
373
- // RN 0.85+ uses hermes-compiler, older projects may still use other paths.
334
+ candidates.push(path_1.default.join(hermesCompilerDir, 'hermesc', osBin, executableName));
335
+ }
336
+ catch {
337
+ // RN 0.85+ uses hermes-compiler, older projects may still use other paths.
374
338
  }
375
339
  try {
376
340
  const hermesEngineDir = dirnameOfPackage('hermes-engine/package.json', projectRoot);
377
- candidates.push(_path.default.join(hermesEngineDir, osBin, executableName), _path.default.join(hermesEngineDir, 'hermesc', osBin, executableName));
378
- } catch (unused) {
379
- // RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
341
+ candidates.push(path_1.default.join(hermesEngineDir, osBin, executableName), path_1.default.join(hermesEngineDir, 'hermesc', osBin, executableName));
342
+ }
343
+ catch {
344
+ // RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
380
345
  }
381
- const hermesCommand = candidates.find((candidate)=>_fsextra.existsSync(candidate));
346
+ const hermesCommand = candidates.find((candidate) => fs.existsSync(candidate));
382
347
  if (hermesCommand) {
383
348
  return hermesCommand;
384
349
  }
385
- throw new Error(`Cannot find hermesc. Tried:\n${candidates.map((candidate)=>`- ${candidate}`).join('\n')}`);
350
+ throw new Error(`Cannot find hermesc. Tried:\n${candidates.map((candidate) => `- ${candidate}`).join('\n')}`);
386
351
  }
387
352
  async function checkGradleConfig() {
388
353
  let enableHermes = false;
@@ -392,68 +357,64 @@ async function checkGradleConfig() {
392
357
  crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
393
358
  const projectConfig = gradleConfig['project.ext.react'];
394
359
  if (projectConfig) {
395
- for (const packagerConfig of projectConfig){
396
- if (packagerConfig.includes('enableHermes') && packagerConfig.includes('true')) {
360
+ for (const packagerConfig of projectConfig) {
361
+ if (packagerConfig.includes('enableHermes') &&
362
+ packagerConfig.includes('true')) {
397
363
  enableHermes = true;
398
364
  break;
399
365
  }
400
366
  }
401
367
  }
402
- } catch (unused) {
403
- // ignore parsing failures
368
+ }
369
+ catch {
370
+ // ignore parsing failures
404
371
  }
405
372
  return {
406
373
  enableHermes,
407
- crunchPngs
374
+ crunchPngs,
408
375
  };
409
376
  }
410
377
  async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap) {
411
- console.log((0, _i18n.t)('hermesEnabledCompiling'));
378
+ console.log((0, i18n_1.t)('hermesEnabledCompiling'));
412
379
  const hermesCommand = resolveHermesCommand();
413
380
  const args = [
414
381
  '-emit-binary',
415
382
  '-out',
416
- _path.default.join(outputFolder, bundleName),
417
- _path.default.join(outputFolder, bundleName),
418
- '-O'
383
+ path_1.default.join(outputFolder, bundleName),
384
+ path_1.default.join(outputFolder, bundleName),
385
+ '-O',
419
386
  ];
420
387
  if (sourcemapOutput) {
421
- _fsextra.copyFileSync(sourcemapOutput, _path.default.join(outputFolder, `${bundleName}.txt.map`));
388
+ fs.copyFileSync(sourcemapOutput, path_1.default.join(outputFolder, `${bundleName}.txt.map`));
422
389
  args.push('-output-source-map');
423
390
  }
424
- console.log((0, _i18n.t)('runningHermesc', {
425
- command: hermesCommand,
426
- args: args.join(' ')
427
- }));
428
- assertSuccessfulSyncProcess((0, _child_process.spawnSync)(hermesCommand, args, {
429
- stdio: 'ignore'
391
+ console.log((0, i18n_1.t)('runningHermesc', { command: hermesCommand, args: args.join(' ') }));
392
+ assertSuccessfulSyncProcess((0, child_process_1.spawnSync)(hermesCommand, args, {
393
+ stdio: 'ignore',
430
394
  }), hermesCommand);
431
395
  if (sourcemapOutput) {
432
396
  let composerPath;
433
397
  try {
434
398
  // resolve through the project so hoisted node_modules (monorepos) work
435
- composerPath = require.resolve('react-native/scripts/compose-source-maps.js', {
436
- paths: [
437
- process.cwd()
438
- ]
439
- });
440
- } catch (unused) {
441
- console.warn((0, _i18n.t)('composeSourceMapsNotFound'));
399
+ composerPath = require.resolve('react-native/scripts/compose-source-maps.js', { paths: [process.cwd()] });
400
+ }
401
+ catch {
402
+ console.warn((0, i18n_1.t)('composeSourceMapsNotFound'));
442
403
  return;
443
404
  }
444
- console.log((0, _i18n.t)('composingSourceMap'));
445
- assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
405
+ console.log((0, i18n_1.t)('composingSourceMap'));
406
+ assertSuccessfulSyncProcess((0, runtime_1.spawnJavaScriptSync)([
446
407
  composerPath,
447
- _path.default.join(outputFolder, `${bundleName}.txt.map`),
448
- _path.default.join(outputFolder, `${bundleName}.map`),
408
+ path_1.default.join(outputFolder, `${bundleName}.txt.map`),
409
+ path_1.default.join(outputFolder, `${bundleName}.map`),
449
410
  '-o',
450
- sourcemapOutput
411
+ sourcemapOutput,
451
412
  ], {
452
- stdio: 'ignore'
413
+ stdio: 'ignore',
453
414
  }), composerPath);
454
415
  }
455
416
  if (shouldCleanSourcemap) {
456
- _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
417
+ fs.removeSync(path_1.default.join(outputFolder, `${bundleName}.txt.map`));
457
418
  }
458
419
  }
459
420
  async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
@@ -461,55 +422,54 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
461
422
  let copyDebugidPath;
462
423
  try {
463
424
  copyDebugidPath = require.resolve('@sentry/react-native/scripts/copy-debugid.js', {
464
- paths: [
465
- process.cwd()
466
- ]
425
+ paths: [process.cwd()],
467
426
  });
468
- } catch (unused) {
469
- console.error((0, _i18n.t)('sentryReactNativeNotFound'));
427
+ }
428
+ catch {
429
+ console.error((0, i18n_1.t)('sentryReactNativeNotFound'));
470
430
  return;
471
431
  }
472
- if (!_fsextra.existsSync(copyDebugidPath)) {
432
+ if (!fs.existsSync(copyDebugidPath)) {
473
433
  return;
474
434
  }
475
- console.log((0, _i18n.t)('copyingDebugId'));
476
- assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
435
+ console.log((0, i18n_1.t)('copyingDebugId'));
436
+ assertSuccessfulSyncProcess((0, runtime_1.spawnJavaScriptSync)([
477
437
  copyDebugidPath,
478
- _path.default.join(outputFolder, `${bundleName}.txt.map`),
479
- _path.default.join(outputFolder, `${bundleName}.map`)
438
+ path_1.default.join(outputFolder, `${bundleName}.txt.map`),
439
+ path_1.default.join(outputFolder, `${bundleName}.map`),
480
440
  ], {
481
- stdio: 'ignore'
441
+ stdio: 'ignore',
482
442
  }), copyDebugidPath);
483
443
  }
484
- _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
444
+ fs.removeSync(path_1.default.join(outputFolder, `${bundleName}.txt.map`));
485
445
  }
486
446
  async function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
487
- const bundlePath = _path.default.join(outputFolder, bundleName);
488
- const sourcemapPath = _path.default.join(outputFolder, `${bundleName}.map`);
447
+ const bundlePath = path_1.default.join(outputFolder, bundleName);
448
+ const sourcemapPath = path_1.default.join(outputFolder, `${bundleName}.map`);
489
449
  if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
490
450
  return {
491
451
  bundlePath,
492
- sourcemapPath
452
+ sourcemapPath,
493
453
  };
494
454
  }
495
- const androidBundlePath = _path.default.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
496
- const androidSourcemapPath = _path.default.join(outputFolder, `${ANDROID_SENTRY_BUNDLE_NAME}.map`);
497
- await _fsextra.promises.copyFile(bundlePath, androidBundlePath);
498
- const sourcemap = JSON.parse(await _fsextra.promises.readFile(sourcemapPath, 'utf8'));
455
+ const androidBundlePath = path_1.default.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
456
+ const androidSourcemapPath = path_1.default.join(outputFolder, `${ANDROID_SENTRY_BUNDLE_NAME}.map`);
457
+ await fs.promises.copyFile(bundlePath, androidBundlePath);
458
+ const sourcemap = JSON.parse(await fs.promises.readFile(sourcemapPath, 'utf8'));
499
459
  sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
500
- await _fsextra.promises.writeFile(androidSourcemapPath, JSON.stringify(sourcemap));
460
+ await fs.promises.writeFile(androidSourcemapPath, JSON.stringify(sourcemap));
501
461
  return {
502
462
  bundlePath: androidBundlePath,
503
- sourcemapPath: androidSourcemapPath
463
+ sourcemapPath: androidSourcemapPath,
504
464
  };
505
465
  }
506
466
  async function readSourcemapDebugId(sourcemapPath) {
507
467
  try {
508
- var _sourcemap_debugId;
509
- const sourcemap = JSON.parse(await _fsextra.promises.readFile(sourcemapPath, 'utf8'));
510
- const debugId = (_sourcemap_debugId = sourcemap.debugId) != null ? _sourcemap_debugId : sourcemap.debug_id;
468
+ const sourcemap = JSON.parse(await fs.promises.readFile(sourcemapPath, 'utf8'));
469
+ const debugId = sourcemap.debugId ?? sourcemap.debug_id;
511
470
  return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
512
- } catch (unused) {
471
+ }
472
+ catch {
513
473
  return undefined;
514
474
  }
515
475
  }
@@ -520,7 +480,7 @@ function resolveSentryReleaseFromValues(releaseValue, distValue) {
520
480
  }
521
481
  return {
522
482
  release,
523
- dist: normalizeString(distValue)
483
+ dist: normalizeString(distValue),
524
484
  };
525
485
  }
526
486
  async function resolveSentryUploadMode(sourcemapPath, options = {}) {
@@ -528,32 +488,29 @@ async function resolveSentryUploadMode(sourcemapPath, options = {}) {
528
488
  if (optionRelease) {
529
489
  return {
530
490
  type: 'release',
531
- ...optionRelease
491
+ ...optionRelease,
532
492
  };
533
493
  }
534
494
  const debugId = await readSourcemapDebugId(sourcemapPath);
535
495
  if (debugId) {
536
496
  return {
537
497
  type: 'debug-id',
538
- debugId
498
+ debugId,
539
499
  };
540
500
  }
541
501
  const environmentRelease = resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
542
502
  if (environmentRelease) {
543
503
  return {
544
504
  type: 'release',
545
- ...environmentRelease
505
+ ...environmentRelease,
546
506
  };
547
507
  }
548
- throw new Error('[pushy/sentry] Generated source map does not contain a Debug ID. ' + 'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' + 'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.');
508
+ throw new Error('[pushy/sentry] Generated source map does not contain a Debug ID. ' +
509
+ 'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' +
510
+ 'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.');
549
511
  }
550
- function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix = process.cwd(), debugIdReference = false, useStandaloneSourcemapsCommand = true }) {
551
- const uploadArgs = [
552
- '--strip-prefix',
553
- stripPrefix,
554
- bundlePath,
555
- sourcemapPath
556
- ];
512
+ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix = process.cwd(), debugIdReference = false, useStandaloneSourcemapsCommand = true, }) {
513
+ const uploadArgs = ['--strip-prefix', stripPrefix, bundlePath, sourcemapPath];
557
514
  if (debugIdReference) {
558
515
  if (!useStandaloneSourcemapsCommand) {
559
516
  throw new Error('[pushy/sentry] Debug ID upload requires sentry-cli sourcemaps upload.');
@@ -563,7 +520,7 @@ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapP
563
520
  'sourcemaps',
564
521
  'upload',
565
522
  '--debug-id-reference',
566
- ...uploadArgs
523
+ ...uploadArgs,
567
524
  ];
568
525
  }
569
526
  if (!release) {
@@ -576,11 +533,8 @@ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapP
576
533
  'files',
577
534
  release,
578
535
  'upload-sourcemaps',
579
- ...dist ? [
580
- '--dist',
581
- dist
582
- ] : [],
583
- ...uploadArgs
536
+ ...(dist ? ['--dist', dist] : []),
537
+ ...uploadArgs,
584
538
  ];
585
539
  }
586
540
  return [
@@ -589,78 +543,58 @@ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapP
589
543
  'upload',
590
544
  '--release',
591
545
  release,
592
- ...dist ? [
593
- '--dist',
594
- dist
595
- ] : [],
596
- ...uploadArgs
546
+ ...(dist ? ['--dist', dist] : []),
547
+ ...uploadArgs,
597
548
  ];
598
549
  }
599
550
  function supportsStandaloneSentrySourcemapsUpload(sentryCliPath) {
600
- const result = (0, _runtime.spawnJavaScriptSync)([
601
- sentryCliPath,
602
- 'sourcemaps',
603
- 'upload',
604
- '--help'
605
- ], {
606
- stdio: 'ignore'
551
+ const result = (0, runtime_1.spawnJavaScriptSync)([sentryCliPath, 'sourcemaps', 'upload', '--help'], {
552
+ stdio: 'ignore',
607
553
  });
608
554
  return !result.error && result.status === 0;
609
555
  }
610
556
  function supportsSentryDebugIdReference(sentryCliPath) {
611
- const result = (0, _runtime.spawnJavaScriptSync)([
612
- sentryCliPath,
613
- 'sourcemaps',
614
- 'upload',
615
- '--help'
616
- ], {
617
- encoding: 'utf8'
557
+ const result = (0, runtime_1.spawnJavaScriptSync)([sentryCliPath, 'sourcemaps', 'upload', '--help'], {
558
+ encoding: 'utf8',
618
559
  });
619
- return !result.error && result.status === 0 && typeof result.stdout === 'string' && result.stdout.includes('--debug-id-reference');
560
+ return (!result.error &&
561
+ result.status === 0 &&
562
+ typeof result.stdout === 'string' &&
563
+ result.stdout.includes('--debug-id-reference'));
620
564
  }
621
565
  function runSentryCli(args) {
622
- return (0, _runtime.spawnJavaScriptSync)(args, {
623
- stdio: 'inherit'
566
+ return (0, runtime_1.spawnJavaScriptSync)(args, {
567
+ stdio: 'inherit',
624
568
  });
625
569
  }
626
- function uploadSourcemapsWithRelease({ sentryCliPath, bundlePath, sourcemapPath, release, dist, useStandaloneSourcemapsCommand }) {
627
- assertSuccessfulSyncProcess(runSentryCli([
628
- sentryCliPath,
629
- 'releases',
630
- 'set-commits',
631
- release,
632
- '--auto'
633
- ]), sentryCliPath);
634
- console.log((0, _i18n.t)('sentryReleaseCreated', {
635
- version: release
636
- }));
637
- console.log((0, _i18n.t)('uploadingSourcemap'));
570
+ function uploadSourcemapsWithRelease({ sentryCliPath, bundlePath, sourcemapPath, release, dist, useStandaloneSourcemapsCommand, }) {
571
+ assertSuccessfulSyncProcess(runSentryCli([sentryCliPath, 'releases', 'set-commits', release, '--auto']), sentryCliPath);
572
+ console.log((0, i18n_1.t)('sentryReleaseCreated', { version: release }));
573
+ console.log((0, i18n_1.t)('uploadingSourcemap'));
638
574
  assertSuccessfulSyncProcess(runSentryCli(buildSentrySourcemapsUploadArgs({
639
575
  sentryCliPath,
640
576
  bundlePath,
641
577
  sourcemapPath,
642
578
  release,
643
579
  dist,
644
- useStandaloneSourcemapsCommand
580
+ useStandaloneSourcemapsCommand,
645
581
  })), sentryCliPath);
646
582
  }
647
583
  async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, platform = '', sentryOptions = {}) {
648
- var _resolveSentryReleaseFromValues;
649
584
  if (!sourcemapOutput) {
650
585
  return;
651
586
  }
652
587
  let sentryCliPath;
653
588
  try {
654
589
  sentryCliPath = require.resolve('@sentry/cli/bin/sentry-cli', {
655
- paths: [
656
- process.cwd()
657
- ]
590
+ paths: [process.cwd()],
658
591
  });
659
- } catch (unused) {
660
- console.error((0, _i18n.t)('sentryCliNotFound'));
592
+ }
593
+ catch {
594
+ console.error((0, i18n_1.t)('sentryCliNotFound'));
661
595
  return;
662
596
  }
663
- if (!_fsextra.existsSync(sentryCliPath)) {
597
+ if (!fs.existsSync(sentryCliPath)) {
664
598
  return;
665
599
  }
666
600
  const { bundlePath, sourcemapPath } = await prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
@@ -673,16 +607,18 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
673
607
  sourcemapPath,
674
608
  release: uploadMode.release,
675
609
  dist: uploadMode.dist,
676
- useStandaloneSourcemapsCommand
610
+ useStandaloneSourcemapsCommand,
677
611
  });
678
612
  return;
679
613
  }
680
- console.log((0, _i18n.t)('uploadingSourcemap'));
681
- if (!useStandaloneSourcemapsCommand || !supportsSentryDebugIdReference(sentryCliPath)) {
682
- var _resolveSentryReleaseFromValues1;
683
- const explicitRelease = (_resolveSentryReleaseFromValues1 = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues1 : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
614
+ console.log((0, i18n_1.t)('uploadingSourcemap'));
615
+ if (!useStandaloneSourcemapsCommand ||
616
+ !supportsSentryDebugIdReference(sentryCliPath)) {
617
+ const explicitRelease = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist) ??
618
+ resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
684
619
  if (!explicitRelease) {
685
- throw new Error('[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' + 'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.');
620
+ throw new Error('[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' +
621
+ 'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.');
686
622
  }
687
623
  uploadSourcemapsWithRelease({
688
624
  sentryCliPath,
@@ -690,7 +626,7 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
690
626
  sourcemapPath,
691
627
  release: explicitRelease.release,
692
628
  dist: explicitRelease.dist,
693
- useStandaloneSourcemapsCommand
629
+ useStandaloneSourcemapsCommand,
694
630
  });
695
631
  return;
696
632
  }
@@ -700,12 +636,13 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
700
636
  bundlePath,
701
637
  sourcemapPath,
702
638
  debugIdReference: true,
703
- useStandaloneSourcemapsCommand
639
+ useStandaloneSourcemapsCommand,
704
640
  }));
705
641
  if (debugIdResult.status === 0 && !debugIdResult.error) {
706
642
  return;
707
643
  }
708
- const explicitRelease = (_resolveSentryReleaseFromValues = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
644
+ const explicitRelease = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist) ??
645
+ resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
709
646
  if (!explicitRelease) {
710
647
  assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
711
648
  return;
@@ -717,6 +654,6 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
717
654
  sourcemapPath,
718
655
  release: explicitRelease.release,
719
656
  dist: explicitRelease.dist,
720
- useStandaloneSourcemapsCommand
657
+ useStandaloneSourcemapsCommand,
721
658
  });
722
659
  }