create-signet-app 0.7.0 → 0.8.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 CHANGED
@@ -77,7 +77,7 @@ bunx create-signet-app my-app --starter saas --with ai # a starter, plus a
77
77
  | `saas` | account, orgs, admin, notifications, privacy, payments |
78
78
  | `launch` | account, privacy, growth (waitlist, invites, referrals, feedback) |
79
79
  | `internal-tool` | account, orgs, admin, workflows |
80
- | `api` | account, payments; the API half only |
80
+ | `api-billing` | account, payments; the API half only (`--starter api` still works) |
81
81
  | `ai-app` | account, privacy, payments, ai |
82
82
  | `paywall` | account, payments, paywalls |
83
83
  | `automation` | account, notifications, workflows |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-signet-app",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "description": "Scaffold a Vite + React + Tailwind app wired to Signet.",
6
6
  "keywords": [
@@ -38,12 +38,13 @@
38
38
  ],
39
39
  "scripts": {
40
40
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
41
- "test": "bun run test/scaffold.ts && bun run test/scaffold-api.ts && bun run test/scaffold-full.ts && bun run test/scaffold-cli.ts && bun run test/scaffold-extension.ts && bun run test/scaffold-desktop.ts && bun run test/describe.ts",
41
+ "test": "bun run test/scaffold.ts && bun run test/scaffold-api.ts && bun run test/scaffold-full.ts && bun run test/scaffold-cli.ts && bun run test/scaffold-extension.ts && bun run test/scaffold-desktop.ts && bun run test/describe.ts && bun run test/picker.ts",
42
42
  "test:parts": "bun run test/scaffold-parts.ts",
43
43
  "test:pm": "bun run test/scaffold-pm.ts",
44
44
  "test:runtime": "bun run test/scaffold-runtime.ts"
45
45
  },
46
46
  "dependencies": {
47
+ "@clack/prompts": "1.8.1",
47
48
  "@dapplelight/signet-mcp": "^0.1.5"
48
49
  },
