react-native-bspatch 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -539,6 +539,7 @@ react-native-bspatch/
539
539
  │ └── OtaBundleResolver.swift # Bundle resolution + crash rollback (before JS)
540
540
  ├── cpp/bsdiff/ # bspatch (C, mmap)
541
541
  └── tools/
542
+ ├── cli.js # bin entry (Yarn Berry runs bins with node)
542
543
  ├── build_ota.sh # CLI: patch / reset / setup / version
543
544
  ├── upload_ota.sh # Upload to Cloudflare R2 or a GitHub storage repo
544
545
  ├── update_registry.js # Writes ota_registry.json entries + signatures
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bspatch",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Premium OTA Update Solution for React Native using TurboModules and bsdiff",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -56,7 +56,7 @@
56
56
  "access": "public"
57
57
  },
58
58
  "bin": {
59
- "react-native-bspatch": "./tools/build_ota.sh"
59
+ "react-native-bspatch": "./tools/cli.js"
60
60
  },
61
61
  "scripts": {
62
62
  "setup": "node ./tools/setup_project.js",
@@ -98,16 +98,18 @@ if [ "$ACTION" = "setup" ]; then
98
98
  fi
99
99
 
100
100
  # ── Build environment ──────────────────────────────────────────────────────
101
- echo "Preparing build environment..."
102
- # Kill any existing Metro processes to prevent file locks
103
- pkill -f "react-native/local-cli/cli.js" || true
104
- pkill -f "metro-config/src/index.js" || true
105
-
106
- # Manually clear metro cache if it exists (robust vs ENOTEMPTY error)
107
- METRO_CACHE_DIR=$(node -e "console.log(require('os').tmpdir())")/metro-cache
108
- if [ -d "$METRO_CACHE_DIR" ]; then
109
- echo " Cleaning Metro cache..."
110
- rm -rf "$METRO_CACHE_DIR"
101
+ if [ "$ACTION" = "ota" ]; then
102
+ echo "Preparing build environment..."
103
+ # Kill any existing Metro processes to prevent file locks
104
+ pkill -f "react-native/local-cli/cli.js" || true
105
+ pkill -f "metro-config/src/index.js" || true
106
+
107
+ # Manually clear metro cache if it exists (robust vs ENOTEMPTY error)
108
+ METRO_CACHE_DIR=$(node -e "console.log(require('os').tmpdir())")/metro-cache
109
+ if [ -d "$METRO_CACHE_DIR" ]; then
110
+ echo " Cleaning Metro cache..."
111
+ rm -rf "$METRO_CACHE_DIR"
112
+ fi
111
113
  fi
112
114
 
113
115
  mkdir -p "$ROOT/android/output"
@@ -123,8 +125,7 @@ if [ "$ACTION" != "setup" ]; then
123
125
  BASE_URL="${OTA_BASE_URL:-}"
124
126
  BASE_FOLDER="${OTA_FOLDER:-ota}"
125
127
 
126
- echo " Using URL: $BASE_URL"
127
- echo " Using Folder: $BASE_FOLDER"
128
+ echo " Storage: ${OTA_R2_BUCKET:+R2 $OTA_R2_BUCKET → }$BASE_URL/$BASE_FOLDER"
128
129
 
129
130
  if [[ -n "${OTA_R2_BUCKET:-}" ]]; then
130
131
  R2_URL="https://${OTA_R2_ACCOUNT_ID:?set OTA_R2_ACCOUNT_ID}.r2.cloudflarestorage.com/${OTA_R2_BUCKET}"
@@ -234,7 +235,9 @@ fi
234
235
  # Confirm in a terminal (Enter keeps the detected version); CI / -y / --release-version skip it
235
236
  if [ -t 0 ] && [ "$CONFIRM_VERSION" = true ] && [ -z "$APP_VERSION_ARG" ]; then
236
237
  echo ""
237
- read -r -p " Release version for ${PLATFORM_ARG:-android + ios} [${APP_VERSION:-none detected}]: " INPUT_VERSION
238
+ if [ "$ACTION" = "reset" ]; then PROMPT_WHAT="Release version to RESET ($FLAVOR_LOWER, android + ios)"
239
+ else PROMPT_WHAT="Release version for ${PLATFORM_ARG:-android + ios} ($FLAVOR_LOWER)"; fi
240
+ read -r -p " $PROMPT_WHAT [${APP_VERSION:-none detected}]: " INPUT_VERSION
238
241
  INPUT_VERSION="${INPUT_VERSION// /}"
239
242
  APP_VERSION="${INPUT_VERSION:-$APP_VERSION}"
240
243
  fi
package/tools/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // Yarn Berry runs package bins with node regardless of the shebang, so the bash CLI needs a JS entry
3
+ const { spawnSync } = require('child_process');
4
+ const path = require('path');
5
+
6
+ const result = spawnSync('bash', [path.join(__dirname, 'build_ota.sh'), ...process.argv.slice(2)], {
7
+ stdio: 'inherit',
8
+ });
9
+ process.exit(result.status ?? 1);