react-native-update-cli 1.9.0 → 1.11.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/cli.json CHANGED
@@ -140,7 +140,9 @@
140
140
  "default": ".pushy/output/${platform}.${time}.ppk",
141
141
  "hasValue": true
142
142
  },
143
- "verbose": {}
143
+ "sourcemap": {
144
+ "default": false
145
+ }
144
146
  }
145
147
  },
146
148
  "release": {
package/lib/bundle.js CHANGED
@@ -81,8 +81,8 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
81
81
  if (exitCode) {
82
82
  reject(new Error(`"react-native bundle" command exited with code ${exitCode}.`));
83
83
  } else {
84
- if (gradleConfig.enableHermes) {
85
- await compileHermesByteCode(bundleName, outputFolder);
84
+ if (platform === 'android' && gradleConfig.enableHermes || platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine')) {
85
+ await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput);
86
86
  }
87
87
  resolve(null);
88
88
  }
@@ -116,16 +116,26 @@ async function checkGradleConfig() {
116
116
  };
117
117
  }
118
118
 
119
- async function compileHermesByteCode(bundleName, outputFolder) {
119
+ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput) {
120
120
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
121
- const hermesPackage = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' // 0.2+
122
- : 'node_modules/hermesvm'; // < 0.2
123
- const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
124
-
125
- const hermesCommand = fs.existsSync(`${hermesPath}/hermesc`) ? `${hermesPath}/hermesc` // 0.5+
126
- : `${hermesPath}/hermes`; // < 0.5
127
-
128
- spawnSync(path.join.apply(null, hermesCommand.split('/')), ['-emit-binary', '-out', path.join(outputFolder, bundleName), path.join(outputFolder, bundleName), '-O'], { stdio: 'ignore' });
121
+ // >= rn 0.69
122
+ let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
123
+ // < rn 0.69
124
+ if (!fs.existsSync(hermesCommand)) {
125
+ const hermesPackage = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' // 0.2+
126
+ : 'node_modules/hermesvm'; // < 0.2
127
+ const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
128
+
129
+ hermesCommand = fs.existsSync(`${hermesPath}/hermesc`) ? `${hermesPath}/hermesc` // 0.5+
130
+ : `${hermesPath}/hermes`; // < 0.5
131
+ }
132
+ const args = ['-emit-binary', '-out', path.join(outputFolder, bundleName), path.join(outputFolder, bundleName), '-O'];
133
+ if (sourcemapOutput) {
134
+ args.push('-output-source-map');
135
+ }
136
+ spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
137
+ stdio: 'ignore'
138
+ });
129
139
  }
130
140
 
