@appzung/react-native-code-push 7.1.1 → 9.0.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 (97) 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 +20 -21
  6. package/CodePush.podspec +3 -3
  7. package/README.md +7 -5
  8. package/android/app/build.gradle +3 -1
  9. package/android/app/src/main/AndroidManifest.xml +2 -7
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -5
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +9 -1
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +18 -10
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +3 -1
  15. package/android/build.gradle +6 -2
  16. package/android/codepush.gradle +72 -26
  17. package/docs/api-js.md +1 -1
  18. package/docs/setup-android.md +27 -3
  19. package/docs/setup-ios.md +1 -1
  20. package/docs/setup-windows.md +23 -0
  21. package/ios/CodePush/CodePush.m +2 -1
  22. package/ios/CodePush/CodePushPackage.m +4 -0
  23. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  24. package/ios/CodePush/SSZipArchive/README.md +1 -1
  25. package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
  26. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
  27. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  28. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  29. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  30. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  31. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  32. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  33. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  34. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  35. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  36. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  37. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  38. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  39. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  40. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  41. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  42. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  43. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  44. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  45. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  46. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  47. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  48. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  49. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  50. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  51. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  52. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  53. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  54. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  55. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  56. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  57. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  58. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  59. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  60. package/ios/CodePush.xcodeproj/project.pbxproj +245 -130
  61. package/ios/PrivacyInfo.xcprivacy +31 -0
  62. package/package.json +2 -2
  63. package/typings/react-native-code-push.d.ts +1 -1
  64. package/windows/CodePush/CodePush.vcxproj +2 -3
  65. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +2 -2
  66. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +2 -2
  67. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  68. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  69. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  70. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  71. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  72. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  73. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  74. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  75. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  76. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  77. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  78. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  79. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  80. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  81. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  82. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  83. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  84. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  85. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  86. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  87. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  88. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  89. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  90. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  91. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  92. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  93. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  94. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  95. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  96. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  97. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
