react-native-bspatch 1.0.2 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bspatch",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",
@@ -44,11 +44,13 @@ FLAVOR="dev"
44
44
  ACTION="ota"
45
45
  PLATFORM_ARG=""
46
46
 
47
+ PUSH_REMOTE=false
47
48
  # Arg parsing
48
49
  while [[ "$#" -gt 0 ]]; do
49
50
  case $1 in
50
51
  --platform) PLATFORM_ARG="$2"; shift ;;
51
52
  --flavor) FLAVOR="$2"; shift ;;
53
+ --push) PUSH_REMOTE=true ;;
52
54
  reset|base) ACTION="$1" ;;
53
55
  setup) ACTION="$1" ;;
54
56
  apk|ipa|seed) ACTION="base" ;; # Compatibility for legacy/seed actions
@@ -196,7 +198,7 @@ fi
196
198
  # ── Reset ─────────────────────────────────────────────────────────────────────
197
199
  if [ "$ACTION" = "reset" ]; then
198
200
  echo "Resetting OTA registry and clearing output..."
199
- rm -f "$REGISTRY_SHARED"
201
+ echo '{"apps":{}}' > "$REGISTRY_SHARED"
200
202
  # Preserve base-assets manifests so the build after reset can still
201
203
  # correctly identify which assets are already bundled in the base app.
202
204
  # Only delete bundles, patches, manifests and workspace — not base-assets.
@@ -209,6 +211,11 @@ import type { OtaPatch } from 'react-native-bspatch';
209
211
  export const OTA_PATCHES: OtaPatch[] = [];
210
212
  TSEEOF
211
213
  echo " ✓ Registry and output files cleared (base-assets preserved)"
214
+
215
+ if [ "$PUSH_REMOTE" = true ]; then
216
+ echo " Syncing reset state to remote storage..."
217
+ bash "$SCRIPT_DIR/upload_ota_custom.sh" "$APP_VERSION" "$FLAVOR_LOWER" "0" "" "ios" "--clean-remote"
218
+ fi
212
219
  exit 0
213
220
  fi
214
221
 
@@ -42,6 +42,14 @@ if [[ ! -f "$REGISTRY_FILE" ]]; then
42
42
  exit 1
43
43
  fi
44
44
 
45
+ # Check for clean remote flag
46
+ CLEAN_REMOTE=false
47
+ for ARG in "$@"; do
48
+ if [ "$ARG" == "--clean-remote" ]; then
49
+ CLEAN_REMOTE=true
50
+ fi
51
+ done
52
+
45
53
  # ── GitHub Auto-Push Integration ──────────────────────────────────────────────
46
54
  if [[ "$BASE_URL" == *"github"* ]] || [[ "$BASE_URL" == *"raw.githubusercontent"* ]]; then
47
55
  # Parse OWNER, REPO, BRANCH from URL
