create-signet-app 0.4.8 → 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 +114 -33
- package/{template-full → base/api}/api/app.ts +52 -9
- 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 +8 -0
- package/base/api/api/server.ts +157 -0
- package/{template-full → base/api}/api/services.ts +61 -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/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 +5 -4
- 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/desktop.ts +10 -10
- package/src/index.ts +368 -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/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/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.4.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.
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// The full template: the web app's deps plus the API's, signet-db and
|
|
209
|
-
// signet-payments for plans, admin, privacy and billing, and the screens' peers.
|
|
210
|
-
const FULL_DEPS = {
|
|
211
|
-
...DEPS,
|
|
212
|
-
...API_DEPS,
|
|
213
|
-
"@base-ui/react": "^1.3.0",
|
|
214
|
-
"@dapplelight/signet-db": "^0.2.0",
|
|
215
|
-
"@dapplelight/signet-payments": "^0.1.0",
|
|
216
|
-
"drizzle-orm": "^0.45.4",
|
|
217
|
-
"input-otp": "^1.4.2",
|
|
278
|
+
vite: "^8.3.8",
|
|
218
279
|
}
|
|
219
280
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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,51 @@ 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> ${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)
|
|
344
441
|
cloudflare: Worker entry + wrangler.jsonc
|
|
345
442
|
bun: Bun.serve entry + Dockerfile
|
|
443
|
+
deno: Deno.serve entry + Dockerfile (Deno 2)
|
|
346
444
|
node: node:http entry (Node 22.18+)
|
|
347
445
|
vercel: Vercel entry + vercel.json
|
|
348
|
-
--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)
|
|
349
448
|
(default: asks when interactive, else --mcp)
|
|
350
|
-
-t, --theme <name> ${THEMES.join(" | ")} (default: editorial; web
|
|
449
|
+
-t, --theme <name> ${THEMES.join(" | ")} (default: editorial; anything with a web UI)
|
|
351
450
|
--pm <name> ${PMS.join(" | ")} (default: the one that ran this, else bun)
|
|
352
451
|
Sets the commands in CI, the README and below.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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)
|
|
356
456
|
-h, --help
|
|
357
457
|
|
|
358
458
|
Examples:
|
|
359
459
|
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
|
-
|
|
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
|
|
365
467
|
bun create-signet-app my-app --describe "a team inbox with settings and pricing"
|
|
366
468
|
`)
|
|
367
469
|
process.exit(0)
|
|
@@ -373,7 +475,24 @@ Examples:
|
|
|
373
475
|
}
|
|
374
476
|
|
|
375
477
|
if (!name) throw new Error("Missing target directory.\nUsage: create-signet-app <directory>")
|
|
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"
|
|
376
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
|
+
)
|
|
377
496
|
if (templateGiven && !DESCRIBE_TEMPLATES.includes(templateGiven))
|
|
378
497
|
throw new Error("--describe applies to --template web, api and full only.")
|
|
379
498
|
// The template and theme come from the sentence, so these are checked once they are known.
|
|
@@ -385,23 +504,52 @@ Examples:
|
|
|
385
504
|
targetGiven: target,
|
|
386
505
|
mcp,
|
|
387
506
|
pm: pm ?? detectPm(),
|
|
507
|
+
composeFlags,
|
|
388
508
|
describe: { sentence: describe, template: templateGiven, theme: themeGiven },
|
|
389
509
|
}
|
|
390
510
|
}
|
|
391
|
-
checkCombo(template, theme, target, mcp)
|
|
392
|
-
return {
|
|
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
|
+
}
|
|
393
522
|
}
|
|
394
523
|
|
|
395
|
-
/** Flags that only fit some
|
|
396
|
-
function checkCombo(
|
|
397
|
-
|
|
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
|
+
}
|
|
398
541
|
if (
|
|
399
542
|
mcp !== undefined &&
|
|
400
543
|
(template === "web" || template === "cli" || template === "extension" || template === "desktop")
|
|
401
544
|
)
|
|
402
|
-
throw new Error("--mcp / --no-mcp apply to --
|
|
403
|
-
if (theme !== "editorial" && template === "api")
|
|
404
|
-
throw new Error("--theme applies to
|
|
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.")
|
|
405
553
|
}
|
|
406
554
|
|
|
407
555
|
/** Replace placeholders in every text file under dir. */
|
|
@@ -436,6 +584,88 @@ async function askMcp(): Promise<boolean> {
|
|
|
436
584
|
}
|
|
437
585
|
}
|
|
438
586
|
|
|
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]}`)
|
|
590
|
+
const targetsDir = join(templateDir, "_targets")
|
|
591
|
+
const mcpDir = join(templateDir, "_mcp")
|
|
592
|
+
await cp(templateDir, dest, {
|
|
593
|
+
recursive: true,
|
|
594
|
+
filter: (src) => src !== targetsDir && src !== mcpDir,
|
|
595
|
+
})
|
|
596
|
+
// Only the chosen runtime's files, laid over the shared ones; MCP's tests with MCP.
|
|
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
|
+
}
|
|
604
|
+
}
|
|
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
|
+
|
|
439
669
|
async function main() {
|
|
440
670
|
const parsed = parseArgs(process.argv)
|
|
441
671
|
const { name, target, pm, ...flags } = parsed
|
|
@@ -454,35 +684,23 @@ async function main() {
|
|
|
454
684
|
;({ theme, template } = described)
|
|
455
685
|
checkCombo(template, theme, parsed.targetGiven, flags.mcp)
|
|
456
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
|
+
)
|
|
457
691
|
|
|
458
692
|
if (existsSync(dest) && (await readdir(dest)).length > 0) {
|
|
459
693
|
throw new Error(`${dest} already exists and is not empty.`)
|
|
460
694
|
}
|
|
461
695
|
|
|
462
|
-
const
|
|
463
|
-
const
|
|
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()))
|
|
464
700
|
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
|
-
}
|
|
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)
|
|
486
704
|
|
|
487
705
|
// npm strips a file literally named .gitignore from published packages, so
|
|
488
706
|
// the template ships it as _gitignore and it is renamed on scaffold.
|
|
@@ -490,7 +708,7 @@ async function main() {
|
|
|
490
708
|
// the CI workflow ships under _github.
|
|
491
709
|
await rename(join(dest, "_gitignore"), join(dest, ".gitignore"))
|
|
492
710
|
await rename(join(dest, "_github"), join(dest, ".github"))
|
|
493
|
-
if (template === "api" && target === "bun")
|
|
711
|
+
if (template === "api" && (target === "bun" || target === "deno"))
|
|
494
712
|
await rename(join(dest, "_dockerignore"), join(dest, ".dockerignore"))
|
|
495
713
|
// pnpm (10+) refuses to install until build scripts are reviewed; esbuild's
|
|
496
714
|
// (vite, drizzle-kit, wrangler) and workerd's are the ones these templates
|
|
@@ -500,6 +718,9 @@ async function main() {
|
|
|
500
718
|
join(dest, "pnpm-workspace.yaml"),
|
|
501
719
|
"allowBuilds:\n esbuild: true\n workerd: true\nonlyBuiltDependencies:\n - esbuild\n - workerd\n",
|
|
502
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")
|
|
503
724
|
const ci = join(dest, ".github/workflows/ci.yml")
|
|
504
725
|
await writeFile(ci, applyPm(await readFile(ci, "utf8"), pm))
|
|
505
726
|
|
|
@@ -512,22 +733,10 @@ async function main() {
|
|
|
512
733
|
__PM_X__: PM[pm].x,
|
|
513
734
|
})
|
|
514
735
|
|
|
515
|
-
if (
|
|
736
|
+
if (made?.env.length)
|
|
516
737
|
// The API's secrets for this machine, fresh per app; gitignored. Bun loads
|
|
517
738
|
// 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
|
-
}
|
|
739
|
+
await writeFile(join(dest, ".env"), made.env.join("\n"))
|
|
531
740
|
|
|
532
741
|
// signet-mcp's index reads the scripts below from this source by their
|
|
533
742
|
// shape: the api object first, the web object as the next literal.
|
|
@@ -541,33 +750,26 @@ async function main() {
|
|
|
541
750
|
typecheck: "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
542
751
|
test: "bun test",
|
|
543
752
|
}
|
|
544
|
-
:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
test: "bun test",
|
|
554
|
-
},
|
|
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
|
+
},
|
|
555
762
|
dependencies:
|
|
556
|
-
template === "api"
|
|
557
|
-
? { ...API_DEPS, ...(mcp ? MCP_DEPS : {}) }
|
|
558
|
-
: template === "full"
|
|
559
|
-
? { ...FULL_DEPS, ...(mcp ? MCP_DEPS : {}) }
|
|
560
|
-
: { ...DEPS, ...I18N_DEPS },
|
|
763
|
+
template === "api" ? { ...API_DEPS, ...(mcp ? MCP_DEPS : {}) } : { ...DEPS, ...I18N_DEPS },
|
|
561
764
|
devDependencies:
|
|
562
765
|
template === "api"
|
|
563
766
|
? { ...API_DEV_DEPS, ...API_TARGETS[target].devDeps }
|
|
564
|
-
:
|
|
565
|
-
? FULL_DEV_DEPS
|
|
566
|
-
: { ...DEV_DEPS, ...PWA_DEV_DEPS },
|
|
767
|
+
: { ...DEV_DEPS, ...PWA_DEV_DEPS },
|
|
567
768
|
...(template === "api" && API_TARGETS[target].engines
|
|
568
769
|
? { engines: API_TARGETS[target].engines }
|
|
569
770
|
: {}),
|
|
570
771
|
}
|
|
772
|
+
if (made) Object.assign(pkg, made.pkg)
|
|
571
773
|
if (template === "extension")
|
|
572
774
|
Object.assign(pkg, {
|
|
573
775
|
scripts: EXT_SCRIPTS,
|
|
@@ -579,22 +781,23 @@ async function main() {
|
|
|
579
781
|
template === "cli"
|
|
580
782
|
? JSON.parse(JSON.stringify(CLI_PKG).replaceAll("__APP_NAME__", appName))
|
|
581
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 })
|
|
582
797
|
await writeFile(
|
|
583
798
|
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`,
|
|
799
|
+
`${JSON.stringify(out, null, 2)}
|
|
800
|
+
`,
|
|
598
801
|
)
|
|
599
802
|
|
|
600
803
|
const { install, run } = PM[pm]
|
|
@@ -643,17 +846,8 @@ async function main() {
|
|
|
643
846
|
Needs Rust and Tauri's system dependencies. README.md covers sign-in (register
|
|
644
847
|
the client on signet-server) and the identifier in src-tauri/tauri.conf.json.
|
|
645
848
|
`
|
|
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
|
-
`
|
|
849
|
+
: composed
|
|
850
|
+
? composedMessage(appName, theme, steps, composed)
|
|
657
851
|
: `
|
|
658
852
|
Created ${appName} with the ${theme} theme.
|
|
659
853
|
|