react-native-update-cli 2.24.1 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/README.zh-CN.md +11 -4
- 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 +27 -0
- package/lib/bundle-runner.js +240 -21
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +19 -6
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +5 -14
- package/lib/locales/en.js +5 -14
- package/lib/locales/zh.d.ts +5 -13
- package/lib/locales/zh.js +5 -13
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +11 -3
- 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/hermes-base.js +2 -1
- 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/slim-sourcemap.d.ts +11 -0
- package/lib/utils/slim-sourcemap.js +22 -0
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +16 -15
- package/package.json +4 -2
- 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 -159
- 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 -83
- 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 -894
package/lib/bundle-runner.js
CHANGED
|
@@ -39,6 +39,9 @@ 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;
|
|
@@ -57,6 +60,7 @@ const fs = __importStar(require("fs-extra"));
|
|
|
57
60
|
const os_1 = __importDefault(require("os"));
|
|
58
61
|
const path_1 = __importDefault(require("path"));
|
|
59
62
|
const api_1 = require("./api");
|
|
63
|
+
const dep_versions_1 = require("./utils/dep-versions");
|
|
60
64
|
const hermes_base_1 = require("./utils/hermes-base");
|
|
61
65
|
const i18n_1 = require("./utils/i18n");
|
|
62
66
|
const runtime_1 = require("./utils/runtime");
|
|
@@ -129,7 +133,7 @@ function resolveExpoCli(projectRoot = process.cwd()) {
|
|
|
129
133
|
async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, hermesBase, resetCache = true, cli, isSentry, }) {
|
|
130
134
|
let gradleConfig = {};
|
|
131
135
|
if (platform === 'android') {
|
|
132
|
-
gradleConfig = await checkGradleConfig();
|
|
136
|
+
gradleConfig = await checkGradleConfig(process.cwd());
|
|
133
137
|
if (gradleConfig.crunchPngs !== false) {
|
|
134
138
|
console.warn((0, i18n_1.t)('androidCrunchPngsWarning'));
|
|
135
139
|
}
|
|
@@ -139,6 +143,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
139
143
|
if (envArgs) {
|
|
140
144
|
reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
|
|
141
145
|
}
|
|
146
|
+
outputFolder = assertSafeToEmpty(outputFolder);
|
|
142
147
|
fs.emptyDirSync(outputFolder);
|
|
143
148
|
let cliPath = '';
|
|
144
149
|
let usingExpo = false;
|
|
@@ -285,30 +290,241 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
285
290
|
});
|
|
286
291
|
return hermesResult;
|
|
287
292
|
}
|
|
288
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Validate the intermediate directory before it is emptied and return the
|
|
295
|
+
* canonical path that was validated. The caller must use this returned path:
|
|
296
|
+
* validating one spelling and deleting through another re-opens symlink
|
|
297
|
+
* redirection.
|
|
298
|
+
*/
|
|
299
|
+
function assertSafeToEmpty(dir, cwd = process.cwd()) {
|
|
300
|
+
const requested = path_1.default.resolve(cwd, dir);
|
|
301
|
+
const lexicalCwd = path_1.default.resolve(cwd);
|
|
302
|
+
const lexicalHome = path_1.default.resolve(os_1.default.homedir());
|
|
303
|
+
const lexicalTmp = path_1.default.resolve(os_1.default.tmpdir());
|
|
304
|
+
const contains = (parent, child) => {
|
|
305
|
+
const relative = path_1.default.relative(parent, child);
|
|
306
|
+
return (relative === '' ||
|
|
307
|
+
(!relative.startsWith('..') && !path_1.default.isAbsolute(relative)));
|
|
308
|
+
};
|
|
309
|
+
const samePath = (left, right) => {
|
|
310
|
+
const normalize = (value) => {
|
|
311
|
+
const resolved = path_1.default.resolve(value);
|
|
312
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
313
|
+
};
|
|
314
|
+
return normalize(left) === normalize(right);
|
|
315
|
+
};
|
|
316
|
+
const reject = (target) => {
|
|
317
|
+
throw new Error((0, i18n_1.t)('unsafeIntermediateDir', { dir: target }));
|
|
318
|
+
};
|
|
319
|
+
const validate = (target, projectRoot, home, tmpRoot) => {
|
|
320
|
+
// Reject each protected directory and all of its ancestors.
|
|
321
|
+
for (const protectedPath of [
|
|
322
|
+
path_1.default.parse(target).root,
|
|
323
|
+
projectRoot,
|
|
324
|
+
home,
|
|
325
|
+
tmpRoot,
|
|
326
|
+
]) {
|
|
327
|
+
if (contains(target, protectedPath))
|
|
328
|
+
reject(target);
|
|
329
|
+
}
|
|
330
|
+
// Never allow build cleanup inside source-control metadata.
|
|
331
|
+
for (const metadata of ['.git', '.hg', '.svn']) {
|
|
332
|
+
if (contains(path_1.default.join(projectRoot, metadata), target))
|
|
333
|
+
reject(target);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
validate(requested, lexicalCwd, lexicalHome, lexicalTmp);
|
|
337
|
+
// A final-component symlink is the direct dangerous case: emptyDirSync would
|
|
338
|
+
// enumerate and remove entries from its target rather than removing the link.
|
|
339
|
+
if (fs.existsSync(requested) && fs.lstatSync(requested).isSymbolicLink()) {
|
|
340
|
+
reject(requested);
|
|
341
|
+
}
|
|
342
|
+
// emptyDirSync creates a missing directory too; create it first so it can be
|
|
343
|
+
// canonicalized and the exact validated path can be passed to deletion.
|
|
344
|
+
fs.ensureDirSync(requested);
|
|
345
|
+
const canonical = (value) => fs.realpathSync.native(value);
|
|
346
|
+
const target = canonical(requested);
|
|
347
|
+
const canonicalCwd = canonical(lexicalCwd);
|
|
348
|
+
const canonicalHome = canonical(lexicalHome);
|
|
349
|
+
const canonicalTmp = canonical(lexicalTmp);
|
|
350
|
+
validate(target, canonicalCwd, canonicalHome, canonicalTmp);
|
|
351
|
+
// Reject a symlink in any component below a known safe base. System aliases
|
|
352
|
+
// such as macOS /var -> /private/var remain valid because the base itself is
|
|
353
|
+
// canonicalized before the relative suffix is appended.
|
|
354
|
+
for (const [lexicalBase, canonicalBase] of [
|
|
355
|
+
[lexicalCwd, canonicalCwd],
|
|
356
|
+
[lexicalHome, canonicalHome],
|
|
357
|
+
[lexicalTmp, canonicalTmp],
|
|
358
|
+
]) {
|
|
359
|
+
const relative = path_1.default.relative(lexicalBase, requested);
|
|
360
|
+
if (relative === '' ||
|
|
361
|
+
(!relative.startsWith('..') && !path_1.default.isAbsolute(relative))) {
|
|
362
|
+
if (!samePath(path_1.default.resolve(canonicalBase, relative), target)) {
|
|
363
|
+
reject(target);
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return target;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Whether the app runs Hermes, i.e. whether the bundle must be compiled to
|
|
372
|
+
* bytecode. A JS bundle shipped to a Hermes app still runs, but starts slower
|
|
373
|
+
* and cannot use the Hermes base delta, so false negatives are what this
|
|
374
|
+
* guards against.
|
|
375
|
+
*
|
|
376
|
+
* Android: `hermesEnabled` in gradle.properties wins; then the legacy
|
|
377
|
+
* `project.ext.react.enableHermes` of build.gradle; with neither, the React
|
|
378
|
+
* Native gradle plugin (0.71+) defaults to Hermes and older versions to JSC.
|
|
379
|
+
* iOS: an installed `Pods/hermes-engine`; when `pod install` has not run on
|
|
380
|
+
* this machine (CI), Expo's `Podfile.properties.json` or the pod listed in
|
|
381
|
+
* `Podfile.lock` tell the same.
|
|
382
|
+
*/
|
|
383
|
+
async function detectHermesEnabled(platform, forceHermes, gradleConfig, projectRoot = process.cwd()) {
|
|
289
384
|
if (forceHermes) {
|
|
290
385
|
console.log((0, i18n_1.t)('forceHermes'));
|
|
291
386
|
return true;
|
|
292
387
|
}
|
|
293
388
|
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
|
-
});
|
|
389
|
+
const gradleProperties = await readGradleProperties(path_1.default.join(projectRoot, 'android', 'gradle.properties'));
|
|
304
390
|
if (typeof gradleProperties.hermesEnabled === 'boolean') {
|
|
305
391
|
return gradleProperties.hermesEnabled;
|
|
306
392
|
}
|
|
307
|
-
|
|
393
|
+
if (typeof gradleConfig.enableHermes === 'boolean') {
|
|
394
|
+
return gradleConfig.enableHermes;
|
|
395
|
+
}
|
|
396
|
+
return reactNativeDefaultsToHermes(projectRoot);
|
|
397
|
+
}
|
|
398
|
+
if (platform === 'ios') {
|
|
399
|
+
return detectIosHermes(projectRoot);
|
|
400
|
+
}
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
/** parsed gradle.properties; a missing file is simply empty */
|
|
404
|
+
function readGradleProperties(file) {
|
|
405
|
+
return new Promise((resolve) => {
|
|
406
|
+
properties.parse(file, { path: true }, (error, props = {}) => {
|
|
407
|
+
if (error) {
|
|
408
|
+
if (error.code !== 'ENOENT') {
|
|
409
|
+
console.warn(`${file}: ${error.message ?? error}`);
|
|
410
|
+
}
|
|
411
|
+
resolve({});
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
resolve(props);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/** React Native's gradle plugin (0.71+) enables Hermes unless a property says otherwise */
|
|
419
|
+
function reactNativeDefaultsToHermes(projectRoot) {
|
|
420
|
+
const version = (0, dep_versions_1.getDepVersion)('react-native', projectRoot);
|
|
421
|
+
// major.minor by hand: React Native is 0.x, and the check must not depend
|
|
422
|
+
// on a semver library (tests replace compare-versions wholesale)
|
|
423
|
+
const match = version ? /^(\d+)\.(\d+)\./.exec(version) : null;
|
|
424
|
+
if (!match) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
428
|
+
return major > 0 || minor >= 71;
|
|
429
|
+
}
|
|
430
|
+
/** Remove Ruby comments without treating a # inside a quoted string as one. */
|
|
431
|
+
function stripRubyComments(source) {
|
|
432
|
+
return source
|
|
433
|
+
.split(/\r?\n/)
|
|
434
|
+
.map((line) => {
|
|
435
|
+
let quote;
|
|
436
|
+
let escaped = false;
|
|
437
|
+
for (let index = 0; index < line.length; index++) {
|
|
438
|
+
const char = line[index];
|
|
439
|
+
if (escaped) {
|
|
440
|
+
escaped = false;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (quote) {
|
|
444
|
+
if (char === '\\') {
|
|
445
|
+
escaped = true;
|
|
446
|
+
}
|
|
447
|
+
else if (char === quote) {
|
|
448
|
+
quote = undefined;
|
|
449
|
+
}
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (char === "'" || char === '"') {
|
|
453
|
+
quote = char;
|
|
454
|
+
}
|
|
455
|
+
else if (char === '#') {
|
|
456
|
+
return line.slice(0, index);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return line;
|
|
460
|
+
})
|
|
461
|
+
.join('\n');
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Read explicit iOS engine configuration. An explicit JSC/disabled-Hermes
|
|
465
|
+
* setting wins over installed pods because CocoaPods may still fetch the
|
|
466
|
+
* hermes-engine dependency for a JSC build.
|
|
467
|
+
*/
|
|
468
|
+
function configuredIosEngine(ios) {
|
|
469
|
+
let expoEngine;
|
|
470
|
+
try {
|
|
471
|
+
const value = JSON.parse(fs.readFileSync(path_1.default.join(ios, 'Podfile.properties.json'), 'utf8'))?.['expo.jsEngine'];
|
|
472
|
+
if (value === 'hermes' || value === 'jsc')
|
|
473
|
+
expoEngine = value;
|
|
474
|
+
}
|
|
475
|
+
catch {
|
|
476
|
+
// no Expo properties file
|
|
477
|
+
}
|
|
478
|
+
let podfile = '';
|
|
479
|
+
try {
|
|
480
|
+
podfile = fs.readFileSync(path_1.default.join(ios, 'Podfile'), 'utf8');
|
|
308
481
|
}
|
|
309
|
-
|
|
482
|
+
catch {
|
|
483
|
+
// no Podfile
|
|
484
|
+
}
|
|
485
|
+
const activePodfile = stripRubyComments(podfile);
|
|
486
|
+
const envValue = (name) => new RegExp(`ENV\\s*\\[\\s*['"]${name}['"]\\s*\\]\\s*(?:\\|\\|=|=)\\s*['"]([^'"]+)['"]`, 'i')
|
|
487
|
+
.exec(activePodfile)?.[1]
|
|
488
|
+
?.toLowerCase();
|
|
489
|
+
const useHermes = envValue('USE_HERMES');
|
|
490
|
+
const useThirdPartyJsc = envValue('USE_THIRD_PARTY_JSC');
|
|
491
|
+
const hermesOption = /(?:^|[,(]\s*)(?::hermes_enabled\s*=>|hermes_enabled\s*:)\s*(true|false)\b/im
|
|
492
|
+
.exec(activePodfile)?.[1]
|
|
493
|
+
?.toLowerCase();
|
|
494
|
+
if (useThirdPartyJsc === '1' ||
|
|
495
|
+
useThirdPartyJsc === 'true' ||
|
|
496
|
+
useHermes === '0' ||
|
|
497
|
+
useHermes === 'false' ||
|
|
498
|
+
hermesOption === 'false' ||
|
|
499
|
+
expoEngine === 'jsc') {
|
|
500
|
+
return 'jsc';
|
|
501
|
+
}
|
|
502
|
+
if (useHermes === '1' ||
|
|
503
|
+
useHermes === 'true' ||
|
|
504
|
+
hermesOption === 'true' ||
|
|
505
|
+
expoEngine === 'hermes') {
|
|
506
|
+
return 'hermes';
|
|
507
|
+
}
|
|
508
|
+
return undefined;
|
|
509
|
+
}
|
|
510
|
+
/** Hermes on iOS: explicit configuration first, installed artifacts second. */
|
|
511
|
+
function detectIosHermes(projectRoot) {
|
|
512
|
+
const ios = path_1.default.join(projectRoot, 'ios');
|
|
513
|
+
const configured = configuredIosEngine(ios);
|
|
514
|
+
if (configured)
|
|
515
|
+
return configured === 'hermes';
|
|
516
|
+
if (fs.existsSync(path_1.default.join(ios, 'Pods', 'hermes-engine'))) {
|
|
310
517
|
return true;
|
|
311
518
|
}
|
|
519
|
+
// CI may not have run pod install, so use the lockfile only as weak evidence.
|
|
520
|
+
try {
|
|
521
|
+
const lock = fs.readFileSync(path_1.default.join(ios, 'Podfile.lock'), 'utf8');
|
|
522
|
+
if (/^\s*-\s+hermes-engine\b/m.test(lock))
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
catch {
|
|
526
|
+
// no lockfile either
|
|
527
|
+
}
|
|
312
528
|
return false;
|
|
313
529
|
}
|
|
314
530
|
function getHermesOSBin() {
|
|
@@ -376,18 +592,19 @@ function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
|
376
592
|
}
|
|
377
593
|
throw new Error(`Cannot find hermesc. Tried:\n${candidates.map((candidate) => `- ${candidate}`).join('\n')}`);
|
|
378
594
|
}
|
|
379
|
-
async function checkGradleConfig() {
|
|
380
|
-
|
|
595
|
+
async function checkGradleConfig(projectRoot) {
|
|
596
|
+
// undefined when build.gradle does not mention Hermes at all (React Native
|
|
597
|
+
// 0.71+ moved the switch to gradle.properties; see detectHermesEnabled)
|
|
598
|
+
let enableHermes;
|
|
381
599
|
let crunchPngs;
|
|
382
600
|
try {
|
|
383
|
-
const gradleConfig = await g2js.parseFile('android
|
|
601
|
+
const gradleConfig = await g2js.parseFile(path_1.default.join(projectRoot, 'android', 'app', 'build.gradle'));
|
|
384
602
|
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
|
385
603
|
const projectConfig = gradleConfig['project.ext.react'];
|
|
386
604
|
if (projectConfig) {
|
|
387
605
|
for (const packagerConfig of projectConfig) {
|
|
388
|
-
if (packagerConfig.includes('enableHermes')
|
|
389
|
-
packagerConfig.includes('true')
|
|
390
|
-
enableHermes = true;
|
|
606
|
+
if (packagerConfig.includes('enableHermes')) {
|
|
607
|
+
enableHermes = packagerConfig.includes('true');
|
|
391
608
|
break;
|
|
392
609
|
}
|
|
393
610
|
}
|
|
@@ -560,7 +777,7 @@ async function composeSourceMaps(packagerMap, hermesMap, sourcemapOutput) {
|
|
|
560
777
|
assertSuccessfulSyncProcess(await runProcess((0, runtime_1.getJavaScriptRuntime)(), [composerPath, packagerMap, hermesMap, '-o', sourcemapOutput], false), composerPath);
|
|
561
778
|
return true;
|
|
562
779
|
}
|
|
563
|
-
async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap, baseRequest, pendingBase, hermesCommand
|
|
780
|
+
async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap, baseRequest, pendingBase, hermesCommand, }) {
|
|
564
781
|
console.log((0, i18n_1.t)('hermesEnabledCompiling'));
|
|
565
782
|
const bundlePath = path_1.default.join(outputFolder, bundleName);
|
|
566
783
|
const hermesMap = `${bundlePath}.map`;
|
|
@@ -578,6 +795,8 @@ async function compileHermesByteCode({ bundleName, outputFolder, sourcemapOutput
|
|
|
578
795
|
else {
|
|
579
796
|
console.log((0, i18n_1.t)('hermesSourcemapKept', { file: hermesMap }));
|
|
580
797
|
}
|
|
798
|
+
// the selection already resolved hermesc while Metro ran; only look it up
|
|
799
|
+
// again when there was no selection (or it could not find the binary)
|
|
581
800
|
let selection = pendingBase ? await awaitPendingBase(pendingBase) : null;
|
|
582
801
|
const command = hermesCommand ?? selection?.hermesCommand ?? resolveHermesCommand();
|
|
583
802
|
if (!selection || selection.commandUnavailable) {
|
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,
|
|
@@ -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;
|
|
@@ -180,5 +166,10 @@ declare const _default: {
|
|
|
180
166
|
hermesBaseVerifyFailed: string;
|
|
181
167
|
cacheCleaned: string;
|
|
182
168
|
cacheStats: string;
|
|
169
|
+
loginCredentialsRequired: string;
|
|
170
|
+
bundleUnexpectedArgs: string;
|
|
171
|
+
unsafeIntermediateDir: string;
|
|
172
|
+
appKeyMissing: string;
|
|
173
|
+
errorStackHint: string;
|
|
183
174
|
};
|
|
184
175
|
export default _default;
|
package/lib/locales/en.js
CHANGED
|
@@ -34,24 +34,18 @@ exports.default = {
|
|
|
34
34
|
bundlingWithRN: 'Bundling with react-native: {{version}}',
|
|
35
35
|
cancelled: 'Cancelled',
|
|
36
36
|
composingSourceMap: 'Composing source map',
|
|
37
|
-
copyFileFailed: 'Failed to copy file: {{error}}',
|
|
38
|
-
copyHarmonyBundleError: 'Error copying Harmony bundle: {{error}}',
|
|
39
37
|
copyingDebugId: 'Copying debugid',
|
|
40
38
|
createAppSuccess: 'App created successfully (id: {{id}})',
|
|
41
39
|
deleteFile: 'Delete {{- file}}',
|
|
42
|
-
deletingFile: 'Delete {{- file}}',
|
|
43
40
|
enterAppIdQuestion: 'Enter AppId:',
|
|
44
41
|
enterNativePackageId: 'Enter native package ID:',
|
|
45
|
-
errorInHarmonyApp: 'Error in getEntryFromHarmonyApp: {{error}}',
|
|
46
42
|
expiredStatus: '(Expired)',
|
|
47
|
-
failedToParseIcon: '[Warning] failed to parse icon: {{error}}',
|
|
48
43
|
failedToParseUpdateJson: 'Failed to parse file `{{- configPath}}`. Try to remove it manually.',
|
|
49
44
|
fileGenerated: '{{- file}} generated.',
|
|
50
45
|
fileSizeExceeded: 'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
|
|
51
46
|
forceHermes: 'Forcing Hermes enabled for this build',
|
|
52
47
|
hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
|
|
53
48
|
ipaUploadSuccess: 'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
|
|
54
|
-
keyStrings: 'Key strings:',
|
|
55
49
|
latestVersionTag: '(latest: {{version}})',
|
|
56
50
|
lockBestPractice: `
|
|
57
51
|
Best practices for lock files:
|
|
@@ -94,15 +88,9 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
94
88
|
packing: 'Packing',
|
|
95
89
|
pausedStatus: '(Paused)',
|
|
96
90
|
platform: 'Platform',
|
|
97
|
-
platformPrompt: 'Platform (ios/android/harmony):',
|
|
98
91
|
platformQuestion: 'Platform(ios/android/harmony):',
|
|
99
|
-
platformRequired: 'Platform must be specified.',
|
|
100
92
|
pluginDetectionError: 'error while detecting {{name}} plugin: {{error}}',
|
|
101
93
|
pluginDetected: 'detected {{name}} plugin',
|
|
102
|
-
ppkPackageGenerated: 'ppk package generated and saved to: {{- output}}',
|
|
103
|
-
processingError: 'Error processing file: {{error}}',
|
|
104
|
-
processingPackage: 'Processing the package {{count}} ...',
|
|
105
|
-
processingStringPool: 'Processing the string pool ...',
|
|
106
94
|
publishUsage: 'Usage: pushy publish <ppk file> --platform ios|android|harmony',
|
|
107
95
|
sourceMapNotFound: 'Source map not found: {{path}}',
|
|
108
96
|
sourceMapMissingWarning: 'No source map was archived with this version: crashes cannot be symbolicated later. Bundle with the default --sourcemap, or pass --sourcemap <file> to publish.',
|
|
@@ -122,7 +110,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
122
110
|
sentryReleaseCreated: 'Sentry release created for version: {{version}}',
|
|
123
111
|
totalApps: 'Total {{count}} {{platform}} apps',
|
|
124
112
|
totalPackages: 'Total {{count}} packages',
|
|
125
|
-
typeStrings: 'Type strings:',
|
|
126
113
|
unsupportedPlatform: 'Unsupported platform `{{platform}}`',
|
|
127
114
|
uploadBundlePrompt: 'Upload this bundle now?(Y/N)',
|
|
128
115
|
uploadingSourcemap: 'Uploading sourcemap',
|
|
@@ -132,7 +119,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
132
119
|
usageExtractApk: 'Usage: cresc extractApk <aab file> [--output <apk file>] [--includeAllSplits] [--splits <split names>]',
|
|
133
120
|
usageParseApp: 'Usage: cresc parseApp <app file>',
|
|
134
121
|
usageParseIpa: 'Usage: cresc parseIpa <ipa file>',
|
|
135
|
-
usageUnderDevelopment: 'Usage is under development now.',
|
|
136
122
|
usageUploadApk: 'Usage: cresc uploadApk <apk file>',
|
|
137
123
|
usageUploadAab: 'Usage: cresc uploadAab <aab file> [--includeAllSplits] [--splits <split names>]',
|
|
138
124
|
usageUploadApp: 'Usage: cresc uploadApp <app file>',
|
|
@@ -188,4 +174,9 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
188
174
|
hermesBaseVerifyFailed: 'Hermes base: bytecode differs from a plain compile; dropping the base and recompiling',
|
|
189
175
|
cacheCleaned: 'Removed {{count}} cached bundle(s)',
|
|
190
176
|
cacheStats: 'Bundle cache: {{- dir}} — {{files}} file(s), {{mb}} MB',
|
|
177
|
+
loginCredentialsRequired: 'Email and password are required. Usage: {{scriptName}} login <email> <password>',
|
|
178
|
+
bundleUnexpectedArgs: 'bundle takes no positional arguments, got: {{- args}}. Boolean flags take no value; switch one off with --no-<flag> (e.g. --no-sourcemap).',
|
|
179
|
+
unsafeIntermediateDir: 'Refusing to empty {{- dir}} as the intermediate directory: it resolves to a protected or symbolic-link location. Point --intermediaDir at a dedicated build directory.',
|
|
180
|
+
appKeyMissing: 'App {{appId}} did not return a valid app key.',
|
|
181
|
+
errorStackHint: '(set RNU_DEBUG=1 to print the stack trace)',
|
|
191
182
|
};
|
package/lib/locales/zh.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
|
sourceMapNotFound: string;
|
|
99
87
|
sourceMapMissingWarning: string;
|
|
100
88
|
sourceMapArchived: 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;
|
|
@@ -179,5 +166,10 @@ declare const _default: {
|
|
|
179
166
|
hermesBaseVerifyFailed: string;
|
|
180
167
|
cacheCleaned: string;
|
|
181
168
|
cacheStats: string;
|
|
169
|
+
loginCredentialsRequired: string;
|
|
170
|
+
bundleUnexpectedArgs: string;
|
|
171
|
+
unsafeIntermediateDir: string;
|
|
172
|
+
appKeyMissing: string;
|
|
173
|
+
errorStackHint: string;
|
|
182
174
|
};
|
|
183
175
|
export default _default;
|