@@ -0,0 +1,104 @@
1
+ trigger:
2
+ - master
3
+
4
+ pr:
5
+ - master
6
+
7
+ resources:
8
+ repositories:
9
+ - repository: 1ESPipelineTemplates
10
+ type: git
11
+ name: 1ESPipelineTemplates/1ESPipelineTemplates
12
+ ref: refs/tags/release
13
+ name: $(Build.SourceBranchName)_$(date:yyyyMMdd)$(rev:.r)
14
+
15
+ extends:
16
+ ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
17
+ template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
18
+ ${{ else }}:
19
+ template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates
20
+ parameters:
21
+ pool:
22
+ name: 1ES-PT-CBL-Mariner-2.0-Gen2
23
+ os: linux
24
+ customBuildTags:
25
+ - ES365AIMigrationTooling-BulkMigrated
26
+ sdl:
27
+ sourceAnalysisPool: 1ES-PT-Windows-2022
28
+ credscan:
29
+ suppressionsFile: $(Build.SourcesDirectory)/.config/CredScanSuppressions.json
30
+ stages:
31
+ - stage: Stage
32
+ jobs:
33
+ - job: HostJob
34
+ templateContext:
35
+ outputs:
36
+ - output: pipelineArtifact
37
+ displayName: "Publish Artifact: artifacts"
38
+ path: '$(Build.ArtifactStagingDirectory)/npm'
39
+ artifactName: npm
40
+
41
+ steps:
42
+ - task: NodeTool@0
43
+ inputs:
44
+ versionSpec: '14.x'
45
+ displayName: 'Install Node.js'
46
+
47
+ - script: |
48
+ npm pack
49
+ npm install -g react-native-code-push*.tgz
50
+ displayName: 'Package react-native-code-push'
51
+ workingDirectory: $(Build.SourcesDirectory)
52
+
53
+ - task: DeleteFiles@1
54
+ inputs:
55
+ contents: node_modules
56
+ displayName: 'Delete node_modules'
57
+
58
+ - task: ArchiveFiles@2
59
+ inputs:
60
+ rootFolderOrFile: '$(Build.SourcesDirectory)'
61
+ includeRootFolder: false
62
+ archiveType: 'tar'
63
+ archiveFile: '$(Build.ArtifactStagingDirectory)/npm/$(Build.BuildId).tgz'
64
+ replaceExistingArchive: true
65
+ verbose: true
66
+ displayName: 'Prepare npm artifact'
67
+
68
+ - stage: APIScan
69
+ dependsOn: Stage
70
+ pool:
71
+ name: 1ES-PT-Windows-2022
72
+ os: windows
73
+ variables:
74
+ "agent.source.skip": true
75
+ jobs:
76
+ - job: APIScan
77
+ steps:
78
+ - task: DownloadPipelineArtifact@2
79
+ displayName: Download Build Artifacts for APIScan
80
+ inputs:
81
+ artifactName: npm
82
+ targetPath: '$(Agent.BuildDirectory)/npm'
83
+ - task: ExtractFiles@1
84
+ inputs:
85
+ archiveFilePatterns: '$(Agent.BuildDirectory)/npm/*.tgz'
86
+ destinationFolder: '$(Agent.BuildDirectory)/npm_extracted'
87
+ - task: AzureKeyVault@2
88
+ inputs:
89
+ azureSubscription: 'AC - Dev Infra & Build Pool'
90
+ KeyVaultName: 'mobile-center-sdk'
91
+ SecretsFilter: 'appcenter-sdk-managed-identity-clientid'
92
+ RunAsPreJob: false
93
+ - task: APIScan@2
94
+ displayName: 'Run APIScan'
95
+ inputs:
96
+ softwareFolder: '$(Agent.BuildDirectory)\npm_extracted'
97
+ softwareName: 'react-native-code-push'
98
+ softwareVersionNum: '$(Build.BuildId)'
99
+ isLargeApp: false
100
+ toolVersion: 'Latest'
101
+ verbosityLevel: verbose
102
+ condition: and(succeeded(), ne(variables['DisableAPIScan'], 'true'))
103
+ env:
104
+ AzureServicesAuthConnectionString: 'runAs=App;AppId=$(appcenter-sdk-managed-identity-clientid)'
@@ -0,0 +1,94 @@
1
+ trigger:
2
+ - master
3
+
4
+ pr:
5
+ - master
6
+
7
+ variables:
8
+ - name: api-level
9
+ value: '27'
10
+
11
+ pool:
12
+ vmImage: 'macOS-12'
13
+
14
+ stages:
15
+ - stage: RunTests
16
+ displayName: 'Run Android & IOS tests'
17
+ jobs:
18
+ - job: TestAndroid
19
+ timeoutInMinutes: 120
20
+ displayName: 'Test android'
21
+ steps:
22
+
23
+ - script: |
24
+ adb devices
25
+ displayName: 'Start adb server'
26
+
27
+ - script: |
28
+ $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-$(api-level);google_apis;x86"
29
+ displayName: 'Download system image'
30
+
31
+ - script: |
32
+ $ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestEmulator --abi google_apis/x86 --package 'system-images;android-$(api-level);google_apis;x86' --device "Nexus 6P"
33
+ displayName: 'Creating Android emulator'
34
+
35
+ - script: |
36
+ $ANDROID_HOME/emulator/emulator -avd TestEmulator -noaudio -no-window -no-snapshot-save -no-boot-anim -memory 6144 &
37
+ displayName: 'Start Android emulator'
38
+
39
+ - script: |
40
+ $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
41
+ displayName: 'Wait for emulator to boot'
42
+
43
+ - script: |
44
+ adb shell settings put global window_animation_scale 0.0
45
+ displayName: 'Disable animations and transitions'
46
+
47
+ - script: |
48
+ adb shell settings put global transition_animation_scale 0.0
49
+ displayName: 'Disable animations and transitions'
50
+
51
+ - script: |
52
+ adb shell settings put global animator_duration_scale 0.0
53
+ displayName: 'Disable animations and transitions'
54
+
55
+
56
+ - task: JavaToolInstaller@0
57
+ inputs:
58
+ versionSpec: '11'
59
+ jdkArchitectureOption: 'x64'
60
+ jdkSourceOption: 'PreInstalled'
61
+ displayName: 'Change Java version'
62
+
63
+ - script: |
64
+ npm install
65
+ displayName: 'Package Installation'
66
+
67
+ - script: |
68
+ npm run build:tests && npm run test:setup:android
69
+ displayName: 'Setup Android tests'
70
+
71
+ - script: |
72
+ npm run test:fast:android
73
+ displayName: 'Run Android test'
74
+
75
+ - job: TestIOS
76
+ timeoutInMinutes: 120
77
+ displayName: 'Test IOS'
78
+ steps:
79
+
80
+ - script: |
81
+ npm install
82
+ displayName: 'Install dependencies'
83
+
84
+ - script: |
85
+ npm run build:tests && npm run test:setup:ios
86
+ displayName: 'Setup iOS tests'
87
+
88
+ - script: |
89
+ npm run test:fast:ios
90
+ displayName: 'Run tests'
91
+
92
+
93
+
94
+
@@ -0,0 +1,14 @@
1
+ {
2
+ "tool": "Credential Scanner",
3
+ "suppressions": [
4
+ {
5
+ "file": "/Examples/CodePushDemoApp/android/app/debug.keystore",
6
+ "_justification": "Used only in DemoApp"
7
+ },
8
+ {
9
+ "file": "/Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp/CodePushDemoAppCpp_TemporaryKey.pfx",
10
+ "_justification": "Used only in DemoApp"
11
+ }
12
+ ]
13
+ }
14
+
package/CONTRIBUTING.md CHANGED
@@ -37,10 +37,10 @@ Follow these steps to test your modifications to the plugin manually:
37
37
 
