@algocare/react-native-code-push 12.6.4 → 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.
Files changed (296) hide show
  1. package/CodePush.podspec +6 -8
  2. package/README.md +343 -586
  3. package/android/app/build.gradle +2 -1
  4. package/android/app/proguard-rules.pro +14 -0
  5. package/android/app/src/debug/AndroidManifest.xml +9 -0
  6. package/android/app/src/main/AndroidManifest.xml +1 -2
  7. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -139
  8. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +0 -3
  9. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +108 -63
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +2 -33
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +13 -109
  12. package/android/build.gradle +3 -0
  13. package/app.plugin.js +1 -0
  14. package/bin/code-push.js +6 -0
  15. package/cli/commands/bundleCommand/bundleCodePush.ts +118 -0
  16. package/cli/commands/bundleCommand/index.ts +34 -0
  17. package/cli/commands/createHistoryCommand/createReleaseHistory.ts +37 -0
  18. package/cli/commands/createHistoryCommand/createReleaseHistoryList.ts +40 -0
  19. package/cli/commands/createHistoryCommand/index.ts +44 -0
  20. package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.ts +33 -0
  21. package/cli/commands/createPullRequestHistoryCommand/index.ts +31 -0
  22. package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.ts +71 -0
  23. package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.ts +75 -0
  24. package/cli/commands/createPullRequestReleaseCommand/index.ts +74 -0
  25. package/cli/commands/getPackageHashCommand/index.ts +45 -0
  26. package/cli/commands/initCommand/index.ts +14 -0
  27. package/cli/commands/initCommand/initAndroid.ts +91 -0
  28. package/cli/commands/initCommand/initIos.ts +123 -0
  29. package/cli/commands/initCommand/test/initAndroid.test.ts +128 -0
  30. package/cli/commands/initCommand/test/initIos.test.ts +99 -0
  31. package/cli/commands/releaseCommand/addToReleaseHistory.ts +57 -0
  32. package/cli/commands/releaseCommand/index.ts +90 -0
  33. package/cli/commands/releaseCommand/release.ts +105 -0
  34. package/cli/commands/removePullRequestHistoryCommand/index.ts +37 -0
  35. package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.ts +28 -0
  36. package/cli/commands/showHistoryCommand/index.ts +31 -0
  37. package/cli/commands/updateHistoryCommand/index.ts +55 -0
  38. package/cli/commands/updateHistoryCommand/updateReleaseHistory.ts +42 -0
  39. package/cli/constant.ts +4 -0
  40. package/cli/dist/commands/bundleCommand/bundleCodePush.js +65 -0
  41. package/cli/dist/commands/bundleCommand/index.js +15 -0
  42. package/cli/dist/commands/createHistoryCommand/createReleaseHistory.js +25 -0
  43. package/cli/dist/commands/createHistoryCommand/createReleaseHistoryList.js +27 -0
  44. package/cli/dist/commands/createHistoryCommand/index.js +20 -0
  45. package/cli/dist/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +23 -0
  46. package/cli/dist/commands/createPullRequestHistoryCommand/index.js +15 -0
  47. package/cli/dist/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +51 -0
  48. package/cli/dist/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +39 -0
  49. package/cli/dist/commands/createPullRequestReleaseCommand/index.js +35 -0
  50. package/cli/dist/commands/getPackageHashCommand/index.js +26 -0
  51. package/cli/dist/commands/initCommand/index.js +12 -0
  52. package/cli/dist/commands/initCommand/initAndroid.js +73 -0
  53. package/cli/dist/commands/initCommand/initIos.js +108 -0
  54. package/cli/dist/commands/initCommand/test/initAndroid.test.js +113 -0
  55. package/cli/dist/commands/initCommand/test/initIos.test.js +95 -0
  56. package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +35 -0
  57. package/cli/dist/commands/releaseCommand/index.js +45 -0
  58. package/cli/dist/commands/releaseCommand/release.js +62 -0
  59. package/cli/dist/commands/removePullRequestHistoryCommand/index.js +19 -0
  60. package/cli/dist/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +18 -0
  61. package/cli/dist/commands/showHistoryCommand/index.js +15 -0
  62. package/cli/dist/commands/updateHistoryCommand/index.js +31 -0
  63. package/cli/dist/commands/updateHistoryCommand/updateReleaseHistory.js +28 -0
  64. package/cli/dist/constant.js +4 -0
  65. package/cli/dist/functions/getReactTempDir.js +10 -0
  66. package/cli/{functions → dist/functions}/makeCodePushBundle.js +5 -11
  67. package/cli/{functions → dist/functions}/prepareToBundleJS.js +2 -5
  68. package/cli/dist/functions/runExpoBundleCommand.js +35 -0
  69. package/cli/{functions → dist/functions}/runHermesEmitBinaryCommand.js +36 -71
  70. package/cli/{functions → dist/functions}/runReactNativeBundleCommand.js +19 -24
  71. package/cli/dist/index.js +54 -0
  72. package/cli/dist/utils/datetime.js +17 -0
  73. package/cli/dist/utils/file-utils.js +19 -0
  74. package/cli/dist/utils/fsUtils.js +44 -0
  75. package/cli/{utils → dist/utils}/hash-utils.js +19 -130
  76. package/cli/{utils → dist/utils}/promisfied-fs.js +5 -16
  77. package/cli/dist/utils/showLogo.js +21 -0
  78. package/cli/dist/utils/unzip.js +41 -0
  79. package/cli/{utils → dist/utils}/zip.js +15 -51
  80. package/cli/functions/{getReactTempDir.js → getReactTempDir.ts} +2 -6
  81. package/cli/functions/makeCodePushBundle.ts +26 -0
  82. package/cli/functions/prepareToBundleJS.ts +10 -0
  83. package/cli/functions/runExpoBundleCommand.ts +45 -0
  84. package/cli/functions/runHermesEmitBinaryCommand.ts +203 -0
  85. package/cli/functions/runReactNativeBundleCommand.ts +67 -0
  86. package/cli/index.ts +68 -0
  87. package/cli/package.json +35 -0
  88. package/cli/utils/datetime.ts +19 -0
  89. package/cli/utils/{file-utils.js → file-utils.ts} +4 -21
  90. package/cli/utils/fsUtils.ts +50 -0
  91. package/cli/utils/hash-utils.ts +143 -0
  92. package/cli/utils/promisfied-fs.ts +19 -0
  93. package/cli/utils/{showLogo.js → showLogo.ts} +4 -6
  94. package/cli/utils/unzip.ts +46 -0
  95. package/cli/utils/zip.ts +65 -0
  96. package/expo/plugin/withCodePush.js +14 -0
  97. package/expo/plugin/withCodePushAndroid.js +92 -0
  98. package/expo/plugin/withCodePushIos.js +143 -0
  99. package/ios/CodePush/CodePush.h +0 -16
  100. package/ios/CodePush/CodePush.m +30 -20
  101. package/ios/CodePush/CodePushConfig.m +1 -11
  102. package/ios/CodePush/CodePushPackage.m +12 -69
  103. package/ios/CodePush/CodePushUpdateUtils.m +1 -91
  104. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  105. package/ios/CodePush/SSZipArchive/README.md +1 -1
  106. package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
  107. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
  108. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  109. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  110. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  111. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  112. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  113. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  114. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  115. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  116. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  117. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  118. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  119. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  120. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  121. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  122. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  123. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  124. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  125. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  126. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  127. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  128. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  129. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  130. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  131. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  132. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  133. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  134. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  135. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  136. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  137. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  138. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  139. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  141. package/ios/CodePush.xcodeproj/project.pbxproj +244 -453
  142. package/ios/PrivacyInfo.xcprivacy +31 -0
  143. package/package.json +68 -42
  144. package/react-native.config.js +1 -1
  145. package/{AlertAdapter.js → src/AlertAdapter.js} +5 -5
  146. package/src/CodePush.js +947 -0
  147. package/{package-mixins.js → src/package-mixins.js} +1 -1
  148. package/{versioning → src/versioning}/BaseVersioning.js +12 -1
  149. package/{versioning → src/versioning}/SemverVersioning.test.js +78 -0
  150. package/typings/react-native-code-push.d.ts +559 -495
  151. package/.claude/commands/release.md +0 -78
  152. package/.claude/skills/npm-release/SKILL.md +0 -89
  153. package/CLAUDE.md +0 -83
  154. package/CONTRIBUTING.md +0 -134
  155. package/CodePush.js +0 -972
  156. package/SECURITY.md +0 -41
  157. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
  158. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -12
  159. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
  160. package/android/codepush.gradle +0 -162
  161. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  162. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  163. package/android/gradlew +0 -164
  164. package/android/gradlew.bat +0 -90
  165. package/babel.config.js +0 -3
  166. package/cli/commands/bundleCommand/bundleCodePush.js +0 -57
  167. package/cli/commands/bundleCommand/index.js +0 -55
  168. package/cli/commands/common.js +0 -245
  169. package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -42
  170. package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +0 -52
  171. package/cli/commands/createHistoryCommand/index.js +0 -95
  172. package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +0 -34
  173. package/cli/commands/createPullRequestHistoryCommand/index.js +0 -29
  174. package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +0 -74
  175. package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +0 -91
  176. package/cli/commands/createPullRequestReleaseCommand/index.js +0 -68
  177. package/cli/commands/getPackageHashCommand/index.js +0 -42
  178. package/cli/commands/releaseCommand/addToReleaseHistory.js +0 -85
  179. package/cli/commands/releaseCommand/index.js +0 -151
  180. package/cli/commands/releaseCommand/release.js +0 -121
  181. package/cli/commands/removePullRequestHistoryCommand/index.js +0 -28
  182. package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +0 -23
  183. package/cli/commands/showHistoryCommand/index.js +0 -88
  184. package/cli/commands/updateHistoryCommand/index.js +0 -123
  185. package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +0 -69
  186. package/cli/constant.js +0 -8
  187. package/cli/index.js +0 -63
  188. package/cli/utils/datetime.js +0 -22
  189. package/cli/utils/fsUtils.js +0 -64
  190. package/cli/utils/version.js +0 -26
  191. package/code-push.config.example.supabase.ts +0 -114
  192. package/code-push.config.js +0 -229
  193. package/code-push.config.ts +0 -175
  194. package/docs/api-android.md +0 -83
  195. package/docs/api-ios.md +0 -31
  196. package/docs/api-js.md +0 -592
  197. package/docs/multi-deployment-testing-android.md +0 -148
  198. package/docs/multi-deployment-testing-ios.md +0 -59
  199. package/docs/setup-android.md +0 -482
  200. package/docs/setup-ios.md +0 -280
  201. package/eslint.config.mjs +0 -32
  202. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
  203. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
  204. package/ios/CodePush/Base64/README.md +0 -47
  205. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
  206. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
  207. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
  208. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
  209. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
  210. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
  211. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
  212. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
  213. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
  214. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
  215. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
  216. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
  217. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
  218. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
  219. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
  220. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
  221. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
  222. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
  223. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
  224. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
  225. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
  226. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
  227. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
  228. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
  229. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
  230. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
  231. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
  232. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
  233. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
  234. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
  235. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
  236. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
  237. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
  238. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
  239. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
  240. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
  241. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
  242. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
  243. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
  244. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
  245. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
  246. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
  247. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
  248. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
  249. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
  250. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
  251. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
  252. package/ios/CodePush/JWT/LICENSE +0 -19
  253. package/ios/CodePush/JWT/README.md +0 -489
  254. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  255. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  256. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  257. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  258. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  259. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  260. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  261. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  262. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  263. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  264. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  265. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  266. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  267. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  268. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  269. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  270. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  271. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  272. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  273. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  274. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  275. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  276. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  277. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  278. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  279. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  280. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  281. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  282. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  283. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  284. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
  285. package/scripts/generateBundledResourcesHash.js +0 -125
  286. package/scripts/getFilesInFolder.js +0 -19
  287. package/scripts/recordFilesBeforeBundleCommand.js +0 -41
  288. package/scripts/release.sh +0 -86
  289. package/tsconfig.json +0 -20
  290. package/tslint.json +0 -32
  291. /package/{logging.js → src/logging.js} +0 -0
  292. /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
  293. /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
  294. /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
  295. /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
  296. /package/{versioning → src/versioning}/index.js +0 -0
