create-signet-app 0.8.1 → 0.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-signet-app",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "license": "MIT",
5
5
  "description": "Scaffold a Vite + React + Tailwind app wired to Signet.",
6
6
  "keywords": [
package/src/index.ts CHANGED
@@ -39,8 +39,11 @@ import {
39
39
  } from "./compose.js"
40
40
  import { appId, DESKTOP_PKG } from "./desktop.js"
41
41
  import {
42
+ answer,
42
43
  choose,
43
44
  command,
45
+ hasApi,
46
+ hasUi,
44
47
  type Mix,
45
48
  mixRows,
46
49
  nameError,
@@ -532,7 +535,10 @@ Examples:
532
535
  describe: { sentence: describe, template: templateGiven, theme: themeGiven },
533
536
  }
534
537
  }
535
- checkCombo(template, theme, target, mcp, composeFlags)
538
+ // Nothing said what to build: asked on a terminal, else the web platform.
539
+ const pick = !templateGiven && !composing
540
+ // When the picker will run, --mcp / --no-mcp is checked against what it picks (main).
541
+ checkCombo(template, theme, target, pick && process.stdin.isTTY ? undefined : mcp, composeFlags)
536
542
  return {
537
543
  name,
538
544
  theme,
@@ -543,8 +549,7 @@ Examples:
543
549
  pm: pm ?? detectPm(),
544
550
  composeFlags,
545
551
  themeGiven,
546
- // Nothing said what to build: asked on a terminal, else the web platform.
547
- pick: !templateGiven && !composing,
552
+ pick,
548
553
  }
549
554
  }
550
555
 
@@ -629,7 +634,7 @@ async function askName(): Promise<string> {
629
634
  * its features (ticked, to adjust); the theme where there is a web UI; MCP
630
635
  * where there is an API. Rows and the mapping to flags are in src/picker.ts.
631
636
  */
632
- async function askWhat(themeGiven?: Theme) {
637
+ async function askWhat(themeGiven?: Theme, mcpGiven?: boolean) {
633
638
  const what = ask(
634
639
  await select<Platform>({
635
640
  message: "What are you building?",
@@ -653,20 +658,18 @@ async function askWhat(themeGiven?: Theme) {
653
658
  )
654
659
  choice = choose(what, mix, ticks)
655
660
  }
656
- // A web app's every answer has a web UI; an API's and a CLI's none.
657
- const ui = what !== "api" && what !== "cli"
658
- const theme =
659
- ui && !themeGiven
660
- ? ask(
661
- await select<Theme>({
662
- message: "Theme",
663
- initialValue: "editorial",
664
- options: THEMES.map((t) => ({ value: t, label: THEME_LABELS[t] ?? t })),
665
- }),
666
- )
667
- : themeGiven
668
- const mcp = choice.template === "api" || choice.template === "full" ? await askMcp() : undefined
669
- return { what, choice, ticks, theme: ui ? theme : undefined, mcp }
661
+ // A flag that already answered a question keeps its value; it is not asked.
662
+ const theme = await answer(hasUi(what), themeGiven, async () =>
663
+ ask(
664
+ await select<Theme>({
665
+ message: "Theme",
666
+ initialValue: "editorial",
667
+ options: THEMES.map((t) => ({ value: t, label: THEME_LABELS[t] ?? t })),
668
+ }),
669
+ ),
670
+ )
671
+ const mcp = await answer(hasApi(choice), mcpGiven, askMcp)
672
+ return { what, choice, ticks, theme, mcp }
670
673
  }
671
674
 
672
675
  /** "Let AI coding agents work with this app?", default yes; only asked on a terminal. */
@@ -790,14 +793,17 @@ async function main() {
790
793
  }
791
794
  const picking = parsed.pick && process.stdin.isTTY
792
795
  if (picking) {
793
- const { what, choice, ticks, theme: picked, mcp } = await askWhat(parsed.themeGiven)
796
+ const { what, choice, ticks, theme: picked, mcp } = await askWhat(parsed.themeGiven, flags.mcp)
794
797
  template = choice.template
795
798
  const c = parsed.composeFlags
796
799
  c.starter = choice.starter
797
800
  c.api = choice.api ?? false
798
801
  c.with = choice.with ?? []
799
802
  if (picked) theme = picked
800
- flags.mcp = mcp
803
+ // Set only when the picker asked (or kept the flag); a flag is never cleared.
804
+ if (mcp !== undefined) flags.mcp = mcp
805
+ // The flags' combinations, checked now that the platform is known (parseArgs left MCP to here).
806
+ checkCombo(template, theme, parsed.targetGiven, flags.mcp, c)
801
807
  const runner = `${pm === "bun" ? "bunx" : "npx"} create-signet-app`
802
808
  note(
803
809
  [
package/src/picker.ts CHANGED
@@ -162,6 +162,24 @@ export function summary(
162
162
  ]
163
163
  }
164
164
 
165
+ /**
166
+ * A question the picker asks only where it applies and only when no flag
167
+ * answered it: the flag's value is kept, never overwritten. Undefined where
168
+ * it does not apply (a flag given there is left for checkCombo to refuse).
169
+ */
170
+ export async function answer<T>(
171
+ applies: boolean,
172
+ given: T | undefined,
173
+ ask: () => Promise<T>,
174
+ ): Promise<T | undefined> {
175
+ if (!applies) return undefined
176
+ return given ?? ask()
177
+ }
178
+
179
+ /** MCP applies where there is an API; the theme where there is a web UI. */
180
+ export const hasApi = (c: Choice) => c.template === "api" || c.template === "full"
181
+ export const hasUi = (what: Platform) => what !== "api" && what !== "cli"
182
+
165
183
  /** Why a typed project name can't be used, or undefined; empty is the default, my-app. */
166
184
  export function nameError(typed: string | undefined, cwd: string): string | undefined {
167
185
  const name = typed?.trim() || "my-app"