38
38
  First, make sure you have installed the dependencies for the plugin by following the steps above.
39
39
 
40
- Then, make sure you have installed `react-native-cli`.
40
+ Then, make sure you have installed `react-native`.
41
41
 
42
42
  ```
43
- npm install -g react-native-cli
43
+ npm install -g react-native
44
44
  ```
45
45
 
46
46
  To run Android tests, make sure you have `sdk\tools`, `sdk\emulator` and `sdk\platform-tools` in your PATH.
@@ -131,4 +131,4 @@ To run the core unit tests on Android and pull the plugin from NPM:
131
131
  NPM=true CORE=true npm run test:android
132
132
  ```
133
133
 
134
- ...and so on!
134
+ ...and so on!
package/CodePush.js CHANGED
@@ -531,42 +531,41 @@ function codePushify(options = {}) {
531
531
  );
532
532
  }
533
533
 
534
- var decorator = (RootComponent) => {
535
- const extended = class CodePushComponent extends React.Component {
534
+ const decorator = (RootComponent) => {
535
+ class CodePushComponent extends React.Component {
536
+ constructor(props) {
537
+ super(props);
538
+ this.rootComponentRef = React.createRef();
539
+ }
540
+
536
541
  componentDidMount() {
537
542
  if (options.checkFrequency === CodePush.CheckFrequency.MANUAL) {
538
543
  CodePush.notifyAppReady();
539
544
  } else {
540
- let rootComponentInstance = this.refs.rootComponent;
545
+ const rootComponentInstance = this.rootComponentRef.current;
541
546
 
542
547
  let syncStatusCallback;
543
548
  if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
544
- syncStatusCallback = rootComponentInstance.codePushStatusDidChange;
545
- if (rootComponentInstance instanceof React.Component) {
546
- syncStatusCallback = syncStatusCallback.bind(rootComponentInstance);
547
- }
549
+ syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
548
550
  }
549
551
 
550
552
  let downloadProgressCallback;
551
553
  if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
552
- downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress;
553
- if (rootComponentInstance instanceof React.Component) {
554
- downloadProgressCallback = downloadProgressCallback.bind(rootComponentInstance);
555
- }
554
+ downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
556
555
  }
557
556
 
558
557
  let handleBinaryVersionMismatchCallback;
559
558
  if (rootComponentInstance && rootComponentInstance.codePushOnBinaryVersionMismatch) {
560
- handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch;
561
- if (rootComponentInstance instanceof React.Component) {
562
- handleBinaryVersionMismatchCallback = handleBinaryVersionMismatchCallback.bind(rootComponentInstance);
563
- }
559
+ handleBinaryVersionMismatchCallback = rootComponentInstance.codePushOnBinaryVersionMismatch.bind(rootComponentInstance);
564
560
  }
565
561
 
566
562
  CodePush.sync(options, syncStatusCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback);
563
+
567
564
  if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
568
565
  ReactNative.AppState.addEventListener("change", (newState) => {
569
- newState === "active" && CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
566
+ if (newState === "active") {
567
+ CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
568
+ }
570
569
  });
571
570
  }
572
571
  }
@@ -575,17 +574,17 @@ function codePushify(options = {}) {
575
574
  render() {
576
575
  const props = {...this.props};
577
576
 
578
- // we can set ref property on class components only (not stateless)
579
- // check it by render method
580
- if (RootComponent.prototype.render) {
581
- props.ref = "rootComponent";
577
+ // We can set ref property on class components only (not stateless)
578
+ // Check it by render method
579
+ if (RootComponent.prototype && RootComponent.prototype.render) {
580
+ props.ref = this.rootComponentRef;
582
581
  }
583
582
 
584
583
  return <RootComponent {...props} />
585
584
  }
586
585
  }
587
586
 
588
- return hoistStatics(extended, RootComponent);
587
+ return hoistStatics(CodePushComponent, RootComponent);
589
588
  }
590
589
 
591
590
  if (typeof options === "function") {
package/CodePush.podspec CHANGED
@@ -10,8 +10,8 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.homepage = package['homepage']
12
12
  s.source = { :git => 'https://github.com/appzung/react-native-code-push.git', :tag => "v#{s.version}"}
13
- s.ios.deployment_target = '9.0'
14
- s.tvos.deployment_target = '9.0'
13
+ s.ios.deployment_target = '15.5'
14
+ s.tvos.deployment_target = '15.5'
15
15
  s.preserve_paths = '*.js'
16
16
  s.library = 'z'
17
17
  s.source_files = 'ios/CodePush/*.{h,m}'
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
21
21
  # we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and
22
22
  # linked properly at a parent workspace level.
23
23
  s.dependency 'React-Core'
24
- s.dependency 'SSZipArchive', '~> 2.2.2'
24
+ s.dependency 'SSZipArchive', '~> 2.5.5'
25
25
  s.dependency 'JWT', '~> 3.0.0-beta.12'
26
26
  s.dependency 'Base64', '~> 1.1'
27
27
  end
package/README.md CHANGED
@@ -3,7 +3,9 @@
3
3
  #### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush
4
4
 
5
5
  # React Native Module for CodePush
6
-
6
+ > [!WARNING]
7
+ > React Native CodePush won't support new Architecture. In order to use this plugin on React Native versions starting from 0.76 you will need to [opt out](https://reactnative.dev/blog/2024/10/23/the-new-architecture-is-here#opt-out) from new architecture.
8
+ >
7
9
  *Note: This README is only relevant to the latest version of our plugin. If you are using an older version, please switch to the relevant tag on [our GitHub repo](https://github.com/microsoft/react-native-code-push) to view the docs for that particular version.*
8
10
 
9
11
  ![Switching tags](https://user-images.githubusercontent.com/42337914/57237511-0835de80-7030-11e9-88fa-64eb200478d0.png)
@@ -75,7 +77,8 @@ We try our best to maintain backwards compatibility of our plugin with previous
75
77
  | v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
76
78
  | v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |
77
79
  | v0.62-v0.64 | v6.2+ *(RN removed LiveReload)* |
78
- | v0.65-v0.69 | v7.2+ *(RN updated iPhone-target-version)* |
80
+ | v0.65-v0.70 | v7.0+ *(RN updated iPhone-target-version)* |
81
+ | v0.71 | v8.0+ *(RN moved to react-native-gradle-plugin)* |
79
82
 
80
83
  *NOTE: `react-native-code-push` versions lower than **[v5.7.0](https://github.com/microsoft/react-native-code-push/releases/tag/v5.7.0)** will stop working in the near future. You can find more information in our [documentation](https://github.com/microsoft/code-push/blob/master/migration-notice.md).*
81
84
 
@@ -276,7 +279,7 @@ Once your app is configured and distributed to your users, and you have made som
276
279
 
277
280
  *NOTE: Before you can start releasing updates, please log into App Center by running the `appcenter login` command.*
278
281
 
279
- In it's the most basic form, this command only requires one parameter: your owner name + "/" + app name.
282
+ In its most basic form, this command only requires one parameter: your owner name + "/" + app name.
280
283
 
281
284
  ```shell