@@ -0,0 +1,51 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { getTimestamp } from "../../utils/datetime.js";
4
+ /**
5
+ * Appends a PR preview release entry to the release history.
6
+ *
7
+ * PR preview releases are keyed as `{prNumber}-{semver}` (e.g. `1234-1.0.0`) so that
8
+ * the runtime can filter them by PR number (`SyncOptions.prNumber`) while normal
9
+ * clients ignore any key containing `-`.
10
+ */
11
+ export async function addToPullRequestRelease(binaryVersion, prNumber, bundleDownloadUrl, packageHash, getReleaseHistory, setReleaseHistory, platform, identifier, app, mandatory, enable) {
12
+ const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier, app);
13
+ const releaseHistoryKeysWithPrNumber = Object.keys(releaseHistory)
14
+ .filter((key) => key.startsWith(`${prNumber}-`));
15
+ const newReleaseVersionKey = getNewReleaseVersionKey(releaseHistoryKeysWithPrNumber, prNumber);
16
+ const newReleaseHistory = structuredClone(releaseHistory);
17
+ newReleaseHistory[newReleaseVersionKey] = {
18
+ binaryVersion,
19
+ enabled: enable,
20
+ mandatory,
21
+ downloadUrl: bundleDownloadUrl,
22
+ packageHash,
23
+ createdAt: getTimestamp(),
24
+ };
25
+ try {
26
+ const JSON_FILE_NAME = `${binaryVersion}.json`;
27
+ const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
28
+ console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(newReleaseHistory, null, 2));
29
+ fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory));
30
+ await setReleaseHistory(binaryVersion, JSON_FILE_PATH, newReleaseHistory, platform, identifier, app);
31
+ fs.unlinkSync(JSON_FILE_PATH);
32
+ }
33
+ catch (error) {
34
+ console.error('Error occurred while updating history:', error);
35
+ process.exit(1);
36
+ }
37
+ }
38
+ /**
39
+ * Determines the next PR release key. (`{prNumber}-1.0.0` → `{prNumber}-2.0.0` → ...)
40
+ */
41
+ function getNewReleaseVersionKey(releaseHistoryKeysWithPrNumber, prNumber) {
42
+ const lastKey = releaseHistoryKeysWithPrNumber.at(-1);
43
+ if (lastKey) {
44
+ const [, latestVersion] = lastKey.split('-');
45
+ const latestMajor = parseInt(latestVersion.split('.')[0], 10);
46
+ return `${prNumber}-${latestMajor + 1}.0.0`;
47
+ }
48
+ else {
49
+ return `${prNumber}-1.0.0`;
50
+ }
51
+ }
@@ -0,0 +1,39 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { bundleCodePush } from "../bundleCommand/bundleCodePush.js";
4
+ import { addToPullRequestRelease } from "./addToPullRequestRelease.js";
5
+ export async function createPullRequestRelease(bundleUploader, getReleaseHistory, setReleaseHistory, binaryVersion, prNumber, framework, platform, identifier, app, outputPath, entryFile, jsBundleName, mandatory, enable, skipBundle, skipCleanup, bundleDirectory, outputMetroDir) {
6
+ const bundleFileName = skipBundle
7
+ ? readBundleFileNameFrom(bundleDirectory)
8
+ : await bundleCodePush(framework, platform, outputPath, entryFile, jsBundleName, bundleDirectory, outputMetroDir);
9
+ const bundleFilePath = `${bundleDirectory}/${bundleFileName}`;
10
+ const downloadUrl = await (async () => {
11
+ try {
12
+ console.log('Uploading Bundle File...');
13
+ const { downloadUrl } = await bundleUploader(bundleFilePath, platform, identifier, app);
14
+ console.log('Bundle File uploaded:', downloadUrl);
15
+ return downloadUrl;
16
+ }
17
+ catch (error) {
18
+ console.error('Failed to upload the bundle file. Exiting the program.\n', error);
19
+ process.exit(1);
20
+ }
21
+ })();
22
+ await addToPullRequestRelease(binaryVersion, prNumber, downloadUrl, bundleFileName, // bundleFileName represents the package hash
23
+ getReleaseHistory, setReleaseHistory, platform, identifier, app, mandatory, enable);
24
+ if (!skipCleanup) {
25
+ cleanUpOutputs(outputPath);
26
+ }
27
+ }
28
+ function cleanUpOutputs(dir) {
29
+ fs.rmSync(dir, { recursive: true });
30
+ }
31
+ function readBundleFileNameFrom(bundleDirectory) {
32
+ const files = fs.readdirSync(bundleDirectory);
33
+ if (files.length !== 1) {
34
+ console.error('The bundlePath must contain only one file.');
35
+ process.exit(1);
36
+ }
37
+ const bundleFilePath = path.join(bundleDirectory, files[0]);
38
+ return path.basename(bundleFilePath);
39
+ }
@@ -0,0 +1,35 @@
1
+ import { program, Option } from "commander";
2
+ import { findAndReadConfigFile } from "../../utils/fsUtils.js";
3
+ import { createPullRequestRelease } from "./createPullRequestRelease.js";
4
+ import { OUTPUT_BUNDLE_DIR, CONFIG_FILE_NAME, ROOT_OUTPUT_DIR } from "../../constant.js";
5
+ program.command('create-pr-release')
6
+ .description('Deploys a PR preview CodePush release.\nThe release is keyed as `{prNumber}-{semver}` in the release history so that only clients syncing with the matching `prNumber` receive it.')
7
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
8
+ .requiredOption('-r, --pr-number <string>', '(Required) The pull request number')
9
+ .addOption(new Option('-f, --framework <type>', 'framework type (expo)').choices(['expo']))
10
+ .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
11
+ .option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
12
+ .option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
13
+ .option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
14
+ .option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
15
+ .option('-e, --entry-file <string>', 'path to JS/TS entry file (default: auto-detect index.<platform>.js → index.js → index.ts)')
16
+ .option('-j, --js-bundle-name <string>', 'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
17
+ .option('-m, --mandatory [bool]', 'make the release to be mandatory', parseBoolean, false)
18
+ .option('--enable [bool]', 'make the release to be enabled', parseBoolean, true)
19
+ .option('--skip-bundle [bool]', 'skip bundle process', parseBoolean, false)
20
+ .option('--skip-cleanup [bool]', 'skip cleanup process', parseBoolean, false)
21
+ .option('--output-metro-dir <string>', 'name of directory to copy the Metro JS bundle and sourcemap before Hermes compilation')
22
+ .option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
23
+ .action(async (options) => {
24
+ const config = findAndReadConfigFile(process.cwd(), options.config);
25
+ await createPullRequestRelease(config.bundleUploader, config.getReleaseHistory, config.setReleaseHistory, options.binaryVersion, options.prNumber, options.framework, options.platform, options.identifier, options.app, options.outputPath, options.entryFile, options.jsBundleName, options.mandatory, options.enable, options.skipBundle, options.skipCleanup, `${options.outputPath}/${options.outputBundleDir}`, options.outputMetroDir);
26
+ console.log('🚀 PR preview release completed.');
27
+ });
28
+ function parseBoolean(value) {
29
+ if (value === 'true')
30
+ return true;
31
+ if (value === 'false')
32
+ return false;
33
+ else
34
+ return undefined;
35
+ }
@@ -0,0 +1,26 @@
1
+ import { program, Option } from "commander";
2
+ import { findAndReadConfigFile } from "../../utils/fsUtils.js";
3
+ import { CONFIG_FILE_NAME } from "../../constant.js";
4
+ program.command('get-package-hash')
5
+ .description('Retrieves and prints the package hash of the latest release for a specific binary version.\nWhen --pr-number is given, only PR preview releases (`{prNumber}-*` keys) are considered.\n`getReleaseHistory` function should be implemented in the config file.')
6
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
7
+ .option('-r, --pr-number <string>', 'pull request number (filters PR preview releases)')
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>', 'configuration file name (JS/TS)', CONFIG_FILE_NAME)
12
+ .action(async (options) => {
13
+ const config = findAndReadConfigFile(process.cwd(), options.config);
14
+ const releaseHistory = await config.getReleaseHistory(options.binaryVersion, options.platform, options.identifier, options.app);
15
+ const targetKeys = Object.keys(releaseHistory).filter((key) => {
16
+ return options.prNumber
17
+ ? key.startsWith(`${options.prNumber}-`)
18
+ : !key.includes('-');
19
+ });
20
+ const latestReleaseKey = targetKeys.at(-1);
21
+ if (!latestReleaseKey) {
22
+ console.error('No matching release found.');
23
+ process.exit(1);
24
+ }
25
+ process.stdout.write(releaseHistory[latestReleaseKey].packageHash);
26
+ });
@@ -0,0 +1,12 @@
1
+ import { initAndroid } from "./initAndroid.js";
2
+ import { initIos } from "./initIos.js";
3
+ import { program } from "commander";
4
+ program
5
+ .command('init')
6
+ .description('Automatically performs iOS/Android native configurations to initialize the CodePush project.')
7
+ .action(async () => {
8
+ console.log('log: Start initializing CodePush...');
9
+ await initAndroid();
10
+ await initIos();
11
+ console.log('log: CodePush has been successfully initialized.');
12
+ });
@@ -0,0 +1,73 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { EOL } from "os";
4
+ const IMPORT_CODE_PUSH = 'import com.microsoft.codepush.react.CodePush';
5
+ const RN_LEGACY_MARKER = 'object : DefaultReactNativeHost(this)';
6
+ const RN_082_MARKER = ' getDefaultReactHost(';
7
+ export function modifyMainApplicationKt(mainApplicationContent) {
8
+ const hasCodePushImport = mainApplicationContent.includes(IMPORT_CODE_PUSH);
9
+ const hasGetJSBundleFileFn = mainApplicationContent.includes('CodePush.getJSBundleFile()');
10
+ if (hasCodePushImport && hasGetJSBundleFileFn) {
11
+ console.log('log: MainApplication.kt already has CodePush initialized.');
12
+ return mainApplicationContent;
13
+ }
14
+ let updatedContent = mainApplicationContent;
15
+ if (!hasCodePushImport) {
16
+ updatedContent = mainApplicationContent.replace('import com.facebook.react.ReactApplication', `import com.facebook.react.ReactApplication${EOL}${IMPORT_CODE_PUSH}`);
17
+ }
18
+ const isExtendingDefaultReactNativeHost = mainApplicationContent.includes(RN_LEGACY_MARKER);
19
+ // RN <0.82
20
+ if (isExtendingDefaultReactNativeHost) {
21
+ if (!hasGetJSBundleFileFn) {
22
+ updatedContent = updatedContent.replace('override fun getJSMainModuleName(): String = "index"', `override fun getJSMainModuleName(): String = "index"${EOL} override fun getJSBundleFile(): String = CodePush.getJSBundleFile()`);
23
+ }
24
+ return updatedContent;
25
+ }
26
+ // RN 0.82+
27
+ const isUsingGetDefaultReactHost = mainApplicationContent.includes(RN_082_MARKER);
28
+ if (isUsingGetDefaultReactHost) {
29
+ if (!hasGetJSBundleFileFn) {
30
+ return addJsBundleFilePathArgument(updatedContent);
31
+ }
32
+ return updatedContent;
33
+ }
34
+ throw new Error('Unsupported MainApplication.kt structure.');
35
+ }
36
+ function addJsBundleFilePathArgument(mainApplicationContent) {
37
+ const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)/;
38
+ if (!packageListArgumentPattern.test(mainApplicationContent)) {
39
+ console.log('log: Could not find packageList argument while updating MainApplication.kt.');
40
+ return mainApplicationContent;
41
+ }
42
+ return mainApplicationContent.replace(packageListArgumentPattern, (match) => {
43
+ if (match.includes('jsBundleFilePath')) {
44
+ return match;
45
+ }
46
+ return `${match} jsBundleFilePath = CodePush.getJSBundleFile(),${EOL}`;
47
+ });
48
+ }
49
+ export async function initAndroid() {
50
+ console.log('log: Running Android setup...');
51
+ await applyMainApplication();
52
+ }
53
+ async function applyMainApplication() {
54
+ const mainApplicationPath = await findMainApplication();
55
+ if (!mainApplicationPath) {
56
+ console.log('log: Could not find MainApplication.kt');
57
+ return;
58
+ }
59
+ if (mainApplicationPath.endsWith('.java')) {
60
+ console.log('log: MainApplication.java is not supported. Please migrate to MainApplication.kt.');
61
+ return;
62
+ }
63
+ const mainApplicationContent = fs.readFileSync(mainApplicationPath, 'utf-8');
64
+ const newContent = modifyMainApplicationKt(mainApplicationContent);
65
+ fs.writeFileSync(mainApplicationPath, newContent);
66
+ console.log('log: Successfully updated MainApplication.kt.');
67
+ }
68
+ async function findMainApplication() {
69
+ const searchPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'java');
70
+ const files = fs.readdirSync(searchPath, { encoding: 'utf-8', recursive: true });
71
+ const mainApplicationFile = files.find(file => file.endsWith('MainApplication.java') || file.endsWith('MainApplication.kt'));
72
+ return mainApplicationFile ? path.join(searchPath, mainApplicationFile) : null;
73
+ }
@@ -0,0 +1,108 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ // @ts-expect-error -- types for "xcode" are not available
4
+ import xcode from "xcode";
5
+ export async function initIos() {
6
+ console.log('log: Running iOS setup...');
7
+ const projectDir = path.join(process.cwd(), 'ios');
8
+ const files = fs.readdirSync(projectDir);
9
+ const xcodeprojFile = files.find(file => file.endsWith('.xcodeproj'));
10
+ if (!xcodeprojFile) {
11
+ console.log('log: Could not find .xcodeproj file in ios directory');
12
+ return;
13
+ }
14
+ const projectName = xcodeprojFile.replace('.xcodeproj', '');
15
+ const appDelegatePath = findAppDelegate(path.join(projectDir, projectName));
16
+ if (!appDelegatePath) {
17
+ console.log('log: Could not find AppDelegate file');
18
+ return;
19
+ }
20
+ if (appDelegatePath.endsWith('.swift')) {
21
+ await setupSwift(appDelegatePath, projectDir, projectName);
22
+ }
23
+ else {
24
+ await setupObjectiveC(appDelegatePath);
25
+ }
26
+ console.log('log: Please run `cd ios && pod install` to complete the setup.');
27
+ }
28
+ function findAppDelegate(searchPath) {
29
+ if (!fs.existsSync(searchPath))
30
+ return null;
31
+ const files = fs.readdirSync(searchPath);
32
+ const appDelegateFile = files.find(file => file.startsWith('AppDelegate') && (file.endsWith('.m') || file.endsWith('.mm') || file.endsWith('.swift')));
33
+ return appDelegateFile ? path.join(searchPath, appDelegateFile) : null;
34
+ }
35
+ export function modifyObjectiveCAppDelegate(appDelegateContent) {
36
+ const IMPORT_STATEMENT = '#import <CodePush/CodePush.h>';
37
+ if (appDelegateContent.includes(IMPORT_STATEMENT)) {
38
+ console.log('log: AppDelegate already has CodePush imported.');
39
+ return appDelegateContent;
40
+ }
41
+ return appDelegateContent
42
+ .replace('#import "AppDelegate.h"\n', `#import "AppDelegate.h"\n${IMPORT_STATEMENT}\n`)
43
+ .replace('[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];', '[CodePush bundleURL];');
44
+ }
45
+ export function modifySwiftAppDelegate(appDelegateContent) {
46
+ const CODEPUSH_CALL_STATEMENT = 'CodePush.bundleURL()';
47
+ if (appDelegateContent.includes(CODEPUSH_CALL_STATEMENT)) {
48
+ console.log('log: AppDelegate.swift already configured for CodePush.');
49
+ return appDelegateContent;
50
+ }
51
+ return appDelegateContent
52
+ .replace('Bundle.main.url(forResource: "main", withExtension: "jsbundle")', CODEPUSH_CALL_STATEMENT);
53
+ }
54
+ async function setupObjectiveC(appDelegatePath) {
55
+ const appDelegateContent = fs.readFileSync(appDelegatePath, 'utf-8');
56
+ const newContent = modifyObjectiveCAppDelegate(appDelegateContent);
57
+ fs.writeFileSync(appDelegatePath, newContent);
58
+ console.log('log: Successfully updated AppDelegate.m/mm.');
59
+ }
60
+ async function setupSwift(appDelegatePath, projectDir, projectName) {
61
+ const bridgingHeaderPath = await ensureBridgingHeader(projectDir, projectName);
62
+ if (!bridgingHeaderPath) {
63
+ console.log('log: Failed to create or find bridging header.');
64
+ return;
65
+ }
66
+ const appDelegateContent = fs.readFileSync(appDelegatePath, 'utf-8');
67
+ const newContent = modifySwiftAppDelegate(appDelegateContent);
68
+ fs.writeFileSync(appDelegatePath, newContent);
69
+ console.log('log: Successfully updated AppDelegate.swift.');
70
+ }
71
+ async function ensureBridgingHeader(projectDir, projectName) {
72
+ const projectPath = path.join(projectDir, `${projectName}.xcodeproj`, 'project.pbxproj');
73
+ const myProj = xcode.project(projectPath);
74
+ return new Promise((resolve, reject) => {
75
+ myProj.parse(function (err) {
76
+ if (err) {
77
+ console.error(`Error parsing Xcode project: ${err}`);
78
+ return reject(err);
79
+ }
80
+ const bridgingHeaderRelativePath = `${projectName}/${projectName}-Bridging-Header.h`;
81
+ const bridgingHeaderAbsolutePath = path.join(projectDir, bridgingHeaderRelativePath);
82
+ const configurations = myProj.pbxXCBuildConfigurationSection();
83
+ for (const name in configurations) {
84
+ const config = configurations[name];
85
+ if (config.buildSettings) {
86
+ config.buildSettings.SWIFT_OBJC_BRIDGING_HEADER = `"${bridgingHeaderRelativePath}"`;
87
+ }
88
+ }
89
+ if (!fs.existsSync(bridgingHeaderAbsolutePath)) {
90
+ fs.mkdirSync(path.dirname(bridgingHeaderAbsolutePath), { recursive: true });
91
+ fs.writeFileSync(bridgingHeaderAbsolutePath, '#import <CodePush/CodePush.h>\n');
92
+ console.log(`log: Created bridging header at ${bridgingHeaderAbsolutePath}`);
93
+ const groupKey = myProj.findPBXGroupKey({ name: projectName });
94
+ myProj.addHeaderFile(bridgingHeaderRelativePath, { public: true }, groupKey);
95
+ }
96
+ else {
97
+ const headerContent = fs.readFileSync(bridgingHeaderAbsolutePath, 'utf-8');
98
+ if (!headerContent.includes('#import <CodePush/CodePush.h>')) {
99
+ fs.appendFileSync(bridgingHeaderAbsolutePath, '\n#import <CodePush/CodePush.h>\n');
100
+ console.log(`log: Updated bridging header at ${bridgingHeaderAbsolutePath}`);
101
+ }
102
+ }
103
+ fs.writeFileSync(projectPath, myProj.writeSync());
104
+ console.log('log: Updated Xcode project with bridging header path.');
105
+ resolve(bridgingHeaderAbsolutePath);
106
+ });
107
+ });
108
+ }
@@ -0,0 +1,113 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { initAndroid, modifyMainApplicationKt } from "../initAndroid.js";
4
+ import { jest, expect, describe, it } from "@jest/globals";
5
+ const tempDir = path.join(__dirname, 'temp');
6
+ // https://github.com/react-native-community/template/blob/0.80.2/template/android/app/src/main/java/com/helloworld/MainApplication.kt
7
+ const ktTemplate = `
8
+ package com.helloworld
9
+
10
+ import android.app.Application
11
+ import com.facebook.react.PackageList
12
+ import com.facebook.react.ReactApplication
13
+ import com.facebook.react.ReactHost
14
+ import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
15
+ import com.facebook.react.ReactNativeHost
16
+ import com.facebook.react.ReactPackage
17
+ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
18
+ import com.facebook.react.defaults.DefaultReactNativeHost
19
+
20
+ class MainApplication : Application(), ReactApplication {
21
+
22
+ override val reactNativeHost: ReactNativeHost =
23
+ object : DefaultReactNativeHost(this) {
24
+ override fun getPackages(): List<ReactPackage> =
25
+ PackageList(this).packages.apply {
26
+ // Packages that cannot be autolinked yet can be added manually here, for example:
27
+ // add(MyReactNativePackage())
28
+ }
29
+
30
+ override fun getJSMainModuleName(): String = "index"
31
+
32
+ override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
33
+
34
+ override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
35
+ override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
36
+ }
37
+
38
+ override val reactHost: ReactHost
39
+ get() = getDefaultReactHost(applicationContext, reactNativeHost)
40
+
41
+ override fun onCreate() {
42
+ super.onCreate()
43
+ loadReactNative(this)
44
+ }
45
+ }
46
+ `;
47
+ // https://github.com/react-native-community/template/blob/0.82.1/template/android/app/src/main/java/com/helloworld/MainApplication.kt
48
+ const ktRN82Template = `
49
+ package com.helloworld
50
+
51
+ import android.app.Application
52
+ import com.facebook.react.PackageList
53
+ import com.facebook.react.ReactApplication
54
+ import com.facebook.react.ReactHost
55
+ import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
56
+ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
57
+
58
+ class MainApplication : Application(), ReactApplication {
59
+
60
+ override val reactHost: ReactHost by lazy {
61
+ getDefaultReactHost(
62
+ context = applicationContext,
63
+ packageList =
64
+ PackageList(this).packages.apply {
65
+ // Packages that cannot be autolinked yet can be added manually here, for example:
66
+ // add(MyReactNativePackage())
67
+ },
68
+ )
69
+ }
70
+
71
+ override fun onCreate() {
72
+ super.onCreate()
73
+ loadReactNative(this)
74
+ }
75
+ }
76
+ `;
77
+ describe('Android init command', () => {
78
+ it('should correctly modify Kotlin MainApplication content', () => {
79
+ const modifiedContent = modifyMainApplicationKt(ktTemplate);
80
+ expect(modifiedContent).toContain('import com.microsoft.codepush.react.CodePush');
81
+ expect(modifiedContent).toContain('override fun getJSBundleFile(): String = CodePush.getJSBundleFile()');
82
+ });
83
+ it('should insert jsBundleFilePath argument for RN 0.82 style MainApplication', () => {
84
+ const modifiedContent = modifyMainApplicationKt(ktRN82Template);
85
+ expect(modifiedContent).toContain('import com.microsoft.codepush.react.CodePush');
86
+ expect(modifiedContent).toContain('jsBundleFilePath = CodePush.getJSBundleFile()');
87
+ const packageListIndex = modifiedContent.indexOf('packageList =');
88
+ const jsBundleIndex = modifiedContent.indexOf('jsBundleFilePath = CodePush.getJSBundleFile()');
89
+ expect(jsBundleIndex).toBeGreaterThan(packageListIndex);
90
+ });
91
+ it('should log a message and exit if MainApplication.java is found', async () => {
92
+ const originalCwd = process.cwd();
93
+ fs.mkdirSync(tempDir, { recursive: true });
94
+ process.chdir(tempDir);
95
+ // Arrange
96
+ const javaAppDir = path.join(tempDir, 'android', 'app', 'src', 'main', 'java', 'com', 'helloworld');
97
+ fs.mkdirSync(javaAppDir, { recursive: true });
98
+ const javaFilePath = path.join(javaAppDir, 'MainApplication.java');
99
+ const originalContent = '// Java file content';
100
+ fs.writeFileSync(javaFilePath, originalContent);
101
+ const consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => {
102
+ });
103
+ // Act
104
+ await initAndroid();
105
+ // Assert
106
+ expect(consoleSpy).toHaveBeenCalledWith('log: MainApplication.java is not supported. Please migrate to MainApplication.kt.');
107
+ const finalContent = fs.readFileSync(javaFilePath, 'utf-8');
108
+ expect(finalContent).toBe(originalContent); // Ensure file is not modified
109
+ consoleSpy.mockRestore();
110
+ process.chdir(originalCwd);
111
+ fs.rmSync(tempDir, { recursive: true, force: true });
112
+ });
113
+ });
@@ -0,0 +1,95 @@
1
+ import { modifyObjectiveCAppDelegate, modifySwiftAppDelegate } from "../initIos.js";
2
+ import { expect, describe, it } from "@jest/globals";
3
+ // https://github.com/react-native-community/template/blob/0.80.2/template/ios/HelloWorld/AppDelegate.swift
4
+ const swiftTemplate = `
5
+ import UIKit
6
+ import React
7
+ import React_RCTAppDelegate
8
+ import ReactAppDependencyProvider
9
+
10
+ @main
11
+ class AppDelegate: UIResponder, UIApplicationDelegate {
12
+ var window: UIWindow?
13
+ var reactNativeDelegate: ReactNativeDelegate?
14
+ var reactNativeFactory: RCTReactNativeFactory?
15
+
16
+ func application(
17
+ _ application: UIApplication,
18
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
19
+ ) -> Bool {
20
+ let delegate = ReactNativeDelegate()
21
+ let factory = RCTReactNativeFactory(delegate: delegate)
22
+ delegate.dependencyProvider = RCTAppDependencyProvider()
23
+ reactNativeDelegate = delegate
24
+ reactNativeFactory = factory
25
+ window = UIWindow(frame: UIScreen.main.bounds)
26
+ factory.startReactNative(
27
+ withModuleName: "HelloWorld",
28
+ in: window,
29
+ launchOptions: launchOptions
30
+ )
31
+ return true
32
+ }
33
+ }
34
+
35
+ class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
36
+ override func sourceURL(for bridge: RCTBridge) -> URL? {
37
+ self.bundleURL()
38
+ }
39
+
40
+ override func bundleURL() -> URL? {
41
+ #if DEBUG
42
+ RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
43
+ #else
44
+ Bundle.main.url(forResource: "main", withExtension: "jsbundle")
45
+ #endif
46
+ }
47
+ }
48
+ `;
49
+ // https://github.com/react-native-community/template/blob/0.76.9/template/ios/HelloWorld/AppDelegate.mm
50
+ const objcTemplate = `
51
+ #import "AppDelegate.h"
52
+
53
+ #import <React/RCTBundleURLProvider.h>
54
+
55
+ @implementation AppDelegate
56
+
57
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
58
+ {
59
+ self.moduleName = @"HelloWorld";
60
+ // You can add your custom initial props in the dictionary below.
61
+ // They will be passed down to the ViewController used by React Native.
62
+ self.initialProps = @{};
63
+
64
+ return [super application:application didFinishLaunchingWithOptions:launchOptions];
65
+ }
66
+
67
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
68
+ {
69
+ return [self bundleURL];
70
+ }
71
+
72
+ - (NSURL *)bundleURL
73
+ {
74
+ #if DEBUG
75
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
76
+ #else
77
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
78
+ #endif
79
+ }
80
+
81
+ @end
82
+ `;
83
+ describe('iOS init command - pure functions', () => {
84
+ it('should correctly modify Swift AppDelegate content', () => {
85
+ const modifiedContent = modifySwiftAppDelegate(swiftTemplate);
86
+ expect(modifiedContent).toContain('CodePush.bundleURL()');
87
+ expect(modifiedContent).not.toContain('Bundle.main.url(forResource: "main", withExtension: "jsbundle")');
88
+ });
89
+ it('should correctly modify Objective-C AppDelegate content', () => {
90
+ const modifiedContent = modifyObjectiveCAppDelegate(objcTemplate);
91
+ expect(modifiedContent).toContain('#import <CodePush/CodePush.h>');
92
+ expect(modifiedContent).toContain('[CodePush bundleURL]');
93
+ expect(modifiedContent).not.toContain('[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];');
94
+ });
95
+ });
@@ -0,0 +1,35 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { getTimestamp } from "../../utils/datetime.js";
4
+ export async function addToReleaseHistory(appVersion, binaryVersion, bundleDownloadUrl, packageHash, getReleaseHistory, setReleaseHistory, platform, identifier, app, mandatory, enable, rollout) {
5
+ const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier, app);
6
+ const updateInfo = releaseHistory[appVersion];
7
+ if (updateInfo) {
8
+ console.error(`v${appVersion} is already released`);
9
+ process.exit(1);
10
+ }
11
+ const newReleaseHistory = structuredClone(releaseHistory);
12
+ newReleaseHistory[appVersion] = {
13
+ enabled: enable,
14
+ mandatory: mandatory,
15
+ downloadUrl: bundleDownloadUrl,
16
+ packageHash: packageHash,
17
+ createdAt: getTimestamp(),
18
+ updatedAt: '-',
19
+ };
20
+ if (typeof rollout === 'number') {
21
+ newReleaseHistory[appVersion].rollout = rollout;
22
+ }
23
+ try {
24
+ const JSON_FILE_NAME = `${binaryVersion}.json`;
25
+ const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
26
+ console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(newReleaseHistory, null, 2));
27
+ fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory));
28
+ await setReleaseHistory(binaryVersion, JSON_FILE_PATH, newReleaseHistory, platform, identifier, app);
29
+ fs.unlinkSync(JSON_FILE_PATH);
30
+ }
31
+ catch (error) {
32
+ console.error('Error occurred while updating history:', error);
33
+ process.exit(1);
34
+ }
35
+ }
@@ -0,0 +1,45 @@
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
+ program.command('release')
6
+ .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.')
7
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
8
+ .requiredOption('-v, --app-version <string>', '(Required) The app version to be released. It must be greater than the binary version.')
9
+ .addOption(new Option('-f, --framework <type>', 'framework type (expo)').choices(['expo']))
10
+ .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
11
+ .option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
12
+ .option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
13
+ .option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
14
+ .option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
15
+ .option('-e, --entry-file <string>', 'path to JS/TS entry file (default: auto-detect index.<platform>.js → index.js → index.ts)')
16
+ .option('-j, --js-bundle-name <string>', 'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
17
+ .option('-m, --mandatory [bool]', 'make the release to be mandatory', parseBoolean, false)
18
+ .option('--enable [bool]', 'make the release to be enabled', parseBoolean, true)
19
+ .option('--rollout <number>', 'rollout percentage (0-100)', parseFloat)
20
+ .option('--skip-bundle [bool]', 'skip bundle process', parseBoolean, false)
21
+ .option('--hash-calc [bool]', 'calculates the bundle file hash used for packageHash in the release history (Requires setting --skip-bundle to true)', parseBoolean)
22
+ .option('--skip-cleanup [bool]', 'skip cleanup process', parseBoolean, false)
23
+ .option('--output-metro-dir <string>', 'name of directory to copy the Metro JS bundle and sourcemap before Hermes compilation')
24
+ .option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
25
+ .action(async (options) => {
26
+ const config = findAndReadConfigFile(process.cwd(), options.config);
27
+ if (typeof options.rollout === 'number' && (options.rollout < 0 || options.rollout > 100)) {
28
+ console.error('Rollout percentage number must be between 0 and 100 (inclusive).');
29
+ process.exit(1);
30
+ }
31
+ if (options.hashCalc && !options.skipBundle) {
32
+ console.error('--hash-calc option can be used only when --skip-bundle is set to true.');
33
+ process.exit(1);
34
+ }
35
+ await release(config.bundleUploader, config.getReleaseHistory, config.setReleaseHistory, options.binaryVersion, options.appVersion, options.framework, options.platform, options.identifier, options.app, options.outputPath, options.entryFile, options.bundleName, options.mandatory, options.enable, options.rollout, options.skipBundle, options.skipCleanup, `${options.outputPath}/${options.outputBundleDir}`, options.outputMetroDir, options.hashCalc);
36
+ console.log('🚀 Release completed.');
37
+ });
38
+ function parseBoolean(value) {
39
+ if (value === 'true')
40
+ return true;
41
+ if (value === 'false')
42
+ return false;
43
+ else
44
+ return undefined;
45
+ }