create-signet-app 0.8.1 → 0.8.3
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/base/web/src/routes/_app.tsx +6 -3
- package/package.json +1 -1
- package/src/index.ts +26 -20
- package/src/picker.ts +18 -0
|
@@ -141,13 +141,16 @@ function AppLayout() {
|
|
|
141
141
|
// !dashboard:begin
|
|
142
142
|
return (
|
|
143
143
|
<>
|
|
144
|
-
|
|
144
|
+
{/* On phones the nav drops to its own row under the name and actions. */}
|
|
145
|
+
<header className="flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-border px-4 py-3 sm:px-6">
|
|
145
146
|
<Link to="/" className="font-medium">
|
|
146
147
|
__APP_NAME__
|
|
147
148
|
</Link>
|
|
148
149
|
{switcher} {/* @orgs */}
|
|
149
|
-
<nav className="flex
|
|
150
|
-
|
|
150
|
+
<nav className="order-last flex w-full flex-wrap items-center gap-1 text-sm sm:order-none sm:w-auto sm:flex-1">
|
|
151
|
+
{nav}
|
|
152
|
+
</nav>
|
|
153
|
+
<div className="ml-auto flex items-center gap-2">{actions}</div>
|
|
151
154
|
</header>
|
|
152
155
|
<main className="mx-auto max-w-3xl p-6">
|
|
153
156
|
<Outlet />
|
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
|
-
|
|
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"
|