@zero2webmaster/starter-kit 0.2.0 → 0.3.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 +14 -15
- package/dist/airtable.d.ts +119 -0
- package/dist/airtable.js +273 -0
- package/dist/brief.d.ts +2 -2
- package/dist/brief.js +11 -4
- package/dist/cli.js +290 -17
- package/dist/confirm.d.ts +16 -4
- package/dist/confirm.js +66 -32
- package/dist/index.d.ts +195 -3
- package/dist/index.js +155 -6
- package/dist/inventory.d.ts +137 -0
- package/dist/inventory.js +258 -0
- package/dist/license.d.ts +97 -0
- package/dist/license.js +474 -0
- package/dist/parse-brief.d.ts +45 -1
- package/dist/parse-brief.js +349 -21
- package/dist/scaffolders/common.d.ts +42 -1
- package/dist/scaffolders/common.js +753 -30
- package/dist/scaffolders/index.d.ts +1 -0
- package/dist/scaffolders/index.js +3 -0
- package/dist/scaffolders/library.js +26 -2
- package/dist/scaffolders/nextjs.d.ts +1 -1
- package/dist/scaffolders/nextjs.js +254 -24
- package/dist/scaffolders/node-service.d.ts +3 -0
- package/dist/scaffolders/node-service.js +320 -0
- package/dist/scaffolders/pro-seo-extension.d.ts +11 -0
- package/dist/scaffolders/pro-seo-extension.js +782 -0
- package/dist/scaffolders/python-service.js +10 -2
- package/dist/scaffolders/wp-plugin.js +8 -8
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +164 -5
- package/dist/substitute.d.ts +22 -3
- package/dist/substitute.js +19 -5
- package/dist/summary.d.ts +9 -0
- package/dist/summary.js +31 -13
- package/dist/templates.d.ts +43 -57
- package/dist/templates.js +108 -175
- package/dist/with-init.d.ts +32 -0
- package/dist/with-init.js +171 -0
- package/dist/wizard.js +21 -0
- package/dist/writer.d.ts +13 -6
- package/dist/writer.js +119 -21
- package/package.json +2 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// z2w-starter-kit automatic GitHub-repo setup.
|
|
2
|
+
//
|
|
3
|
+
// After a successful scaffold, runs:
|
|
4
|
+
// git init -b main
|
|
5
|
+
// git config user.email "kerry@zero2webmaster.com" (repo-local)
|
|
6
|
+
// git add .
|
|
7
|
+
// git commit -m "Initial scaffold via @zero2webmaster/starter-kit (<slug>)"
|
|
8
|
+
// gh repo create {githubOrg}/{slug} --private --source=. --remote=origin --push [--description "…"]
|
|
9
|
+
// gh repo edit {githubOrg}/{slug} --add-topic … (non-fatal — cosmetic)
|
|
10
|
+
//
|
|
11
|
+
// As of the 2026-06-16 Track D decision (STATUS.md → Decisions), this is a
|
|
12
|
+
// DEFAULT side-effect of `init`, not a paid opt-in. It runs for the interactive
|
|
13
|
+
// brief-first / --wizard flows unless `--no-repo` is passed; it is SKIPPED for
|
|
14
|
+
// --dry-run and for the non-interactive --input (CI) path, which only print the
|
|
15
|
+
// would-be commands. This OVERRIDES CLAUDE.md Operating Principle #3 for repo
|
|
16
|
+
// creation specifically; every other side-effect (npm install, composer
|
|
17
|
+
// install, ln -s, …) stays surfaced-only. The exported names retain the
|
|
18
|
+
// `WithInit` prefix from when repo creation was the body of the retired paid
|
|
19
|
+
// `--with-init` flag — the chain is the same, only the gating changed.
|
|
20
|
+
//
|
|
21
|
+
// `runWithInit` THROWS on a hard failure (git/gh missing, non-zero exit). The
|
|
22
|
+
// caller (src/cli.ts) wraps it in warn-and-proceed so a failed repo setup never
|
|
23
|
+
// fails the scaffold — the files are already written; the manual fallback
|
|
24
|
+
// commands are surfaced instead (mirrors the Airtable-row warn-and-proceed
|
|
25
|
+
// posture). The repo-local `user.email` is the Vercel-Hobby commit-author
|
|
26
|
+
// workaround per [[z2w-magic-link-auth]] §8.
|
|
27
|
+
//
|
|
28
|
+
// `gh` is invoked, not the GitHub REST API, so the user's existing
|
|
29
|
+
// `gh auth login` credentials are honored (no token plumbing required).
|
|
30
|
+
import { spawn } from "node:child_process";
|
|
31
|
+
const REPO_COMMIT_AUTHOR_EMAIL = "kerry@zero2webmaster.com";
|
|
32
|
+
const MAX_DESCRIPTION_LENGTH = 140;
|
|
33
|
+
export class WithInitError extends Error {
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = "WithInitError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build the repo's GitHub `--description` (the "About" blurb). Prefers the
|
|
41
|
+
* brief's Purpose section when scaffolding from a brief, else the project
|
|
42
|
+
* description. Collapses whitespace/newlines to a single line and caps the
|
|
43
|
+
* length so a multi-paragraph Purpose doesn't become an unwieldy blurb.
|
|
44
|
+
* Returns `null` when there's nothing meaningful to set.
|
|
45
|
+
*/
|
|
46
|
+
export function repoDescription(inputs) {
|
|
47
|
+
const source = inputs.briefSections?.purpose?.trim() || inputs.description?.trim() || "";
|
|
48
|
+
const collapsed = source.replace(/\s+/g, " ").trim();
|
|
49
|
+
if (collapsed.length === 0)
|
|
50
|
+
return null;
|
|
51
|
+
if (collapsed.length <= MAX_DESCRIPTION_LENGTH)
|
|
52
|
+
return collapsed;
|
|
53
|
+
return collapsed.slice(0, MAX_DESCRIPTION_LENGTH - 1).trimEnd() + "…";
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the repo's GitHub topics: the project type plus the brand preset
|
|
57
|
+
* (skipping `custom`, which isn't a meaningful public topic). Lowercased,
|
|
58
|
+
* de-duplicated, and order-stable. Topic strings from the enums are already
|
|
59
|
+
* GitHub-legal (lowercase, hyphenated).
|
|
60
|
+
*/
|
|
61
|
+
export function repoTopics(inputs) {
|
|
62
|
+
const candidates = [inputs.projectType, inputs.brand === "custom" ? null : inputs.brand];
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
const topics = [];
|
|
65
|
+
for (const c of candidates) {
|
|
66
|
+
if (c === null)
|
|
67
|
+
continue;
|
|
68
|
+
const t = c.toLowerCase();
|
|
69
|
+
if (seen.has(t))
|
|
70
|
+
continue;
|
|
71
|
+
seen.add(t);
|
|
72
|
+
topics.push(t);
|
|
73
|
+
}
|
|
74
|
+
return topics;
|
|
75
|
+
}
|
|
76
|
+
function runCommand(command, args, cwd, spawnImpl) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const child = spawnImpl(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
79
|
+
let stdout = "";
|
|
80
|
+
let stderr = "";
|
|
81
|
+
child.stdout?.on("data", (chunk) => {
|
|
82
|
+
stdout += chunk.toString("utf8");
|
|
83
|
+
});
|
|
84
|
+
child.stderr?.on("data", (chunk) => {
|
|
85
|
+
stderr += chunk.toString("utf8");
|
|
86
|
+
});
|
|
87
|
+
child.on("error", (err) => reject(err));
|
|
88
|
+
child.on("close", (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async function step(label, command, args, cwd, spawnImpl, stdout) {
|
|
92
|
+
stdout.write(`\n ${label}: ${command} ${args.join(" ")}\n`);
|
|
93
|
+
let result;
|
|
94
|
+
try {
|
|
95
|
+
result = await runCommand(command, args, cwd, spawnImpl);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const message = err.code === "ENOENT"
|
|
99
|
+
? `${command} not found on PATH. Install it and re-run.`
|
|
100
|
+
: err.message;
|
|
101
|
+
throw new WithInitError(`${label} failed: ${message}`);
|
|
102
|
+
}
|
|
103
|
+
if (result.code !== 0) {
|
|
104
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
105
|
+
throw new WithInitError(`${label} exited with code ${result.code}${detail ? `: ${detail}` : ""}`);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Like {@link step}, but a failure (missing binary or non-zero exit) is
|
|
111
|
+
* surfaced as a warning and swallowed rather than thrown. Used for the
|
|
112
|
+
* topics step — the repo + push already succeeded by then, so a topic-edit
|
|
113
|
+
* hiccup must not unwind the whole setup.
|
|
114
|
+
*/
|
|
115
|
+
async function stepNonFatal(label, command, args, cwd, spawnImpl, stdout) {
|
|
116
|
+
stdout.write(`\n ${label}: ${command} ${args.join(" ")}\n`);
|
|
117
|
+
try {
|
|
118
|
+
const result = await runCommand(command, args, cwd, spawnImpl);
|
|
119
|
+
if (result.code !== 0) {
|
|
120
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
121
|
+
stdout.write(` (skipped: ${label} exited ${result.code}${detail ? ` — ${detail}` : ""})\n`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
const message = err.code === "ENOENT"
|
|
126
|
+
? `${command} not on PATH`
|
|
127
|
+
: err.message;
|
|
128
|
+
stdout.write(` (skipped: ${label} — ${message})\n`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Runs the post-scaffold git + gh chain that creates the private GitHub repo.
|
|
133
|
+
* THROWS {@link WithInitError} on a hard failure; the caller decides whether to
|
|
134
|
+
* warn-and-proceed (it does — see src/cli.ts).
|
|
135
|
+
*/
|
|
136
|
+
export async function runWithInit(inputs, targetPath, opts = {}) {
|
|
137
|
+
const stdout = opts.stdout ?? process.stdout;
|
|
138
|
+
const stderr = opts.stderr ?? process.stderr;
|
|
139
|
+
const spawnImpl = opts.spawnImpl ?? spawn;
|
|
140
|
+
const repoRef = `${inputs.githubOrg}/${inputs.slug}`;
|
|
141
|
+
const commitMessage = `Initial scaffold via @zero2webmaster/starter-kit (${inputs.slug})`;
|
|
142
|
+
const description = repoDescription(inputs);
|
|
143
|
+
const topics = repoTopics(inputs);
|
|
144
|
+
stdout.write(`\nSetting up the private GitHub repo ${repoRef} ...\n`);
|
|
145
|
+
await step("git init", "git", ["init", "-b", "main"], targetPath, spawnImpl, stdout);
|
|
146
|
+
await step("git config user.email", "git", ["config", "user.email", REPO_COMMIT_AUTHOR_EMAIL], targetPath, spawnImpl, stdout);
|
|
147
|
+
await step("git add", "git", ["add", "."], targetPath, spawnImpl, stdout);
|
|
148
|
+
await step("git commit", "git", ["commit", "-m", commitMessage], targetPath, spawnImpl, stdout);
|
|
149
|
+
const createArgs = [
|
|
150
|
+
"repo",
|
|
151
|
+
"create",
|
|
152
|
+
repoRef,
|
|
153
|
+
"--private",
|
|
154
|
+
"--source=.",
|
|
155
|
+
"--remote=origin",
|
|
156
|
+
"--push",
|
|
157
|
+
];
|
|
158
|
+
if (description !== null) {
|
|
159
|
+
createArgs.push("--description", description);
|
|
160
|
+
}
|
|
161
|
+
await step("gh repo create", "gh", createArgs, targetPath, spawnImpl, stdout);
|
|
162
|
+
if (topics.length > 0) {
|
|
163
|
+
const editArgs = ["repo", "edit", repoRef];
|
|
164
|
+
for (const t of topics) {
|
|
165
|
+
editArgs.push("--add-topic", t);
|
|
166
|
+
}
|
|
167
|
+
await stepNonFatal("gh repo edit (topics)", "gh", editArgs, targetPath, spawnImpl, stdout);
|
|
168
|
+
}
|
|
169
|
+
stdout.write(`\nRepo ready: https://github.com/${repoRef} (private) — scaffold committed and pushed.\n`);
|
|
170
|
+
stderr; // (touch: stderr is reserved for future surfacing)
|
|
171
|
+
}
|
package/dist/wizard.js
CHANGED
|
@@ -138,6 +138,24 @@ export async function runWizard(opts) {
|
|
|
138
138
|
const hasWebUi = await askValidated(prompter, "8a. Has web UI (yes/no):", parseYesNo, undefined, out);
|
|
139
139
|
const hasCron = await askValidated(prompter, "8b. Has cron / scheduled jobs (yes/no):", parseYesNo, undefined, out);
|
|
140
140
|
const participateInBulletin = await askValidated(prompter, "8c. Participate in agent bulletin (yes/no):", parseYesNo, brand === "zero2webmaster" ? "yes" : "no", out);
|
|
141
|
+
// Only nextjs / node-service honor this; other types use FluentSMTP (WP) or
|
|
142
|
+
// the Cloudflare Email Service (Workers). Default no — the mailer pulls in the
|
|
143
|
+
// AWS/Resend SDKs, so we only emit it when the app actually sends email.
|
|
144
|
+
const sendsEmail = await askValidated(prompter, "8d. Sends transactional / auth email (yes/no):", parseYesNo, "no", out);
|
|
145
|
+
// Gates the [[moderation-system]] standard. Default no — only relevant for
|
|
146
|
+
// apps whose users post content others see (community, events, marketplace,
|
|
147
|
+
// profiles, DMs). Skipped downstream for wp-plugin / library / protocol-repo.
|
|
148
|
+
const hasUserContent = await askValidated(prompter, "8e. Accepts user-generated content (yes/no):", parseYesNo, "no", out);
|
|
149
|
+
// Gates the [[sentry-runtime-errors]] standard. Default YES for customer-facing
|
|
150
|
+
// web apps (nextjs / cf-pages + web UI) — Sentry's free tier covers Z2W-scale
|
|
151
|
+
// projects and the org default is "wire runtime-error tracking at instantiation
|
|
152
|
+
// for apps with real users." Default NO otherwise (Workers / services / CLI /
|
|
153
|
+
// WP have no per-user request surface the Next.js wizard fits). Downstream the
|
|
154
|
+
// standard only inserts for nextjs / cf-pages regardless.
|
|
155
|
+
const observabilityDefault = (projectType === "nextjs" || projectType === "cf-pages") && hasWebUi
|
|
156
|
+
? "yes"
|
|
157
|
+
: "no";
|
|
158
|
+
const hasObservability = await askValidated(prompter, "8f. Wire Sentry runtime-error tracking (yes/no):", parseYesNo, observabilityDefault, out);
|
|
141
159
|
const result = {
|
|
142
160
|
slug,
|
|
143
161
|
description,
|
|
@@ -149,6 +167,9 @@ export async function runWizard(opts) {
|
|
|
149
167
|
hasWebUi,
|
|
150
168
|
hasCron,
|
|
151
169
|
participateInBulletin,
|
|
170
|
+
sendsEmail,
|
|
171
|
+
hasUserContent,
|
|
172
|
+
hasObservability,
|
|
152
173
|
};
|
|
153
174
|
if (customBrand) {
|
|
154
175
|
result.customBrand = customBrand;
|
package/dist/writer.d.ts
CHANGED
|
@@ -4,22 +4,29 @@ import type { ScaffoldFile } from "./scaffolders/common.js";
|
|
|
4
4
|
import { type StandardDecision, type StandardKey } from "./standards.js";
|
|
5
5
|
import { type ReadTemplateOptions } from "./templates.js";
|
|
6
6
|
export interface WriteScaffoldOptions {
|
|
7
|
-
/** When true, print
|
|
7
|
+
/** When true, print a file list to stdout and skip disk writes. */
|
|
8
8
|
dryRun?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* In dry-run mode, also dump the full content of every file (the pre-v0.2.1
|
|
11
|
+
* default). When false (the new default), dry-run prints only the file list
|
|
12
|
+
* with byte sizes — the 2026-06-03 dogfood finding #5, where a full-content
|
|
13
|
+
* dump buried the standards summary + next-actions in hundreds of lines.
|
|
14
|
+
*/
|
|
15
|
+
showContents?: boolean;
|
|
9
16
|
/** When true (default), refuse to write into a non-empty target directory. */
|
|
10
17
|
refuseNonEmpty?: boolean;
|
|
11
|
-
/** Forwarded to {@link
|
|
18
|
+
/** Forwarded to {@link resolveAgentsTemplate}; tests pin this at a sandbox. */
|
|
12
19
|
templatesPath?: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/** Overrides for the Templates resolver (mirror URL, cache dir, fetch, clock, onWarn). Tests. */
|
|
16
|
-
templatesOverrides?: Omit<ReadTemplateOptions, "templatesPath" | "refreshTemplates">;
|
|
20
|
+
/** Overrides for the Templates resolver (onWarn). Tests. */
|
|
21
|
+
templatesOverrides?: Omit<ReadTemplateOptions, "templatesPath">;
|
|
17
22
|
/** When true, run the interactive (a) inline / (b) promote dialog per standard. */
|
|
18
23
|
promoteStandards?: boolean;
|
|
19
24
|
/** Forwarded to {@link resolveStandards} + {@link scaffoldByType}; date pin. */
|
|
20
25
|
date?: string;
|
|
21
26
|
/** Required when `promoteStandards: true`; ignored otherwise. */
|
|
22
27
|
prompter?: Prompter;
|
|
28
|
+
/** When true, layer the Pro SEO baseline extension on top of nextjs/cf-pages scaffolds. v0.3.0 paid feature. */
|
|
29
|
+
withProSeo?: boolean;
|
|
23
30
|
/** Where dry-run output + promotion-dialog narration are written. */
|
|
24
31
|
output?: NodeJS.WritableStream;
|
|
25
32
|
}
|
package/dist/writer.js
CHANGED
|
@@ -24,9 +24,10 @@ import { promises as fs } from "node:fs";
|
|
|
24
24
|
import * as path from "node:path";
|
|
25
25
|
import fsExtra from "fs-extra";
|
|
26
26
|
import { AGENTS_BODY_MARKER, STANDARDS_BLOCK_MARKER, } from "./scaffolders/common.js";
|
|
27
|
+
import { buildProSeoExtension, proSeoApplies, } from "./scaffolders/pro-seo-extension.js";
|
|
27
28
|
import { scaffoldByType } from "./scaffolders/index.js";
|
|
28
29
|
import { applyStandardsBlock, resolveStandards, } from "./standards.js";
|
|
29
|
-
import {
|
|
30
|
+
import { resolveAgentsTemplate, } from "./templates.js";
|
|
30
31
|
export class WriterError extends Error {
|
|
31
32
|
constructor(message) {
|
|
32
33
|
super(message);
|
|
@@ -34,11 +35,6 @@ export class WriterError extends Error {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
const PROMOTIONS_FILE = "STANDARDS_PROMOTIONS.md";
|
|
37
|
-
function agentsTemplateNameFor(inputs) {
|
|
38
|
-
return inputs.projectType === "wp-plugin"
|
|
39
|
-
? "AGENTS_WP_v3.1.0.md"
|
|
40
|
-
: "AGENTS_v2.13.0.md";
|
|
41
|
-
}
|
|
42
38
|
/**
|
|
43
39
|
* Split a standards body into preamble + per-standard sections so the writer
|
|
44
40
|
* can drop sections the user picked (b) for during the promotion dialog.
|
|
@@ -188,8 +184,17 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
188
184
|
throw new WriterError(`targetPath must be absolute. Got: ${JSON.stringify(targetPath)}.`);
|
|
189
185
|
}
|
|
190
186
|
const resolvedTarget = path.resolve(targetPath);
|
|
187
|
+
// Resolve the canonical AGENTS body FIRST — its filename is the single source
|
|
188
|
+
// of truth for {{framework_version}}, which Layer 1 substitutes into the
|
|
189
|
+
// scaffolded files. Discovered by glob on the local path so a canonical
|
|
190
|
+
// filename bump flows through with no code change.
|
|
191
|
+
const agentsKind = inputs.projectType === "wp-plugin" ? "wp" : "general";
|
|
192
|
+
const { content: agentsBody, version: frameworkVersion, } = await resolveAgentsTemplate(agentsKind, {
|
|
193
|
+
templatesPath: opts.templatesPath,
|
|
194
|
+
...(opts.templatesOverrides ?? {}),
|
|
195
|
+
});
|
|
191
196
|
// Layer 1 — per-type scaffolder output.
|
|
192
|
-
const files = scaffoldByType(inputs, { date: opts.date });
|
|
197
|
+
const files = scaffoldByType(inputs, { date: opts.date, frameworkVersion });
|
|
193
198
|
// Layer 2 — standards resolver.
|
|
194
199
|
let resolution = resolveStandards(inputs, {
|
|
195
200
|
promoteStandards,
|
|
@@ -204,14 +209,7 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
204
209
|
resolution = dialog.resolution;
|
|
205
210
|
promotions = dialog.promotions;
|
|
206
211
|
}
|
|
207
|
-
//
|
|
208
|
-
const agentsName = agentsTemplateNameFor(inputs);
|
|
209
|
-
const { content: agentsBody } = await readTemplateWithFallback(agentsName, {
|
|
210
|
-
templatesPath: opts.templatesPath,
|
|
211
|
-
refreshTemplates: opts.refreshTemplates,
|
|
212
|
-
...(opts.templatesOverrides ?? {}),
|
|
213
|
-
});
|
|
214
|
-
// Compose CLAUDE.md by filling both markers.
|
|
212
|
+
// Compose CLAUDE.md by filling both markers (AGENTS body resolved up top).
|
|
215
213
|
const claudeIdx = files.findIndex((f) => f.path === "CLAUDE.md");
|
|
216
214
|
if (claudeIdx === -1) {
|
|
217
215
|
throw new WriterError(`Internal error: scaffoldByType output for projectType=${inputs.projectType} did not include CLAUDE.md.`);
|
|
@@ -226,16 +224,40 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
226
224
|
const dateForFile = opts.date ?? new Date().toISOString().slice(0, 10);
|
|
227
225
|
files.push(buildPromotionsFile(inputs, promotions, dateForFile));
|
|
228
226
|
}
|
|
227
|
+
// Layer 4 — Pro SEO baseline extension (paid feature; nextjs/cf-pages only).
|
|
228
|
+
if (opts.withProSeo === true) {
|
|
229
|
+
if (!proSeoApplies(inputs)) {
|
|
230
|
+
throw new WriterError(`--with-pro-seo applies only to nextjs + cf-pages projects with hasWebUi=true. ` +
|
|
231
|
+
`This scaffold is projectType=${inputs.projectType} (hasWebUi=${inputs.hasWebUi}).`);
|
|
232
|
+
}
|
|
233
|
+
for (const file of buildProSeoExtension(inputs)) {
|
|
234
|
+
files.push(file);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
229
237
|
for (const file of files) {
|
|
230
238
|
assertScaffoldedPathSafe(resolvedTarget, file);
|
|
231
239
|
}
|
|
232
240
|
if (dryRun) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
output.write(
|
|
241
|
+
const showContents = opts.showContents === true;
|
|
242
|
+
output.write(`\n# Dry run — would write ${files.length} files into ${resolvedTarget}\n\n`);
|
|
243
|
+
if (showContents) {
|
|
244
|
+
for (const file of files) {
|
|
245
|
+
output.write(`\n----- ${file.path} -----\n`);
|
|
246
|
+
output.write(file.content);
|
|
247
|
+
if (!file.content.endsWith("\n"))
|
|
248
|
+
output.write("\n");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
// Default: a scannable file list with byte sizes. The full content dump
|
|
253
|
+
// is behind --show-contents so the standards summary + next-actions
|
|
254
|
+
// (rendered by renderSummary right after this) stay visible.
|
|
255
|
+
const width = String(Math.max(...files.map((f) => Buffer.byteLength(f.content, "utf8")))).length;
|
|
256
|
+
for (const file of files) {
|
|
257
|
+
const bytes = String(Buffer.byteLength(file.content, "utf8")).padStart(width);
|
|
258
|
+
output.write(` ${bytes} B ${file.path}\n`);
|
|
259
|
+
}
|
|
260
|
+
output.write(`\n# (run with --show-contents to print every file's full content)\n`);
|
|
239
261
|
}
|
|
240
262
|
output.write(`\n# End dry run — ${files.length} files, CLAUDE.md is ${claudeContent.length} bytes.\n`);
|
|
241
263
|
return {
|
|
@@ -348,6 +370,82 @@ export function parseScaffoldInputs(json) {
|
|
|
348
370
|
accentColor: cbo["accentColor"],
|
|
349
371
|
};
|
|
350
372
|
}
|
|
373
|
+
// Optional: whether this project sends transactional / auth email. Defaults
|
|
374
|
+
// to false (no mailer). Honored only by nextjs / node-service scaffolders.
|
|
375
|
+
if (obj["sendsEmail"] !== undefined) {
|
|
376
|
+
if (typeof obj["sendsEmail"] !== "boolean") {
|
|
377
|
+
throw new WriterError(`--input field "sendsEmail" must be a boolean, got ${typeof obj["sendsEmail"]}.`);
|
|
378
|
+
}
|
|
379
|
+
inputs.sendsEmail = obj["sendsEmail"];
|
|
380
|
+
}
|
|
381
|
+
// Optional: whether this project accepts user-generated content. Defaults to
|
|
382
|
+
// false (no moderation standard). Gates the [[moderation-system]] standard for
|
|
383
|
+
// non-WP app types (skipped for wp-plugin / library / protocol-repo).
|
|
384
|
+
if (obj["hasUserContent"] !== undefined) {
|
|
385
|
+
if (typeof obj["hasUserContent"] !== "boolean") {
|
|
386
|
+
throw new WriterError(`--input field "hasUserContent" must be a boolean, got ${typeof obj["hasUserContent"]}.`);
|
|
387
|
+
}
|
|
388
|
+
inputs.hasUserContent = obj["hasUserContent"];
|
|
389
|
+
}
|
|
390
|
+
// Optional: whether to wire Sentry runtime-error/APM observability. Defaults
|
|
391
|
+
// to false on the --input path (opt-in / explicit for CI + programmatic
|
|
392
|
+
// callers; the interactive flows apply the customer-facing smart default
|
|
393
|
+
// instead). Gates the [[sentry-runtime-errors]] standard for nextjs / cf-pages.
|
|
394
|
+
if (obj["hasObservability"] !== undefined) {
|
|
395
|
+
if (typeof obj["hasObservability"] !== "boolean") {
|
|
396
|
+
throw new WriterError(`--input field "hasObservability" must be a boolean, got ${typeof obj["hasObservability"]}.`);
|
|
397
|
+
}
|
|
398
|
+
inputs.hasObservability = obj["hasObservability"];
|
|
399
|
+
}
|
|
400
|
+
// Optional: the verbatim instantiation prompt, recorded on the Airtable row.
|
|
401
|
+
// The --input path has no brief to capture, so callers may supply it here;
|
|
402
|
+
// when omitted, the Airtable write reminds the agent to add it by hand.
|
|
403
|
+
if (obj["instantiationPrompt"] !== undefined) {
|
|
404
|
+
if (typeof obj["instantiationPrompt"] !== "string") {
|
|
405
|
+
throw new WriterError(`--input field "instantiationPrompt" must be a string, got ${typeof obj["instantiationPrompt"]}.`);
|
|
406
|
+
}
|
|
407
|
+
inputs.instantiationPrompt = obj["instantiationPrompt"];
|
|
408
|
+
}
|
|
409
|
+
// Optional: brief planning sections (purpose / roadmap / future improvements /
|
|
410
|
+
// …). The interactive brief-first flow populates these via
|
|
411
|
+
// `extractBriefSections`; the `--input` path has no brief to parse, so a
|
|
412
|
+
// caller that HAS the brief content (e.g. a bootstrap builder that embedded
|
|
413
|
+
// the brief as `instantiationPrompt`) may pass the pre-sliced sections here.
|
|
414
|
+
// Without this, every `--input`-scaffolded project falls to a placeholder
|
|
415
|
+
// ROADMAP even when the brief content is available (see STATUS Tech Debt,
|
|
416
|
+
// found 2026-07-01 during the home-systems bootstrap).
|
|
417
|
+
if (obj["briefSections"] !== undefined) {
|
|
418
|
+
const bs = obj["briefSections"];
|
|
419
|
+
if (bs === null || typeof bs !== "object" || Array.isArray(bs)) {
|
|
420
|
+
throw new WriterError(`--input field "briefSections" must be an object, got ${Array.isArray(bs) ? "array" : typeof bs}.`);
|
|
421
|
+
}
|
|
422
|
+
const bso = bs;
|
|
423
|
+
const BRIEF_SECTION_KEYS = [
|
|
424
|
+
"purpose",
|
|
425
|
+
"keyApis",
|
|
426
|
+
"dataSources",
|
|
427
|
+
"expectedOutputs",
|
|
428
|
+
"edgeCases",
|
|
429
|
+
"roadmap",
|
|
430
|
+
"futureImprovements",
|
|
431
|
+
];
|
|
432
|
+
const sections = {};
|
|
433
|
+
for (const key of BRIEF_SECTION_KEYS) {
|
|
434
|
+
const v = bso[key];
|
|
435
|
+
if (v === undefined)
|
|
436
|
+
continue;
|
|
437
|
+
if (typeof v !== "string") {
|
|
438
|
+
throw new WriterError(`--input briefSections.${key} must be a string, got ${typeof v}.`);
|
|
439
|
+
}
|
|
440
|
+
sections[key] = v;
|
|
441
|
+
}
|
|
442
|
+
// Only attach when at least one known section was supplied — an empty or
|
|
443
|
+
// unknown-keys-only object stays undefined so the scaffolder's
|
|
444
|
+
// placeholder-vs-concrete branch behaves exactly as the no-brief path.
|
|
445
|
+
if (Object.keys(sections).length > 0) {
|
|
446
|
+
inputs.briefSections = sections;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
351
449
|
return inputs;
|
|
352
450
|
}
|
|
353
451
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero2webmaster/starter-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Dr. Kerry Kriger",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@inquirer/prompts": "^7.0.0",
|
|
44
|
+
"@neondatabase/serverless": "^1.1.0",
|
|
44
45
|
"chalk": "^5.3.0",
|
|
45
46
|
"commander": "^15.0.0",
|
|
46
47
|
"fs-extra": "^11.2.0"
|