@@ -84,29 +92,37 @@ if [[ "$BASE_URL" == *"github"* ]] || [[ "$BASE_URL" == *"raw.githubusercontent"
84
92
  git clone --branch "$BRANCH" --depth 1 "$GIT_REMOTE" "$GH_REPO_DIR" 2>/dev/null || git clone "$GIT_REMOTE" "$GH_REPO_DIR"
85
93
  fi
86
94
 
87
- # 2. Copy generated files into storage repo
88
- TARGET_RELEASE_DIR="$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION/$CHANNEL"
89
- mkdir -p "$TARGET_RELEASE_DIR"
90
-
91
- echo " Copying release files to storage repo..."
92
- for FILE in "$OUTPUT_DIR"/*.{patch,hbc,json}; do
93
- [[ -f "$FILE" ]] || continue
94
- FNAME=$(basename "$FILE")
95
- cp "$FILE" "$TARGET_RELEASE_DIR/$FNAME"
96
- done
95
+ # 2. Copy generated files into storage repo (or reset remote)
96
+ if [ "$CLEAN_REMOTE" = true ]; then
97
+ echo " Resetting remote storage state..."
98
+ rm -rf "$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION"
99
+ mkdir -p "$GH_REPO_DIR/$BASE_FOLDER"
100
+ cp "$REGISTRY_FILE" "$GH_REPO_DIR/$BASE_FOLDER/ota_registry.json"
101
+ cp "$REGISTRY_FILE" "$GH_REPO_DIR/ota_registry.json" 2>/dev/null || true
102
+ else
103
+ TARGET_RELEASE_DIR="$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION/$CHANNEL"
104
+ mkdir -p "$TARGET_RELEASE_DIR"
105
+
106
+ echo " Copying release files to storage repo..."
107
+ for FILE in "$OUTPUT_DIR"/*.{patch,hbc,json}; do
108
+ [[ -f "$FILE" ]] || continue
109
+ FNAME=$(basename "$FILE")
110
+ cp "$FILE" "$TARGET_RELEASE_DIR/$FNAME"
111
+ done
112
+
113
+ # Copy asset store if present
114
+ if [[ -d "$OUTPUT_DIR/asset-store" ]]; then
115
+ TARGET_ASSET_DIR="$GH_REPO_DIR/$BASE_FOLDER/assets"
116
+ mkdir -p "$TARGET_ASSET_DIR"
117
+ cp -R "$OUTPUT_DIR/asset-store/"* "$TARGET_ASSET_DIR/" 2>/dev/null || true
118
+ fi
97
119
 
98
- # Copy asset store if present
99
- if [[ -d "$OUTPUT_DIR/asset-store" ]]; then
100
- TARGET_ASSET_DIR="$GH_REPO_DIR/$BASE_FOLDER/assets"
101
- mkdir -p "$TARGET_ASSET_DIR"
102
- cp -R "$OUTPUT_DIR/asset-store/"* "$TARGET_ASSET_DIR/" 2>/dev/null || true
120
+ # Copy ota_registry.json
121
+ mkdir -p "$GH_REPO_DIR/$BASE_FOLDER"
122
+ cp "$REGISTRY_FILE" "$GH_REPO_DIR/$BASE_FOLDER/ota_registry.json"
123
+ cp "$REGISTRY_FILE" "$GH_REPO_DIR/ota_registry.json" 2>/dev/null || true
103
124
  fi
104
125
 
105
- # Copy ota_registry.json
106
- mkdir -p "$GH_REPO_DIR/$BASE_FOLDER"
107
- cp "$REGISTRY_FILE" "$GH_REPO_DIR/$BASE_FOLDER/ota_registry.json"
108
- cp "$REGISTRY_FILE" "$GH_REPO_DIR/ota_registry.json" 2>/dev/null || true
109
-
110
126
  # 3. Commit and Push to GitHub
111
127
  cd "$GH_REPO_DIR"
112
128
  git config user.name "hungbv-taureau" 2>/dev/null || true
@@ -115,8 +131,12 @@ if [[ "$BASE_URL" == *"github"* ]] || [[ "$BASE_URL" == *"raw.githubusercontent"
115
131
  if git diff --staged --quiet; then
116
132
  echo " ✓ Storage repository is up to date (no changes)."
117
133
  else
118
- echo " Committing OTA release (App: $APP_VERSION v$OTA_VERSION)..."
119
- git commit -m "auto(ota): publish $PLATFORM $APP_VERSION v$OTA_VERSION ($CHANNEL)"
134
+ COMMIT_MSG="auto(ota): publish $PLATFORM $APP_VERSION v$OTA_VERSION ($CHANNEL)"
135
+ if [ "$CLEAN_REMOTE" = true ]; then
136
+ COMMIT_MSG="auto(ota): reset remote OTA registry and releases"
137
+ fi
138
+ echo " Committing OTA changes ($COMMIT_MSG)..."
139
+ git commit -m "$COMMIT_MSG"
120
140
  echo " Pushing to GitHub (${BRANCH})..."
121
141
 
122
142
  if git push origin "$BRANCH"; then