@@ -8,9 +8,16 @@ SDK_ROOT=$(cd "$ORIGINAL_DIR/../.." && pwd)
88info () { echo -e " \033[0;32m[setup]\033[0m $* " ; }
99
1010# ── Plugin tarball cache ─────────────────────────────────────────────────────
11- # Skip rebuild/repack/`vp add` when plugin sources haven't changed.
12- SDK_STAMP=" $SDK_ROOT /.capacitor-sdk-source.stamp"
11+ # Two stamps: the SDK build is shared across demos (one tarball serves all),
12+ # but the `vp add` install is per-demo. Without the split, running setup in
13+ # `demo` first would leave the shared stamp at the new hash, and a follow-up
14+ # `demo_pods` setup would short-circuit the install and keep stale sources in
15+ # `demo_pods/node_modules/@onesignal/capacitor-plugin/` — which is what
16+ # CocoaPods path-references, so the native pod stays pre-fix.
17+ SDK_BUILD_STAMP=" $SDK_ROOT /.capacitor-sdk-source.stamp"
18+ INSTALLED_STAMP=" $ORIGINAL_DIR /.capacitor-sdk-installed.stamp"
1319INSTALLED_DIR=" $ORIGINAL_DIR /node_modules/@onesignal/capacitor-plugin"
20+ TARBALL=" $SDK_ROOT /onesignal-capacitor-plugin.tgz"
1421
1522SDK_SRC_HASH=$( find " $SDK_ROOT /src" " $SDK_ROOT /android" " $SDK_ROOT /ios" \
1623 " $SDK_ROOT /package.json" \
@@ -23,21 +30,25 @@ SDK_SRC_HASH=$(find "$SDK_ROOT/src" "$SDK_ROOT/android" "$SDK_ROOT/ios" \
2330 | shasum \
2431 | awk ' {print $1}' )
2532
26- if [[ -d " $INSTALLED_DIR " ]] && [[ -f " $SDK_STAMP " ]] && [[ " $( cat " $SDK_STAMP " ) " == " $SDK_SRC_HASH " ]]; then
27- info " Capacitor SDK source unchanged , skipping rebuild + repack"
33+ if [[ -f " $TARBALL " ]] && [[ -f " $SDK_BUILD_STAMP " ]] && [[ " $( cat " $SDK_BUILD_STAMP " ) " == " $SDK_SRC_HASH " ]]; then
34+ info " Capacitor SDK tarball is up-to-date , skipping rebuild + repack"
2835else
2936 info " Building Capacitor plugin & packing tarball..."
3037 (cd " $SDK_ROOT " && vp run build)
3138 (cd " $SDK_ROOT " && rm -f onesignal-capacitor-plugin* .tgz && vp pm pack && mv onesignal-capacitor-plugin-* .tgz onesignal-capacitor-plugin.tgz)
39+ echo " $SDK_SRC_HASH " > " $SDK_BUILD_STAMP "
40+ fi
3241
42+ if [[ -d " $INSTALLED_DIR " ]] && [[ -f " $INSTALLED_STAMP " ]] && [[ " $( cat " $INSTALLED_STAMP " ) " == " $SDK_SRC_HASH " ]]; then
43+ info " Plugin already installed at current SDK hash, skipping vp add"
44+ else
3345 # Remove before add so bun.lock's integrity hash refreshes against the new
3446 # tarball; otherwise `vp add` hits a dependency-loop error under bun 1.3+.
3547 # Keep the relative `file:../../...` path to match package.json's spec.
3648 info " Registering tarball with vp (refreshes bun.lock integrity hash)..."
3749 vp remove @onesignal/capacitor-plugin 2> /dev/null || true
3850 vp add file:../../onesignal-capacitor-plugin.tgz
39-
40- echo " $SDK_SRC_HASH " > " $SDK_STAMP "
51+ echo " $SDK_SRC_HASH " > " $INSTALLED_STAMP "
4152fi
4253
4354# ── Vite prebundle staleness check ───────────────────────────────────────────
0 commit comments