@algocare/react-native-code-push 9.0.0-beta.3
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/AlertAdapter.js +24 -0
- package/CONTRIBUTING.md +134 -0
- package/CodePush.js +778 -0
- package/CodePush.podspec +27 -0
- package/LICENSE.md +13 -0
- package/README.md +491 -0
- package/SECURITY.md +41 -0
- package/android/app/build.gradle +31 -0
- package/android/app/proguard-rules.pro +25 -0
- package/android/app/src/main/AndroidManifest.xml +6 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +441 -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 +714 -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 +268 -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/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 +21 -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/babel.config.js +3 -0
- package/cli/commands/bundleCommand/bundleCodePush.js +57 -0
- package/cli/commands/bundleCommand/index.js +29 -0
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +53 -0
- package/cli/commands/createHistoryCommand/index.js +29 -0
- package/cli/commands/releaseCommand/addToReleaseHistory.js +75 -0
- package/cli/commands/releaseCommand/index.js +66 -0
- package/cli/commands/releaseCommand/release.js +109 -0
- package/cli/commands/showHistoryCommand/index.js +29 -0
- package/cli/commands/updateHistoryCommand/index.js +50 -0
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +62 -0
- package/cli/constant.js +6 -0
- package/cli/functions/getReactTempDir.js +16 -0
- package/cli/functions/makeCodePushBundle.js +28 -0
- package/cli/functions/prepareToBundleJS.js +12 -0
- package/cli/functions/runHermesEmitBinaryCommand.js +213 -0
- package/cli/functions/runReactNativeBundleCommand.js +59 -0
- package/cli/index.js +43 -0
- package/cli/utils/file-utils.js +42 -0
- package/cli/utils/fsUtils.js +49 -0
- package/cli/utils/hash-utils.js +227 -0
- package/cli/utils/promisfied-fs.js +29 -0
- package/cli/utils/showLogo.js +23 -0
- package/cli/utils/zip.js +89 -0
- package/code-push.config.example.supabase.ts +114 -0
- package/docs/api-android.md +83 -0
- package/docs/api-ios.md +31 -0
- package/docs/api-js.md +592 -0
- package/docs/multi-deployment-testing-android.md +148 -0
- package/docs/multi-deployment-testing-ios.md +59 -0
- package/docs/setup-android.md +482 -0
- package/docs/setup-ios.md +280 -0
- package/eslint.config.mjs +32 -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 +1121 -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/Common.h +81 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
- package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
- package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
- package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
- package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
- package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
- package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
- package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
- package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/logging.js +6 -0
- package/package-mixins.js +61 -0
- package/package.json +84 -0
- package/react-native.config.js +12 -0
- package/scripts/generateBundledResourcesHash.js +125 -0
- package/scripts/getFilesInFolder.js +19 -0
- package/scripts/recordFilesBeforeBundleCommand.js +41 -0
- package/tsconfig.json +14 -0
- package/tslint.json +32 -0
- package/typings/react-native-code-push.d.ts +589 -0
- package/versioning/BaseVersioning.js +126 -0
- package/versioning/BaseVersioning.test.js +15 -0
- package/versioning/IncrementalVersioning.js +9 -0
- package/versioning/IncrementalVersioning.test.js +186 -0
- package/versioning/SemverVersioning.js +10 -0
- package/versioning/SemverVersioning.test.js +205 -0
- package/versioning/index.js +7 -0
package/logging.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { NativeEventEmitter } from "react-native";
|
|
2
|
+
import log from "./logging";
|
|
3
|
+
|
|
4
|
+
// This function is used to augment remote and local
|
|
5
|
+
// package objects with additional functionality/properties
|
|
6
|
+
// beyond what is included in the metadata sent by the server.
|
|
7
|
+
module.exports = (NativeCodePush) => {
|
|
8
|
+
const remote = () => {
|
|
9
|
+
return {
|
|
10
|
+
async download(downloadProgressCallback) {
|
|
11
|
+
if (!this.downloadUrl) {
|
|
12
|
+
throw new Error("Cannot download an update without a download url");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let downloadProgressSubscription;
|
|
16
|
+
if (downloadProgressCallback) {
|
|
17
|
+
const codePushEventEmitter = new NativeEventEmitter(NativeCodePush);
|
|
18
|
+
// Use event subscription to obtain download progress.
|
|
19
|
+
downloadProgressSubscription = codePushEventEmitter.addListener(
|
|
20
|
+
"CodePushDownloadProgress",
|
|
21
|
+
downloadProgressCallback
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Use the downloaded package info. Native code will save the package info
|
|
26
|
+
// so that the client knows what the current package version is.
|
|
27
|
+
try {
|
|
28
|
+
const updatePackageCopy = Object.assign({}, this);
|
|
29
|
+
Object.keys(updatePackageCopy).forEach((key) => (typeof updatePackageCopy[key] === 'function') && delete updatePackageCopy[key]);
|
|
30
|
+
|
|
31
|
+
const downloadedPackage = await NativeCodePush.downloadUpdate(updatePackageCopy, !!downloadProgressCallback);
|
|
32
|
+
|
|
33
|
+
return { ...downloadedPackage, ...local };
|
|
34
|
+
} finally {
|
|
35
|
+
downloadProgressSubscription && downloadProgressSubscription.remove();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
isPending: false // A remote package could never be in a pending state
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const local = {
|
|
44
|
+
async install(installMode = NativeCodePush.codePushInstallModeOnNextRestart, minimumBackgroundDuration = 0, updateInstalledCallback) {
|
|
45
|
+
const localPackage = this;
|
|
46
|
+
const localPackageCopy = Object.assign({}, localPackage); // In dev mode, React Native deep freezes any object queued over the bridge
|
|
47
|
+
await NativeCodePush.installUpdate(localPackageCopy, installMode, minimumBackgroundDuration);
|
|
48
|
+
updateInstalledCallback && updateInstalledCallback();
|
|
49
|
+
if (installMode == NativeCodePush.codePushInstallModeImmediate) {
|
|
50
|
+
NativeCodePush.restartApp(false);
|
|
51
|
+
} else {
|
|
52
|
+
NativeCodePush.clearPendingRestart();
|
|
53
|
+
localPackage.isPending = true; // Mark the package as pending since it hasn't been applied yet
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
isPending: false // A local package wouldn't be pending until it was installed
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return { local, remote };
|
|
61
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@algocare/react-native-code-push",
|
|
3
|
+
"version": "9.0.0-beta.3",
|
|
4
|
+
"description": "React Native plugin for the CodePush service",
|
|
5
|
+
"main": "CodePush.js",
|
|
6
|
+
"typings": "typings/react-native-code-push.d.ts",
|
|
7
|
+
"homepage": "https://microsoft.github.io/code-push",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react-native",
|
|
10
|
+
"code",
|
|
11
|
+
"push"
|
|
12
|
+
],
|
|
13
|
+
"author": "Soomgo Mobile Team (originally Microsoft Corporation)",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bin": {
|
|
16
|
+
"code-push": "cli/index.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "shx rm -rf bin",
|
|
20
|
+
"setup": "npm install --quiet --no-progress",
|
|
21
|
+
"prebuild:tests": "npm run clean && npm run tslint",
|
|
22
|
+
"build:tests": "tsc",
|
|
23
|
+
"test": "npm run build:tests && npm run test:setup && npm run test:fast",
|
|
24
|
+
"test:android": "npm run build:tests && npm run test:setup:android && npm run test:fast:android",
|
|
25
|
+
"test:ios": "npm run build:tests && npm run test:setup:ios && npm run test:fast:ios",
|
|
26
|
+
"test:setup": "mocha --recursive bin/test --android --ios --setup",
|
|
27
|
+
"test:setup:android": "mocha --recursive bin/test --android --setup",
|
|
28
|
+
"test:setup:ios": "mocha --recursive bin/test --ios --setup",
|
|
29
|
+
"test:fast": "mocha --recursive bin/test --android --ios",
|
|
30
|
+
"test:fast:android": "mocha --recursive bin/test --android",
|
|
31
|
+
"test:fast:ios": "mocha --recursive bin/test --ios",
|
|
32
|
+
"test:debugger:android": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --android",
|
|
33
|
+
"test:debugger:ios": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --ios",
|
|
34
|
+
"tslint": "tslint -c tslint.json test/**/*.ts",
|
|
35
|
+
"publish": "npm publish --access=public",
|
|
36
|
+
"eslint": "eslint --quiet .",
|
|
37
|
+
"jest": "jest versioning/*"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/Soomgo-Mobile/react-native-code-push.git"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"commander": "^12.1.0",
|
|
45
|
+
"hoist-non-react-statics": "^3.3.2",
|
|
46
|
+
"semver": "^7.3.5",
|
|
47
|
+
"shelljs": "^0.8.5",
|
|
48
|
+
"yazl": "^3.3.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@babel/core": "^7.26.0",
|
|
52
|
+
"@babel/preset-env": "^7.26.0",
|
|
53
|
+
"@eslint/js": "^9.13.0",
|
|
54
|
+
"@types/assert": "^1.5.2",
|
|
55
|
+
"@types/mkdirp": "^1.0.1",
|
|
56
|
+
"@types/mocha": "^9.0.0",
|
|
57
|
+
"@types/node": "^14.0.27",
|
|
58
|
+
"@types/q": "^1.5.4",
|
|
59
|
+
"@types/semver": "^7.5.8",
|
|
60
|
+
"@types/shelljs": "^0.8.15",
|
|
61
|
+
"archiver": "latest",
|
|
62
|
+
"babel-jest": "^29.7.0",
|
|
63
|
+
"body-parser": "latest",
|
|
64
|
+
"code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
|
|
65
|
+
"del": "v6.0.0",
|
|
66
|
+
"eslint": "^9.13.0",
|
|
67
|
+
"eslint-plugin-react": "^7.37.2",
|
|
68
|
+
"express": "latest",
|
|
69
|
+
"globals": "^15.11.0",
|
|
70
|
+
"jest": "^29.7.0",
|
|
71
|
+
"mkdirp": "latest",
|
|
72
|
+
"mocha": "^9.2.0",
|
|
73
|
+
"q": "^1.5.1",
|
|
74
|
+
"shx": "^0.3.4",
|
|
75
|
+
"slash": "^3.0.0",
|
|
76
|
+
"ts-node": "^10.9.2",
|
|
77
|
+
"tslint": "^6.1.3",
|
|
78
|
+
"typescript": "^4.4.3",
|
|
79
|
+
"typescript-eslint": "^8.11.0"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=18"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependency: {
|
|
3
|
+
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
packageImportPath: "import com.microsoft.codepush.react.CodePush;",
|
|
6
|
+
packageInstance:
|
|
7
|
+
"new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)",
|
|
8
|
+
sourceDir: './android/app'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This script generates a hash of all the React Native bundled assets and writes it into
|
|
3
|
+
* into the APK. The hash in "updateCheck" requests to prevent downloading an identical
|
|
4
|
+
* update to the one already present in the binary.
|
|
5
|
+
*
|
|
6
|
+
* It first creates a snapshot of the contents in the resource directory by creating
|
|
7
|
+
* a map with the modified time of all the files in the directory. It then compares this
|
|
8
|
+
* snapshot with the one saved earlier in "recordFilesBeforeBundleCommand.js" to figure
|
|
9
|
+
* out which files were generated by the "react-native bundle" command. It then computes
|
|
10
|
+
* the hash for each file to generate a manifest, and then computes a hash over the entire
|
|
11
|
+
* manifest to generate the final hash, which is saved to the APK's assets directory.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
var crypto = require("crypto");
|
|
15
|
+
var fs = require("fs");
|
|
16
|
+
var path = require("path");
|
|
17
|
+
|
|
18
|
+
var getFilesInFolder = require("./getFilesInFolder");
|
|
19
|
+
|
|
20
|
+
var CODE_PUSH_FOLDER_PREFIX = "CodePush";
|
|
21
|
+
var CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
|
|
22
|
+
var CODE_PUSH_HASH_OLD_FILE_NAME = "CodePushHash.json";
|
|
23
|
+
var HASH_ALGORITHM = "sha256";
|
|
24
|
+
|
|
25
|
+
var resourcesDir = process.argv[2];
|
|
26
|
+
var jsBundleFilePath = process.argv[3];
|
|
27
|
+
var assetsDir = process.argv[4];
|
|
28
|
+
var tempFileName = process.argv[5];
|
|
29
|
+
|
|
30
|
+
var oldFileToModifiedTimeMap = {};
|
|
31
|
+
var tempFileLocalPath = null;
|
|
32
|
+
if (tempFileName) {
|
|
33
|
+
tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
|
|
34
|
+
oldFileToModifiedTimeMap = require(tempFileLocalPath);
|
|
35
|
+
}
|
|
36
|
+
var resourceFiles = [];
|
|
37
|
+
|
|
38
|
+
getFilesInFolder(resourcesDir, resourceFiles);
|
|
39
|
+
|
|
40
|
+
var newFileToModifiedTimeMap = {};
|
|
41
|
+
|
|
42
|
+
resourceFiles.forEach(function(resourceFile) {
|
|
43
|
+
newFileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var bundleGeneratedAssetFiles = [];
|
|
47
|
+
|
|
48
|
+
for (var newFilePath in newFileToModifiedTimeMap) {
|
|
49
|
+
if (!oldFileToModifiedTimeMap[newFilePath] || oldFileToModifiedTimeMap[newFilePath] < newFileToModifiedTimeMap[newFilePath].getTime()) {
|
|
50
|
+
bundleGeneratedAssetFiles.push(newFilePath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var manifest = [];
|
|
55
|
+
|
|
56
|
+
if (bundleGeneratedAssetFiles.length) {
|
|
57
|
+
bundleGeneratedAssetFiles.forEach(function(assetFile) {
|
|
58
|
+
// Generate hash for each asset file
|
|
59
|
+
addFileToManifest(resourcesDir, assetFile, manifest, function() {
|
|
60
|
+
if (manifest.length === bundleGeneratedAssetFiles.length) {
|
|
61
|
+
addJsBundleAndMetaToManifest();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
addJsBundleAndMetaToManifest();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function addJsBundleAndMetaToManifest() {
|
|
70
|
+
addFileToManifest(path.dirname(jsBundleFilePath), path.basename(jsBundleFilePath), manifest, function() {
|
|
71
|
+
var jsBundleMetaFilePath = jsBundleFilePath + ".meta";
|
|
72
|
+
addFileToManifest(path.dirname(jsBundleMetaFilePath), path.basename(jsBundleMetaFilePath), manifest, function() {
|
|
73
|
+
manifest = manifest.sort();
|
|
74
|
+
var finalHash = crypto.createHash(HASH_ALGORITHM)
|
|
75
|
+
.update(JSON.stringify(manifest))
|
|
76
|
+
.digest("hex");
|
|
77
|
+
|
|
78
|
+
console.log(finalHash);
|
|
79
|
+
|
|
80
|
+
var savedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_FILE_NAME;
|
|
81
|
+
fs.writeFileSync(savedResourcesManifestPath, finalHash);
|
|
82
|
+
|
|
83
|
+
// "CodePushHash.json" file name breaks flow type checking.
|
|
84
|
+
// To fix the issue we need to delete "CodePushHash.json" file and
|
|
85
|
+
// use "CodePushHash" file name instead to store the hash value.
|
|
86
|
+
// Relates to https://github.com/microsoft/react-native-code-push/issues/577
|
|
87
|
+
var oldSavedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_OLD_FILE_NAME;
|
|
88
|
+
if (fs.existsSync(oldSavedResourcesManifestPath)) {
|
|
89
|
+
fs.unlinkSync(oldSavedResourcesManifestPath);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function addFileToManifest(folder, assetFile, manifest, done) {
|
|
96
|
+
var fullFilePath = path.join(folder, assetFile);
|
|
97
|
+
if (!fileExists(fullFilePath)) {
|
|
98
|
+
done();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var readStream = fs.createReadStream(path.join(folder, assetFile));
|
|
103
|
+
var hashStream = crypto.createHash(HASH_ALGORITHM);
|
|
104
|
+
|
|
105
|
+
readStream.pipe(hashStream)
|
|
106
|
+
.on("error", function(error) {
|
|
107
|
+
throw error;
|
|
108
|
+
})
|
|
109
|
+
.on("finish", function() {
|
|
110
|
+
hashStream.end();
|
|
111
|
+
var buffer = hashStream.read();
|
|
112
|
+
var fileHash = buffer.toString("hex");
|
|
113
|
+
manifest.push(path.join(CODE_PUSH_FOLDER_PREFIX, assetFile).replace(/\\/g, "/") + ":" + fileHash);
|
|
114
|
+
done();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function fileExists(file) {
|
|
119
|
+
try { return fs.statSync(file).isFile(); }
|
|
120
|
+
catch (e) { return false; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (tempFileLocalPath) {
|
|
124
|
+
fs.unlinkSync(tempFileLocalPath);
|
|
125
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var fs = require("fs");
|
|
2
|
+
var path = require("path");
|
|
3
|
+
|
|
4
|
+
// Utility function that collects the stats of every file in a directory
|
|
5
|
+
// as well as in its subdirectories.
|
|
6
|
+
function getFilesInFolder(folderName, fileList) {
|
|
7
|
+
var folderFiles = fs.readdirSync(folderName);
|
|
8
|
+
folderFiles.forEach(function(file) {
|
|
9
|
+
var fileStats = fs.statSync(path.join(folderName, file));
|
|
10
|
+
if (fileStats.isDirectory()) {
|
|
11
|
+
getFilesInFolder(path.join(folderName, file), fileList);
|
|
12
|
+
} else {
|
|
13
|
+
fileStats.path = path.join(folderName, file);
|
|
14
|
+
fileList.push(fileStats);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = getFilesInFolder;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This script creates a snapshot of the contents in the resource directory
|
|
3
|
+
* by creating a map with the modified time of all the files in the directory
|
|
4
|
+
* and saving it to a temp file. This snapshot is later referenced in
|
|
5
|
+
* "generatePackageHash.js" to figure out which files have changed or were
|
|
6
|
+
* newly generated by the "react-native bundle" command.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var fs = require("fs");
|
|
10
|
+
var path = require("path");
|
|
11
|
+
|
|
12
|
+
var getFilesInFolder = require("./getFilesInFolder");
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var resourcesDir = process.argv[2];
|
|
16
|
+
var tempFileName = process.argv[3];
|
|
17
|
+
|
|
18
|
+
var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
|
|
19
|
+
var resourceFiles = [];
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
getFilesInFolder(resourcesDir, resourceFiles);
|
|
23
|
+
} catch(error) {
|
|
24
|
+
var targetPathNotFoundExceptionMessage = "\nResources directory path does not exist.\n";
|
|
25
|
+
targetPathNotFoundExceptionMessage += "Unable to find '" + resourcesDir;
|
|
26
|
+
targetPathNotFoundExceptionMessage += "' directory. Please check version of Android Plugin for Gradle.";
|
|
27
|
+
error.message += targetPathNotFoundExceptionMessage;
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var fileToModifiedTimeMap = {};
|
|
32
|
+
|
|
33
|
+
resourceFiles.forEach(function(resourceFile) {
|
|
34
|
+
fileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime.getTime();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function(err) {
|
|
38
|
+
if (err) {
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES5",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["es6"],
|
|
6
|
+
"noImplicitAny": true,
|
|
7
|
+
"noEmitOnError": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"rootDir": "test",
|
|
11
|
+
"outDir": "bin",
|
|
12
|
+
"removeComments": true
|
|
13
|
+
}
|
|
14
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"defaultSeverity": "error",
|
|
3
|
+
"rules": {
|
|
4
|
+
"class-name": true,
|
|
5
|
+
"comment-format": [true,
|
|
6
|
+
"check-space"
|
|
7
|
+
],
|
|
8
|
+
"indent": [true,
|
|
9
|
+
"spaces"
|
|
10
|
+
],
|
|
11
|
+
"one-line": [true,
|
|
12
|
+
"check-open-brace"
|
|
13
|
+
],
|
|
14
|
+
"quotemark": [true,
|
|
15
|
+
"double"
|
|
16
|
+
],
|
|
17
|
+
"semicolon": true,
|
|
18
|
+
"whitespace": [true,
|
|
19
|
+
"check-branch",
|
|
20
|
+
"check-operator",
|
|
21
|
+
"check-separator",
|
|
22
|
+
"check-type"
|
|
23
|
+
],
|
|
24
|
+
"typedef-whitespace": [true, {
|
|
25
|
+
"call-signature": "nospace",
|
|
26
|
+
"index-signature": "nospace",
|
|
27
|
+
"parameter": "nospace",
|
|
28
|
+
"property-declaration": "nospace",
|
|
29
|
+
"variable-declaration": "nospace"
|
|
30
|
+
}]
|
|
31
|
+
}
|
|
32
|
+
}
|