From 5a174066aff617972c3e15163d145b49f89daef4 Mon Sep 17 00:00:00 2001 From: Jackong Date: Sat, 19 Mar 2016 11:50:08 +0800 Subject: [PATCH 1/7] Fix bundle file name to support multi-bundles --- .../java/com/microsoft/codepush/react/CodePush.java | 6 +++--- .../com/microsoft/codepush/react/CodePushPackage.java | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index fd3361e..731a2f8 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -135,7 +135,7 @@ public class CodePush { long binaryResourcesModifiedTime = getBinaryResourcesModifiedTime(); try { - String packageFilePath = codePushPackage.getCurrentPackageBundlePath(); + String packageFilePath = codePushPackage.getCurrentPackageBundlePath(this.assetsBundleFileName); if (packageFilePath == null) { // There has not been any downloaded updates. CodePushUtils.logBundleUrl(binaryJsBundleUrl); @@ -579,7 +579,7 @@ public class CodePush { public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) { if (isUsingTestConfiguration()) { try { - codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl); + codePushPackage.downloadAndReplaceCurrentBundle(remoteBundleUrl, assetsBundleFileName); } catch (IOException e) { throw new CodePushUnknownException("Unable to replace current bundle", e); } @@ -628,4 +628,4 @@ public class CodePush { return new ArrayList<>(); } } -} \ No newline at end of file +} diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java index a9483b4..2d4aaa9 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java @@ -31,7 +31,6 @@ public class CodePushPackage { private final String RELATIVE_BUNDLE_PATH_KEY = "bundlePath"; private final String STATUS_FILE = "codepush.json"; private final String UNZIPPED_FOLDER_NAME = "unzipped"; - private final String UPDATE_BUNDLE_FILE_NAME = "app.jsbundle"; private String documentsDirectory; @@ -95,7 +94,7 @@ public class CodePushPackage { return getPackageFolderPath(packageHash); } - public String getCurrentPackageBundlePath() { + public String getCurrentPackageBundlePath(String bundleFileName) { String packageFolder = getCurrentPackageFolderPath(); if (packageFolder == null) { return null; @@ -104,7 +103,7 @@ public class CodePushPackage { WritableMap currentPackage = getCurrentPackage(); String relativeBundlePath = CodePushUtils.tryGetString(currentPackage, RELATIVE_BUNDLE_PATH_KEY); if (relativeBundlePath == null) { - return CodePushUtils.appendPathComponent(packageFolder, UPDATE_BUNDLE_FILE_NAME); + return CodePushUtils.appendPathComponent(packageFolder, bundleFileName); } else { return CodePushUtils.appendPathComponent(packageFolder, relativeBundlePath); } @@ -270,7 +269,7 @@ public class CodePushPackage { } } else { // File is a jsbundle, move it to a folder with the packageHash as its name - FileUtils.moveFile(downloadFile, newUpdateFolderPath, UPDATE_BUNDLE_FILE_NAME); + FileUtils.moveFile(downloadFile, newUpdateFolderPath, expectedBundleFileName); } // Save metadata to the folder. @@ -307,7 +306,7 @@ public class CodePushPackage { updateCurrentPackageInfo(info); } - public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) throws IOException { + public void downloadAndReplaceCurrentBundle(String remoteBundleUrl, String bundleFileName) throws IOException { URL downloadUrl; HttpURLConnection connection = null; BufferedInputStream bin = null; @@ -317,7 +316,7 @@ public class CodePushPackage { downloadUrl = new URL(remoteBundleUrl); connection = (HttpURLConnection) (downloadUrl.openConnection()); bin = new BufferedInputStream(connection.getInputStream()); - File downloadFile = new File(getCurrentPackageBundlePath()); + File downloadFile = new File(getCurrentPackageBundlePath(bundleFileName)); downloadFile.delete(); fos = new FileOutputStream(downloadFile); bout = new BufferedOutputStream(fos, DOWNLOAD_BUFFER_SIZE); From e48444a32c53f0250df171afcd30d45d7f7a5562 Mon Sep 17 00:00:00 2001 From: Xavier Carpentier Date: Wed, 23 Mar 2016 17:29:25 +0100 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37b72a6..b53efe6 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ We hope to eventually remove the need for steps #2-4, but in the meantime, RNPM 1. Add the CodePush plugin dependency to your `Podfile`, pointing at the path where NPM installed it ```ruby - pod 'CodePush', :path => './node_modules/react-native-code-push` + pod 'CodePush', :path => './node_modules/react-native-code-push' ``` 2. Run `pod install` From 31b5dc389562f74f6b1e128b6a75b3225ae0c02c Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 10:49:52 -0700 Subject: [PATCH 3/7] Improving error message for invalid updates --- .../java/com/microsoft/codepush/react/CodePushPackage.java | 2 +- ios/CodePush/CodePushPackage.m | 4 +++- package-mixins.js | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java index a9483b4..dc8218e 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushPackage.java @@ -246,7 +246,7 @@ public class CodePushPackage { String relativeBundlePath = CodePushUpdateUtils.findJSBundleInUpdateContents(newUpdateFolderPath, expectedBundleFileName); if (relativeBundlePath == null) { - throw new CodePushInvalidUpdateException("Update is invalid - no files with extension .bundle, .js or .jsbundle were found in the update package."); + throw new CodePushInvalidUpdateException("Update is invalid - A JS bundle file named \"" + expectedBundleFileName + "\" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary."); } else { if (FileUtils.fileAtPathExists(newUpdateMetadataPath)) { File metadataFileFromOldUpdate = new File(newUpdateMetadataPath); diff --git a/ios/CodePush/CodePushPackage.m b/ios/CodePush/CodePushPackage.m index a0658cc..cba883f 100644 --- a/ios/CodePush/CodePushPackage.m +++ b/ios/CodePush/CodePushPackage.m @@ -207,7 +207,9 @@ static NSString *const UnzippedFolderName = @"unzipped"; if (relativeBundlePath) { [mutableUpdatePackage setValue:relativeBundlePath forKey:RelativeBundlePathKey]; } else { - error = [CodePushErrorUtils errorWithMessage:@"Update is invalid - no files with extension .jsbundle or .bundle were found in the update package."]; + NSString *errorMessage = [NSString stringWithFormat:@"Update is invalid - A JS bundle file named \"%@\" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.", expectedBundleFileName]; + + error = [CodePushErrorUtils errorWithMessage:errorMessage]; failCallback(error); return; diff --git a/package-mixins.js b/package-mixins.js index 4c68404..604c386 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,8 +27,12 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; + } catch (e) { + // Rethrow the error so that the caller of this method + // is aware of the issue (e.g. the update was invalid) + throw e; } finally { - downloadProgressSubscription && downloadProgressSubscription.remove(); + downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From 226f398ea849bf731e66dca56f994db5de543a75 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:20:05 -0700 Subject: [PATCH 4/7] Reverting rethrow --- package-mixins.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package-mixins.js b/package-mixins.js index 604c386..f3b2730 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,11 +27,8 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; - } catch (e) { - // Rethrow the error so that the caller of this method - // is aware of the issue (e.g. the update was invalid) - throw e; - } finally { + } + finally { downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From ff59cf55e958a823a403f19339e68c41f4a06c6d Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:21:01 -0700 Subject: [PATCH 5/7] Fixing spacing --- package-mixins.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package-mixins.js b/package-mixins.js index f3b2730..3a83c29 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -27,8 +27,7 @@ module.exports = (NativeCodePush) => { const downloadedPackage = await NativeCodePush.downloadUpdate(this); reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; - } - finally { + } finally { downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From 236b3ffbf1f00c2463641c9ca1c3fa20a7ef3c11 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 11:21:35 -0700 Subject: [PATCH 6/7] Fixing spacing --- package-mixins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-mixins.js b/package-mixins.js index 3a83c29..4c68404 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -28,7 +28,7 @@ module.exports = (NativeCodePush) => { reportStatusDownload && reportStatusDownload(this); return { ...downloadedPackage, ...local }; } finally { - downloadProgressSubscription && downloadProgressSubscription.remove(); + downloadProgressSubscription && downloadProgressSubscription.remove(); } }, From ac38eaa7b264a860f805305ab9a7878a46bec8db Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Wed, 23 Mar 2016 14:33:27 -0700 Subject: [PATCH 7/7] Updating RN support matrix to include 0.23.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b53efe6..3922011 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ We try our best to maintain backwards compatability of our plugin with previous | <0.14.0 | **Unsupported** | | v0.14.0 | v1.3.0 *(introduced Android support)* | | v0.15.0-v0.18.0 | v1.4.0-v1.6.0 *(introduced iOS asset support)* | -| v0.19.0-v0.22.0 | v1.7.0+ *(introduced Android asset support)* | -| v0.23.0+ | TBD :) We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is. +| v0.19.0-v0.23.0 | v1.7.0+ *(introduced Android asset support)* | +| v0.24.0+ | TBD :) We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is. ## Supported Components