282
285
  appcenter codepush release-react -a <ownerName>/<appName>
@@ -387,7 +390,6 @@ The React Native community has graciously created some awesome open source apps
387
390
 
388
391
  Additionally, if you're looking to get started with React Native + CodePush, and are looking for an awesome starter kit, you should check out the following:
389
392
 
390
- * [Native Starter Pro](http://strapmobile.com/native-starter-pro/)
391
393
  * [Pepperoni](http://getpepperoni.com/)
392
394
 
393
395
  *Note: If you've developed a React Native app using CodePush, that is also open-source, please let us know. We would love to add it to this list!*
@@ -432,7 +434,7 @@ In addition to being able to use the CodePush CLI to "manually" release updates,
432
434
  * [Visual Studio Team Services](https://marketplace.visualstudio.com/items?itemName=ms-vsclient.code-push) - *NOTE: VSTS also has extensions for publishing to [HockeyApp](https://marketplace.visualstudio.com/items?itemName=ms.hockeyapp) and the [Google Play](https://github.com/microsoft/google-play-vsts-extension) store, so it provides a pretty great mobile CD solution in general.*
433
435
  * [Travis CI](https://github.com/mondora/code-push-travis-cli)
434
436
 
435
- Additionally, if you'd like more details of what a complete mobile CI/CD workflow can look like, which includes CodePush, check out this [excellent article](https://zeemee.engineering/zeemee-engineering-and-the-quest-for-the-holy-mobile-dev-grail-1310be4953d1#.zfwaxtbco) by the [ZeeMee engineering team](https://zeemee.engineering).
437
+ Additionally, if you'd like more details of what a complete mobile CI/CD workflow can look like, which includes CodePush, check out this [excellent article](https://medium.com/zeemee-engineering/zeemee-engineering-and-the-quest-for-the-holy-mobile-dev-grail-1310be4953d1) by the [ZeeMee engineering team](https://www.zeemee.com/).
436
438
 
437
439
  ### TypeScript Consumption
438
440
 
@@ -6,6 +6,8 @@ def DEFAULT_TARGET_SDK_VERSION = 26
6
6
  def DEFAULT_MIN_SDK_VERSION = 16
7
7
 
8
8
  android {
9
+ namespace "com.microsoft.codepush.react"
10
+
9
11
  compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
10
12
  buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
11
13
 
@@ -27,5 +29,5 @@ android {
27
29
 
28
30
  dependencies {
29
31
  implementation "com.facebook.react:react-native:+"
30
- implementation 'com.nimbusds:nimbus-jose-jwt:5.1'
32
+ implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
31
33
  }
@@ -1,10 +1,5 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.microsoft.codepush.react">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
 
4
3
  <uses-permission android:name="android.permission.INTERNET" />
5
4
 
6
- <application>
7
- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
8
- </application>
9
-
10
- </manifest>
5
+ </manifest>
@@ -10,8 +10,8 @@ import com.facebook.react.ReactPackage;
10
10
  import com.facebook.react.bridge.JavaScriptModule;
11
11
  import com.facebook.react.bridge.NativeModule;
12
12
  import com.facebook.react.bridge.ReactApplicationContext;
13
- import com.facebook.react.devsupport.DevInternalSettings;
14
13
  import com.facebook.react.devsupport.interfaces.DevSupportManager;
14
+ import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
15
15
  import com.facebook.react.uimanager.ViewManager;
16
16
 
17
17
  import org.json.JSONException;
@@ -152,12 +152,12 @@ public class CodePush implements ReactPackage {
152
152
  if (instanceManager != null) {
153
153
  DevSupportManager devSupportManager = instanceManager.getDevSupportManager();
154
154
  if (devSupportManager != null) {
155
- DevInternalSettings devInternalSettings = (DevInternalSettings)devSupportManager.getDevSettings();
156
- Method[] methods = devInternalSettings.getClass().getMethods();
155
+ DeveloperSettings devSettings = devSupportManager.getDevSettings();
156
+ Method[] methods = devSettings.getClass().getMethods();
157
157
  for (Method m : methods) {
158
158
  if (m.getName().equals("isReloadOnJSChangeEnabled")) {
159
159
  try {
160
- return (boolean) m.invoke(devInternalSettings);
160
+ return (boolean) m.invoke(devSettings);
161
161
  } catch (Exception x) {
162
162
  return false;
163
163
  }
@@ -295,7 +295,16 @@ public class CodePush implements ReactPackage {
295
295
 
296
296
  JSONObject pendingUpdate = mSettingsManager.getPendingUpdate();
297
297
  if (pendingUpdate != null) {
298
- JSONObject packageMetadata = this.mUpdateManager.getCurrentPackage();
298
+ JSONObject packageMetadata = null;
299
+
300
+ try {
301
+ packageMetadata = this.mUpdateManager.getCurrentPackage();
302
+ } catch (CodePushMalformedDataException e) {
303
+ // We need to recover the app in case 'codepush.json' is corrupted
304
+ CodePushUtils.log(e);
305
+ clearUpdates();
306
+ return;
307
+ }
299
308
  if (packageMetadata == null || !isPackageBundleLatest(packageMetadata) && hasBinaryVersionChanged(packageMetadata)) {
300
309
  CodePushUtils.log("Skipping initializeUpdateAfterRestart(), binary version is newer");
301
310
  return;
@@ -31,4 +31,5 @@ public class CodePushConstants {
31
31
  public static final String LATEST_ROLLBACK_PACKAGE_HASH_KEY = "packageHash";
32
32
  public static final String LATEST_ROLLBACK_TIME_KEY = "time";
33
33
  public static final String LATEST_ROLLBACK_COUNT_KEY = "count";
34
+ public static final String CLIENT_UNIQUE_ID_KEY = "clientUniqueId";
34
35
  }
@@ -1,6 +1,7 @@
1
1
  package com.microsoft.codepush.react;
2
2
 
3
3
  import android.app.Activity;
4
+ import android.content.SharedPreferences;
4
5
  import android.os.AsyncTask;
5
6
  import android.os.Handler;
6
7
  import android.os.Looper;
@@ -34,6 +35,7 @@ import java.util.Date;
34
35
  import java.util.HashMap;
35
36
  import java.util.List;
36
37
  import java.util.Map;
38
+ import java.util.UUID;
37
39
 
38
40
  public class CodePushNativeModule extends ReactContextBaseJavaModule {
39
41
  private String mBinaryContentsHash = null;
@@ -60,7 +62,13 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
60
62
 
61
63
  // Initialize module state while we have a reference to the current context.
62
64
  mBinaryContentsHash = CodePushUpdateUtils.getHashForBinaryContents(reactContext, mCodePush.isDebugMode());
63
- mClientUniqueId = Settings.Secure.getString(reactContext.getContentResolver(), Settings.Secure.ANDROID_ID);
65
+
66
+ SharedPreferences preferences = codePush.getContext().getSharedPreferences(CodePushConstants.CODE_PUSH_PREFERENCES, 0);
67
+ mClientUniqueId = preferences.getString(CodePushConstants.CLIENT_UNIQUE_ID_KEY, null);
68
+ if (mClientUniqueId == null) {
69
+ mClientUniqueId = UUID.randomUUID().toString();
70
+ preferences.edit().putString(CodePushConstants.CLIENT_UNIQUE_ID_KEY, mClientUniqueId).apply();
71
+ }
64
72
  }
65
73
 
66
74
  @Override
@@ -3,11 +3,11 @@ package com.microsoft.codepush.react;
3
3
  import android.content.Context;
4
4
  import android.util.Base64;
5
5
 
6
- import java.security.interfaces.*;
6
+ import com.nimbusds.jose.JWSVerifier;
7
+ import com.nimbusds.jose.crypto.RSASSAVerifier;
8
+ import com.nimbusds.jwt.SignedJWT;
7
9
 
8
- import com.nimbusds.jose.*;
9
- import com.nimbusds.jose.crypto.*;
10
- import com.nimbusds.jwt.*;
10
+ import java.security.interfaces.*;
11
11
 
12
12
  import org.json.JSONArray;
13
13
  import org.json.JSONException;
@@ -85,8 +85,12 @@ public class CodePushUpdateUtils {
85
85
  throw new CodePushUnknownException("Unable to compute hash of update contents.", e);
86
86
  } finally {
87
87
  try {
88
- if (digestInputStream != null) digestInputStream.close();
89
- if (dataStream != null) dataStream.close();
88
+ if (digestInputStream != null) {
89
+ digestInputStream.close();
90
+ }
91
+ if (dataStream != null) {
92
+ dataStream.close();
93
+ }
90
94
  } catch (IOException e) {
91
95
  e.printStackTrace();
92
96
  }
@@ -97,6 +101,10 @@ public class CodePushUpdateUtils {
97
101
  }
98
102
 
99
103
  public static void copyNecessaryFilesFromCurrentPackage(String diffManifestFilePath, String currentPackageFolderPath, String newPackageFolderPath) throws IOException {
104
+ if (currentPackageFolderPath == null || !new File(currentPackageFolderPath).exists()) {
105
+ CodePushUtils.log("Unable to copy files from current package during diff update, because currentPackageFolderPath is invalid.");
106
+ return;
107
+ }
100
108
  FileUtils.copyDirectoryContents(currentPackageFolderPath, newPackageFolderPath);
101
109
  JSONObject diffManifest = CodePushUtils.getJsonObjectFromFile(diffManifestFilePath);
102
110
  try {
@@ -183,7 +191,7 @@ public class CodePushUpdateUtils {
183
191
  public static Map<String, Object> verifyAndDecodeJWT(String jwt, PublicKey publicKey) {
184
192
  try {
185
193
  SignedJWT signedJWT = SignedJWT.parse(jwt);
186
- JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey)publicKey);
194
+ JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey) publicKey);
187
195
  if (signedJWT.verify(verifier)) {
188
196
  Map<String, Object> claims = signedJWT.getJWTClaimsSet().getClaims();
189
197
  CodePushUtils.log("JWT verification succeeded, payload content: " + claims.toString());
@@ -216,7 +224,7 @@ public class CodePushUpdateUtils {
216
224
  }
217
225
  }
218
226
 
219
- public static String getSignatureFilePath(String updateFolderPath){
227
+ public static String getSignatureFilePath(String updateFolderPath) {
220
228
  return CodePushUtils.appendPathComponent(
221
229
  CodePushUtils.appendPathComponent(updateFolderPath, CodePushConstants.CODE_PUSH_FOLDER_PREFIX),
222
230
  CodePushConstants.BUNDLE_JWT_FILE
@@ -253,7 +261,7 @@ public class CodePushUpdateUtils {
253
261
  throw new CodePushInvalidUpdateException("The update could not be verified because it was not signed by a trusted party.");
254
262
  }
255
263
 
256
- final String contentHash = (String)claims.get("contentHash");
264
+ final String contentHash = (String) claims.get("contentHash");
257
265
  if (contentHash == null) {
258
266
  throw new CodePushInvalidUpdateException("The update could not be verified because the signature did not specify a content hash.");
259
267
  }
@@ -264,4 +272,4 @@ public class CodePushUpdateUtils {
264
272
 
265
273
  CodePushUtils.log("The update contents succeeded the code signing check.");
266
274
  }
267
- }
275
+ }
@@ -67,7 +67,9 @@ public class CodePushUtils {
67
67
  String key = it.next();
68
68
  Object obj = null;
69
69
  try {
70
- obj = jsonObj.get(key);
70
+ if (!jsonObj.isNull(key)) {
71
+ obj = jsonObj.get(key);
72
+ }
71
73
  } catch (JSONException jsonException) {
72
74
  // Should not happen.
73
75
  throw new CodePushUnknownException("Key " + key + " should exist in " + jsonObj.toString() + ".", jsonException);
@@ -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'
@@ -13,8 +14,11 @@ buildscript {
13
14
  }
14
15
 
15
16
  allprojects {
17
+ android {
18
+ namespace "com.microsoft.codepush.react"
19
+ }
16
20
  repositories {
17
21
  mavenLocal()
18
- jcenter()
22
+ mavenCentral()
19
23
  }
20
24
  }