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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { app, post, signIn } from "./helpers.ts"
|
|
3
|
+
|
|
4
|
+
test("consent is given and withdrawn; an erasure request opens", async () => {
|
|
5
|
+
const cookie = await signIn("+919000000004")
|
|
6
|
+
expect((await post("/api/privacy/consents/analytics", {}, cookie)).status).toBe(200)
|
|
7
|
+
// A browser sends Origin on a DELETE; the CSRF guard refuses one without it.
|
|
8
|
+
const withdraw = await app.request("/api/privacy/consents/analytics", {
|
|
9
|
+
method: "DELETE",
|
|
10
|
+
headers: { cookie, origin: "http://localhost" },
|
|
11
|
+
})
|
|
12
|
+
expect(withdraw.status).toBe(200)
|
|
13
|
+
expect((await post("/api/privacy/requests", { kind: "erasure" }, cookie)).status).toBe(201)
|
|
14
|
+
const p = (await (await app.request("/api/privacy", { headers: { cookie } })).json()) as {
|
|
15
|
+
consents: { withdrawnAt: string | null }[]
|
|
16
|
+
requests: { kind: string }[]
|
|
17
|
+
}
|
|
18
|
+
expect(p.consents[0]?.withdrawnAt).not.toBeNull()
|
|
19
|
+
expect(p.requests[0]?.kind).toBe("erasure")
|
|
20
|
+
})
|
package/src/compose.ts
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
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 auth from "../parts/auth/part.js"
|
|
20
|
+
import growth from "../parts/growth/part.js"
|
|
21
|
+
import mcp from "../parts/mcp/part.js"
|
|
22
|
+
import notifications from "../parts/notifications/part.js"
|
|
23
|
+
import orgs from "../parts/orgs/part.js"
|
|
24
|
+
import payments from "../parts/payments/part.js"
|
|
25
|
+
import privacy from "../parts/privacy/part.js"
|
|
26
|
+
|
|
27
|
+
type Deps = Record<string, string>
|
|
28
|
+
|
|
29
|
+
/** What one part adds, besides its files. Its code in shared files is marked `// <name>:begin`. */
|
|
30
|
+
export type Part = {
|
|
31
|
+
/** One line, for --help. */
|
|
32
|
+
description: string
|
|
33
|
+
/** Parts it cannot work without; added for you. */
|
|
34
|
+
needs?: PartName[]
|
|
35
|
+
/** Needs the API surface (it has no web half). */
|
|
36
|
+
apiOnly?: boolean
|
|
37
|
+
web?: { deps?: Deps }
|
|
38
|
+
api?: { deps?: Deps }
|
|
39
|
+
/** With both surfaces: dev deps and scripts (the browser test). */
|
|
40
|
+
both?: { devDeps?: Deps; scripts?: Record<string, string> }
|
|
41
|
+
/** Lines for the generated env file. A function, so secrets are fresh per app. */
|
|
42
|
+
env?: () => string[]
|
|
43
|
+
/** SQL tables its schema adds: the migrations keep only the chosen parts' tables. */
|
|
44
|
+
tables?: string[]
|
|
45
|
+
/** API files the web half also reads; a UI-only app gets a copy at the mapped path. */
|
|
46
|
+
uiCopies?: Record<string, string>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** In dependency order: a part comes after what it needs. */
|
|
50
|
+
export const PART_NAMES = [
|
|
51
|
+
"auth",
|
|
52
|
+
"account",
|
|
53
|
+
"orgs",
|
|
54
|
+
"admin",
|
|
55
|
+
"notifications",
|
|
56
|
+
"privacy",
|
|
57
|
+
"payments",
|
|
58
|
+
"growth",
|
|
59
|
+
"mcp",
|
|
60
|
+
] as const
|
|
61
|
+
export type PartName = (typeof PART_NAMES)[number]
|
|
62
|
+
export const PARTS: Record<PartName, Part> = {
|
|
63
|
+
auth,
|
|
64
|
+
account,
|
|
65
|
+
orgs,
|
|
66
|
+
admin,
|
|
67
|
+
notifications,
|
|
68
|
+
privacy,
|
|
69
|
+
payments,
|
|
70
|
+
growth,
|
|
71
|
+
mcp,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A named mix of parts. `full` is everything the full template had; `blank`
|
|
76
|
+
* is the base alone (the shell, the API, the database), for parts of your own.
|
|
77
|
+
* MCP is not listed: it is asked for (or --mcp / --no-mcp), as it always was.
|
|
78
|
+
*/
|
|
79
|
+
export const STARTERS = {
|
|
80
|
+
full: { parts: PART_NAMES.filter((p) => p !== "mcp") },
|
|
81
|
+
blank: { parts: [] },
|
|
82
|
+
} satisfies Record<string, { parts: PartName[] }>
|
|
83
|
+
export type StarterName = keyof typeof STARTERS
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The chosen parts plus everything they need, in PARTS order, and what was
|
|
87
|
+
* added for a need. Throws on an unknown part or a need that was excluded.
|
|
88
|
+
*/
|
|
89
|
+
export function resolveParts(
|
|
90
|
+
chosen: string[],
|
|
91
|
+
without: string[],
|
|
92
|
+
): { parts: PartName[]; added: { part: PartName; for: PartName }[] } {
|
|
93
|
+
for (const p of [...chosen, ...without])
|
|
94
|
+
if (!PART_NAMES.includes(p as PartName))
|
|
95
|
+
throw new Error(`Unknown part "${p}". Available: ${PART_NAMES.join(", ")}`)
|
|
96
|
+
const both = chosen.filter((p) => without.includes(p))
|
|
97
|
+
if (both.length) throw new Error(`"${both[0]}" is in both --with and --without.`)
|
|
98
|
+
const set = new Set(chosen as PartName[])
|
|
99
|
+
const added: { part: PartName; for: PartName }[] = []
|
|
100
|
+
// ponytail: needs are at most two deep, so a few passes settle; a cycle would be a bug in a manifest.
|
|
101
|
+
for (let pass = 0; pass < PART_NAMES.length; pass++)
|
|
102
|
+
for (const p of [...set])
|
|
103
|
+
for (const need of (PARTS[p] as Part).needs ?? []) {
|
|
104
|
+
if (without.includes(need))
|
|
105
|
+
throw new Error(`${p} needs ${need}: drop --without ${need}, or leave ${p} out.`)
|
|
106
|
+
if (!set.has(need)) {
|
|
107
|
+
set.add(need)
|
|
108
|
+
added.push({ part: need, for: p })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { parts: PART_NAMES.filter((p) => set.has(p)), added }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** What runs the API: bun (bun:sqlite, Bun.serve), or deno or node (node:sqlite, node:http). */
|
|
115
|
+
export const RUNTIMES = ["bun", "deno", "node"] as const
|
|
116
|
+
export type Runtime = (typeof RUNTIMES)[number]
|
|
117
|
+
|
|
118
|
+
/** How each runtime runs a TypeScript file, with the app's env file loaded. */
|
|
119
|
+
const RUN: Record<Runtime, string> = {
|
|
120
|
+
bun: "bun",
|
|
121
|
+
deno: "deno run -A --env-file=.env",
|
|
122
|
+
node: "node --env-file-if-exists=.env",
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const MARKER_NAMES = new Set<string>([...PART_NAMES, "web", "api", ...RUNTIMES])
|
|
126
|
+
const BLOCK = /^\s*(?:\/\/|\{\/\*|<!--|#)\s*(!?[\w|-]+):(begin|end)\s*(?:\*\/\}|-->)?\s*$/
|
|
127
|
+
const TAG =
|
|
128
|
+
/\s+(?:\/\/\s*@(!?[\w|-]+)|#\s*@(!?[\w|-]+)|\{\/\*\s*@(!?[\w|-]+)\s*\*\/\}|<!--\s*@(!?[\w|-]+)\s*-->)\s*$/
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Keep what applies, drop the markers. A block is the lines between
|
|
132
|
+
* `// name:begin` and `// name:end` (also `{/* name:begin *\/}`, `<!-- … -->`,
|
|
133
|
+
* `# …`); blocks nest. A line ending in `// @name` is that one line. `!name`
|
|
134
|
+
* means "without name"; `a|b` means "with a or b", `!a|b` "with neither". Names are parts and the
|
|
135
|
+
* surfaces, `web` and `api`.
|
|
136
|
+
*/
|
|
137
|
+
export function applyBlocks(text: string, on: ReadonlySet<string>): string {
|
|
138
|
+
const name = (c: string) => c.replace(/^!/, "")
|
|
139
|
+
// Only our names are markers, so a stray `// @ts-expect-error` stays put.
|
|
140
|
+
const known = (c: string) =>
|
|
141
|
+
name(c)
|
|
142
|
+
.split("|")
|
|
143
|
+
.every((n) => MARKER_NAMES.has(n))
|
|
144
|
+
const holds = (c: string) =>
|
|
145
|
+
c.startsWith("!")
|
|
146
|
+
? !name(c)
|
|
147
|
+
.split("|")
|
|
148
|
+
.some((n) => on.has(n))
|
|
149
|
+
: c.split("|").some((n) => on.has(n))
|
|
150
|
+
const open: boolean[] = []
|
|
151
|
+
const out: string[] = []
|
|
152
|
+
for (const line of text.split("\n")) {
|
|
153
|
+
const block = BLOCK.exec(line)
|
|
154
|
+
if (block && known(block[1] as string)) {
|
|
155
|
+
if (block[2] === "begin") open.push(holds(block[1] as string))
|
|
156
|
+
else if (open.pop() === undefined) throw new Error(`Unmatched marker: ${line.trim()}`)
|
|
157
|
+
continue
|
|
158
|
+
}
|
|
159
|
+
if (!open.every(Boolean)) continue
|
|
160
|
+
const tag = TAG.exec(line)
|
|
161
|
+
const cond = tag && (tag[1] ?? tag[2] ?? tag[3] ?? tag[4])
|
|
162
|
+
if (!tag || !cond || !known(cond) || !line.slice(0, tag.index).trim()) out.push(line)
|
|
163
|
+
else if (holds(cond)) out.push(line.slice(0, tag.index))
|
|
164
|
+
}
|
|
165
|
+
if (open.length) throw new Error(`Unclosed marker (${open.length} open)`)
|
|
166
|
+
return out.join("\n")
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The blank lines a dropped block leaves, gone the way the formatter would
|
|
171
|
+
* have it: none at the top or bottom, never two in a row, none just inside brackets.
|
|
172
|
+
*/
|
|
173
|
+
export function tidy(text: string): string {
|
|
174
|
+
return text
|
|
175
|
+
.replace(/^\n+/, "")
|
|
176
|
+
.replace(/\n{2,}$/, "\n")
|
|
177
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
178
|
+
.replace(/([{([]|=>)\n\n/g, "$1\n")
|
|
179
|
+
.replace(/\n\n(\s*[})\]])/g, "\n$1")
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Every file under dir, relative to it. */
|
|
183
|
+
async function walk(dir: string, base = dir): Promise<string[]> {
|
|
184
|
+
const out: string[] = []
|
|
185
|
+
for (const e of await readdir(dir, { withFileTypes: true })) {
|
|
186
|
+
const full = join(dir, e.name)
|
|
187
|
+
if (e.isDirectory()) out.push(...(await walk(full, base)))
|
|
188
|
+
else out.push(full.slice(base.length + 1))
|
|
189
|
+
}
|
|
190
|
+
return out
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Keep the chosen parts' tables in drizzle/: drop each statement on a table
|
|
195
|
+
* of a part left out, and the table from the snapshot. A migration left with
|
|
196
|
+
* no statements goes, with its snapshot and journal entry.
|
|
197
|
+
* ponytail: drops only trailing migrations cleanly (prevId is not relinked);
|
|
198
|
+
* the base has two, and only the last can empty out.
|
|
199
|
+
*/
|
|
200
|
+
async function filterMigrations(dir: string, dropTables: Set<string>) {
|
|
201
|
+
if (!dropTables.size) return
|
|
202
|
+
const journalPath = join(dir, "meta/_journal.json")
|
|
203
|
+
const journal = JSON.parse(await readFile(journalPath, "utf8")) as {
|
|
204
|
+
entries: { idx: number; tag: string }[]
|
|
205
|
+
}
|
|
206
|
+
const keep: typeof journal.entries = []
|
|
207
|
+
for (const entry of journal.entries) {
|
|
208
|
+
const sqlPath = join(dir, `${entry.tag}.sql`)
|
|
209
|
+
const snapPath = join(dir, `meta/${entry.tag.slice(0, 4)}_snapshot.json`)
|
|
210
|
+
const statements = (await readFile(sqlPath, "utf8")).split("--> statement-breakpoint")
|
|
211
|
+
const kept = statements.filter((s) => {
|
|
212
|
+
const table = /CREATE TABLE `(\w+)`/.exec(s)?.[1] ?? / ON `(\w+)`/.exec(s)?.[1]
|
|
213
|
+
return !table || !dropTables.has(table)
|
|
214
|
+
})
|
|
215
|
+
if (!kept.some((s) => s.trim())) {
|
|
216
|
+
await rm(sqlPath)
|
|
217
|
+
await rm(snapPath)
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
220
|
+
keep.push(entry)
|
|
221
|
+
if (kept.length !== statements.length)
|
|
222
|
+
await writeFile(sqlPath, kept.join("--> statement-breakpoint").trim())
|
|
223
|
+
// Snapshots are cumulative: a later one still lists an earlier one's tables.
|
|
224
|
+
const snap = JSON.parse(await readFile(snapPath, "utf8")) as { tables: Record<string, unknown> }
|
|
225
|
+
for (const t of dropTables) delete snap.tables[t]
|
|
226
|
+
await writeFile(snapPath, JSON.stringify(snap, null, 2))
|
|
227
|
+
}
|
|
228
|
+
if (keep.length !== journal.entries.length) {
|
|
229
|
+
journal.entries = keep
|
|
230
|
+
await writeFile(journalPath, JSON.stringify(journal, null, 2))
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type ComposeOptions = {
|
|
235
|
+
parts: PartName[]
|
|
236
|
+
web: boolean
|
|
237
|
+
api: boolean
|
|
238
|
+
runtime?: Runtime
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** The base's own dependencies per surface, from index.ts (signet-mcp's index reads them there). */
|
|
242
|
+
export type BaseDeps = {
|
|
243
|
+
web: { deps: Deps; devDeps: Deps }
|
|
244
|
+
api: { deps: Deps; devDeps: Deps }
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const ROOT = resolve(import.meta.dirname, "..")
|
|
248
|
+
const sorted = (o: Deps) =>
|
|
249
|
+
Object.fromEntries(Object.entries(o).sort(([a], [b]) => a.localeCompare(b)))
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Lay the base and the chosen parts' files into dest and resolve their
|
|
253
|
+
* markers. Returns the package.json body and the env file lines.
|
|
254
|
+
*/
|
|
255
|
+
export async function compose(
|
|
256
|
+
dest: string,
|
|
257
|
+
{ parts, web, api, runtime = "bun" }: ComposeOptions,
|
|
258
|
+
base: BaseDeps,
|
|
259
|
+
) {
|
|
260
|
+
const halves = ["shared", ...(web ? ["web"] : []), ...(api ? ["api"] : [])]
|
|
261
|
+
if (web && api) halves.push("both")
|
|
262
|
+
for (const dir of ["base", ...parts.map((p) => `parts/${p}`)])
|
|
263
|
+
for (const half of halves) {
|
|
264
|
+
const src = join(ROOT, dir, half)
|
|
265
|
+
if (existsSync(src)) await cp(src, dest, { recursive: true })
|
|
266
|
+
}
|
|
267
|
+
const chosen = parts.map((p) => PARTS[p] as Part)
|
|
268
|
+
if (!api)
|
|
269
|
+
for (const p of parts)
|
|
270
|
+
for (const [from, to] of Object.entries((PARTS[p] as Part).uiCopies ?? {}))
|
|
271
|
+
await cp(join(ROOT, "parts", p, "api", from), join(dest, to))
|
|
272
|
+
|
|
273
|
+
const on = new Set<string>([...parts, ...(web ? ["web"] : []), ...(api ? ["api", runtime] : [])])
|
|
274
|
+
for (const f of await walk(dest)) {
|
|
275
|
+
const path = join(dest, f)
|
|
276
|
+
const text = await readFile(path, "utf8")
|
|
277
|
+
let out = applyBlocks(text, on)
|
|
278
|
+
if (out === text) continue
|
|
279
|
+
// Code only: in Markdown a blank line before `)` or after `(` can matter.
|
|
280
|
+
if (/\.(tsx?|json)$/.test(f)) out = tidy(out)
|
|
281
|
+
await writeFile(path, out.replace(/^\n+/, "").replace(/\n{3,}/g, "\n\n"))
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (api)
|
|
285
|
+
await filterMigrations(
|
|
286
|
+
join(dest, "drizzle"),
|
|
287
|
+
new Set(
|
|
288
|
+
PART_NAMES.filter((p) => !parts.includes(p)).flatMap(
|
|
289
|
+
(p) => (PARTS[p] as Part).tables ?? [],
|
|
290
|
+
),
|
|
291
|
+
),
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
const refs = [...(web ? ["app", "node", "test"] : []), ...(api ? ["api"] : [])]
|
|
295
|
+
const ref = (r: string) => `{ "path": "./tsconfig.${r}.json" }`
|
|
296
|
+
await writeFile(
|
|
297
|
+
join(dest, "tsconfig.json"),
|
|
298
|
+
`{\n "files": [],\n "references": ${
|
|
299
|
+
refs.length > 1
|
|
300
|
+
? `[\n${refs.map((r) => ` ${ref(r)}`).join(",\n")}\n ]`
|
|
301
|
+
: `[${ref(refs[0] as string)}]`
|
|
302
|
+
}\n}\n`,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
const deps: Deps = {}
|
|
306
|
+
const devDeps: Deps = {}
|
|
307
|
+
for (const [on, b] of [
|
|
308
|
+
[web, base.web],
|
|
309
|
+
[api, base.api],
|
|
310
|
+
] as const) {
|
|
311
|
+
if (!on) continue
|
|
312
|
+
Object.assign(deps, b.deps)
|
|
313
|
+
Object.assign(devDeps, b.devDeps)
|
|
314
|
+
}
|
|
315
|
+
for (const p of chosen) {
|
|
316
|
+
if (web) Object.assign(deps, p.web?.deps)
|
|
317
|
+
if (api) Object.assign(deps, p.api?.deps)
|
|
318
|
+
if (web && api) Object.assign(devDeps, p.both?.devDeps)
|
|
319
|
+
}
|
|
320
|
+
const scripts: Record<string, string> =
|
|
321
|
+
web && api
|
|
322
|
+
? {
|
|
323
|
+
// Both halves: the API (restarting on change) and Vite, which proxies /api to it.
|
|
324
|
+
dev: `${RUN[runtime]} scripts/dev.ts`,
|
|
325
|
+
build: "tsc -b && vite build",
|
|
326
|
+
// One process serves the API and the built app from dist/.
|
|
327
|
+
start: `${RUN[runtime]} api/server.ts`,
|
|
328
|
+
preview: "vite preview",
|
|
329
|
+
lint: "biome check .",
|
|
330
|
+
format: "biome check --write .",
|
|
331
|
+
typecheck: "tsc -b --noEmit",
|
|
332
|
+
test: "bun test src test",
|
|
333
|
+
...Object.assign({}, ...chosen.map((p) => p.both?.scripts)),
|
|
334
|
+
}
|
|
335
|
+
: web
|
|
336
|
+
? {
|
|
337
|
+
dev: "vite",
|
|
338
|
+
build: "tsc -b && vite build",
|
|
339
|
+
preview: "vite preview",
|
|
340
|
+
lint: "biome check .",
|
|
341
|
+
format: "biome check --write .",
|
|
342
|
+
typecheck: "tsc -b --noEmit",
|
|
343
|
+
test: "bun test src",
|
|
344
|
+
}
|
|
345
|
+
: {
|
|
346
|
+
dev: `${RUN[runtime]} --watch api/server.ts`,
|
|
347
|
+
start: `${RUN[runtime]} api/server.ts`,
|
|
348
|
+
lint: "biome check .",
|
|
349
|
+
format: "biome check --write .",
|
|
350
|
+
typecheck: "tsc -b --noEmit",
|
|
351
|
+
test: "bun test test",
|
|
352
|
+
}
|
|
353
|
+
if (api)
|
|
354
|
+
Object.assign(scripts, {
|
|
355
|
+
"db:generate": "drizzle-kit generate",
|
|
356
|
+
"db:check": "signet-db-check drizzle",
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
pkg: {
|
|
361
|
+
scripts,
|
|
362
|
+
dependencies: sorted(deps),
|
|
363
|
+
devDependencies: sorted(devDeps),
|
|
364
|
+
// Runs api/server.ts as is: type stripping is on by default from 22.18.
|
|
365
|
+
...(api && runtime === "node" ? { engines: { node: ">=22.18" } } : {}),
|
|
366
|
+
},
|
|
367
|
+
env: api ? ["APP_ENV=development", ...chosen.flatMap((p) => p.env?.() ?? []), ""] : [],
|
|
368
|
+
}
|
|
369
|
+
}
|
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.
|
|
26
|
+
"@dapplelight/signet-ui": "^0.4.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.
|
|
33
|
-
react: "^19.3.
|
|
34
|
-
"react-dom": "^19.3.
|
|
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.
|
|
39
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
40
40
|
"@tauri-apps/cli": "^2.0.0",
|
|
41
|
-
"@types/bun": "^1.4.
|
|
42
|
-
"@types/node": "^26.6.
|
|
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.
|
|
46
|
-
tailwindcss: "^4.3.
|
|
45
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
46
|
+
tailwindcss: "^4.3.5",
|
|
47
47
|
typescript: "^7.0.2",
|
|
48
|
-
vite: "^8.3.
|
|
48
|
+
vite: "^8.3.8",
|
|
49
49
|
},
|
|
50
50
|
}
|