react-native-bspatch 1.0.8 → 1.0.9

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.8",
3
+ "version": "1.0.9",
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",
@@ -253,23 +253,35 @@ fi
253
253
 
254
254
  # ── Reset ─────────────────────────────────────────────────────────────────────
255
255
  if [ "$ACTION" = "reset" ]; then
256
- echo "Resetting OTA registry and clearing output..."
257
- echo '{"apps":{}}' > "$REGISTRY_SHARED"
258
- # Preserve base-assets manifests so the build after reset can still
259
- # correctly identify which assets are already bundled in the base app.
260
- # Only delete bundles, patches, manifests and workspace — not base-assets.
261
- find "$ROOT/android/output" -mindepth 1 -not -name 'base-assets_*' -delete 2>/dev/null || true
262
- find "$ROOT/ios/output" -mindepth 1 -not -name 'base-assets_*' -delete 2>/dev/null || true
263
- cat > "$GENERATED_TS" << 'TSEEOF'
264
- // AUTO-GENERATED by build_ota.sh — do not edit manually
265
- import type { OtaPatch } from 'react-native-bspatch';
266
-
267
- export const OTA_PATCHES: OtaPatch[] = [];
268
- TSEEOF
269
- echo " ✓ Registry and output files cleared (base-assets preserved)"
256
+ FLAVOR_LOWER=$(echo "$FLAVOR" | tr '[:upper:]' '[:lower:]')
257
+ echo "Resetting OTA registry and output for flavor '$FLAVOR_LOWER'..."
258
+
259
+ # Reset only the specific flavor in registry JSON if registry exists
260
+ if [ -f "$REGISTRY_SHARED" ]; then
261
+ node -e "
262
+ try {
263
+ const fs = require('fs');
264
+ const reg = JSON.parse(fs.readFileSync('$REGISTRY_SHARED', 'utf8'));
265
+ if (reg.apps && reg.apps['$APP_VERSION'] && reg.apps['$APP_VERSION'].flavors) {
266
+ delete reg.apps['$APP_VERSION'].flavors['$FLAVOR_LOWER'];
267
+ }
268
+ fs.writeFileSync('$REGISTRY_SHARED', JSON.stringify(reg, null, 4));
269
+ } catch(e) {}
270
+ "
271
+ else
272
+ echo '{"apps":{}}' > "$REGISTRY_SHARED"
273
+ fi
274
+
275
+ # Delete only output files belonging to this specific flavor
276
+ find "$ROOT/android/output" -mindepth 1 -name "*_${FLAVOR_LOWER}.*" -not -name 'base-assets_*' -delete 2>/dev/null || true
277
+ find "$ROOT/android/output" -mindepth 1 -name "*_${FLAVOR_LOWER}_*" -not -name 'base-assets_*' -delete 2>/dev/null || true
278
+ find "$ROOT/ios/output" -mindepth 1 -name "*_${FLAVOR_LOWER}.*" -not -name 'base-assets_*' -delete 2>/dev/null || true
279
+ find "$ROOT/ios/output" -mindepth 1 -name "*_${FLAVOR_LOWER}_*" -not -name 'base-assets_*' -delete 2>/dev/null || true
280
+
281
+ echo " ✓ Registry and output files cleared for flavor '$FLAVOR_LOWER' (base-assets preserved)"
270
282
 
271
283
  if [ "$PUSH_REMOTE" = true ]; then
272
- echo " Syncing reset state to remote storage..."
284
+ echo " Syncing reset state for flavor '$FLAVOR_LOWER' to remote storage..."
273
285
  bash "$SCRIPT_DIR/upload_ota_custom.sh" "$APP_VERSION" "$FLAVOR_LOWER" "0" "" "ios" "--clean-remote"
274
286
  fi
275
287
  exit 0
@@ -94,8 +94,8 @@ if [[ "$BASE_URL" == *"github"* ]] || [[ "$BASE_URL" == *"raw.githubusercontent"
94
94
 
95
95
  # 2. Copy generated files into storage repo (or reset remote)
96
96
  if [ "$CLEAN_REMOTE" = true ]; then
97
- echo " Resetting remote storage state..."
98
- rm -rf "$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION"
97
+ echo " Resetting remote storage state for channel '$CHANNEL'..."
98
+ rm -rf "$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION/$CHANNEL"
99
99
  mkdir -p "$GH_REPO_DIR/$BASE_FOLDER"
100
100
  cp "$REGISTRY_FILE" "$GH_REPO_DIR/$BASE_FOLDER/ota_registry.json"
101
101
  cp "$REGISTRY_FILE" "$GH_REPO_DIR/ota_registry.json" 2>/dev/null || true
@@ -103,8 +103,8 @@ if [[ "$BASE_URL" == *"github"* ]] || [[ "$BASE_URL" == *"raw.githubusercontent"
103
103
  TARGET_RELEASE_DIR="$GH_REPO_DIR/$BASE_FOLDER/$APP_VERSION/$CHANNEL"
104
104
  mkdir -p "$TARGET_RELEASE_DIR"
105
105
 
106
- echo " Copying release files to storage repo..."
107
- for FILE in "$OUTPUT_DIR"/*.{patch,hbc,json}; do
106
+ echo " Copying release files to storage repo for channel '$CHANNEL'..."
107
+ for FILE in "$OUTPUT_DIR"/*_${CHANNEL}.json "$OUTPUT_DIR"/*_${CHANNEL}.hbc "$OUTPUT_DIR"/*_${CHANNEL}_*.patch "$OUTPUT_DIR"/*_${CHANNEL}.patch; do
108
108
  [[ -f "$FILE" ]] || continue
109
109
  FNAME=$(basename "$FILE")
110
110
  cp "$FILE" "$TARGET_RELEASE_DIR/$FNAME"