@zero2webmaster/starter-kit 0.43.2 → 0.45.0
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/README.md +7 -3
- package/dist/scaffolders/cf-worker.js +3 -1
- package/dist/scaffolders/library.js +20 -1
- package/dist/scaffolders/nextjs.js +98 -36
- package/dist/scaffolders/node-service.js +3 -1
- package/dist/scaffolders/pre-push-hook.d.ts +30 -0
- package/dist/scaffolders/pre-push-hook.js +148 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.45.0 | **Framework:** 2.19.0
|
|
4
4
|
|
|
5
5
|
> Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
|
|
6
6
|
|
|
@@ -83,7 +83,11 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
83
83
|
|
|
84
84
|
## Status
|
|
85
85
|
|
|
86
|
-
- **v0.
|
|
86
|
+
- **v0.45.0 (current)** runs the tests before every push. `nextjs`, `cf-worker`, `library` and `node-service` scaffolds now ship a tracked `pre-push` hook that runs `npm test`, installed into the repo's own `.git/hooks/` by `npm install` (skipped in CI, never fails an install). Until now the scaffold emitted a test script that nothing ran: `audit-engine` measured 24 of 29 multi-tenant apps whose cross-tenant tests ran only when someone typed the command. A `library` scaffold also gets a starter test, because its first `npm test` used to fail with "No test files found". Verified on real scaffolds from the built `dist/`, through the global hook dispatcher: a green push passes, a red one is refused.
|
|
87
|
+
|
|
88
|
+
- **v0.44.0** stops the PWA service worker from storing pages. Since v0.19.0 it cached every page it loaded, including signed-in ones, which then stayed readable offline after sign-out. Page loads now go to the network, with a built-in "You're offline" page when that fails, and only content-hashed `/_next/static/` files are cached. Verified in Chromium against a dynamic page, with the old worker as a control. Full detail in [CHANGELOG.md](CHANGELOG.md).
|
|
89
|
+
|
|
90
|
+
- **v0.27.0** answers `org-hq`'s two scaffold defects, ten days after they were filed. The headline: **`app/robots.ts` was asking the wrong question.** Its gate required a production deployment AND a real custom domain — and an internal admin console satisfies **both** while still being wrong to index, so `org-hq` served `Allow: /` on a branded public subdomain for a month with every check it had passing, because none of them asked. Indexability now takes a third condition, `hasPublicSurface`, baked in at scaffold time rather than read from the environment, because it is a fact about what an app IS and not about where a copy of it is running. **It fails CLOSED** — omitted reads as "no public surface" — which is the opposite default from every other optional input here and is deliberate: a public site wrongly withheld is one field and a redeploy with nothing having escaped, while an internal console wrongly published is silent, slow to undo, and has already happened by the time anyone notices. The wizard and brief-first flows ask, and the CLI's final summary now **states the posture out loud in both directions**, since a silent default is how the original defect survived. `cf-pages` is fixed in the same release — it published `Allow: /` unconditionally — because shipping the fix only in the type that was reported would have left its sibling quietly broken. The second defect: the `*.vercel.app` alias redirect now **excludes `/api/*`**, whose SEO rationale never applied and whose 308 breaks every server-to-server caller that does not follow redirects. **And re-measuring the report changed it:** the companion claim — that adding the exclusion would silently stop redirecting `/`, because a `:path` param cannot match the empty string — **did not reproduce.** On Next.js 15.5.23 a CUSTOM param pattern supplies its own `.*`, which matches empty, so the wildcard alone still redirected the root; the explicit root rule ships anyway as insurance against a path-to-regexp detail that is not a documented guarantee, described as insurance rather than as a repair. Verified per tier 1 on two real scaffolds from the built `dist/` — `npm install`, a real `next build`, and `curl` with forged `Host` headers against both the shipped form and a control build with the root rule removed. **1241 of 1241 passing.**
|
|
87
91
|
- **v0.26.0** releases two things. First, the **per-service Uptime Kuma health keyword**, built on 2026-08-21 but never released or written down until now: every deploy target's health document serves `{"status":"ok","service":"<slug>","keyword":"<slug>-health-ok"}`, and the emitted standards block tells the reader to match the full keyword. **The old portfolio-wide `"status":"ok"` was worthless as a check** — byte-identical across every Z2W service, so a monitor with a mistyped URL, one copied from a sibling project, or one left pointing at a decommissioned host still went green, which is the exact failure a keyword exists to catch; a portfolio audit found **12 of 23 monitors** keyed on it. The value is DERIVED from the slug via `healthKeyword()`, which is the load-bearing half — a shared constant would rebuild the same trap with extra steps. Second, a fix in `rollup-integrations.mjs`: **a comma in an author's prose is not an edge separator.** Stripping parentheticals before splitting handled the `(why…)` note form and did nothing for the canonical form's `— why` note, which runs to end of line, so `- consumes: contact-registry — people, tags, entitlements.` was about to write **`tags`** into the Project Registry as a dependency of `commerce-engine`, and `audit-engine`'s trailing sentence was about to write **`live-status`**. Both had been PRINTED on every run under `ⓘ not registry slugs (external, or prose noise — check)` — a line that reports and does not filter, so **a reported artifact that is still written is not a caught one**. A comma-part is now an edge only when it is a known registry slug or carries a `:qualifier`, with the first part exempt because that is where the author names the edge and the only position a legitimate non-registry backend occupies. The same work uncovered the inverse defect — a MISS: prose left attached to the last inline item swallowed its slug, so `z2w-observability-bridge`'s section yielded **only `Vercel`**, an external its own sentence had just disclaimed, while its real edge went unread. **1233 of 1233 passing.**
|
|
88
92
|
- **v0.25.0** adds `scripts/reconcile-production-url.mjs`, which reconciles the Project Registry's `production_url` column against the Vercel API — and **measuring the real API showed the 2026-08-17 design sketch was wrong in three separate ways.** The sketch said "read `domains[]`, filter out `*.vercel.app`, never take `domains[0]`." Measured across all 23 Zero2Webmaster Vercel projects: **position carries no information at all** (`z2w-social`'s correct domain is the first survivor, `org-hq`'s is the second), so no positional rule can exist; **filtering the aliases out blanks five Live rows** whose only public surface *is* a `.vercel.app` alias, so aliases are a lower-priority tier rather than noise; and **multiple custom domains are the common case, not an edge** — 6 of 19 resolvable projects have more than one, `file-server` has four. The reconciler therefore returns a *verdict object* rather than a URL, so "there is one" and "I picked one of four" cannot print the same way, and it writes only into a NULL — a recorded value that disagrees is reported as drift and never overwritten, because it may be a human's deliberate choice. **It found a real one on its first live run:** the registry's `z2w-social` URL 308-redirects to `frogspace.savethefrogs.com`. Live redirect evidence is used only to *eliminate* a candidate that points at another candidate — both `leaderboard` domains 307 to `/bansuri`, a tenant path, so "follow redirects and take the final URL" would have written a tenant-scoped URL as a project's production URL. A coverage ledger accounts for every row asserting a public surface, and a completeness check makes an unexplained row loud instead of absent. Also re-syncs the canonical Agent Coordination block to **v0.1.27**, which brings the previously-red conformance test back to green — **1199 of 1199 passing.**
|
|
89
93
|
- **v0.24.0** makes contrast a measured property of a PAIR rather than a taste call about a swatch. Every `nextjs` scaffold now emits `lib/a11y/contrast.ts` and `test/contrast.test.ts`, a table of **SURFACE x TEXT-ROLE x THRESHOLD** rows measured against the stylesheet the project actually ships — thirteen pairs across six surfaces, with `--brand-ink` measured four separate times because it is painted on four different backgrounds. The candidate came from `static-sites` and its lesson is one line: *contrast is per-surface, not per-palette* — a validator that checks each swatch against white passes cleanly while shipping unreadable text, because the swatch is rendered on the tint panel three components down. **Writing that check found two real defects in this scaffold's own CSS, both invisible to every brand preset.** The keyboard focus ring was painted in `--brand-primary`, which measures 2.03:1 on white in Z2W green and 1.40:1 in Z2W gold — so focusing a field made its boundary *less* visible than at rest, in Zero2Webmaster's and Save The Frogs' own colors. And `readableInkOn()` picked the better of near-black and white without checking that the winner cleared anything, which put a 4.41:1 glyph on any mid-tone brand fill. Fixed with a derived `--brand-focus` (same hue, darkened only as far as 3:1 requires) and an escalation to pure black, which provably clears 4.5:1 on every possible background. **Verified by running the scaffold's own vitest, plus four canaries that each reproduce a defect on demand** — including the one that matters most: an ink that stays green on white and fails at 4.06:1 on the code tint.
|
|
@@ -135,4 +139,4 @@ Inquiries: kerry@zero2webmaster.com.
|
|
|
135
139
|
---
|
|
136
140
|
|
|
137
141
|
*Scaffolded 2026-05-28 via the [[instantiate-z2w-project]] Claude Code skill v1; reconciled against the consolidated skill v1.1.0 (brief-first + Agent Coordination block) on 2026-05-29.*
|
|
138
|
-
*Version: 0.
|
|
142
|
+
*Version: 0.45.0 | Last Updated: 2026-10-26*
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// to the SEO baseline (no indexable HTML surface). Compatibility date pinned
|
|
5
5
|
// to {{date}} so scaffolded projects start on the user's scaffold day, not
|
|
6
6
|
// some hardcoded past day.
|
|
7
|
+
import { prePushHookFiles, withHookScripts } from "./pre-push-hook.js";
|
|
7
8
|
import { commonBaseFiles, resolveBrandSpec, sub, } from "./common.js";
|
|
8
9
|
const NARRATIVE = `## What this is
|
|
9
10
|
|
|
@@ -171,7 +172,8 @@ export function scaffoldCfWorker(inputs, opts) {
|
|
|
171
172
|
{ path: "wrangler.jsonc", content: sub(WRANGLER_TEMPLATE, inputs, opts, spec) },
|
|
172
173
|
{ path: "src/index.ts", content: sub(SRC_INDEX_TEMPLATE, inputs, opts, spec) },
|
|
173
174
|
{ path: "src/index.test.ts", content: sub(SRC_INDEX_TEST_TEMPLATE, inputs, opts, spec) },
|
|
174
|
-
{ path: "package.json", content: sub(PACKAGE_JSON_TEMPLATE, inputs, opts, spec) },
|
|
175
|
+
{ path: "package.json", content: withHookScripts(sub(PACKAGE_JSON_TEMPLATE, inputs, opts, spec)) },
|
|
176
|
+
...prePushHookFiles(),
|
|
175
177
|
{ path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
|
|
176
178
|
{ path: "vitest.config.ts", content: sub(VITEST_CONFIG_TEMPLATE, inputs, opts, spec) },
|
|
177
179
|
{ path: ".dev.vars", content: sub(DEV_VARS_TEMPLATE, inputs, opts, spec) },
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// No web surface, no /health, no Fathom, no SEO baseline. Just a clean npm
|
|
4
4
|
// package skeleton that compiles with `tsc` and exports a stub `version`.
|
|
5
|
+
import { prePushHookFiles, withHookScripts } from "./pre-push-hook.js";
|
|
5
6
|
import { commonBaseFiles, localEnvFrom, resolveBrandSpec, sub, } from "./common.js";
|
|
6
7
|
const NARRATIVE = `## What this is
|
|
7
8
|
|
|
@@ -102,6 +103,22 @@ const SRC_INDEX_TEMPLATE = `// {{slug}} — public API.
|
|
|
102
103
|
|
|
103
104
|
export const version = "{{version}}";
|
|
104
105
|
`;
|
|
106
|
+
// Until v0.45.0 a library scaffold shipped `"test": "vitest run"` and no test
|
|
107
|
+
// file, so its first `npm test` failed with "No test files found". Harmless
|
|
108
|
+
// while nothing ran it; fatal once the pre-push hook runs it on every push.
|
|
109
|
+
const SRC_INDEX_TEST_TEMPLATE = `import { readFileSync } from "node:fs";
|
|
110
|
+
|
|
111
|
+
import { describe, expect, it } from "vitest";
|
|
112
|
+
|
|
113
|
+
import { version } from "./index.js";
|
|
114
|
+
|
|
115
|
+
describe("{{slug}}", () => {
|
|
116
|
+
it("exports the version that package.json declares", () => {
|
|
117
|
+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
118
|
+
expect(version).toBe(pkg.version);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
`;
|
|
105
122
|
// A no-deploy library has no runtime secrets of its own, but in this portfolio
|
|
106
123
|
// libraries routinely need keys for dogfood scripts, integration tests, or a
|
|
107
124
|
// later HTTP surface (z2w-ai-engine, a library wrapping embedding providers, is
|
|
@@ -132,9 +149,11 @@ export function scaffoldLibrary(inputs, opts) {
|
|
|
132
149
|
const base = commonBaseFiles(inputs, opts, NARRATIVE);
|
|
133
150
|
const envExample = sub(ENV_EXAMPLE_TEMPLATE, inputs, opts, spec);
|
|
134
151
|
const typeSpecific = [
|
|
135
|
-
{ path: "package.json", content: sub(PACKAGE_JSON_TEMPLATE, inputs, opts, spec) },
|
|
152
|
+
{ path: "package.json", content: withHookScripts(sub(PACKAGE_JSON_TEMPLATE, inputs, opts, spec)) },
|
|
153
|
+
...prePushHookFiles(),
|
|
136
154
|
{ path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
|
|
137
155
|
{ path: "src/index.ts", content: sub(SRC_INDEX_TEMPLATE, inputs, opts, spec) },
|
|
156
|
+
{ path: "src/index.test.ts", content: sub(SRC_INDEX_TEST_TEMPLATE, inputs, opts, spec) },
|
|
138
157
|
{ path: "LICENSE", content: sub(LICENSE_TEMPLATE, inputs, opts, spec) },
|
|
139
158
|
{ path: ".env.example", content: envExample },
|
|
140
159
|
// A library's local-env convention is `.env` (gitignored), like python — not
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
// allowlist stub in `.env.example`. This CLI emits no auth code, so it plants the
|
|
47
47
|
// seam + the pointer at [[z2w-magic-link-auth]] §0 rule 2b rather than a check —
|
|
48
48
|
// see CANONICAL_HOSTS_ENV_BLOCK for why that is the honest half.
|
|
49
|
+
import { prePushHookFiles, withHookScripts } from "./pre-push-hook.js";
|
|
49
50
|
import { GUIDE_MODULE_TEMPLATE, GUIDE_PAGE_TEMPLATE, GUIDE_TEST_TEMPLATE, WHATS_NEW_PAGE_TEMPLATE, } from "./nextjs-guide.js";
|
|
50
51
|
import { commonBaseFiles, EMAIL_DEPS, EMAIL_ENV_BLOCK, emailFiles, localEnvFrom, accessibleOn, contrastRatio, readableInkOn, resolveBrandSpec, SENTRY_DEPS, NEON_DRIVER_DEP, sub, } from "./common.js";
|
|
51
52
|
const NARRATIVE = `## What this is
|
|
@@ -4120,11 +4121,23 @@ const PWA_ICON_SVG_TEMPLATE = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="
|
|
|
4120
4121
|
`;
|
|
4121
4122
|
const PWA_SERVICE_WORKER_TEMPLATE = `// Service worker for {{brand_name}} — {{slug}}.
|
|
4122
4123
|
//
|
|
4123
|
-
//
|
|
4124
|
-
//
|
|
4125
|
-
//
|
|
4126
|
-
//
|
|
4127
|
-
//
|
|
4124
|
+
// 🔴 IT NEVER STORES A PAGE. Most Z2W apps show something personal once a
|
|
4125
|
+
// person signs in (their records, their organization's data, their name in the
|
|
4126
|
+
// header). A cached copy of such a page stays in the browser after sign-out,
|
|
4127
|
+
// readable offline by whoever picks the phone up next, and it shows yesterday's
|
|
4128
|
+
// data as if it were today's. Until CLI v0.44.0 this worker cached every page
|
|
4129
|
+
// it loaded; \`pharmies\` (health data) found the hole and this is its design:
|
|
4130
|
+
//
|
|
4131
|
+
// - Page loads (navigations) always go to the network. If the network fails,
|
|
4132
|
+
// the person sees a small built-in "You're offline" page with no data on it.
|
|
4133
|
+
// - Only Next's build files under /_next/static/ are stored. Their names are
|
|
4134
|
+
// content-hashed, so a stored copy can never be stale and holds no data.
|
|
4135
|
+
// - Everything else (/api/, Next's in-app data fetches, images, form posts,
|
|
4136
|
+
// other sites) passes straight through, untouched.
|
|
4137
|
+
//
|
|
4138
|
+
// An app that genuinely needs data offline keeps it in its own data layer,
|
|
4139
|
+
// ids only where it can, and clears it at sign-out (the \`mobile-apps\` skill,
|
|
4140
|
+
// references/offline-sync.md). Not here.
|
|
4128
4141
|
//
|
|
4129
4142
|
// The cache name is namespaced per app because two Z2W apps can share an
|
|
4130
4143
|
// origin (rootdomain.com/app-a, rootdomain.com/app-b — see
|
|
@@ -4132,9 +4145,16 @@ const PWA_SERVICE_WORKER_TEMPLATE = `// Service worker for {{brand_name}} — {{
|
|
|
4132
4145
|
// evicting each other's entries on every activate.
|
|
4133
4146
|
//
|
|
4134
4147
|
// To ship a breaking change to the caching rules, bump the version suffix. The
|
|
4135
|
-
// activate handler deletes this app's OTHER versions and nothing else.
|
|
4148
|
+
// activate handler deletes this app's OTHER versions and nothing else. (v2
|
|
4149
|
+
// exists so that an app moving off the old page-caching worker deletes the
|
|
4150
|
+
// pages that worker stored.)
|
|
4136
4151
|
const CACHE_PREFIX = "{{slug}}-";
|
|
4137
|
-
const CACHE = CACHE_PREFIX + "
|
|
4152
|
+
const CACHE = CACHE_PREFIX + "v2";
|
|
4153
|
+
|
|
4154
|
+
// Shown when a page load fails offline. Built in, so it needs no route (an auth
|
|
4155
|
+
// middleware could redirect a /offline page to /login, which also fails), and
|
|
4156
|
+
// carries nothing about the signed-in person.
|
|
4157
|
+
const OFFLINE_HTML = __OFFLINE_PAGE_HTML__;
|
|
4138
4158
|
|
|
4139
4159
|
self.addEventListener("install", () => {
|
|
4140
4160
|
// Take over immediately rather than waiting for every tab to close. Paired
|
|
@@ -4175,41 +4195,80 @@ self.addEventListener("fetch", (event) => {
|
|
|
4175
4195
|
|
|
4176
4196
|
const url = new URL(request.url);
|
|
4177
4197
|
|
|
4178
|
-
// Cross-origin (fonts, Fathom, Sentry) belongs to whoever serves it.
|
|
4179
|
-
// no way to know their freshness rules, so we do not hold their bytes.
|
|
4198
|
+
// Cross-origin (fonts, Fathom, Sentry) belongs to whoever serves it.
|
|
4180
4199
|
if (url.origin !== self.location.origin) return;
|
|
4181
4200
|
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
// about per endpoint.
|
|
4187
|
-
if (url.pathname === "/api" || url.pathname.startsWith("/api/")) return;
|
|
4201
|
+
if (request.mode === "navigate") {
|
|
4202
|
+
event.respondWith(networkOrOfflinePage(request));
|
|
4203
|
+
return;
|
|
4204
|
+
}
|
|
4188
4205
|
|
|
4189
|
-
|
|
4206
|
+
if (url.pathname.startsWith("/_next/static/")) {
|
|
4207
|
+
event.respondWith(cacheFirst(request));
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
// Everything else: not intercepted. That includes /api/ (per-user and often
|
|
4211
|
+
// per-second; a stale copy is wrong data presented as current) and Next's
|
|
4212
|
+
// in-app page data, which carries the same personal content as the page.
|
|
4190
4213
|
});
|
|
4191
4214
|
|
|
4192
|
-
|
|
4193
|
-
|
|
4215
|
+
/** Network only; the built-in offline page when the network fails. Never cached. */
|
|
4216
|
+
async function networkOrOfflinePage(request) {
|
|
4194
4217
|
try {
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
}
|
|
4202
|
-
return response;
|
|
4203
|
-
} catch (networkError) {
|
|
4204
|
-
const cached = await cache.match(request);
|
|
4205
|
-
if (cached) return cached;
|
|
4206
|
-
// Nothing cached and no network: let the browser show its own offline
|
|
4207
|
-
// error rather than inventing one. Swallowing this would present an empty
|
|
4208
|
-
// page as a successful load.
|
|
4209
|
-
throw networkError;
|
|
4218
|
+
return await fetch(request);
|
|
4219
|
+
} catch {
|
|
4220
|
+
return new Response(OFFLINE_HTML, {
|
|
4221
|
+
status: 503,
|
|
4222
|
+
headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" },
|
|
4223
|
+
});
|
|
4210
4224
|
}
|
|
4211
4225
|
}
|
|
4226
|
+
|
|
4227
|
+
/** Content-hashed build files: a stored copy is always right. */
|
|
4228
|
+
async function cacheFirst(request) {
|
|
4229
|
+
const cache = await caches.open(CACHE);
|
|
4230
|
+
const cached = await cache.match(request);
|
|
4231
|
+
if (cached) return cached;
|
|
4232
|
+
const response = await fetch(request);
|
|
4233
|
+
// Only same-origin, genuinely-successful responses are stored. Caching a 404
|
|
4234
|
+
// or a redirect would make the failure sticky, which is worse than the failure.
|
|
4235
|
+
if (response && response.ok && response.type === "basic") {
|
|
4236
|
+
await cache.put(request, response.clone());
|
|
4237
|
+
}
|
|
4238
|
+
return response;
|
|
4239
|
+
}
|
|
4212
4240
|
`;
|
|
4241
|
+
/** Escape text for an HTML text node. */
|
|
4242
|
+
function escapeHtmlText(value) {
|
|
4243
|
+
return value.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
4244
|
+
}
|
|
4245
|
+
/**
|
|
4246
|
+
* The service worker's built-in offline page. Large, plain type per the org
|
|
4247
|
+
* readability rule; no script, so it works under any CSP; "Try again" is a link
|
|
4248
|
+
* to the same address, which reloads it.
|
|
4249
|
+
*/
|
|
4250
|
+
function offlinePageHtml(brandName) {
|
|
4251
|
+
const name = escapeHtmlText(brandName);
|
|
4252
|
+
return [
|
|
4253
|
+
"<!doctype html>",
|
|
4254
|
+
'<html lang="en"><head><meta charset="utf-8">',
|
|
4255
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
4256
|
+
`<title>You're offline · ${name}</title>`,
|
|
4257
|
+
"<style>body{font-family:system-ui,sans-serif;font-size:18px;line-height:1.6;margin:0;padding:48px 16px;color:#1a1a1a;background:#fff}",
|
|
4258
|
+
"main{max-width:32rem;margin:0 auto}h1{font-size:1.6rem;line-height:1.3}a{color:#1a1a1a;font-weight:600}</style>",
|
|
4259
|
+
"</head><body><main>",
|
|
4260
|
+
`<h1>You're offline</h1>`,
|
|
4261
|
+
`<p>${name} needs an internet connection to show this page.</p>`,
|
|
4262
|
+
'<p><a href="">Try again</a></p>',
|
|
4263
|
+
"</main></body></html>",
|
|
4264
|
+
].join("");
|
|
4265
|
+
}
|
|
4266
|
+
/** The emitted `public/sw.js`, with the offline page embedded as a JS string. */
|
|
4267
|
+
function pwaServiceWorker(inputs, opts, spec) {
|
|
4268
|
+
const html = JSON.stringify(offlinePageHtml(spec.brandName));
|
|
4269
|
+
// A replacer FUNCTION: a replacement string would interpret `$&`-style patterns.
|
|
4270
|
+
return sub(PWA_SERVICE_WORKER_TEMPLATE, inputs, opts, spec).replace("__OFFLINE_PAGE_HTML__", () => html);
|
|
4271
|
+
}
|
|
4213
4272
|
const PWA_REGISTER_TEMPLATE = `"use client";
|
|
4214
4273
|
|
|
4215
4274
|
// Registers public/sw.js. Mounted once from app/layout.tsx; renders nothing.
|
|
@@ -4256,10 +4315,10 @@ Not SEO, but it is a pre-launch check and this is the pre-launch file.
|
|
|
4256
4315
|
|
|
4257
4316
|
- ✅ \`public/manifest.json\` — \`display: "standalone"\`, \`start_url: "/"\`, \`theme_color\` matching \`viewport.themeColor\` in \`app/layout.tsx\`
|
|
4258
4317
|
- ✅ \`public/icon.svg\` — 512×512, listed twice in the manifest (\`purpose: "any"\` **and** \`purpose: "maskable"\`)
|
|
4259
|
-
- ✅ \`public/sw.js\` —
|
|
4318
|
+
- ✅ \`public/sw.js\` — never stores a page (signed-in pages would stay readable offline after sign-out); page loads go to the network with a built-in offline page; only \`/_next/static/\` build files are cached
|
|
4260
4319
|
- ✅ \`components/ServiceWorker.tsx\` — registers the worker in **production only**, mounted from \`app/layout.tsx\`
|
|
4261
4320
|
- [ ] **Verify installability on the deployed site, not locally** — the worker does not register under \`next dev\` by design. Chrome DevTools → Application → Manifest should list the manifest with no errors and both icon purposes; Application → Service Workers should show \`sw.js\` activated
|
|
4262
|
-
- [ ] **Confirm
|
|
4321
|
+
- [ ] **Confirm no page or API response is cached** — DevTools → Application → Cache Storage → \`{{slug}}-v2\` should list only \`/_next/static/\` files
|
|
4263
4322
|
- [ ] Replace \`public/icon.svg\` with real artwork; keep the 512×512 frame and keep the mark inside the central ~80% (Android crops the rest)
|
|
4264
4323
|
- [ ] Shorten \`short_name\` if \`{{slug}}\` is over ~12 characters — longer names are truncated under the home-screen icon
|
|
4265
4324
|
`;
|
|
@@ -5728,6 +5787,8 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
5728
5787
|
else if (durableLimit) {
|
|
5729
5788
|
packageJson = withExtraDeps(packageJson, NEON_DRIVER_DEP);
|
|
5730
5789
|
}
|
|
5790
|
+
// A test script nothing runs is not a gate (ROADMAP Step 52).
|
|
5791
|
+
packageJson = withHookScripts(packageJson);
|
|
5731
5792
|
let envExample = sub(ENV_EXAMPLE_TEMPLATE, inputs, opts, spec);
|
|
5732
5793
|
// Gated on the DB STRATEGY, not on `durableLimit` — the variable belongs to
|
|
5733
5794
|
// the project's database, not to the one emitted module that happens to read
|
|
@@ -5746,6 +5807,7 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
5746
5807
|
envExample += CARD_PATH_ENV_BLOCK;
|
|
5747
5808
|
const typeSpecific = [
|
|
5748
5809
|
{ path: "package.json", content: packageJson },
|
|
5810
|
+
...prePushHookFiles(),
|
|
5749
5811
|
{
|
|
5750
5812
|
path: "next.config.mjs",
|
|
5751
5813
|
content: sub(hostRouted ? NEXT_CONFIG_HOST_ROUTED_TEMPLATE : NEXT_CONFIG_TEMPLATE, inputs, opts, spec),
|
|
@@ -5857,7 +5919,7 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
5857
5919
|
typeSpecific.push({
|
|
5858
5920
|
path: "public/manifest.json",
|
|
5859
5921
|
content: sub(PWA_MANIFEST_TEMPLATE, inputs, opts, spec),
|
|
5860
|
-
}, { path: "public/icon.svg", content: sub(PWA_ICON_SVG_TEMPLATE, inputs, opts, spec) }, { path: "public/sw.js", content:
|
|
5922
|
+
}, { path: "public/icon.svg", content: sub(PWA_ICON_SVG_TEMPLATE, inputs, opts, spec) }, { path: "public/sw.js", content: pwaServiceWorker(inputs, opts, spec) }, {
|
|
5861
5923
|
path: "components/ServiceWorker.tsx",
|
|
5862
5924
|
content: sub(PWA_REGISTER_TEMPLATE, inputs, opts, spec),
|
|
5863
5925
|
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// NOT subject to the SEO baseline (API-only service, no public HTML surface)
|
|
15
15
|
// and NOT to Fathom (no web UI). IS a deploy target, so the standards resolver
|
|
16
16
|
// inserts the Uptime Kuma + (when applicable) Neon-careful disciplines.
|
|
17
|
+
import { prePushHookFiles, withHookScripts } from "./pre-push-hook.js";
|
|
17
18
|
import { commonBaseFiles, EMAIL_DEPS, EMAIL_ENV_BLOCK, emailFiles, localEnvFrom, resolveBrandSpec, sub, } from "./common.js";
|
|
18
19
|
function buildNarrative(usesNeon) {
|
|
19
20
|
const dbParagraph = usesNeon
|
|
@@ -317,7 +318,8 @@ export function scaffoldNodeService(inputs, opts) {
|
|
|
317
318
|
const base = commonBaseFiles(inputs, opts, buildNarrative(usesNeon));
|
|
318
319
|
const envExample = sub(buildEnvExample(usesNeon, sendsEmail), inputs, opts, spec);
|
|
319
320
|
const typeSpecific = [
|
|
320
|
-
{ path: "package.json", content: sub(buildPackageJson(usesNeon, sendsEmail), inputs, opts, spec) },
|
|
321
|
+
{ path: "package.json", content: withHookScripts(sub(buildPackageJson(usesNeon, sendsEmail), inputs, opts, spec)) },
|
|
322
|
+
...prePushHookFiles(),
|
|
321
323
|
{ path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
|
|
322
324
|
{ path: "vitest.config.ts", content: sub(VITEST_CONFIG_TEMPLATE, inputs, opts, spec) },
|
|
323
325
|
{ path: "src/index.ts", content: sub(SRC_INDEX_TEMPLATE, inputs, opts, spec) },
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tracked `pre-push` hook that runs `npm test`, for every scaffold whose
|
|
3
|
+
* package.json has a test script (`nextjs`, `cf-worker`, `library`,
|
|
4
|
+
* `node-service`).
|
|
5
|
+
*
|
|
6
|
+
* Why (ROADMAP Step 52, `audit-engine`'s 2026-10-25 ACTION): the scaffold
|
|
7
|
+
* emitted `"test": "vitest run"` and nothing that ever ran it. Across 29 apps
|
|
8
|
+
* with tenants, 24 had cross-tenant tests that ran only when an agent typed the
|
|
9
|
+
* command. A local hook costs zero Actions minutes and fails while the author is
|
|
10
|
+
* still at the keyboard ([[github-actions-minute-budget]];
|
|
11
|
+
* [[second-tenant-audit]] Hazard 11). No Actions workflow is emitted: the
|
|
12
|
+
* account's 2,000 shared minutes are the scarce resource.
|
|
13
|
+
*
|
|
14
|
+
* Ported from `file-server`'s `tools/install-hooks.sh`, keeping its three
|
|
15
|
+
* safety rules (each learned when its first draft overwrote Kerry's GLOBAL hook
|
|
16
|
+
* dispatcher), plus one more: in a linked worktree the hooks folder belongs to
|
|
17
|
+
* the main checkout, so the installer skips rather than reaching outside.
|
|
18
|
+
*
|
|
19
|
+
* `prepare` runs on every `npm install`, so it must never fail one: the Node
|
|
20
|
+
* wrapper skips under CI (Vercel and Actions both set `CI`), skips when there is
|
|
21
|
+
* no git repo yet, and turns any installer failure into a warning.
|
|
22
|
+
*/
|
|
23
|
+
import type { ScaffoldFile } from "./common.js";
|
|
24
|
+
export declare const PRE_PUSH_HOOK = "#!/usr/bin/env bash\n#\n# pre-push hook: runs `npm test` before every push.\n# Installed into .git/hooks/ by `npm run hooks:install` (and by `npm install`).\n#\n# Why a hook and not CI: it costs no Actions minutes, and it fails while you are\n# still here to fix it, instead of in a badge nobody re-reads.\n#\n# Skip once: `git push --no-verify`, or `SKIP_PREPUSH=1 git push`.\n\nset -euo pipefail\n\nif [ \"${SKIP_PREPUSH:-}\" = \"1\" ]; then\n echo \"\u00B7 pre-push: skipped (SKIP_PREPUSH=1)\"\n exit 0\nfi\n\ncd \"$(git rev-parse --show-toplevel)\"\n\necho \"\u00B7 pre-push: npm test (skip once with --no-verify)\"\n\n# git passes the refs being pushed on stdin; the tests must not read them.\nif ! npm test < /dev/null; then\n echo \"\"\n echo \"\u2717 pre-push blocked: the tests failed.\"\n echo \" Fix them, or push anyway with: git push --no-verify\"\n exit 1\nfi\n\necho \"\u2713 pre-push: tests passed\"\n";
|
|
25
|
+
export declare const INSTALL_HOOKS_SH = "#!/usr/bin/env bash\n#\n# Install this repo's git hooks. Run: `npm run hooks:install`\n# (`npm install` also runs it, through tools/prepare-hooks.mjs.)\n#\n# Hooks live in tools/ (tracked in git) and are copied into THIS repo's\n# .git/hooks/ (not tracked). Safe to re-run.\n#\n# Four safety rules. The first three were learned when an earlier installer\n# overwrote a machine-wide git hook dispatcher:\n#\n# 1. Find the hooks folder with `git rev-parse --git-dir`, never\n# `git rev-parse --git-path hooks`. The latter follows a global\n# `core.hooksPath`, so a repo installer would write machine-wide.\n# 2. Refuse to write anywhere outside this repository.\n# 3. `rm -f` the destination before copying. A global hooks folder often\n# holds SYMLINKS to a shared dispatcher, and `cp` follows a symlink.\n# 4. In a linked worktree, do nothing: the hooks folder is the main\n# checkout's, outside this folder. Run this from the main checkout.\n#\n# A global `core.hooksPath` dispatcher that chains to `.git/hooks/<name>`\n# runs first and then runs this hook. Both run, in that order.\nset -euo pipefail\n\nrepo_root=\"$(cd \"$(dirname \"$0\")/..\" && pwd)\"\ncd \"$repo_root\"\n\n# Rule 4: a linked worktree shares the main checkout's hooks.\ngit_dir=\"$(cd \"$(git rev-parse --git-dir)\" && pwd)\"\ncommon_dir=\"$(cd \"$(git rev-parse --git-common-dir)\" && pwd)\"\nif [ \"$git_dir\" != \"$common_dir\" ]; then\n echo \"\u00B7 hooks: this is a linked worktree; its hooks are the main checkout's.\"\n echo \" Run \\`npm run hooks:install\\` there instead. Nothing was installed.\"\n exit 0\nfi\n\n# Rule 1: --git-dir, not --git-path hooks.\nhooks_dir=\"$git_dir/hooks\"\n\n# Rule 2: never write outside the repository.\ncase \"$hooks_dir\" in\n \"$repo_root\"/*) ;;\n *)\n echo \"\u2717 refusing to install: the hooks folder is outside this repo\" >&2\n echo \" repo: $repo_root\" >&2\n echo \" hooks: $hooks_dir\" >&2\n exit 1\n ;;\nesac\n\nlocal_hooks=\"$(git config --local --get core.hooksPath || true)\"\nif [ -n \"$local_hooks\" ]; then\n echo \"! this repo sets core.hooksPath to $local_hooks, so git will not read .git/hooks.\" >&2\n echo \" Copy tools/pre-push there by hand, or unset it. Nothing was installed.\" >&2\n exit 1\nfi\n\nmkdir -p \"$hooks_dir\"\n\nfor src in tools/pre-push; do\n dest=\"$hooks_dir/$(basename \"$src\")\"\n\n # Rule 3: clear the path first so cp cannot follow a symlink to its target.\n if [ -L \"$dest\" ]; then\n echo \"\u00B7 $dest was a symlink to $(readlink \"$dest\"); replacing the link, not its target\"\n fi\n rm -f \"$dest\"\n\n cp \"$src\" \"$dest\"\n chmod +x \"$dest\"\n\n if [ ! -f \"$dest\" ] || [ -L \"$dest\" ] || [ ! -x \"$dest\" ] || ! cmp -s \"$src\" \"$dest\"; then\n echo \"\u2717 failed to install $src to $dest\" >&2\n exit 1\n fi\n echo \"\u2713 installed $src \u2192 $dest\"\ndone\n\necho \"The tests now run before each push. Skip once with: git push --no-verify\"\n";
|
|
26
|
+
export declare const PREPARE_HOOKS_MJS = "// Runs on every `npm install` (the \"prepare\" script). Installs the git hooks\n// in tools/ and must NEVER fail an install: it skips in CI (Vercel and GitHub\n// Actions set CI), skips when there is no git repo yet, and turns any installer\n// error into a one-line warning. To install by hand: npm run hooks:install\nimport { spawnSync } from \"node:child_process\";\n\nif (process.env.CI) process.exit(0);\n\nconst inRepo = spawnSync(\"git\", [\"rev-parse\", \"--git-dir\"], { stdio: \"ignore\" });\nif (inRepo.status !== 0) {\n console.log(\"\u00B7 hooks: no git repo yet; run `npm run hooks:install` after `git init`.\");\n process.exit(0);\n}\n\nconst run = spawnSync(\"bash\", [\"tools/install-hooks.sh\"], { stdio: \"inherit\" });\nif (run.status !== 0) {\n console.warn(\"! hooks were not installed (see above). npm install itself is fine.\");\n}\nprocess.exit(0);\n";
|
|
27
|
+
export declare const HOOK_SCRIPTS: Readonly<Record<string, string>>;
|
|
28
|
+
export declare function prePushHookFiles(): ScaffoldFile[];
|
|
29
|
+
/** Adds {@link HOOK_SCRIPTS} to a package.json string, keeping its layout. */
|
|
30
|
+
export declare function withHookScripts(pkgJson: string): string;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export const PRE_PUSH_HOOK = `#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# pre-push hook: runs \`npm test\` before every push.
|
|
4
|
+
# Installed into .git/hooks/ by \`npm run hooks:install\` (and by \`npm install\`).
|
|
5
|
+
#
|
|
6
|
+
# Why a hook and not CI: it costs no Actions minutes, and it fails while you are
|
|
7
|
+
# still here to fix it, instead of in a badge nobody re-reads.
|
|
8
|
+
#
|
|
9
|
+
# Skip once: \`git push --no-verify\`, or \`SKIP_PREPUSH=1 git push\`.
|
|
10
|
+
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
|
|
13
|
+
if [ "\${SKIP_PREPUSH:-}" = "1" ]; then
|
|
14
|
+
echo "· pre-push: skipped (SKIP_PREPUSH=1)"
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
cd "$(git rev-parse --show-toplevel)"
|
|
19
|
+
|
|
20
|
+
echo "· pre-push: npm test (skip once with --no-verify)"
|
|
21
|
+
|
|
22
|
+
# git passes the refs being pushed on stdin; the tests must not read them.
|
|
23
|
+
if ! npm test < /dev/null; then
|
|
24
|
+
echo ""
|
|
25
|
+
echo "✗ pre-push blocked: the tests failed."
|
|
26
|
+
echo " Fix them, or push anyway with: git push --no-verify"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
echo "✓ pre-push: tests passed"
|
|
31
|
+
`;
|
|
32
|
+
export const INSTALL_HOOKS_SH = `#!/usr/bin/env bash
|
|
33
|
+
#
|
|
34
|
+
# Install this repo's git hooks. Run: \`npm run hooks:install\`
|
|
35
|
+
# (\`npm install\` also runs it, through tools/prepare-hooks.mjs.)
|
|
36
|
+
#
|
|
37
|
+
# Hooks live in tools/ (tracked in git) and are copied into THIS repo's
|
|
38
|
+
# .git/hooks/ (not tracked). Safe to re-run.
|
|
39
|
+
#
|
|
40
|
+
# Four safety rules. The first three were learned when an earlier installer
|
|
41
|
+
# overwrote a machine-wide git hook dispatcher:
|
|
42
|
+
#
|
|
43
|
+
# 1. Find the hooks folder with \`git rev-parse --git-dir\`, never
|
|
44
|
+
# \`git rev-parse --git-path hooks\`. The latter follows a global
|
|
45
|
+
# \`core.hooksPath\`, so a repo installer would write machine-wide.
|
|
46
|
+
# 2. Refuse to write anywhere outside this repository.
|
|
47
|
+
# 3. \`rm -f\` the destination before copying. A global hooks folder often
|
|
48
|
+
# holds SYMLINKS to a shared dispatcher, and \`cp\` follows a symlink.
|
|
49
|
+
# 4. In a linked worktree, do nothing: the hooks folder is the main
|
|
50
|
+
# checkout's, outside this folder. Run this from the main checkout.
|
|
51
|
+
#
|
|
52
|
+
# A global \`core.hooksPath\` dispatcher that chains to \`.git/hooks/<name>\`
|
|
53
|
+
# runs first and then runs this hook. Both run, in that order.
|
|
54
|
+
set -euo pipefail
|
|
55
|
+
|
|
56
|
+
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
57
|
+
cd "$repo_root"
|
|
58
|
+
|
|
59
|
+
# Rule 4: a linked worktree shares the main checkout's hooks.
|
|
60
|
+
git_dir="$(cd "$(git rev-parse --git-dir)" && pwd)"
|
|
61
|
+
common_dir="$(cd "$(git rev-parse --git-common-dir)" && pwd)"
|
|
62
|
+
if [ "$git_dir" != "$common_dir" ]; then
|
|
63
|
+
echo "· hooks: this is a linked worktree; its hooks are the main checkout's."
|
|
64
|
+
echo " Run \\\`npm run hooks:install\\\` there instead. Nothing was installed."
|
|
65
|
+
exit 0
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Rule 1: --git-dir, not --git-path hooks.
|
|
69
|
+
hooks_dir="$git_dir/hooks"
|
|
70
|
+
|
|
71
|
+
# Rule 2: never write outside the repository.
|
|
72
|
+
case "$hooks_dir" in
|
|
73
|
+
"$repo_root"/*) ;;
|
|
74
|
+
*)
|
|
75
|
+
echo "✗ refusing to install: the hooks folder is outside this repo" >&2
|
|
76
|
+
echo " repo: $repo_root" >&2
|
|
77
|
+
echo " hooks: $hooks_dir" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
;;
|
|
80
|
+
esac
|
|
81
|
+
|
|
82
|
+
local_hooks="$(git config --local --get core.hooksPath || true)"
|
|
83
|
+
if [ -n "$local_hooks" ]; then
|
|
84
|
+
echo "! this repo sets core.hooksPath to $local_hooks, so git will not read .git/hooks." >&2
|
|
85
|
+
echo " Copy tools/pre-push there by hand, or unset it. Nothing was installed." >&2
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
mkdir -p "$hooks_dir"
|
|
90
|
+
|
|
91
|
+
for src in tools/pre-push; do
|
|
92
|
+
dest="$hooks_dir/$(basename "$src")"
|
|
93
|
+
|
|
94
|
+
# Rule 3: clear the path first so cp cannot follow a symlink to its target.
|
|
95
|
+
if [ -L "$dest" ]; then
|
|
96
|
+
echo "· $dest was a symlink to $(readlink "$dest"); replacing the link, not its target"
|
|
97
|
+
fi
|
|
98
|
+
rm -f "$dest"
|
|
99
|
+
|
|
100
|
+
cp "$src" "$dest"
|
|
101
|
+
chmod +x "$dest"
|
|
102
|
+
|
|
103
|
+
if [ ! -f "$dest" ] || [ -L "$dest" ] || [ ! -x "$dest" ] || ! cmp -s "$src" "$dest"; then
|
|
104
|
+
echo "✗ failed to install $src to $dest" >&2
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
echo "✓ installed $src → $dest"
|
|
108
|
+
done
|
|
109
|
+
|
|
110
|
+
echo "The tests now run before each push. Skip once with: git push --no-verify"
|
|
111
|
+
`;
|
|
112
|
+
export const PREPARE_HOOKS_MJS = `// Runs on every \`npm install\` (the "prepare" script). Installs the git hooks
|
|
113
|
+
// in tools/ and must NEVER fail an install: it skips in CI (Vercel and GitHub
|
|
114
|
+
// Actions set CI), skips when there is no git repo yet, and turns any installer
|
|
115
|
+
// error into a one-line warning. To install by hand: npm run hooks:install
|
|
116
|
+
import { spawnSync } from "node:child_process";
|
|
117
|
+
|
|
118
|
+
if (process.env.CI) process.exit(0);
|
|
119
|
+
|
|
120
|
+
const inRepo = spawnSync("git", ["rev-parse", "--git-dir"], { stdio: "ignore" });
|
|
121
|
+
if (inRepo.status !== 0) {
|
|
122
|
+
console.log("· hooks: no git repo yet; run \`npm run hooks:install\` after \`git init\`.");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const run = spawnSync("bash", ["tools/install-hooks.sh"], { stdio: "inherit" });
|
|
127
|
+
if (run.status !== 0) {
|
|
128
|
+
console.warn("! hooks were not installed (see above). npm install itself is fine.");
|
|
129
|
+
}
|
|
130
|
+
process.exit(0);
|
|
131
|
+
`;
|
|
132
|
+
export const HOOK_SCRIPTS = {
|
|
133
|
+
"hooks:install": "bash tools/install-hooks.sh",
|
|
134
|
+
prepare: "node tools/prepare-hooks.mjs",
|
|
135
|
+
};
|
|
136
|
+
export function prePushHookFiles() {
|
|
137
|
+
return [
|
|
138
|
+
{ path: "tools/pre-push", content: PRE_PUSH_HOOK },
|
|
139
|
+
{ path: "tools/install-hooks.sh", content: INSTALL_HOOKS_SH },
|
|
140
|
+
{ path: "tools/prepare-hooks.mjs", content: PREPARE_HOOKS_MJS },
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
/** Adds {@link HOOK_SCRIPTS} to a package.json string, keeping its layout. */
|
|
144
|
+
export function withHookScripts(pkgJson) {
|
|
145
|
+
const obj = JSON.parse(pkgJson);
|
|
146
|
+
obj.scripts = { ...obj.scripts, ...HOOK_SCRIPTS };
|
|
147
|
+
return JSON.stringify(obj, null, 2) + "\n";
|
|
148
|
+
}
|