react-native-update-cli 1.13.0 → 1.18.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
@@ -56,7 +56,17 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
56
56
 
57
57
  fs.emptyDirSync(outputFolder);
58
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
+ let cliPath = require.resolve('react-native/local-cli/cli.js', {
60
+ paths: [process.cwd()]
61
+ });
62
+ try {
63
+ cliPath = require.resolve('@expo/cli', {
64
+ paths: [process.cwd()]
65
+ });
66
+ } catch (e) {}
67
+ const bundleCommand = cliPath.includes('@expo/cli') ? 'export:embed' : 'bundle';
68
+
69
+ 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']);
60
70
 
61
71
  if (sourcemapOutput) {
62
72
  reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
@@ -139,7 +149,11 @@ async function checkGradleConfig() {
139
149
  async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput) {
140
150
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
141
151
  // >= rn 0.69
142
- let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
152
+ const rnDir = path.dirname(require.resolve('react-native', {
153
+ paths: [process.cwd()]
154
+ }));
155
+ const hermesCommand = path.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}/hermesc`);
156
+
143
157
  // < rn 0.69
144
158
  if (!fs.existsSync(hermesCommand)) {
145
159
  const hermesPackage = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' // 0.2+
@@ -153,7 +167,8 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput)
153
167
  if (sourcemapOutput) {
154
168
  args.push('-output-source-map');
155
169
  }
156
- spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
170
+ console.log('Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n');
171
+ spawnSync(hermesCommand, args, {
157
172
  stdio: 'ignore'
158
173
  });
159
174
  }
@@ -63,7 +63,9 @@ function translateOptions(options) {
63
63
  }
64
64
 
65
65
  function getRNVersion() {
66
- const version = JSON.parse(_fsExtra2.default.readFileSync(_path2.default.resolve('node_modules/react-native/package.json'))).version;
66
+ const version = JSON.parse(_fsExtra2.default.readFileSync(require.resolve('react-native/package.json', {
67
+ paths: [process.cwd()]
68
+ }))).version;
67
69
 
68
70
  // We only care about major and minor version.
69
71
  const match = /^(\d+)\.(\d+)\./.exec(version);
@@ -111,9 +113,7 @@ async function getIpaInfo(fn) {
111
113
  if (updateJsonFile) {
112
114
  appCredential = JSON.parse(updateJsonFile.toString()).ios;
113
115
  }
114
- const {
115
- CFBundleShortVersionString: versionName
116
- } = await appInfoParser.parse();
116
+ const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
117
117
  let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
118
118
  if (!buildTimeTxtBuffer) {
119
119
  // Not in root bundle when use `use_frameworks`
@@ -138,7 +138,9 @@ function saveToLocal(originPath, destName) {
138
138
  function printVersionCommand() {
139
139
  console.log('react-native-update-cli: ' + pkg.version);
140
140
  try {
141
- const PACKAGE_JSON_PATH = _path2.default.resolve(process.cwd(), 'node_modules', 'react-native-update', 'package.json');
141
+ const PACKAGE_JSON_PATH = require.resolve('react-native-update/package.json', {
142
+ paths: [process.cwd()]
143
+ });
142
144
  console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version);
143
145
  } catch (e) {
144
146
  console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.13.0",
3
+ "version": "1.18.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
@@ -49,9 +49,21 @@ async function runReactNativeBundleCommand(
49
49
 
50
50
  fs.emptyDirSync(outputFolder);
51
51
 
52
+ let cliPath = require.resolve('react-native/local-cli/cli.js', {
53
+ paths: [process.cwd()],
54
+ });
55
+ try {
56
+ cliPath = require.resolve('@expo/cli', {
57
+ paths: [process.cwd()],
58
+ });
59
+ } catch (e) {}
60
+ const bundleCommand = cliPath.includes('@expo/cli')
61
+ ? 'export:embed'
62
+ : 'bundle';
63
+
52
64
  Array.prototype.push.apply(reactNativeBundleArgs, [
53
- path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
54
- 'bundle',
65
+ cliPath,
66
+ bundleCommand,
55
67
  '--assets-dest',
56
68
  outputFolder,
57
69
  '--bundle-output',
@@ -171,7 +183,16 @@ async function compileHermesByteCode(
171
183
  ) {
172
184
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
173
185
  // >= rn 0.69
174
- let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
186
+ const rnDir = path.dirname(
187
+ require.resolve('react-native', {
188
+ paths: [process.cwd()],
189
+ }),
190
+ );
191
+ const hermesCommand = path.join(
192
+ rnDir,
193
+ `/sdks/hermesc/${getHermesOSBin()}/hermesc`,
194
+ );
195
+
175
196
  // < rn 0.69
176
197
  if (!fs.existsSync(hermesCommand)) {
177
198
  const hermesPackage = fs.existsSync('node_modules/hermes-engine')
@@ -193,7 +214,10 @@ async function compileHermesByteCode(
193
214
  if (sourcemapOutput) {
194
215
  args.push('-output-source-map');
195
216
  }
196
- spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
217
+ console.log(
218
+ 'Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n',
219
+ );
220
+ spawnSync(hermesCommand, args, {
197
221
  stdio: 'ignore',
198
222
  });
199
223
  }
@@ -43,7 +43,11 @@ export function translateOptions(options) {
43
43
 
44
44
  export function getRNVersion() {
45
45
  const version = JSON.parse(
46
- fs.readFileSync(path.resolve('node_modules/react-native/package.json')),
46
+ fs.readFileSync(
47
+ require.resolve('react-native/package.json', {
48
+ paths: [process.cwd()],
49
+ }),
50
+ ),
47
51
  ).version;
48
52
 
49
53
  // We only care about major and minor version.
@@ -106,9 +110,8 @@ export async function getIpaInfo(fn) {
106
110
  if (updateJsonFile) {
107
111
  appCredential = JSON.parse(updateJsonFile.toString()).ios;
108
112
  }
109
- const {
110
- CFBundleShortVersionString: versionName,
111
- } = await appInfoParser.parse();
113
+ const { CFBundleShortVersionString: versionName } =
114
+ await appInfoParser.parse();
112
115
  let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(
113
116
  /payload\/.+?\.app\/pushy_build_time.txt/,
114
117
  );
@@ -139,11 +142,11 @@ export function saveToLocal(originPath, destName) {
139
142
  export function printVersionCommand() {
140
143
  console.log('react-native-update-cli: ' + pkg.version);
141
144
  try {
142
- const PACKAGE_JSON_PATH = path.resolve(
143
- process.cwd(),
144
- 'node_modules',
145
- 'react-native-update',
146
- 'package.json',
145
+ const PACKAGE_JSON_PATH = require.resolve(
146
+ 'react-native-update/package.json',
147
+ {
148
+ paths: [process.cwd()],
149
+ },
147
150
  );
148
151
  console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version);
149
152
  } catch (e) {