react-native-update-cli 2.29.0 → 2.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.js +9 -29
- package/lib/bundle-pack.js +6 -38
- package/lib/bundle-runner.js +36 -67
- package/lib/diff.js +18 -49
- package/lib/native-package.js +10 -42
- package/lib/package.js +6 -38
- package/lib/utils/app-info-parser/aab.js +6 -38
- package/lib/utils/app-info-parser/resource-finder.d.ts +5 -13
- package/lib/utils/app-info-parser/resource-finder.js +63 -60
- package/lib/utils/fs-helpers.d.ts +13 -0
- package/lib/utils/fs-helpers.js +65 -0
- package/lib/utils/hermes-base.js +50 -47
- package/lib/utils/plugin-config.js +6 -36
- package/lib/utils/runtime.d.ts +1 -1
- package/lib/utils/runtime.js +2 -10
- package/lib/utils/upload-request.d.ts +33 -0
- package/lib/utils/upload-request.js +120 -0
- package/lib/utils/zip-entries.js +7 -39
- package/lib/utils/zip-range.js +4 -4
- package/lib/utils/zip-raw-writer.js +6 -5
- package/package.json +1 -7
package/lib/api.js
CHANGED
|
@@ -17,6 +17,7 @@ const constants_1 = require("./utils/constants");
|
|
|
17
17
|
const http_helper_1 = require("./utils/http-helper");
|
|
18
18
|
const i18n_1 = require("./utils/i18n");
|
|
19
19
|
const runtime_1 = require("./utils/runtime");
|
|
20
|
+
const upload_request_1 = require("./utils/upload-request");
|
|
20
21
|
let session;
|
|
21
22
|
let savedSession;
|
|
22
23
|
let apiToken;
|
|
@@ -252,16 +253,6 @@ class UploadTimeoutError extends Error {
|
|
|
252
253
|
this.name = 'UploadTimeoutError';
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
|
-
/**
|
|
256
|
-
* node-fetch is only needed for the streaming multipart / PUT upload below
|
|
257
|
-
* (the built-in fetch cannot stream a form-data body). Loading it eagerly
|
|
258
|
-
* pulled whatwg-url → punycode into every command, which Node ≥ 21 greets
|
|
259
|
-
* with a DEP0040 deprecation warning on stderr; so it is loaded on first use.
|
|
260
|
-
*/
|
|
261
|
-
function loadNodeFetch() {
|
|
262
|
-
const mod = require('node-fetch');
|
|
263
|
-
return (mod.default ?? mod);
|
|
264
|
-
}
|
|
265
256
|
/**
|
|
266
257
|
* Send the file (or one slice of it) with a size-scaled deadline and retries
|
|
267
258
|
* on a transient network error. `buildRequest` is invoked per attempt with a
|
|
@@ -269,7 +260,6 @@ function loadNodeFetch() {
|
|
|
269
260
|
*/
|
|
270
261
|
async function sendUpload(fn, realUrl, fileSize, bar, buildRequest, slice = { start: 0, end: fileSize, retries: UPLOAD_MAX_RETRIES }) {
|
|
271
262
|
const timeoutMs = uploadTimeoutMs(slice.end - slice.start);
|
|
272
|
-
const nodeFetch = loadNodeFetch();
|
|
273
263
|
// HTTP(S)_PROXY / NO_PROXY, like every other request of the CLI
|
|
274
264
|
const agent = (0, runtime_1.proxyAgentFor)(realUrl);
|
|
275
265
|
for (let attempt = 0;; attempt++) {
|
|
@@ -290,10 +280,10 @@ async function sendUpload(fn, realUrl, fileSize, bar, buildRequest, slice = { st
|
|
|
290
280
|
bar.tick(data.length);
|
|
291
281
|
});
|
|
292
282
|
try {
|
|
293
|
-
return await
|
|
294
|
-
...buildRequest(fileStream),
|
|
283
|
+
return await (0, upload_request_1.sendUploadRequest)(realUrl, buildRequest(fileStream), {
|
|
295
284
|
agent,
|
|
296
285
|
signal: controller.signal,
|
|
286
|
+
userAgent,
|
|
297
287
|
});
|
|
298
288
|
}
|
|
299
289
|
catch (rawError) {
|
|
@@ -387,7 +377,7 @@ async function uploadFile(fn, key, appId) {
|
|
|
387
377
|
pricingPageUrl: constants_1.pricingPageUrl,
|
|
388
378
|
}));
|
|
389
379
|
}
|
|
390
|
-
// progress
|
|
380
|
+
// progress is only needed here; keep it off the startup path
|
|
391
381
|
const progressModule = require('progress');
|
|
392
382
|
const ProgressBarImpl = (progressModule.default ??
|
|
393
383
|
progressModule);
|
|
@@ -425,21 +415,11 @@ async function uploadFile(fn, key, appId) {
|
|
|
425
415
|
}
|
|
426
416
|
return { hash: resp.key };
|
|
427
417
|
}
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
for (const [k, v] of Object.entries(fields)) {
|
|
434
|
-
form.append(k, v);
|
|
435
|
-
}
|
|
436
|
-
// With every part's length known node-fetch sends Content-Length
|
|
437
|
-
// instead of a chunked body: what object stores expect, and the only
|
|
438
|
-
// framing that survives http-proxy-agent's rewrite of the buffered
|
|
439
|
-
// request head.
|
|
440
|
-
form.append('file', fileStream, { knownLength: byteCount });
|
|
441
|
-
return { method: 'POST', body: form };
|
|
442
|
-
};
|
|
418
|
+
const postForm = (fields, byteCount) => (fileStream) => (0, upload_request_1.multipartRequest)(fields, {
|
|
419
|
+
name: fn,
|
|
420
|
+
size: byteCount,
|
|
421
|
+
stream: fileStream,
|
|
422
|
+
});
|
|
443
423
|
if (resp.chunked && !key) {
|
|
444
424
|
try {
|
|
445
425
|
await sendChunks(fn, realUrl, fileSize, bar, resp.chunked, postForm);
|
package/lib/bundle-pack.js
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
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.packBundle = packBundle;
|
|
40
|
-
const
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
41
8
|
const path_1 = __importDefault(require("path"));
|
|
42
9
|
const yazl_1 = require("yazl");
|
|
10
|
+
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
43
11
|
const i18n_1 = require("./utils/i18n");
|
|
44
12
|
const zip_options_1 = require("./utils/zip-options");
|
|
45
13
|
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
|
@@ -52,21 +20,21 @@ async function packBundle(dir, output, bundleName) {
|
|
|
52
20
|
ignorePackingFileNames.push(`${bundleName}.map`);
|
|
53
21
|
}
|
|
54
22
|
console.log((0, i18n_1.t)('packing'));
|
|
55
|
-
|
|
23
|
+
(0, fs_helpers_1.ensureDirSync)(path_1.default.dirname(output));
|
|
56
24
|
await new Promise((resolve, reject) => {
|
|
57
25
|
const zipfile = new yazl_1.ZipFile();
|
|
58
26
|
function addDirectory(root, rel) {
|
|
59
27
|
if (rel) {
|
|
60
28
|
zipfile.addEmptyDirectory(rel);
|
|
61
29
|
}
|
|
62
|
-
const children =
|
|
30
|
+
const children = fs_1.default.readdirSync(root);
|
|
63
31
|
for (const name of children) {
|
|
64
32
|
if (ignorePackingFileNames.includes(name) ||
|
|
65
33
|
ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))) {
|
|
66
34
|
continue;
|
|
67
35
|
}
|
|
68
36
|
const fullPath = path_1.default.join(root, name);
|
|
69
|
-
const stat =
|
|
37
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
70
38
|
if (stat.isFile()) {
|
|
71
39
|
zipfile.addFile(fullPath, rel + name, (0, zip_options_1.zipOptionsForPayloadFile)(fullPath, rel + name));
|
|
72
40
|
}
|
|
@@ -77,7 +45,7 @@ async function packBundle(dir, output, bundleName) {
|
|
|
77
45
|
}
|
|
78
46
|
addDirectory(dir, '');
|
|
79
47
|
zipfile.outputStream.on('error', (err) => reject(err));
|
|
80
|
-
zipfile.outputStream.pipe(
|
|
48
|
+
zipfile.outputStream.pipe(fs_1.default.createWriteStream(output)).on('close', () => {
|
|
81
49
|
resolve();
|
|
82
50
|
});
|
|
83
51
|
zipfile.end();
|
package/lib/bundle-runner.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
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
|
};
|
|
@@ -57,11 +24,12 @@ exports.buildSentrySourcemapsUploadArgs = buildSentrySourcemapsUploadArgs;
|
|
|
57
24
|
exports.uploadSourcemapForSentry = uploadSourcemapForSentry;
|
|
58
25
|
const child_process_1 = require("child_process");
|
|
59
26
|
const compare_versions_1 = require("compare-versions");
|
|
60
|
-
const
|
|
27
|
+
const fs_1 = __importDefault(require("fs"));
|
|
61
28
|
const os_1 = __importDefault(require("os"));
|
|
62
29
|
const path_1 = __importDefault(require("path"));
|
|
63
30
|
const api_1 = require("./api");
|
|
64
31
|
const dep_versions_1 = require("./utils/dep-versions");
|
|
32
|
+
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
65
33
|
const hermes_base_1 = require("./utils/hermes-base");
|
|
66
34
|
const hermes_timeout_1 = require("./utils/hermes-timeout");
|
|
67
35
|
const i18n_1 = require("./utils/i18n");
|
|
@@ -77,7 +45,7 @@ const dependencyFields = [
|
|
|
77
45
|
const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
|
|
78
46
|
function hasProjectDependency(dependencyName, projectRoot = process.cwd()) {
|
|
79
47
|
try {
|
|
80
|
-
const packageJson = JSON.parse(
|
|
48
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectRoot, 'package.json'), 'utf8'));
|
|
81
49
|
return dependencyFields.some((field) => {
|
|
82
50
|
const dependencies = packageJson[field];
|
|
83
51
|
if (typeof dependencies !== 'object' || dependencies === null) {
|
|
@@ -111,7 +79,7 @@ function resolveExpoCli(projectRoot = process.cwd()) {
|
|
|
111
79
|
const cliPath = require.resolve('@expo/cli', {
|
|
112
80
|
paths: searchPaths,
|
|
113
81
|
});
|
|
114
|
-
const expoCliVersion = JSON.parse(
|
|
82
|
+
const expoCliVersion = JSON.parse(fs_1.default.readFileSync(require.resolve('@expo/cli/package.json', {
|
|
115
83
|
paths: searchPaths,
|
|
116
84
|
}), 'utf8')).version;
|
|
117
85
|
if (!(0, compare_versions_1.satisfies)(expoCliVersion, '>= 0.10.17')) {
|
|
@@ -146,7 +114,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
146
114
|
reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
|
|
147
115
|
}
|
|
148
116
|
outputFolder = assertSafeToEmpty(outputFolder);
|
|
149
|
-
|
|
117
|
+
(0, fs_helpers_1.emptyDirSync)(outputFolder);
|
|
150
118
|
let cliPath = '';
|
|
151
119
|
let usingExpo = false;
|
|
152
120
|
const getExpoCli = () => {
|
|
@@ -199,7 +167,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
199
167
|
process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
|
|
200
168
|
}
|
|
201
169
|
else if (platform === 'harmony' &&
|
|
202
|
-
|
|
170
|
+
fs_1.default.existsSync('harmony/sentry.properties')) {
|
|
203
171
|
process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
|
|
204
172
|
}
|
|
205
173
|
}
|
|
@@ -275,13 +243,14 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
275
243
|
}
|
|
276
244
|
if (platform === 'harmony') {
|
|
277
245
|
const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
246
|
+
(0, fs_helpers_1.ensureDirSync)(harmonyRawAssetsPath);
|
|
247
|
+
fs_1.default.cpSync(outputFolder, harmonyRawAssetsPath, {
|
|
248
|
+
recursive: true,
|
|
249
|
+
force: true,
|
|
281
250
|
// sourcemaps must not ship inside the native package
|
|
282
251
|
filter: (src) => !src.endsWith('.map'),
|
|
283
252
|
});
|
|
284
|
-
|
|
253
|
+
(0, fs_helpers_1.moveSync)(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`);
|
|
285
254
|
}
|
|
286
255
|
resolve();
|
|
287
256
|
}
|
|
@@ -338,13 +307,13 @@ function assertSafeToEmpty(dir, cwd = process.cwd()) {
|
|
|
338
307
|
validate(requested, lexicalCwd, lexicalHome, lexicalTmp);
|
|
339
308
|
// A final-component symlink is the direct dangerous case: emptyDirSync would
|
|
340
309
|
// enumerate and remove entries from its target rather than removing the link.
|
|
341
|
-
if (
|
|
310
|
+
if (fs_1.default.existsSync(requested) && fs_1.default.lstatSync(requested).isSymbolicLink()) {
|
|
342
311
|
reject(requested);
|
|
343
312
|
}
|
|
344
313
|
// emptyDirSync creates a missing directory too; create it first so it can be
|
|
345
314
|
// canonicalized and the exact validated path can be passed to deletion.
|
|
346
|
-
|
|
347
|
-
const canonical = (value) =>
|
|
315
|
+
(0, fs_helpers_1.ensureDirSync)(requested);
|
|
316
|
+
const canonical = (value) => fs_1.default.realpathSync.native(value);
|
|
348
317
|
const target = canonical(requested);
|
|
349
318
|
const canonicalCwd = canonical(lexicalCwd);
|
|
350
319
|
const canonicalHome = canonical(lexicalHome);
|
|
@@ -470,7 +439,7 @@ function stripRubyComments(source) {
|
|
|
470
439
|
function configuredIosEngine(ios) {
|
|
471
440
|
let expoEngine;
|
|
472
441
|
try {
|
|
473
|
-
const value = JSON.parse(
|
|
442
|
+
const value = JSON.parse(fs_1.default.readFileSync(path_1.default.join(ios, 'Podfile.properties.json'), 'utf8'))?.['expo.jsEngine'];
|
|
474
443
|
if (value === 'hermes' || value === 'jsc')
|
|
475
444
|
expoEngine = value;
|
|
476
445
|
}
|
|
@@ -479,7 +448,7 @@ function configuredIosEngine(ios) {
|
|
|
479
448
|
}
|
|
480
449
|
let podfile = '';
|
|
481
450
|
try {
|
|
482
|
-
podfile =
|
|
451
|
+
podfile = fs_1.default.readFileSync(path_1.default.join(ios, 'Podfile'), 'utf8');
|
|
483
452
|
}
|
|
484
453
|
catch {
|
|
485
454
|
// no Podfile
|
|
@@ -515,12 +484,12 @@ function detectIosHermes(projectRoot) {
|
|
|
515
484
|
const configured = configuredIosEngine(ios);
|
|
516
485
|
if (configured)
|
|
517
486
|
return configured === 'hermes';
|
|
518
|
-
if (
|
|
487
|
+
if (fs_1.default.existsSync(path_1.default.join(ios, 'Pods', 'hermes-engine'))) {
|
|
519
488
|
return true;
|
|
520
489
|
}
|
|
521
490
|
// CI may not have run pod install, so use the lockfile only as weak evidence.
|
|
522
491
|
try {
|
|
523
|
-
const lock =
|
|
492
|
+
const lock = fs_1.default.readFileSync(path_1.default.join(ios, 'Podfile.lock'), 'utf8');
|
|
524
493
|
if (/^\s*-\s+hermes-engine\b/m.test(lock))
|
|
525
494
|
return true;
|
|
526
495
|
}
|
|
@@ -588,7 +557,7 @@ function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
|
588
557
|
catch {
|
|
589
558
|
// RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
|
|
590
559
|
}
|
|
591
|
-
const hermesCommand = candidates.find((candidate) =>
|
|
560
|
+
const hermesCommand = candidates.find((candidate) => fs_1.default.existsSync(candidate));
|
|
592
561
|
if (hermesCommand) {
|
|
593
562
|
return hermesCommand;
|
|
594
563
|
}
|
|
@@ -790,10 +759,10 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
790
759
|
// hermesc is about to write its own map at `<bundle>.map`, which is where
|
|
791
760
|
// the packager map normally sits: move it aside (copy only when elsewhere)
|
|
792
761
|
if (path_1.default.resolve(sourcemapOutput) === path_1.default.resolve(hermesMap)) {
|
|
793
|
-
|
|
762
|
+
fs_1.default.renameSync(sourcemapOutput, packagerMap);
|
|
794
763
|
}
|
|
795
764
|
else {
|
|
796
|
-
|
|
765
|
+
fs_1.default.copyFileSync(sourcemapOutput, packagerMap);
|
|
797
766
|
}
|
|
798
767
|
}
|
|
799
768
|
else {
|
|
@@ -829,8 +798,8 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
829
798
|
const jsSource = path_1.default.join(workDir, bundleName);
|
|
830
799
|
const plainPath = path_1.default.join(workDir, 'plain', bundleName);
|
|
831
800
|
const wantPlain = Boolean(baseRequest?.verify);
|
|
832
|
-
|
|
833
|
-
|
|
801
|
+
(0, fs_helpers_1.ensureDirSync)(path_1.default.dirname(plainPath));
|
|
802
|
+
fs_1.default.renameSync(bundlePath, jsSource);
|
|
834
803
|
const args = (0, hermes_base_1.hermescArgsWithBase)(buildHermescArgs(bundlePath, jsSource), base.path);
|
|
835
804
|
console.log((0, i18n_1.t)('runningHermesc', { command, args: args.join(' ') }));
|
|
836
805
|
const [attempt, plain] = await Promise.all([
|
|
@@ -858,7 +827,7 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
858
827
|
// the intermediate dir, never inside it (its content is packed)
|
|
859
828
|
const logPath = hermesBaseErrorLogPath(outputFolder);
|
|
860
829
|
try {
|
|
861
|
-
|
|
830
|
+
fs_1.default.writeFileSync(logPath, fullStderr);
|
|
862
831
|
console.warn((0, i18n_1.t)('hermesBaseCompileFailedLog', { file: logPath }));
|
|
863
832
|
}
|
|
864
833
|
catch { }
|
|
@@ -934,16 +903,16 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
934
903
|
}
|
|
935
904
|
if (!usedBase) {
|
|
936
905
|
if (plainOk) {
|
|
937
|
-
|
|
938
|
-
if (
|
|
939
|
-
|
|
906
|
+
(0, fs_helpers_1.moveSync)(plainPath, bundlePath);
|
|
907
|
+
if (fs_1.default.existsSync(`${plainPath}.map`)) {
|
|
908
|
+
(0, fs_helpers_1.moveSync)(`${plainPath}.map`, hermesMap);
|
|
940
909
|
}
|
|
941
910
|
}
|
|
942
911
|
else {
|
|
943
912
|
await compilePlain(command, bundlePath, jsSource);
|
|
944
913
|
}
|
|
945
914
|
}
|
|
946
|
-
|
|
915
|
+
(0, fs_helpers_1.removeSync)(workDir);
|
|
947
916
|
result.base = usedBase ? base : null;
|
|
948
917
|
if (usedBase)
|
|
949
918
|
result.outcome = 'used';
|
|
@@ -952,7 +921,7 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
952
921
|
await composeSourceMaps(packagerMap, hermesMap, sourcemapOutput);
|
|
953
922
|
}
|
|
954
923
|
if (shouldCleanSourcemap) {
|
|
955
|
-
|
|
924
|
+
(0, fs_helpers_1.removeSync)(packagerMap);
|
|
956
925
|
}
|
|
957
926
|
return result;
|
|
958
927
|
}
|
|
@@ -1061,7 +1030,7 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
1061
1030
|
console.error((0, i18n_1.t)('sentryReactNativeNotFound'));
|
|
1062
1031
|
return;
|
|
1063
1032
|
}
|
|
1064
|
-
if (!
|
|
1033
|
+
if (!fs_1.default.existsSync(copyDebugidPath)) {
|
|
1065
1034
|
return;
|
|
1066
1035
|
}
|
|
1067
1036
|
console.log((0, i18n_1.t)('copyingDebugId'));
|
|
@@ -1073,7 +1042,7 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
1073
1042
|
stdio: 'ignore',
|
|
1074
1043
|
}), copyDebugidPath);
|
|
1075
1044
|
}
|
|
1076
|
-
|
|
1045
|
+
(0, fs_helpers_1.removeSync)(path_1.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
1077
1046
|
}
|
|
1078
1047
|
async function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
|
|
1079
1048
|
const bundlePath = path_1.default.join(outputFolder, bundleName);
|
|
@@ -1086,10 +1055,10 @@ async function prepareSentryUploadArtifacts(bundleName, outputFolder, platform)
|
|
|
1086
1055
|
}
|
|
1087
1056
|
const androidBundlePath = path_1.default.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
|
|
1088
1057
|
const androidSourcemapPath = path_1.default.join(outputFolder, `${ANDROID_SENTRY_BUNDLE_NAME}.map`);
|
|
1089
|
-
await
|
|
1090
|
-
const sourcemap = JSON.parse(await
|
|
1058
|
+
await fs_1.default.promises.copyFile(bundlePath, androidBundlePath);
|
|
1059
|
+
const sourcemap = JSON.parse(await fs_1.default.promises.readFile(sourcemapPath, 'utf8'));
|
|
1091
1060
|
sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
|
|
1092
|
-
await
|
|
1061
|
+
await fs_1.default.promises.writeFile(androidSourcemapPath, JSON.stringify(sourcemap));
|
|
1093
1062
|
return {
|
|
1094
1063
|
bundlePath: androidBundlePath,
|
|
1095
1064
|
sourcemapPath: androidSourcemapPath,
|
|
@@ -1097,7 +1066,7 @@ async function prepareSentryUploadArtifacts(bundleName, outputFolder, platform)
|
|
|
1097
1066
|
}
|
|
1098
1067
|
async function readSourcemapDebugId(sourcemapPath) {
|
|
1099
1068
|
try {
|
|
1100
|
-
const sourcemap = JSON.parse(await
|
|
1069
|
+
const sourcemap = JSON.parse(await fs_1.default.promises.readFile(sourcemapPath, 'utf8'));
|
|
1101
1070
|
const debugId = sourcemap.debugId ?? sourcemap.debug_id;
|
|
1102
1071
|
return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
|
|
1103
1072
|
}
|
|
@@ -1226,7 +1195,7 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
1226
1195
|
console.error((0, i18n_1.t)('sentryCliNotFound'));
|
|
1227
1196
|
return;
|
|
1228
1197
|
}
|
|
1229
|
-
if (!
|
|
1198
|
+
if (!fs_1.default.existsSync(sentryCliPath)) {
|
|
1230
1199
|
return;
|
|
1231
1200
|
}
|
|
1232
1201
|
const { bundlePath, sourcemapPath } = await prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
|
package/lib/diff.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
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
|
};
|
|
@@ -40,7 +7,7 @@ exports.diffCommands = exports.readEntry = exports.enumZipEntries = void 0;
|
|
|
40
7
|
exports.zipEntryContentKey = zipEntryContentKey;
|
|
41
8
|
exports.zipEntriesHaveSameContent = zipEntriesHaveSameContent;
|
|
42
9
|
const node_crypto_1 = require("node:crypto");
|
|
43
|
-
const
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
44
11
|
const global_dirs_1 = require("global-dirs");
|
|
45
12
|
const os_1 = __importDefault(require("os"));
|
|
46
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -48,6 +15,7 @@ const yazl_1 = require("yazl");
|
|
|
48
15
|
const native_package_1 = require("./native-package");
|
|
49
16
|
const utils_1 = require("./utils");
|
|
50
17
|
const constants_1 = require("./utils/constants");
|
|
18
|
+
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
51
19
|
const hbcTransform_1 = require("./utils/hbcTransform");
|
|
52
20
|
const i18n_1 = require("./utils/i18n");
|
|
53
21
|
const zip_entries_1 = require("./utils/zip-entries");
|
|
@@ -84,9 +52,9 @@ function basename(fn) {
|
|
|
84
52
|
return m?.[1];
|
|
85
53
|
}
|
|
86
54
|
function createOutputZip(output) {
|
|
87
|
-
|
|
55
|
+
(0, fs_helpers_1.ensureDirSync)(path_1.default.dirname(output));
|
|
88
56
|
const zipfile = new yazl_1.ZipFile();
|
|
89
|
-
const writeStream =
|
|
57
|
+
const writeStream = fs_1.default.createWriteStream(output);
|
|
90
58
|
const writePromise = new Promise((resolve, reject) => {
|
|
91
59
|
zipfile.outputStream.on('error', reject);
|
|
92
60
|
// without this, a full disk / read-only target left the promise pending
|
|
@@ -110,7 +78,7 @@ function createOutputZip(output) {
|
|
|
110
78
|
}
|
|
111
79
|
});
|
|
112
80
|
}
|
|
113
|
-
await
|
|
81
|
+
await fs_1.default.promises.rm(output, { force: true });
|
|
114
82
|
};
|
|
115
83
|
return { zipfile, writePromise, abort };
|
|
116
84
|
}
|
|
@@ -141,25 +109,25 @@ function reportDiffPhase(options, metric) {
|
|
|
141
109
|
}
|
|
142
110
|
}
|
|
143
111
|
const bundleSourceSize = (source) => source.kind === 'buffer' ? source.data.length : source.size;
|
|
144
|
-
const bundleSourceBuffer = async (source) => source.kind === 'buffer' ? source.data :
|
|
112
|
+
const bundleSourceBuffer = async (source) => source.kind === 'buffer' ? source.data : fs_1.default.promises.readFile(source.path);
|
|
145
113
|
async function bundleSourceFile(source, outputPath) {
|
|
146
114
|
if (source.kind === 'file') {
|
|
147
115
|
return source.path;
|
|
148
116
|
}
|
|
149
|
-
await
|
|
117
|
+
await fs_1.default.promises.writeFile(outputPath, source.data);
|
|
150
118
|
return outputPath;
|
|
151
119
|
}
|
|
152
120
|
async function hashFile(filePath) {
|
|
153
121
|
const hash = (0, node_crypto_1.createHash)('sha256');
|
|
154
|
-
for await (const chunk of
|
|
122
|
+
for await (const chunk of fs_1.default.createReadStream(filePath)) {
|
|
155
123
|
hash.update(chunk);
|
|
156
124
|
}
|
|
157
125
|
return hash.digest('hex');
|
|
158
126
|
}
|
|
159
127
|
async function filesEqual(leftPath, rightPath) {
|
|
160
128
|
const [leftStat, rightStat] = await Promise.all([
|
|
161
|
-
|
|
162
|
-
|
|
129
|
+
fs_1.default.promises.stat(leftPath),
|
|
130
|
+
fs_1.default.promises.stat(rightPath),
|
|
163
131
|
]);
|
|
164
132
|
if (leftStat.size !== rightStat.size) {
|
|
165
133
|
return false;
|
|
@@ -182,7 +150,7 @@ async function buildStreamBundlePatch(originSource, newSource, options, workRoot
|
|
|
182
150
|
if (!diffStreamFn || !patchStreamFn) {
|
|
183
151
|
throw new Error('stream diff requires diffStream/patchStream from node-hdiffpatch');
|
|
184
152
|
}
|
|
185
|
-
const tempRoot =
|
|
153
|
+
const tempRoot = fs_1.default.mkdtempSync(path_1.default.join(workRoot, 'stream-'));
|
|
186
154
|
const inputBytes = bundleSourceSize(originSource) + bundleSourceSize(newSource);
|
|
187
155
|
const extractionDurationMs = (originSource.kind === 'file' ? originSource.materializeDurationMs : 0) +
|
|
188
156
|
(newSource.kind === 'file' ? newSource.materializeDurationMs : 0);
|
|
@@ -206,12 +174,13 @@ async function buildStreamBundlePatch(originSource, newSource, options, workRoot
|
|
|
206
174
|
const rawPatchFile = path_1.default.join(tempRoot, 'patch-raw.bin');
|
|
207
175
|
await diffStreamFn(rawOldFile, rawNewFile, rawPatchFile);
|
|
208
176
|
let patchFile = rawPatchFile;
|
|
209
|
-
let patchBytes = (await
|
|
177
|
+
let patchBytes = (await fs_1.default.promises.stat(rawPatchFile)).size;
|
|
210
178
|
let chosenPair = null;
|
|
211
179
|
if (pair) {
|
|
212
180
|
const transformedPatchFile = path_1.default.join(tempRoot, 'patch-transformed.bin');
|
|
213
181
|
await diffStreamFn(transformedOldFile, transformedNewFile, transformedPatchFile);
|
|
214
|
-
const transformedPatchBytes = (await
|
|
182
|
+
const transformedPatchBytes = (await fs_1.default.promises.stat(transformedPatchFile))
|
|
183
|
+
.size;
|
|
215
184
|
const metaOverhead = Buffer.byteLength(JSON.stringify(pair.meta));
|
|
216
185
|
if (transformedPatchBytes + metaOverhead < patchBytes) {
|
|
217
186
|
patchFile = transformedPatchFile;
|
|
@@ -322,7 +291,7 @@ async function addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource,
|
|
|
322
291
|
bundleOptions.streamThresholdBytes;
|
|
323
292
|
let newSource;
|
|
324
293
|
if (shouldStream) {
|
|
325
|
-
const nextRoot =
|
|
294
|
+
const nextRoot = fs_1.default.mkdtempSync(path_1.default.join(workRoot, 'next-'));
|
|
326
295
|
const nextPath = path_1.default.join(nextRoot, 'bundle.bin');
|
|
327
296
|
const startedAt = performance.now();
|
|
328
297
|
await (0, zip_entries_1.writeEntry)(entry, nextZipfile, nextPath);
|
|
@@ -352,7 +321,7 @@ async function readOriginBundleSource(entry, zipFile, bundleOptions, workRoot) {
|
|
|
352
321
|
if (!bundleOptions.streamThresholdBytes) {
|
|
353
322
|
return { kind: 'buffer', data: await (0, zip_entries_1.readEntry)(entry, zipFile) };
|
|
354
323
|
}
|
|
355
|
-
const originRoot =
|
|
324
|
+
const originRoot = fs_1.default.mkdtempSync(path_1.default.join(workRoot, 'origin-'));
|
|
356
325
|
const originPath = path_1.default.join(originRoot, 'bundle.bin');
|
|
357
326
|
const startedAt = performance.now();
|
|
358
327
|
await (0, zip_entries_1.writeEntry)(entry, zipFile, originPath);
|
|
@@ -642,7 +611,7 @@ function diffArgsCheck(args, options, diffFnName) {
|
|
|
642
611
|
const createDiffCommand = ({ diffFnName, target }) => async ({ args, options }) => {
|
|
643
612
|
const { origin, next, realOutput, diffFn } = diffArgsCheck(args, options, diffFnName);
|
|
644
613
|
const bundleOptions = resolveBundleDiffOptions(options);
|
|
645
|
-
const workRoot =
|
|
614
|
+
const workRoot = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-bundle-diff-'));
|
|
646
615
|
try {
|
|
647
616
|
if (target.kind === 'ppk') {
|
|
648
617
|
await diffFromPPK(origin, next, realOutput, diffFn, bundleOptions, workRoot);
|
|
@@ -652,7 +621,7 @@ const createDiffCommand = ({ diffFnName, target }) => async ({ args, options })
|
|
|
652
621
|
}
|
|
653
622
|
}
|
|
654
623
|
finally {
|
|
655
|
-
|
|
624
|
+
fs_1.default.rmSync(workRoot, { recursive: true, force: true });
|
|
656
625
|
}
|
|
657
626
|
console.log((0, i18n_1.t)('diffPackageGenerated', { output: realOutput }));
|
|
658
627
|
};
|