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