49
50
  "devDependencies": {
package/src/compose.ts CHANGED
@@ -118,7 +118,7 @@ export const STARTERS = {
118
118
  description: "for your own team: orgs and roles, the admin panel, approval workflows",
119
119
  parts: ["account", "orgs", "admin", "workflows"],
120
120
  },
121
- api: {
121
+ "api-billing": {
122
122
  description: "the API half only: sign-in, API keys, billing webhooks",
123
123
  parts: ["account", "payments"],
124
124
  surface: "api",
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  import { existsSync } from "node:fs"
14
14
  import { cp, mkdir, readdir, readFile, rename, writeFile } from "node:fs/promises"
15
15
  import { basename, join, resolve } from "node:path"
16
- import { createInterface } from "node:readline/promises"
16
+ import { cancel, confirm, intro, isCancel, outro, select } from "@clack/prompts"
17
17
  import {
18
18
  applyBlocks,
19
19
  type BaseDeps,
@@ -373,7 +373,8 @@ function parseArgs(argv: string[]) {
373
373
  throw new Error("--platform and --template are the same flag; give one.")
374
374
  template = templateGiven = v as Template
375
375
  } else if (a === "--starter") {
376
- const v = args[++i]
376
+ // `api` was api-billing's name until the picker listed it beside the api platform.
377
+ const v = args[++i] === "api" ? "api-billing" : args[i]
377
378
  if (!STARTER_NAMES.includes(v as StarterName)) {
378
379
  throw new Error(`Unknown starter "${v}". Available: ${STARTER_NAMES.join(", ")}`)
379
380
  }
@@ -573,44 +574,56 @@ async function substitute(dir: string, vars: Record<string, string>) {
573
574
  }
574
575
  }
575
576
 
576
- /** "What are you building?": a platform or a starter, by number or name; default web. */
577
- async function askWhat(): Promise<Platform | StarterName> {
578
- const choices = [...PLATFORMS, ...STARTER_NAMES.map((s) => `starter ${s}`)]
579
- const lines = [
580
- ...PLATFORMS.map((p) => p),
581
- ...STARTER_NAMES.map((s) => `${s.padEnd(14)}${STARTERS[s].description}`),
582
- ]
583
- console.log(
584
- `\n What are you building?\n${lines.map((l, i) => ` ${String(i + 1).padStart(3)}. ${l}`).join("\n")}`,
585
- )
586
- const rl = createInterface({ input: process.stdin, output: process.stdout })
587
- try {
588
- for (;;) {
589
- const a = (await rl.question(" Number or name (web): ")).trim().toLowerCase()
590
- if (a === "") return "web"
591
- const n = Number(a)
592
- const pick =
593
- Number.isInteger(n) && n >= 1
594
- ? choices[n - 1]
595
- : choices.find((c) => c === a || c === `starter ${a}`)
596
- if (pick) return pick.replace(/^starter /, "") as Platform | StarterName
597
- console.log(` Not one of these: ${a}`)
598
- }
599
- } finally {
600
- rl.close()
577
+ /** One line each in the picker; cut to the terminal's width when shown. */
578
+ const PLATFORM_HINTS: Record<Platform, string> = {
579
+ web: "Vite + React + Signet UI",
580
+ api: "Hono Worker: error envelope, request ids, rate limiting",
581
+ cli: "Bun CLI compiled to one binary, device-code login",
582
+ extension: "Chrome MV3 extension: popup, options page, service worker",
583
+ desktop: "Tauri v2 desktop + menu-bar app, browser sign-in",
584
+ }
585
+
586
+ /** Ctrl+C at a prompt: say so and leave without scaffolding. */
587
+ function cancelled(): never {
588
+ cancel("Cancelled.")
589
+ process.exit(130)
590
+ }
591
+
592
+ /** A picker row: "platform · web" or "starter · saas", its hint kept to one line. */
593
+ function pickerOption<V extends string>(group: string, value: V, hint: string, width: number) {
594
+ const label = `${group.padEnd(8)} · ${value}`
595
+ // "│ ● " before the label, " (" and ")" around the hint, and the margin
596
+ // clack keeps when it wraps a row.
597
+ const room = width - label.length - 21
598
+ return {
599
+ value,
600
+ label,
601
+ hint: room < 2 ? undefined : hint.length > room ? `${hint.slice(0, room - 1)}…` : hint,
601
602
  }
602
603
  }
603
604
 
605
+ /** "What are you building?": a platform or a starter, by arrow keys; default web. */
606
+ async function askWhat(): Promise<Platform | StarterName> {
607
+ intro("create-signet-app")
608
+ const width = process.stdout.columns || 80
609
+ const what = await select<Platform | StarterName>({
610
+ message: "What are you building?",
611
+ initialValue: "web",
612
+ options: [
613
+ ...PLATFORMS.map((p) => pickerOption("platform", p, PLATFORM_HINTS[p], width)),
614
+ ...STARTER_NAMES.map((s) => pickerOption("starter", s, STARTERS[s].description, width)),
615
+ ],
616
+ })
617
+ if (isCancel(what)) cancelled()
618
+ return what
619
+ }
620
+
604
621
  /** "Add MCP for agents?", default yes; only asked on a terminal. */
605
622
  async function askMcp(): Promise<boolean> {
606
623
  if (!process.stdin.isTTY) return true
607
- const rl = createInterface({ input: process.stdin, output: process.stdout })
608
- try {
609
- const answer = (await rl.question(" Add MCP for agents? (Y/n) ")).trim().toLowerCase()
610
- return answer === "" || answer.startsWith("y")
611
- } finally {
612
- rl.close()
613
- }
624
+ const yes = await confirm({ message: "Add MCP for agents?", initialValue: true })
625
+ if (isCancel(yes)) cancelled()
626
+ return yes
614
627
  }
615
628
 
616
629
  /** A platform's template, its --target files and MCP's overlay, as they always were. */
@@ -717,7 +730,8 @@ async function main() {
717
730
  ;({ theme, template } = described)
718
731
  checkCombo(template, theme, parsed.targetGiven, flags.mcp)
719
732
  }
720
- if (parsed.pick && process.stdin.isTTY) {
733
+ const picking = parsed.pick && process.stdin.isTTY
734
+ if (picking) {
721
735
  const what = await askWhat()
722
736
  if ((PLATFORMS as readonly string[]).includes(what)) template = what as Platform
723
737
  else {
@@ -852,6 +866,8 @@ async function main() {
852
866
  await writeFile(join(dest, "AGENTS.md"), renderAgents(appName, described, runner))
853
867
  }
854
868
  const steps = `cd ${name}\n ${install}\n ${run} dev`
869
+ // Closes the picker's frame; the next steps below are printed as they always were.
870
+ if (picking) outro(`Scaffolded ${appName}.`)
855
871
  console.log(
856
872
  template === "cli"
857
873
  ? `