@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.
Files changed (292) 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 +67 -41
  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/CONTRIBUTING.md +0 -134
  152. package/CodePush.js +0 -972
  153. package/SECURITY.md +0 -41
  154. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
  155. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -12
  156. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
  157. package/android/codepush.gradle +0 -162
  158. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  159. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  160. package/android/gradlew +0 -164
  161. package/android/gradlew.bat +0 -90
  162. package/babel.config.js +0 -3
  163. package/cli/commands/bundleCommand/bundleCodePush.js +0 -57
  164. package/cli/commands/bundleCommand/index.js +0 -55
  165. package/cli/commands/common.js +0 -245
  166. package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -42
  167. package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +0 -52
  168. package/cli/commands/createHistoryCommand/index.js +0 -95
  169. package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +0 -34
  170. package/cli/commands/createPullRequestHistoryCommand/index.js +0 -29
  171. package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +0 -74
  172. package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +0 -91
  173. package/cli/commands/createPullRequestReleaseCommand/index.js +0 -68
  174. package/cli/commands/getPackageHashCommand/index.js +0 -42
  175. package/cli/commands/releaseCommand/addToReleaseHistory.js +0 -85
  176. package/cli/commands/releaseCommand/index.js +0 -151
  177. package/cli/commands/releaseCommand/release.js +0 -121
  178. package/cli/commands/removePullRequestHistoryCommand/index.js +0 -28
  179. package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +0 -23
  180. package/cli/commands/showHistoryCommand/index.js +0 -88
  181. package/cli/commands/updateHistoryCommand/index.js +0 -123
  182. package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +0 -69
  183. package/cli/constant.js +0 -8
  184. package/cli/index.js +0 -63
  185. package/cli/utils/datetime.js +0 -22
  186. package/cli/utils/fsUtils.js +0 -64
  187. package/cli/utils/version.js +0 -26
  188. package/code-push.config.example.supabase.ts +0 -114
  189. package/code-push.config.js +0 -229
  190. package/code-push.config.ts +0 -175
  191. package/docs/api-android.md +0 -83
  192. package/docs/api-ios.md +0 -31
  193. package/docs/api-js.md +0 -592
  194. package/docs/multi-deployment-testing-android.md +0 -148
  195. package/docs/multi-deployment-testing-ios.md +0 -59
  196. package/docs/setup-android.md +0 -482
  197. package/docs/setup-ios.md +0 -280
  198. package/eslint.config.mjs +0 -32
  199. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
  200. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
  201. package/ios/CodePush/Base64/README.md +0 -47
  202. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
  203. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
  204. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
  205. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
  206. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
  207. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
  208. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
  209. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
  210. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
  211. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
  212. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
  213. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
  214. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
  215. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
  216. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
  217. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
  218. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
  219. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
  220. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
  221. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
  222. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
  223. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
  224. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
  225. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
  226. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
  227. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
  228. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
  229. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
  230. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
  231. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
  232. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
  233. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
  234. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
  235. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
  236. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
  237. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
  238. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
  239. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
  240. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
  241. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
  242. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
  243. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
  244. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
  245. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
  246. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
  247. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
  248. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
  249. package/ios/CodePush/JWT/LICENSE +0 -19
  250. package/ios/CodePush/JWT/README.md +0 -489
  251. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  252. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  253. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  254. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  255. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  256. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  257. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  258. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  259. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  260. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  261. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  262. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  263. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  264. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  265. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  266. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  267. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  268. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  269. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  270. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  271. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  272. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  273. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  274. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  275. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  276. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  277. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  278. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  279. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  280. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  281. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
  282. package/scripts/generateBundledResourcesHash.js +0 -125
  283. package/scripts/getFilesInFolder.js +0 -19
  284. package/scripts/recordFilesBeforeBundleCommand.js +0 -41
  285. package/tsconfig.json +0 -20
  286. package/tslint.json +0 -32
  287. /package/{logging.js → src/logging.js} +0 -0
  288. /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
  289. /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
  290. /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
  291. /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
  292. /package/{versioning → src/versioning}/index.js +0 -0
