@appzung/react-native-code-push 6.4.2 → 8.3.2

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.
Files changed (91) hide show
  1. package/.azurepipelines/build-rn-code-push-1es.yml +104 -0
  2. package/.azurepipelines/test-rn-code-push.yml +94 -0
  3. package/.config/CredScanSuppressions.json +14 -0
  4. package/CONTRIBUTING.md +3 -3
  5. package/CodePush.js +26 -28
  6. package/CodePush.podspec +1 -1
  7. package/README.md +8 -7
  8. package/SECURITY.md +41 -0
  9. package/android/app/build.gradle +1 -1
  10. package/android/app/src/main/AndroidManifest.xml +1 -5
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -5
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -0
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +19 -1
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +5 -4
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +3 -1
  16. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +8 -9
  17. package/android/build.gradle +3 -2
  18. package/android/codepush.gradle +79 -30
  19. package/docs/api-js.md +1 -1
  20. package/docs/setup-android.md +27 -3
  21. package/docs/setup-ios.md +1 -1
  22. package/docs/setup-windows.md +59 -3
  23. package/ios/CodePush/CodePushPackage.m +4 -0
  24. package/ios/CodePush/CodePushUpdateUtils.m +1 -1
  25. package/ios/CodePush.xcodeproj/project.pbxproj +2 -2
  26. package/package.json +11 -11
  27. package/typings/react-native-code-push.d.ts +1 -1
  28. package/windows/CodePush/CodePush.def +3 -0
  29. package/windows/CodePush/CodePush.vcxproj +198 -0
  30. package/windows/CodePush/CodePush.vcxproj.filters +91 -0
  31. package/windows/CodePush/CodePushConfig.cpp +104 -0
  32. package/windows/CodePush/CodePushConfig.h +66 -0
  33. package/windows/CodePush/CodePushConfig.idl +12 -0
  34. package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
  35. package/windows/CodePush/CodePushDownloadHandler.h +32 -0
  36. package/windows/CodePush/CodePushNativeModule.cpp +934 -0
  37. package/windows/CodePush/CodePushNativeModule.h +247 -0
  38. package/windows/CodePush/CodePushPackage.cpp +456 -0
  39. package/windows/CodePush/CodePushPackage.h +49 -0
  40. package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
  41. package/windows/CodePush/CodePushTelemetryManager.h +29 -0
  42. package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
  43. package/windows/CodePush/CodePushUpdateUtils.h +38 -0
  44. package/windows/CodePush/CodePushUtils.cpp +29 -0
  45. package/windows/CodePush/CodePushUtils.h +18 -0
  46. package/windows/CodePush/FileUtils.cpp +131 -0
  47. package/windows/CodePush/FileUtils.h +28 -0
  48. package/windows/CodePush/PropertySheet.props +16 -0
  49. package/windows/CodePush/ReactPackageProvider.cpp +15 -0
  50. package/windows/CodePush/ReactPackageProvider.h +22 -0
  51. package/windows/CodePush/ReactPackageProvider.idl +9 -0
  52. package/windows/CodePush/miniz/LICENSE +22 -0
  53. package/windows/CodePush/miniz/miniz.c +7657 -0
  54. package/windows/CodePush/miniz/miniz.h +1338 -0
  55. package/windows/CodePush/miniz/readme.md +37 -0
  56. package/windows/CodePush/packages.config +4 -0
  57. package/windows/CodePush/pch.cpp +1 -0
  58. package/windows/CodePush/pch.h +4 -0
  59. package/{windows → windows-legacy}/CodePush/CodePush.csproj +1 -1
  60. package/{windows → windows-legacy}/CodePush.Net46/CodePush.Net46.csproj +2 -2
  61. package/{windows → windows-legacy}/CodePush.Net46/packages.config +1 -1
  62. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
  63. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
  64. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
  65. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
  66. package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
  67. package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
  68. /package/{windows → windows-legacy}/CodePush/CodePushUtils.cs +0 -0
  69. /package/{windows → windows-legacy}/CodePush/FileUtils.cs +0 -0
  70. /package/{windows → windows-legacy}/CodePush/Properties/AssemblyInfo.cs +0 -0
  71. /package/{windows → windows-legacy}/CodePush/Properties/CodePush.rd.xml +0 -0
  72. /package/{windows → windows-legacy}/CodePush/UpdateManager.cs +0 -0
  73. /package/{windows → windows-legacy}/CodePush/UpdateUtils.cs +0 -0
  74. /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -0
  75. /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -0
  76. /package/{windows → windows-legacy}/CodePush.Net46/CodePushUtils.cs +0 -0
  77. /package/{windows → windows-legacy}/CodePush.Net46/FileUtils.cs +0 -0
  78. /package/{windows → windows-legacy}/CodePush.Net46/Properties/AssemblyInfo.cs +0 -0
  79. /package/{windows → windows-legacy}/CodePush.Net46/UpdateManager.cs +0 -0
  80. /package/{windows → windows-legacy}/CodePush.Net46/UpdateUtils.cs +0 -0
  81. /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.projitems +0 -0
  82. /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.shproj +0 -0
  83. /package/{windows → windows-legacy}/CodePush.Shared/CodePushConstants.cs +0 -0
  84. /package/{windows → windows-legacy}/CodePush.Shared/CodePushNativeModule.cs +0 -0
  85. /package/{windows → windows-legacy}/CodePush.Shared/CodePushReactPackage.cs +0 -0
  86. /package/{windows → windows-legacy}/CodePush.Shared/CodePushUtils.cs +0 -0
  87. /package/{windows → windows-legacy}/CodePush.Shared/InstallMode.cs +0 -0
  88. /package/{windows → windows-legacy}/CodePush.Shared/MinimumBackgroundListener.cs +0 -0
  89. /package/{windows → windows-legacy}/CodePush.Shared/SettingsManager.cs +0 -0
  90. /package/{windows → windows-legacy}/CodePush.Shared/TelemetryManager.cs +0 -0
  91. /package/{windows → windows-legacy}/CodePush.Shared/UpdateState.cs +0 -0
