react-native-update-cli 2.24.2 → 2.26.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.
- package/README.md +12 -5
- package/README.zh-CN.md +12 -5
- package/cli.json +7 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +63 -18
- package/lib/app.js +25 -3
- package/lib/bin.js +39 -45
- package/lib/bundle-runner.d.ts +45 -1
- package/lib/bundle-runner.js +303 -34
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +23 -7
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +7 -14
- package/lib/locales/en.js +10 -17
- package/lib/locales/zh.d.ts +7 -13
- package/lib/locales/zh.js +10 -16
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +7 -2
- package/lib/types.d.ts +1 -0
- package/lib/user.js +6 -0
- package/lib/utils/add-gitignore.js +7 -1
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +78 -26
- package/lib/utils/git.js +9 -6
- package/lib/utils/hbcTransform.d.ts +15 -0
- package/lib/utils/hbcTransform.js +22 -0
- package/lib/utils/hermes-base.d.ts +61 -6
- package/lib/utils/hermes-base.js +328 -46
- package/lib/utils/hermes-literals.d.ts +51 -0
- package/lib/utils/hermes-literals.js +210 -0
- package/lib/utils/i18n.d.ts +5 -0
- package/lib/utils/i18n.js +14 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +9 -4
- package/lib/utils/latest-version/index.js +8 -0
- package/lib/utils/runtime.d.ts +21 -0
- package/lib/utils/runtime.js +138 -5
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +14 -4
- package/package.json +6 -3
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -17
- package/src/api.ts +0 -470
- package/src/app.ts +0 -241
- package/src/auto-update.ts +0 -647
- package/src/bin-cresc.ts +0 -8
- package/src/bin.ts +0 -115
- package/src/bundle-pack.ts +0 -61
- package/src/bundle-runner.ts +0 -1430
- package/src/bundle.ts +0 -371
- package/src/cache.ts +0 -20
- package/src/diff.ts +0 -1010
- package/src/exports.ts +0 -17
- package/src/index.ts +0 -1
- package/src/install.ts +0 -50
- package/src/locales/en.ts +0 -257
- package/src/locales/zh.ts +0 -234
- package/src/native-package.ts +0 -338
- package/src/package.ts +0 -482
- package/src/provider.ts +0 -294
- package/src/symbolicate.ts +0 -164
- package/src/types.ts +0 -150
- package/src/user.ts +0 -39
- package/src/utils/add-gitignore.ts +0 -35
- package/src/utils/app-info-parser/aab.ts +0 -241
- package/src/utils/app-info-parser/apk.ts +0 -92
- package/src/utils/app-info-parser/app.ts +0 -7
- package/src/utils/app-info-parser/index.ts +0 -54
- package/src/utils/app-info-parser/ipa.ts +0 -109
- package/src/utils/app-info-parser/resource-finder.ts +0 -508
- package/src/utils/app-info-parser/utils.ts +0 -161
- package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
- package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
- package/src/utils/app-info-parser/zip.ts +0 -108
- package/src/utils/check-lockfile.ts +0 -93
- package/src/utils/check-plugin.ts +0 -38
- package/src/utils/command-result.ts +0 -24
- package/src/utils/constants.ts +0 -25
- package/src/utils/dep-versions.ts +0 -83
- package/src/utils/git.ts +0 -71
- package/src/utils/hbcTransform.ts +0 -649
- package/src/utils/hermes-base.ts +0 -1137
- package/src/utils/http-helper.ts +0 -152
- package/src/utils/i18n.ts +0 -39
- package/src/utils/index.ts +0 -698
- package/src/utils/latest-version/index.ts +0 -573
- package/src/utils/options.ts +0 -78
- package/src/utils/plugin-config.ts +0 -32
- package/src/utils/runtime.ts +0 -187
- package/src/utils/slim-sourcemap.ts +0 -105
- package/src/utils/zip-entries.ts +0 -209
- package/src/utils/zip-options.ts +0 -178
- package/src/utils/zip-range.ts +0 -727
- package/src/utils/zip-raw-writer.ts +0 -247
- package/src/versions.ts +0 -892
package/lib/bundle-runner.js
CHANGED
|
@@ -39,11 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.hasProjectDependency = hasProjectDependency;
|
|
40
40
|
exports.resolveExpoCli = resolveExpoCli;
|
|
41
41
|
exports.runReactNativeBundleCommand = runReactNativeBundleCommand;
|
|
42
|
+
exports.assertSafeToEmpty = assertSafeToEmpty;
|
|
43
|
+
exports.detectHermesEnabled = detectHermesEnabled;
|
|
44
|
+
exports.detectIosHermes = detectIosHermes;
|
|
42
45
|
exports.resolveHermesCommand = resolveHermesCommand;
|
|
43
46
|
exports.summarizeHermescStderr = summarizeHermescStderr;
|
|
44
47
|
exports.buildHermescArgs = buildHermescArgs;
|
|
45
48
|
exports.compileHermesByteCode = compileHermesByteCode;
|
|
46
49
|
exports.hermesBaseErrorLogPath = hermesBaseErrorLogPath;
|
|
50
|
+
exports.hermesBaseDumpPaths = hermesBaseDumpPaths;
|
|
47
51
|
exports.startHermesBaseSelection = startHermesBaseSelection;
|
|
48
52
|
exports.copyDebugidForSentry = copyDebugidForSentry;
|
|
49
53
|
exports.prepareSentryUploadArtifacts = prepareSentryUploadArtifacts;
|
|
@@ -57,6 +61,7 @@ const fs = __importStar(require("fs-extra"));
|
|
|
57
61
|
const os_1 = __importDefault(require("os"));
|
|
58
62
|
const path_1 = __importDefault(require("path"));
|
|
59
63
|
const api_1 = require("./api");
|
|
64
|
+
const dep_versions_1 = require("./utils/dep-versions");
|
|
60
65
|
const hermes_base_1 = require("./utils/hermes-base");
|
|
61
66
|
const i18n_1 = require("./utils/i18n");
|
|
62
67
|
const runtime_1 = require("./utils/runtime");
|
|
@@ -129,7 +134,7 @@ function resolveExpoCli(projectRoot = process.cwd()) {
|
|
|
129
134
|
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, hermesBase, resetCache = true, cli, isSentry, }) {
|
|
130
135
|
let gradleConfig = {};
|
|
131
136
|
if (platform === 'android') {
|
|
132
|
-
gradleConfig = await checkGradleConfig();
|
|
137
|
+
gradleConfig = await checkGradleConfig(process.cwd());
|
|
133
138
|
if (gradleConfig.crunchPngs !== false) {
|
|
134
139
|
console.warn((0, i18n_1.t)('androidCrunchPngsWarning'));
|
|
135
140
|
}
|
|
@@ -139,6 +144,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
139
144
|
if (envArgs) {
|
|
140
145
|
reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
|
|
141
146
|
}
|
|
147
|
+
outputFolder = assertSafeToEmpty(outputFolder);
|
|
142
148
|
fs.emptyDirSync(outputFolder);
|
|
143
149
|
let cliPath = '';
|
|
144
150
|
let usingExpo = false;
|
|
@@ -285,30 +291,241 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
285
291
|
});
|
|
286
292
|
return hermesResult;
|
|
287
293
|
}
|
|
288
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Validate the intermediate directory before it is emptied and return the
|
|
296
|
+
* canonical path that was validated. The caller must use this returned path:
|
|
297
|
+
* validating one spelling and deleting through another re-opens symlink
|
|
298
|
+
* redirection.
|
|
299
|
+
*/
|
|
300
|
+
function assertSafeToEmpty(dir, cwd = process.cwd()) {
|
|
301
|
+
const requested = path_1.default.resolve(cwd, dir);
|
|
302
|
+
const lexicalCwd = path_1.default.resolve(cwd);
|
|
303
|
+
const lexicalHome = path_1.default.resolve(os_1.default.homedir());
|
|
304
|
+
const lexicalTmp = path_1.default.resolve(os_1.default.tmpdir());
|
|
305
|
+
const contains = (parent, child) => {
|
|
306
|
+
const relative = path_1.default.relative(parent, child);
|
|
307
|
+
return (relative === '' ||
|
|
308
|
+
(!relative.startsWith('..') && !path_1.default.isAbsolute(relative)));
|
|
309
|
+
};
|
|
310
|
+
const samePath = (left, right) => {
|
|
311
|
+
const normalize = (value) => {
|
|
312
|
+
const resolved = path_1.default.resolve(value);
|
|
313
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
314
|
+
};
|
|
315
|
+
return normalize(left) === normalize(right);
|
|
316
|
+
};
|
|
317
|
+
const reject = (target) => {
|
|
318
|
+
throw new Error((0, i18n_1.t)('unsafeIntermediateDir', { dir: target }));
|
|
319
|
+
};
|
|
320
|
+
const validate = (target, projectRoot, home, tmpRoot) => {
|
|
321
|
+
// Reject each protected directory and all of its ancestors.
|
|
322
|
+
for (const protectedPath of [
|
|
323
|
+
path_1.default.parse(target).root,
|
|
324
|
+
projectRoot,
|
|
325
|
+
home,
|
|
326
|
+
tmpRoot,
|
|
327
|
+
]) {
|
|
328
|
+
if (contains(target, protectedPath))
|
|
329
|
+
reject(target);
|
|
330
|
+
}
|
|
331
|
+
// Never allow build cleanup inside source-control metadata.
|
|
332
|
+
for (const metadata of ['.git', '.hg', '.svn']) {
|
|
333
|
+
if (contains(path_1.default.join(projectRoot, metadata), target))
|
|
334
|
+
reject(target);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
validate(requested, lexicalCwd, lexicalHome, lexicalTmp);
|
|
338
|
+
// A final-component symlink is the direct dangerous case: emptyDirSync would
|
|
339
|
+
// enumerate and remove entries from its target rather than removing the link.
|
|
340
|
+
if (fs.existsSync(requested) && fs.lstatSync(requested).isSymbolicLink()) {
|
|
341
|
+
reject(requested);
|
|
342
|
+
}
|
|
343
|
+
// emptyDirSync creates a missing directory too; create it first so it can be
|
|
344
|
+
// canonicalized and the exact validated path can be passed to deletion.
|
|
345
|
+
fs.ensureDirSync(requested);
|
|
346
|
+
const canonical = (value) => fs.realpathSync.native(value);
|
|
347
|
+
const target = canonical(requested);
|
|
348
|
+
const canonicalCwd = canonical(lexicalCwd);
|
|
349
|
+
const canonicalHome = canonical(lexicalHome);
|
|
350
|
+
const canonicalTmp = canonical(lexicalTmp);
|
|
351
|
+
validate(target, canonicalCwd, canonicalHome, canonicalTmp);
|
|
352
|
+
// Reject a symlink in any component below a known safe base. System aliases
|
|
353
|
+
// such as macOS /var -> /private/var remain valid because the base itself is
|
|
354
|
+
// canonicalized before the relative suffix is appended.
|
|
355
|
+
for (const [lexicalBase, canonicalBase] of [
|
|
356
|
+
[lexicalCwd, canonicalCwd],
|
|
357
|
+
[lexicalHome, canonicalHome],
|
|
358
|
+
[lexicalTmp, canonicalTmp],
|
|
359
|
+
]) {
|
|
360
|
+
const relative = path_1.default.relative(lexicalBase, requested);
|
|
361
|
+
if (relative === '' ||
|
|
362
|
+
(!relative.startsWith('..') && !path_1.default.isAbsolute(relative))) {
|
|
363
|
+
if (!samePath(path_1.default.resolve(canonicalBase, relative), target)) {
|
|
364
|
+
reject(target);
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return target;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Whether the app runs Hermes, i.e. whether the bundle must be compiled to
|
|
373
|
+
* bytecode. A JS bundle shipped to a Hermes app still runs, but starts slower
|
|
374
|
+
* and cannot use the Hermes base delta, so false negatives are what this
|
|
375
|
+
* guards against.
|
|
376
|
+
*
|
|
377
|
+
* Android: `hermesEnabled` in gradle.properties wins; then the legacy
|
|
378
|
+
* `project.ext.react.enableHermes` of build.gradle; with neither, the React
|
|
379
|
+
* Native gradle plugin (0.71+) defaults to Hermes and older versions to JSC.
|
|
380
|
+
* iOS: an installed `Pods/hermes-engine`; when `pod install` has not run on
|
|
381
|
+
* this machine (CI), Expo's `Podfile.properties.json` or the pod listed in
|
|
382
|
+
* `Podfile.lock` tell the same.
|
|
383
|
+
*/
|
|
384
|
+
async function detectHermesEnabled(platform, forceHermes, gradleConfig, projectRoot = process.cwd()) {
|
|
289
385
|
if (forceHermes) {
|
|
290
386
|
console.log((0, i18n_1.t)('forceHermes'));
|
|
291
387
|
return true;
|
|
292
388
|
}
|
|
293
389
|
if (platform === 'android') {
|
|
294
|
-
const gradleProperties = await
|
|
295
|
-
properties.parse('./android/gradle.properties', { path: true }, (error, props = {}) => {
|
|
296
|
-
if (error) {
|
|
297
|
-
console.error(error);
|
|
298
|
-
resolve({});
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
resolve(props);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
390
|
+
const gradleProperties = await readGradleProperties(path_1.default.join(projectRoot, 'android', 'gradle.properties'));
|
|
304
391
|
if (typeof gradleProperties.hermesEnabled === 'boolean') {
|
|
305
392
|
return gradleProperties.hermesEnabled;
|
|
306
393
|
}
|
|
307
|
-
|
|
394
|
+
if (typeof gradleConfig.enableHermes === 'boolean') {
|
|
395
|
+
return gradleConfig.enableHermes;
|
|
396
|
+
}
|
|
397
|
+
return reactNativeDefaultsToHermes(projectRoot);
|
|
398
|
+
}
|
|
399
|
+
if (platform === 'ios') {
|
|
400
|
+
return detectIosHermes(projectRoot);
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
/** parsed gradle.properties; a missing file is simply empty */
|
|
405
|
+
function readGradleProperties(file) {
|
|
406
|
+
return new Promise((resolve) => {
|
|
407
|
+
properties.parse(file, { path: true }, (error, props = {}) => {
|
|
408
|
+
if (error) {
|
|
409
|
+
if (error.code !== 'ENOENT') {
|
|
410
|
+
console.warn(`${file}: ${error.message ?? error}`);
|
|
411
|
+
}
|
|
412
|
+
resolve({});
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
resolve(props);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/** React Native's gradle plugin (0.71+) enables Hermes unless a property says otherwise */
|
|
420
|
+
function reactNativeDefaultsToHermes(projectRoot) {
|
|
421
|
+
const version = (0, dep_versions_1.getDepVersion)('react-native', projectRoot);
|
|
422
|
+
// major.minor by hand: React Native is 0.x, and the check must not depend
|
|
423
|
+
// on a semver library (tests replace compare-versions wholesale)
|
|
424
|
+
const match = version ? /^(\d+)\.(\d+)\./.exec(version) : null;
|
|
425
|
+
if (!match) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
429
|
+
return major > 0 || minor >= 71;
|
|
430
|
+
}
|
|
431
|
+
/** Remove Ruby comments without treating a # inside a quoted string as one. */
|
|
432
|
+
function stripRubyComments(source) {
|
|
433
|
+
return source
|
|
434
|
+
.split(/\r?\n/)
|
|
435
|
+
.map((line) => {
|
|
436
|
+
let quote;
|
|
437
|
+
let escaped = false;
|
|
438
|
+
for (let index = 0; index < line.length; index++) {
|
|
439
|
+
const char = line[index];
|
|
440
|
+
if (escaped) {
|
|
441
|
+
escaped = false;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (quote) {
|
|
445
|
+
if (char === '\\') {
|
|
446
|
+
escaped = true;
|
|
447
|
+
}
|
|
448
|
+
else if (char === quote) {
|
|
449
|
+
quote = undefined;
|
|
450
|
+
}
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (char === "'" || char === '"') {
|
|
454
|
+
quote = char;
|
|
455
|
+
}
|
|
456
|
+
else if (char === '#') {
|
|
457
|
+
return line.slice(0, index);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return line;
|
|
461
|
+
})
|
|
462
|
+
.join('\n');
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Read explicit iOS engine configuration. An explicit JSC/disabled-Hermes
|
|
466
|
+
* setting wins over installed pods because CocoaPods may still fetch the
|
|
467
|
+
* hermes-engine dependency for a JSC build.
|
|
468
|
+
*/
|
|
469
|
+
function configuredIosEngine(ios) {
|
|
470
|
+
let expoEngine;
|
|
471
|
+
try {
|
|
472
|
+
const value = JSON.parse(fs.readFileSync(path_1.default.join(ios, 'Podfile.properties.json'), 'utf8'))?.['expo.jsEngine'];
|
|
473
|
+
if (value === 'hermes' || value === 'jsc')
|
|
474
|
+
expoEngine = value;
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
// no Expo properties file
|
|
308
478
|
}
|
|
309
|
-
|
|
479
|
+
let podfile = '';
|
|
480
|
+
try {
|
|
481
|
+
podfile = fs.readFileSync(path_1.default.join(ios, 'Podfile'), 'utf8');
|
|
482
|
+
}
|
|
483
|
+
catch {
|
|
484
|
+
// no Podfile
|
|
485
|
+
}
|
|
486
|
+
const activePodfile = stripRubyComments(podfile);
|
|
487
|
+
const envValue = (name) => new RegExp(`ENV\\s*\\[\\s*['"]${name}['"]\\s*\\]\\s*(?:\\|\\|=|=)\\s*['"]([^'"]+)['"]`, 'i')
|
|
488
|
+
.exec(activePodfile)?.[1]
|
|
489
|
+
?.toLowerCase();
|
|
490
|
+
const useHermes = envValue('USE_HERMES');
|
|
491
|
+
const useThirdPartyJsc = envValue('USE_THIRD_PARTY_JSC');
|
|
492
|
+
const hermesOption = /(?:^|[,(]\s*)(?::hermes_enabled\s*=>|hermes_enabled\s*:)\s*(true|false)\b/im
|
|
493
|
+
.exec(activePodfile)?.[1]
|
|
494
|
+
?.toLowerCase();
|
|
495
|
+
if (useThirdPartyJsc === '1' ||
|
|
496
|
+
useThirdPartyJsc === 'true' ||
|
|
497
|
+
useHermes === '0' ||
|
|
498
|
+
useHermes === 'false' ||
|
|
499
|
+
hermesOption === 'false' ||
|
|
500
|
+
expoEngine === 'jsc') {
|
|
501
|
+
return 'jsc';
|
|
502
|
+
}
|
|
503
|
+
if (useHermes === '1' ||
|
|
504
|
+
useHermes === 'true' ||
|
|
505
|
+
hermesOption === 'true' ||
|
|
506
|
+
expoEngine === 'hermes') {
|
|
507
|
+
return 'hermes';
|
|
508
|
+
}
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
/** Hermes on iOS: explicit configuration first, installed artifacts second. */
|
|
512
|
+
function detectIosHermes(projectRoot) {
|
|
513
|
+
const ios = path_1.default.join(projectRoot, 'ios');
|
|
514
|
+
const configured = configuredIosEngine(ios);
|
|
515
|
+
if (configured)
|
|
516
|
+
return configured === 'hermes';
|
|
517
|
+
if (fs.existsSync(path_1.default.join(ios, 'Pods', 'hermes-engine'))) {
|
|
310
518
|
return true;
|
|
311
519
|
}
|
|
520
|
+
// CI may not have run pod install, so use the lockfile only as weak evidence.
|
|
521
|
+
try {
|
|
522
|
+
const lock = fs.readFileSync(path_1.default.join(ios, 'Podfile.lock'), 'utf8');
|
|
523
|
+
if (/^\s*-\s+hermes-engine\b/m.test(lock))
|
|
524
|
+
return true;
|
|
525
|
+
}
|
|
526
|
+
catch {
|
|
527
|
+
// no lockfile either
|
|
528
|
+
}
|
|
312
529
|
return false;
|
|
313
530
|
}
|
|
314
531
|
function getHermesOSBin() {
|
|
@@ -376,18 +593,19 @@ function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
|
376
593
|
}
|
|
377
594
|
throw new Error(`Cannot find hermesc. Tried:\n${candidates.map((candidate) => `- ${candidate}`).join('\n')}`);
|
|
378
595
|
}
|
|
379
|
-
async function checkGradleConfig() {
|
|
380
|
-
|
|
596
|
+
async function checkGradleConfig(projectRoot) {
|
|
597
|
+
// undefined when build.gradle does not mention Hermes at all (React Native
|
|
598
|
+
// 0.71+ moved the switch to gradle.properties; see detectHermesEnabled)
|
|
599
|
+
let enableHermes;
|
|
381
600
|
let crunchPngs;
|
|
382
601
|
try {
|
|
383
|
-
const gradleConfig = await g2js.parseFile('android
|
|
602
|
+
const gradleConfig = await g2js.parseFile(path_1.default.join(projectRoot, 'android', 'app', 'build.gradle'));
|
|
384
603
|
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
|
385
604
|
const projectConfig = gradleConfig['project.ext.react'];
|
|
386
605
|
if (projectConfig) {
|
|
387
606
|
for (const packagerConfig of projectConfig) {
|
|
388
|
-
if (packagerConfig.includes('enableHermes')
|
|
389
|
-
packagerConfig.includes('true')
|
|
390
|
-
enableHermes = true;
|
|
607
|
+
if (packagerConfig.includes('enableHermes')) {
|
|
608
|
+
enableHermes = packagerConfig.includes('true');
|
|
391
609
|
break;
|
|
392
610
|
}
|
|
393
611
|
}
|
|
@@ -560,7 +778,7 @@ async function composeSourceMaps(packagerMap, hermesMap, sourcemapOutput) {
|
|
|
560
778
|
assertSuccessfulSyncProcess(await runProcess((0, runtime_1.getJavaScriptRuntime)(), [composerPath, packagerMap, hermesMap, '-o', sourcemapOutput], false), composerPath);
|
|
561
779
|
return true;
|
|
562
780
|
}
|
|
563
|
-
async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap, baseRequest, pendingBase, hermesCommand
|
|
781
|
+
async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap, baseRequest, pendingBase, hermesCommand, }) {
|
|
564
782
|
console.log((0, i18n_1.t)('hermesEnabledCompiling'));
|
|
565
783
|
const bundlePath = path_1.default.join(outputFolder, bundleName);
|
|
566
784
|
const hermesMap = `${bundlePath}.map`;
|
|
@@ -578,6 +796,8 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
578
796
|
else {
|
|
579
797
|
console.log((0, i18n_1.t)('hermesSourcemapKept', { file: hermesMap }));
|
|
580
798
|
}
|
|
799
|
+
// the selection already resolved hermesc while Metro ran; only look it up
|
|
800
|
+
// again when there was no selection (or it could not find the binary)
|
|
581
801
|
let selection = pendingBase ? await awaitPendingBase(pendingBase) : null;
|
|
582
802
|
const command = hermesCommand ?? selection?.hermesCommand ?? resolveHermesCommand();
|
|
583
803
|
if (!selection || selection.commandUnavailable) {
|
|
@@ -588,6 +808,7 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
588
808
|
const result = {
|
|
589
809
|
bytecodeVersion: selection.bytecodeVersion,
|
|
590
810
|
base: null,
|
|
811
|
+
outcome: 'none',
|
|
591
812
|
};
|
|
592
813
|
const base = selection.base;
|
|
593
814
|
// the packager + hermes maps merged into sourcemapOutput
|
|
@@ -625,6 +846,7 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
625
846
|
console.warn((0, i18n_1.t)('hermesBaseCompileFailed', {
|
|
626
847
|
reason: reason || `exit ${attempt.status}`,
|
|
627
848
|
}));
|
|
849
|
+
result.outcomeDetail = `base compile failed: ${reason || `exit ${attempt.status}`}`;
|
|
628
850
|
if (fullStderr.trim()) {
|
|
629
851
|
// the summary drops noise; keep everything for bug reports — next to
|
|
630
852
|
// the intermediate dir, never inside it (its content is packed)
|
|
@@ -644,26 +866,56 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
644
866
|
: null;
|
|
645
867
|
if (usedBase && wantPlain) {
|
|
646
868
|
if (!plainOk) {
|
|
647
|
-
//
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
869
|
+
// The check could not run. That is not evidence against the base,
|
|
870
|
+
// but verification was asked for and did not happen, so the base is
|
|
871
|
+
// dropped exactly like a dump that could not be read: never ship
|
|
872
|
+
// unverified when asked to verify. The plain compile is simply
|
|
873
|
+
// repeated below (compilePlain), which surfaces a real compiler
|
|
874
|
+
// failure as the build error it is.
|
|
875
|
+
const reason = (plain?.error && String(plain.error.message ?? plain.error)) ||
|
|
876
|
+
`exit ${plain?.status}`;
|
|
877
|
+
console.warn((0, i18n_1.t)('hermesBasePlainCompileFailed', { reason }));
|
|
878
|
+
result.outcome = 'dump-failed';
|
|
879
|
+
result.outcomeDetail = `plain compile failed: ${reason}`;
|
|
880
|
+
usedBase = false;
|
|
652
881
|
}
|
|
653
882
|
else {
|
|
654
|
-
|
|
883
|
+
const dumpTo = hermesBaseDumpPaths(outputFolder);
|
|
884
|
+
let outcome;
|
|
655
885
|
try {
|
|
656
|
-
|
|
886
|
+
outcome = await (0, hermes_base_1.compareHermesBytecode)(command, bundlePath, plainPath, {
|
|
887
|
+
dumpTo,
|
|
888
|
+
});
|
|
657
889
|
}
|
|
658
|
-
catch {
|
|
659
|
-
|
|
890
|
+
catch (error) {
|
|
891
|
+
outcome = {
|
|
892
|
+
status: 'dump-failed',
|
|
893
|
+
detail: String(error?.message ?? error),
|
|
894
|
+
functions: 0,
|
|
895
|
+
};
|
|
660
896
|
}
|
|
661
|
-
result.verified =
|
|
662
|
-
if (
|
|
663
|
-
|
|
897
|
+
result.verified = outcome.status === 'equivalent';
|
|
898
|
+
if (outcome.status !== 'equivalent') {
|
|
899
|
+
result.outcome =
|
|
900
|
+
outcome.status === 'different' ? 'rejected' : 'dump-failed';
|
|
901
|
+
result.outcomeDetail = outcome.detail;
|
|
902
|
+
}
|
|
903
|
+
if (outcome.status === 'equivalent') {
|
|
904
|
+
console.log((0, i18n_1.t)('hermesBaseVerified', { functions: outcome.functions }));
|
|
664
905
|
}
|
|
665
906
|
else {
|
|
666
|
-
|
|
907
|
+
// a dump that could not be read is not evidence either way; the
|
|
908
|
+
// base is still dropped (never ship unverified when asked to
|
|
909
|
+
// verify), but the log says which case this is
|
|
910
|
+
console.warn((0, i18n_1.t)(outcome.status === 'different'
|
|
911
|
+
? 'hermesBaseVerifyFailed'
|
|
912
|
+
: 'hermesBaseVerifyDumpFailed', { detail: outcome.detail ?? '' }));
|
|
913
|
+
if (dumpTo) {
|
|
914
|
+
console.warn((0, i18n_1.t)('hermesBaseVerifyDumpsWritten', {
|
|
915
|
+
withBase: dumpTo.withBase,
|
|
916
|
+
plain: dumpTo.plain,
|
|
917
|
+
}));
|
|
918
|
+
}
|
|
667
919
|
usedBase = false;
|
|
668
920
|
}
|
|
669
921
|
}
|
|
@@ -689,6 +941,8 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
689
941
|
}
|
|
690
942
|
fs.removeSync(workDir);
|
|
691
943
|
result.base = usedBase ? base : null;
|
|
944
|
+
if (usedBase)
|
|
945
|
+
result.outcome = 'used';
|
|
692
946
|
}
|
|
693
947
|
if (sourcemapOutput && !composed) {
|
|
694
948
|
await composeSourceMaps(packagerMap, hermesMap, sourcemapOutput);
|
|
@@ -702,6 +956,21 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
702
956
|
function hermesBaseErrorLogPath(outputFolder) {
|
|
703
957
|
return path_1.default.join(path_1.default.dirname(path_1.default.resolve(outputFolder)), 'hermes-base-error.log');
|
|
704
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* With PUSHY_HERMES_BASE_DEBUG set, both disassemblies of the equivalence
|
|
961
|
+
* check are kept next to the intermediate directory (never packed) so a
|
|
962
|
+
* rejected base can be reported with the exact difference.
|
|
963
|
+
*/
|
|
964
|
+
function hermesBaseDumpPaths(outputFolder, env = process.env) {
|
|
965
|
+
const flag = env.PUSHY_HERMES_BASE_DEBUG?.trim().toLowerCase();
|
|
966
|
+
if (!flag || flag === '0' || flag === 'false')
|
|
967
|
+
return undefined;
|
|
968
|
+
const dir = path_1.default.dirname(path_1.default.resolve(outputFolder));
|
|
969
|
+
return {
|
|
970
|
+
withBase: path_1.default.join(dir, 'hermes-base-dump-base.txt'),
|
|
971
|
+
plain: path_1.default.join(dir, 'hermes-base-dump-plain.txt'),
|
|
972
|
+
};
|
|
973
|
+
}
|
|
705
974
|
/**
|
|
706
975
|
* Begin resolving the base right away (before Metro); the compile phase awaits
|
|
707
976
|
* the result. Never rejects: any failure is reported there instead.
|
package/lib/bundle.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ type NormalizedBundleOptions = {
|
|
|
32
32
|
export declare function normalizeBundleOptions(translatedOptions: Record<string, unknown>, platform: string): NormalizedBundleOptions;
|
|
33
33
|
export declare const bundleCommands: {
|
|
34
34
|
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
35
|
-
bundle: ({ options, }: {
|
|
35
|
+
bundle: ({ args, options, }: {
|
|
36
36
|
args?: string[];
|
|
37
37
|
options: Record<string, unknown>;
|
|
38
38
|
}) => Promise<void>;
|
package/lib/bundle.js
CHANGED
|
@@ -18,6 +18,10 @@ const hermes_base_1 = require("./utils/hermes-base");
|
|
|
18
18
|
const i18n_1 = require("./utils/i18n");
|
|
19
19
|
const options_1 = require("./utils/options");
|
|
20
20
|
const versions_1 = require("./versions");
|
|
21
|
+
/** `--no-<flag>` as parsed by cli-arguments: the key is present without a value. */
|
|
22
|
+
function isClearedFlag(options, key) {
|
|
23
|
+
return key in options && options[key] === undefined;
|
|
24
|
+
}
|
|
21
25
|
/** Parse a positive cache-size option expressed in megabytes. */
|
|
22
26
|
function parseCacheMaxMb(value) {
|
|
23
27
|
const parsed = typeof value === 'string' ? Number(value) : value;
|
|
@@ -41,8 +45,13 @@ function normalizeBundleOptions(translatedOptions, platform) {
|
|
|
41
45
|
output: (0, options_1.getStringOption)(translatedOptions, 'output', `${constants_1.tempDir}/output/${platform}.\${time}.ppk`),
|
|
42
46
|
dev: (0, options_1.getBooleanOption)(translatedOptions, 'dev', false) ? 'true' : 'false',
|
|
43
47
|
// On by default since 2.23: the map is archived with the published
|
|
44
|
-
// version (pushy symbolicate).
|
|
45
|
-
|
|
48
|
+
// version (pushy symbolicate). `--no-sourcemap` opts out: cli-arguments
|
|
49
|
+
// implements `--no-<flag>` by clearing the flag's value, so a key that is
|
|
50
|
+
// present but undefined is the opt-out and only a missing key means
|
|
51
|
+
// "default" (`--sourcemap false` would leave the flag on, see `bundle`).
|
|
52
|
+
sourcemap: isClearedFlag(translatedOptions, 'sourcemap')
|
|
53
|
+
? false
|
|
54
|
+
: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', true),
|
|
46
55
|
taro: (0, options_1.getBooleanOption)(translatedOptions, 'taro', false),
|
|
47
56
|
expo: (0, options_1.getBooleanOption)(translatedOptions, 'expo', false),
|
|
48
57
|
rncli: (0, options_1.getBooleanOption)(translatedOptions, 'rncli', false),
|
|
@@ -87,7 +96,14 @@ async function publishBundleVersion(outputPath, platform, payload) {
|
|
|
87
96
|
}
|
|
88
97
|
exports.bundleCommands = {
|
|
89
98
|
/** Build a bundle and optionally publish it to one operation-scoped app. */
|
|
90
|
-
bundle: async ({ options, }) => {
|
|
99
|
+
bundle: async ({ args = [], options, }) => {
|
|
100
|
+
// Boolean flags take no value: `--sourcemap false` leaves the flag on and
|
|
101
|
+
// turns "false" into a stray argument. Refuse it rather than silently
|
|
102
|
+
// bundling with the wrong settings (a flag is switched off with
|
|
103
|
+
// `--no-<flag>`).
|
|
104
|
+
if (args.length > 0) {
|
|
105
|
+
throw new Error((0, i18n_1.t)('bundleUnexpectedArgs', { args: args.join(' ') }));
|
|
106
|
+
}
|
|
91
107
|
const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string' ? options.platform : undefined);
|
|
92
108
|
const translatedOptions = (0, utils_1.translateOptions)({
|
|
93
109
|
...options,
|
|
@@ -136,9 +152,6 @@ exports.bundleCommands = {
|
|
|
136
152
|
]);
|
|
137
153
|
const sourcemapOutput = path_1.default.join(normalized.intermediaDir, `${normalized.bundleName}.map`);
|
|
138
154
|
const realOutput = normalized.output.replace(/\$\{time\}/g, `${Date.now()}`);
|
|
139
|
-
if (!platform) {
|
|
140
|
-
throw new Error((0, i18n_1.t)('platformRequired'));
|
|
141
|
-
}
|
|
142
155
|
console.log((0, i18n_1.t)('bundlingWithRN', { version: dep_versions_1.depVersions['react-native'] }));
|
|
143
156
|
const hermesResult = await (0, bundle_runner_1.runReactNativeBundleCommand)({
|
|
144
157
|
bundleName: normalized.bundleName,
|
|
@@ -159,7 +172,10 @@ exports.bundleCommands = {
|
|
|
159
172
|
});
|
|
160
173
|
await (0, bundle_pack_1.packBundle)(path_1.default.resolve(normalized.intermediaDir), realOutput, normalized.bundleName);
|
|
161
174
|
const baseMeta = hermesResult
|
|
162
|
-
? (0, hermes_base_1.hermesBaseMeta)(hermesResult.base, hermesResult.bytecodeVersion
|
|
175
|
+
? (0, hermes_base_1.hermesBaseMeta)(hermesResult.base, hermesResult.bytecodeVersion, {
|
|
176
|
+
outcome: hermesResult.outcome,
|
|
177
|
+
detail: hermesResult.outcomeDetail,
|
|
178
|
+
})
|
|
163
179
|
: undefined;
|
|
164
180
|
if (normalized.name) {
|
|
165
181
|
await publishBundleVersion(realOutput, platform, {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
|
|
2
|
+
/** names of all commands, in the order they are listed by `help` */
|
|
3
|
+
export declare const commandNames: readonly string[];
|
|
4
|
+
/** the handler of `name`, loading its module now; undefined for unknown names */
|
|
5
|
+
export declare function loadCommandHandler(name: string): CliCommandHandler | undefined;
|
|
6
|
+
export {};
|
package/lib/commands.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Command registry. Every command group is `require`d on first use, so a
|
|
3
|
+
// command only pays for its own modules: `apps` never loads Metro/Hermes
|
|
4
|
+
// plumbing, `bundle` never loads the source-map library, and so on.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commandNames = void 0;
|
|
7
|
+
exports.loadCommandHandler = loadCommandHandler;
|
|
8
|
+
const groups = {
|
|
9
|
+
app: () => require('./app').getAppCommands(),
|
|
10
|
+
bundle: () => require('./bundle').bundleCommands,
|
|
11
|
+
cache: () => require('./cache').cacheCommands,
|
|
12
|
+
diff: () => require('./diff').diffCommands,
|
|
13
|
+
install: () => require('./install').installCommands,
|
|
14
|
+
package: () => require('./package').packageCommands,
|
|
15
|
+
symbolicate: () => require('./symbolicate').symbolicateCommands,
|
|
16
|
+
user: () => require('./user').userCommands,
|
|
17
|
+
versions: () => require('./versions').versionCommands,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* command name → group. Kept in sync with cli.json by tests/commands.test.ts,
|
|
21
|
+
* so a command added to one place but not the other fails the suite.
|
|
22
|
+
*/
|
|
23
|
+
const commandGroups = {
|
|
24
|
+
login: 'user',
|
|
25
|
+
logout: 'user',
|
|
26
|
+
me: 'user',
|
|
27
|
+
createApp: 'app',
|
|
28
|
+
apps: 'app',
|
|
29
|
+
deleteApp: 'app',
|
|
30
|
+
selectApp: 'app',
|
|
31
|
+
uploadIpa: 'package',
|
|
32
|
+
uploadApk: 'package',
|
|
33
|
+
uploadAab: 'package',
|
|
34
|
+
uploadApp: 'package',
|
|
35
|
+
parseApp: 'package',
|
|
36
|
+
parseIpa: 'package',
|
|
37
|
+
parseApk: 'package',
|
|
38
|
+
parseAab: 'package',
|
|
39
|
+
extractApk: 'package',
|
|
40
|
+
packages: 'package',
|
|
41
|
+
deletePackage: 'package',
|
|
42
|
+
publish: 'versions',
|
|
43
|
+
versions: 'versions',
|
|
44
|
+
update: 'versions',
|
|
45
|
+
updateVersionInfo: 'versions',
|
|
46
|
+
deleteVersion: 'versions',
|
|
47
|
+
bundle: 'bundle',
|
|
48
|
+
hdiff: 'diff',
|
|
49
|
+
hdiffFromApk: 'diff',
|
|
50
|
+
hdiffFromApp: 'diff',
|
|
51
|
+
hdiffFromIpa: 'diff',
|
|
52
|
+
install: 'install',
|
|
53
|
+
cache: 'cache',
|
|
54
|
+
symbolicate: 'symbolicate',
|
|
55
|
+
};
|
|
56
|
+
/** names of all commands, in the order they are listed by `help` */
|
|
57
|
+
exports.commandNames = Object.keys(commandGroups);
|
|
58
|
+
/** the handler of `name`, loading its module now; undefined for unknown names */
|
|
59
|
+
function loadCommandHandler(name) {
|
|
60
|
+
const group = commandGroups[name];
|
|
61
|
+
if (!group) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return groups[group]()[name];
|
|
65
|
+
}
|
package/lib/locales/en.d.ts
CHANGED
|
@@ -32,24 +32,18 @@ declare const _default: {
|
|
|
32
32
|
bundlingWithRN: string;
|
|
33
33
|
cancelled: string;
|
|
34
34
|
composingSourceMap: string;
|
|
35
|
-
copyFileFailed: string;
|
|
36
|
-
copyHarmonyBundleError: string;
|
|
37
35
|
copyingDebugId: string;
|
|
38
36
|
createAppSuccess: string;
|
|
39
37
|
deleteFile: string;
|
|
40
|
-
deletingFile: string;
|
|
41
38
|
enterAppIdQuestion: string;
|
|
42
39
|
enterNativePackageId: string;
|
|
43
|
-
errorInHarmonyApp: string;
|
|
44
40
|
expiredStatus: string;
|
|
45
|
-
failedToParseIcon: string;
|
|
46
41
|
failedToParseUpdateJson: string;
|
|
47
42
|
fileGenerated: string;
|
|
48
43
|
fileSizeExceeded: string;
|
|
49
44
|
forceHermes: string;
|
|
50
45
|
hermesEnabledCompiling: string;
|
|
51
46
|
ipaUploadSuccess: string;
|
|
52
|
-
keyStrings: string;
|
|
53
47
|
latestVersionTag: string;
|
|
54
48
|
lockBestPractice: string;
|
|
55
49
|
lockNotFound: string;
|
|
@@ -86,15 +80,9 @@ declare const _default: {
|
|
|
86
80
|
packing: string;
|
|
87
81
|
pausedStatus: string;
|
|
88
82
|
platform: string;
|
|
89
|
-
platformPrompt: string;
|
|
90
83
|
platformQuestion: string;
|
|
91
|
-
platformRequired: string;
|
|
92
84
|
pluginDetectionError: string;
|
|
93
85
|
pluginDetected: string;
|
|
94
|
-
ppkPackageGenerated: string;
|
|
95
|
-
processingError: string;
|
|
96
|
-
processingPackage: string;
|
|
97
|
-
processingStringPool: string;
|
|
98
86
|
publishUsage: string;
|
|
99
87
|
sourceMapNotFound: string;
|
|
100
88
|
sourceMapMissingWarning: string;
|
|
@@ -114,7 +102,6 @@ declare const _default: {
|
|
|
114
102
|
sentryReleaseCreated: string;
|
|
115
103
|
totalApps: string;
|
|
116
104
|
totalPackages: string;
|
|
117
|
-
typeStrings: string;
|
|
118
105
|
unsupportedPlatform: string;
|
|
119
106
|
uploadBundlePrompt: string;
|
|
120
107
|
uploadingSourcemap: string;
|
|
@@ -124,7 +111,6 @@ declare const _default: {
|
|
|
124
111
|
usageExtractApk: string;
|
|
125
112
|
usageParseApp: string;
|
|
126
113
|
usageParseIpa: string;
|
|
127
|
-
usageUnderDevelopment: string;
|
|
128
114
|
usageUploadApk: string;
|
|
129
115
|
usageUploadAab: string;
|
|
130
116
|
usageUploadApp: string;
|
|
@@ -178,7 +164,14 @@ declare const _default: {
|
|
|
178
164
|
hermesBasePlainCompileFailed: string;
|
|
179
165
|
hermesBaseVerified: string;
|
|
180
166
|
hermesBaseVerifyFailed: string;
|
|
167
|
+
hermesBaseVerifyDumpFailed: string;
|
|
168
|
+
hermesBaseVerifyDumpsWritten: string;
|
|
181
169
|
cacheCleaned: string;
|
|
182
170
|
cacheStats: string;
|
|
171
|
+
loginCredentialsRequired: string;
|
|
172
|
+
bundleUnexpectedArgs: string;
|
|
173
|
+
unsafeIntermediateDir: string;
|
|
174
|
+
appKeyMissing: string;
|
|
175
|
+
errorStackHint: string;
|
|
183
176
|
};
|
|
184
177
|
export default _default;
|