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.
Files changed (99) hide show
  1. package/README.md +133 -33
  2. package/{template-full → base/api}/api/app.ts +105 -13
  3. package/base/api/api/db/open.ts +121 -0
  4. package/{template-full → base/api}/api/db/schema.ts +34 -7
  5. package/{template-full → base/api}/api/env.ts +16 -0
  6. package/base/api/api/server.ts +163 -0
  7. package/{template-full → base/api}/api/services.ts +103 -10
  8. package/base/api/drizzle/0002_ai_paywalls_workflows.sql +77 -0
  9. package/base/api/drizzle/meta/0002_snapshot.json +1759 -0
  10. package/{template-full → base/api}/drizzle/meta/_journal.json +7 -0
  11. package/base/api/test/api.test.ts +51 -0
  12. package/base/api/test/helpers.ts +51 -0
  13. package/base/both/scripts/dev.ts +44 -0
  14. package/base/shared/README.md +385 -0
  15. package/{template-full → base/shared}/_github/workflows/ci.yml +1 -1
  16. package/{template-full → base/web}/src/lib/api.ts +28 -1
  17. package/{template-full → base/web}/src/main.tsx +4 -1
  18. package/{template-full → base/web}/src/routeTree.gen.ts +155 -90
  19. package/{template-full → base/web}/src/router.test.ts +13 -9
  20. package/base/web/src/routes/_app/index.tsx +55 -0
  21. package/{template-full → base/web}/src/routes/_app.tsx +40 -16
  22. package/{template-full → base/web}/vite.config.ts +3 -1
  23. package/package.json +9 -5
  24. package/parts/account/api/test/account.test.ts +30 -0
  25. package/parts/account/part.ts +6 -0
  26. package/parts/admin/api/test/admin.test.ts +35 -0
  27. package/parts/admin/part.ts +6 -0
  28. package/{template-full → parts/admin/web}/src/routes/_app/admin.tsx +2 -1
  29. package/parts/ai/api/api/routes/ai.ts +28 -0
  30. package/parts/ai/api/test/ai.test.ts +52 -0
  31. package/parts/ai/part.ts +16 -0
  32. package/{template-full → parts/auth/api}/api/routes/account.ts +32 -3
  33. package/{template-full → parts/auth/api}/api/routes/auth.ts +5 -3
  34. package/parts/auth/api/test/auth.test.ts +28 -0
  35. package/{template-full → parts/auth/both}/e2e/smoke.spec.ts +21 -7
  36. package/parts/auth/part.ts +22 -0
  37. package/parts/growth/part.ts +7 -0
  38. package/{template-full/_mcp → parts/mcp/api}/test/mcp.test.ts +25 -16
  39. package/parts/mcp/part.ts +8 -0
  40. package/parts/notifications/api/test/notifications.test.ts +18 -0
  41. package/parts/notifications/part.ts +6 -0
  42. package/{template-full → parts/notifications/web}/src/routes/_app/notifications.tsx +1 -1
  43. package/parts/orgs/api/test/orgs.test.ts +56 -0
  44. package/parts/orgs/part.ts +7 -0
  45. package/{template-full → parts/payments/api}/api/routes/billing.ts +3 -2
  46. package/parts/payments/api/test/payments.test.ts +31 -0
  47. package/parts/payments/part.ts +12 -0
  48. package/{template-full → parts/payments/web}/src/routes/_app/billing.tsx +6 -3
  49. package/parts/paywalls/api/api/routes/paywall.ts +126 -0
  50. package/parts/paywalls/api/test/paywalls.test.ts +71 -0
  51. package/parts/paywalls/part.ts +8 -0
  52. package/parts/privacy/api/test/privacy.test.ts +20 -0
  53. package/parts/privacy/part.ts +7 -0
  54. package/parts/workflows/api/api/workflows.ts +33 -0
  55. package/parts/workflows/api/test/workflows.test.ts +44 -0
  56. package/parts/workflows/part.ts +7 -0
  57. package/parts/workflows/web/src/routes/_app/approvals.tsx +34 -0
  58. package/src/compose.ts +426 -0
  59. package/src/desktop.ts +10 -10
  60. package/src/index.ts +407 -174
  61. package/template-api/_targets/deno/Dockerfile +12 -0
  62. package/template-api/_targets/deno/_dockerignore +10 -0
  63. package/template-api/_targets/deno/src/server.ts +43 -0
  64. package/template-full/README.md +0 -166
  65. package/template-full/api/db/open.ts +0 -33
  66. package/template-full/api/server.ts +0 -50
  67. package/template-full/scripts/dev.ts +0 -17
  68. package/template-full/src/routes/_app/index.tsx +0 -33
  69. package/template-full/test/api.test.ts +0 -238
  70. package/template-full/tsconfig.json +0 -9
  71. /package/{template-full → base/api}/api/db/index.ts +0 -0
  72. /package/{template-full → base/api}/api/db/kv.ts +0 -0
  73. /package/{template-full → base/api}/drizzle/0000_init.sql +0 -0
  74. /package/{template-full → base/api}/drizzle/0001_orgs.sql +0 -0
  75. /package/{template-full → base/api}/drizzle/meta/0000_snapshot.json +0 -0
  76. /package/{template-full → base/api}/drizzle/meta/0001_snapshot.json +0 -0
  77. /package/{template-full → base/api}/drizzle.config.ts +0 -0
  78. /package/{template-full → base/api}/tsconfig.api.json +0 -0
  79. /package/{template-full → base/shared}/_gitignore +0 -0
  80. /package/{template-full → base/shared}/biome.json +0 -0
  81. /package/{template-full → base/web}/index.html +0 -0
  82. /package/{template-full → base/web}/src/app.css +0 -0
  83. /package/{template-full → base/web}/src/components/toaster.tsx +0 -0
  84. /package/{template-full → base/web}/src/router.ts +0 -0
  85. /package/{template-full → base/web}/src/routes/__root.tsx +0 -0
  86. /package/{template-full → base/web}/tsconfig.app.json +0 -0
  87. /package/{template-full → base/web}/tsconfig.node.json +0 -0
  88. /package/{template-full → base/web}/tsconfig.test.json +0 -0
  89. /package/{template-full → parts/account/web}/src/routes/_app/account.tsx +0 -0
  90. /package/{template-full → parts/auth/both}/playwright.config.ts +0 -0
  91. /package/{template-full → parts/auth/web}/src/routes/login.tsx +0 -0
  92. /package/{template-full → parts/notifications/api}/api/routes/notifications.ts +0 -0
  93. /package/{template-full → parts/orgs/web}/src/routes/_app/org/index.tsx +0 -0
  94. /package/{template-full → parts/orgs/web}/src/routes/_app/org/members.tsx +0 -0
  95. /package/{template-full → parts/orgs/web}/src/routes/_app/org/new.tsx +0 -0
  96. /package/{template-full → parts/orgs/web}/src/routes/invite.$token.tsx +0 -0
  97. /package/{template-full → parts/payments/api}/api/plans.ts +0 -0
  98. /package/{template-full → parts/privacy/api}/api/routes/privacy.ts +0 -0
  99. /package/{template-full → parts/privacy/web}/src/routes/_app/privacy.tsx +0 -0