@@ -2,7 +2,8 @@
2
2
 
3
3
  buildscript {
4
4
  repositories {
5
- jcenter()
5
+ google()
6
+ mavenCentral()
6
7
  }
7
8
  dependencies {
8
9
  classpath 'com.android.tools.build:gradle:1.3.0'
@@ -15,6 +16,6 @@ buildscript {
15
16
  allprojects {
16
17
  repositories {
17
18
  mavenLocal()
18
- jcenter()
19
+ mavenCentral()
19
20
  }
20
21
  }
@@ -2,8 +2,8 @@
2
2
 
3
3
  import java.nio.file.Paths;
4
4
 
5
- def config = project.hasProperty("react") ? project.react : [];
6
- def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
5
+ def config = project.extensions.findByName("react") ?: [:]
6
+ def bundleAssetName = config.bundleAssetName ? config.bundleAssetName.get() : "index.android.bundle"
7
7
 
8
8
  // because elvis operator
9
9
  def elvisFile(thing) {
@@ -17,21 +17,61 @@ void runBefore(String dependentTaskName, Task task) {
17
17
  }
18
18
  }
19
19
 
20
- gradle.projectsEvaluated {
21
- android.buildTypes.each {
22
- // to prevent incorrect long value restoration from strings.xml we need to wrap it with double quotes
23
- // https://github.com/microsoft/cordova-plugin-code-push/issues/264
24
- it.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
20
+ /**
21
+ * Finds the path of the installed npm package with the given name using Node's
22
+ * module resolution algorithm, which searches "node_modules" directories up to
23
+ * the file system root. This handles various cases, including:
24
+ *
25
+ * - Working in the open-source RN repo:
26
+ * Gradle: /path/to/react-native/ReactAndroid
27
+ * Node module: /path/to/react-native/node_modules/[package]
28
+ *
29
+ * - Installing RN as a dependency of an app and searching for hoisted
30
+ * dependencies:
31
+ * Gradle: /path/to/app/node_modules/react-native/ReactAndroid
32
+ * Node module: /path/to/app/node_modules/[package]
33
+ *
34
+ * - Working in a larger repo (e.g., Facebook) that contains RN:
35
+ * Gradle: /path/to/repo/path/to/react-native/ReactAndroid
36
+ * Node module: /path/to/repo/node_modules/[package]
37
+ *
38
+ * The search begins at the given base directory (a File object). The returned
39
+ * path is a string.
40
+ */
41
+ static def findNodeModulePath(baseDir, packageName) {
42
+ def basePath = baseDir.toPath().normalize()
43
+ // Node's module resolution algorithm searches up to the root directory,
44
+ // after which the base path will be null
45
+ while (basePath) {
46
+ def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
47
+ if (candidatePath.toFile().exists()) {
48
+ return candidatePath.toString()
49
+ }
50
+ basePath = basePath.getParent()
25
51
  }
26
-
52
+ return null
53
+ }
54
+
55
+ android.buildTypes.each { buildType ->
56
+ // to prevent incorrect long value restoration from strings.xml we need to wrap it with double quotes
57
+ // https://github.com/microsoft/cordova-plugin-code-push/issues/264
58
+ buildType.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
59
+ }
60
+
61
+ gradle.projectsEvaluated {
62
+ def debuggableVariants = config.debuggableVariants ? config.debuggableVariants.get() : ['debug']
63
+
27
64
  android.applicationVariants.all { variant ->
65
+ // No code push for debuggable variants
66
+ if (debuggableVariants.contains(variant.name)) {
67
+ return;
68
+ }
69
+
28
70
  def nodeModulesPath;
29
- if (config.root) {
30
- nodeModulesPath = Paths.get(config.root, "/node_modules");
31
- } else if (project.hasProperty('nodeModulesPath')) {
32
- nodeModulesPath = project.nodeModulesPath
71
+ if (project.hasProperty('nodeModulesPath')) {
72
+ nodeModulesPath = "${project.nodeModulesPath}/react-native-code-push"
33
73
  } else {
34
- nodeModulesPath = "../../node_modules";
74
+ nodeModulesPath = findNodeModulePath(projectDir, "react-native-code-push")
35
75
  }
36
76
 
37
77
  def targetName = variant.name.capitalize()
@@ -42,37 +82,45 @@ gradle.projectsEvaluated {
42
82
  def jsBundleFile;
43
83
 
44
84
  // Additional node commandline arguments
45
- def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"]
46
- def extraPackagerArgs = config.extraPackagerArgs ?: []
85
+ def nodeExecutableAndArgs = config.nodeExecutableAndArgs ? config.nodeExecutableAndArgs.get(): ["node"]
86
+ def extraPackagerArgs = config.extraPackagerArgs ? config.extraPackagerArgs.get() : []
47
87
 
48
88
  // Make this task run right after the bundle task
49
89
  def generateBundledResourcesHash;
50
90
 
51
- if (variant.hasProperty("bundleJsAndAssets")) {
52
- def reactBundleTask = variant.bundleJsAndAssets
53
- jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath
54
- resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath
91
+ def reactBundleTask = tasks.findByName("createBundle${targetName}JsAndAssets")
92
+ if (reactBundleTask) {
93
+ jsBundleDir = reactBundleTask.property('jsBundleDir').asFile.get()
94
+ resourcesDir = reactBundleTask.property('resourcesDir').asFile.get()
95
+
96
+ // mitigates Resource and asset merger: Duplicate resources error
97
+ project.delete(files("${jsBundleDir}"))
98
+
99
+ jsBundleDir.mkdirs()
100
+ resourcesDir.mkdirs()
101
+
55
102
  jsBundleFile = file("$jsBundleDir/$bundleAssetName")
56
103
 
57
104
  generateBundledResourcesHash = tasks.create(
58
105
  name: "generateBundledResourcesHash${targetName}",
59
106
  type: Exec) {
60
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir)
107
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir)
61
108
 
62
- enabled config."bundleIn${targetName}" ||
63
- config."bundleIn${variant.buildType.name.capitalize()}" ?:
64
- targetName.toLowerCase().contains("release")
65
- }
109
+ enabled !debuggableVariants.contains(variant.name) ?: targetName.toLowerCase().contains("release")
110
+ }
111
+
112
+ runBefore("merge${targetName}Resources", generateBundledResourcesHash)
113
+ runBefore("merge${targetName}Assets", generateBundledResourcesHash)
66
114
  } else {
67
115
  def jsBundleDirConfigName = "jsBundleDir${targetName}"
68
- jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
116
+ jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ? elvisFile(config."$jsBundleDirConfigName").get():
69
117
  file("$buildDir/intermediates/assets/${targetPath}")
70
118
 
71
119
  def resourcesDirConfigName = "resourcesDir${targetName}"
72
- resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
120
+ resourcesDir = elvisFile(config."${resourcesDirConfigName}") ? elvisFile(config."${resourcesDirConfigName}").get():
73
121
  file("$buildDir/intermediates/res/merged/${targetPath}")
74
122
 
75
- // In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
123
+ // In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
76
124
  // '$buildDir' has slightly different structure - 'merged' folder
77
125
  // does not exists so '${targetPath}' folder contains directly in 'res' folder.
78
126
  if (!resourcesDir.exists() && file("$buildDir/intermediates/res/${targetPath}").exists()) {
@@ -86,14 +134,14 @@ gradle.projectsEvaluated {
86
134
  generateBundledResourcesHash = tasks.create(
87
135
  name: "generateBundledResourcesHash${targetName}",
88
136
  type: Exec) {
89
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir, resourcesMapTempFileName)
137
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir, resourcesMapTempFileName)
90
138
  }
91
139
 
92
140
  // Make this task run right before the bundle task
93
141
  def recordFilesBeforeBundleCommand = tasks.create(
94
142
  name: "recordFilesBeforeBundleCommand${targetName}",
95
143
  type: Exec) {
96
- commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName)
144
+ commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName)
97
145
  }
98
146
 
99
147
  recordFilesBeforeBundleCommand.dependsOn("merge${targetName}Resources")
@@ -104,7 +152,8 @@ gradle.projectsEvaluated {
104
152
  generateBundledResourcesHash.dependsOn("recordFilesBeforeBundleCommand${targetName}")
105
153
  }
106
154
 
107
- generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets")
155
+ generateBundledResourcesHash.dependsOn("createBundle${targetName}JsAndAssets")
156
+
108
157
  runBefore("processArmeabi-v7a${targetName}Resources", generateBundledResourcesHash)
109
158
  runBefore("processX86${targetName}Resources", generateBundledResourcesHash)
110
159
  runBefore("processUniversal${targetName}Resources", generateBundledResourcesHash)
package/docs/api-js.md CHANGED
@@ -128,7 +128,7 @@ The `codePush` decorator accepts an "options" object that allows you to customiz
128
128
 
129
129
  * __minimumBackgroundDuration__ *(Number)* - Specifies the minimum number of seconds that the app needs to have been in the background before restarting the app. This property only applies to updates which are installed using `InstallMode.ON_NEXT_RESUME` or `InstallMode.ON_NEXT_SUSPEND`, and can be useful for getting your update in front of end users sooner, without being too obtrusive. Defaults to `0`, which has the effect of applying the update immediately after a resume or unless the app suspension is long enough to not matter, regardless how long it was in the background.
130
130
 
131
- * __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/microsoft/react-native-code-push#user-content-apple-note).
131
+ * __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/microsoft/react-native-code-push#app-store).
132
132
 
133
133
  The following list represents the available options and their defaults:
134
134
 
@@ -27,16 +27,40 @@ In order to integrate CodePush into your Android project, please perform the fol
27
27
  project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
28
28
  ```
29
29
 
30
- 2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
30
+ 2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition to the end of the file:
31
31
 
32
32
  ```gradle
33
33
  ...
34
- apply from: "../../node_modules/react-native/react.gradle"
35
34
  apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
36
35
  ...
37
36
  ```
38
37
 
39
- 3. Update the `MainApplication.java` file to use CodePush via the following changes:
38
+ 3. Update the `MainApplication` file to use CodePush via the following changes:
39
+
40
+ For React Native 0.73 and above: update the `MainApplication.kt`
41
+
42
+ ```kotlin
43
+ ...
44
+ // 1. Import the plugin class.
45
+ import com.microsoft.codepush.react.CodePush
46
+
47
+ class MainApplication : Application(), ReactApplication {
48
+
49
+ override val reactNativeHost: ReactNativeHost =
50
+ object : DefaultReactNativeHost(this) {
51
+ ...
52
+
53
+ // 2. Override the getJSBundleFile method in order to let
54
+ // the CodePush runtime determine where to get the JS
55
+ // bundle location from on each app start
56
+ override fun getJSBundleFile(): String {
57
+ return CodePush.getJSBundleFile()
58
+ }
59
+ };
60
+ }
61
+ ```
62
+
63
+ For React Native 0.72 and below: update the `MainApplication.java`
40
64
 
41
65
  ```java
42
66
  ...
package/docs/setup-ios.md CHANGED
@@ -35,7 +35,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Xcod
35
35
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
36
36
  {
37
37
  #if DEBUG
38
- return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
38
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
39
39
  #else
40
40
  return [CodePush bundleURL];
41
41
  #endif
@@ -2,9 +2,65 @@
2
2
 
3
3
  Once you've acquired the CodePush plugin, you need to integrate it into the Visual Studio project of your React Native app and configure it correctly. To do this, take the following steps:
4
4
 
5
- ### Plugin Installation (Windows)
5
+ ### Plugin Installation and Configuration for React Native Windows 0.63.6 version and above
6
6
 
7
- 1. Open the Visual Studio solution located at `windows\<AppName>\<AppName>.sln` within your app
7
+ #### Plugin Installation (Windows-npx)
8
+
9
+ Once the plugin has been downloaded, run `npx react-native autolink-windows` in your application's root directory to automatically add the CodePush c++ project to your application's windows solution file.
10
+
11
+ #### Plugin Configuration (Windows)
12
+
13
+ 1. Replace the following files located at `windows/<app name>` with those in the CodePushDemoAppCpp example app in this repo found at `Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp`:
14
+ 1. app.h
15
+ 2. app.cpp
16
+ 3. app.xaml
17
+
18
+ 2. In the above files, replace any occurance of `CodePushDemoAppCpp` with the name of your application
19
+
20
+ 3. Enter your application's app version and deployment key to the `configMap` object at the top of your app's `OnLaunched` method in `App.cpp`:
21
+
22
+ ```c++
23
+ ...
24
+ void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
25
+ {
26
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::SetHost(Host());
27
+ auto configMap{ winrt::single_threaded_map<hstring, hstring>() };
28
+ configMap.Insert(L"appVersion", L"1.0.0");
29
+ configMap.Insert(L"deploymentKey", L"<app deployment key>");
30
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::Init(configMap);
31
+ ...
32
+ }
33
+ ...
34
+ ```
35
+
36
+ #### Plugin Configuration (Windows) C#
37
+
38
+ 1. add name space `Microsoft.CodePush` to `App.xaml.cs`
39
+
40
+ 2. add app version and deployment key to `configMap` at the start of your app's `OnLaunched` method in `App.xaml.cs`.
41
+
42
+ ```c#
43
+ using Microsoft.CodePush;
44
+
45
+ ...
46
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
47
+ {
48
+ Microsoft.CodePush.ReactNative.CodePushConfig.SetHost(Host);
49
+ IDictionary<string, string> configMap = new Dictionary<string, string>();
50
+ configMap.Add("appVersion", "1.0.0");
51
+ configMap.Add("deploymentKey", "deployment key");
52
+ Microsoft.CodePush.ReactNative.CodePushConfig.Init(configMap);
53
+ ...
54
+ }
55
+ ...
56
+ ```
57
+
58
+
59
+ ### Plugin Installation and Configuration for React Native Windows lower than 0.60
60
+
61
+ #### Plugin Installation (Windows)
62
+
63
+ 1. Open the Visual Studio solution located at `windows-legacy\<AppName>\<AppName>.sln` within your app
8
64
 
9
65
  2. Right-click the solution node in the `Solution Explorer` window and select the `Add -> Existing Project...` menu item
10
66
 
@@ -20,7 +76,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Visu
20
76
 
21
77
  ![Add Reference Dialog](https://cloud.githubusercontent.com/assets/116461/14467147/cb805b6e-008e-11e6-964f-f856c59b65af.PNG)
22
78
 
23
- ### Plugin Configuration (Windows)
79
+ #### Plugin Configuration (Windows)
24
80
 
25
81
  After installing the plugin, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, update the `MainReactNativeHost.cs` file to use CodePush via the following changes:
26
82
 
@@ -1,5 +1,9 @@
1
1
  #import "CodePush.h"
2
+ #if __has_include(<SSZipArchive/SSZipArchive.h>)
3
+ #import <SSZipArchive/SSZipArchive.h>
4
+ #else
2
5
  #import "SSZipArchive.h"
6
+ #endif
3
7
 
4
8
  @implementation CodePushPackage
5
9
 
@@ -93,7 +93,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
93
93
  // The JSON serialization turns path separators into "\/", e.g. "CodePush\/assets\/image.png"
94
94
  manifestString = [manifestString stringByReplacingOccurrencesOfString:@"\\/"
95
95
  withString:@"/"];
96
- return [self computeHashForData:[NSData dataWithBytes:manifestString.UTF8String length:manifestString.length]];
96
+ return [self computeHashForData:[NSData dataWithBytes:manifestString.UTF8String length:[manifestString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]];
97
97
  }
98
98
 
99
99
  + (NSString *)computeHashForData:(NSData *)inputData
@@ -771,7 +771,7 @@
771
771
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
772
772
  GCC_WARN_UNUSED_FUNCTION = YES;
773
773
  GCC_WARN_UNUSED_VARIABLE = YES;
774
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
774
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
775
775
  MTL_ENABLE_DEBUG_INFO = YES;
776
776
  ONLY_ACTIVE_ARCH = YES;
777
777
  SDKROOT = iphoneos;
@@ -817,7 +817,7 @@
817
817
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
818
818
  GCC_WARN_UNUSED_FUNCTION = YES;
819
819
  GCC_WARN_UNUSED_VARIABLE = YES;
820
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
820
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
821
821
  MTL_ENABLE_DEBUG_INFO = NO;
822
822
  SDKROOT = iphoneos;
823
823
  USER_HEADER_SEARCH_PATHS = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appzung/react-native-code-push",
3
- "version": "6.4.2",
3
+ "version": "8.3.2",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",
@@ -25,33 +25,33 @@
25
25
  "tslint": "tslint -c tslint.json test/**/*.ts"
26
26
  },
27
27
  "dependencies": {
28
- "code-push": "^4.0.2",
29
- "glob": "^7.1.6",
28
+ "code-push": "^4.2.2",
29
+ "glob": "^7.1.7",
30
30
  "hoist-non-react-statics": "^3.3.2",
31
- "inquirer": "^7.3.3",
32
- "plist": "3.0.1",
33
- "semver": "^7.3.2",
31
+ "inquirer": "^8.1.5",
32
+ "plist": "^3.0.4",
33
+ "semver": "^7.3.5",
34
34
  "xcode": "3.0.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/assert": "^1.5.2",
38
38
  "@types/mkdirp": "^1.0.1",
39
- "@types/mocha": "^8.0.3",
39
+ "@types/mocha": "^9.0.0",
40
40
  "@types/node": "^14.0.27",
41
41
  "@types/q": "^1.5.4",
42
42
  "archiver": "latest",
43
43
  "body-parser": "latest",
44
44
  "code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
45
- "del": "latest",
45
+ "del": "v6.0.0",
46
46
  "express": "latest",
47
47
  "mkdirp": "latest",
48
- "mocha": "^8.1.3",
48
+ "mocha": "^9.2.0",
49
49
  "q": "^1.5.1",
50
50
  "run-sequence": "latest",
51
- "shx": "^0.3.2",
51
+ "shx": "^0.3.4",
52
52
  "slash": "^3.0.0",
53
53
  "tslint": "^6.1.3",
54
- "typescript": "^4.0.3"
54
+ "typescript": "^4.4.3"
55
55
  },
56
56
  "rnpm": {
57
57
  "android": {
@@ -134,7 +134,7 @@ export interface SyncOptions {
134
134
  * value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as
135
135
  * overriding one or more of the default strings.
136
136
  */
137
- updateDialog?: UpdateDialog;
137
+ updateDialog?: UpdateDialog | true;
138
138
 
139
139
  /**
140
140
  * The rollback retry mechanism allows the application to attempt to reinstall an update that was previously rolled back (with the restrictions
@@ -0,0 +1,3 @@
1
+ EXPORTS
2
+ DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3
+ DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
@@ -0,0 +1,198 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" />
4
+ <PropertyGroup Label="Globals">
5
+ <CppWinRTOptimized>true</CppWinRTOptimized>
6
+ <CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
7
+ <CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
8
+ <MinimalCoreWin>true</MinimalCoreWin>
9
+ <ProjectGuid>{a6b6216e-fa3f-45e2-9c8e-40023cce9132}</ProjectGuid>
10
+ <ProjectName>CodePush</ProjectName>
11
+ <RootNamespace>Microsoft.CodePush.ReactNative</RootNamespace>
12
+ <DefaultLanguage>en-US</DefaultLanguage>
13
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
14
+ <AppContainerApplication>true</AppContainerApplication>
15
+ <ApplicationType>Windows Store</ApplicationType>
16
+ <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
17
+ <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0</WindowsTargetPlatformVersion>
18
+ <WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
19
+ </PropertyGroup>
20
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21
+ <PropertyGroup Label="ReactNativeWindowsProps">
22
+ <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
23
+ </PropertyGroup>
24
+ <ItemGroup Label="ProjectConfigurations">
25
+ <ProjectConfiguration Include="Debug|ARM">
26
+ <Configuration>Debug</Configuration>
27
+ <Platform>ARM</Platform>
28
+ </ProjectConfiguration>
29
+ <ProjectConfiguration Include="Debug|ARM64">
30
+ <Configuration>Debug</Configuration>
31
+ <Platform>ARM64</Platform>
32
+ </ProjectConfiguration>
33
+ <ProjectConfiguration Include="Debug|Win32">
34
+ <Configuration>Debug</Configuration>
35
+ <Platform>Win32</Platform>
36
+ </ProjectConfiguration>
37
+ <ProjectConfiguration Include="Debug|x64">
38
+ <Configuration>Debug</Configuration>
39
+ <Platform>x64</Platform>
40
+ </ProjectConfiguration>
41
+ <ProjectConfiguration Include="Release|ARM">
42
+ <Configuration>Release</Configuration>
43
+ <Platform>ARM</Platform>
44
+ </ProjectConfiguration>
45
+ <ProjectConfiguration Include="Release|ARM64">
46
+ <Configuration>Release</Configuration>
47
+ <Platform>ARM64</Platform>
48
+ </ProjectConfiguration>
49
+ <ProjectConfiguration Include="Release|Win32">
50
+ <Configuration>Release</Configuration>
51
+ <Platform>Win32</Platform>
52
+ </ProjectConfiguration>
53
+ <ProjectConfiguration Include="Release|x64">
54
+ <Configuration>Release</Configuration>
55
+ <Platform>x64</Platform>
56
+ </ProjectConfiguration>
57
+ </ItemGroup>
58
+ <PropertyGroup Label="Configuration">
59
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
60
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
61
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
62
+ <CharacterSet>Unicode</CharacterSet>
63
+ <GenerateManifest>false</GenerateManifest>
64
+ </PropertyGroup>
65
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
66
+ <UseDebugLibraries>true</UseDebugLibraries>
67
+ <LinkIncremental>true</LinkIncremental>
68
+ </PropertyGroup>
69
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
70
+ <UseDebugLibraries>false</UseDebugLibraries>
71
+ <WholeProgramOptimization>true</WholeProgramOptimization>
72
+ <LinkIncremental>false</LinkIncremental>
73
+ </PropertyGroup>
74
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
75
+ <ImportGroup Label="ExtensionSettings">
76
+ </ImportGroup>
77
+ <ImportGroup Label="Shared">
78
+ </ImportGroup>
79
+ <ImportGroup Label="PropertySheets">
80
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
81
+ </ImportGroup>
82
+ <ImportGroup Label="PropertySheets">
83
+ <Import Project="PropertySheet.props" />
84
+ </ImportGroup>
85
+ <ImportGroup Label="ReactNativeWindowsPropertySheets">
86
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" />
87
+ </ImportGroup>
88
+ <PropertyGroup Label="UserMacros" />
89
+ <PropertyGroup />
90
+ <ItemDefinitionGroup>
91
+ <ClCompile>
92
+ <PrecompiledHeader>Use</PrecompiledHeader>
93
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
94
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
95
+ <WarningLevel>Level4</WarningLevel>
96
+ <AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
97
+ <!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
98
+ <AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
99
+ <DisableSpecificWarnings>
100
+ </DisableSpecificWarnings>
101
+ <PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102
+ <AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
103
+ </ClCompile>
104
+ <Link>
105
+ <SubSystem>Console</SubSystem>
106
+ <GenerateWindowsMetadata>true</GenerateWindowsMetadata>
107
+ <ModuleDefinitionFile>CodePush.def</ModuleDefinitionFile>
108
+ </Link>
109
+ </ItemDefinitionGroup>
110
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
111
+ <ClCompile>
112
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
113
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
114
+ </ClCompile>
115
+ </ItemDefinitionGroup>
116
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
117
+ <ClCompile>
118
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119
+ </ClCompile>
120
+ <Link>
121
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
122
+ <OptimizeReferences>true</OptimizeReferences>
123
+ </Link>
124
+ </ItemDefinitionGroup>
125
+ <ItemGroup>
126
+ <ClInclude Include="CodePushConfig.h" />
127
+ <ClInclude Include="CodePushDownloadHandler.h" />
128
+ <ClInclude Include="CodePushNativeModule.h" />
129
+ <ClInclude Include="CodePushPackage.h" />
130
+ <ClInclude Include="CodePushTelemetryManager.h" />
131
+ <ClInclude Include="CodePushUpdateUtils.h" />
132
+ <ClInclude Include="CodePushUtils.h" />
133
+ <ClInclude Include="FileUtils.h" />
134
+ <ClInclude Include="miniz\miniz.h" />
135
+ <ClInclude Include="pch.h" />
136
+ <ClInclude Include="ReactPackageProvider.h">
137
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
138
+ </ClInclude>
139
+ </ItemGroup>
140
+ <ItemGroup>
141
+ <ClCompile Include="CodePushConfig.cpp" />
142
+ <ClCompile Include="CodePushDownloadHandler.cpp" />
143
+ <ClCompile Include="CodePushNativeModule.cpp" />
144
+ <ClCompile Include="CodePushPackage.cpp" />
145
+ <ClCompile Include="CodePushTelemetryManager.cpp" />
146
+ <ClCompile Include="CodePushUpdateUtils.cpp" />
147
+ <ClCompile Include="CodePushUtils.cpp" />
148
+ <ClCompile Include="FileUtils.cpp" />
149
+ <ClCompile Include="miniz\miniz.c">
150
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
151
+ </ClCompile>
152
+ <ClCompile Include="pch.cpp">
153
+ <PrecompiledHeader>Create</PrecompiledHeader>
154
+ </ClCompile>
155
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
156
+ <ClCompile Include="ReactPackageProvider.cpp">
157
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
158
+ </ClCompile>
159
+ </ItemGroup>
160
+ <ItemGroup>
161
+ <Midl Include="CodePushConfig.idl" />
162
+ <Midl Include="ReactPackageProvider.idl" />
163
+ </ItemGroup>
164
+ <ItemGroup>
165
+ <None Include="CodePush.def" />
166
+ </ItemGroup>
167
+ <ItemGroup>
168
+ <None Include="packages.config" />
169
+ <None Include="PropertySheet.props" />
170
+ </ItemGroup>
171
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172
+ <ImportGroup Label="ReactNativeWindowsTargets">
173
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
174
+ </ImportGroup>
175
+ <Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
176
+ <PropertyGroup>
177
+ <ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
178
+ </PropertyGroup>
179
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
180
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
181
+ </Target>
182
+ <ImportGroup Label="ExtensionTargets">
183
+ <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
184
+ </ImportGroup>
185
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
186
+ <PropertyGroup>
187
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
188
+ </PropertyGroup>
189
+ <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
190
+ <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
191
+ </Target>
192
+ <ItemGroup>
193
+ <ProjectReference Update="$(ReactNativeWindowsDir)\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
194
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
195
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
196
+ </ProjectReference>
197
+ </ItemGroup>
198
+ </Project>