react-native-update-cli 1.17.0 → 1.19.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
@@ -41,9 +41,9 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
41
41
  let gradleConfig = {};
42
42
  if (platform === 'android') {
43
43
  gradleConfig = await checkGradleConfig();
44
- // if (gradleConfig.crunchPngs !== false) {
45
- // throw new Error('请先禁用android的crunchPngs优化,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8android%E7%9A%84crunch%E4%BC%98%E5%8C%96')
46
- // }
44
+ if (gradleConfig.crunchPngs !== false) {
45
+ console.warn('android的crunchPngs选项似乎尚未禁用(如已禁用则请忽略此提示),这可能导致热更包体积异常增大,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n');
46
+ }
47
47
  }
48
48
 
49
49
  let reactNativeBundleArgs = [];
@@ -56,10 +56,23 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
56
56
 
57
57
  fs.emptyDirSync(outputFolder);
58
58
 
59
- Array.prototype.push.apply(reactNativeBundleArgs, [require.resolve('react-native/local-cli/cli.js', {
59
+ let cliPath = require.resolve('react-native/local-cli/cli.js', {
60
60
  paths: [process.cwd()]
61
- }), // 'react-native' package may be symlinked
62
- 'bundle', '--assets-dest', outputFolder, '--bundle-output', path.join(outputFolder, bundleName), '--dev', development, '--entry-file', entryFile, '--platform', platform, '--reset-cache']);
61
+ });
62
+ try {
63
+ require.resolve('expo-router', {
64
+ paths: [process.cwd()]
65
+ });
66
+
67
+ console.log(`expo-router detected, will use @expo/cli to bundle.\n`);
68
+ // if using expo-router, use expo-cli
69
+ cliPath = require.resolve('@expo/cli', {
70
+ paths: [process.cwd()]
71
+ });
72
+ } catch (e) {}
73
+ const bundleCommand = cliPath.includes('@expo/cli') ? 'export:embed' : 'bundle';
74
+
75
+ Array.prototype.push.apply(reactNativeBundleArgs, [cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', path.join(outputFolder, bundleName), '--dev', development, '--entry-file', entryFile, '--platform', platform, '--reset-cache']);
63
76
 
64
77
  if (sourcemapOutput) {
65
78
  reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
@@ -160,7 +173,8 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput)
160
173
  if (sourcemapOutput) {
161
174
  args.push('-output-source-map');
162
175
  }
163
- spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
176
+ console.log('Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n');
177
+ spawnSync(hermesCommand, args, {
164
178
  stdio: 'ignore'
165
179
  });
166
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/bundle.js CHANGED
@@ -31,9 +31,11 @@ async function runReactNativeBundleCommand(
31
31
  let gradleConfig = {};
32
32
  if (platform === 'android') {
33
33
  gradleConfig = await checkGradleConfig();
34
- // if (gradleConfig.crunchPngs !== false) {
35
- // throw new Error('请先禁用android的crunchPngs优化,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8android%E7%9A%84crunch%E4%BC%98%E5%8C%96')
36
- // }
34
+ if (gradleConfig.crunchPngs !== false) {
35
+ console.warn(
36
+ 'android的crunchPngs选项似乎尚未禁用(如已禁用则请忽略此提示),这可能导致热更包体积异常增大,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n',
37
+ );
38
+ }
37
39
  }
38
40
 
39
41
  let reactNativeBundleArgs = [];
@@ -49,11 +51,27 @@ async function runReactNativeBundleCommand(
49
51
 
50
52
  fs.emptyDirSync(outputFolder);
51
53
 
52
- Array.prototype.push.apply(reactNativeBundleArgs, [
53
- require.resolve('react-native/local-cli/cli.js', {
54
+ let cliPath = require.resolve('react-native/local-cli/cli.js', {
55
+ paths: [process.cwd()],
56
+ });
57
+ try {
58
+ require.resolve('expo-router', {
59
+ paths: [process.cwd()],
60
+ });
61
+
62
+ console.log(`expo-router detected, will use @expo/cli to bundle.\n`);
63
+ // if using expo-router, use expo-cli
64
+ cliPath = require.resolve('@expo/cli', {
54
65
  paths: [process.cwd()],
55
- }), // 'react-native' package may be symlinked
56
- 'bundle',
66
+ });
67
+ } catch (e) {}
68
+ const bundleCommand = cliPath.includes('@expo/cli')
69
+ ? 'export:embed'
70
+ : 'bundle';
71
+
72
+ Array.prototype.push.apply(reactNativeBundleArgs, [
73
+ cliPath,
74
+ bundleCommand,
57
75
  '--assets-dest',
58
76
  outputFolder,
59
77
  '--bundle-output',
@@ -204,7 +222,10 @@ async function compileHermesByteCode(
204
222
  if (sourcemapOutput) {
205
223
  args.push('-output-source-map');
206
224
  }
207
- spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
225
+ console.log(
226
+ 'Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n',
227
+ );
228
+ spawnSync(hermesCommand, args, {
208
229
  stdio: 'ignore',
209
230
  });
210
231
  }