diff --git a/README.md b/README.md index 0773c40..f721eff 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ 因为React Native调整了okhttp的依赖,对于0.27以上版本的React Native,请安装1.1.x版本,对于0.26及以前版本,请安装1.0.x版本。 +0.31开始React Native调整了bundle的传参,因此需要更新本插件到2.1.0 + ### 优势 1. 命令行工具&网页双端管理,版本发布过程简单便捷,完全可以集成CI。 diff --git a/local-cli/src/bundle.js b/local-cli/src/bundle.js index d769017..0979963 100644 --- a/local-cli/src/bundle.js +++ b/local-cli/src/bundle.js @@ -365,22 +365,40 @@ export const commands = { const Config = require(path.resolve('node_modules/react-native/local-cli/util/Config')); const bundle = require(path.resolve('node_modules/react-native/local-cli/bundle/bundle')); - const defaultConfig = require(path.resolve('node_modules/react-native/local-cli/default.config')); + const defaultConfig = + Config.get(path.resolve('node_modules/react-native/local-cli'), + require(path.resolve('node_modules/react-native/local-cli/default.config')) + ); - await bundle([ - '--entry-file', - entryFile, - '--platform', - platform, - '--dev', - '' + !!dev, - '--bundle-output', - `${realIntermedia}${path.sep}index.bundlejs`, - '--assets-dest', - `${realIntermedia}`, - '--verbose', - '' + !!verbose, - ], Config.get(path.resolve('node_modules/react-native/local-cli'), defaultConfig)); + if (bundle.func) { + // React native after 0.31.0 + await bundle.func([], defaultConfig, { + entryFile : entryFile, + platform: platform, + dev: !!dev, + bundleOutput: `${realIntermedia}${path.sep}index.bundlejs`, + assetsDest: `${realIntermedia}`, + verbose: !!verbose, + transformer: require.resolve('react-native/packager/transformer'), + bundleEncoding: 'utf8', + }); + } else { + // React native before 0.30.0 + await bundle([ + '--entry-file', + entryFile, + '--platform', + platform, + '--dev', + '' + !!dev, + '--bundle-output', + `${realIntermedia}${path.sep}index.bundlejs`, + '--assets-dest', + `${realIntermedia}`, + '--verbose', + '' + !!verbose, + ], defaultConfig); + } console.log('Packing'); diff --git a/local-cli/src/index.js b/local-cli/src/index.js index 566d088..9d613f9 100644 --- a/local-cli/src/index.js +++ b/local-cli/src/index.js @@ -33,7 +33,7 @@ exports.run = function () { console.log('Not loggined.\nRun `pushy login` at your project directory to login.'); return; } - console.error(err.message); + console.error(err.stack); process.exit(-1); }); }; diff --git a/package.json b/package.json index a28ebd5..0d05689 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "2.0.1", + "version": "2.1.0", "description": "react-native hot update", "main": "lib/index.js", "scripts": {