react-native-update-cli 1.12.0 → 1.17.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,10 @@ 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
+ Array.prototype.push.apply(reactNativeBundleArgs, [require.resolve('react-native/local-cli/cli.js', {
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']);
60
63
 
61
64
  if (sourcemapOutput) {
62
65
  reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
@@ -139,7 +142,11 @@ async function checkGradleConfig() {
139
142
  async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput) {
140
143
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
141
144
  // >= rn 0.69
142
- let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
145
+ const rnDir = path.dirname(require.resolve('react-native', {
146
+ paths: [process.cwd()]
147
+ }));
148
+ const hermesCommand = path.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}/hermesc`);
149
+
143
150
  // < rn 0.69
144
151
  if (!fs.existsSync(hermesCommand)) {
145
152
  const hermesPackage = fs.existsSync('node_modules/hermes-engine') ? 'node_modules/hermes-engine' // 0.2+
package/lib/package.js CHANGED
@@ -74,7 +74,7 @@ const commands = exports.commands = {
74
74
  } = await (0, _utils.getIpaInfo)(fn);
75
75
  const { appId, appKey } = await (0, _app.getSelectedApp)('ios');
76
76
 
77
- if (appIdInPkg && appIdInPkg !== appId) {
77
+ if (appIdInPkg && appIdInPkg != appId) {
78
78
  throw new Error(`appId不匹配!当前ipa: ${appIdInPkg}, 当前update.json: ${appId}`);
79
79
  }
80
80
 
@@ -105,7 +105,7 @@ const commands = exports.commands = {
105
105
  } = await (0, _utils.getApkInfo)(fn);
106
106
  const { appId, appKey } = await (0, _app.getSelectedApp)('android');
107
107
 
108
- if (appIdInPkg && appIdInPkg !== appId) {
108
+ if (appIdInPkg && appIdInPkg != appId) {
109
109
  throw new Error(`appId不匹配!当前apk: ${appIdInPkg}, 当前update.json: ${appId}`);
110
110
  }
111
111
 
@@ -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.12.0",
3
+ "version": "1.17.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
@@ -50,7 +50,9 @@ async function runReactNativeBundleCommand(
50
50
  fs.emptyDirSync(outputFolder);
51
51
 
52
52
  Array.prototype.push.apply(reactNativeBundleArgs, [
53
- path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
53
+ require.resolve('react-native/local-cli/cli.js', {
54
+ paths: [process.cwd()],
55
+ }), // 'react-native' package may be symlinked
54
56
  'bundle',
55
57
  '--assets-dest',
56
58
  outputFolder,
@@ -171,7 +173,16 @@ async function compileHermesByteCode(
171
173
  ) {
172
174
  console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
173
175
  // >= rn 0.69
174
- let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
176
+ const rnDir = path.dirname(
177
+ require.resolve('react-native', {
178
+ paths: [process.cwd()],
179
+ }),
180
+ );
181
+ const hermesCommand = path.join(
182
+ rnDir,
183
+ `/sdks/hermesc/${getHermesOSBin()}/hermesc`,
184
+ );
185
+
175
186
  // < rn 0.69
176
187
  if (!fs.existsSync(hermesCommand)) {
177
188
  const hermesPackage = fs.existsSync('node_modules/hermes-engine')
package/src/package.js CHANGED
@@ -65,7 +65,7 @@ export const commands = {
65
65
  } = await getIpaInfo(fn);
66
66
  const { appId, appKey } = await getSelectedApp('ios');
67
67
 
68
- if (appIdInPkg && appIdInPkg !== appId) {
68
+ if (appIdInPkg && appIdInPkg != appId) {
69
69
  throw new Error(
70
70
  `appId不匹配!当前ipa: ${appIdInPkg}, 当前update.json: ${appId}`,
71
71
  );
@@ -100,7 +100,7 @@ export const commands = {
100
100
  } = await getApkInfo(fn);
101
101
  const { appId, appKey } = await getSelectedApp('android');
102
102
 
103
- if (appIdInPkg && appIdInPkg !== appId) {
103
+ if (appIdInPkg && appIdInPkg != appId) {
104
104
  throw new Error(
105
105
  `appId不匹配!当前apk: ${appIdInPkg}, 当前update.json: ${appId}`,
106
106
  );
@@ -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) {