@srcpush/react-native-code-push 1.0.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/.azurepipelines/build-rn-code-push-1es.yml +104 -0
- package/.azurepipelines/test-rn-code-push.yml +94 -0
- package/.config/CredScanSuppressions.json +14 -0
- package/.node-version +1 -0
- package/AlertAdapter.js +24 -0
- package/CONTRIBUTING.md +134 -0
- package/CodePush.js +671 -0
- package/CodePush.podspec +28 -0
- package/LICENSE.md +13 -0
- package/README.md +403 -0
- package/SECURITY.md +41 -0
- package/android/app/build.gradle +48 -0
- package/android/app/proguard-rules.pro +33 -0
- package/android/app/src/main/AndroidManifest.xml +5 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +444 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +35 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +848 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +383 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +275 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +238 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +203 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactHostHolder.java +11 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
- package/android/build.gradle +24 -0
- package/android/codepush.gradle +162 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +20 -0
- package/android/gradlew +164 -0
- package/android/gradlew.bat +90 -0
- package/android/settings.gradle +1 -0
- package/docs/api-android.md +53 -0
- package/docs/api-ios.md +31 -0
- package/docs/api-js.md +592 -0
- package/docs/multi-deployment-testing-android.md +54 -0
- package/docs/multi-deployment-testing-ios.md +60 -0
- package/docs/setup-android.md +93 -0
- package/docs/setup-ios.md +144 -0
- package/docs/setup-windows.md +121 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
- package/ios/CodePush/Base64/README.md +47 -0
- package/ios/CodePush/CodePush.h +235 -0
- package/ios/CodePush/CodePush.m +1122 -0
- package/ios/CodePush/CodePushConfig.m +116 -0
- package/ios/CodePush/CodePushDownloadHandler.m +130 -0
- package/ios/CodePush/CodePushErrorUtils.m +20 -0
- package/ios/CodePush/CodePushPackage.m +602 -0
- package/ios/CodePush/CodePushTelemetryManager.m +175 -0
- package/ios/CodePush/CodePushUpdateUtils.m +376 -0
- package/ios/CodePush/CodePushUtils.m +9 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
- package/ios/CodePush/JWT/LICENSE +19 -0
- package/ios/CodePush/JWT/README.md +489 -0
- package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
- package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +178 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1496 -0
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
- package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +1052 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/logging.js +6 -0
- package/package-mixins.js +68 -0
- package/package.json +86 -0
- package/react-native.config.js +11 -0
- package/request-fetch-adapter.js +52 -0
- package/scripts/generateBundledResourcesHash.js +125 -0
- package/scripts/getFilesInFolder.js +19 -0
- package/scripts/postlink/android/postlink.js +87 -0
- package/scripts/postlink/ios/postlink.js +116 -0
- package/scripts/postlink/run.js +11 -0
- package/scripts/postunlink/android/postunlink.js +74 -0
- package/scripts/postunlink/ios/postunlink.js +87 -0
- package/scripts/postunlink/run.js +11 -0
- package/scripts/recordFilesBeforeBundleCommand.js +41 -0
- package/scripts/tools/linkToolsAndroid.js +57 -0
- package/scripts/tools/linkToolsIos.js +130 -0
- package/tsconfig.json +17 -0
- package/tslint.json +32 -0
- package/typings/react-native-code-push.d.ts +455 -0
- package/windows/CodePush/CodePush.def +3 -0
- package/windows/CodePush/CodePush.vcxproj +198 -0
- package/windows/CodePush/CodePush.vcxproj.filters +91 -0
- package/windows/CodePush/CodePushConfig.cpp +104 -0
- package/windows/CodePush/CodePushConfig.h +66 -0
- package/windows/CodePush/CodePushConfig.idl +12 -0
- package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
- package/windows/CodePush/CodePushDownloadHandler.h +32 -0
- package/windows/CodePush/CodePushNativeModule.cpp +934 -0
- package/windows/CodePush/CodePushNativeModule.h +247 -0
- package/windows/CodePush/CodePushPackage.cpp +456 -0
- package/windows/CodePush/CodePushPackage.h +49 -0
- package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
- package/windows/CodePush/CodePushTelemetryManager.h +29 -0
- package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
- package/windows/CodePush/CodePushUpdateUtils.h +38 -0
- package/windows/CodePush/CodePushUtils.cpp +29 -0
- package/windows/CodePush/CodePushUtils.h +18 -0
- package/windows/CodePush/FileUtils.cpp +131 -0
- package/windows/CodePush/FileUtils.h +28 -0
- package/windows/CodePush/PropertySheet.props +16 -0
- package/windows/CodePush/ReactPackageProvider.cpp +15 -0
- package/windows/CodePush/ReactPackageProvider.h +22 -0
- package/windows/CodePush/ReactPackageProvider.idl +9 -0
- package/windows/CodePush/miniz/LICENSE +22 -0
- package/windows/CodePush/miniz/miniz.c +7657 -0
- package/windows/CodePush/miniz/miniz.h +1338 -0
- package/windows/CodePush/miniz/readme.md +37 -0
- package/windows/CodePush/packages.config +4 -0
- package/windows/CodePush/pch.cpp +1 -0
- package/windows/CodePush/pch.h +4 -0
- package/windows-legacy/CodePush/CodePush.csproj +128 -0
- package/windows-legacy/CodePush/CodePushUtils.cs +47 -0
- package/windows-legacy/CodePush/FileUtils.cs +40 -0
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +29 -0
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +33 -0
- package/windows-legacy/CodePush/UpdateManager.cs +305 -0
- package/windows-legacy/CodePush/UpdateUtils.cs +46 -0
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +103 -0
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +158 -0
- package/windows-legacy/CodePush.Net46/FileUtils.cs +55 -0
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +330 -0
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +70 -0
- package/windows-legacy/CodePush.Net46/packages.config +5 -0
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
- package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
- package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +22 -0
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +13 -0
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +35 -0
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +329 -0
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +235 -0
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +70 -0
- package/windows-legacy/CodePush.Shared/InstallMode.cs +9 -0
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +148 -0
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +250 -0
- package/windows-legacy/CodePush.Shared/UpdateState.cs +9 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
using CodePush.Net46.Adapters.Http;
|
|
2
|
+
using Newtonsoft.Json;
|
|
3
|
+
using Newtonsoft.Json.Linq;
|
|
4
|
+
using PCLStorage;
|
|
5
|
+
using System;
|
|
6
|
+
using System.IO;
|
|
7
|
+
using System.IO.Compression;
|
|
8
|
+
using System.Runtime.CompilerServices;
|
|
9
|
+
using System.Threading.Tasks;
|
|
10
|
+
|
|
11
|
+
namespace CodePush.ReactNative
|
|
12
|
+
{
|
|
13
|
+
internal class UpdateManager
|
|
14
|
+
{
|
|
15
|
+
#region Internal methods
|
|
16
|
+
|
|
17
|
+
internal async Task ClearUpdatesAsync()
|
|
18
|
+
{
|
|
19
|
+
await (await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false)).DeleteAsync().ConfigureAwait(false);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
internal async Task DownloadPackageAsync(JObject updatePackage, string expectedBundleFileName, Progress<HttpProgress> downloadProgress)
|
|
23
|
+
{
|
|
24
|
+
// Using its hash, get the folder where the new update will be saved
|
|
25
|
+
var codePushFolder = await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false);
|
|
26
|
+
var newUpdateHash = (string)updatePackage[CodePushConstants.PackageHashKey];
|
|
27
|
+
var newUpdateFolder = await GetPackageFolderAsync(newUpdateHash, false).ConfigureAwait(false);
|
|
28
|
+
if (newUpdateFolder != null)
|
|
29
|
+
{
|
|
30
|
+
// This removes any stale data in newUpdateFolder that could have been left
|
|
31
|
+
// uncleared due to a crash or error during the download or install process.
|
|
32
|
+
await newUpdateFolder.DeleteAsync().ConfigureAwait(false);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
newUpdateFolder = await GetPackageFolderAsync(newUpdateHash, true).ConfigureAwait(false);
|
|
36
|
+
var newUpdateMetadataFile = await newUpdateFolder.CreateFileAsync(CodePushConstants.PackageFileName, CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);
|
|
37
|
+
var downloadUrlString = (string)updatePackage[CodePushConstants.DownloadUrlKey];
|
|
38
|
+
var downloadFile = await GetDownloadFileAsync().ConfigureAwait(false);
|
|
39
|
+
|
|
40
|
+
await UpdateUtils.DownloadBundleAsync(downloadUrlString, downloadFile.Path, downloadProgress);
|
|
41
|
+
|
|
42
|
+
try
|
|
43
|
+
{
|
|
44
|
+
// Unzip the downloaded file and then delete the zip
|
|
45
|
+
var unzippedFolder = await CreateUnzippedFolderAsync().ConfigureAwait(false);
|
|
46
|
+
/**
|
|
47
|
+
* TODO:
|
|
48
|
+
* 1) ZipFile.ExtractToDirectory is not reliable and throws exception if:
|
|
49
|
+
* - path is too long (> 250 chars)
|
|
50
|
+
*
|
|
51
|
+
* 2) Un-zipping is quite long operation. Does it make sense for async?
|
|
52
|
+
* await UpdateUtils.UnzipBundleAsync(downloadFile.Path, unzippedFolder.Path);
|
|
53
|
+
*
|
|
54
|
+
* Possible implementation
|
|
55
|
+
*
|
|
56
|
+
* internal async static Task UnzipBundleAsync(string zipFileName, string targetDir)
|
|
57
|
+
* {
|
|
58
|
+
* await Task.Run(() =>
|
|
59
|
+
* {
|
|
60
|
+
* ZipFile.ExtractToDirectory(zipFileName, targetDir)
|
|
61
|
+
* return Task.CompletedTask;
|
|
62
|
+
* });
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
ZipFile.ExtractToDirectory(downloadFile.Path, unzippedFolder.Path);
|
|
66
|
+
await downloadFile.DeleteAsync().ConfigureAwait(false);
|
|
67
|
+
|
|
68
|
+
// Merge contents with current update based on the manifest
|
|
69
|
+
IFile diffManifestFile = null;
|
|
70
|
+
try
|
|
71
|
+
{
|
|
72
|
+
diffManifestFile = await unzippedFolder.GetFileAsync(CodePushConstants.DiffManifestFileName).ConfigureAwait(false);
|
|
73
|
+
}
|
|
74
|
+
catch (FileNotFoundException)
|
|
75
|
+
{
|
|
76
|
+
//file may not be present in folder just skip it
|
|
77
|
+
}
|
|
78
|
+
if (diffManifestFile != null)
|
|
79
|
+
{
|
|
80
|
+
var currentPackageFolder = await GetCurrentPackageFolderAsync().ConfigureAwait(false);
|
|
81
|
+
if (currentPackageFolder == null)
|
|
82
|
+
{
|
|
83
|
+
throw new InvalidDataException("Received a diff update, but there is no current version to diff against.");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
await UpdateUtils.CopyNecessaryFilesFromCurrentPackageAsync(diffManifestFile, currentPackageFolder, newUpdateFolder).ConfigureAwait(false);
|
|
87
|
+
await diffManifestFile.DeleteAsync().ConfigureAwait(false);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await FileUtils.MergeFoldersAsync(unzippedFolder, newUpdateFolder).ConfigureAwait(false);
|
|
91
|
+
await unzippedFolder.DeleteAsync().ConfigureAwait(false);
|
|
92
|
+
|
|
93
|
+
// For zip updates, we need to find the relative path to the jsBundle and save it in the
|
|
94
|
+
// metadata so that we can find and run it easily the next time.
|
|
95
|
+
var relativeBundlePath = await UpdateUtils.FindJSBundleInUpdateContentsAsync(newUpdateFolder, expectedBundleFileName).ConfigureAwait(false);
|
|
96
|
+
if (relativeBundlePath == null)
|
|
97
|
+
{
|
|
98
|
+
throw new InvalidDataException("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.");
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
{
|
|
102
|
+
if (diffManifestFile != null)
|
|
103
|
+
{
|
|
104
|
+
// TODO verify hash for diff update
|
|
105
|
+
// CodePushUpdateUtils.verifyHashForDiffUpdate(newUpdateFolderPath, newUpdateHash);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
updatePackage[CodePushConstants.RelativeBundlePathKey] = relativeBundlePath;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (InvalidDataException)
|
|
112
|
+
{
|
|
113
|
+
// Downloaded file is not a zip, assume it is a jsbundle
|
|
114
|
+
await downloadFile.RenameAsync(expectedBundleFileName).ConfigureAwait(false);
|
|
115
|
+
await downloadFile.MoveAsync(newUpdateFolder.Path, NameCollisionOption.ReplaceExisting).ConfigureAwait(false);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Save metadata to the folder
|
|
119
|
+
await newUpdateMetadataFile.WriteAllTextAsync(JsonConvert.SerializeObject(updatePackage)).ConfigureAwait(false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
internal async Task<JObject> GetCurrentPackageAsync()
|
|
123
|
+
{
|
|
124
|
+
var packageHash = await GetCurrentPackageHashAsync().ConfigureAwait(false);
|
|
125
|
+
return packageHash == null ? null : await GetPackageAsync(packageHash).ConfigureAwait(false);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
internal async Task<IFile> GetCurrentPackageBundleAsync(string bundleFileName)
|
|
129
|
+
{
|
|
130
|
+
var packageFolder = await GetCurrentPackageFolderAsync().ConfigureAwait(false);
|
|
131
|
+
if (packageFolder == null)
|
|
132
|
+
{
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var currentPackage = await GetCurrentPackageAsync().ConfigureAwait(false);
|
|
137
|
+
var relativeBundlePath = (string)currentPackage[CodePushConstants.RelativeBundlePathKey];
|
|
138
|
+
|
|
139
|
+
return relativeBundlePath == null
|
|
140
|
+
? await packageFolder.GetFileAsync(bundleFileName).ConfigureAwait(false)
|
|
141
|
+
: await packageFolder.GetFileAsync(relativeBundlePath).ConfigureAwait(false);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
internal async Task<string> GetCurrentPackageHashAsync()
|
|
145
|
+
{
|
|
146
|
+
var info = await GetCurrentPackageInfoAsync().ConfigureAwait(false);
|
|
147
|
+
var currentPackageShortHash = (string)info[CodePushConstants.CurrentPackageKey];
|
|
148
|
+
if (currentPackageShortHash == null)
|
|
149
|
+
{
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var currentPackageMetadata = await GetPackageAsync(currentPackageShortHash).ConfigureAwait(false);
|
|
154
|
+
return currentPackageMetadata == null ? null : (string)currentPackageMetadata[CodePushConstants.PackageHashKey];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
internal async Task<JObject> GetPackageAsync(string packageHash)
|
|
158
|
+
{
|
|
159
|
+
var packageFolder = await GetPackageFolderAsync(packageHash, false).ConfigureAwait(false);
|
|
160
|
+
if (packageFolder == null)
|
|
161
|
+
{
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
try
|
|
166
|
+
{
|
|
167
|
+
var packageFile = await packageFolder.GetFileAsync(CodePushConstants.PackageFileName).ConfigureAwait(false);
|
|
168
|
+
return await CodePushUtils.GetJObjectFromFileAsync(packageFile).ConfigureAwait(false);
|
|
169
|
+
}
|
|
170
|
+
catch (IOException)
|
|
171
|
+
{
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
internal async Task<IFolder> GetPackageFolderAsync(string packageHash, bool createIfNotExists)
|
|
177
|
+
{
|
|
178
|
+
var codePushFolder = await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false);
|
|
179
|
+
try
|
|
180
|
+
{
|
|
181
|
+
packageHash = ShortenPackageHash(packageHash);
|
|
182
|
+
return createIfNotExists
|
|
183
|
+
? await codePushFolder.CreateFolderAsync(packageHash, CreationCollisionOption.OpenIfExists).ConfigureAwait(false)
|
|
184
|
+
: await codePushFolder.GetFolderAsync(packageHash).ConfigureAwait(false);
|
|
185
|
+
}
|
|
186
|
+
catch (FileNotFoundException)
|
|
187
|
+
{
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
catch (DirectoryNotFoundException)
|
|
191
|
+
{
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
internal async Task<JObject> GetPreviousPackageAsync()
|
|
197
|
+
{
|
|
198
|
+
var packageHash = await GetPreviousPackageHashAsync().ConfigureAwait(false);
|
|
199
|
+
return packageHash == null ? null : await GetPackageAsync(packageHash).ConfigureAwait(false);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
internal async Task<string> GetPreviousPackageHashAsync()
|
|
203
|
+
{
|
|
204
|
+
var info = await GetCurrentPackageInfoAsync().ConfigureAwait(false);
|
|
205
|
+
var previousPackageShortHash = (string)info[CodePushConstants.PreviousPackageKey];
|
|
206
|
+
if (previousPackageShortHash == null)
|
|
207
|
+
{
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var previousPackageMetadata = await GetPackageAsync(previousPackageShortHash).ConfigureAwait(false);
|
|
212
|
+
return previousPackageMetadata == null ? null : (string)previousPackageMetadata[CodePushConstants.PackageHashKey];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
internal async Task InstallPackageAsync(JObject updatePackage, bool currentUpdateIsPending)
|
|
216
|
+
{
|
|
217
|
+
var packageHash = (string)updatePackage[CodePushConstants.PackageHashKey];
|
|
218
|
+
var info = await GetCurrentPackageInfoAsync().ConfigureAwait(false);
|
|
219
|
+
if (currentUpdateIsPending)
|
|
220
|
+
{
|
|
221
|
+
// Don't back up current update to the "previous" position because
|
|
222
|
+
// it is an unverified update which should not be rolled back to.
|
|
223
|
+
var currentPackageFolder = await GetCurrentPackageFolderAsync().ConfigureAwait(false);
|
|
224
|
+
if (currentPackageFolder != null)
|
|
225
|
+
{
|
|
226
|
+
await currentPackageFolder.DeleteAsync().ConfigureAwait(false);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else
|
|
230
|
+
{
|
|
231
|
+
var previousPackageHash = await GetPreviousPackageHashAsync().ConfigureAwait(false);
|
|
232
|
+
if (previousPackageHash != null && !previousPackageHash.Equals(packageHash))
|
|
233
|
+
{
|
|
234
|
+
var previousPackageFolder = await GetPackageFolderAsync(previousPackageHash, false).ConfigureAwait(false);
|
|
235
|
+
if (previousPackageFolder != null)
|
|
236
|
+
{
|
|
237
|
+
await previousPackageFolder.DeleteAsync().ConfigureAwait(false);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
info[CodePushConstants.PreviousPackageKey] = info[CodePushConstants.CurrentPackageKey];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
info[CodePushConstants.CurrentPackageKey] = packageHash;
|
|
245
|
+
await UpdateCurrentPackageInfoAsync(info).ConfigureAwait(false);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
internal async Task RollbackPackageAsync()
|
|
249
|
+
{
|
|
250
|
+
var info = await GetCurrentPackageInfoAsync().ConfigureAwait(false);
|
|
251
|
+
var currentPackageFolder = await GetCurrentPackageFolderAsync().ConfigureAwait(false);
|
|
252
|
+
if (currentPackageFolder != null)
|
|
253
|
+
{
|
|
254
|
+
await currentPackageFolder.DeleteAsync().ConfigureAwait(false);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
info[CodePushConstants.CurrentPackageKey] = info[CodePushConstants.PreviousPackageKey];
|
|
258
|
+
info[CodePushConstants.PreviousPackageKey] = null;
|
|
259
|
+
await UpdateCurrentPackageInfoAsync(info).ConfigureAwait(false);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
#endregion
|
|
263
|
+
|
|
264
|
+
#region Private methods
|
|
265
|
+
|
|
266
|
+
private async Task<IFolder> GetCurrentPackageFolderAsync()
|
|
267
|
+
{
|
|
268
|
+
var info = await GetCurrentPackageInfoAsync().ConfigureAwait(false);
|
|
269
|
+
if (info == null)
|
|
270
|
+
{
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
var packageHash = (string)info[CodePushConstants.CurrentPackageKey];
|
|
274
|
+
return packageHash == null ? null : await GetPackageFolderAsync(packageHash, false).ConfigureAwait(false);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private async Task<JObject> GetCurrentPackageInfoAsync()
|
|
278
|
+
{
|
|
279
|
+
var statusFile = await GetStatusFileAsync().ConfigureAwait(false);
|
|
280
|
+
var info = await CodePushUtils.GetJObjectFromFileAsync(statusFile).ConfigureAwait(false);
|
|
281
|
+
|
|
282
|
+
if (info != null)
|
|
283
|
+
{
|
|
284
|
+
return info;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// info file has been corrupted - re-create it
|
|
288
|
+
await statusFile.DeleteAsync().ConfigureAwait(false);
|
|
289
|
+
statusFile = await GetStatusFileAsync().ConfigureAwait(false);
|
|
290
|
+
return await CodePushUtils.GetJObjectFromFileAsync(statusFile).ConfigureAwait(false);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private async Task<IFile> GetDownloadFileAsync()
|
|
294
|
+
{
|
|
295
|
+
var codePushFolder = await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false);
|
|
296
|
+
return await codePushFolder.CreateFileAsync(CodePushConstants.DownloadFileName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private async Task<IFile> GetStatusFileAsync()
|
|
300
|
+
{
|
|
301
|
+
var codePushFolder = await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false);
|
|
302
|
+
return await codePushFolder.CreateFileAsync(CodePushConstants.StatusFileName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private async Task<IFolder> CreateUnzippedFolderAsync()
|
|
306
|
+
{
|
|
307
|
+
var codePushFolder = await UpdateUtils.GetCodePushFolderAsync().ConfigureAwait(false);
|
|
308
|
+
var isUnzippedFolderExists = await codePushFolder.CheckExistsAsync(CodePushConstants.UnzippedFolderName).ConfigureAwait(false);
|
|
309
|
+
|
|
310
|
+
if (isUnzippedFolderExists != ExistenceCheckResult.NotFound)
|
|
311
|
+
{
|
|
312
|
+
await codePushFolder.GetFolderAsync(CodePushConstants.UnzippedFolderName).ContinueWith((existingFolder) => existingFolder.Result.DeleteAsync());
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return await codePushFolder.CreateFolderAsync(CodePushConstants.UnzippedFolderName, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private string ShortenPackageHash(string longPackageHash)
|
|
319
|
+
{
|
|
320
|
+
return longPackageHash.Substring(0, 8);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private async Task UpdateCurrentPackageInfoAsync(JObject packageInfo)
|
|
324
|
+
{
|
|
325
|
+
var file = await GetStatusFileAsync().ConfigureAwait(false);
|
|
326
|
+
await file.WriteAllTextAsync(JsonConvert.SerializeObject(packageInfo)).ConfigureAwait(false);
|
|
327
|
+
}
|
|
328
|
+
#endregion
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
using CodePush.Net46.Adapters.Http;
|
|
2
|
+
using Newtonsoft.Json.Linq;
|
|
3
|
+
using PCLStorage;
|
|
4
|
+
using System;
|
|
5
|
+
using System.IO;
|
|
6
|
+
using System.Net;
|
|
7
|
+
using System.Threading.Tasks;
|
|
8
|
+
|
|
9
|
+
namespace CodePush.ReactNative
|
|
10
|
+
{
|
|
11
|
+
internal class UpdateUtils
|
|
12
|
+
{
|
|
13
|
+
internal async static Task CopyNecessaryFilesFromCurrentPackageAsync(IFile diffManifestFile, IFolder currentPackageFolder, IFolder newPackageFolder)
|
|
14
|
+
{
|
|
15
|
+
await FileUtils.MergeFoldersAsync(currentPackageFolder, newPackageFolder).ConfigureAwait(false);
|
|
16
|
+
JObject diffManifest = await CodePushUtils.GetJObjectFromFileAsync(diffManifestFile).ConfigureAwait(false);
|
|
17
|
+
var deletedFiles = (JArray)diffManifest["deletedFiles"];
|
|
18
|
+
foreach (string fileNameToDelete in deletedFiles)
|
|
19
|
+
{
|
|
20
|
+
var fileToDelete = await newPackageFolder.GetFileAsync(fileNameToDelete).ConfigureAwait(false);
|
|
21
|
+
await fileToDelete.DeleteAsync().ConfigureAwait(false);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
internal async static Task<string> FindJSBundleInUpdateContentsAsync(IFolder updateFolder, string expectedFileName)
|
|
26
|
+
{
|
|
27
|
+
foreach (IFile file in await updateFolder.GetFilesAsync().ConfigureAwait(false))
|
|
28
|
+
{
|
|
29
|
+
string fileName = file.Name;
|
|
30
|
+
if (fileName.Equals(expectedFileName))
|
|
31
|
+
{
|
|
32
|
+
return fileName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
foreach (IFolder folder in await updateFolder.GetFoldersAsync().ConfigureAwait(false))
|
|
37
|
+
{
|
|
38
|
+
string mainBundlePathInSubFolder = await FindJSBundleInUpdateContentsAsync(folder, expectedFileName).ConfigureAwait(false);
|
|
39
|
+
if (mainBundlePathInSubFolder != null)
|
|
40
|
+
{
|
|
41
|
+
return Path.Combine(folder.Name, mainBundlePathInSubFolder);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
internal async static Task DownloadBundleAsync(string url, string fileName, IProgress<HttpProgress> downloadProgress)
|
|
49
|
+
{
|
|
50
|
+
var uri = new Uri(url);
|
|
51
|
+
var client = new WebClient();
|
|
52
|
+
client.DownloadProgressChanged += (s, e) =>
|
|
53
|
+
{
|
|
54
|
+
downloadProgress.Report(new HttpProgress
|
|
55
|
+
{
|
|
56
|
+
BytesReceived = (ulong)e.BytesReceived, //conversion long to ulong is safe
|
|
57
|
+
TotalBytesToReceive = (ulong)e.TotalBytesToReceive //because size can't be negative
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
await client.DownloadFileTaskAsync(uri, fileName);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
internal static async Task<IFolder> GetCodePushFolderAsync()
|
|
65
|
+
{
|
|
66
|
+
var pathToCodePush = Path.Combine(CodePushUtils.GetFileBundlePrefix(), CodePushConstants.CodePushFolderPrefix);
|
|
67
|
+
return await FileSystem.Current.LocalStorage.CreateFolderAsync(pathToCodePush, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
3
|
+
using CodePush.Net46.Adapters.Storage;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
|
|
6
|
+
namespace CodePush.Net46.Test
|
|
7
|
+
{
|
|
8
|
+
[TestClass]
|
|
9
|
+
public class ApplicationDataContainerTest
|
|
10
|
+
{
|
|
11
|
+
readonly static string key1 = "key1";
|
|
12
|
+
readonly static string key2 = "key2";
|
|
13
|
+
readonly static string key3 = "key3";
|
|
14
|
+
|
|
15
|
+
readonly static string val1 = "string data1";
|
|
16
|
+
readonly static string val2 = "string data2";
|
|
17
|
+
readonly static string val3 = "string data1";
|
|
18
|
+
|
|
19
|
+
[TestMethod]
|
|
20
|
+
public void TestInMemmorySet()
|
|
21
|
+
{
|
|
22
|
+
var settings = new ApplicationDataContainer();
|
|
23
|
+
|
|
24
|
+
settings.Values[key1] = val1;
|
|
25
|
+
settings.Values[key2] = val2;
|
|
26
|
+
settings.Values[key3] = val3;
|
|
27
|
+
|
|
28
|
+
Assert.AreEqual(settings.Values[key1], val1);
|
|
29
|
+
Assert.AreEqual(settings.Values[key2], val2);
|
|
30
|
+
Assert.AreEqual(settings.Values[key3], val3);
|
|
31
|
+
|
|
32
|
+
settings.DeleteAsync().Wait();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[TestMethod]
|
|
36
|
+
public void TestInMemmoryReset()
|
|
37
|
+
{
|
|
38
|
+
var settings = new ApplicationDataContainer();
|
|
39
|
+
|
|
40
|
+
settings.Values[key1] = val1;
|
|
41
|
+
settings.Values[key1] = val2;
|
|
42
|
+
settings.Values[key1] = val3;
|
|
43
|
+
|
|
44
|
+
Assert.AreEqual(settings.Values[key1], val3);
|
|
45
|
+
|
|
46
|
+
settings.DeleteAsync().Wait();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[TestMethod]
|
|
50
|
+
public void TestInMemmoryRemove()
|
|
51
|
+
{
|
|
52
|
+
var settings = new ApplicationDataContainer();
|
|
53
|
+
|
|
54
|
+
settings.Values[key1] = val1;
|
|
55
|
+
settings.Values[key2] = val2;
|
|
56
|
+
settings.Values[key3] = val3;
|
|
57
|
+
|
|
58
|
+
settings.Values.Remove(key2);
|
|
59
|
+
|
|
60
|
+
Assert.AreEqual(settings.Values[key1], val1);
|
|
61
|
+
Assert.IsNull(settings.Values[key2]);
|
|
62
|
+
Assert.AreEqual(settings.Values[key3], val3);
|
|
63
|
+
|
|
64
|
+
settings.DeleteAsync().Wait();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[TestMethod]
|
|
68
|
+
public void TestPersistentSet()
|
|
69
|
+
{
|
|
70
|
+
var settings = new ApplicationDataContainer();
|
|
71
|
+
|
|
72
|
+
settings.Values[key1] = val1;
|
|
73
|
+
settings.Values[key2] = val2;
|
|
74
|
+
settings.Values[key3] = val3;
|
|
75
|
+
|
|
76
|
+
settings = new ApplicationDataContainer();
|
|
77
|
+
|
|
78
|
+
Assert.AreEqual(settings.Values[key1], val1);
|
|
79
|
+
Assert.AreEqual(settings.Values[key2], val2);
|
|
80
|
+
Assert.AreEqual(settings.Values[key3], val3);
|
|
81
|
+
|
|
82
|
+
settings.DeleteAsync().Wait();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[TestMethod]
|
|
86
|
+
public void TestPersistentRemove()
|
|
87
|
+
{
|
|
88
|
+
var settings = new ApplicationDataContainer();
|
|
89
|
+
|
|
90
|
+
settings.Values[key1] = val1;
|
|
91
|
+
settings.Values[key2] = val2;
|
|
92
|
+
settings.Values[key3] = val3;
|
|
93
|
+
|
|
94
|
+
settings.Values.Remove(key2);
|
|
95
|
+
|
|
96
|
+
settings = new ApplicationDataContainer();
|
|
97
|
+
|
|
98
|
+
Assert.AreEqual(settings.Values[key1], val1);
|
|
99
|
+
Assert.IsNull(settings.Values[key2]);
|
|
100
|
+
Assert.AreEqual(settings.Values[key3], val3);
|
|
101
|
+
|
|
102
|
+
settings.DeleteAsync().Wait();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
5
|
+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
6
|
+
<ProjectGuid>{BBB48F0B-AF6F-4A14-AFA4-306D3FB0B7CF}</ProjectGuid>
|
|
7
|
+
<OutputType>Library</OutputType>
|
|
8
|
+
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
9
|
+
<RootNamespace>CodePush.Net46.Test</RootNamespace>
|
|
10
|
+
<AssemblyName>CodePush.Net46.Test</AssemblyName>
|
|
11
|
+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
|
12
|
+
<FileAlignment>512</FileAlignment>
|
|
13
|
+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
14
|
+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
|
15
|
+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
16
|
+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
|
17
|
+
<IsCodedUITest>False</IsCodedUITest>
|
|
18
|
+
<TestProjectType>UnitTest</TestProjectType>
|
|
19
|
+
</PropertyGroup>
|
|
20
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
21
|
+
<DebugSymbols>true</DebugSymbols>
|
|
22
|
+
<DebugType>full</DebugType>
|
|
23
|
+
<Optimize>false</Optimize>
|
|
24
|
+
<OutputPath>bin\Debug\</OutputPath>
|
|
25
|
+
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
26
|
+
<ErrorReport>prompt</ErrorReport>
|
|
27
|
+
<WarningLevel>4</WarningLevel>
|
|
28
|
+
</PropertyGroup>
|
|
29
|
+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
30
|
+
<DebugType>pdbonly</DebugType>
|
|
31
|
+
<Optimize>true</Optimize>
|
|
32
|
+
<OutputPath>bin\Release\</OutputPath>
|
|
33
|
+
<DefineConstants>TRACE</DefineConstants>
|
|
34
|
+
<ErrorReport>prompt</ErrorReport>
|
|
35
|
+
<WarningLevel>4</WarningLevel>
|
|
36
|
+
</PropertyGroup>
|
|
37
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
|
38
|
+
<DebugSymbols>true</DebugSymbols>
|
|
39
|
+
<OutputPath>bin\x64\Debug\</OutputPath>
|
|
40
|
+
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
41
|
+
<DebugType>full</DebugType>
|
|
42
|
+
<PlatformTarget>x64</PlatformTarget>
|
|
43
|
+
<ErrorReport>prompt</ErrorReport>
|
|
44
|
+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
45
|
+
</PropertyGroup>
|
|
46
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
|
47
|
+
<OutputPath>bin\x64\Release\</OutputPath>
|
|
48
|
+
<DefineConstants>TRACE</DefineConstants>
|
|
49
|
+
<Optimize>true</Optimize>
|
|
50
|
+
<DebugType>pdbonly</DebugType>
|
|
51
|
+
<PlatformTarget>x64</PlatformTarget>
|
|
52
|
+
<ErrorReport>prompt</ErrorReport>
|
|
53
|
+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
54
|
+
</PropertyGroup>
|
|
55
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
56
|
+
<DebugSymbols>true</DebugSymbols>
|
|
57
|
+
<OutputPath>bin\x86\Debug\</OutputPath>
|
|
58
|
+
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
59
|
+
<DebugType>full</DebugType>
|
|
60
|
+
<PlatformTarget>x86</PlatformTarget>
|
|
61
|
+
<ErrorReport>prompt</ErrorReport>
|
|
62
|
+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
63
|
+
</PropertyGroup>
|
|
64
|
+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
|
65
|
+
<OutputPath>bin\x86\Release\</OutputPath>
|
|
66
|
+
<DefineConstants>TRACE</DefineConstants>
|
|
67
|
+
<Optimize>true</Optimize>
|
|
68
|
+
<DebugType>pdbonly</DebugType>
|
|
69
|
+
<PlatformTarget>x86</PlatformTarget>
|
|
70
|
+
<ErrorReport>prompt</ErrorReport>
|
|
71
|
+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
72
|
+
</PropertyGroup>
|
|
73
|
+
<ItemGroup>
|
|
74
|
+
<Reference Include="Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
|
75
|
+
<SpecificVersion>False</SpecificVersion>
|
|
76
|
+
<HintPath>..\..\Examples\CodePushDemoApp\windows\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
|
77
|
+
<Private>True</Private>
|
|
78
|
+
</Reference>
|
|
79
|
+
<Reference Include="System" />
|
|
80
|
+
</ItemGroup>
|
|
81
|
+
<Choose>
|
|
82
|
+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
|
83
|
+
<ItemGroup>
|
|
84
|
+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
|
85
|
+
</ItemGroup>
|
|
86
|
+
</When>
|
|
87
|
+
<Otherwise>
|
|
88
|
+
<ItemGroup>
|
|
89
|
+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
|
|
90
|
+
<Private>False</Private>
|
|
91
|
+
</Reference>
|
|
92
|
+
</ItemGroup>
|
|
93
|
+
</Otherwise>
|
|
94
|
+
</Choose>
|
|
95
|
+
<ItemGroup>
|
|
96
|
+
<Compile Include="ApplicationDataContainerTest.cs" />
|
|
97
|
+
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
98
|
+
<Compile Include="TelemetryManagerTest.cs" />
|
|
99
|
+
</ItemGroup>
|
|
100
|
+
<ItemGroup>
|
|
101
|
+
<ProjectReference Include="..\CodePush.Net46\CodePush.Net46.csproj">
|
|
102
|
+
<Project>{4dfe3f9f-5e15-4f17-8fd4-33ff0519348e}</Project>
|
|
103
|
+
<Name>CodePush.Net46</Name>
|
|
104
|
+
</ProjectReference>
|
|
105
|
+
</ItemGroup>
|
|
106
|
+
<ItemGroup>
|
|
107
|
+
<None Include="app.config" />
|
|
108
|
+
<None Include="packages.config" />
|
|
109
|
+
</ItemGroup>
|
|
110
|
+
<Choose>
|
|
111
|
+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
|
112
|
+
<ItemGroup>
|
|
113
|
+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
114
|
+
<Private>False</Private>
|
|
115
|
+
</Reference>
|
|
116
|
+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
117
|
+
<Private>False</Private>
|
|
118
|
+
</Reference>
|
|
119
|
+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
120
|
+
<Private>False</Private>
|
|
121
|
+
</Reference>
|
|
122
|
+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
123
|
+
<Private>False</Private>
|
|
124
|
+
</Reference>
|
|
125
|
+
</ItemGroup>
|
|
126
|
+
</When>
|
|
127
|
+
</Choose>
|
|
128
|
+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
|
129
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
130
|
+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
131
|
+
Other similar extension points exist, see Microsoft.Common.targets.
|
|
132
|
+
<Target Name="BeforeBuild">
|
|
133
|
+
</Target>
|
|
134
|
+
<Target Name="AfterBuild">
|
|
135
|
+
</Target>
|
|
136
|
+
-->
|
|
137
|
+
</Project>
|