@patchstack/connect 0.3.14 → 0.3.15

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/dist/cli.js CHANGED
@@ -1723,6 +1723,25 @@ function scaffold(cwd) {
1723
1723
  copyFileSync(join(TEMPLATES, "rules.json"), join(dst, "rules.json"));
1724
1724
  log("scaffolded guard.ts + rules.json");
1725
1725
  }
1726
+ function bakeSiteUuid(cwd) {
1727
+ const rc = join(cwd, ".patchstackrc.json");
1728
+ if (!existsSync4(rc)) return log("no .patchstackrc.json \u2014 guard uses PATCHSTACK_SITE_UUID env or the bundled fallback");
1729
+ let uuid;
1730
+ try {
1731
+ uuid = JSON.parse(read(rc)).siteUuid;
1732
+ } catch {
1733
+ return log(".patchstackrc.json unreadable \u2014 skipping site-UUID bake");
1734
+ }
1735
+ if (!uuid || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuid)) {
1736
+ return log(".patchstackrc.json siteUuid missing or malformed \u2014 guard uses PATCHSTACK_SITE_UUID env or the bundled fallback");
1737
+ }
1738
+ const p = join(cwd, "src/integrations/patchstack/guard.ts");
1739
+ if (!existsSync4(p)) return;
1740
+ const s = read(p);
1741
+ if (!s.includes("__PATCHSTACK_SITE_UUID__")) return log("guard.ts site UUID already baked");
1742
+ writeFileSync2(p, s.replace("__PATCHSTACK_SITE_UUID__", uuid));
1743
+ log("baked site UUID into guard.ts \u2014 live rules from the Patchstack API");
1744
+ }
1726
1745
  function patchClient(cwd) {
1727
1746
  const p = join(cwd, "src/integrations/supabase/client.ts");
1728
1747
  let s = read(p);
@@ -1777,6 +1796,7 @@ function runProtect(cwd) {
1777
1796
  return;
1778
1797
  }
1779
1798
  scaffold(cwd);
1799
+ bakeSiteUuid(cwd);
1780
1800
  patchClient(cwd);
1781
1801
  patchStart(cwd);
1782
1802
  log("done \u2014 guard wired and always-on (blocks by default). Set PATCHSTACK_MODE=dry-run for log-only.");