131
141
  async function pack(dir, output) {
@@ -455,18 +465,11 @@ const commands = exports.commands = {
455
465
  bundle: async function ({ options }) {
456
466
  const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
457
467
 
458
- let {
459
- bundleName,
460
- entryFile,
461
- intermediaDir,
462
- output,
463
- dev,
464
- verbose
465
- } = (0, _utils.translateOptions)(_extends({}, options, {
468
+ let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = (0, _utils.translateOptions)(_extends({}, options, {
466
469
  platform
467
470
  }));
468
471
 
469
- // const sourcemapOutput = path.join(intermediaDir, bundleName + ".map");
472
+ const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
470
473
 
471
474
  const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
472
475
 
@@ -479,7 +482,7 @@ const commands = exports.commands = {
479
482
  console.log('Bundling with react-native: ', version);
480
483
  (0, _utils.printVersionCommand)();
481
484
 
482
- await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform);
485
+ await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform, sourcemap ? sourcemapOutput : '');
483
486
 
484
487
  await pack(path.resolve(intermediaDir), realOutput);
485
488
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  "cli-arguments": "^0.2.1",
37
37
  "filesize-parser": "^1.5.0",
38
38
  "fs-extra": "8",
39
- "gradle-to-js": "^2.0.0",
39
+ "gradle-to-js": "^2.0.1",
40
40
  "node-fetch": "^2.6.1",
41
41
  "progress": "^2.0.3",
42
42
  "read": "^1.0.7",
package/src/bundle.js CHANGED
@@ -94,8 +94,15 @@ async function runReactNativeBundleCommand(
94
94
  ),
95
95
  );
96
96
  } else {
97
- if (gradleConfig.enableHermes) {
98
- await compileHermesByteCode(bundleName, outputFolder);
97
+ if (
98
+ (platform === 'android' && gradleConfig.enableHermes) ||
99
+ (platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine'))
100
+ ) {
101
+ await compileHermesByteCode(
102
+ bundleName,
103
+ outputFolder,
104
+ sourcemapOutput,
105
+ );
99
106
  }
100
107
  resolve(null);
101
108
  }
@@ -132,28 +139,38 @@ async function checkGradleConfig() {
132
139
  };
133
140
  }
134
141
 
135
- async function compileHermesByteCode(bundleName, outputFolder) {
142
+ async function compileHermesByteCode(
143
+ bundleName,
144
+ outputFolder,
145
+ sourcemapOutput,
146
+ ) {
136
147
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
137
- const hermesPackage = fs.existsSync('node_modules/hermes-engine')
138
- ? 'node_modules/hermes-engine' // 0.2+
139
- : 'node_modules/hermesvm'; // < 0.2
140
- const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
141
-
142
- const hermesCommand = fs.existsSync(`${hermesPath}/hermesc`)
143
- ? `${hermesPath}/hermesc` // 0.5+
144
- : `${hermesPath}/hermes`; // < 0.5
145
-
146
- spawnSync(
147
- path.join.apply(null, hermesCommand.split('/')),
148
- [
149
- '-emit-binary',
150
- '-out',
151
- path.join(outputFolder, bundleName),
152
- path.join(outputFolder, bundleName),
153
- '-O',
154
- ],
155
- { stdio: 'ignore' },
156
- );
148
+ // >= rn 0.69
149
+ let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
150
+ // < rn 0.69
151
+ if (!fs.existsSync(hermesCommand)) {
152
+ const hermesPackage = fs.existsSync('node_modules/hermes-engine')
153
+ ? 'node_modules/hermes-engine' // 0.2+
154
+ : 'node_modules/hermesvm'; // < 0.2
155
+ const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
156
+
157
+ hermesCommand = fs.existsSync(`${hermesPath}/hermesc`)
158
+ ? `${hermesPath}/hermesc` // 0.5+
159
+ : `${hermesPath}/hermes`; // < 0.5
160
+ }
161
+ const args = [
162
+ '-emit-binary',
163
+ '-out',
164
+ path.join(outputFolder, bundleName),
165
+ path.join(outputFolder, bundleName),
166
+ '-O',
167
+ ];
168
+ if (sourcemapOutput) {
169
+ args.push('-output-source-map');
170
+ }
171
+ spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
172
+ stdio: 'ignore',
173
+ });
157
174
  }
158
175
 
159
176
  async function pack(dir, output) {
@@ -514,19 +531,13 @@ export const commands = {
514
531
  options.platform || (await question('平台(ios/android):')),
515
532
  );
516
533
 
517
- let {
518
- bundleName,
519
- entryFile,
520
- intermediaDir,
521
- output,
522
- dev,
523
- verbose,
524
- } = translateOptions({
525
- ...options,
526
- platform,
527
- });
534
+ let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
535
+ translateOptions({
536
+ ...options,
537
+ platform,
538
+ });
528
539
 
529
- // const sourcemapOutput = path.join(intermediaDir, bundleName + ".map");
540
+ const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
530
541
 
531
542
  const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
532
543
 
@@ -545,6 +556,7 @@ export const commands = {
545
556
  entryFile,
546
557
  intermediaDir,
547
558
  platform,
559
+ sourcemap ? sourcemapOutput : '',
548
560
  );
549
561
 
550
562
  await pack(path.resolve(intermediaDir), realOutput);