package/src/compose.ts ADDED
@@ -0,0 +1,426 @@
1
+ /**
2
+ * The composer: an app is surfaces (web, api or both) plus parts. Files come
3
+ * from base/ and each selected part's folder, in halves:
4
+ *
5
+ * shared/ always web/ with the web surface
6
+ * api/ with the api both/ with both surfaces
7
+ *
8
+ * each laid over the app root. Code shared between parts (api/app.ts, the
9
+ * schema, services, the shell, the route tree) lives in base/ once, with each
10
+ * part's lines marked; `applyBlocks` keeps the lines of what was chosen and
11
+ * drops the markers, so the app carries no trace of the parts it left out.
12
+ */
13
+
14
+ import { existsSync } from "node:fs"
15
+ import { cp, readdir, readFile, rm, writeFile } from "node:fs/promises"
16
+ import { join, resolve } from "node:path"
17
+ import account from "../parts/account/part.js"
18
+ import admin from "../parts/admin/part.js"
19
+ import ai from "../parts/ai/part.js"
20
+ import auth from "../parts/auth/part.js"
21
+ import growth from "../parts/growth/part.js"
22
+ import mcp from "../parts/mcp/part.js"
23
+ import notifications from "../parts/notifications/part.js"
24
+ import orgs from "../parts/orgs/part.js"
25
+ import payments from "../parts/payments/part.js"
26
+ import paywalls from "../parts/paywalls/part.js"
27
+ import privacy from "../parts/privacy/part.js"
28
+ import workflows from "../parts/workflows/part.js"
29
+
30
+ type Deps = Record<string, string>
31
+
32
+ /** What one part adds, besides its files. Its code in shared files is marked `// <name>:begin`. */
33
+ export type Part = {
34
+ /** One line, for --help. */
35
+ description: string
36
+ /** Parts it cannot work without; added for you. */
37
+ needs?: PartName[]
38
+ /** Needs the API surface (it has no web half). */
39
+ apiOnly?: boolean
40
+ web?: { deps?: Deps }
41
+ api?: { deps?: Deps }
42
+ /** With both surfaces: dev deps and scripts (the browser test). */
43
+ both?: { devDeps?: Deps; scripts?: Record<string, string> }
44
+ /** Lines for the generated env file. A function, so secrets are fresh per app. */
45
+ env?: () => string[]
46
+ /**
47
+ * SQL tables its schema adds: the migrations keep only the chosen parts'
48
+ * tables. Two parts may list one table; it stays when either is chosen.
49
+ */
50
+ tables?: string[]
51
+ /** API files the web half also reads; a UI-only app gets a copy at the mapped path. */
52
+ uiCopies?: Record<string, string>
53
+ }
54
+
55
+ /** In dependency order: a part comes after what it needs. */
56
+ export const PART_NAMES = [
57
+ "auth",
58
+ "account",
59
+ "orgs",
60
+ "admin",
61
+ "notifications",
62
+ "privacy",
63
+ "payments",
64
+ "paywalls",
65
+ "growth",
66
+ "ai",
67
+ "workflows",
68
+ "mcp",
69
+ ] as const
70
+ export type PartName = (typeof PART_NAMES)[number]
71
+ export const PARTS: Record<PartName, Part> = {
72
+ auth,
73
+ account,
74
+ orgs,
75
+ admin,
76
+ notifications,
77
+ privacy,
78
+ payments,
79
+ paywalls,
80
+ growth,
81
+ ai,
82
+ workflows,
83
+ mcp,
84
+ }
85
+
86
+ /**
87
+ * A named mix of parts, by the shape of app, never its domain. `full` is
88
+ * everything the full template had; `blank` is the base alone (the shell, the
89
+ * API, the database), for parts of your own. Needs are added for you (admin
90
+ * brings orgs, everything brings auth). `surface: "api"` is the API half only.
91
+ * MCP is not listed: it is asked for (or --mcp / --no-mcp), as it always was.
92
+ * Each description is one line, quoted, first: signet-mcp's index reads it.
93
+ */
94
+ export const STARTERS = {
95
+ full: { description: "every part, web + API", parts: PART_NAMES.filter((p) => p !== "mcp") },
96
+ blank: { description: "no parts: the shell, the API and the database", parts: [] },
97
+ saas: {
98
+ description: "a paid team product: orgs, admin, billing, inbox, account, privacy",
99
+ parts: ["account", "orgs", "admin", "notifications", "privacy", "payments"],
100
+ },
101
+ launch: {
102
+ description: "before launch: sign-in, waitlist, invites, referrals, feedback, privacy",
103
+ parts: ["account", "privacy", "growth"],
104
+ },
105
+ "internal-tool": {
106
+ description: "for your own team: orgs and roles, the admin panel, approval workflows",
107
+ parts: ["account", "orgs", "admin", "workflows"],
108
+ },
109
+ api: {
110
+ description: "the API half only: sign-in, API keys, billing webhooks",
111
+ parts: ["account", "payments"],
112
+ surface: "api",
113
+ },
114
+ "ai-app": {
115
+ description: "an AI product: spend caps per user, billing, account, privacy",
116
+ parts: ["account", "privacy", "payments", "ai"],
117
+ },
118
+ paywall: {
119
+ description: "sell access: plans, entitlements, billing, remote paywalls",
120
+ parts: ["account", "payments", "paywalls"],
121
+ },
122
+ automation: {
123
+ description: "durable workflows with approvals, and an inbox to tell people",
124
+ parts: ["account", "notifications", "workflows"],
125
+ },
126
+ } satisfies Record<string, { description: string; parts: PartName[]; surface?: "api" }>
127
+ export type StarterName = keyof typeof STARTERS
128
+
129
+ /**
130
+ * The chosen parts plus everything they need, in PARTS order, and what was
131
+ * added for a need. Throws on an unknown part or a need that was excluded.
132
+ */
133
+ export function resolveParts(
134
+ chosen: string[],
135
+ without: string[],
136
+ ): { parts: PartName[]; added: { part: PartName; for: PartName }[] } {
137
+ for (const p of [...chosen, ...without])
138
+ if (!PART_NAMES.includes(p as PartName))
139
+ throw new Error(`Unknown part "${p}". Available: ${PART_NAMES.join(", ")}`)
140
+ const both = chosen.filter((p) => without.includes(p))
141
+ if (both.length) throw new Error(`"${both[0]}" is in both --with and --without.`)
142
+ const set = new Set(chosen as PartName[])
143
+ const added: { part: PartName; for: PartName }[] = []
144
+ // ponytail: needs are at most two deep, so a few passes settle; a cycle would be a bug in a manifest.
145
+ for (let pass = 0; pass < PART_NAMES.length; pass++)
146
+ for (const p of [...set])
147
+ for (const need of (PARTS[p] as Part).needs ?? []) {
148
+ if (without.includes(need))
149
+ throw new Error(`${p} needs ${need}: drop --without ${need}, or leave ${p} out.`)
150
+ if (!set.has(need)) {
151
+ set.add(need)
152
+ added.push({ part: need, for: p })
153
+ }
154
+ }
155
+ return { parts: PART_NAMES.filter((p) => set.has(p)), added }
156
+ }
157
+
158
+ /** What runs the API: bun (bun:sqlite, Bun.serve), or deno or node (node:sqlite, node:http). */
159
+ export const RUNTIMES = ["bun", "deno", "node"] as const
160
+ export type Runtime = (typeof RUNTIMES)[number]
161
+
162
+ /** How each runtime runs a TypeScript file, with the app's env file loaded. */
163
+ const RUN: Record<Runtime, string> = {
164
+ bun: "bun",
165
+ deno: "deno run -A --env-file=.env",
166
+ node: "node --env-file-if-exists=.env",
167
+ }
168
+
169
+ const MARKER_NAMES = new Set<string>([...PART_NAMES, "web", "api", ...RUNTIMES])
170
+ const BLOCK = /^\s*(?:\/\/|\{\/\*|<!--|#)\s*(!?[\w|-]+):(begin|end)\s*(?:\*\/\}|-->)?\s*$/
171
+ const TAG =
172
+ /\s+(?:\/\/\s*@(!?[\w|-]+)|#\s*@(!?[\w|-]+)|\{\/\*\s*@(!?[\w|-]+)\s*\*\/\}|<!--\s*@(!?[\w|-]+)\s*-->)\s*$/
173
+
174
+ /**
175
+ * Keep what applies, drop the markers. A block is the lines between
176
+ * `// name:begin` and `// name:end` (also `{/* name:begin *\/}`, `<!-- … -->`,
177
+ * `# …`); blocks nest. A line ending in `// @name` is that one line. `!name`
178
+ * means "without name"; `a|b` means "with a or b", `!a|b` "with neither". Names are parts and the
179
+ * surfaces, `web` and `api`.
180
+ */
181
+ export function applyBlocks(text: string, on: ReadonlySet<string>): string {
182
+ const name = (c: string) => c.replace(/^!/, "")
183
+ // Only our names are markers, so a stray `// @ts-expect-error` stays put.
184
+ const known = (c: string) =>
185
+ name(c)
186
+ .split("|")
187
+ .every((n) => MARKER_NAMES.has(n))
188
+ const holds = (c: string) =>
189
+ c.startsWith("!")
190
+ ? !name(c)
191
+ .split("|")
192
+ .some((n) => on.has(n))
193
+ : c.split("|").some((n) => on.has(n))
194
+ const open: boolean[] = []
195
+ const out: string[] = []
196
+ for (const line of text.split("\n")) {
197
+ const block = BLOCK.exec(line)
198
+ if (block && known(block[1] as string)) {
199
+ if (block[2] === "begin") open.push(holds(block[1] as string))
200
+ else if (open.pop() === undefined) throw new Error(`Unmatched marker: ${line.trim()}`)
201
+ continue
202
+ }
203
+ if (!open.every(Boolean)) continue
204
+ const tag = TAG.exec(line)
205
+ const cond = tag && (tag[1] ?? tag[2] ?? tag[3] ?? tag[4])
206
+ if (!tag || !cond || !known(cond) || !line.slice(0, tag.index).trim()) out.push(line)
207
+ else if (holds(cond)) out.push(line.slice(0, tag.index))
208
+ }
209
+ if (open.length) throw new Error(`Unclosed marker (${open.length} open)`)
210
+ return out.join("\n")
211
+ }
212
+
213
+ /**
214
+ * The blank lines a dropped block leaves, gone the way the formatter would
215
+ * have it: none at the top or bottom, never two in a row, none just inside brackets.
216
+ */
217
+ export function tidy(text: string): string {
218
+ return text
219
+ .replace(/^\n+/, "")
220
+ .replace(/\n{2,}$/, "\n")
221
+ .replace(/\n{3,}/g, "\n\n")
222
+ .replace(/([{([]|=>)\n\n/g, "$1\n")
223
+ .replace(/\n\n(\s*[})\]])/g, "\n$1")
224
+ }
225
+
226
+ /** Every file under dir, relative to it. */
227
+ async function walk(dir: string, base = dir): Promise<string[]> {
228
+ const out: string[] = []
229
+ for (const e of await readdir(dir, { withFileTypes: true })) {
230
+ const full = join(dir, e.name)
231
+ if (e.isDirectory()) out.push(...(await walk(full, base)))
232
+ else out.push(full.slice(base.length + 1))
233
+ }
234
+ return out
235
+ }
236
+
237
+ /** The tables a left-out part lists, less any a chosen part also lists (usage_counters: payments and ai). */
238
+ export function droppedTables(parts: readonly PartName[]): Set<string> {
239
+ const kept = new Set(parts.flatMap((p) => (PARTS[p] as Part).tables ?? []))
240
+ return new Set(
241
+ PART_NAMES.filter((p) => !parts.includes(p))
242
+ .flatMap((p) => (PARTS[p] as Part).tables ?? [])
243
+ .filter((t) => !kept.has(t)),
244
+ )
245
+ }
246
+
247
+ /**
248
+ * Keep the chosen parts' tables in drizzle/: drop each statement on a table
249
+ * of a part left out, and the table from the snapshot. A migration left with
250
+ * no statements goes, with its snapshot and journal entry; the ones after it
251
+ * move up a number and link to the snapshot before, so the next `db:generate`
252
+ * neither reuses a number nor finds a broken chain.
253
+ */
254
+ export async function filterMigrations(dir: string, dropTables: Set<string>) {
255
+ if (!dropTables.size) return
256
+ const journalPath = join(dir, "meta/_journal.json")
257
+ const journal = JSON.parse(await readFile(journalPath, "utf8")) as {
258
+ entries: { idx: number; tag: string }[]
259
+ }
260
+ const keep: typeof journal.entries = []
261
+ let prevId: string | undefined
262
+ for (const entry of journal.entries) {
263
+ const sqlPath = join(dir, `${entry.tag}.sql`)
264
+ const snapPath = join(dir, `meta/${entry.tag.slice(0, 4)}_snapshot.json`)
265
+ const text = await readFile(sqlPath, "utf8")
266
+ const statements = text.split("--> statement-breakpoint")
267
+ const kept = statements.filter((s) => {
268
+ const table = /CREATE TABLE `(\w+)`/.exec(s)?.[1] ?? / ON `(\w+)`/.exec(s)?.[1]
269
+ return !table || !dropTables.has(table)
270
+ })
271
+ await rm(sqlPath)
272
+ if (!kept.some((s) => s.trim())) {
273
+ await rm(snapPath)
274
+ continue
275
+ }
276
+ // Snapshots are cumulative: a later one still lists an earlier one's tables.
277
+ const snap = JSON.parse(await readFile(snapPath, "utf8")) as {
278
+ id: string
279
+ prevId: string
280
+ tables: Record<string, unknown>
281
+ }
282
+ await rm(snapPath)
283
+ for (const t of dropTables) delete snap.tables[t]
284
+ if (prevId !== undefined) snap.prevId = prevId
285
+ prevId = snap.id
286
+ const n = String(keep.length).padStart(4, "0")
287
+ const tag = `${n}${entry.tag.slice(4)}`
288
+ await writeFile(
289
+ join(dir, `${tag}.sql`),
290
+ kept.length === statements.length ? text : kept.join("--> statement-breakpoint").trim(),
291
+ )
292
+ await writeFile(join(dir, `meta/${n}_snapshot.json`), JSON.stringify(snap, null, 2))
293
+ keep.push({ ...entry, idx: keep.length, tag })
294
+ }
295
+ journal.entries = keep
296
+ await writeFile(journalPath, JSON.stringify(journal, null, 2))
297
+ }
298
+
299
+ export type ComposeOptions = {
300
+ parts: PartName[]
301
+ web: boolean
302
+ api: boolean
303
+ runtime?: Runtime
304
+ }
305
+
306
+ /** The base's own dependencies per surface, from index.ts (signet-mcp's index reads them there). */
307
+ export type BaseDeps = {
308
+ web: { deps: Deps; devDeps: Deps }
309
+ api: { deps: Deps; devDeps: Deps }
310
+ }
311
+
312
+ const ROOT = resolve(import.meta.dirname, "..")
313
+ const sorted = (o: Deps) =>
314
+ Object.fromEntries(Object.entries(o).sort(([a], [b]) => a.localeCompare(b)))
315
+
316
+ /**
317
+ * Lay the base and the chosen parts' files into dest and resolve their
318
+ * markers. Returns the package.json body and the env file lines.
319
+ */
320
+ export async function compose(
321
+ dest: string,
322
+ { parts, web, api, runtime = "bun" }: ComposeOptions,
323
+ base: BaseDeps,
324
+ ) {
325
+ const halves = ["shared", ...(web ? ["web"] : []), ...(api ? ["api"] : [])]
326
+ if (web && api) halves.push("both")
327
+ for (const dir of ["base", ...parts.map((p) => `parts/${p}`)])
328
+ for (const half of halves) {
329
+ const src = join(ROOT, dir, half)
330
+ if (existsSync(src)) await cp(src, dest, { recursive: true })
331
+ }
332
+ const chosen = parts.map((p) => PARTS[p] as Part)
333
+ if (!api)
334
+ for (const p of parts)
335
+ for (const [from, to] of Object.entries((PARTS[p] as Part).uiCopies ?? {}))
336
+ await cp(join(ROOT, "parts", p, "api", from), join(dest, to))
337
+
338
+ const on = new Set<string>([...parts, ...(web ? ["web"] : []), ...(api ? ["api", runtime] : [])])
339
+ for (const f of await walk(dest)) {
340
+ const path = join(dest, f)
341
+ const text = await readFile(path, "utf8")
342
+ let out = applyBlocks(text, on)
343
+ if (out === text) continue
344
+ // Code only: in Markdown a blank line before `)` or after `(` can matter.
345
+ if (/\.(tsx?|json)$/.test(f)) out = tidy(out)
346
+ await writeFile(path, out.replace(/^\n+/, "").replace(/\n{3,}/g, "\n\n"))
347
+ }
348
+
349
+ if (api) await filterMigrations(join(dest, "drizzle"), droppedTables(parts))
350
+
351
+ const refs = [...(web ? ["app", "node", "test"] : []), ...(api ? ["api"] : [])]
352
+ const ref = (r: string) => `{ "path": "./tsconfig.${r}.json" }`
353
+ await writeFile(
354
+ join(dest, "tsconfig.json"),
355
+ `{\n "files": [],\n "references": ${
356
+ refs.length > 1
357
+ ? `[\n${refs.map((r) => ` ${ref(r)}`).join(",\n")}\n ]`
358
+ : `[${ref(refs[0] as string)}]`
359
+ }\n}\n`,
360
+ )
361
+
362
+ const deps: Deps = {}
363
+ const devDeps: Deps = {}
364
+ for (const [on, b] of [
365
+ [web, base.web],
366
+ [api, base.api],
367
+ ] as const) {
368
+ if (!on) continue
369
+ Object.assign(deps, b.deps)
370
+ Object.assign(devDeps, b.devDeps)
371
+ }
372
+ for (const p of chosen) {
373
+ if (web) Object.assign(deps, p.web?.deps)
374
+ if (api) Object.assign(deps, p.api?.deps)
375
+ if (web && api) Object.assign(devDeps, p.both?.devDeps)
376
+ }
377
+ const scripts: Record<string, string> =
378
+ web && api
379
+ ? {
380
+ // Both halves: the API (restarting on change) and Vite, which proxies /api to it.
381
+ dev: `${RUN[runtime]} scripts/dev.ts`,
382
+ build: "tsc -b && vite build",
383
+ // One process serves the API and the built app from dist/.
384
+ start: `${RUN[runtime]} api/server.ts`,
385
+ preview: "vite preview",
386
+ lint: "biome check .",
387
+ format: "biome check --write .",
388
+ typecheck: "tsc -b --noEmit",
389
+ test: "bun test src test",
390
+ ...Object.assign({}, ...chosen.map((p) => p.both?.scripts)),
391
+ }
392
+ : web
393
+ ? {
394
+ dev: "vite",
395
+ build: "tsc -b && vite build",
396
+ preview: "vite preview",
397
+ lint: "biome check .",
398
+ format: "biome check --write .",
399
+ typecheck: "tsc -b --noEmit",
400
+ test: "bun test src",
401
+ }
402
+ : {
403
+ dev: `${RUN[runtime]} --watch api/server.ts`,
404
+ start: `${RUN[runtime]} api/server.ts`,
405
+ lint: "biome check .",
406
+ format: "biome check --write .",
407
+ typecheck: "tsc -b --noEmit",
408
+ test: "bun test test",
409
+ }
410
+ if (api)
411
+ Object.assign(scripts, {
412
+ "db:generate": "drizzle-kit generate",
413
+ "db:check": "signet-db-check drizzle",
414
+ })
415
+
416
+ return {
417
+ pkg: {
418
+ scripts,
419
+ dependencies: sorted(deps),
420
+ devDependencies: sorted(devDeps),
421
+ // Runs api/server.ts as is: type stripping is on by default from 22.18.
422
+ ...(api && runtime === "node" ? { engines: { node: ">=22.18" } } : {}),
423
+ },
424
+ env: api ? ["APP_ENV=development", ...chosen.flatMap((p) => p.env?.() ?? []), ""] : [],
425
+ }
426
+ }
package/src/desktop.ts CHANGED
@@ -23,28 +23,28 @@ export const DESKTOP_PKG = {
23
23
  dependencies: {
24
24
  "@dapplelight/signet-lib": "^0.4.1",
25
25
  "@dapplelight/signet-tokens": "^0.4.0",
26
- "@dapplelight/signet-ui": "^0.3.0",
26
+ "@dapplelight/signet-ui": "^0.5.0",
27
27
  "@tauri-apps/api": "^2.0.0",
28
28
  "@tauri-apps/plugin-opener": "^2.0.0",
29
29
  "@tauri-apps/plugin-store": "^2.0.0",
30
30
  "class-variance-authority": "^0.7.1",
31
31
  clsx: "^2.1.1",
32
- "lucide-react": "^1.47.0",
33
- react: "^19.3.0",
34
- "react-dom": "^19.3.0",
32
+ "lucide-react": "^1.74.0",
33
+ react: "^19.3.1",
34
+ "react-dom": "^19.3.1",
35
35
  "tailwind-merge": "^3.7.0",
36
36
  },
37
37
  devDependencies: {
38
38
  "@biomejs/biome": "^2.5.14",
39
- "@tailwindcss/vite": "^4.3.3",
39
+ "@tailwindcss/vite": "^4.3.5",
40
40
  "@tauri-apps/cli": "^2.0.0",
41
- "@types/bun": "^1.4.2",
42
- "@types/node": "^26.6.2",
41
+ "@types/bun": "^1.4.4",
42
+ "@types/node": "^26.6.6",
43
43
  "@types/react": "^19.3.0",
44
44
  "@types/react-dom": "^19.3.0",
45
- "@vitejs/plugin-react": "^6.1.1",
46
- tailwindcss: "^4.3.3",
45
+ "@vitejs/plugin-react": "^6.3.0",
46
+ tailwindcss: "^4.3.5",
47
47
  typescript: "^7.0.2",
48
- vite: "^8.3.0",
48
+ vite: "^8.3.8",
49
49
  },
50
50
  }