create-signet-app 0.4.8 → 0.6.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 +133 -33
- package/{template-full → base/api}/api/app.ts +105 -13
- package/base/api/api/db/open.ts +121 -0
- package/{template-full → base/api}/api/db/schema.ts +34 -7
- package/{template-full → base/api}/api/env.ts +16 -0
- package/base/api/api/server.ts +163 -0
- package/{template-full → base/api}/api/services.ts +103 -10
- package/base/api/drizzle/0002_ai_paywalls_workflows.sql +77 -0
- package/base/api/drizzle/meta/0002_snapshot.json +1759 -0
- package/{template-full → base/api}/drizzle/meta/_journal.json +7 -0
- package/base/api/test/api.test.ts +51 -0
- package/base/api/test/helpers.ts +51 -0
- package/base/both/scripts/dev.ts +44 -0
- package/base/shared/README.md +385 -0
- package/{template-full → base/shared}/_github/workflows/ci.yml +1 -1
- package/{template-full → base/web}/src/lib/api.ts +28 -1
- package/{template-full → base/web}/src/main.tsx +4 -1
- package/{template-full → base/web}/src/routeTree.gen.ts +155 -90
- package/{template-full → base/web}/src/router.test.ts +13 -9
- package/base/web/src/routes/_app/index.tsx +55 -0
- package/{template-full → base/web}/src/routes/_app.tsx +40 -16
- package/{template-full → base/web}/vite.config.ts +3 -1
- package/package.json +9 -5
- package/parts/account/api/test/account.test.ts +30 -0
- package/parts/account/part.ts +6 -0
- package/parts/admin/api/test/admin.test.ts +35 -0
- package/parts/admin/part.ts +6 -0
- package/{template-full → parts/admin/web}/src/routes/_app/admin.tsx +2 -1
- package/parts/ai/api/api/routes/ai.ts +28 -0
- package/parts/ai/api/test/ai.test.ts +52 -0
- package/parts/ai/part.ts +16 -0
- package/{template-full → parts/auth/api}/api/routes/account.ts +32 -3
- package/{template-full → parts/auth/api}/api/routes/auth.ts +5 -3
- package/parts/auth/api/test/auth.test.ts +28 -0
- package/{template-full → parts/auth/both}/e2e/smoke.spec.ts +21 -7
- package/parts/auth/part.ts +22 -0
- package/parts/growth/part.ts +7 -0
- package/{template-full/_mcp → parts/mcp/api}/test/mcp.test.ts +25 -16
- package/parts/mcp/part.ts +8 -0
- package/parts/notifications/api/test/notifications.test.ts +18 -0
- package/parts/notifications/part.ts +6 -0
- package/{template-full → parts/notifications/web}/src/routes/_app/notifications.tsx +1 -1
- package/parts/orgs/api/test/orgs.test.ts +56 -0
- package/parts/orgs/part.ts +7 -0
- package/{template-full → parts/payments/api}/api/routes/billing.ts +3 -2
- package/parts/payments/api/test/payments.test.ts +31 -0
- package/parts/payments/part.ts +12 -0
- package/{template-full → parts/payments/web}/src/routes/_app/billing.tsx +6 -3
- package/parts/paywalls/api/api/routes/paywall.ts +126 -0
- package/parts/paywalls/api/test/paywalls.test.ts +71 -0
- package/parts/paywalls/part.ts +8 -0
- package/parts/privacy/api/test/privacy.test.ts +20 -0
- package/parts/privacy/part.ts +7 -0
- package/parts/workflows/api/api/workflows.ts +33 -0
- package/parts/workflows/api/test/workflows.test.ts +44 -0
- package/parts/workflows/part.ts +7 -0
- package/parts/workflows/web/src/routes/_app/approvals.tsx +34 -0
- package/src/compose.ts +426 -0
- package/src/desktop.ts +10 -10
- package/src/index.ts +407 -174
- package/template-api/_targets/deno/Dockerfile +12 -0
- package/template-api/_targets/deno/_dockerignore +10 -0
- package/template-api/_targets/deno/src/server.ts +43 -0
- package/template-full/README.md +0 -166
- package/template-full/api/db/open.ts +0 -33
- package/template-full/api/server.ts +0 -50
- package/template-full/scripts/dev.ts +0 -17
- package/template-full/src/routes/_app/index.tsx +0 -33
- package/template-full/test/api.test.ts +0 -238
- package/template-full/tsconfig.json +0 -9
- /package/{template-full → base/api}/api/db/index.ts +0 -0
- /package/{template-full → base/api}/api/db/kv.ts +0 -0
- /package/{template-full → base/api}/drizzle/0000_init.sql +0 -0
- /package/{template-full → base/api}/drizzle/0001_orgs.sql +0 -0
- /package/{template-full → base/api}/drizzle/meta/0000_snapshot.json +0 -0
- /package/{template-full → base/api}/drizzle/meta/0001_snapshot.json +0 -0
- /package/{template-full → base/api}/drizzle.config.ts +0 -0
- /package/{template-full → base/api}/tsconfig.api.json +0 -0
- /package/{template-full → base/shared}/_gitignore +0 -0
- /package/{template-full → base/shared}/biome.json +0 -0
- /package/{template-full → base/web}/index.html +0 -0
- /package/{template-full → base/web}/src/app.css +0 -0
- /package/{template-full → base/web}/src/components/toaster.tsx +0 -0
- /package/{template-full → base/web}/src/router.ts +0 -0
- /package/{template-full → base/web}/src/routes/__root.tsx +0 -0
- /package/{template-full → base/web}/tsconfig.app.json +0 -0
- /package/{template-full → base/web}/tsconfig.node.json +0 -0
- /package/{template-full → base/web}/tsconfig.test.json +0 -0
- /package/{template-full → parts/account/web}/src/routes/_app/account.tsx +0 -0
- /package/{template-full → parts/auth/both}/playwright.config.ts +0 -0
- /package/{template-full → parts/auth/web}/src/routes/login.tsx +0 -0
- /package/{template-full → parts/notifications/api}/api/routes/notifications.ts +0 -0
- /package/{template-full → parts/orgs/web}/src/routes/_app/org/index.tsx +0 -0
- /package/{template-full → parts/orgs/web}/src/routes/_app/org/members.tsx +0 -0
- /package/{template-full → parts/orgs/web}/src/routes/_app/org/new.tsx +0 -0
- /package/{template-full → parts/orgs/web}/src/routes/invite.$token.tsx +0 -0
- /package/{template-full → parts/payments/api}/api/plans.ts +0 -0
- /package/{template-full → parts/privacy/api}/api/routes/privacy.ts +0 -0
- /package/{template-full → parts/privacy/web}/src/routes/_app/privacy.tsx +0 -0
package/src/index.ts
CHANGED
|
@@ -14,24 +14,71 @@ 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
16
|
import { createInterface } from "node:readline/promises"
|
|
17
|
+
import {
|
|
18
|
+
applyBlocks,
|
|
19
|
+
type BaseDeps,
|
|
20
|
+
compose,
|
|
21
|
+
PART_NAMES,
|
|
22
|
+
PARTS,
|
|
23
|
+
type PartName,
|
|
24
|
+
RUNTIMES,
|
|
25
|
+
type Runtime,
|
|
26
|
+
resolveParts,
|
|
27
|
+
STARTERS,
|
|
28
|
+
type StarterName,
|
|
29
|
+
} from "./compose.js"
|
|
17
30
|
import { appId, DESKTOP_PKG } from "./desktop.js"
|
|
18
31
|
|
|
19
32
|
const THEMES = ["editorial", "cinematic", "finance"] as const
|
|
20
33
|
type Theme = (typeof THEMES)[number]
|
|
21
|
-
const
|
|
34
|
+
const PLATFORMS = ["web", "api", "cli", "extension", "desktop"] as const
|
|
35
|
+
type Platform = (typeof PLATFORMS)[number]
|
|
36
|
+
// --template is the old name for --platform, kept working; its `full` is now `--starter full`.
|
|
37
|
+
const TEMPLATES = [...PLATFORMS, "full"] as const
|
|
22
38
|
type Template = (typeof TEMPLATES)[number]
|
|
23
|
-
const
|
|
39
|
+
const STARTER_NAMES = Object.keys(STARTERS) as StarterName[]
|
|
40
|
+
const TARGETS = ["cloudflare", "bun", "deno", "node", "vercel"] as const
|
|
24
41
|
type Target = (typeof TARGETS)[number]
|
|
25
42
|
const DESCRIBE_TEMPLATES: readonly Template[] = ["web", "api", "full"]
|
|
26
|
-
const PMS = ["bun", "npm", "pnpm"] as const
|
|
43
|
+
const PMS = ["bun", "npm", "pnpm", "yarn", "deno"] as const
|
|
27
44
|
type Pm = (typeof PMS)[number]
|
|
28
45
|
|
|
29
|
-
/** `npm create`
|
|
46
|
+
/** `npm create`, `pnpm create`, `yarn create`, `deno run`... say who ran them; bun otherwise. */
|
|
30
47
|
function detectPm(): Pm {
|
|
31
48
|
const agent = process.env.npm_config_user_agent ?? ""
|
|
32
|
-
|
|
49
|
+
for (const pm of ["yarn", "pnpm", "bun", "deno", "npm"] as const)
|
|
50
|
+
if (agent.startsWith(`${pm}/`)) return pm
|
|
51
|
+
return "bun"
|
|
33
52
|
}
|
|
34
53
|
|
|
54
|
+
/** Yarn through corepack, pinned so CI and every machine run the same one. */
|
|
55
|
+
const YARN = "yarn@4.18.1"
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* signet-ui's required peers. npm, pnpm, bun and deno install them on their
|
|
59
|
+
* own; Yarn does not, so a Yarn app lists them (test/scaffold-pm.ts checks
|
|
60
|
+
* this list against signet-ui's package.json).
|
|
61
|
+
*/
|
|
62
|
+
const UI_PEERS: Record<string, string> = {
|
|
63
|
+
"@base-ui/react": ">=1.3.0",
|
|
64
|
+
"@radix-ui/react-checkbox": ">=1.0.0",
|
|
65
|
+
"@radix-ui/react-dropdown-menu": ">=2.0.0",
|
|
66
|
+
"@radix-ui/react-popover": ">=1.0.0",
|
|
67
|
+
"@radix-ui/react-tooltip": ">=1.0.0",
|
|
68
|
+
"@tanstack/react-table": ">=9.0.0",
|
|
69
|
+
"class-variance-authority": ">=0.0.0",
|
|
70
|
+
clsx: ">=2.0.0",
|
|
71
|
+
"input-otp": ">=1.4.0",
|
|
72
|
+
"lucide-react": ">=1.0.0",
|
|
73
|
+
react: ">=19.0.0",
|
|
74
|
+
"react-day-picker": ">=10.0.0",
|
|
75
|
+
"react-dom": ">=19.0.0",
|
|
76
|
+
"tailwind-merge": ">=3.0.0",
|
|
77
|
+
"@dapplelight/signet-tokens": "^0.3.0 || ^0.4.0",
|
|
78
|
+
}
|
|
79
|
+
const sortDeps = (o: Record<string, string>) =>
|
|
80
|
+
Object.fromEntries(Object.entries(o).sort(([a], [b]) => a.localeCompare(b)))
|
|
81
|
+
|
|
35
82
|
/** How each package manager spells install, a frozen install and running a script or a bin. */
|
|
36
83
|
const PM: Record<Pm, { install: string; ci: string; run: string; x: string; lock: string }> = {
|
|
37
84
|
bun: {
|
|
@@ -55,23 +102,43 @@ const PM: Record<Pm, { install: string; ci: string; run: string; x: string; lock
|
|
|
55
102
|
x: "pnpm exec",
|
|
56
103
|
lock: "pnpm-lock.yaml",
|
|
57
104
|
},
|
|
105
|
+
yarn: {
|
|
106
|
+
install: "yarn install",
|
|
107
|
+
ci: "yarn install --immutable",
|
|
108
|
+
run: "yarn run",
|
|
109
|
+
x: "yarn exec",
|
|
110
|
+
lock: "yarn.lock",
|
|
111
|
+
},
|
|
112
|
+
deno: {
|
|
113
|
+
install: "deno install",
|
|
114
|
+
ci: "deno install --frozen",
|
|
115
|
+
run: "deno task",
|
|
116
|
+
x: "deno x",
|
|
117
|
+
lock: "deno.lock",
|
|
118
|
+
},
|
|
58
119
|
}
|
|
59
120
|
|
|
60
121
|
/**
|
|
61
|
-
* The CI workflow is written for bun; for
|
|
62
|
-
* that instead. Bun stays for `bun test` (and the
|
|
122
|
+
* The CI workflow is written for bun; for another manager, install and run
|
|
123
|
+
* with that instead. Bun stays for `bun test` (and the composed app's API).
|
|
63
124
|
*/
|
|
64
125
|
function applyPm(ci: string, pm: Pm): string {
|
|
65
126
|
if (pm === "bun") return ci
|
|
66
127
|
const p = PM[pm]
|
|
128
|
+
const node = [
|
|
129
|
+
" - uses: actions/setup-node@v4",
|
|
130
|
+
" with:",
|
|
131
|
+
" node-version: 22",
|
|
132
|
+
]
|
|
67
133
|
const setup = [
|
|
68
134
|
...(pm === "pnpm"
|
|
69
135
|
? [" - uses: pnpm/action-setup@v4", " with:", " version: 10"]
|
|
70
136
|
: []),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
137
|
+
...(pm === "deno"
|
|
138
|
+
? [" - uses: denoland/setup-deno@v2", " with:", " deno-version: v2.x"]
|
|
139
|
+
: pm === "yarn"
|
|
140
|
+
? [...node, " - run: corepack enable"]
|
|
141
|
+
: [...node, ` cache: ${pm}`]),
|
|
75
142
|
" - uses: oven-sh/setup-bun@v2",
|
|
76
143
|
].join("\n")
|
|
77
144
|
return ci
|
|
@@ -85,10 +152,9 @@ function applyPm(ci: string, pm: Pm): string {
|
|
|
85
152
|
.replaceAll("bunx ", `${p.x} `)
|
|
86
153
|
}
|
|
87
154
|
|
|
88
|
-
const TEMPLATE_DIRS: Record<
|
|
155
|
+
const TEMPLATE_DIRS: Record<Platform, string> = {
|
|
89
156
|
web: "template",
|
|
90
157
|
api: "template-api",
|
|
91
|
-
full: "template-full",
|
|
92
158
|
cli: "template-cli",
|
|
93
159
|
extension: "template-extension",
|
|
94
160
|
desktop: "template-desktop",
|
|
@@ -97,29 +163,28 @@ const TEMPLATE_DIRS: Record<Template, string> = {
|
|
|
97
163
|
// The api template: a Hono Worker with Signet's request id, error envelope,
|
|
98
164
|
// validation and exact Durable Object rate limiting already wired.
|
|
99
165
|
const API_DEPS = {
|
|
100
|
-
"@dapplelight/signet-server": "^0.
|
|
166
|
+
"@dapplelight/signet-server": "^0.6.1",
|
|
101
167
|
hono: "^4.13.8",
|
|
102
168
|
zod: "^4.6.7",
|
|
103
169
|
}
|
|
104
170
|
|
|
105
171
|
// Added with MCP (--mcp, the default): signet-server's optional peer for /mcp.
|
|
106
172
|
const MCP_DEPS = {
|
|
107
|
-
"@modelcontextprotocol/server": "^2.
|
|
173
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
108
174
|
}
|
|
109
175
|
|
|
110
176
|
/**
|
|
111
177
|
* The api template marks MCP-only lines with `// mcp:begin` / `// mcp:end`
|
|
112
|
-
* lines: with MCP the markers go, without it the blocks go.
|
|
178
|
+
* lines: with MCP the markers go, without it the blocks go. The same markers
|
|
179
|
+
* the composer resolves for every part (applyBlocks in compose.ts).
|
|
113
180
|
*/
|
|
114
181
|
function applyMcp(text: string, mcp: boolean): string {
|
|
115
|
-
return mcp
|
|
116
|
-
? text.replace(/^[ \t]*\/\/ mcp:(begin|end)\n/gm, "")
|
|
117
|
-
: text.replace(/^[ \t]*\/\/ mcp:begin\n[\s\S]*?^[ \t]*\/\/ mcp:end\n/gm, "")
|
|
182
|
+
return applyBlocks(text, new Set(mcp ? ["mcp"] : []))
|
|
118
183
|
}
|
|
119
184
|
|
|
120
185
|
const API_DEV_DEPS = {
|
|
121
186
|
"@biomejs/biome": "^2.5.14",
|
|
122
|
-
"@types/bun": "^1.4.
|
|
187
|
+
"@types/bun": "^1.4.4",
|
|
123
188
|
typescript: "^7.0.2",
|
|
124
189
|
}
|
|
125
190
|
|
|
@@ -138,9 +203,12 @@ const API_TARGETS: Record<
|
|
|
138
203
|
devDeps: { wrangler: "^4.136.3" },
|
|
139
204
|
},
|
|
140
205
|
bun: { scripts: { dev: "bun --watch src/server.ts", start: "bun src/server.ts" } },
|
|
206
|
+
deno: {
|
|
207
|
+
scripts: { dev: "deno run -A --watch src/server.ts", start: "deno run -A src/server.ts" },
|
|
208
|
+
},
|
|
141
209
|
node: {
|
|
142
210
|
scripts: { dev: "node --watch src/server.ts", start: "node src/server.ts" },
|
|
143
|
-
devDeps: { "@types/node": "^26.6.
|
|
211
|
+
devDeps: { "@types/node": "^26.6.6" },
|
|
144
212
|
// Runs src/server.ts as is: type stripping is on by default from 22.18.
|
|
145
213
|
engines: { node: ">=22.18" },
|
|
146
214
|
},
|
|
@@ -152,6 +220,8 @@ const API_NEXT_STEPS: Record<Target, string> = {
|
|
|
152
220
|
Object in wrangler.jsonc. Append migration tags; never edit a deployed one.`,
|
|
153
221
|
bun: `bun run start serves src/server.ts under Bun.serve; the Dockerfile runs the same.
|
|
154
222
|
Rate limiting is in-process and keyed by the socket address.`,
|
|
223
|
+
deno: `bun run start serves src/server.ts under Deno.serve (Deno 2); the Dockerfile runs the same.
|
|
224
|
+
Rate limiting is in-process and keyed by the socket address.`,
|
|
155
225
|
node: `bun run start runs src/server.ts with node 22.18+ (node:http, no extra dependency).
|
|
156
226
|
Rate limiting is in-process and keyed by the socket address.`,
|
|
157
227
|
vercel: `index.ts is the Vercel entry (Hono preset, vercel.json). Deploy with bun run deploy.
|
|
@@ -164,17 +234,20 @@ const DEPS = {
|
|
|
164
234
|
// links the local copies, because the range matches the workspace version.
|
|
165
235
|
"@dapplelight/signet-lib": "^0.4.0",
|
|
166
236
|
"@dapplelight/signet-tokens": "^0.4.0",
|
|
167
|
-
//
|
|
168
|
-
"@dapplelight/signet-ui": "^0.
|
|
169
|
-
"@tanstack/react-query": "^5.
|
|
237
|
+
// LabelsProvider (src/components/signet-labels.tsx) since 0.3.2.
|
|
238
|
+
"@dapplelight/signet-ui": "^0.5.0",
|
|
239
|
+
"@tanstack/react-query": "^5.108.0",
|
|
170
240
|
"@tanstack/react-router": "^1.170.39",
|
|
171
241
|
"class-variance-authority": "^0.7.1",
|
|
172
242
|
clsx: "^2.1.1",
|
|
173
|
-
"lucide-react": "^1.
|
|
174
|
-
react: "^19.3.
|
|
175
|
-
"react-dom": "^19.3.
|
|
243
|
+
"lucide-react": "^1.74.0",
|
|
244
|
+
react: "^19.3.1",
|
|
245
|
+
"react-dom": "^19.3.1",
|
|
176
246
|
sonner: "^2.0.8",
|
|
177
247
|
"tailwind-merge": "^3.7.0",
|
|
248
|
+
// Listed so npm resolves signet-ui's optional zod 4 peer, not the zod 3
|
|
249
|
+
// that @hookform/resolvers' optional peers pull in otherwise (ERESOLVE).
|
|
250
|
+
zod: "^4.6.7",
|
|
178
251
|
}
|
|
179
252
|
|
|
180
253
|
// The web template's i18n: src/lib/i18n.ts + src/locales/*.json.
|
|
@@ -193,34 +266,30 @@ const PWA_DEV_DEPS = {
|
|
|
193
266
|
|
|
194
267
|
const DEV_DEPS = {
|
|
195
268
|
"@biomejs/biome": "^2.5.14",
|
|
196
|
-
"@tailwindcss/vite": "^4.3.
|
|
269
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
197
270
|
"@tanstack/router-plugin": "^1.168.40",
|
|
198
|
-
"@types/bun": "^1.4.
|
|
199
|
-
"@types/node": "^26.6.
|
|
271
|
+
"@types/bun": "^1.4.4",
|
|
272
|
+
"@types/node": "^26.6.6",
|
|
200
273
|
"@types/react": "^19.3.0",
|
|
201
274
|
"@types/react-dom": "^19.3.0",
|
|
202
|
-
"@vitejs/plugin-react": "^6.
|
|
203
|
-
tailwindcss: "^4.3.
|
|
275
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
276
|
+
tailwindcss: "^4.3.5",
|
|
204
277
|
typescript: "^7.0.2",
|
|
205
|
-
vite: "^8.3.
|
|
278
|
+
vite: "^8.3.8",
|
|
206
279
|
}
|
|
207
280
|
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const FULL_DEV_DEPS = {
|
|
221
|
-
...DEV_DEPS,
|
|
222
|
-
"@playwright/test": "^1.65.1",
|
|
223
|
-
"drizzle-kit": "^0.31.11",
|
|
281
|
+
// Composed apps (--ui, --api, --with, --starter): the base's own deps per
|
|
282
|
+
// surface. Each part adds its own in parts/<name>/part.ts. The web half calls
|
|
283
|
+
// the API through hono/client; the screens need @base-ui/react.
|
|
284
|
+
const BASE: BaseDeps = {
|
|
285
|
+
web: {
|
|
286
|
+
deps: { ...DEPS, "@base-ui/react": "^1.3.0", hono: API_DEPS.hono },
|
|
287
|
+
devDeps: DEV_DEPS,
|
|
288
|
+
},
|
|
289
|
+
api: {
|
|
290
|
+
deps: { ...API_DEPS, "@dapplelight/signet-db": "^0.2.0", "drizzle-orm": "^0.45.4" },
|
|
291
|
+
devDeps: { ...API_DEV_DEPS, "drizzle-kit": "^0.31.11" },
|
|
292
|
+
},
|
|
224
293
|
}
|
|
225
294
|
|
|
226
295
|
// The cli template: a Bun CLI that signs in by device code, compiled to one binary.
|
|
@@ -255,24 +324,22 @@ const EXT_SCRIPTS = {
|
|
|
255
324
|
test: "bun test",
|
|
256
325
|
}
|
|
257
326
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
lint: "biome check .",
|
|
266
|
-
format: "biome check --write .",
|
|
267
|
-
typecheck: "tsc -b --noEmit",
|
|
268
|
-
test: "bun test src test",
|
|
269
|
-
"test:e2e": "playwright test",
|
|
270
|
-
"db:generate": "drizzle-kit generate",
|
|
271
|
-
"db:check": "signet-db-check drizzle",
|
|
327
|
+
/** What a composed app is made of, as the flags said it. */
|
|
328
|
+
type ComposeFlags = {
|
|
329
|
+
starter?: StarterName
|
|
330
|
+
ui: boolean
|
|
331
|
+
api: boolean
|
|
332
|
+
with: string[]
|
|
333
|
+
without: string[]
|
|
272
334
|
}
|
|
273
335
|
|
|
274
|
-
|
|
275
|
-
|
|
336
|
+
const list = (v: string | undefined, flag: string) => {
|
|
337
|
+
if (!v || v.startsWith("-")) throw new Error(`${flag} needs parts, e.g. ${flag} auth,payments`)
|
|
338
|
+
return v
|
|
339
|
+
.split(",")
|
|
340
|
+
.map((s) => s.trim())
|
|
341
|
+
.filter(Boolean)
|
|
342
|
+
}
|
|
276
343
|
|
|
277
344
|
function parseArgs(argv: string[]) {
|
|
278
345
|
const args = argv.slice(2)
|
|
@@ -285,6 +352,7 @@ function parseArgs(argv: string[]) {
|
|
|
285
352
|
let describe: string | undefined
|
|
286
353
|
let themeGiven: Theme | undefined
|
|
287
354
|
let templateGiven: Template | undefined
|
|
355
|
+
const composeFlags: ComposeFlags = { ui: false, api: false, with: [], without: [] }
|
|
288
356
|
|
|
289
357
|
for (let i = 0; i < args.length; i++) {
|
|
290
358
|
const a = args[i]
|
|
@@ -294,12 +362,26 @@ function parseArgs(argv: string[]) {
|
|
|
294
362
|
throw new Error(`Unknown theme "${v}". Available: ${THEMES.join(", ")}`)
|
|
295
363
|
}
|
|
296
364
|
theme = themeGiven = v as Theme
|
|
297
|
-
} else if (a === "--template") {
|
|
365
|
+
} else if (a === "--platform" || a === "--template") {
|
|
298
366
|
const v = args[++i]
|
|
299
|
-
if (
|
|
300
|
-
throw new Error(
|
|
367
|
+
if (a === "--platform" && v === "full")
|
|
368
|
+
throw new Error("full is a starter now: --starter full (or --template full).")
|
|
369
|
+
if (!(a === "--platform" ? PLATFORMS : TEMPLATES).includes(v as Platform)) {
|
|
370
|
+
throw new Error(`Unknown platform "${v}". Available: ${PLATFORMS.join(", ")}`)
|
|
301
371
|
}
|
|
372
|
+
if (templateGiven && templateGiven !== v)
|
|
373
|
+
throw new Error("--platform and --template are the same flag; give one.")
|
|
302
374
|
template = templateGiven = v as Template
|
|
375
|
+
} else if (a === "--starter") {
|
|
376
|
+
const v = args[++i]
|
|
377
|
+
if (!STARTER_NAMES.includes(v as StarterName)) {
|
|
378
|
+
throw new Error(`Unknown starter "${v}". Available: ${STARTER_NAMES.join(", ")}`)
|
|
379
|
+
}
|
|
380
|
+
composeFlags.starter = v as StarterName
|
|
381
|
+
} else if (a === "--ui" || a === "--api") {
|
|
382
|
+
composeFlags[a === "--ui" ? "ui" : "api"] = true
|
|
383
|
+
} else if (a === "--with" || a === "--without") {
|
|
384
|
+
composeFlags[a === "--with" ? "with" : "without"].push(...list(args[++i], a))
|
|
303
385
|
} else if (a === "--describe") {
|
|
304
386
|
const v = args[++i]
|
|
305
387
|
if (!v?.trim() || v.startsWith("--"))
|
|
@@ -325,14 +407,11 @@ function parseArgs(argv: string[]) {
|
|
|
325
407
|
console.log(`
|
|
326
408
|
create-signet-app <directory> [options]
|
|
327
409
|
|
|
328
|
-
|
|
329
|
-
--
|
|
410
|
+
Platforms (one app each):
|
|
411
|
+
--platform <name> web | api | cli | extension | desktop (default: web)
|
|
330
412
|
web: Vite + React + Signet UI
|
|
331
413
|
api: Hono Worker with the error envelope, request ids,
|
|
332
414
|
validation and Durable Object rate limiting
|
|
333
|
-
full: web + API in one project, typed client between
|
|
334
|
-
them, SQLite with migrations, phone sign-in,
|
|
335
|
-
account, inbox, privacy, billing and admin
|
|
336
415
|
cli: Bun CLI compiled to one binary; login by device
|
|
337
416
|
code, logout, whoami
|
|
338
417
|
extension: Chrome MV3 extension: popup, options page and
|
|
@@ -340,28 +419,50 @@ Options:
|
|
|
340
419
|
chrome.identity (plain Vite, no extension plugin)
|
|
341
420
|
desktop: Tauri v2 desktop + menu-bar app, browser sign-in
|
|
342
421
|
(PKCE, loopback redirect), CI on macOS/Windows/Linux
|
|
343
|
-
--
|
|
422
|
+
--template <name> the old name for --platform; --template full is --starter full
|
|
423
|
+
|
|
424
|
+
Composed apps (a web app and its API from parts; any of these flags):
|
|
425
|
+
--starter <name> a named mix of parts, web + API in one project, typed
|
|
426
|
+
client between them, SQLite with migrations:
|
|
427
|
+
${STARTER_NAMES.map((s) => ` ${s.padEnd(14)}${STARTERS[s].description}`).join("\n")}
|
|
428
|
+
--with <parts> comma-separated parts to add; the parts they need come too
|
|
429
|
+
--without <parts> parts to leave out (alone: the full starter without them)
|
|
430
|
+
--ui the web half only; it calls an API elsewhere (VITE_API_URL)
|
|
431
|
+
--api the API half only (Hono on Bun, SQLite)
|
|
432
|
+
neither: both halves
|
|
433
|
+
Parts:
|
|
434
|
+
${PART_NAMES.map((p) => ` ${p.padEnd(14)}${PARTS[p].description}${PARTS[p].needs ? ` (needs ${PARTS[p].needs?.join(", ")})` : ""}`).join("\n")}
|
|
435
|
+
|
|
436
|
+
Options:
|
|
437
|
+
--target <runtime> ${TARGETS.join(" | ")} (default: cloudflare; platform api)
|
|
438
|
+
composed apps: ${RUNTIMES.join(" | ")} runs the API (default: bun;
|
|
439
|
+
deno and node use node:sqlite and node:http)
|
|
344
440
|
cloudflare: Worker entry + wrangler.jsonc
|
|
345
441
|
bun: Bun.serve entry + Dockerfile
|
|
442
|
+
deno: Deno.serve entry + Dockerfile (Deno 2)
|
|
346
443
|
node: node:http entry (Node 22.18+)
|
|
347
444
|
vercel: Vercel entry + vercel.json
|
|
348
|
-
--mcp, --no-mcp api and
|
|
445
|
+
--mcp, --no-mcp platform api and composed apps with an API: serve the
|
|
446
|
+
routes to agents at /mcp (the mcp part)
|
|
349
447
|
(default: asks when interactive, else --mcp)
|
|
350
|
-
-t, --theme <name> ${THEMES.join(" | ")} (default: editorial; web
|
|
448
|
+
-t, --theme <name> ${THEMES.join(" | ")} (default: editorial; anything with a web UI)
|
|
351
449
|
--pm <name> ${PMS.join(" | ")} (default: the one that ran this, else bun)
|
|
352
450
|
Sets the commands in CI, the README and below.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
451
|
+
Tests (bun test) still need Bun; deno: not for platform cli
|
|
452
|
+
--describe "<sentence>" Pick platform (or the full starter) and theme from one
|
|
453
|
+
sentence, scaffold, write PLAN.md and AGENTS.md (web, api
|
|
454
|
+
and full; an explicit --platform or --theme wins)
|
|
356
455
|
-h, --help
|
|
357
456
|
|
|
358
457
|
Examples:
|
|
359
458
|
bun create-signet-app my-app --theme cinematic
|
|
360
|
-
bun create-signet-app my-api --
|
|
361
|
-
bun create-signet-app my-
|
|
362
|
-
bun create-signet-app my-app --
|
|
363
|
-
bun create-signet-app my-
|
|
364
|
-
|
|
459
|
+
bun create-signet-app my-api --platform api --target bun
|
|
460
|
+
bun create-signet-app my-app --starter full --theme finance
|
|
461
|
+
bun create-signet-app my-app --with payments,notifications
|
|
462
|
+
bun create-signet-app my-app --without admin,privacy
|
|
463
|
+
bun create-signet-app my-api --api --with orgs
|
|
464
|
+
bun create-signet-app my-cli --platform cli
|
|
465
|
+
npm create signet-app my-app -- --starter full --pm npm
|
|
365
466
|
bun create-signet-app my-app --describe "a team inbox with settings and pricing"
|
|
366
467
|
`)
|
|
367
468
|
process.exit(0)
|
|
@@ -373,7 +474,24 @@ Examples:
|
|
|
373
474
|
}
|
|
374
475
|
|
|
375
476
|
if (!name) throw new Error("Missing target directory.\nUsage: create-signet-app <directory>")
|
|
477
|
+
const composing =
|
|
478
|
+
composeFlags.starter ||
|
|
479
|
+
composeFlags.ui ||
|
|
480
|
+
composeFlags.api ||
|
|
481
|
+
composeFlags.with.length ||
|
|
482
|
+
composeFlags.without.length
|
|
483
|
+
if (composing && templateGiven && templateGiven !== "full")
|
|
484
|
+
throw new Error(
|
|
485
|
+
`--platform ${templateGiven} is its own app; --starter, --with, --without, --ui and --api compose a web app and its API. Give one or the other.`,
|
|
486
|
+
)
|
|
487
|
+
if (composeFlags.ui && composeFlags.api)
|
|
488
|
+
throw new Error("--ui and --api together are the default (both halves): drop them.")
|
|
489
|
+
if (composing) template = "full"
|
|
376
490
|
if (describe !== undefined) {
|
|
491
|
+
if (composing && templateGiven !== "full")
|
|
492
|
+
throw new Error(
|
|
493
|
+
"--describe picks the platform or starter itself; drop --starter, --with, --without, --ui and --api.",
|
|
494
|
+
)
|
|
377
495
|
if (templateGiven && !DESCRIBE_TEMPLATES.includes(templateGiven))
|
|
378
496
|
throw new Error("--describe applies to --template web, api and full only.")
|
|
379
497
|
// The template and theme come from the sentence, so these are checked once they are known.
|
|
@@ -385,23 +503,54 @@ Examples:
|
|
|
385
503
|
targetGiven: target,
|
|
386
504
|
mcp,
|
|
387
505
|
pm: pm ?? detectPm(),
|
|
506
|
+
composeFlags,
|
|
388
507
|
describe: { sentence: describe, template: templateGiven, theme: themeGiven },
|
|
389
508
|
}
|
|
390
509
|
}
|
|
391
|
-
checkCombo(template, theme, target, mcp)
|
|
392
|
-
return {
|
|
510
|
+
checkCombo(template, theme, target, mcp, composeFlags)
|
|
511
|
+
return {
|
|
512
|
+
name,
|
|
513
|
+
theme,
|
|
514
|
+
template,
|
|
515
|
+
target: target ?? "cloudflare",
|
|
516
|
+
targetGiven: target,
|
|
517
|
+
mcp,
|
|
518
|
+
pm: pm ?? detectPm(),
|
|
519
|
+
composeFlags,
|
|
520
|
+
// Nothing said what to build: asked on a terminal, else the web platform.
|
|
521
|
+
pick: !templateGiven && !composing,
|
|
522
|
+
}
|
|
393
523
|
}
|
|
394
524
|
|
|
395
|
-
/** Flags that only fit some
|
|
396
|
-
function checkCombo(
|
|
397
|
-
|
|
525
|
+
/** Flags that only fit some platforms. */
|
|
526
|
+
function checkCombo(
|
|
527
|
+
template: Template,
|
|
528
|
+
theme: Theme,
|
|
529
|
+
target?: Target,
|
|
530
|
+
mcp?: boolean,
|
|
531
|
+
c?: ComposeFlags,
|
|
532
|
+
) {
|
|
533
|
+
if (target && template !== "api" && template !== "full")
|
|
534
|
+
throw new Error("--target applies to --platform api and composed apps only.")
|
|
535
|
+
if (target && template === "full") {
|
|
536
|
+
if (!(RUNTIMES as readonly string[]).includes(target))
|
|
537
|
+
throw new Error(
|
|
538
|
+
`A composed app's API runs on ${RUNTIMES.join(", ")}: --target ${target} is for --platform api.`,
|
|
539
|
+
)
|
|
540
|
+
if (c?.ui) throw new Error("--target picks the API's runtime: drop --ui, or --target.")
|
|
541
|
+
}
|
|
398
542
|
if (
|
|
399
543
|
mcp !== undefined &&
|
|
400
544
|
(template === "web" || template === "cli" || template === "extension" || template === "desktop")
|
|
401
545
|
)
|
|
402
|
-
throw new Error("--mcp / --no-mcp apply to --
|
|
403
|
-
if (theme !== "editorial" && template === "api")
|
|
404
|
-
throw new Error("--theme applies to
|
|
546
|
+
throw new Error("--mcp / --no-mcp apply to --platform api and composed apps only.")
|
|
547
|
+
if (theme !== "editorial" && (template === "api" || c?.api))
|
|
548
|
+
throw new Error("--theme applies to apps with a web UI only.")
|
|
549
|
+
if (!c) return
|
|
550
|
+
const withMcp = c.with.includes("mcp")
|
|
551
|
+
if ((withMcp || mcp) && c.ui) throw new Error("mcp serves the API's routes: drop --ui, or mcp.")
|
|
552
|
+
if ((withMcp && mcp === false) || (c.without.includes("mcp") && mcp))
|
|
553
|
+
throw new Error("--with/--without mcp and --mcp/--no-mcp disagree; give one.")
|
|
405
554
|
}
|
|
406
555
|
|
|
407
556
|
/** Replace placeholders in every text file under dir. */
|
|
@@ -424,6 +573,34 @@ async function substitute(dir: string, vars: Record<string, string>) {
|
|
|
424
573
|
}
|
|
425
574
|
}
|
|
426
575
|
|
|
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()
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
427
604
|
/** "Add MCP for agents?", default yes; only asked on a terminal. */
|
|
428
605
|
async function askMcp(): Promise<boolean> {
|
|
429
606
|
if (!process.stdin.isTTY) return true
|
|
@@ -436,6 +613,90 @@ async function askMcp(): Promise<boolean> {
|
|
|
436
613
|
}
|
|
437
614
|
}
|
|
438
615
|
|
|
616
|
+
/** A platform's template, its --target files and MCP's overlay, as they always were. */
|
|
617
|
+
async function copyPlatform(platform: Platform, dest: string, target: Target, mcp: boolean) {
|
|
618
|
+
const templateDir = resolve(import.meta.dirname, `../${TEMPLATE_DIRS[platform]}`)
|
|
619
|
+
const targetsDir = join(templateDir, "_targets")
|
|
620
|
+
const mcpDir = join(templateDir, "_mcp")
|
|
621
|
+
await cp(templateDir, dest, {
|
|
622
|
+
recursive: true,
|
|
623
|
+
filter: (src) => src !== targetsDir && src !== mcpDir,
|
|
624
|
+
})
|
|
625
|
+
// Only the chosen runtime's files, laid over the shared ones; MCP's tests with MCP.
|
|
626
|
+
if (platform === "api") {
|
|
627
|
+
await cp(join(targetsDir, target), dest, { recursive: true })
|
|
628
|
+
if (mcp && existsSync(mcpDir)) await cp(mcpDir, dest, { recursive: true })
|
|
629
|
+
for (const f of ["src/app.ts", "src/env.ts"]) {
|
|
630
|
+
const path = join(dest, f)
|
|
631
|
+
await writeFile(path, applyMcp(await readFile(path, "utf8"), mcp))
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* The parts and surfaces a composed app gets. The base set is the starter's
|
|
638
|
+
* (`--template full` and `--without` alone mean the full starter), then
|
|
639
|
+
* --with adds, --without takes away, and needs are added. MCP is asked for
|
|
640
|
+
* when nothing said, as it always was.
|
|
641
|
+
*/
|
|
642
|
+
async function pickParts(c: ComposeFlags, mcpFlag: boolean | undefined) {
|
|
643
|
+
const flagged = c.ui || c.api || c.with.length > 0 || c.without.length > 0
|
|
644
|
+
const starter =
|
|
645
|
+
c.starter ?? (!flagged || (!c.with.length && c.without.length) ? "full" : undefined)
|
|
646
|
+
const apiStarter = starter !== undefined && "surface" in STARTERS[starter]
|
|
647
|
+
if (apiStarter && c.ui) throw new Error(`--starter ${starter} is the API only: drop --ui.`)
|
|
648
|
+
const web = !c.api && !apiStarter
|
|
649
|
+
const api = !c.ui
|
|
650
|
+
// A UI-only app takes the starter's parts that have a web half.
|
|
651
|
+
const base = starter ? STARTERS[starter].parts.filter((p) => api || !PARTS[p].apiOnly) : []
|
|
652
|
+
const mcp = c.with.includes("mcp")
|
|
653
|
+
? true
|
|
654
|
+
: c.without.includes("mcp")
|
|
655
|
+
? false
|
|
656
|
+
: api && (mcpFlag ?? (await askMcp()))
|
|
657
|
+
const chosen = [...base.filter((p) => !c.without.includes(p)), ...c.with, ...(mcp ? ["mcp"] : [])]
|
|
658
|
+
const { parts, added } = resolveParts([...new Set(chosen)], c.without)
|
|
659
|
+
for (const p of parts)
|
|
660
|
+
if (PARTS[p].apiOnly && !api) throw new Error(`${p} needs the API: drop --ui, or ${p}.`)
|
|
661
|
+
return { parts, added, web, api, starter }
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function composedMessage(
|
|
665
|
+
appName: string,
|
|
666
|
+
theme: Theme,
|
|
667
|
+
steps: string,
|
|
668
|
+
{ parts, added, web, api }: Awaited<ReturnType<typeof pickParts>>,
|
|
669
|
+
): string {
|
|
670
|
+
const what = web && api ? "web app + API" : web ? "web app (UI only)" : "API"
|
|
671
|
+
const has = (p: PartName) => parts.includes(p)
|
|
672
|
+
const lines = [
|
|
673
|
+
`Created ${appName}: ${what}${web ? ` with the ${theme} theme` : ""}${has("mcp") ? ", MCP at /mcp" : ""}.`,
|
|
674
|
+
`Parts: ${parts.length ? parts.join(", ") : "none"}${added.length ? ` (added ${added.map((a) => `${a.part} for ${a.for}`).join(", ")})` : ""}.`,
|
|
675
|
+
"",
|
|
676
|
+
steps,
|
|
677
|
+
"",
|
|
678
|
+
]
|
|
679
|
+
if (web && api)
|
|
680
|
+
lines.push(
|
|
681
|
+
has("auth")
|
|
682
|
+
? "Open the URL Vite prints and sign in with any phone number; in development\n the code is printed in this terminal."
|
|
683
|
+
: "Open the URL Vite prints.",
|
|
684
|
+
)
|
|
685
|
+
if (web && !api)
|
|
686
|
+
lines.push(
|
|
687
|
+
"Set VITE_API_URL (.env.local) to your API's origin; src/lib/api.ts says how to type it.",
|
|
688
|
+
)
|
|
689
|
+
if (!web && has("auth"))
|
|
690
|
+
lines.push(
|
|
691
|
+
"Sign in with POST /api/auth/otp, then /api/auth/verify; in development the\n code is printed in this terminal.",
|
|
692
|
+
)
|
|
693
|
+
if (has("admin")) lines.push("Put your number in ADMIN_PHONES (.env) to see /admin.")
|
|
694
|
+
lines.push(
|
|
695
|
+
`README.md walks through the first day.${api ? " The API runs on Bun,\n whichever package manager installs it." : ""}`,
|
|
696
|
+
)
|
|
697
|
+
return `\n ${lines.join("\n ").replace(/\n {2}\n/g, "\n\n")}\n`
|
|
698
|
+
}
|
|
699
|
+
|
|
439
700
|
async function main() {
|
|
440
701
|
const parsed = parseArgs(process.argv)
|
|
441
702
|
const { name, target, pm, ...flags } = parsed
|
|
@@ -454,35 +715,31 @@ async function main() {
|
|
|
454
715
|
;({ theme, template } = described)
|
|
455
716
|
checkCombo(template, theme, parsed.targetGiven, flags.mcp)
|
|
456
717
|
}
|
|
718
|
+
if (parsed.pick && process.stdin.isTTY) {
|
|
719
|
+
const what = await askWhat()
|
|
720
|
+
if ((PLATFORMS as readonly string[]).includes(what)) template = what as Platform
|
|
721
|
+
else {
|
|
722
|
+
template = "full"
|
|
723
|
+
parsed.composeFlags.starter = what as StarterName
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (parsed.pm === "deno" && template === "cli")
|
|
727
|
+
throw new Error(
|
|
728
|
+
"--platform cli compiles one binary with `bun build --compile`; use --pm bun, npm, pnpm or yarn.",
|
|
729
|
+
)
|
|
457
730
|
|
|
458
731
|
if (existsSync(dest) && (await readdir(dest)).length > 0) {
|
|
459
732
|
throw new Error(`${dest} already exists and is not empty.`)
|
|
460
733
|
}
|
|
461
734
|
|
|
462
|
-
const
|
|
463
|
-
const
|
|
735
|
+
const composed = template === "full" ? await pickParts(parsed.composeFlags, flags.mcp) : undefined
|
|
736
|
+
const mcp = composed
|
|
737
|
+
? composed.parts.includes("mcp")
|
|
738
|
+
: template === "api" && (flags.mcp ?? (await askMcp()))
|
|
464
739
|
await mkdir(dest, { recursive: true })
|
|
465
|
-
const
|
|
466
|
-
const
|
|
467
|
-
await
|
|
468
|
-
recursive: true,
|
|
469
|
-
filter: (src) => src !== targetsDir && src !== mcpDir,
|
|
470
|
-
})
|
|
471
|
-
// Only the chosen runtime's files, laid over the shared ones; MCP's tests with MCP.
|
|
472
|
-
if (template === "api") await cp(join(targetsDir, target), dest, { recursive: true })
|
|
473
|
-
if (mcp && existsSync(mcpDir)) await cp(mcpDir, dest, { recursive: true })
|
|
474
|
-
const mcpFiles: Record<Template, string[]> = {
|
|
475
|
-
web: [],
|
|
476
|
-
extension: [],
|
|
477
|
-
desktop: [],
|
|
478
|
-
api: ["src/app.ts", "src/env.ts"],
|
|
479
|
-
full: ["api/app.ts", "api/env.ts"],
|
|
480
|
-
cli: [],
|
|
481
|
-
}
|
|
482
|
-
for (const f of mcpFiles[template]) {
|
|
483
|
-
const path = join(dest, f)
|
|
484
|
-
await writeFile(path, applyMcp(await readFile(path, "utf8"), mcp))
|
|
485
|
-
}
|
|
740
|
+
const runtime = (parsed.targetGiven ?? "bun") as Runtime
|
|
741
|
+
const made = composed ? await compose(dest, { ...composed, runtime }, BASE) : undefined
|
|
742
|
+
if (!composed) await copyPlatform(template as Platform, dest, target, mcp)
|
|
486
743
|
|
|
487
744
|
// npm strips a file literally named .gitignore from published packages, so
|
|
488
745
|
// the template ships it as _gitignore and it is renamed on scaffold.
|
|
@@ -490,7 +747,7 @@ async function main() {
|
|
|
490
747
|
// the CI workflow ships under _github.
|
|
491
748
|
await rename(join(dest, "_gitignore"), join(dest, ".gitignore"))
|
|
492
749
|
await rename(join(dest, "_github"), join(dest, ".github"))
|
|
493
|
-
if (template === "api" && target === "bun")
|
|
750
|
+
if (template === "api" && (target === "bun" || target === "deno"))
|
|
494
751
|
await rename(join(dest, "_dockerignore"), join(dest, ".dockerignore"))
|
|
495
752
|
// pnpm (10+) refuses to install until build scripts are reviewed; esbuild's
|
|
496
753
|
// (vite, drizzle-kit, wrangler) and workerd's are the ones these templates
|
|
@@ -500,6 +757,9 @@ async function main() {
|
|
|
500
757
|
join(dest, "pnpm-workspace.yaml"),
|
|
501
758
|
"allowBuilds:\n esbuild: true\n workerd: true\nonlyBuiltDependencies:\n - esbuild\n - workerd\n",
|
|
502
759
|
)
|
|
760
|
+
// Yarn's default Plug'n'Play has no node_modules, which Vite, tsc and
|
|
761
|
+
// wrangler expect; a plain node_modules works with all of them.
|
|
762
|
+
if (pm === "yarn") await writeFile(join(dest, ".yarnrc.yml"), "nodeLinker: node-modules\n")
|
|
503
763
|
const ci = join(dest, ".github/workflows/ci.yml")
|
|
504
764
|
await writeFile(ci, applyPm(await readFile(ci, "utf8"), pm))
|
|
505
765
|
|
|
@@ -512,22 +772,10 @@ async function main() {
|
|
|
512
772
|
__PM_X__: PM[pm].x,
|
|
513
773
|
})
|
|
514
774
|
|
|
515
|
-
if (
|
|
775
|
+
if (made?.env.length)
|
|
516
776
|
// The API's secrets for this machine, fresh per app; gitignored. Bun loads
|
|
517
777
|
// it on its own. Production sets these on the host instead.
|
|
518
|
-
await writeFile(
|
|
519
|
-
join(dest, ".env"),
|
|
520
|
-
[
|
|
521
|
-
"APP_ENV=development",
|
|
522
|
-
`SESSION_SECRET=${secret()}`,
|
|
523
|
-
`OTP_SECRET=${secret()}`,
|
|
524
|
-
"# Phone numbers (E.164, comma-separated) that become admins on sign-in.",
|
|
525
|
-
"ADMIN_PHONES=",
|
|
526
|
-
"BILLING=fake",
|
|
527
|
-
"",
|
|
528
|
-
].join("\n"),
|
|
529
|
-
)
|
|
530
|
-
}
|
|
778
|
+
await writeFile(join(dest, ".env"), made.env.join("\n"))
|
|
531
779
|
|
|
532
780
|
// signet-mcp's index reads the scripts below from this source by their
|
|
533
781
|
// shape: the api object first, the web object as the next literal.
|
|
@@ -541,33 +789,26 @@ async function main() {
|
|
|
541
789
|
typecheck: "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
542
790
|
test: "bun test",
|
|
543
791
|
}
|
|
544
|
-
:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
test: "bun test",
|
|
554
|
-
},
|
|
792
|
+
: {
|
|
793
|
+
dev: "vite",
|
|
794
|
+
build: "tsc -b && vite build",
|
|
795
|
+
preview: "vite preview",
|
|
796
|
+
lint: "biome check .",
|
|
797
|
+
format: "biome check --write .",
|
|
798
|
+
typecheck: "tsc -b --noEmit",
|
|
799
|
+
test: "bun test",
|
|
800
|
+
},
|
|
555
801
|
dependencies:
|
|
556
|
-
template === "api"
|
|
557
|
-
? { ...API_DEPS, ...(mcp ? MCP_DEPS : {}) }
|
|
558
|
-
: template === "full"
|
|
559
|
-
? { ...FULL_DEPS, ...(mcp ? MCP_DEPS : {}) }
|
|
560
|
-
: { ...DEPS, ...I18N_DEPS },
|
|
802
|
+
template === "api" ? { ...API_DEPS, ...(mcp ? MCP_DEPS : {}) } : { ...DEPS, ...I18N_DEPS },
|
|
561
803
|
devDependencies:
|
|
562
804
|
template === "api"
|
|
563
805
|
? { ...API_DEV_DEPS, ...API_TARGETS[target].devDeps }
|
|
564
|
-
:
|
|
565
|
-
? FULL_DEV_DEPS
|
|
566
|
-
: { ...DEV_DEPS, ...PWA_DEV_DEPS },
|
|
806
|
+
: { ...DEV_DEPS, ...PWA_DEV_DEPS },
|
|
567
807
|
...(template === "api" && API_TARGETS[target].engines
|
|
568
808
|
? { engines: API_TARGETS[target].engines }
|
|
569
809
|
: {}),
|
|
570
810
|
}
|
|
811
|
+
if (made) Object.assign(pkg, made.pkg)
|
|
571
812
|
if (template === "extension")
|
|
572
813
|
Object.assign(pkg, {
|
|
573
814
|
scripts: EXT_SCRIPTS,
|
|
@@ -579,22 +820,23 @@ async function main() {
|
|
|
579
820
|
template === "cli"
|
|
580
821
|
? JSON.parse(JSON.stringify(CLI_PKG).replaceAll("__APP_NAME__", appName))
|
|
581
822
|
: pkg
|
|
823
|
+
const out = {
|
|
824
|
+
name: appName,
|
|
825
|
+
private: true,
|
|
826
|
+
version: "0.1.0",
|
|
827
|
+
type: "module",
|
|
828
|
+
...(pm === "yarn" ? { packageManager: YARN } : {}),
|
|
829
|
+
...(template === "desktop" ? DESKTOP_PKG : final),
|
|
830
|
+
// npm 11 warns on unreviewed install scripts and will block them later.
|
|
831
|
+
// esbuild (under Vite and wrangler) needs its postinstall to fetch its binary.
|
|
832
|
+
...(pm === "npm" && template !== "cli" ? { allowScripts: { esbuild: true } } : {}),
|
|
833
|
+
}
|
|
834
|
+
if (pm === "yarn" && out.dependencies?.["@dapplelight/signet-ui"])
|
|
835
|
+
out.dependencies = sortDeps({ ...UI_PEERS, ...out.dependencies })
|
|
582
836
|
await writeFile(
|
|
583
837
|
join(dest, "package.json"),
|
|
584
|
-
`${JSON.stringify(
|
|
585
|
-
|
|
586
|
-
name: appName,
|
|
587
|
-
private: true,
|
|
588
|
-
version: "0.1.0",
|
|
589
|
-
type: "module",
|
|
590
|
-
...(template === "desktop" ? DESKTOP_PKG : final),
|
|
591
|
-
// npm 11 warns on unreviewed install scripts and will block them later.
|
|
592
|
-
// esbuild (under Vite and wrangler) needs its postinstall to fetch its binary.
|
|
593
|
-
...(pm === "npm" && template !== "cli" ? { allowScripts: { esbuild: true } } : {}),
|
|
594
|
-
},
|
|
595
|
-
null,
|
|
596
|
-
2,
|
|
597
|
-
)}\n`,
|
|
838
|
+
`${JSON.stringify(out, null, 2)}
|
|
839
|
+
`,
|
|
598
840
|
)
|
|
599
841
|
|
|
600
842
|
const { install, run } = PM[pm]
|
|
@@ -643,17 +885,8 @@ async function main() {
|
|
|
643
885
|
Needs Rust and Tauri's system dependencies. README.md covers sign-in (register
|
|
644
886
|
the client on signet-server) and the identifier in src-tauri/tauri.conf.json.
|
|
645
887
|
`
|
|
646
|
-
:
|
|
647
|
-
?
|
|
648
|
-
Created ${appName}: web app + API with the ${theme} theme${mcp ? ", MCP at /mcp" : ""}.
|
|
649
|
-
|
|
650
|
-
${steps}
|
|
651
|
-
|
|
652
|
-
Open the URL Vite prints and sign in with any phone number; in development
|
|
653
|
-
the code is printed in this terminal. Put your number in ADMIN_PHONES (.env)
|
|
654
|
-
to see /admin. README.md walks through the first day. The API runs on Bun,
|
|
655
|
-
whichever package manager installs it.
|
|
656
|
-
`
|
|
888
|
+
: composed
|
|
889
|
+
? composedMessage(appName, theme, steps, composed)
|
|
657
890
|
: `
|
|
658
891
|
Created ${appName} with the ${theme} theme.
|
|
659
892
|
|