@@ -0,0 +1,62 @@
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 { generatePackageHashFromDirectory } from "../../utils/hash-utils.js";
6
+ import { unzip } from "../../utils/unzip.js";
7
+ export async function release(bundleUploader, getReleaseHistory, setReleaseHistory, binaryVersion, appVersion, framework, platform, identifier, app, outputPath, entryFile, jsBundleName, mandatory, enable, rollout, skipBundle, skipCleanup, bundleDirectory, outputMetroDir, hashCalc) {
8
+ const bundleFileName = skipBundle
9
+ ? readBundleFileNameFrom(bundleDirectory)
10
+ : await bundleCodePush(framework, platform, outputPath, entryFile, jsBundleName, bundleDirectory, outputMetroDir);
11
+ const bundleFilePath = `${bundleDirectory}/${bundleFileName}`;
12
+ const packageHash = await (() => {
13
+ if (skipBundle && hashCalc) {
14
+ return calcHashFromBundleFile(bundleFilePath);
15
+ }
16
+ // If not using --skip-bundle, the bundleFileName represents package hash already.
17
+ return bundleFileName;
18
+ })();
19
+ const downloadUrl = await (async () => {
20
+ try {
21
+ const { downloadUrl } = await bundleUploader(bundleFilePath, platform, identifier, app);
22
+ return downloadUrl;
23
+ }
24
+ catch (error) {
25
+ console.error('Failed to upload the bundle file. Exiting the program.\n', error);
26
+ process.exit(1);
27
+ }
28
+ })();
29
+ await addToReleaseHistory(appVersion, binaryVersion, downloadUrl, packageHash, getReleaseHistory, setReleaseHistory, platform, identifier, app, mandatory, enable, rollout);
30
+ if (!skipCleanup) {
31
+ cleanUpOutputs(outputPath);
32
+ }
33
+ }
34
+ function cleanUpOutputs(dir) {
35
+ fs.rmSync(dir, { recursive: true });
36
+ }
37
+ function readBundleFileNameFrom(bundleDirectory) {
38
+ const files = fs.readdirSync(bundleDirectory);
39
+ if (files.length !== 1) {
40
+ console.error('The bundlePath must contain only one file.');
41
+ process.exit(1);
42
+ }
43
+ const bundleFilePath = path.join(bundleDirectory, files[0]);
44
+ return path.basename(bundleFilePath);
45
+ }
46
+ async function calcHashFromBundleFile(bundleFilePath) {
47
+ const tempDir = path.resolve(path.join(path.dirname(bundleFilePath), 'temp_contents_for_hash_calc'));
48
+ const zipFilePath = path.resolve(bundleFilePath);
49
+ if (fs.existsSync(tempDir)) {
50
+ fs.rmSync(tempDir, { recursive: true, force: true });
51
+ }
52
+ fs.mkdirSync(tempDir, { recursive: true });
53
+ try {
54
+ await unzip(zipFilePath, tempDir);
55
+ const hash = await generatePackageHashFromDirectory(tempDir, tempDir);
56
+ console.log(`log: Calculated package hash from existing bundle file: ${hash}`);
57
+ return hash;
58
+ }
59
+ finally {
60
+ fs.rmSync(tempDir, { recursive: true, force: true });
61
+ }
62
+ }
@@ -0,0 +1,19 @@
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
+ program.command('remove-pr-history')
6
+ .description('Removes a PR preview release history.\n`removeReleaseHistory` function should be implemented in the config file.')
7
+ .requiredOption('-r, --pr-number <string>', '(Required) The pull request number')
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
+ if (!config.removeReleaseHistory) {
15
+ console.error('`removeReleaseHistory` function is not implemented in the config file.');
16
+ process.exit(1);
17
+ }
18
+ await removePullRequestHistory(config.getReleaseHistory, config.removeReleaseHistory, options.prNumber, options.platform, options.identifier, options.app);
19
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Removes a PR preview release history file.
3
+ * (typically executed when the pull request is closed/merged)
4
+ */
5
+ export async function removePullRequestHistory(getReleaseHistory, removeReleaseHistory, prNumber, platform, identifier, app) {
6
+ const releaseHistory = await getReleaseHistory(prNumber, platform, identifier, app);
7
+ if (!releaseHistory) {
8
+ console.error(`v${prNumber} is already removed or is not released.`);
9
+ process.exit(1);
10
+ }
11
+ try {
12
+ await removeReleaseHistory(prNumber, platform, identifier, app);
13
+ }
14
+ catch (error) {
15
+ console.error('Error occurred while removing history:', error);
16
+ process.exit(1);
17
+ }
18
+ }
@@ -0,0 +1,15 @@
1
+ import { program, Option } from "commander";
2
+ import { findAndReadConfigFile } from "../../utils/fsUtils.js";
3
+ import { CONFIG_FILE_NAME } from "../../constant.js";
4
+ program.command('show-history')
5
+ .description('Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.')
6
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version for retrieving the release history.')
7
+ .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
8
+ .option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
9
+ .option('-a, --app <string>', 'target app name for multi-app repositories. (e.g. home-mobile)')
10
+ .option('-c, --config <path>', 'configuration file name (JS/TS)', CONFIG_FILE_NAME)
11
+ .action(async (options) => {
12
+ const config = findAndReadConfigFile(process.cwd(), options.config);
13
+ const releaseHistory = await config.getReleaseHistory(options.binaryVersion, options.platform, options.identifier, options.app);
14
+ console.log(JSON.stringify(releaseHistory, null, 2));
15
+ });
@@ -0,0 +1,31 @@
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
+ program.command('update-history')
6
+ .description('Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.')
7
+ .requiredOption('-v, --app-version <string>', '(Required) The app version for which update information is to be modified.')
8
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version of the app for which update information is to be modified.')
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
+ .option('-m, --mandatory [bool]', 'make the release to be mandatory', parseBoolean, undefined)
14
+ .option('-e, --enable [bool]', 'make the release to be enabled', parseBoolean, undefined)
15
+ .option('--rollout <number>', 'rollout percentage (0-100)', parseFloat, undefined)
16
+ .action(async (options) => {
17
+ const config = findAndReadConfigFile(process.cwd(), options.config);
18
+ if (typeof options.mandatory !== "boolean" && typeof options.enable !== "boolean") {
19
+ console.error('No options specified. Exiting the program.');
20
+ process.exit(1);
21
+ }
22
+ await updateReleaseHistory(options.appVersion, options.binaryVersion, config.getReleaseHistory, config.setReleaseHistory, options.platform, options.identifier, options.app, options.mandatory, options.enable, options.rollout);
23
+ });
24
+ function parseBoolean(value) {
25
+ if (value === 'true')
26
+ return true;
27
+ if (value === 'false')
28
+ return false;
29
+ else
30
+ return undefined;
31
+ }
@@ -0,0 +1,28 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getTimestamp } from "../../utils/datetime.js";
4
+ export async function updateReleaseHistory(appVersion, binaryVersion, 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
+ throw new Error(`v${appVersion} is not released`);
9
+ if (typeof mandatory === "boolean")
10
+ updateInfo.mandatory = mandatory;
11
+ if (typeof enable === "boolean")
12
+ updateInfo.enabled = enable;
13
+ if (typeof rollout === "number")
14
+ updateInfo.rollout = rollout;
15
+ updateInfo.updatedAt = getTimestamp();
16
+ try {
17
+ const JSON_FILE_NAME = `${binaryVersion}.json`;
18
+ const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
19
+ console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(releaseHistory, null, 2));
20
+ fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(releaseHistory));
21
+ await setReleaseHistory(binaryVersion, JSON_FILE_PATH, releaseHistory, platform, identifier, app);
22
+ fs.unlinkSync(JSON_FILE_PATH);
23
+ }
24
+ catch (error) {
25
+ console.error('Error occurred while updating history:', error);
26
+ process.exit(1);
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ export const CONFIG_FILE_NAME = "code-push.config.ts";
2
+ export const OUTPUT_BUNDLE_DIR = "bundleOutput";
3
+ export const ROOT_OUTPUT_DIR = "build";
4
+ export const ENTRY_FILE = "index.ts";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * code based on appcenter-cli
3
+ */
4
+ import os from "os";
5
+ /**
6
+ * Return the path of the temporary directory for react-native bundling
7
+ */
8
+ export function getReactTempDir() {
9
+ return `${os.tmpdir()}/react-*`;
10
+ }
@@ -1,8 +1,7 @@
1
- const path = require('path');
2
- const shell = require('shelljs');
3
- const zip = require('../utils/zip');
4
- const {generatePackageHashFromDirectory} = require('../utils/hash-utils');
5
-
1
+ import path from "path";
2
+ import shell from "shelljs";
3
+ import { zip } from "../utils/zip.js";
4
+ import { generatePackageHashFromDirectory } from "../utils/hash-utils.js";
6
5
  /**
7
6
  * Create a CodePush bundle file and return the information.
8
7
  *
@@ -10,19 +9,14 @@ const {generatePackageHashFromDirectory} = require('../utils/hash-utils');
10
9
  * @param bundleDirectory {string} The directory path to save the CodePush bundle file
11
10
  * @return {Promise<{ bundleFileName: string }>}
12
11
  */
13
- async function makeCodePushBundle(contentsPath, bundleDirectory) {
12
+ export async function makeCodePushBundle(contentsPath, bundleDirectory) {
14
13
  const updateContentsZipPath = await zip(contentsPath);
15
-
16
14
  const packageHash = await generatePackageHashFromDirectory(contentsPath, path.join(contentsPath, '..'));
17
-
18
15
  shell.mkdir('-p', `./${bundleDirectory}`);
19
16
  shell.mv(updateContentsZipPath, `./${bundleDirectory}/${packageHash}`);
20
-
21
17
  return {
22
18
  // To allow the "release" command to get the file and hash value from the result of the "bundle" command,
23
19
  // use the hash value as the name of the file.
24
20
  bundleFileName: packageHash,
25
21
  };
26
22
  }
27
-
28
- module.exports = { makeCodePushBundle };
@@ -1,12 +1,9 @@
1
- const shell = require('shelljs');
2
-
1
+ import shell from "shelljs";
3
2
  /**
4
3
  * @param deleteDirs {string[]} Directories to delete
5
4
  * @param makeDir {string} Directory path to create
6
5
  */
7
- function prepareToBundleJS({ deleteDirs, makeDir }) {
6
+ export function prepareToBundleJS({ deleteDirs, makeDir }) {
8
7
  shell.rm('-rf', deleteDirs);
9
8
  shell.mkdir('-p', makeDir);
10
9
  }
11
-
12
- module.exports = { prepareToBundleJS };
@@ -0,0 +1,35 @@
1
+ import path from "path";
2
+ import shell from "shelljs";
3
+ /**
4
+ * Run `expo bundle` CLI command
5
+ *
6
+ * @param bundleName {string} JS bundle file name
7
+ * @param entryFile {string} App code entry file name (default: index.ts)
8
+ * @param outputPath {string} Path to output JS bundle file and assets
9
+ * @param platform {string} Platform (ios | android)
10
+ * @param sourcemapOutput {string} Path to output sourcemap file (Warning: if sourcemapOutput points to the outputPath, the sourcemap will be included in the CodePush bundle and increase the deployment size)
11
+ * @return {void}
12
+ */
13
+ export function runExpoBundleCommand(bundleName, outputPath, platform, sourcemapOutput, entryFile) {
14
+ function getCliPath() {
15
+ return path.join('node_modules', '.bin', 'expo');
16
+ }
17
+ const expoBundleArgs = [
18
+ 'export:embed',
19
+ '--assets-dest',
20
+ outputPath,
21
+ '--bundle-output',
22
+ path.join(outputPath, bundleName),
23
+ '--dev',
24
+ 'false',
25
+ '--entry-file',
26
+ entryFile,
27
+ '--platform',
28
+ platform,
29
+ '--sourcemap-output',
30
+ sourcemapOutput,
31
+ '--reset-cache',
32
+ ];
33
+ console.log('Running "expo export:embed" command:\n');
34
+ shell.exec(`${getCliPath()} ${expoBundleArgs.join(' ')}`);
35
+ }
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * code based on appcenter-cli
3
3
  */
4
-
5
- const childProcess = require('child_process');
6
- const fs = require('fs');
7
- const path = require('path');
8
- const shell = require('shelljs');
9
-
4
+ import childProcess from "child_process";
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import shell from "shelljs";
10
8
  /**
11
9
  * Run Hermes compile CLI command
12
10
  *
@@ -16,15 +14,7 @@ const shell = require('shelljs');
16
14
  * @param extraHermesFlags {string[]} Additional options to pass to `hermesc` command
17
15
  * @return {Promise<void>}
18
16
  */
19
- async function runHermesEmitBinaryCommand(
20
- bundleName,
21
- outputPath,
22
- sourcemapOutput,
23
- extraHermesFlags = [],
24
- ) {
25
- /**
26
- * @type {string[]}
27
- */
17
+ export async function runHermesEmitBinaryCommand(bundleName, outputPath, sourcemapOutput, extraHermesFlags = []) {
28
18
  const hermesArgs = [
29
19
  '-emit-binary',
30
20
  '-out',
@@ -35,23 +25,20 @@ async function runHermesEmitBinaryCommand(
35
25
  if (sourcemapOutput) {
36
26
  hermesArgs.push('-output-source-map');
37
27
  }
38
-
39
28
  console.log('Converting JS bundle to byte code via Hermes, running command:\n');
40
-
41
29
  return new Promise((resolve, reject) => {
42
30
  try {
43
31
  const hermesCommand = getHermesCommand();
44
-
45
32
  const disableAllWarningsArg = '-w';
46
33
  shell.exec(`${hermesCommand} ${hermesArgs.join(' ')} ${disableAllWarningsArg}`);
47
-
48
34
  // Copy HBC bundle to overwrite JS bundle
49
35
  const source = path.join(outputPath, bundleName + '.hbc');
50
36
  const destination = path.join(outputPath, bundleName);
51
37
  shell.cp(source, destination);
52
38
  shell.rm(source);
53
39
  resolve();
54
- } catch (e) {
40
+ }
41
+ catch (e) {
55
42
  reject(e);
56
43
  }
57
44
  }).then(() => {
@@ -59,18 +46,15 @@ async function runHermesEmitBinaryCommand(
59
46
  // skip source map compose if source map is not enabled
60
47
  return;
61
48
  }
62
-
63
49
  // compose-source-maps.js file path
64
50
  const composeSourceMapsPath = getComposeSourceMapsPath();
65
51
  if (composeSourceMapsPath === null) {
66
52
  throw new Error('react-native compose-source-maps.js scripts is not found');
67
53
  }
68
-
69
54
  const jsCompilerSourceMapFile = path.join(outputPath, bundleName + '.hbc' + '.map');
70
55
  if (!fs.existsSync(jsCompilerSourceMapFile)) {
71
56
  throw new Error(`sourcemap file ${jsCompilerSourceMapFile} is not found`);
72
57
  }
73
-
74
58
  return new Promise((resolve, reject) => {
75
59
  const composeSourceMapsArgs = [
76
60
  composeSourceMapsPath,
@@ -81,65 +65,43 @@ async function runHermesEmitBinaryCommand(
81
65
  ];
82
66
  const composeSourceMapsProcess = childProcess.spawn('node', composeSourceMapsArgs);
83
67
  console.log(`${composeSourceMapsPath} ${composeSourceMapsArgs.join(' ')}`);
84
-
85
68
  composeSourceMapsProcess.stdout.on('data', (data) => {
86
69
  console.log(data.toString().trim());
87
70
  });
88
-
89
71
  composeSourceMapsProcess.stderr.on('data', (data) => {
90
72
  console.error(data.toString().trim());
91
73
  });
92
-
93
74
  composeSourceMapsProcess.on('close', (exitCode, signal) => {
94
75
  if (exitCode !== 0) {
95
76
  reject(new Error(`"compose-source-maps" command failed (exitCode=${exitCode}, signal=${signal}).`));
96
77
  }
97
-
98
78
  // Delete the HBC sourceMap, otherwise it will be included in 'code-push' bundle as well
99
79
  fs.unlink(jsCompilerSourceMapFile, (err) => {
100
80
  if (err != null) {
101
81
  console.error(err);
102
82
  reject(err);
103
83
  }
104
-
105
84
  resolve();
106
85
  });
107
86
  });
108
87
  });
109
88
  });
110
89
  }
111
-
112
- /**
113
- * @return {string}
114
- */
115
90
  function getHermesCommand() {
116
- /**
117
- * @type {(file: string) => boolean}
118
- */
119
91
  const fileExists = (file) => {
120
92
  try {
121
93
  return fs.statSync(file).isFile();
122
- } catch (e) {
94
+ }
95
+ catch (e) {
123
96
  return false;
124
97
  }
125
98
  };
126
- // Hermes is bundled with react-native since 0.69
127
- const bundledHermesEngine = path.join(
128
- getReactNativePackagePath(),
129
- 'sdks',
130
- 'hermesc',
131
- getHermesOSBin(),
132
- getHermesOSExe(),
133
- );
134
- if (fileExists(bundledHermesEngine)) {
135
- return bundledHermesEngine;
99
+ const hermescExecutable = path.join(getHermesCompilerPath(), getHermesOSBin(), getHermesOSExe());
100
+ if (fileExists(hermescExecutable)) {
101
+ return hermescExecutable;
136
102
  }
137
103
  throw new Error('Hermes engine binary not found. Please upgrade to react-native 0.69 or later');
138
104
  }
139
-
140
- /**
141
- * @return {string}
142
- */
143
105
  function getHermesOSBin() {
144
106
  switch (process.platform) {
145
107
  case 'win32':
@@ -153,10 +115,6 @@ function getHermesOSBin() {
153
115
  return 'linux64-bin';
154
116
  }
155
117
  }
156
-
157
- /**
158
- * @return {string}
159
- */
160
118
  function getHermesOSExe() {
161
119
  const hermesExecutableName = 'hermesc';
162
120
  switch (process.platform) {
@@ -166,10 +124,6 @@ function getHermesOSExe() {
166
124
  return hermesExecutableName;
167
125
  }
168
126
  }
169
-
170
- /**
171
- * @return {string | null}
172
- */
173
127
  function getComposeSourceMapsPath() {
174
128
  // detect if compose-source-maps.js script exists
175
129
  const composeSourceMaps = path.join(getReactNativePackagePath(), 'scripts', 'compose-source-maps.js');
@@ -178,10 +132,6 @@ function getComposeSourceMapsPath() {
178
132
  }
179
133
  return null;
180
134
  }
181
-
182
- /**
183
- * @return {string}
184
- */
185
135
  function getReactNativePackagePath() {
186
136
  const result = childProcess.spawnSync('node', [
187
137
  '--print',
@@ -191,23 +141,38 @@ function getReactNativePackagePath() {
191
141
  if (result.status === 0 && directoryExistsSync(packagePath)) {
192
142
  return packagePath;
193
143
  }
194
-
195
144
  return path.join('node_modules', 'react-native');
196
145
  }
197
-
198
- /**
199
- * @param dirname {string}
200
- * @return {boolean}
201
- */
146
+ function getHermescDirPathInHermesCompilerPackage() {
147
+ const result = childProcess.spawnSync('node', [
148
+ '--print',
149
+ "require.resolve('hermes-compiler/package.json')",
150
+ ]);
151
+ const packagePath = path.dirname(result.stdout.toString());
152
+ const hermescDirPath = path.join(packagePath, 'hermesc');
153
+ if (result.status === 0 && directoryExistsSync(hermescDirPath)) {
154
+ return hermescDirPath;
155
+ }
156
+ return null;
157
+ }
158
+ function getHermesCompilerPath() {
159
+ const hermescDirPath = getHermescDirPathInHermesCompilerPackage();
160
+ if (hermescDirPath) {
161
+ // Since react-native 0.83, Hermes compiler executables are in 'hermes-compiler' package
162
+ return hermescDirPath;
163
+ }
164
+ else {
165
+ return path.join(getReactNativePackagePath(), 'sdks', 'hermesc');
166
+ }
167
+ }
202
168
  function directoryExistsSync(dirname) {
203
169
  try {
204
170
  return fs.statSync(dirname).isDirectory();
205
- } catch (err) {
171
+ }
172
+ catch (err) {
206
173
  if (err.code !== 'ENOENT') {
207
174
  throw err;
208
175
  }
209
176
  }
210
177
  return false;
211
178
  }
212
-
213
- module.exports = { runHermesEmitBinaryCommand };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * code based on appcenter-cli
3
3
  */
4
-
5
- const path = require('path');
6
- const shell = require('shelljs');
7
-
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { createRequire } from "module";
7
+ import shell from "shelljs";
8
8
  /**
9
9
  * Run `react-native bundle` CLI command
10
10
  *
@@ -16,24 +16,23 @@ const shell = require('shelljs');
16
16
  * @param extraBundlerOptions {string[]} Additional options to pass to `react-native bundle` command
17
17
  * @return {void}
18
18
  */
19
- function runReactNativeBundleCommand(
20
- bundleName,
21
- outputPath,
22
- platform,
23
- sourcemapOutput,
24
- entryFile,
25
- extraBundlerOptions = [],
26
- ) {
27
- /**
28
- * @return {string}
29
- */
19
+ export function runReactNativeBundleCommand(bundleName, outputPath, platform, sourcemapOutput, entryFile, extraBundlerOptions = []) {
30
20
  function getCliPath() {
31
- return path.join('node_modules', '.bin', 'react-native');
21
+ // pnpm hoisted 레이아웃에서는 react-native가 워크스페이스 루트로 호이스트되어
22
+ // cwd 상대 node_modules/.bin 경로가 존재하지 않을 수 있다. 로컬 .bin을 우선
23
+ // 사용하고, 없으면 Node resolution(상위 디렉토리 탐색)으로 패키지 bin을 찾는다.
24
+ const localBin = path.join('node_modules', '.bin', 'react-native');
25
+ if (fs.existsSync(localBin)) {
26
+ return localBin;
27
+ }
28
+ const requireFromCwd = createRequire(path.resolve('package.json'));
29
+ const packageJsonPath = requireFromCwd.resolve('react-native/package.json');
30
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
31
+ const binRelativePath = typeof packageJson.bin === 'string'
32
+ ? packageJson.bin
33
+ : packageJson.bin['react-native'];
34
+ return `node "${path.join(path.dirname(packageJsonPath), binRelativePath)}"`;
32
35
  }
33
-
34
- /**
35
- * @type {string[]}
36
- */
37
36
  const reactNativeBundleArgs = [
38
37
  'bundle',
39
38
  '--assets-dest',
@@ -50,10 +49,6 @@ function runReactNativeBundleCommand(
50
49
  sourcemapOutput,
51
50
  ...extraBundlerOptions,
52
51
  ];
53
-
54
52
  console.log('Running "react-native bundle" command:\n');
55
-
56
53
  shell.exec(`${getCliPath()} ${reactNativeBundleArgs.join(' ')}`);
57
54
  }
58
-
59
- module.exports = { runReactNativeBundleCommand };
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import { program } from "commander";
3
+ import shell from "shelljs";
4
+ import { showLogo } from "./utils/showLogo.js";
5
+ /**
6
+ * npx code-push bundle
7
+ */
8
+ import "./commands/bundleCommand/index.js";
9
+ /**
10
+ * npx code-push create-history
11
+ */
12
+ import "./commands/createHistoryCommand/index.js";
13
+ /**
14
+ * npx code-push update-history
15
+ */
16
+ import "./commands/updateHistoryCommand/index.js";
17
+ /**
18
+ * npx code-push release
19
+ */
20
+ import "./commands/releaseCommand/index.js";
21
+ /**
22
+ * npx code-push show-history
23
+ */
24
+ import "./commands/showHistoryCommand/index.js";
25
+ /**
26
+ * npx code-push init
27
+ */
28
+ import "./commands/initCommand/index.js";
29
+ /**
30
+ * npx code-push create-pr-history
31
+ */
32
+ import "./commands/createPullRequestHistoryCommand/index.js";
33
+ /**
34
+ * npx code-push create-pr-release
35
+ */
36
+ import "./commands/createPullRequestReleaseCommand/index.js";
37
+ /**
38
+ * npx code-push remove-pr-history
39
+ */
40
+ import "./commands/removePullRequestHistoryCommand/index.js";
41
+ /**
42
+ * npx code-push get-package-hash
43
+ */
44
+ import "./commands/getPackageHashCommand/index.js";
45
+ shell.set("-e");
46
+ shell.set("+v");
47
+ program
48
+ .name("npx code-push")
49
+ .description("Command line interface for @algocare/react-native-code-push")
50
+ .version("1.0.0")
51
+ .action(() => {
52
+ showLogo();
53
+ });
54
+ program.parse();
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns the current local timestamp in `YYYY-MM-DD HH:mm:ss` format.
3
+ * Recorded in release history entries as `createdAt` / `updatedAt`.
4
+ */
5
+ export function getTimestamp() {
6
+ const date = new Date();
7
+ const year = date.getFullYear();
8
+ const month = padWithZero(date.getMonth() + 1);
9
+ const day = padWithZero(date.getDate());
10
+ const hour = padWithZero(date.getHours());
11
+ const minute = padWithZero(date.getMinutes());
12
+ const second = padWithZero(date.getSeconds());
13
+ return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
14
+ }
15
+ function padWithZero(value) {
16
+ return value < 10 ? `0${value}` : `${value}`;
17
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * code based on appcenter-cli
3
+ */
4
+ import fs from "fs";
5
+ export function isDirectory(path) {
6
+ return fs.statSync(path).isDirectory();
7
+ }
8
+ export function generateRandomFilename(length) {
9
+ let filename = '';
10
+ const validChar = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
11
+ for (let i = 0; i < length; i++) {
12
+ filename += validChar.charAt(Math.floor(Math.random() * validChar.length));
13
+ }
14
+ return filename;
15
+ }
16
+ export function normalizePath(filePath) {
17
+ //replace all backslashes coming from cli running on windows machines by slashes
18
+ return filePath.replace(/\\/g, '/');
19
+ }