@algocare/react-native-code-push 12.6.3 → 13.0.0-rc.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/CodePush.podspec +6 -8
- package/README.md +343 -586
- package/android/app/build.gradle +2 -1
- package/android/app/proguard-rules.pro +14 -0
- package/android/app/src/debug/AndroidManifest.xml +9 -0
- package/android/app/src/main/AndroidManifest.xml +1 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -139
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +0 -3
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +108 -63
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +2 -33
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +13 -109
- package/android/build.gradle +3 -0
- package/app.plugin.js +1 -0
- package/bin/code-push.js +6 -0
- package/cli/commands/bundleCommand/bundleCodePush.ts +118 -0
- package/cli/commands/bundleCommand/index.ts +34 -0
- package/cli/commands/createHistoryCommand/createReleaseHistory.ts +37 -0
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.ts +40 -0
- package/cli/commands/createHistoryCommand/index.ts +44 -0
- package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.ts +33 -0
- package/cli/commands/createPullRequestHistoryCommand/index.ts +31 -0
- package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.ts +71 -0
- package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.ts +75 -0
- package/cli/commands/createPullRequestReleaseCommand/index.ts +74 -0
- package/cli/commands/getPackageHashCommand/index.ts +45 -0
- package/cli/commands/initCommand/index.ts +14 -0
- package/cli/commands/initCommand/initAndroid.ts +91 -0
- package/cli/commands/initCommand/initIos.ts +123 -0
- package/cli/commands/initCommand/test/initAndroid.test.ts +128 -0
- package/cli/commands/initCommand/test/initIos.test.ts +99 -0
- package/cli/commands/releaseCommand/addToReleaseHistory.ts +57 -0
- package/cli/commands/releaseCommand/index.ts +90 -0
- package/cli/commands/releaseCommand/release.ts +105 -0
- package/cli/commands/removePullRequestHistoryCommand/index.ts +37 -0
- package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.ts +28 -0
- package/cli/commands/showHistoryCommand/index.ts +31 -0
- package/cli/commands/updateHistoryCommand/index.ts +55 -0
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.ts +42 -0
- package/cli/constant.ts +4 -0
- package/cli/dist/commands/bundleCommand/bundleCodePush.js +65 -0
- package/cli/dist/commands/bundleCommand/index.js +15 -0
- package/cli/dist/commands/createHistoryCommand/createReleaseHistory.js +25 -0
- package/cli/dist/commands/createHistoryCommand/createReleaseHistoryList.js +27 -0
- package/cli/dist/commands/createHistoryCommand/index.js +20 -0
- package/cli/dist/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +23 -0
- package/cli/dist/commands/createPullRequestHistoryCommand/index.js +15 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +51 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +39 -0
- package/cli/dist/commands/createPullRequestReleaseCommand/index.js +35 -0
- package/cli/dist/commands/getPackageHashCommand/index.js +26 -0
- package/cli/dist/commands/initCommand/index.js +12 -0
- package/cli/dist/commands/initCommand/initAndroid.js +73 -0
- package/cli/dist/commands/initCommand/initIos.js +108 -0
- package/cli/dist/commands/initCommand/test/initAndroid.test.js +113 -0
- package/cli/dist/commands/initCommand/test/initIos.test.js +95 -0
- package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +35 -0
- package/cli/dist/commands/releaseCommand/index.js +45 -0
- package/cli/dist/commands/releaseCommand/release.js +62 -0
- package/cli/dist/commands/removePullRequestHistoryCommand/index.js +19 -0
- package/cli/dist/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +18 -0
- package/cli/dist/commands/showHistoryCommand/index.js +15 -0
- package/cli/dist/commands/updateHistoryCommand/index.js +31 -0
- package/cli/dist/commands/updateHistoryCommand/updateReleaseHistory.js +28 -0
- package/cli/dist/constant.js +4 -0
- package/cli/dist/functions/getReactTempDir.js +10 -0
- package/cli/{functions → dist/functions}/makeCodePushBundle.js +5 -11
- package/cli/{functions → dist/functions}/prepareToBundleJS.js +2 -5
- package/cli/dist/functions/runExpoBundleCommand.js +35 -0
- package/cli/{functions → dist/functions}/runHermesEmitBinaryCommand.js +36 -71
- package/cli/{functions → dist/functions}/runReactNativeBundleCommand.js +19 -24
- package/cli/dist/index.js +54 -0
- package/cli/dist/utils/datetime.js +17 -0
- package/cli/dist/utils/file-utils.js +19 -0
- package/cli/dist/utils/fsUtils.js +44 -0
- package/cli/{utils → dist/utils}/hash-utils.js +19 -130
- package/cli/{utils → dist/utils}/promisfied-fs.js +5 -16
- package/cli/dist/utils/showLogo.js +21 -0
- package/cli/dist/utils/unzip.js +41 -0
- package/cli/{utils → dist/utils}/zip.js +15 -51
- package/cli/functions/{getReactTempDir.js → getReactTempDir.ts} +2 -6
- package/cli/functions/makeCodePushBundle.ts +26 -0
- package/cli/functions/prepareToBundleJS.ts +10 -0
- package/cli/functions/runExpoBundleCommand.ts +45 -0
- package/cli/functions/runHermesEmitBinaryCommand.ts +203 -0
- package/cli/functions/runReactNativeBundleCommand.ts +67 -0
- package/cli/index.ts +68 -0
- package/cli/package.json +35 -0
- package/cli/utils/datetime.ts +19 -0
- package/cli/utils/{file-utils.js → file-utils.ts} +4 -21
- package/cli/utils/fsUtils.ts +50 -0
- package/cli/utils/hash-utils.ts +143 -0
- package/cli/utils/promisfied-fs.ts +19 -0
- package/cli/utils/{showLogo.js → showLogo.ts} +4 -6
- package/cli/utils/unzip.ts +46 -0
- package/cli/utils/zip.ts +65 -0
- package/expo/plugin/withCodePush.js +14 -0
- package/expo/plugin/withCodePushAndroid.js +92 -0
- package/expo/plugin/withCodePushIos.js +143 -0
- package/ios/CodePush/CodePush.h +0 -16
- package/ios/CodePush/CodePush.m +30 -20
- package/ios/CodePush/CodePushConfig.m +1 -11
- package/ios/CodePush/CodePushPackage.m +12 -69
- package/ios/CodePush/CodePushUpdateUtils.m +1 -91
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
- 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 +244 -453
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/package.json +67 -41
- package/react-native.config.js +1 -1
- package/{AlertAdapter.js → src/AlertAdapter.js} +5 -5
- package/src/CodePush.js +947 -0
- package/{package-mixins.js → src/package-mixins.js} +1 -1
- package/{versioning → src/versioning}/BaseVersioning.js +12 -1
- package/{versioning → src/versioning}/SemverVersioning.test.js +78 -0
- package/typings/react-native-code-push.d.ts +559 -495
- package/CONTRIBUTING.md +0 -134
- package/CodePush.js +0 -972
- package/SECURITY.md +0 -41
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -12
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
- package/android/codepush.gradle +0 -162
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -164
- package/android/gradlew.bat +0 -90
- package/babel.config.js +0 -3
- package/cli/commands/bundleCommand/bundleCodePush.js +0 -57
- package/cli/commands/bundleCommand/index.js +0 -55
- package/cli/commands/common.js +0 -245
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -42
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +0 -52
- package/cli/commands/createHistoryCommand/index.js +0 -95
- package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +0 -34
- package/cli/commands/createPullRequestHistoryCommand/index.js +0 -29
- package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +0 -74
- package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +0 -91
- package/cli/commands/createPullRequestReleaseCommand/index.js +0 -68
- package/cli/commands/getPackageHashCommand/index.js +0 -42
- package/cli/commands/releaseCommand/addToReleaseHistory.js +0 -85
- package/cli/commands/releaseCommand/index.js +0 -151
- package/cli/commands/releaseCommand/release.js +0 -121
- package/cli/commands/removePullRequestHistoryCommand/index.js +0 -28
- package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +0 -23
- package/cli/commands/showHistoryCommand/index.js +0 -88
- package/cli/commands/updateHistoryCommand/index.js +0 -123
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +0 -69
- package/cli/constant.js +0 -8
- package/cli/index.js +0 -63
- package/cli/utils/datetime.js +0 -22
- package/cli/utils/fsUtils.js +0 -64
- package/cli/utils/version.js +0 -26
- package/code-push.config.example.supabase.ts +0 -114
- package/code-push.config.js +0 -229
- package/code-push.config.ts +0 -175
- package/docs/api-android.md +0 -83
- package/docs/api-ios.md +0 -31
- package/docs/api-js.md +0 -592
- package/docs/multi-deployment-testing-android.md +0 -148
- package/docs/multi-deployment-testing-ios.md +0 -59
- package/docs/setup-android.md +0 -482
- package/docs/setup-ios.md +0 -280
- package/eslint.config.mjs +0 -32
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
- package/ios/CodePush/Base64/README.md +0 -47
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
- package/ios/CodePush/JWT/LICENSE +0 -19
- package/ios/CodePush/JWT/README.md +0 -489
- package/ios/CodePush/SSZipArchive/Common.h +0 -81
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
- package/scripts/generateBundledResourcesHash.js +0 -125
- package/scripts/getFilesInFolder.js +0 -19
- package/scripts/recordFilesBeforeBundleCommand.js +0 -41
- package/tsconfig.json +0 -20
- package/tslint.json +0 -32
- /package/{logging.js → src/logging.js} +0 -0
- /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
- /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
- /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
- /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
- /package/{versioning → src/versioning}/index.js +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import type { CliConfigInterface } from "../../../typings/react-native-code-push.d.ts";
|
|
4
|
+
import { getTimestamp } from "../../utils/datetime.js";
|
|
5
|
+
|
|
6
|
+
export async function addToReleaseHistory(
|
|
7
|
+
appVersion: string,
|
|
8
|
+
binaryVersion: string,
|
|
9
|
+
bundleDownloadUrl: string,
|
|
10
|
+
packageHash: string,
|
|
11
|
+
getReleaseHistory: CliConfigInterface['getReleaseHistory'],
|
|
12
|
+
setReleaseHistory: CliConfigInterface['setReleaseHistory'],
|
|
13
|
+
platform: 'ios' | 'android',
|
|
14
|
+
identifier: string | undefined,
|
|
15
|
+
app: string | undefined,
|
|
16
|
+
mandatory: boolean,
|
|
17
|
+
enable: boolean,
|
|
18
|
+
rollout: number | undefined,
|
|
19
|
+
): Promise<void> {
|
|
20
|
+
const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier, app);
|
|
21
|
+
|
|
22
|
+
const updateInfo = releaseHistory[appVersion]
|
|
23
|
+
if (updateInfo) {
|
|
24
|
+
console.error(`v${appVersion} is already released`)
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const newReleaseHistory = structuredClone(releaseHistory);
|
|
29
|
+
|
|
30
|
+
newReleaseHistory[appVersion] = {
|
|
31
|
+
enabled: enable,
|
|
32
|
+
mandatory: mandatory,
|
|
33
|
+
downloadUrl: bundleDownloadUrl,
|
|
34
|
+
packageHash: packageHash,
|
|
35
|
+
createdAt: getTimestamp(),
|
|
36
|
+
updatedAt: '-',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (typeof rollout === 'number') {
|
|
40
|
+
newReleaseHistory[appVersion].rollout = rollout;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const JSON_FILE_NAME = `${binaryVersion}.json`;
|
|
45
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
46
|
+
|
|
47
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(newReleaseHistory, null, 2));
|
|
48
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory));
|
|
49
|
+
|
|
50
|
+
await setReleaseHistory(binaryVersion, JSON_FILE_PATH, newReleaseHistory, platform, identifier, app)
|
|
51
|
+
|
|
52
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Error occurred while updating history:', error);
|
|
55
|
+
process.exit(1)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { release } from "./release.js";
|
|
4
|
+
import { OUTPUT_BUNDLE_DIR, CONFIG_FILE_NAME, ROOT_OUTPUT_DIR } from "../../constant.js";
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
binaryVersion: string;
|
|
8
|
+
appVersion: string;
|
|
9
|
+
framework: 'expo' | undefined;
|
|
10
|
+
platform: 'ios' | 'android';
|
|
11
|
+
identifier?: string;
|
|
12
|
+
app?: string;
|
|
13
|
+
config: string;
|
|
14
|
+
outputPath: string;
|
|
15
|
+
entryFile?: string;
|
|
16
|
+
bundleName: string;
|
|
17
|
+
mandatory: boolean;
|
|
18
|
+
enable: boolean;
|
|
19
|
+
rollout?: number;
|
|
20
|
+
skipBundle: boolean;
|
|
21
|
+
skipCleanup: boolean;
|
|
22
|
+
outputBundleDir: string;
|
|
23
|
+
outputMetroDir?: string;
|
|
24
|
+
hashCalc?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
program.command('release')
|
|
28
|
+
.description('Deploys a new CodePush update for a target binary app.\nAfter creating the CodePush bundle, it uploads the file and updates the ReleaseHistory information.\n`bundleUploader`, `getReleaseHistory`, and `setReleaseHistory` functions should be implemented in the config file.')
|
|
29
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
|
|
30
|
+
.requiredOption('-v, --app-version <string>', '(Required) The app version to be released. It must be greater than the binary version.')
|
|
31
|
+
.addOption(new Option('-f, --framework <type>', 'framework type (expo)').choices(['expo']))
|
|
32
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
33
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
34
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
35
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
|
|
36
|
+
.option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
|
|
37
|
+
.option('-e, --entry-file <string>', 'path to JS/TS entry file (default: auto-detect index.<platform>.js → index.js → index.ts)')
|
|
38
|
+
.option('-j, --js-bundle-name <string>', 'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
|
|
39
|
+
.option('-m, --mandatory [bool]', 'make the release to be mandatory', parseBoolean, false)
|
|
40
|
+
.option('--enable [bool]', 'make the release to be enabled', parseBoolean, true)
|
|
41
|
+
.option('--rollout <number>', 'rollout percentage (0-100)', parseFloat)
|
|
42
|
+
.option('--skip-bundle [bool]', 'skip bundle process', parseBoolean, false)
|
|
43
|
+
.option('--hash-calc [bool]', 'calculates the bundle file hash used for packageHash in the release history (Requires setting --skip-bundle to true)', parseBoolean)
|
|
44
|
+
.option('--skip-cleanup [bool]', 'skip cleanup process', parseBoolean, false)
|
|
45
|
+
.option('--output-metro-dir <string>', 'name of directory to copy the Metro JS bundle and sourcemap before Hermes compilation')
|
|
46
|
+
.option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
|
|
47
|
+
.action(async (options: Options) => {
|
|
48
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
49
|
+
|
|
50
|
+
if (typeof options.rollout === 'number' && (options.rollout < 0 || options.rollout > 100)) {
|
|
51
|
+
console.error('Rollout percentage number must be between 0 and 100 (inclusive).');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (options.hashCalc && !options.skipBundle) {
|
|
56
|
+
console.error('--hash-calc option can be used only when --skip-bundle is set to true.');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await release(
|
|
61
|
+
config.bundleUploader,
|
|
62
|
+
config.getReleaseHistory,
|
|
63
|
+
config.setReleaseHistory,
|
|
64
|
+
options.binaryVersion,
|
|
65
|
+
options.appVersion,
|
|
66
|
+
options.framework,
|
|
67
|
+
options.platform,
|
|
68
|
+
options.identifier,
|
|
69
|
+
options.app,
|
|
70
|
+
options.outputPath,
|
|
71
|
+
options.entryFile,
|
|
72
|
+
options.bundleName,
|
|
73
|
+
options.mandatory,
|
|
74
|
+
options.enable,
|
|
75
|
+
options.rollout,
|
|
76
|
+
options.skipBundle,
|
|
77
|
+
options.skipCleanup,
|
|
78
|
+
`${options.outputPath}/${options.outputBundleDir}`,
|
|
79
|
+
options.outputMetroDir,
|
|
80
|
+
options.hashCalc,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
console.log('🚀 Release completed.')
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
function parseBoolean(value: string): boolean | undefined {
|
|
87
|
+
if (value === 'true') return true;
|
|
88
|
+
if (value === 'false') return false;
|
|
89
|
+
else return undefined;
|
|
90
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { bundleCodePush } from "../bundleCommand/bundleCodePush.js";
|
|
4
|
+
import { addToReleaseHistory } from "./addToReleaseHistory.js";
|
|
5
|
+
import type { CliConfigInterface } from "../../../typings/react-native-code-push.d.ts";
|
|
6
|
+
import { generatePackageHashFromDirectory } from "../../utils/hash-utils.js";
|
|
7
|
+
import { unzip } from "../../utils/unzip.js";
|
|
8
|
+
|
|
9
|
+
export async function release(
|
|
10
|
+
bundleUploader: CliConfigInterface['bundleUploader'],
|
|
11
|
+
getReleaseHistory: CliConfigInterface['getReleaseHistory'],
|
|
12
|
+
setReleaseHistory: CliConfigInterface['setReleaseHistory'],
|
|
13
|
+
binaryVersion: string,
|
|
14
|
+
appVersion: string,
|
|
15
|
+
framework: 'expo' | undefined,
|
|
16
|
+
platform: 'ios' | 'android',
|
|
17
|
+
identifier: string | undefined,
|
|
18
|
+
app: string | undefined,
|
|
19
|
+
outputPath: string,
|
|
20
|
+
entryFile: string | undefined,
|
|
21
|
+
jsBundleName: string,
|
|
22
|
+
mandatory: boolean,
|
|
23
|
+
enable: boolean,
|
|
24
|
+
rollout: number | undefined,
|
|
25
|
+
skipBundle: boolean,
|
|
26
|
+
skipCleanup: boolean,
|
|
27
|
+
bundleDirectory: string,
|
|
28
|
+
outputMetroDir?: string,
|
|
29
|
+
hashCalc?: boolean,
|
|
30
|
+
): Promise<void> {
|
|
31
|
+
const bundleFileName = skipBundle
|
|
32
|
+
? readBundleFileNameFrom(bundleDirectory)
|
|
33
|
+
: await bundleCodePush(framework, platform, outputPath, entryFile, jsBundleName, bundleDirectory, outputMetroDir);
|
|
34
|
+
const bundleFilePath = `${bundleDirectory}/${bundleFileName}`;
|
|
35
|
+
|
|
36
|
+
const packageHash = await (() => {
|
|
37
|
+
if (skipBundle && hashCalc) {
|
|
38
|
+
return calcHashFromBundleFile(bundleFilePath);
|
|
39
|
+
}
|
|
40
|
+
// If not using --skip-bundle, the bundleFileName represents package hash already.
|
|
41
|
+
return bundleFileName;
|
|
42
|
+
})();
|
|
43
|
+
|
|
44
|
+
const downloadUrl = await (async () => {
|
|
45
|
+
try {
|
|
46
|
+
const { downloadUrl } = await bundleUploader(bundleFilePath, platform, identifier, app);
|
|
47
|
+
return downloadUrl
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Failed to upload the bundle file. Exiting the program.\n', error)
|
|
50
|
+
process.exit(1)
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
|
|
54
|
+
await addToReleaseHistory(
|
|
55
|
+
appVersion,
|
|
56
|
+
binaryVersion,
|
|
57
|
+
downloadUrl,
|
|
58
|
+
packageHash,
|
|
59
|
+
getReleaseHistory,
|
|
60
|
+
setReleaseHistory,
|
|
61
|
+
platform,
|
|
62
|
+
identifier,
|
|
63
|
+
app,
|
|
64
|
+
mandatory,
|
|
65
|
+
enable,
|
|
66
|
+
rollout,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if (!skipCleanup) {
|
|
70
|
+
cleanUpOutputs(outputPath);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function cleanUpOutputs(dir: string) {
|
|
75
|
+
fs.rmSync(dir, { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function readBundleFileNameFrom(bundleDirectory: string): string {
|
|
79
|
+
const files = fs.readdirSync(bundleDirectory);
|
|
80
|
+
if (files.length !== 1) {
|
|
81
|
+
console.error('The bundlePath must contain only one file.');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
const bundleFilePath = path.join(bundleDirectory, files[0]);
|
|
85
|
+
return path.basename(bundleFilePath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function calcHashFromBundleFile(bundleFilePath: string): Promise<string> {
|
|
89
|
+
const tempDir = path.resolve(path.join(path.dirname(bundleFilePath), 'temp_contents_for_hash_calc'));
|
|
90
|
+
const zipFilePath = path.resolve(bundleFilePath);
|
|
91
|
+
|
|
92
|
+
if (fs.existsSync(tempDir)) {
|
|
93
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
94
|
+
}
|
|
95
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
await unzip(zipFilePath, tempDir);
|
|
99
|
+
const hash = await generatePackageHashFromDirectory(tempDir, tempDir);
|
|
100
|
+
console.log(`log: Calculated package hash from existing bundle file: ${hash}`);
|
|
101
|
+
return hash;
|
|
102
|
+
} finally {
|
|
103
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { removePullRequestHistory } from "./removePullRequestHistory.js";
|
|
4
|
+
import { CONFIG_FILE_NAME } from "../../constant.js";
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
prNumber: string;
|
|
8
|
+
platform: 'ios' | 'android';
|
|
9
|
+
identifier?: string;
|
|
10
|
+
app?: string;
|
|
11
|
+
config: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
program.command('remove-pr-history')
|
|
15
|
+
.description('Removes a PR preview release history.\n`removeReleaseHistory` function should be implemented in the config file.')
|
|
16
|
+
.requiredOption('-r, --pr-number <string>', '(Required) The pull request number')
|
|
17
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
18
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
19
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
20
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
|
|
21
|
+
.action(async (options: Options) => {
|
|
22
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
23
|
+
|
|
24
|
+
if (!config.removeReleaseHistory) {
|
|
25
|
+
console.error('`removeReleaseHistory` function is not implemented in the config file.');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await removePullRequestHistory(
|
|
30
|
+
config.getReleaseHistory,
|
|
31
|
+
config.removeReleaseHistory,
|
|
32
|
+
options.prNumber,
|
|
33
|
+
options.platform,
|
|
34
|
+
options.identifier,
|
|
35
|
+
options.app,
|
|
36
|
+
);
|
|
37
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CliConfigInterface } from "../../../typings/react-native-code-push.d.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Removes a PR preview release history file.
|
|
5
|
+
* (typically executed when the pull request is closed/merged)
|
|
6
|
+
*/
|
|
7
|
+
export async function removePullRequestHistory(
|
|
8
|
+
getReleaseHistory: CliConfigInterface['getReleaseHistory'],
|
|
9
|
+
removeReleaseHistory: NonNullable<CliConfigInterface['removeReleaseHistory']>,
|
|
10
|
+
prNumber: string,
|
|
11
|
+
platform: 'ios' | 'android',
|
|
12
|
+
identifier?: string,
|
|
13
|
+
app?: string,
|
|
14
|
+
): Promise<void> {
|
|
15
|
+
const releaseHistory = await getReleaseHistory(prNumber, platform, identifier, app);
|
|
16
|
+
|
|
17
|
+
if (!releaseHistory) {
|
|
18
|
+
console.error(`v${prNumber} is already removed or is not released.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await removeReleaseHistory(prNumber, platform, identifier, app);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error occurred while removing history:', error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { CONFIG_FILE_NAME } from "../../constant.js";
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
binaryVersion: string;
|
|
7
|
+
platform: 'ios' | 'android';
|
|
8
|
+
identifier?: string;
|
|
9
|
+
app?: string;
|
|
10
|
+
config: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
program.command('show-history')
|
|
14
|
+
.description('Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.')
|
|
15
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version for retrieving the release history.')
|
|
16
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
17
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
18
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
19
|
+
.option('-c, --config <path>', 'configuration file name (JS/TS)', CONFIG_FILE_NAME)
|
|
20
|
+
.action(async (options: Options) => {
|
|
21
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
22
|
+
|
|
23
|
+
const releaseHistory = await config.getReleaseHistory(
|
|
24
|
+
options.binaryVersion,
|
|
25
|
+
options.platform,
|
|
26
|
+
options.identifier,
|
|
27
|
+
options.app
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
console.log(JSON.stringify(releaseHistory, null, 2));
|
|
31
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { updateReleaseHistory } from "./updateReleaseHistory.js";
|
|
4
|
+
import { CONFIG_FILE_NAME } from "../../constant.js";
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
appVersion: string;
|
|
8
|
+
binaryVersion: string;
|
|
9
|
+
platform: 'ios' | 'android';
|
|
10
|
+
identifier?: string;
|
|
11
|
+
app?: string;
|
|
12
|
+
config: string;
|
|
13
|
+
mandatory?: boolean;
|
|
14
|
+
enable?: boolean;
|
|
15
|
+
rollout?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
program.command('update-history')
|
|
19
|
+
.description('Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.')
|
|
20
|
+
.requiredOption('-v, --app-version <string>', '(Required) The app version for which update information is to be modified.')
|
|
21
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version of the app for which update information is to be modified.')
|
|
22
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
23
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
24
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
25
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
|
|
26
|
+
.option('-m, --mandatory [bool]', 'make the release to be mandatory', parseBoolean, undefined)
|
|
27
|
+
.option('-e, --enable [bool]', 'make the release to be enabled', parseBoolean, undefined)
|
|
28
|
+
.option('--rollout <number>', 'rollout percentage (0-100)', parseFloat, undefined)
|
|
29
|
+
.action(async (options: Options) => {
|
|
30
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
31
|
+
|
|
32
|
+
if (typeof options.mandatory !== "boolean" && typeof options.enable !== "boolean") {
|
|
33
|
+
console.error('No options specified. Exiting the program.')
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
await updateReleaseHistory(
|
|
38
|
+
options.appVersion,
|
|
39
|
+
options.binaryVersion,
|
|
40
|
+
config.getReleaseHistory,
|
|
41
|
+
config.setReleaseHistory,
|
|
42
|
+
options.platform,
|
|
43
|
+
options.identifier,
|
|
44
|
+
options.app,
|
|
45
|
+
options.mandatory,
|
|
46
|
+
options.enable,
|
|
47
|
+
options.rollout
|
|
48
|
+
)
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function parseBoolean(value: string) {
|
|
52
|
+
if (value === 'true') return true;
|
|
53
|
+
if (value === 'false') return false;
|
|
54
|
+
else return undefined;
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import type { CliConfigInterface } from "../../../typings/react-native-code-push.d.ts";
|
|
4
|
+
import { getTimestamp } from "../../utils/datetime.js";
|
|
5
|
+
|
|
6
|
+
export async function updateReleaseHistory(
|
|
7
|
+
appVersion: string,
|
|
8
|
+
binaryVersion: string,
|
|
9
|
+
getReleaseHistory: CliConfigInterface['getReleaseHistory'],
|
|
10
|
+
setReleaseHistory: CliConfigInterface['setReleaseHistory'],
|
|
11
|
+
platform: 'ios' | 'android',
|
|
12
|
+
identifier: string | undefined,
|
|
13
|
+
app: string | undefined,
|
|
14
|
+
mandatory: boolean | undefined,
|
|
15
|
+
enable: boolean | undefined,
|
|
16
|
+
rollout: number | undefined,
|
|
17
|
+
): Promise<void> {
|
|
18
|
+
const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier, app);
|
|
19
|
+
|
|
20
|
+
const updateInfo = releaseHistory[appVersion]
|
|
21
|
+
if (!updateInfo) throw new Error(`v${appVersion} is not released`)
|
|
22
|
+
|
|
23
|
+
if (typeof mandatory === "boolean") updateInfo.mandatory = mandatory;
|
|
24
|
+
if (typeof enable === "boolean") updateInfo.enabled = enable;
|
|
25
|
+
if (typeof rollout === "number") updateInfo.rollout = rollout;
|
|
26
|
+
updateInfo.updatedAt = getTimestamp();
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const JSON_FILE_NAME = `${binaryVersion}.json`;
|
|
30
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
31
|
+
|
|
32
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(releaseHistory, null, 2));
|
|
33
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(releaseHistory));
|
|
34
|
+
|
|
35
|
+
await setReleaseHistory(binaryVersion, JSON_FILE_PATH, releaseHistory, platform, identifier, app)
|
|
36
|
+
|
|
37
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error occurred while updating history:', error);
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
42
|
+
}
|
package/cli/constant.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { prepareToBundleJS } from "../../functions/prepareToBundleJS.js";
|
|
4
|
+
import { runReactNativeBundleCommand } from "../../functions/runReactNativeBundleCommand.js";
|
|
5
|
+
import { runExpoBundleCommand } from "../../functions/runExpoBundleCommand.js";
|
|
6
|
+
import { getReactTempDir } from "../../functions/getReactTempDir.js";
|
|
7
|
+
import { runHermesEmitBinaryCommand } from "../../functions/runHermesEmitBinaryCommand.js";
|
|
8
|
+
import { makeCodePushBundle } from "../../functions/makeCodePushBundle.js";
|
|
9
|
+
import { ROOT_OUTPUT_DIR } from "../../constant.js";
|
|
10
|
+
/**
|
|
11
|
+
* @return {Promise<string>} CodePush bundle file name (equals to packageHash)
|
|
12
|
+
*/
|
|
13
|
+
export async function bundleCodePush(framework, platform = 'ios', outputRootPath = ROOT_OUTPUT_DIR, entryFile, jsBundleName, // JS bundle file name (not CodePush bundle file)
|
|
14
|
+
bundleDirectory, // CodePush bundle output directory
|
|
15
|
+
outputMetroDir) {
|
|
16
|
+
const resolvedEntryFile = resolveEntryFile(entryFile, platform);
|
|
17
|
+
if (fs.existsSync(outputRootPath)) {
|
|
18
|
+
fs.rmSync(outputRootPath, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
const OUTPUT_CONTENT_PATH = `${outputRootPath}/CodePush`;
|
|
21
|
+
const DEFAULT_JS_BUNDLE_NAME = platform === 'ios' ? 'main.jsbundle' : 'index.android.bundle';
|
|
22
|
+
const _jsBundleName = jsBundleName || DEFAULT_JS_BUNDLE_NAME; // react-native JS bundle output name
|
|
23
|
+
const SOURCEMAP_OUTPUT = `${outputRootPath}/${_jsBundleName}.map`;
|
|
24
|
+
prepareToBundleJS({ deleteDirs: [outputRootPath, getReactTempDir()], makeDir: OUTPUT_CONTENT_PATH });
|
|
25
|
+
if (framework === 'expo') {
|
|
26
|
+
runExpoBundleCommand(_jsBundleName, OUTPUT_CONTENT_PATH, platform, SOURCEMAP_OUTPUT, resolvedEntryFile);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
runReactNativeBundleCommand(_jsBundleName, OUTPUT_CONTENT_PATH, platform, SOURCEMAP_OUTPUT, resolvedEntryFile);
|
|
30
|
+
}
|
|
31
|
+
console.log('log: JS bundling complete');
|
|
32
|
+
copyMetroOutputsIfNeeded(outputRootPath, outputMetroDir, OUTPUT_CONTENT_PATH, _jsBundleName, SOURCEMAP_OUTPUT);
|
|
33
|
+
await runHermesEmitBinaryCommand(_jsBundleName, OUTPUT_CONTENT_PATH, SOURCEMAP_OUTPUT);
|
|
34
|
+
console.log('log: Hermes compilation complete');
|
|
35
|
+
const { bundleFileName: codePushBundleFileName } = await makeCodePushBundle(OUTPUT_CONTENT_PATH, bundleDirectory);
|
|
36
|
+
console.log(`log: CodePush bundle created (file path: ./${bundleDirectory}/${codePushBundleFileName})`);
|
|
37
|
+
return codePushBundleFileName;
|
|
38
|
+
}
|
|
39
|
+
function resolveEntryFile(entryFile, platform) {
|
|
40
|
+
if (entryFile) {
|
|
41
|
+
if (!fs.existsSync(entryFile)) {
|
|
42
|
+
throw new Error(`Entry file "${entryFile}" does not exist.`);
|
|
43
|
+
}
|
|
44
|
+
return entryFile;
|
|
45
|
+
}
|
|
46
|
+
// 앱마다 엔트리 파일이 다르다 (index.js / index.ts / index.<platform>.js).
|
|
47
|
+
// 명시하지 않으면 react-native CLI 관례 순서로 자동 감지한다.
|
|
48
|
+
const candidates = [`index.${platform}.js`, 'index.js', `index.${platform}.ts`, 'index.ts'];
|
|
49
|
+
const found = candidates.find((candidate) => fs.existsSync(candidate));
|
|
50
|
+
if (!found) {
|
|
51
|
+
throw new Error(`Entry file not found. Tried: ${candidates.join(', ')}. Use -e/--entry-file to specify one.`);
|
|
52
|
+
}
|
|
53
|
+
console.log(`log: entry file auto-detected: ${found}`);
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
function copyMetroOutputsIfNeeded(outputRootPath, outputMetroDir, outputContentPath, jsBundleName, sourceMapOutputPath) {
|
|
57
|
+
if (!outputMetroDir) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const resolvedOutputMetroDir = path.join(outputRootPath, outputMetroDir);
|
|
61
|
+
fs.mkdirSync(resolvedOutputMetroDir, { recursive: true });
|
|
62
|
+
fs.copyFileSync(path.join(outputContentPath, jsBundleName), path.join(resolvedOutputMetroDir, jsBundleName));
|
|
63
|
+
fs.copyFileSync(sourceMapOutputPath, path.join(resolvedOutputMetroDir, path.basename(sourceMapOutputPath)));
|
|
64
|
+
console.log(`log: Metro outputs copied to: ${resolvedOutputMetroDir}`);
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { bundleCodePush } from "./bundleCodePush.js";
|
|
3
|
+
import { OUTPUT_BUNDLE_DIR, ROOT_OUTPUT_DIR } from "../../constant.js";
|
|
4
|
+
program.command('bundle')
|
|
5
|
+
.description('Creates a CodePush bundle file (assumes Hermes is enabled).')
|
|
6
|
+
.addOption(new Option('-f, --framework <type>', 'framework type (expo)').choices(['expo']))
|
|
7
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
8
|
+
.option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
|
|
9
|
+
.option('-e, --entry-file <string>', 'path to JS/TS entry file (default: auto-detect index.<platform>.js → index.js → index.ts)')
|
|
10
|
+
.option('-b, --bundle-name <string>', 'bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
|
|
11
|
+
.option('--output-metro-dir <string>', 'name of directory to copy the Metro JS bundle and sourcemap before Hermes compilation')
|
|
12
|
+
.option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
|
|
13
|
+
.action((options) => {
|
|
14
|
+
bundleCodePush(options.framework, options.platform, options.outputPath, options.entryFile, options.bundleName, `${options.outputPath}/${options.outputBundleDir}`, options.outputMetroDir);
|
|
15
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export async function createReleaseHistory(targetVersion, setReleaseHistory, platform, identifier, app) {
|
|
4
|
+
const BINARY_RELEASE = {
|
|
5
|
+
enabled: true,
|
|
6
|
+
mandatory: false,
|
|
7
|
+
downloadUrl: "",
|
|
8
|
+
packageHash: "",
|
|
9
|
+
};
|
|
10
|
+
const INITIAL_HISTORY = {
|
|
11
|
+
[targetVersion]: BINARY_RELEASE
|
|
12
|
+
};
|
|
13
|
+
try {
|
|
14
|
+
const JSON_FILE_NAME = `${targetVersion}.json`;
|
|
15
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
16
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(INITIAL_HISTORY, null, 2));
|
|
17
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(INITIAL_HISTORY));
|
|
18
|
+
await setReleaseHistory(targetVersion, JSON_FILE_PATH, INITIAL_HISTORY, platform, identifier, app);
|
|
19
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error occurred while creating new history:', error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Adds the new binary version to the binary version list file (`list.json`).
|
|
5
|
+
*
|
|
6
|
+
* The list file indexes all binary versions for which a release history exists,
|
|
7
|
+
* so that deploy pipelines can check for an existing history without listing bucket objects.
|
|
8
|
+
* (algocare extension — runs only when the config implements `getBinaryVersionList`/`setBinaryVersionList`.)
|
|
9
|
+
*/
|
|
10
|
+
export async function createReleaseHistoryList(targetVersion, getBinaryVersionList, setBinaryVersionList, platform, identifier, app) {
|
|
11
|
+
try {
|
|
12
|
+
const JSON_FILE_NAME = 'list.json';
|
|
13
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
14
|
+
const currentList = await getBinaryVersionList(platform, identifier, app);
|
|
15
|
+
if (currentList[targetVersion]) {
|
|
16
|
+
console.error(`Version ${targetVersion} is already released`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(currentList));
|
|
20
|
+
await setBinaryVersionList(targetVersion, JSON_FILE_PATH, platform, identifier, app);
|
|
21
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('Error occurred while creating new history list:', error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { createReleaseHistory } from "./createReleaseHistory.js";
|
|
4
|
+
import { createReleaseHistoryList } from "./createReleaseHistoryList.js";
|
|
5
|
+
import { CONFIG_FILE_NAME } from "../../constant.js";
|
|
6
|
+
program.command('create-history')
|
|
7
|
+
.description('Creates a new release history for the binary app.')
|
|
8
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
|
|
9
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
10
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
11
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
12
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
15
|
+
await createReleaseHistory(options.binaryVersion, config.setReleaseHistory, options.platform, options.identifier, options.app);
|
|
16
|
+
// algocare extension: maintain a `list.json` index of binary versions (only when implemented in config)
|
|
17
|
+
if (config.getBinaryVersionList && config.setBinaryVersionList) {
|
|
18
|
+
await createReleaseHistoryList(options.binaryVersion, config.getBinaryVersionList, config.setBinaryVersionList, options.platform, options.identifier, options.app);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an empty release history for PR preview releases.
|
|
5
|
+
*
|
|
6
|
+
* Unlike `create-history`, this does NOT seed a binary release entry and does NOT
|
|
7
|
+
* register the version in the `list.json` index, so PR preview histories never
|
|
8
|
+
* pollute the official binary version index.
|
|
9
|
+
*/
|
|
10
|
+
export async function createPullRequestHistory(setReleaseHistory, binaryVersion, platform, identifier, app) {
|
|
11
|
+
try {
|
|
12
|
+
const JSON_FILE_NAME = `${binaryVersion}.json`;
|
|
13
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
14
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify({}, null, 2));
|
|
15
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify({}));
|
|
16
|
+
await setReleaseHistory(binaryVersion, JSON_FILE_PATH, {}, platform, identifier, app);
|
|
17
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Error occurred while creating new pull request history:', error);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import { findAndReadConfigFile } from "../../utils/fsUtils.js";
|
|
3
|
+
import { createPullRequestHistory } from "./createPullRequestHistory.js";
|
|
4
|
+
import { CONFIG_FILE_NAME } from "../../constant.js";
|
|
5
|
+
program.command('create-pr-history')
|
|
6
|
+
.description('Creates a new (empty) release history for PR preview releases.')
|
|
7
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
|
|
8
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
9
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
10
|
+
.option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
|
|
11
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
14
|
+
await createPullRequestHistory(config.setReleaseHistory, options.binaryVersion, options.platform, options.identifier, options.app);
|
|
15
|
+
});
|