@patchstack/connect 0.3.13 → 0.3.14
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 +28 -35
- package/dist/cli.js.map +1 -1
- package/dist/protect/templates/guard.ts +3 -9
- package/dist/protect.cjs +2 -82
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.d.ts +0 -4
- package/dist/protect.js +2 -81
- package/dist/protect.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1577,7 +1577,7 @@ function renderGuideChecklist(state, useColor) {
|
|
|
1577
1577
|
lines.push(done(`@patchstack/connect installed (${state.installed.version}, ${state.installed.section})`));
|
|
1578
1578
|
} else {
|
|
1579
1579
|
lines.push(todo("Install @patchstack/connect as a dev dependency"));
|
|
1580
|
-
lines.push(detail(
|
|
1580
|
+
lines.push(detail(`Run \u2192 ${installCommand(state.packageManager)}`));
|
|
1581
1581
|
if (state.packageManager === "bun") {
|
|
1582
1582
|
lines.push(detail(`(if bun isn't available here, ${INSTALL_COMMANDS.npm} works too)`));
|
|
1583
1583
|
}
|
|
@@ -1586,22 +1586,22 @@ function renderGuideChecklist(state, useColor) {
|
|
|
1586
1586
|
lines.push(done(`Site provisioned (${state.siteUuid})`));
|
|
1587
1587
|
} else {
|
|
1588
1588
|
lines.push(todo("Provision the site \u2014 run the first scan"));
|
|
1589
|
-
lines.push(detail("\u2192 npx @patchstack/connect scan"));
|
|
1590
|
-
lines.push(detail("
|
|
1589
|
+
lines.push(detail("Run \u2192 npx @patchstack/connect scan"));
|
|
1590
|
+
lines.push(detail("reads the lockfile, registers the project, writes .patchstackrc.json,"));
|
|
1591
1591
|
lines.push(detail("and prints a claim URL \u2014 show that URL to the user; never open it yourself."));
|
|
1592
1592
|
}
|
|
1593
1593
|
if (state.prebuildWired && state.postbuildWired) {
|
|
1594
1594
|
lines.push(done("Build hooks wired (scan before builds, mark-build after)"));
|
|
1595
1595
|
} else if (state.packageManager === "bun") {
|
|
1596
|
-
lines.push(todo(
|
|
1597
|
-
lines.push(detail('\u2192 "build": "patchstack-connect scan && <existing build command> && patchstack-connect mark-build"'));
|
|
1596
|
+
lines.push(todo('Wire the build hooks yourself \u2014 edit package.json (bun skips pre/post hooks, so chain inside "build")'));
|
|
1597
|
+
lines.push(detail('Edit package.json \u2192 "build": "patchstack-connect scan && <existing build command> && patchstack-connect mark-build"'));
|
|
1598
1598
|
} else {
|
|
1599
|
-
lines.push(todo(
|
|
1599
|
+
lines.push(todo('Wire the build hooks yourself \u2014 edit package.json "scripts" (chain with && if a hook already exists)'));
|
|
1600
1600
|
if (!state.prebuildWired) {
|
|
1601
|
-
lines.push(detail('\u2192 "prebuild": "patchstack-connect scan"'));
|
|
1601
|
+
lines.push(detail('Edit package.json \u2192 "prebuild": "patchstack-connect scan"'));
|
|
1602
1602
|
}
|
|
1603
1603
|
if (!state.postbuildWired) {
|
|
1604
|
-
lines.push(detail('\u2192 "postbuild": "patchstack-connect mark-build"'));
|
|
1604
|
+
lines.push(detail('Edit package.json \u2192 "postbuild": "patchstack-connect mark-build"'));
|
|
1605
1605
|
}
|
|
1606
1606
|
}
|
|
1607
1607
|
const widgetOk = state.widgetInstalled && state.widgetTokenMatches !== false;
|
|
@@ -1610,16 +1610,16 @@ function renderGuideChecklist(state, useColor) {
|
|
|
1610
1610
|
} else if (widgetOk) {
|
|
1611
1611
|
lines.push(done("Disclosure widget installed"));
|
|
1612
1612
|
} else if (state.widgetInstalled) {
|
|
1613
|
-
lines.push(todo("
|
|
1614
|
-
lines.push(detail(
|
|
1613
|
+
lines.push(todo("Fix the disclosure widget yourself \u2014 its site UUID doesn't match this project's"));
|
|
1614
|
+
lines.push(detail(`Edit the widget tag \u2192 set data-site-uuid (or userToken) to '${state.siteUuid}' (a wrong UUID makes the widget silently no-op)`));
|
|
1615
1615
|
} else if (state.siteUuid === null) {
|
|
1616
1616
|
lines.push(todo('Add the "Report a vulnerability" widget \u2014 the first scan does this for you'));
|
|
1617
|
-
lines.push(detail("\u2192
|
|
1618
|
-
lines.push(detail(" to the root HTML shell
|
|
1617
|
+
lines.push(detail("Run \u2192 npx @patchstack/connect scan (provisions the site and adds the widget tag"));
|
|
1618
|
+
lines.push(detail(" to the root HTML shell: index.html / public/index.html / src/app.html)"));
|
|
1619
1619
|
} else {
|
|
1620
|
-
lines.push(todo('Add the "Report a vulnerability" widget'));
|
|
1621
|
-
lines.push(detail("\u2192 a normal `scan` adds this tag to a plain HTML shell automatically;"));
|
|
1622
|
-
const placement = state.widgetFileHint !== null ? `
|
|
1620
|
+
lines.push(todo('Add the "Report a vulnerability" widget yourself \u2014 this root is code, not a plain HTML shell'));
|
|
1621
|
+
lines.push(detail("Note \u2192 a normal `scan` adds this tag to a plain HTML shell automatically; add it by hand here:"));
|
|
1622
|
+
const placement = state.widgetFileHint !== null ? `Edit ${state.widgetFileHint} \u2192 put it just before </body>:` : "Edit your root layout \u2192 put it just before </body> (the framework's HTML/layout mechanism, never a JS entry point):";
|
|
1623
1623
|
lines.push(detail(placement));
|
|
1624
1624
|
lines.push(detail(` ${buildWidgetTag(state.siteUuid)}`));
|
|
1625
1625
|
lines.push(detail("The site UUID is public by design \u2014 it ships in client-side HTML."));
|
|
@@ -1723,25 +1723,6 @@ 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
|
-
}
|
|
1745
1726
|
function patchClient(cwd) {
|
|
1746
1727
|
const p = join(cwd, "src/integrations/supabase/client.ts");
|
|
1747
1728
|
let s = read(p);
|
|
@@ -1796,7 +1777,6 @@ function runProtect(cwd) {
|
|
|
1796
1777
|
return;
|
|
1797
1778
|
}
|
|
1798
1779
|
scaffold(cwd);
|
|
1799
|
-
bakeSiteUuid(cwd);
|
|
1800
1780
|
patchClient(cwd);
|
|
1801
1781
|
patchStart(cwd);
|
|
1802
1782
|
log("done \u2014 guard wired and always-on (blocks by default). Set PATCHSTACK_MODE=dry-run for log-only.");
|
|
@@ -1977,6 +1957,19 @@ async function runScan(args) {
|
|
|
1977
1957
|
console.log(" (this URL inherits the endpoint override above)");
|
|
1978
1958
|
}
|
|
1979
1959
|
}
|
|
1960
|
+
try {
|
|
1961
|
+
const state = await collectGuideState(process.cwd());
|
|
1962
|
+
const remaining = countRemainingSteps(state);
|
|
1963
|
+
if (remaining > 0) {
|
|
1964
|
+
const hooksMissing = !(state.prebuildWired && state.postbuildWired);
|
|
1965
|
+
console.log("");
|
|
1966
|
+
console.log(
|
|
1967
|
+
`Setup not complete \u2014 ${remaining} step(s) remaining${hooksMissing ? ", including the package.json build hooks (which scan can't wire)" : ""}.`
|
|
1968
|
+
);
|
|
1969
|
+
console.log("Run `npx @patchstack/connect guide` for the exact steps to finish for this project.");
|
|
1970
|
+
}
|
|
1971
|
+
} catch {
|
|
1972
|
+
}
|
|
1980
1973
|
return 0;
|
|
1981
1974
|
}
|
|
1982
1975
|
function reportSourceWidget(siteUuid) {
|