@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
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// z2w-starter-kit CLI entry point.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
// confirmation loop; `--wizard` runs the 8-question fallback;
|
|
6
|
-
// bypasses both and reads a JSON `ScaffoldInputs` from stdin
|
|
7
|
-
// path for non-interactive CI / testing use. `--dry-run`
|
|
8
|
-
// + contents to stdout without touching disk.
|
|
9
|
-
// interactive (a) inline / (b) promote-into-
|
|
4
|
+
// `init` command: brief-first input flow + Step 6 writer. The CLI defaults to
|
|
5
|
+
// the brief-paste confirmation loop; `--wizard` runs the 8-question fallback;
|
|
6
|
+
// `--input <src>` bypasses both and reads a JSON `ScaffoldInputs` from stdin
|
|
7
|
+
// (`-`) or a file path for non-interactive CI / testing use. `--dry-run`
|
|
8
|
+
// prints the file list + contents to stdout without touching disk.
|
|
9
|
+
// `--promote-standards` runs the interactive (a) inline / (b) promote-into-
|
|
10
|
+
// Templates dialog before write.
|
|
11
|
+
//
|
|
12
|
+
// `license set|status|refresh|deactivate` subcommands (v0.3.0+): manage the
|
|
13
|
+
// runtime license that gates paid features. See directives/license-check.md.
|
|
14
|
+
//
|
|
15
|
+
// GitHub repo creation (default-ON, private; Track D decision 2026-06-16):
|
|
16
|
+
// after a successful scaffold the CLI runs `git init` + repo-local
|
|
17
|
+
// `user.email` + first commit + `gh repo create {githubOrg}/{slug} --private`
|
|
18
|
+
// + topics + initial push. `--no-repo` opts out. SKIPPED for --dry-run and for
|
|
19
|
+
// the non-interactive --input (CI) path — both only print the would-be
|
|
20
|
+
// commands. Warn-and-proceed: a failed repo setup never fails the scaffold (the
|
|
21
|
+
// files are already written). This is the documented override of Operating
|
|
22
|
+
// Principle #3 for repo creation; every other side-effect stays surfaced-only.
|
|
23
|
+
//
|
|
24
|
+
// `--with-pro-seo` (v0.3.0+, paid feature; nextjs/cf-pages only): layers the
|
|
25
|
+
// Pro SEO baseline extension files on top of the base scaffold. Gated by a
|
|
26
|
+
// runtime license check.
|
|
27
|
+
//
|
|
28
|
+
// Airtable inventory auto-registration (ROADMAP Step 16): after a successful
|
|
29
|
+
// scaffold, when AIRTABLE_WRITE_PAT is set in the environment, create the
|
|
30
|
+
// project's row in Kerry's "Cursor Projects" inventory. Gated entirely on the
|
|
31
|
+
// PAT's presence (no PAT → silent no-op, the case for every normal user) and
|
|
32
|
+
// warn-and-proceed (never blocks the scaffold). `--no-airtable-row` opts out.
|
|
33
|
+
//
|
|
34
|
+
// Neon inventory write (project-inventory migration P3): the inventory is
|
|
35
|
+
// migrating off Airtable onto Neon Postgres. After a scaffold, when
|
|
36
|
+
// Z2W_INVENTORY_DATABASE_URL is set, UPSERT the project's row into the Neon
|
|
37
|
+
// `projects` table — DUAL-WRITE alongside Airtable during the transition (the
|
|
38
|
+
// Airtable write is dropped at P6). Same gate + warn-and-proceed posture as the
|
|
39
|
+
// Airtable path; no URL → silent no-op. `--no-inventory-row` opts out.
|
|
10
40
|
import { Command } from "commander";
|
|
11
41
|
import { input as inquirerInput } from "@inquirer/prompts";
|
|
42
|
+
import { registerProjectRow } from "./airtable.js";
|
|
43
|
+
import { registerProjectRowNeon } from "./inventory.js";
|
|
12
44
|
import { gatherBrief } from "./brief.js";
|
|
13
|
-
import { confirmInputs } from "./confirm.js";
|
|
14
|
-
import {
|
|
45
|
+
import { confirmInputs, ConfirmCancelledError } from "./confirm.js";
|
|
46
|
+
import { activateLicense, checkLicense, clearLicenseState, deactivateLicense, evaluateLicense, isValidLicenseKey, LicenseError, loadLicenseState, maskKey, runtimeLicenseCheck, } from "./license.js";
|
|
47
|
+
import { expandHome, parseBrief } from "./parse-brief.js";
|
|
48
|
+
import { runWithInit, WithInitError } from "./with-init.js";
|
|
15
49
|
import { runWizard } from "./wizard.js";
|
|
16
50
|
import { version } from "./index.js";
|
|
17
51
|
import { renderSummary } from "./summary.js";
|
|
@@ -29,20 +63,130 @@ async function gatherInputs(flags) {
|
|
|
29
63
|
return runWizard({ prompter: inquirerPrompter });
|
|
30
64
|
}
|
|
31
65
|
const parsed = parseBrief(brief);
|
|
32
|
-
|
|
66
|
+
// Fail LOUD, not silent: a pasted brief whose headings match none of the
|
|
67
|
+
// recognized planning sections produces a placeholder ROADMAP.md + a
|
|
68
|
+
// placeholder README overview. Before 2026-06-28 that happened with zero
|
|
69
|
+
// warning (the backup-engine silent-miss). Surface it so the user can rename
|
|
70
|
+
// a heading or accept the placeholders knowingly.
|
|
71
|
+
if (parsed.briefSections === undefined) {
|
|
72
|
+
process.stderr.write("\n⚠️ No planning sections detected in your brief — ROADMAP.md and the " +
|
|
73
|
+
"README overview will be placeholders.\n" +
|
|
74
|
+
" I look for headings about: Purpose / Key APIs / Data sources / " +
|
|
75
|
+
"Expected outputs / Edge cases / Roadmap (or Phasing) / Future improvements.\n" +
|
|
76
|
+
" The full brief is still saved verbatim to directives/PROJECT_BRIEF.md.\n\n");
|
|
77
|
+
}
|
|
78
|
+
// Pre-fill the target path from the --target-path flag so the confirm
|
|
79
|
+
// screen shows it as set (and editable) rather than [unset] — the
|
|
80
|
+
// 2026-06-03 dogfood finding #4, where the flag was honored at write time
|
|
81
|
+
// but ignored by the confirm screen.
|
|
82
|
+
if (flags.targetPath) {
|
|
83
|
+
parsed.targetPath = expandHome(flags.targetPath);
|
|
84
|
+
}
|
|
85
|
+
const inputs = await confirmInputs(parsed, { prompter: inquirerPrompter });
|
|
86
|
+
// Capture the verbatim pasted brief as the project's instantiation prompt so
|
|
87
|
+
// the Airtable inventory write records it (Kerry's standing rule: every
|
|
88
|
+
// inventory row carries its Project Instantiation Prompt).
|
|
89
|
+
inputs.instantiationPrompt = brief;
|
|
90
|
+
return inputs;
|
|
91
|
+
}
|
|
92
|
+
async function gatePaidFeatures(flags, stderr = process.stderr) {
|
|
93
|
+
if (!flags.withProSeo)
|
|
94
|
+
return;
|
|
95
|
+
const evaluation = await runtimeLicenseCheck();
|
|
96
|
+
if (evaluation.allowPaidFeatures) {
|
|
97
|
+
if (evaluation.warning) {
|
|
98
|
+
stderr.write(`\nlicense: ${evaluation.warning}\n`);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const reason = evaluation.warning ?? "Paid features are not currently allowed.";
|
|
103
|
+
throw new LicenseError(reason);
|
|
33
104
|
}
|
|
34
105
|
async function runInit(flags) {
|
|
106
|
+
await gatePaidFeatures(flags);
|
|
35
107
|
const inputs = await gatherInputs(flags);
|
|
36
|
-
const targetPath = flags.targetPath
|
|
108
|
+
const targetPath = flags.targetPath
|
|
109
|
+
? expandHome(flags.targetPath)
|
|
110
|
+
: inputs.targetPath;
|
|
37
111
|
const result = await writeScaffold(inputs, targetPath, {
|
|
38
112
|
dryRun: flags.dryRun === true,
|
|
113
|
+
showContents: flags.showContents === true,
|
|
39
114
|
refuseNonEmpty: flags.refuseNonEmpty !== false,
|
|
40
115
|
templatesPath: flags.templatesPath,
|
|
41
|
-
refreshTemplates: flags.refreshTemplates === true,
|
|
42
116
|
promoteStandards: flags.promoteStandards === true,
|
|
43
117
|
prompter: flags.promoteStandards ? inquirerPrompter : undefined,
|
|
118
|
+
withProSeo: flags.withProSeo === true,
|
|
44
119
|
});
|
|
45
|
-
|
|
120
|
+
// GitHub repo creation is a DEFAULT side-effect for the interactive flows
|
|
121
|
+
// (Track D decision 2026-06-16). It is skipped — and only the would-be
|
|
122
|
+
// commands are surfaced — for --dry-run (nothing written) and for the
|
|
123
|
+
// non-interactive --input/CI path (auto-creating a repo from CI would be
|
|
124
|
+
// surprising and dangerous). `--no-repo` opts out explicitly.
|
|
125
|
+
const createRepo = flags.dryRun !== true && flags.input === undefined && flags.repo !== false;
|
|
126
|
+
renderSummary(inputs, result, {
|
|
127
|
+
noColor: flags.noColor === true,
|
|
128
|
+
repoAutoCreated: createRepo,
|
|
129
|
+
});
|
|
130
|
+
if (createRepo) {
|
|
131
|
+
// Warn-and-proceed: the files are already written, so a failed repo setup
|
|
132
|
+
// must not fail the scaffold. Surface the manual fallback commands instead.
|
|
133
|
+
try {
|
|
134
|
+
await runWithInit(inputs, targetPath, {
|
|
135
|
+
stdout: process.stdout,
|
|
136
|
+
stderr: process.stderr,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
const detail = err instanceof WithInitError ? err.message : err.message;
|
|
141
|
+
process.stderr.write(`\nwarning: automatic GitHub repo setup did not complete (${detail}).\n` +
|
|
142
|
+
" Your files are written and intact. To finish manually:\n" +
|
|
143
|
+
` cd ${targetPath} && git init -b main && git config user.email "kerry@zero2webmaster.com" && git add . && git commit -m "Initial scaffold"\n` +
|
|
144
|
+
` gh repo create ${inputs.githubOrg}/${inputs.slug} --private --source=. --push\n`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (flags.dryRun === true) {
|
|
148
|
+
process.stdout.write("\n(repo creation skipped in --dry-run mode; would run git init + commit + gh repo create --private --push)\n");
|
|
149
|
+
}
|
|
150
|
+
else if (flags.input !== undefined) {
|
|
151
|
+
process.stdout.write("\n(repo creation skipped for the non-interactive --input path; run the git/gh commands under Next actions to create the repo)\n");
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// --no-repo
|
|
155
|
+
process.stdout.write("\n(--no-repo: automatic GitHub repo creation skipped; the git/gh commands are under Next actions above)\n");
|
|
156
|
+
}
|
|
157
|
+
// Airtable inventory auto-registration (ROADMAP Step 16). No-op unless
|
|
158
|
+
// AIRTABLE_WRITE_PAT is set (so it never fires for normal users) and never
|
|
159
|
+
// blocks the scaffold — warn-and-proceed. `--no-airtable-row` opts out.
|
|
160
|
+
if (flags.airtableRow !== false) {
|
|
161
|
+
const reg = await registerProjectRow(inputs, {
|
|
162
|
+
dryRun: flags.dryRun === true,
|
|
163
|
+
// Verify the coordination block on disk before asserting Registered.
|
|
164
|
+
targetPath,
|
|
165
|
+
});
|
|
166
|
+
if (reg.outcome === "failed") {
|
|
167
|
+
process.stderr.write(`\n${reg.message}\n`);
|
|
168
|
+
}
|
|
169
|
+
else if (reg.outcome !== "skipped") {
|
|
170
|
+
process.stdout.write(`\n${reg.message}\n`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Neon inventory write (project-inventory migration P3 — DUAL-WRITE alongside
|
|
174
|
+
// Airtable during the transition; Airtable is dropped at P6). No-op unless
|
|
175
|
+
// Z2W_INVENTORY_DATABASE_URL is set (so it never fires for normal users) and
|
|
176
|
+
// never blocks the scaffold — warn-and-proceed. `--no-inventory-row` opts out.
|
|
177
|
+
if (flags.inventoryRow !== false) {
|
|
178
|
+
const reg = await registerProjectRowNeon(inputs, {
|
|
179
|
+
dryRun: flags.dryRun === true,
|
|
180
|
+
// Verify the coordination block on disk before asserting Registered.
|
|
181
|
+
targetPath,
|
|
182
|
+
});
|
|
183
|
+
if (reg.outcome === "failed") {
|
|
184
|
+
process.stderr.write(`\n${reg.message}\n`);
|
|
185
|
+
}
|
|
186
|
+
else if (reg.outcome !== "skipped") {
|
|
187
|
+
process.stdout.write(`\n${reg.message}\n`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
46
190
|
}
|
|
47
191
|
const program = new Command();
|
|
48
192
|
program
|
|
@@ -53,32 +197,161 @@ program
|
|
|
53
197
|
.command("init")
|
|
54
198
|
.description("Scaffold a new project (brief-first; --wizard for fallback; --input for non-interactive)")
|
|
55
199
|
.option("--wizard", "skip the brief prompt and run the 8-question wizard")
|
|
56
|
-
.option("--dry-run", "print the file list
|
|
200
|
+
.option("--dry-run", "print the file list (with byte sizes) without writing to disk")
|
|
201
|
+
.option("--show-contents", "in --dry-run mode, also print every file's full content")
|
|
57
202
|
.option("--input <source>", "load ScaffoldInputs JSON from a file path, or '-' for stdin (bypasses brief/wizard)")
|
|
58
203
|
.option("--target-path <path>", "absolute path to scaffold into (defaults to inputs.targetPath)")
|
|
59
|
-
.option("--templates-path <path>", "absolute path to the Templates folder (default: ~/Desktop/Zero2Webmaster/AI/Templates
|
|
60
|
-
.option("--refresh-templates", "force-refresh the local Templates cache (~/.cache/z2w-templates/) from the mirror")
|
|
204
|
+
.option("--templates-path <path>", "absolute path to the Templates folder (default: ~/Desktop/Zero2Webmaster/AI/Templates)")
|
|
61
205
|
.option("--promote-standards", "run the (a) inline / (b) promote-into-Templates dialog per applicable standard")
|
|
62
206
|
.option("--allow-non-empty", "allow writes into a non-empty target directory (default: refuse)")
|
|
63
207
|
.option("--no-color", "disable colored output (default: auto-detect TTY)")
|
|
208
|
+
.option("--no-repo", "skip the default creation of the private GitHub repo (git init + first commit + `gh repo create {githubOrg}/{slug} --private` + push)")
|
|
209
|
+
.option("--with-pro-seo", "(paid; nextjs/cf-pages) layer the Pro SEO baseline extension on top of the base scaffold")
|
|
210
|
+
.option("--no-airtable-row", "skip Airtable inventory auto-registration (only fires when AIRTABLE_WRITE_PAT is set; internal)")
|
|
211
|
+
.option("--no-inventory-row", "skip the Neon inventory write (only fires when Z2W_INVENTORY_DATABASE_URL is set; internal)")
|
|
64
212
|
.action(async (opts) => {
|
|
65
213
|
try {
|
|
66
214
|
await runInit({
|
|
67
215
|
wizard: opts["wizard"] === true,
|
|
68
216
|
dryRun: opts["dryRun"] === true,
|
|
217
|
+
showContents: opts["showContents"] === true,
|
|
69
218
|
input: typeof opts["input"] === "string" ? opts["input"] : undefined,
|
|
70
219
|
targetPath: typeof opts["targetPath"] === "string" ? opts["targetPath"] : undefined,
|
|
71
220
|
templatesPath: typeof opts["templatesPath"] === "string" ? opts["templatesPath"] : undefined,
|
|
72
|
-
refreshTemplates: opts["refreshTemplates"] === true,
|
|
73
221
|
promoteStandards: opts["promoteStandards"] === true,
|
|
74
222
|
refuseNonEmpty: opts["allowNonEmpty"] !== true,
|
|
75
223
|
noColor: opts["color"] === false,
|
|
224
|
+
repo: opts["repo"] !== false,
|
|
225
|
+
withProSeo: opts["withProSeo"] === true,
|
|
226
|
+
airtableRow: opts["airtableRow"] !== false,
|
|
227
|
+
inventoryRow: opts["inventoryRow"] !== false,
|
|
76
228
|
});
|
|
77
229
|
}
|
|
78
230
|
catch (err) {
|
|
79
|
-
|
|
231
|
+
if (err instanceof ConfirmCancelledError) {
|
|
232
|
+
// User-initiated exit, not a failure. Exit 130 to mirror Ctrl+C
|
|
233
|
+
// (SIGINT) semantics — no "error:" prefix, no files written.
|
|
234
|
+
process.stderr.write("\nCancelled — no files were written.\n");
|
|
235
|
+
process.exit(130);
|
|
236
|
+
}
|
|
237
|
+
const message = err instanceof WriterError || err instanceof LicenseError || err instanceof WithInitError
|
|
238
|
+
? err.message
|
|
239
|
+
: err.message;
|
|
240
|
+
process.stderr.write(`\nerror: ${message}\n`);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
const licenseCommand = program
|
|
245
|
+
.command("license")
|
|
246
|
+
.description("Manage the runtime license that gates paid features (see directives/license-check.md)");
|
|
247
|
+
licenseCommand
|
|
248
|
+
.command("set <key>")
|
|
249
|
+
.description("Activate this machine against the supplied license key")
|
|
250
|
+
.action(async (key) => {
|
|
251
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
252
|
+
process.stderr.write("\nerror: license key is required\n");
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
if (!isValidLicenseKey(key)) {
|
|
256
|
+
process.stderr.write(`\nerror: license key "${key}" does not match the expected format ` +
|
|
257
|
+
`(Z2W-XXXX-XXXX-XXXX-XXXX...). Double-check the key in your FluentCRM ` +
|
|
258
|
+
"welcome email.\n");
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
const { state, status } = await activateLicense(key);
|
|
263
|
+
process.stdout.write(`\nLicense activated.\n` +
|
|
264
|
+
` key: ${maskKey(state.key)}\n` +
|
|
265
|
+
` product: ${state.productSlug}\n` +
|
|
266
|
+
` machine ID: ${state.machineId}\n` +
|
|
267
|
+
` status: ${status}${state.cachedExpiresAt ? ` (expires ${state.cachedExpiresAt})` : ""}\n`);
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const message = err instanceof LicenseError ? err.message : err.message;
|
|
80
271
|
process.stderr.write(`\nerror: ${message}\n`);
|
|
81
272
|
process.exit(1);
|
|
82
273
|
}
|
|
83
274
|
});
|
|
275
|
+
licenseCommand
|
|
276
|
+
.command("status")
|
|
277
|
+
.description("Print the current license state (no network call)")
|
|
278
|
+
.action(async () => {
|
|
279
|
+
const state = await loadLicenseState();
|
|
280
|
+
if (state === null) {
|
|
281
|
+
process.stdout.write("\nNo license configured.\n" +
|
|
282
|
+
"Run `z2w-starter-kit license set <key>` to activate, or purchase a license at\n" +
|
|
283
|
+
"https://zero2webmaster.com.\n");
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const evaluation = evaluateLicense(state);
|
|
287
|
+
process.stdout.write(`\nLicense status:\n` +
|
|
288
|
+
` key: ${maskKey(state.key)}\n` +
|
|
289
|
+
` product: ${state.productSlug}\n` +
|
|
290
|
+
` machine ID: ${state.machineId}\n` +
|
|
291
|
+
` cached status: ${state.cachedStatus ?? "(unknown)"}\n` +
|
|
292
|
+
` expires at: ${state.cachedExpiresAt ?? "(unknown)"}\n` +
|
|
293
|
+
` last successful: ${state.lastSuccessfulCheck ?? "(never)"}\n` +
|
|
294
|
+
` last attempt: ${state.lastCheckAttempt ?? "(never)"}\n` +
|
|
295
|
+
` days since last: ${evaluation.daysSinceLastCheck ?? "(n/a)"}\n` +
|
|
296
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed" : "DECLINED"}\n` +
|
|
297
|
+
` templates updates: ${evaluation.allowTemplatesUpdates ? "allowed" : "declined"}\n` +
|
|
298
|
+
` reason: ${evaluation.reason}\n` +
|
|
299
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : "") +
|
|
300
|
+
(state.retryAfter ? ` retry-after: ${state.retryAfter}\n` : ""));
|
|
301
|
+
});
|
|
302
|
+
licenseCommand
|
|
303
|
+
.command("refresh")
|
|
304
|
+
.description("Force a re-check against zero2webmaster.com (bypasses the 24h local cache)")
|
|
305
|
+
.action(async () => {
|
|
306
|
+
const existing = await loadLicenseState();
|
|
307
|
+
if (existing === null) {
|
|
308
|
+
process.stderr.write("\nNo license configured. Run `z2w-starter-kit license set <key>` first.\n");
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
const result = await checkLicense();
|
|
313
|
+
const evaluation = evaluateLicense(result.state);
|
|
314
|
+
if (result.networkOk) {
|
|
315
|
+
process.stdout.write(`\nLicense refresh succeeded.\n` +
|
|
316
|
+
` status: ${result.status}\n` +
|
|
317
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed" : "DECLINED"}\n` +
|
|
318
|
+
` templates: ${evaluation.allowTemplatesUpdates ? "allowed" : "declined"}\n` +
|
|
319
|
+
` reason: ${evaluation.reason}\n` +
|
|
320
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : ""));
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
process.stderr.write(`\nLicense refresh failed.\n` +
|
|
324
|
+
` message: ${result.message ?? "(no detail)"}\n` +
|
|
325
|
+
` cached status: ${result.status ?? "(unknown)"}\n` +
|
|
326
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed (within grace window)" : "DECLINED"}\n` +
|
|
327
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : ""));
|
|
328
|
+
if (!evaluation.allowPaidFeatures) {
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
const message = err instanceof LicenseError ? err.message : err.message;
|
|
334
|
+
process.stderr.write(`\nerror: ${message}\n`);
|
|
335
|
+
process.exit(1);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
licenseCommand
|
|
339
|
+
.command("deactivate")
|
|
340
|
+
.description("Deactivate this machine and clear the local license file")
|
|
341
|
+
.action(async () => {
|
|
342
|
+
try {
|
|
343
|
+
await deactivateLicense();
|
|
344
|
+
process.stdout.write("\nLicense deactivated and local state cleared.\n");
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
if (err instanceof LicenseError) {
|
|
348
|
+
process.stderr.write(`\n${err.message}\n`);
|
|
349
|
+
// Best-effort clear in case state exists but server call failed mysteriously.
|
|
350
|
+
await clearLicenseState();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
process.stderr.write(`\nerror: ${err.message}\n`);
|
|
354
|
+
process.exit(1);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
84
357
|
program.parseAsync(process.argv);
|
package/dist/confirm.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { ParsedBrief } from "./parse-brief.js";
|
|
2
2
|
import type { BrandPreset, CustomBrandInputs, DbStrategy, ProjectType, ScaffoldInputs } from "./index.js";
|
|
3
|
+
import { BRANDS, DB_STRATEGIES, PROJECT_TYPES } from "./index.js";
|
|
3
4
|
export type Prompter = (message: string, defaultValue?: string) => Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
7
|
+
* `q`) at the confirmation prompt. Before v0.2.1 the only escape from the
|
|
8
|
+
* confirm loop was Ctrl+C (the 2026-06-03 dogfood finding #3). The CLI catches
|
|
9
|
+
* this and exits cleanly without writing any files.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ConfirmCancelledError extends Error {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
14
|
+
/** Exit keywords accepted at the confirmation prompt (case-insensitive). */
|
|
15
|
+
export declare const CONFIRM_CANCEL_KEYWORDS: readonly ["cancel", "abort", "quit", "q"];
|
|
4
16
|
export interface ConfirmOptions {
|
|
5
17
|
prompter: Prompter;
|
|
6
18
|
output?: NodeJS.WritableStream;
|
|
7
19
|
/** Skips on-disk checks for the target path; tests set this to true. */
|
|
8
20
|
skipFsChecks?: boolean;
|
|
9
21
|
}
|
|
10
|
-
export
|
|
11
|
-
export declare const BRANDS: readonly BrandPreset[];
|
|
12
|
-
export declare const DB_STRATEGIES: readonly DbStrategy[];
|
|
22
|
+
export { BRANDS, DB_STRATEGIES, PROJECT_TYPES };
|
|
13
23
|
export declare const UNSET_PLACEHOLDER = "[unset \u2014 please type]";
|
|
14
24
|
type ParseResult<T> = {
|
|
15
25
|
ok: true;
|
|
@@ -29,6 +39,9 @@ interface Draft {
|
|
|
29
39
|
hasWebUi: boolean | null;
|
|
30
40
|
hasCron: boolean | null;
|
|
31
41
|
participateInBulletin: boolean | null;
|
|
42
|
+
sendsEmail: boolean;
|
|
43
|
+
hasUserContent: boolean;
|
|
44
|
+
hasObservability: boolean;
|
|
32
45
|
customBrand: CustomBrandInputs | null;
|
|
33
46
|
}
|
|
34
47
|
export declare function renderDraft(draft: Draft): string;
|
|
@@ -41,4 +54,3 @@ export declare function parseSlug(raw: string): ParseResult<string>;
|
|
|
41
54
|
* refuses to accept while any field is still `[unset — please type]`.
|
|
42
55
|
*/
|
|
43
56
|
export declare function confirmInputs(parsed: ParsedBrief, opts: ConfirmOptions): Promise<ScaffoldInputs>;
|
|
44
|
-
export {};
|
package/dist/confirm.js
CHANGED
|
@@ -8,31 +8,27 @@
|
|
|
8
8
|
// wires it to @inquirer/prompts' input() in src/cli.ts.
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { promises as fs } from "node:fs";
|
|
11
|
-
import { githubOrgForBrand, isValidSlug, kebabCase, } from "./parse-brief.js";
|
|
11
|
+
import { expandHome, githubOrgForBrand, isValidSlug, kebabCase, } from "./parse-brief.js";
|
|
12
12
|
import { isHexColor } from "./brand.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"sqlite",
|
|
33
|
-
"mysql-wp",
|
|
34
|
-
"other",
|
|
35
|
-
];
|
|
13
|
+
import { BRANDS, DB_STRATEGIES, PROJECT_TYPES } from "./index.js";
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
16
|
+
* `q`) at the confirmation prompt. Before v0.2.1 the only escape from the
|
|
17
|
+
* confirm loop was Ctrl+C (the 2026-06-03 dogfood finding #3). The CLI catches
|
|
18
|
+
* this and exits cleanly without writing any files.
|
|
19
|
+
*/
|
|
20
|
+
export class ConfirmCancelledError extends Error {
|
|
21
|
+
constructor(message = "Cancelled at the confirmation screen.") {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "ConfirmCancelledError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Exit keywords accepted at the confirmation prompt (case-insensitive). */
|
|
27
|
+
export const CONFIRM_CANCEL_KEYWORDS = ["cancel", "abort", "quit", "q"];
|
|
28
|
+
// The canonical enum value-arrays now live in index.ts (next to the type
|
|
29
|
+
// unions they enumerate); re-exported here so the confirm/wizard flows and
|
|
30
|
+
// their tests keep importing them from confirm unchanged.
|
|
31
|
+
export { BRANDS, DB_STRATEGIES, PROJECT_TYPES };
|
|
36
32
|
export const UNSET_PLACEHOLDER = "[unset — please type]";
|
|
37
33
|
function fmt(value) {
|
|
38
34
|
if (value === null || value === undefined)
|
|
@@ -58,7 +54,7 @@ export function renderDraft(draft) {
|
|
|
58
54
|
const cb = draft.customBrand;
|
|
59
55
|
lines.push(` 4a. Brand name ................ ${fmtCustom(cb?.brandName)}`, ` 4b. Capitalization rule ....... ${fmtCustom(cb?.brandNameRule)}`, ` 4c. Primary hex color ......... ${fmtCustom(cb?.primaryColor)}`, ` 4d. Accent hex color .......... ${fmtCustom(cb?.accentColor)}`);
|
|
60
56
|
}
|
|
61
|
-
lines.push(` 5. GitHub org ..................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`);
|
|
57
|
+
lines.push(` 5. GitHub org ..................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`, ` 11. Sends transactional/auth email . ${fmt(draft.sendsEmail)}`, ` 12. Accepts user-generated content ${fmt(draft.hasUserContent)}`, ` 13. Wire Sentry error tracking ..... ${fmt(draft.hasObservability)}`);
|
|
62
58
|
return lines.join("\n");
|
|
63
59
|
}
|
|
64
60
|
export function parseSlug(raw) {
|
|
@@ -96,11 +92,11 @@ function parseBoolean(raw, label) {
|
|
|
96
92
|
};
|
|
97
93
|
}
|
|
98
94
|
async function parseTargetPath(raw, skipFsChecks) {
|
|
99
|
-
const trimmed = raw.trim();
|
|
95
|
+
const trimmed = expandHome(raw.trim());
|
|
100
96
|
if (!path.isAbsolute(trimmed)) {
|
|
101
97
|
return {
|
|
102
98
|
ok: false,
|
|
103
|
-
error: `Target path must be absolute (start with /). Got: "${trimmed}".`,
|
|
99
|
+
error: `Target path must be absolute (start with / or ~). Got: "${trimmed}".`,
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
102
|
if (skipFsChecks)
|
|
@@ -308,8 +304,32 @@ async function editField(draft, fieldNumber, opts) {
|
|
|
308
304
|
draft.participateInBulletin = result.value;
|
|
309
305
|
return null;
|
|
310
306
|
}
|
|
307
|
+
case 11: {
|
|
308
|
+
const raw = await opts.prompter("Sends transactional / auth email (yes/no):", draft.sendsEmail ? "yes" : "no");
|
|
309
|
+
const result = parseBoolean(raw, "Sends transactional / auth email");
|
|
310
|
+
if (!result.ok)
|
|
311
|
+
return result.error;
|
|
312
|
+
draft.sendsEmail = result.value;
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
case 12: {
|
|
316
|
+
const raw = await opts.prompter("Accepts user-generated content (yes/no):", draft.hasUserContent ? "yes" : "no");
|
|
317
|
+
const result = parseBoolean(raw, "Accepts user-generated content");
|
|
318
|
+
if (!result.ok)
|
|
319
|
+
return result.error;
|
|
320
|
+
draft.hasUserContent = result.value;
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
case 13: {
|
|
324
|
+
const raw = await opts.prompter("Wire Sentry runtime-error tracking (yes/no):", draft.hasObservability ? "yes" : "no");
|
|
325
|
+
const result = parseBoolean(raw, "Wire Sentry runtime-error tracking");
|
|
326
|
+
if (!result.ok)
|
|
327
|
+
return result.error;
|
|
328
|
+
draft.hasObservability = result.value;
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
311
331
|
default:
|
|
312
|
-
return `Field number must be between 1 and
|
|
332
|
+
return `Field number must be between 1 and 13. Got: ${fieldNumber}.`;
|
|
313
333
|
}
|
|
314
334
|
}
|
|
315
335
|
/**
|
|
@@ -332,15 +352,21 @@ export async function confirmInputs(parsed, opts) {
|
|
|
332
352
|
hasWebUi: parsed.hasWebUi,
|
|
333
353
|
hasCron: parsed.hasCron,
|
|
334
354
|
participateInBulletin: parsed.participateInBulletin,
|
|
355
|
+
sendsEmail: parsed.sendsEmail,
|
|
356
|
+
hasUserContent: parsed.hasUserContent,
|
|
357
|
+
hasObservability: parsed.hasObservability,
|
|
335
358
|
customBrand: null,
|
|
336
359
|
};
|
|
337
360
|
while (true) {
|
|
338
361
|
output.write(`\nInferred inputs from your brief:\n\n${renderDraft(draft)}\n\n`);
|
|
339
362
|
const complete = isComplete(draft);
|
|
340
363
|
const prompt = complete
|
|
341
|
-
? "Press Enter to accept,
|
|
342
|
-
: "Type a line number (1-
|
|
364
|
+
? "Press Enter to accept, a line number (1-13) to edit, or 'cancel' to exit (Ctrl+C also works):"
|
|
365
|
+
: "Type a line number (1-13) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
|
|
343
366
|
const reply = (await opts.prompter(prompt)).trim();
|
|
367
|
+
if (CONFIRM_CANCEL_KEYWORDS.includes(reply.toLowerCase())) {
|
|
368
|
+
throw new ConfirmCancelledError();
|
|
369
|
+
}
|
|
344
370
|
if (reply.length === 0) {
|
|
345
371
|
if (complete)
|
|
346
372
|
break;
|
|
@@ -353,8 +379,8 @@ export async function confirmInputs(parsed, opts) {
|
|
|
353
379
|
continue;
|
|
354
380
|
}
|
|
355
381
|
const fieldNumber = Number(reply);
|
|
356
|
-
if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber >
|
|
357
|
-
output.write(`\n ✗ "${reply}" is not a line number (1-
|
|
382
|
+
if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 13) {
|
|
383
|
+
output.write(`\n ✗ "${reply}" is not a line number (1-13).\n`);
|
|
358
384
|
continue;
|
|
359
385
|
}
|
|
360
386
|
const error = await editField(draft, fieldNumber, opts);
|
|
@@ -373,9 +399,17 @@ export async function confirmInputs(parsed, opts) {
|
|
|
373
399
|
hasWebUi: draft.hasWebUi,
|
|
374
400
|
hasCron: draft.hasCron,
|
|
375
401
|
participateInBulletin: draft.participateInBulletin,
|
|
402
|
+
sendsEmail: draft.sendsEmail,
|
|
403
|
+
hasUserContent: draft.hasUserContent,
|
|
404
|
+
hasObservability: draft.hasObservability,
|
|
376
405
|
};
|
|
377
406
|
if (draft.brand === "custom" && draft.customBrand !== null) {
|
|
378
407
|
result.customBrand = draft.customBrand;
|
|
379
408
|
}
|
|
409
|
+
// Brief planning sections aren't user-editable on the confirm screen; carry
|
|
410
|
+
// them straight through so they flow into ROADMAP.md + README.md downstream.
|
|
411
|
+
if (parsed.briefSections !== undefined) {
|
|
412
|
+
result.briefSections = parsed.briefSections;
|
|
413
|
+
}
|
|
380
414
|
return result;
|
|
381
415
|
}
|