react-native-update-cli 1.9.0 → 1.10.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/lib/bundle.js CHANGED
@@ -55,6 +55,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
55
55
 
56
56
  fs.emptyDirSync(outputFolder);
57
57
 
58
+ // TODO sourcemap
58
59
  Array.prototype.push.apply(reactNativeBundleArgs, [path.join('node_modules', 'react-native', 'local-cli', 'cli.js'), 'bundle', '--assets-dest', outputFolder, '--bundle-output', path.join(outputFolder, bundleName), '--dev', development, '--entry-file', entryFile, '--platform', platform, '--reset-cache']);
59
60
 
60
61
  if (sourcemapOutput) {
@@ -81,7 +82,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
81
82
  if (exitCode) {
82
83
  reject(new Error(`"react-native bundle" command exited with code ${exitCode}.`));
83
84
  } else {
84
- if (gradleConfig.enableHermes) {
85
+ if (platform === 'android' && gradleConfig.enableHermes || platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine')) {
85
86
  await compileHermesByteCode(bundleName, outputFolder);
86
87
  }
87
88
  resolve(null);
@@ -118,13 +119,19 @@ async function checkGradleConfig() {
118
119
 
119
120
  async function compileHermesByteCode(bundleName, outputFolder) {
120
121
  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
122
+ // >= rn 0.69
123
+ let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
124
+ // < rn 0.69
125
+ if (!fs.existsSync(hermesCommand)) {
126
+ const hermesPackage = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' // 0.2+
127
+ : 'node_modules/hermesvm'; // < 0.2
128
+ const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
129
+
130
+ hermesCommand = fs.existsSync(`${hermesPath}/hermesc`) ? `${hermesPath}/hermesc` // 0.5+
131
+ : `${hermesPath}/hermes`; // < 0.5
132
+ }
127
133
 
134
+ // TODO sourcemap
128
135
  spawnSync(path.join.apply(null, hermesCommand.split('/')), ['-emit-binary', '-out', path.join(outputFolder, bundleName), path.join(outputFolder, bundleName), '-O'], { stdio: 'ignore' });
129
136
  }
130
137
 
@@ -455,14 +462,7 @@ const commands = exports.commands = {
455
462
  bundle: async function ({ options }) {
456
463
  const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
457
464
 
458
- let {
459
- bundleName,
460
- entryFile,
461
- intermediaDir,
462
- output,
463
- dev,
464
- verbose
465
- } = (0, _utils.translateOptions)(_extends({}, options, {
465
+ let { bundleName, entryFile, intermediaDir, output, dev, verbose } = (0, _utils.translateOptions)(_extends({}, options, {
466
466
  platform
467
467
  }));
468
468
 
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.10.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
@@ -48,6 +48,7 @@ async function runReactNativeBundleCommand(
48
48
 
49
49
  fs.emptyDirSync(outputFolder);
50
50
 
51
+ // TODO sourcemap
51
52
  Array.prototype.push.apply(reactNativeBundleArgs, [
52
53
  path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
53
54
  'bundle',
@@ -94,7 +95,10 @@ async function runReactNativeBundleCommand(
94
95
  ),
95
96
  );
96
97
  } else {
97
- if (gradleConfig.enableHermes) {
98
+ if (
99
+ (platform === 'android' && gradleConfig.enableHermes) ||
100
+ (platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine'))
101
+ ) {
98
102
  await compileHermesByteCode(bundleName, outputFolder);
99
103
  }
100
104
  resolve(null);
@@ -134,15 +138,21 @@ async function checkGradleConfig() {
134
138
 
135
139
  async function compileHermesByteCode(bundleName, outputFolder) {
136
140
  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
141
+ // >= rn 0.69
142
+ let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
143
+ // < rn 0.69
144
+ if (!fs.existsSync(hermesCommand)) {
145
+ const hermesPackage = fs.existsSync('node_modules/hermes-engine')
146
+ ? 'node_modules/hermes-engine' // 0.2+
147
+ : 'node_modules/hermesvm'; // < 0.2
148
+ const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
149
+
150
+ hermesCommand = fs.existsSync(`${hermesPath}/hermesc`)
151
+ ? `${hermesPath}/hermesc` // 0.5+
152
+ : `${hermesPath}/hermes`; // < 0.5
153
+ }
145
154
 
155
+ // TODO sourcemap
146
156
  spawnSync(
147
157
  path.join.apply(null, hermesCommand.split('/')),
148
158
  [
@@ -514,17 +524,11 @@ export const commands = {
514
524
  options.platform || (await question('平台(ios/android):')),
515
525
  );
516
526
 
517
- let {
518
- bundleName,
519
- entryFile,
520
- intermediaDir,
521
- output,
522
- dev,
523
- verbose,
524
- } = translateOptions({
525
- ...options,
526
- platform,
527
- });
527
+ let { bundleName, entryFile, intermediaDir, output, dev, verbose } =
528
+ translateOptions({
529
+ ...options,
530
+ platform,
531
+ });
528
532
 
529
533
  // const sourcemapOutput = path.join(intermediaDir, bundleName + ".map");
530
534