@algocare/react-native-code-push 9.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CONTRIBUTING.md +134 -0
  3. package/CodePush.js +778 -0
  4. package/CodePush.podspec +27 -0
  5. package/LICENSE.md +13 -0
  6. package/README.md +491 -0
  7. package/SECURITY.md +41 -0
  8. package/android/app/build.gradle +31 -0
  9. package/android/app/proguard-rules.pro +25 -0
  10. package/android/app/src/main/AndroidManifest.xml +6 -0
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +441 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +35 -0
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +714 -0
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +383 -0
  24. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +268 -0
  26. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +238 -0
  27. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +203 -0
  30. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
  31. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
  32. package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
  33. package/android/build.gradle +21 -0
  34. package/android/codepush.gradle +162 -0
  35. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  36. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  37. package/android/gradle.properties +20 -0
  38. package/android/gradlew +164 -0
  39. package/android/gradlew.bat +90 -0
  40. package/android/settings.gradle +1 -0
  41. package/babel.config.js +3 -0
  42. package/cli/commands/bundleCommand/bundleCodePush.js +57 -0
  43. package/cli/commands/bundleCommand/index.js +29 -0
  44. package/cli/commands/createHistoryCommand/createReleaseHistory.js +53 -0
  45. package/cli/commands/createHistoryCommand/index.js +29 -0
  46. package/cli/commands/releaseCommand/addToReleaseHistory.js +75 -0
  47. package/cli/commands/releaseCommand/index.js +66 -0
  48. package/cli/commands/releaseCommand/release.js +109 -0
  49. package/cli/commands/showHistoryCommand/index.js +29 -0
  50. package/cli/commands/updateHistoryCommand/index.js +50 -0
  51. package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +62 -0
  52. package/cli/constant.js +6 -0
  53. package/cli/functions/getReactTempDir.js +16 -0
  54. package/cli/functions/makeCodePushBundle.js +28 -0
  55. package/cli/functions/prepareToBundleJS.js +12 -0
  56. package/cli/functions/runHermesEmitBinaryCommand.js +213 -0
  57. package/cli/functions/runReactNativeBundleCommand.js +59 -0
  58. package/cli/index.js +43 -0
  59. package/cli/utils/file-utils.js +42 -0
  60. package/cli/utils/fsUtils.js +49 -0
  61. package/cli/utils/hash-utils.js +227 -0
  62. package/cli/utils/promisfied-fs.js +29 -0
  63. package/cli/utils/showLogo.js +23 -0
  64. package/cli/utils/zip.js +89 -0
  65. package/code-push.config.example.supabase.ts +114 -0
  66. package/docs/api-android.md +83 -0
  67. package/docs/api-ios.md +31 -0
  68. package/docs/api-js.md +592 -0
  69. package/docs/multi-deployment-testing-android.md +148 -0
  70. package/docs/multi-deployment-testing-ios.md +59 -0
  71. package/docs/setup-android.md +482 -0
  72. package/docs/setup-ios.md +280 -0
  73. package/eslint.config.mjs +32 -0
  74. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  75. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  76. package/ios/CodePush/Base64/README.md +47 -0
  77. package/ios/CodePush/CodePush.h +235 -0
  78. package/ios/CodePush/CodePush.m +1121 -0
  79. package/ios/CodePush/CodePushConfig.m +116 -0
  80. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  81. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  82. package/ios/CodePush/CodePushPackage.m +602 -0
  83. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  84. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  85. package/ios/CodePush/CodePushUtils.m +9 -0
  86. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  87. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  88. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  89. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  90. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  91. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  92. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  93. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  94. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  95. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  96. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  97. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  98. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  99. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  100. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  101. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  102. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  103. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  104. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  105. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  106. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  107. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  108. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  109. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  110. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  111. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  112. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  113. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  114. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  115. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  116. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  117. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  118. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  119. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  120. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  121. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  122. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  123. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  124. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  125. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  126. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  127. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  128. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  129. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  130. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  131. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  132. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  133. package/ios/CodePush/JWT/LICENSE +19 -0
  134. package/ios/CodePush/JWT/README.md +489 -0
  135. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  136. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  137. package/ios/CodePush/SSZipArchive/Common.h +81 -0
  138. package/ios/CodePush/SSZipArchive/README.md +1 -0
  139. package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
  140. package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
  141. package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
  142. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
  143. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
  144. package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
  145. package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
  146. package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
  147. package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
  148. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
  149. package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
  150. package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
  151. package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
  152. package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
  153. package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
  154. package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
  155. package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
  156. package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
  157. package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
  158. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
  159. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
  160. package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
  161. package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
  162. package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
  163. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
  164. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
  165. package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
  166. package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
  167. package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
  168. package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
  169. package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
  170. package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
  171. package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
  172. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  173. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  174. package/logging.js +6 -0
  175. package/package-mixins.js +61 -0
  176. package/package.json +84 -0
  177. package/react-native.config.js +12 -0
  178. package/scripts/generateBundledResourcesHash.js +125 -0
  179. package/scripts/getFilesInFolder.js +19 -0
  180. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  181. package/tsconfig.json +14 -0
  182. package/tslint.json +32 -0
  183. package/typings/react-native-code-push.d.ts +589 -0
  184. package/versioning/BaseVersioning.js +126 -0
  185. package/versioning/BaseVersioning.test.js +15 -0
  186. package/versioning/IncrementalVersioning.js +9 -0
  187. package/versioning/IncrementalVersioning.test.js +186 -0
  188. package/versioning/SemverVersioning.js +10 -0
  189. package/versioning/SemverVersioning.test.js +205 -0
  190. package/versioning/index.js +7 -0
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ##############################################################################
4
+ ##
5
+ ## Gradle start up script for UN*X
6
+ ##
7
+ ##############################################################################
8
+
9
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
+ DEFAULT_JVM_OPTS=""
11
+
12
+ APP_NAME="Gradle"
13
+ APP_BASE_NAME=`basename "$0"`
14
+
15
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
16
+ MAX_FD="maximum"
17
+
18
+ warn ( ) {
19
+ echo "$*"
20
+ }
21
+
22
+ die ( ) {
23
+ echo
24
+ echo "$*"
25
+ echo
26
+ exit 1
27
+ }
28
+
29
+ # OS specific support (must be 'true' or 'false').
30
+ cygwin=false
31
+ msys=false
32
+ darwin=false
33
+ case "`uname`" in
34
+ CYGWIN* )
35
+ cygwin=true
36
+ ;;
37
+ Darwin* )
38
+ darwin=true
39
+ ;;
40
+ MINGW* )
41
+ msys=true
42
+ ;;
43
+ esac
44
+
45
+ # For Cygwin, ensure paths are in UNIX format before anything is touched.
46
+ if $cygwin ; then
47
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
+ fi
49
+
50
+ # Attempt to set APP_HOME
51
+ # Resolve links: $0 may be a link
52
+ PRG="$0"
53
+ # Need this for relative symlinks.
54
+ while [ -h "$PRG" ] ; do
55
+ ls=`ls -ld "$PRG"`
56
+ link=`expr "$ls" : '.*-> \(.*\)$'`
57
+ if expr "$link" : '/.*' > /dev/null; then
58
+ PRG="$link"
59
+ else
60
+ PRG=`dirname "$PRG"`"/$link"
61
+ fi
62
+ done
63
+ SAVED="`pwd`"
64
+ cd "`dirname \"$PRG\"`/" >&-
65
+ APP_HOME="`pwd -P`"
66
+ cd "$SAVED" >&-
67
+
68
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69
+
70
+ # Determine the Java command to use to start the JVM.
71
+ if [ -n "$JAVA_HOME" ] ; then
72
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73
+ # IBM's JDK on AIX uses strange locations for the executables
74
+ JAVACMD="$JAVA_HOME/jre/sh/java"
75
+ else
76
+ JAVACMD="$JAVA_HOME/bin/java"
77
+ fi
78
+ if [ ! -x "$JAVACMD" ] ; then
79
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80
+
81
+ Please set the JAVA_HOME variable in your environment to match the
82
+ location of your Java installation."
83
+ fi
84
+ else
85
+ JAVACMD="java"
86
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87
+
88
+ Please set the JAVA_HOME variable in your environment to match the
89
+ location of your Java installation."
90
+ fi
91
+
92
+ # Increase the maximum file descriptors if we can.
93
+ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94
+ MAX_FD_LIMIT=`ulimit -H -n`
95
+ if [ $? -eq 0 ] ; then
96
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97
+ MAX_FD="$MAX_FD_LIMIT"
98
+ fi
99
+ ulimit -n $MAX_FD
100
+ if [ $? -ne 0 ] ; then
101
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
102
+ fi
103
+ else
104
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105
+ fi
106
+ fi
107
+
108
+ # For Darwin, add options to specify how the application appears in the dock
109
+ if $darwin; then
110
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111
+ fi
112
+
113
+ # For Cygwin, switch paths to Windows format before running java
114
+ if $cygwin ; then
115
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117
+
118
+ # We build the pattern for arguments to be converted via cygpath
119
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
+ SEP=""
121
+ for dir in $ROOTDIRSRAW ; do
122
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
123
+ SEP="|"
124
+ done
125
+ OURCYGPATTERN="(^($ROOTDIRS))"
126
+ # Add a user-defined pattern to the cygpath arguments
127
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
+ fi
130
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
+ i=0
132
+ for arg in "$@" ; do
133
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135
+
136
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
+ else
139
+ eval `echo args$i`="\"$arg\""
140
+ fi
141
+ i=$((i+1))
142
+ done
143
+ case $i in
144
+ (0) set -- ;;
145
+ (1) set -- "$args0" ;;
146
+ (2) set -- "$args0" "$args1" ;;
147
+ (3) set -- "$args0" "$args1" "$args2" ;;
148
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
+ esac
155
+ fi
156
+
157
+ # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158
+ function splitJvmOpts() {
159
+ JVM_OPTS=("$@")
160
+ }
161
+ eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
+ JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163
+
164
+ exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@@ -0,0 +1,90 @@
1
+ @if "%DEBUG%" == "" @echo off
2
+ @rem ##########################################################################
3
+ @rem
4
+ @rem Gradle startup script for Windows
5
+ @rem
6
+ @rem ##########################################################################
7
+
8
+ @rem Set local scope for the variables with windows NT shell
9
+ if "%OS%"=="Windows_NT" setlocal
10
+
11
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
+ set DEFAULT_JVM_OPTS=
13
+
14
+ set DIRNAME=%~dp0
15
+ if "%DIRNAME%" == "" set DIRNAME=.
16
+ set APP_BASE_NAME=%~n0
17
+ set APP_HOME=%DIRNAME%
18
+
19
+ @rem Find java.exe
20
+ if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+ set JAVA_EXE=java.exe
23
+ %JAVA_EXE% -version >NUL 2>&1
24
+ if "%ERRORLEVEL%" == "0" goto init
25
+
26
+ echo.
27
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+ echo.
29
+ echo Please set the JAVA_HOME variable in your environment to match the
30
+ echo location of your Java installation.
31
+
32
+ goto fail
33
+
34
+ :findJavaFromJavaHome
35
+ set JAVA_HOME=%JAVA_HOME:"=%
36
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+ if exist "%JAVA_EXE%" goto init
39
+
40
+ echo.
41
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+ echo.
43
+ echo Please set the JAVA_HOME variable in your environment to match the
44
+ echo location of your Java installation.
45
+
46
+ goto fail
47
+
48
+ :init
49
+ @rem Get command-line arguments, handling Windowz variants
50
+
51
+ if not "%OS%" == "Windows_NT" goto win9xME_args
52
+ if "%@eval[2+2]" == "4" goto 4NT_args
53
+
54
+ :win9xME_args
55
+ @rem Slurp the command line arguments.
56
+ set CMD_LINE_ARGS=
57
+ set _SKIP=2
58
+
59
+ :win9xME_args_slurp
60
+ if "x%~1" == "x" goto execute
61
+
62
+ set CMD_LINE_ARGS=%*
63
+ goto execute
64
+
65
+ :4NT_args
66
+ @rem Get arguments from the 4NT Shell from JP Software
67
+ set CMD_LINE_ARGS=%$
68
+
69
+ :execute
70
+ @rem Setup the command line
71
+
72
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+
74
+ @rem Execute Gradle
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76
+
77
+ :end
78
+ @rem End local scope for the variables with windows NT shell
79
+ if "%ERRORLEVEL%"=="0" goto mainEnd
80
+
81
+ :fail
82
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+ rem the _cmd.exe /c_ return code!
84
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85
+ exit /b 1
86
+
87
+ :mainEnd
88
+ if "%OS%"=="Windows_NT" endlocal
89
+
90
+ :omega
@@ -0,0 +1 @@
1
+ include ':app'
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
3
+ };
@@ -0,0 +1,57 @@
1
+ const fs = require('fs');
2
+ const { prepareToBundleJS } = require('../../functions/prepareToBundleJS');
3
+ const { runReactNativeBundleCommand } = require('../../functions/runReactNativeBundleCommand');
4
+ const { getReactTempDir } = require('../../functions/getReactTempDir');
5
+ const { runHermesEmitBinaryCommand } = require('../../functions/runHermesEmitBinaryCommand');
6
+ const { makeCodePushBundle } = require('../../functions/makeCodePushBundle');
7
+ const { ROOT_OUTPUT_DIR, ENTRY_FILE } = require('../../constant');
8
+
9
+ /**
10
+ * @param platform {string} 'ios' | 'android'
11
+ * @param outputRootPath {string}
12
+ * @param entryFile {string}
13
+ * @param jsBundleName {string|undefined}
14
+ * @param bundleDirectory {string}
15
+ * @return {Promise<string>} CodePush bundle file name (equals to packageHash)
16
+ */
17
+ async function bundleCodePush(
18
+ platform = 'ios',
19
+ outputRootPath = ROOT_OUTPUT_DIR,
20
+ entryFile = ENTRY_FILE,
21
+ jsBundleName, // JS bundle file name (not CodePush bundle file)
22
+ bundleDirectory, // CodePush bundle output directory
23
+ ) {
24
+ if (fs.existsSync(outputRootPath)) {
25
+ fs.rmSync(outputRootPath, { recursive: true });
26
+ }
27
+
28
+ const OUTPUT_CONTENT_PATH = `${outputRootPath}/CodePush`;
29
+ const DEFAULT_JS_BUNDLE_NAME = platform === 'ios' ? 'main.jsbundle' : 'index.android.bundle';
30
+ const _jsBundleName = jsBundleName || DEFAULT_JS_BUNDLE_NAME; // react-native JS bundle output name
31
+ const SOURCEMAP_OUTPUT = `${outputRootPath}/${_jsBundleName}.map`;
32
+
33
+ prepareToBundleJS({ deleteDirs: [outputRootPath, getReactTempDir()], makeDir: OUTPUT_CONTENT_PATH });
34
+
35
+ runReactNativeBundleCommand(
36
+ _jsBundleName,
37
+ OUTPUT_CONTENT_PATH,
38
+ platform,
39
+ SOURCEMAP_OUTPUT,
40
+ entryFile,
41
+ );
42
+ console.log('log: JS bundling complete');
43
+
44
+ await runHermesEmitBinaryCommand(
45
+ _jsBundleName,
46
+ OUTPUT_CONTENT_PATH,
47
+ SOURCEMAP_OUTPUT,
48
+ );
49
+ console.log('log: Hermes compilation complete');
50
+
51
+ const { bundleFileName: codePushBundleFileName } = await makeCodePushBundle(OUTPUT_CONTENT_PATH, bundleDirectory);
52
+ console.log(`log: CodePush bundle created (file path: ./${bundleDirectory}/${codePushBundleFileName})`);
53
+
54
+ return codePushBundleFileName;
55
+ }
56
+
57
+ module.exports = { bundleCodePush: bundleCodePush };
@@ -0,0 +1,29 @@
1
+ const { program, Option } = require("commander");
2
+ const { bundleCodePush } = require("./bundleCodePush");
3
+ const { OUTPUT_BUNDLE_DIR, ROOT_OUTPUT_DIR, ENTRY_FILE } = require('../../constant');
4
+
5
+ program.command('bundle')
6
+ .description('Creates a CodePush bundle file (assumes Hermes is enabled).')
7
+ .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
8
+ .option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
9
+ .option('-e, --entry-file <string>', 'path to JS/TS entry file', ENTRY_FILE)
10
+ .option('-b, --bundle-name <string>', 'bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
11
+ .option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
12
+ /**
13
+ * @param {Object} options
14
+ * @param {string} options.platform
15
+ * @param {string} options.outputPath
16
+ * @param {string} options.entryFile
17
+ * @param {string} options.bundleName
18
+ * @param {string} options.outputBundleDir
19
+ * @return {void}
20
+ */
21
+ .action((options) => {
22
+ bundleCodePush(
23
+ options.platform,
24
+ options.outputPath,
25
+ options.entryFile,
26
+ options.bundleName,
27
+ `${options.outputPath}/${options.outputBundleDir}`,
28
+ )
29
+ });
@@ -0,0 +1,53 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ *
6
+ * @param targetVersion {string}
7
+ * @param setReleaseHistory {
8
+ * function(
9
+ * targetBinaryVersion: string,
10
+ * jsonFilePath: string,
11
+ * releaseInfo: ReleaseHistoryInterface,
12
+ * platform: string,
13
+ * identifier: string
14
+ * ): Promise<void>}
15
+ * @param platform {"ios" | "android"}
16
+ * @param identifier {string}
17
+ * @returns {Promise<void>}
18
+ */
19
+ async function createReleaseHistory(
20
+ targetVersion,
21
+ setReleaseHistory,
22
+ platform,
23
+ identifier,
24
+ ) {
25
+ const BINARY_RELEASE = {
26
+ enabled: true,
27
+ mandatory: false,
28
+ downloadUrl: "",
29
+ packageHash: "",
30
+ };
31
+
32
+ /** @type {ReleaseHistoryInterface} */
33
+ const INITIAL_HISTORY = {
34
+ [targetVersion]: BINARY_RELEASE
35
+ };
36
+
37
+ try {
38
+ const JSON_FILE_NAME = `${targetVersion}.json`;
39
+ const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
40
+
41
+ console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(INITIAL_HISTORY, null, 2));
42
+ fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(INITIAL_HISTORY));
43
+
44
+ await setReleaseHistory(targetVersion, JSON_FILE_PATH, INITIAL_HISTORY, platform, identifier)
45
+
46
+ fs.unlinkSync(JSON_FILE_PATH);
47
+ } catch (error) {
48
+ console.error('Error occurred while creating new history:', error);
49
+ process.exit(1)
50
+ }
51
+ }
52
+
53
+ module.exports = { createReleaseHistory: createReleaseHistory }
@@ -0,0 +1,29 @@
1
+ const { program, Option } = require("commander");
2
+ const { findAndReadConfigFile } = require("../../utils/fsUtils");
3
+ const { createReleaseHistory } = require("./createReleaseHistory");
4
+ const { CONFIG_FILE_NAME } = require('../../constant');
5
+
6
+ program.command('create-history')
7
+ .description('Creates a new release history for the binary app.')
8
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
9
+ .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
10
+ .option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
11
+ .option('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
12
+ /**
13
+ * @param {Object} options
14
+ * @param {string} options.binaryVersion
15
+ * @param {string} options.platform
16
+ * @param {string} options.identifier
17
+ * @param {string} options.config
18
+ * @return {void}
19
+ */
20
+ .action(async (options) => {
21
+ const config = findAndReadConfigFile(process.cwd(), options.config);
22
+
23
+ await createReleaseHistory(
24
+ options.binaryVersion,
25
+ config.setReleaseHistory,
26
+ options.platform,
27
+ options.identifier
28
+ );
29
+ });
@@ -0,0 +1,75 @@
1
+ const path = require("path");
2
+ const fs = require("fs");
3
+
4
+ /**
5
+ *
6
+ * @param appVersion {string}
7
+ * @param binaryVersion {string}
8
+ * @param bundleDownloadUrl {string}
9
+ * @param packageHash {string}
10
+ * @param getReleaseHistory {
11
+ * function(
12
+ * targetBinaryVersion: string,
13
+ * platform: string,
14
+ * identifier?: string
15
+ * ): Promise<ReleaseHistoryInterface>}
16
+ * @param setReleaseHistory {
17
+ * function(
18
+ * targetBinaryVersion: string,
19
+ * jsonFilePath: string,
20
+ * releaseInfo: ReleaseHistoryInterface,
21
+ * platform: string,
22
+ * identifier?: string
23
+ * ): Promise<void>}
24
+ * @param platform {"ios" | "android"}
25
+ * @param identifier {string?}
26
+ * @param mandatory {boolean?}
27
+ * @param enable {boolean?}
28
+ * @returns {Promise<void>}
29
+ */
30
+ async function addToReleaseHistory(
31
+ appVersion,
32
+ binaryVersion,
33
+ bundleDownloadUrl,
34
+ packageHash,
35
+ getReleaseHistory,
36
+ setReleaseHistory,
37
+ platform,
38
+ identifier,
39
+ mandatory,
40
+ enable,
41
+ ) {
42
+ const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier);
43
+
44
+ const updateInfo = releaseHistory[appVersion]
45
+ if (updateInfo) {
46
+ console.error(`v${appVersion} is already released`)
47
+ process.exit(1)
48
+ }
49
+
50
+ const newReleaseHistory = structuredClone(releaseHistory);
51
+
52
+ newReleaseHistory[appVersion] = {
53
+ enabled: enable,
54
+ mandatory: mandatory,
55
+ downloadUrl: bundleDownloadUrl,
56
+ packageHash: packageHash,
57
+ }
58
+
59
+ try {
60
+ const JSON_FILE_NAME = `${binaryVersion}.json`;
61
+ const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
62
+
63
+ console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(newReleaseHistory, null, 2));
64
+ fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory));
65
+
66
+ await setReleaseHistory(binaryVersion, JSON_FILE_PATH, newReleaseHistory, platform, identifier)
67
+
68
+ fs.unlinkSync(JSON_FILE_PATH);
69
+ } catch (error) {
70
+ console.error('Error occurred while updating history:', error);
71
+ process.exit(1)
72
+ }
73
+ }
74
+
75
+ module.exports = { addToReleaseHistory: addToReleaseHistory }
@@ -0,0 +1,66 @@
1
+ const { program, Option } = require("commander");
2
+ const { findAndReadConfigFile } = require("../../utils/fsUtils");
3
+ const { release } = require("./release");
4
+ const { OUTPUT_BUNDLE_DIR, CONFIG_FILE_NAME, ROOT_OUTPUT_DIR, ENTRY_FILE } = require('../../constant');
5
+
6
+ program.command('release')
7
+ .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.')
8
+ .requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
9
+ .requiredOption('-v, --app-version <string>', '(Required) The app version to be released. It must be greater than the binary version.')
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('-c, --config <path>', 'set config file name (JS/TS)', CONFIG_FILE_NAME)
13
+ .option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
14
+ .option('-e, --entry-file <string>', 'path to JS/TS entry file', ENTRY_FILE)
15
+ .option('-j, --js-bundle-name <string>', 'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
16
+ .option('-m, --mandatory <bool>', 'make the release to be mandatory', parseBoolean, false)
17
+ .option('--enable <bool>', 'make the release to be enabled', parseBoolean, true)
18
+ .option('--skip-bundle <bool>', 'skip bundle process', parseBoolean, false)
19
+ .option('--skip-cleanup <bool>', 'skip cleanup process', parseBoolean, false)
20
+ .option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
21
+ /**
22
+ * @param {Object} options
23
+ * @param {string} options.binaryVersion
24
+ * @param {string} options.appVersion
25
+ * @param {string} options.platform
26
+ * @param {string} options.identifier
27
+ * @param {string} options.config
28
+ * @param {string} options.outputPath
29
+ * @param {string} options.entryFile
30
+ * @param {string} options.bundleName
31
+ * @param {string} options.mandatory
32
+ * @param {string} options.enable
33
+ * @param {string} options.skipBundle
34
+ * @param {string} options.skipCleanup
35
+ * @param {string} options.outputBundleDir
36
+ * @return {void}
37
+ */
38
+ .action(async (options) => {
39
+ const config = findAndReadConfigFile(process.cwd(), options.config);
40
+
41
+ await release(
42
+ config.bundleUploader,
43
+ config.getReleaseHistory,
44
+ config.setReleaseHistory,
45
+ options.binaryVersion,
46
+ options.appVersion,
47
+ options.platform,
48
+ options.identifier,
49
+ options.outputPath,
50
+ options.entryFile,
51
+ options.bundleName,
52
+ options.mandatory,
53
+ options.enable,
54
+ options.skipBundle,
55
+ options.skipCleanup,
56
+ `${options.outputPath}/${options.outputBundleDir}`,
57
+ )
58
+
59
+ console.log('🚀 Release completed.')
60
+ });
61
+
62
+ function parseBoolean(value) {
63
+ if (value === 'true') return true;
64
+ if (value === 'false') return false;
65
+ else return undefined;
66
+ }
@@ -0,0 +1,109 @@
1
+ const fs = require('fs');
2
+ const { bundleCodePush } = require("../bundleCommand/bundleCodePush");
3
+ const { addToReleaseHistory } = require("./addToReleaseHistory");
4
+
5
+ /**
6
+ * @param bundleUploader {
7
+ * function(
8
+ * source: string,
9
+ * platform: "ios" | "android",
10
+ * identifier?: string
11
+ * ): Promise<{ downloadUrl: string }>}
12
+ * @param getReleaseHistory {
13
+ * function(
14
+ * targetBinaryVersion: string,
15
+ * platform: "ios" | "android",
16
+ * identifier?: string
17
+ * ): Promise<ReleaseHistoryInterface>}
18
+ * @param setReleaseHistory {
19
+ * function(
20
+ * targetBinaryVersion: string,
21
+ * jsonFilePath: string,
22
+ * releaseInfo: ReleaseHistoryInterface,
23
+ * platform: "ios" | "android",
24
+ * identifier?: string
25
+ * ): Promise<void>}
26
+ * @param binaryVersion {string}
27
+ * @param appVersion {string}
28
+ * @param platform {"ios" | "android"}
29
+ * @param identifier {string?}
30
+ * @param outputPath {string}
31
+ * @param entryFile {string}
32
+ * @param jsBundleName {string}
33
+ * @param mandatory {boolean}
34
+ * @param enable {boolean}
35
+ * @param skipBundle {boolean}
36
+ * @param skipCleanup {boolean}
37
+ * @param bundleDirectory {string}
38
+ * @return {Promise<void>}
39
+ */
40
+ async function release(
41
+ bundleUploader,
42
+ getReleaseHistory,
43
+ setReleaseHistory,
44
+ binaryVersion,
45
+ appVersion,
46
+ platform,
47
+ identifier,
48
+ outputPath,
49
+ entryFile,
50
+ jsBundleName,
51
+ mandatory,
52
+ enable,
53
+ skipBundle,
54
+ skipCleanup,
55
+ bundleDirectory,
56
+ ) {
57
+ const bundleFileName = skipBundle
58
+ ? readBundleFileNameFrom(bundleDirectory)
59
+ : await bundleCodePush(platform, outputPath, entryFile, jsBundleName, bundleDirectory);
60
+ const bundleFilePath = `${bundleDirectory}/${bundleFileName}`;
61
+
62
+ const downloadUrl = await (async () => {
63
+ try {
64
+ const { downloadUrl } = await bundleUploader(bundleFilePath, platform, identifier);
65
+ return downloadUrl
66
+ } catch (error) {
67
+ console.error('Failed to upload the bundle file. Exiting the program.', error)
68
+ process.exit(1)
69
+ }
70
+ })();
71
+
72
+ await addToReleaseHistory(
73
+ appVersion,
74
+ binaryVersion,
75
+ downloadUrl,
76
+ bundleFileName,
77
+ getReleaseHistory,
78
+ setReleaseHistory,
79
+ platform,
80
+ identifier,
81
+ mandatory,
82
+ enable,
83
+ )
84
+
85
+ if (!skipCleanup) {
86
+ cleanUpOutputs(outputPath);
87
+ }
88
+ }
89
+
90
+ function cleanUpOutputs(dir) {
91
+ fs.rmSync(dir, { recursive: true });
92
+ }
93
+
94
+ /**
95
+ * @param bundleDirectory {string}
96
+ * @return {string}
97
+ */
98
+ function readBundleFileNameFrom(bundleDirectory) {
99
+ const files = fs.readdirSync(bundleDirectory);
100
+ if (files.length !== 1) {
101
+ console.error('The bundlePath must contain only one file.');
102
+ process.exit(1);
103
+ }
104
+ const path = require('path');
105
+ const bundleFilePath = path.join(bundleDirectory, files[0]);
106
+ return path.basename(bundleFilePath);
107
+ }
108
+
109
+ module.exports = { release: release }