@coreframe/scripts 0.1.0 → 0.1.2
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/dist/config.d.ts +18 -4
- package/dist/config.js +1 -3
- package/dist/coreframe.d.ts +243 -241
- package/dist/coreframe.js +1 -239
- package/dist/db/client.d.ts +26 -18
- package/dist/db/client.js +1 -29
- package/dist/db/config.d.ts +22 -19
- package/dist/db/config.js +1 -32
- package/dist/db/drizzle-kit.d.ts +6 -5
- package/dist/db/drizzle-kit.js +1 -21
- package/dist/db/ensure.d.ts +20 -2
- package/dist/db/ensure.js +1 -39
- package/dist/db/migrate-held.d.ts +16 -10
- package/dist/db/migrate-held.js +3 -112
- package/dist/db/migrate.d.ts +4 -2
- package/dist/db/migrate.js +1 -24
- package/dist/db/project.d.ts +19 -7
- package/dist/db/project.js +1 -9
- package/dist/db/reset.d.ts +4 -2
- package/dist/db/reset.js +1 -18
- package/dist/db/schema-push.d.ts +22 -0
- package/dist/db/schema-push.js +1 -0
- package/dist/db/seed.d.ts +6 -3
- package/dist/db/seed.js +1 -22
- package/dist/db/setup.d.ts +6 -3
- package/dist/db/setup.js +1 -14
- package/dist/deploy/check-migrations.d.ts +4 -2
- package/dist/deploy/check-migrations.js +1 -17
- package/dist/deploy/checks.d.ts +6 -2
- package/dist/deploy/checks.js +1 -27
- package/dist/deploy/config.d.ts +47 -44
- package/dist/deploy/config.js +1 -9
- package/dist/deploy/migrations.d.ts +21 -18
- package/dist/deploy/migrations.js +4 -203
- package/dist/deploy/pending-migrations.d.ts +9 -5
- package/dist/deploy/pending-migrations.js +1 -30
- package/dist/deploy/tauri-release.d.ts +93 -73
- package/dist/deploy/tauri-release.js +1 -512
- package/dist/deploy/version.d.ts +15 -13
- package/dist/deploy/version.js +1 -41
- package/dist/deploy.d.ts +16 -15
- package/dist/deploy.js +1 -246
- package/dist/dev.d.ts +23 -12
- package/dist/dev.js +1 -95
- package/dist/image-generator.d.ts +18 -2
- package/dist/image-generator.js +1 -59
- package/dist/project.d.ts +4 -1
- package/dist/project.js +1 -13
- package/dist/typecheck.d.ts +4 -2
- package/dist/typecheck.js +1 -44
- package/dist/upgrade/check-skill-current.d.ts +10 -5
- package/dist/upgrade/check-skill-current.js +1 -87
- package/dist/upgrade/ensure-template-remote.d.ts +10 -5
- package/dist/upgrade/ensure-template-remote.js +1 -56
- package/dist/upgrade/fast-forward-template-files.d.ts +8 -6
- package/dist/upgrade/fast-forward-template-files.js +1 -279
- package/package.json +7 -2
- package/config.test.ts +0 -15
- package/config.ts +0 -9
- package/coreframe.ts +0 -272
- package/db/client.ts +0 -72
- package/db/config.ts +0 -41
- package/db/drizzle-kit.test.ts +0 -27
- package/db/drizzle-kit.ts +0 -39
- package/db/ensure.ts +0 -67
- package/db/migrate-held.test.ts +0 -81
- package/db/migrate-held.ts +0 -166
- package/db/migrate.ts +0 -39
- package/db/project.ts +0 -28
- package/db/reset.ts +0 -24
- package/db/seed.ts +0 -38
- package/db/setup.ts +0 -18
- package/deploy/check-migrations.ts +0 -31
- package/deploy/checks.ts +0 -38
- package/deploy/config.test.ts +0 -24
- package/deploy/config.ts +0 -68
- package/deploy/migrations.test.ts +0 -110
- package/deploy/migrations.ts +0 -317
- package/deploy/pending-migrations.test.ts +0 -93
- package/deploy/pending-migrations.ts +0 -45
- package/deploy/tauri-release.test.ts +0 -196
- package/deploy/tauri-release.ts +0 -816
- package/deploy/version.test.ts +0 -29
- package/deploy/version.ts +0 -65
- package/deploy.test.ts +0 -101
- package/deploy.ts +0 -346
- package/dev.test.ts +0 -153
- package/dev.ts +0 -155
- package/image-generator.ts +0 -84
- package/project.ts +0 -6
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -20
- package/typecheck.ts +0 -55
- package/upgrade/check-skill-current.ts +0 -112
- package/upgrade/ensure-template-remote.ts +0 -79
- package/upgrade/fast-forward-template-files.ts +0 -408
package/dist/coreframe.js
CHANGED
|
@@ -1,240 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { array,
|
|
3
|
-
import { runDrizzleKitCommand } from "./db/drizzle-kit.js";
|
|
4
|
-
import { ensureLocalDb } from "./db/ensure.js";
|
|
5
|
-
import { migrateHeldMigrations } from "./db/migrate-held.js";
|
|
6
|
-
import { migrateLocalDb } from "./db/migrate.js";
|
|
7
|
-
import { resetLocalDb } from "./db/reset.js";
|
|
8
|
-
import { seedLocalDb } from "./db/seed.js";
|
|
9
|
-
import { setupLocalDb } from "./db/setup.js";
|
|
10
|
-
import { deployProject } from "./deploy.js";
|
|
11
|
-
import { checkDeployMigrations } from "./deploy/check-migrations.js";
|
|
12
|
-
import { tauriReleasePlatforms } from "./deploy/config.js";
|
|
13
|
-
import { runDevServer } from "./dev.js";
|
|
14
|
-
import { typecheckProject } from "./typecheck.js";
|
|
15
|
-
import { checkUpgradeSkillCurrent } from "./upgrade/check-skill-current.js";
|
|
16
|
-
import { ensureTemplateRemote } from "./upgrade/ensure-template-remote.js";
|
|
17
|
-
import { fastForwardTemplateFiles } from "./upgrade/fast-forward-template-files.js";
|
|
18
|
-
const heldMigrationConfirmation = "run-held-migrations";
|
|
19
|
-
const devPlatforms = ["web", "desktop", "ios", "android"];
|
|
20
|
-
export const coreframeCli = subcommands({
|
|
21
|
-
name: "coreframe",
|
|
22
|
-
cmds: {
|
|
23
|
-
deploy: command({
|
|
24
|
-
name: "deploy",
|
|
25
|
-
args: {
|
|
26
|
-
runMigrations: flag({
|
|
27
|
-
long: "run-migrations",
|
|
28
|
-
description: "Run pending deploy-safe database migrations before deploying.",
|
|
29
|
-
defaultValue: () => false,
|
|
30
|
-
}),
|
|
31
|
-
skipMigrations: flag({
|
|
32
|
-
long: "skip-migrations",
|
|
33
|
-
description: "Deploy without running pending deploy-safe database migrations.",
|
|
34
|
-
defaultValue: () => false,
|
|
35
|
-
}),
|
|
36
|
-
skipPostDeployChecks: flag({
|
|
37
|
-
long: "skip-post-deploy-checks",
|
|
38
|
-
description: "Skip post-deploy checks after Cloudflare deployment.",
|
|
39
|
-
defaultValue: () => false,
|
|
40
|
-
}),
|
|
41
|
-
tauriLocalPlatforms: multioption({
|
|
42
|
-
long: "tauri-local-platform",
|
|
43
|
-
type: array(oneOf(tauriReleasePlatforms)),
|
|
44
|
-
description: "Build one Tauri release platform locally. Repeat for multiple platforms.",
|
|
45
|
-
defaultValue: () => [],
|
|
46
|
-
}),
|
|
47
|
-
tauriWorkflowName: option({
|
|
48
|
-
long: "tauri-workflow-name",
|
|
49
|
-
type: optional(string),
|
|
50
|
-
description: "GitHub Actions workflow file or name for remote Tauri release builds.",
|
|
51
|
-
}),
|
|
52
|
-
tauriWorkflowPlatforms: multioption({
|
|
53
|
-
long: "tauri-workflow-platform",
|
|
54
|
-
type: array(oneOf(tauriReleasePlatforms)),
|
|
55
|
-
description: "Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.",
|
|
56
|
-
defaultValue: () => [],
|
|
57
|
-
}),
|
|
58
|
-
tauriWorkflowRef: option({
|
|
59
|
-
long: "tauri-workflow-ref",
|
|
60
|
-
type: optional(string),
|
|
61
|
-
description: "Git ref used when dispatching remote Tauri release builds.",
|
|
62
|
-
}),
|
|
63
|
-
yes: flag({
|
|
64
|
-
long: "yes",
|
|
65
|
-
short: "y",
|
|
66
|
-
description: "Approve noninteractive deploy prompts.",
|
|
67
|
-
defaultValue: () => false,
|
|
68
|
-
}),
|
|
69
|
-
},
|
|
70
|
-
handler: ({ runMigrations, skipMigrations, skipPostDeployChecks, tauriLocalPlatforms, tauriWorkflowName, tauriWorkflowPlatforms, tauriWorkflowRef, yes, }) => deployProject([
|
|
71
|
-
...(runMigrations ? ["--run-migrations"] : []),
|
|
72
|
-
...(skipMigrations ? ["--skip-migrations"] : []),
|
|
73
|
-
...(skipPostDeployChecks ? ["--skip-post-deploy-checks"] : []),
|
|
74
|
-
...tauriLocalPlatforms.flatMap((platform) => ["--tauri-local-platform", platform]),
|
|
75
|
-
...(tauriWorkflowName ? ["--tauri-workflow-name", tauriWorkflowName] : []),
|
|
76
|
-
...tauriWorkflowPlatforms.flatMap((platform) => ["--tauri-workflow-platform", platform]),
|
|
77
|
-
...(tauriWorkflowRef ? ["--tauri-workflow-ref", tauriWorkflowRef] : []),
|
|
78
|
-
...(yes ? ["--yes"] : []),
|
|
79
|
-
]),
|
|
80
|
-
}),
|
|
81
|
-
typecheck: command({
|
|
82
|
-
name: "typecheck",
|
|
83
|
-
args: {},
|
|
84
|
-
handler: typecheckProject,
|
|
85
|
-
}),
|
|
86
|
-
dev: command({
|
|
87
|
-
name: "dev",
|
|
88
|
-
args: {
|
|
89
|
-
platform: positional({
|
|
90
|
-
type: optional(oneOf(devPlatforms)),
|
|
91
|
-
displayName: "platform",
|
|
92
|
-
description: "Development target platform. Defaults to web.",
|
|
93
|
-
}),
|
|
94
|
-
},
|
|
95
|
-
handler: ({ platform }) => runDevServer({ platform: platform ?? "web" }),
|
|
96
|
-
}),
|
|
97
|
-
upgrade: subcommands({
|
|
98
|
-
name: "upgrade",
|
|
99
|
-
cmds: {
|
|
100
|
-
"ensure-template-remote": command({
|
|
101
|
-
name: "ensure-template-remote",
|
|
102
|
-
args: {
|
|
103
|
-
remote: option({
|
|
104
|
-
long: "remote",
|
|
105
|
-
type: string,
|
|
106
|
-
defaultValue: () => "template",
|
|
107
|
-
description: "Remote name to ensure.",
|
|
108
|
-
}),
|
|
109
|
-
noFetch: flag({
|
|
110
|
-
long: "no-fetch",
|
|
111
|
-
description: "Do not fetch the remote after ensuring it exists.",
|
|
112
|
-
defaultValue: () => false,
|
|
113
|
-
}),
|
|
114
|
-
},
|
|
115
|
-
handler: ({ noFetch, remote }) => ensureTemplateRemote({ fetch: !noFetch, remote }),
|
|
116
|
-
}),
|
|
117
|
-
"check-skill-current": command({
|
|
118
|
-
name: "check-skill-current",
|
|
119
|
-
args: {
|
|
120
|
-
target: option({
|
|
121
|
-
long: "target",
|
|
122
|
-
type: string,
|
|
123
|
-
description: "Target Coreframe template git ref.",
|
|
124
|
-
}),
|
|
125
|
-
apply: flag({
|
|
126
|
-
long: "apply",
|
|
127
|
-
description: "Replace the local upgrade skill with the target version when it differs.",
|
|
128
|
-
defaultValue: () => false,
|
|
129
|
-
}),
|
|
130
|
-
},
|
|
131
|
-
handler: ({ apply, target }) => {
|
|
132
|
-
process.exitCode = checkUpgradeSkillCurrent({ apply, target });
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
"fast-forward-template-files": command({
|
|
136
|
-
name: "fast-forward-template-files",
|
|
137
|
-
args: {
|
|
138
|
-
target: option({
|
|
139
|
-
long: "target",
|
|
140
|
-
type: string,
|
|
141
|
-
description: "Target Coreframe template git ref.",
|
|
142
|
-
}),
|
|
143
|
-
base: option({
|
|
144
|
-
long: "base",
|
|
145
|
-
type: optional(string),
|
|
146
|
-
description: "Previous Coreframe template git ref. Defaults to package.json engines.coreframe.",
|
|
147
|
-
}),
|
|
148
|
-
apply: flag({
|
|
149
|
-
long: "apply",
|
|
150
|
-
description: "Write clean fast-forwards to the worktree.",
|
|
151
|
-
defaultValue: () => false,
|
|
152
|
-
}),
|
|
153
|
-
},
|
|
154
|
-
handler: ({ apply, base, target }) => fastForwardTemplateFiles({ apply, base, target }),
|
|
155
|
-
}),
|
|
156
|
-
},
|
|
157
|
-
}),
|
|
158
|
-
db: subcommands({
|
|
159
|
-
name: "db",
|
|
160
|
-
cmds: {
|
|
161
|
-
ensure: command({
|
|
162
|
-
name: "ensure",
|
|
163
|
-
args: {},
|
|
164
|
-
handler: ensureLocalDb,
|
|
165
|
-
}),
|
|
166
|
-
generate: command({
|
|
167
|
-
name: "generate",
|
|
168
|
-
args: {
|
|
169
|
-
args: rest({
|
|
170
|
-
displayName: "drizzle-kit args",
|
|
171
|
-
description: "Additional arguments passed to drizzle-kit generate.",
|
|
172
|
-
}),
|
|
173
|
-
},
|
|
174
|
-
handler: ({ args }) => runDrizzleKitCommand("generate", args),
|
|
175
|
-
}),
|
|
176
|
-
migrate: command({
|
|
177
|
-
name: "migrate",
|
|
178
|
-
args: {
|
|
179
|
-
args: rest({
|
|
180
|
-
displayName: "drizzle-kit args",
|
|
181
|
-
description: "Additional arguments passed to drizzle-kit migrate.",
|
|
182
|
-
}),
|
|
183
|
-
},
|
|
184
|
-
handler: ({ args }) => runDrizzleKitCommand("migrate", args),
|
|
185
|
-
}),
|
|
186
|
-
"migrate-held": command({
|
|
187
|
-
name: "migrate-held",
|
|
188
|
-
args: {
|
|
189
|
-
confirm: option({
|
|
190
|
-
long: "confirm",
|
|
191
|
-
type: optional(oneOf([heldMigrationConfirmation])),
|
|
192
|
-
description: "Required confirmation value for held migrations.",
|
|
193
|
-
}),
|
|
194
|
-
},
|
|
195
|
-
handler: ({ confirm }) => migrateHeldMigrations({
|
|
196
|
-
argv: confirm ? [`--confirm=${confirm}`] : [],
|
|
197
|
-
}),
|
|
198
|
-
}),
|
|
199
|
-
"migrate-local": command({
|
|
200
|
-
name: "migrate-local",
|
|
201
|
-
args: {},
|
|
202
|
-
handler: migrateLocalDb,
|
|
203
|
-
}),
|
|
204
|
-
"migrations-check": command({
|
|
205
|
-
name: "migrations-check",
|
|
206
|
-
args: {},
|
|
207
|
-
handler: checkDeployMigrations,
|
|
208
|
-
}),
|
|
209
|
-
reset: command({
|
|
210
|
-
name: "reset",
|
|
211
|
-
args: {},
|
|
212
|
-
handler: resetLocalDb,
|
|
213
|
-
}),
|
|
214
|
-
seed: command({
|
|
215
|
-
name: "seed",
|
|
216
|
-
args: {},
|
|
217
|
-
handler: () => seedLocalDb(),
|
|
218
|
-
}),
|
|
219
|
-
setup: command({
|
|
220
|
-
name: "setup",
|
|
221
|
-
args: {},
|
|
222
|
-
handler: () => setupLocalDb(),
|
|
223
|
-
}),
|
|
224
|
-
studio: command({
|
|
225
|
-
name: "studio",
|
|
226
|
-
args: {
|
|
227
|
-
args: rest({
|
|
228
|
-
displayName: "drizzle-kit args",
|
|
229
|
-
description: "Additional arguments passed to drizzle-kit studio.",
|
|
230
|
-
}),
|
|
231
|
-
},
|
|
232
|
-
handler: ({ args }) => runDrizzleKitCommand("studio", args),
|
|
233
|
-
}),
|
|
234
|
-
},
|
|
235
|
-
}),
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
if (import.meta.main) {
|
|
239
|
-
run(binary(coreframeCli), process.argv);
|
|
240
|
-
}
|
|
2
|
+
import{runDrizzleKitCommand as e}from"./db/drizzle-kit.js";import{seedLocalDb as t}from"./db/seed.js";import{migrateLocalDb as n}from"./db/migrate.js";import{resetLocalDb as r}from"./db/reset.js";import{setupLocalDb as i}from"./db/setup.js";import{ensureLocalDb as a}from"./db/ensure.js";import{migrateHeldMigrations as o}from"./db/migrate-held.js";import{tauriReleasePlatforms as s}from"./deploy/config.js";import{deployProject as c}from"./deploy.js";import{checkDeployMigrations as l}from"./deploy/check-migrations.js";import{runDevServer as u}from"./dev.js";import{typecheckProject as d}from"./typecheck.js";import{checkUpgradeSkillCurrent as f}from"./upgrade/check-skill-current.js";import{ensureTemplateRemote as p}from"./upgrade/ensure-template-remote.js";import{fastForwardTemplateFiles as m}from"./upgrade/fast-forward-template-files.js";import{array as h,binary as g,command as _,flag as v,multioption as y,oneOf as b,option as x,optional as S,positional as C,rest as w,run as T,string as E,subcommands as D}from"cmd-ts";const O=D({name:`coreframe`,cmds:{deploy:_({name:`deploy`,args:{runMigrations:v({long:`run-migrations`,description:`Run pending deploy-safe database migrations before deploying.`,defaultValue:()=>!1}),skipMigrations:v({long:`skip-migrations`,description:`Deploy without running pending deploy-safe database migrations.`,defaultValue:()=>!1}),skipPostDeployChecks:v({long:`skip-post-deploy-checks`,description:`Skip post-deploy checks after Cloudflare deployment.`,defaultValue:()=>!1}),tauriLocalPlatforms:y({long:`tauri-local-platform`,type:h(b(s)),description:`Build one Tauri release platform locally. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowName:x({long:`tauri-workflow-name`,type:S(E),description:`GitHub Actions workflow file or name for remote Tauri release builds.`}),tauriWorkflowPlatforms:y({long:`tauri-workflow-platform`,type:h(b(s)),description:`Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowRef:x({long:`tauri-workflow-ref`,type:S(E),description:`Git ref used when dispatching remote Tauri release builds.`}),yes:v({long:`yes`,short:`y`,description:`Approve noninteractive deploy prompts.`,defaultValue:()=>!1})},handler:({runMigrations:e,skipMigrations:t,skipPostDeployChecks:n,tauriLocalPlatforms:r,tauriWorkflowName:i,tauriWorkflowPlatforms:a,tauriWorkflowRef:o,yes:s})=>c([...e?[`--run-migrations`]:[],...t?[`--skip-migrations`]:[],...n?[`--skip-post-deploy-checks`]:[],...r.flatMap(e=>[`--tauri-local-platform`,e]),...i?[`--tauri-workflow-name`,i]:[],...a.flatMap(e=>[`--tauri-workflow-platform`,e]),...o?[`--tauri-workflow-ref`,o]:[],...s?[`--yes`]:[]])}),typecheck:_({name:`typecheck`,args:{},handler:d}),dev:_({name:`dev`,args:{platform:C({type:S(b([`web`,`desktop`,`ios`,`android`])),displayName:`platform`,description:`Development target platform. Defaults to web.`})},handler:({platform:e})=>u({platform:e??`web`})}),upgrade:D({name:`upgrade`,cmds:{"ensure-template-remote":_({name:`ensure-template-remote`,args:{remote:x({long:`remote`,type:E,defaultValue:()=>`template`,description:`Remote name to ensure.`}),noFetch:v({long:`no-fetch`,description:`Do not fetch the remote after ensuring it exists.`,defaultValue:()=>!1})},handler:({noFetch:e,remote:t})=>p({fetch:!e,remote:t})}),"check-skill-current":_({name:`check-skill-current`,args:{target:x({long:`target`,type:E,description:`Target Coreframe template git ref.`}),apply:v({long:`apply`,description:`Replace the local upgrade skill with the target version when it differs.`,defaultValue:()=>!1})},handler:({apply:e,target:t})=>{process.exitCode=f({apply:e,target:t})}}),"fast-forward-template-files":_({name:`fast-forward-template-files`,args:{target:x({long:`target`,type:E,description:`Target Coreframe template git ref.`}),base:x({long:`base`,type:S(E),description:`Previous Coreframe template git ref. Defaults to package.json engines.coreframe.`}),apply:v({long:`apply`,description:`Write clean fast-forwards to the worktree.`,defaultValue:()=>!1})},handler:({apply:e,base:t,target:n})=>m({apply:e,base:t,target:n})})}}),db:D({name:`db`,cmds:{ensure:_({name:`ensure`,args:{},handler:a}),generate:_({name:`generate`,args:{args:w({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit generate.`})},handler:({args:t})=>e(`generate`,t)}),migrate:_({name:`migrate`,args:{args:w({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit migrate.`})},handler:({args:t})=>e(`migrate`,t)}),"migrate-held":_({name:`migrate-held`,args:{confirm:x({long:`confirm`,type:S(b([`run-held-migrations`])),description:`Required confirmation value for held migrations.`})},handler:({confirm:e})=>o({argv:e?[`--confirm=${e}`]:[]})}),"migrate-local":_({name:`migrate-local`,args:{},handler:n}),"migrations-check":_({name:`migrations-check`,args:{},handler:l}),reset:_({name:`reset`,args:{},handler:r}),seed:_({name:`seed`,args:{},handler:()=>t()}),setup:_({name:`setup`,args:{},handler:()=>i()}),studio:_({name:`studio`,args:{args:w({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit studio.`})},handler:({args:t})=>e(`studio`,t)})}})}});import.meta.main&&T(g(O),process.argv);export{O as coreframeCli};
|
package/dist/db/client.d.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { SQL } from "drizzle-orm";
|
|
2
|
+
|
|
3
|
+
//#region db/client.d.ts
|
|
4
|
+
type DatabaseDialect = "postgres" | "sqlite";
|
|
5
|
+
type QueryResult<Row extends Record<string, unknown> = Record<string, unknown>> = {
|
|
6
|
+
rowCount?: number | null;
|
|
7
|
+
rows: Row[];
|
|
6
8
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
type DatabaseClient = {
|
|
10
|
+
dialect: DatabaseDialect;
|
|
11
|
+
execute<Row extends Record<string, unknown> = Record<string, unknown>>(statement: string): Promise<QueryResult<Row>>;
|
|
12
|
+
transaction?<Result>(run: (database: DatabaseClient) => Promise<Result>): Promise<Result>;
|
|
13
|
+
close?(): Promise<void>;
|
|
12
14
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
type DrizzleExecutor = {
|
|
16
|
+
execute<Result = unknown>(query: SQL): Result | Promise<Result>;
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
type CreateDatabaseAdapterOptions = {
|
|
19
|
+
close?(): Promise<void>;
|
|
20
|
+
database: DrizzleExecutor;
|
|
21
|
+
dialect: DatabaseDialect;
|
|
20
22
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
declare function createDatabaseAdapter({
|
|
24
|
+
close,
|
|
25
|
+
database,
|
|
26
|
+
dialect
|
|
27
|
+
}: CreateDatabaseAdapterOptions): DatabaseClient;
|
|
28
|
+
declare function normalizeQueryResult<Row extends Record<string, unknown> = Record<string, unknown>>(result: unknown): QueryResult<Row>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CreateDatabaseAdapterOptions, DatabaseClient, DatabaseDialect, DrizzleExecutor, QueryResult, createDatabaseAdapter, normalizeQueryResult };
|
package/dist/db/client.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export function createDrizzleDatabaseClient({ close, database, dialect, }) {
|
|
3
|
-
return {
|
|
4
|
-
dialect,
|
|
5
|
-
async execute(statement) {
|
|
6
|
-
return normalizeQueryResult(await database.execute(sql.raw(statement)));
|
|
7
|
-
},
|
|
8
|
-
close,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function normalizeQueryResult(result) {
|
|
12
|
-
if (Array.isArray(result)) {
|
|
13
|
-
return {
|
|
14
|
-
rows: result,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (isQueryResultLike(result)) {
|
|
18
|
-
return {
|
|
19
|
-
rowCount: typeof result.rowCount === "number" ? result.rowCount : null,
|
|
20
|
-
rows: result.rows,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
rows: [],
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function isQueryResultLike(result) {
|
|
28
|
-
return (typeof result === "object" && result !== null && "rows" in result && Array.isArray(result.rows));
|
|
29
|
-
}
|
|
1
|
+
import{sql as e}from"drizzle-orm";function t({close:t,database:r,dialect:i}){return{dialect:i,async execute(t){return n(await r.execute(e.raw(t)))},close:t}}function n(e){return Array.isArray(e)?{rows:e}:r(e)?{rowCount:typeof e.rowCount==`number`?e.rowCount:null,rows:e.rows}:{rows:[]}}function r(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)}export{t as createDatabaseAdapter,n as normalizeQueryResult};
|
package/dist/db/config.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//#region db/config.d.ts
|
|
2
|
+
declare const LOCAL_DB_DIR: string;
|
|
3
|
+
declare const MIGRATIONS_FOLDER = "drizzle";
|
|
4
|
+
declare const HELD_MIGRATIONS_FOLDER = "drizzle-hold";
|
|
5
|
+
declare const NOW: Date;
|
|
6
|
+
declare const SEED_IDS: {
|
|
7
|
+
readonly adminUser: "00000000-0000-4000-8000-000000000001";
|
|
8
|
+
readonly viewerUser: "00000000-0000-4000-8000-000000000002";
|
|
9
|
+
readonly inactiveUser: "00000000-0000-4000-8000-000000000003";
|
|
10
|
+
readonly unicodeUser: "00000000-0000-4000-8000-000000000004";
|
|
11
|
+
readonly longNameUser: "00000000-0000-4000-8000-000000000005";
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
declare const SEED_EMAILS: {
|
|
14
|
+
readonly adminUser: "admin@example.com";
|
|
15
|
+
readonly viewerUser: "viewer@example.com";
|
|
16
|
+
readonly inactiveUser: "inactive@example.com";
|
|
17
|
+
readonly unicodeUser: "unicode@example.com";
|
|
18
|
+
readonly longNameUser: "long-name@example.com";
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
type SeedProfile = "small" | "large" | "demo" | "test";
|
|
21
|
+
declare function getSeedProfile(argv?: string[]): SeedProfile;
|
|
22
|
+
declare function generatedUserId(index: number): string;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { HELD_MIGRATIONS_FOLDER, LOCAL_DB_DIR, MIGRATIONS_FOLDER, NOW, SEED_EMAILS, SEED_IDS, SeedProfile, generatedUserId, getSeedProfile };
|
package/dist/db/config.js
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const MIGRATIONS_FOLDER = "drizzle";
|
|
3
|
-
export const HELD_MIGRATIONS_FOLDER = "drizzle-hold";
|
|
4
|
-
export const NOW = new Date("2026-01-15T12:00:00.000Z");
|
|
5
|
-
export const SEED_IDS = {
|
|
6
|
-
adminUser: "00000000-0000-4000-8000-000000000001",
|
|
7
|
-
viewerUser: "00000000-0000-4000-8000-000000000002",
|
|
8
|
-
inactiveUser: "00000000-0000-4000-8000-000000000003",
|
|
9
|
-
unicodeUser: "00000000-0000-4000-8000-000000000004",
|
|
10
|
-
longNameUser: "00000000-0000-4000-8000-000000000005",
|
|
11
|
-
};
|
|
12
|
-
export const SEED_EMAILS = {
|
|
13
|
-
adminUser: "admin@example.com",
|
|
14
|
-
viewerUser: "viewer@example.com",
|
|
15
|
-
inactiveUser: "inactive@example.com",
|
|
16
|
-
unicodeUser: "unicode@example.com",
|
|
17
|
-
longNameUser: "long-name@example.com",
|
|
18
|
-
};
|
|
19
|
-
export function getSeedProfile(argv = process.argv.slice(2)) {
|
|
20
|
-
if (argv.includes("--large")) {
|
|
21
|
-
return "large";
|
|
22
|
-
}
|
|
23
|
-
const profileArg = argv.find((arg) => arg.startsWith("--profile="));
|
|
24
|
-
const profile = profileArg?.slice("--profile=".length) ?? "small";
|
|
25
|
-
if (profile === "small" || profile === "large" || profile === "demo" || profile === "test") {
|
|
26
|
-
return profile;
|
|
27
|
-
}
|
|
28
|
-
throw new Error(`Unknown seed profile "${profile}". Expected small, large, demo, or test.`);
|
|
29
|
-
}
|
|
30
|
-
export function generatedUserId(index) {
|
|
31
|
-
return `00000000-0000-4000-8000-${String(1000 + index).padStart(12, "0")}`;
|
|
32
|
-
}
|
|
1
|
+
const e=process.env.PGLITE_DATA_DIR??`.pglite`,t=`drizzle`,n=`drizzle-hold`,r=new Date(`2026-01-15T12:00:00.000Z`),i={adminUser:`00000000-0000-4000-8000-000000000001`,viewerUser:`00000000-0000-4000-8000-000000000002`,inactiveUser:`00000000-0000-4000-8000-000000000003`,unicodeUser:`00000000-0000-4000-8000-000000000004`,longNameUser:`00000000-0000-4000-8000-000000000005`},a={adminUser:`admin@example.com`,viewerUser:`viewer@example.com`,inactiveUser:`inactive@example.com`,unicodeUser:`unicode@example.com`,longNameUser:`long-name@example.com`};function o(e=process.argv.slice(2)){if(e.includes(`--large`))return`large`;let t=e.find(e=>e.startsWith(`--profile=`))?.slice(10)??`small`;if(t===`small`||t===`large`||t===`demo`||t===`test`)return t;throw Error(`Unknown seed profile "${t}". Expected small, large, demo, or test.`)}function s(e){return`00000000-0000-4000-8000-${String(1e3+e).padStart(12,`0`)}`}export{n as HELD_MIGRATIONS_FOLDER,e as LOCAL_DB_DIR,t as MIGRATIONS_FOLDER,r as NOW,a as SEED_EMAILS,i as SEED_IDS,s as generatedUserId,o as getSeedProfile};
|
package/dist/db/drizzle-kit.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
//#region db/drizzle-kit.d.ts
|
|
2
2
|
type Spawn = (file: string, args: readonly string[], options: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
env: NodeJS.ProcessEnv;
|
|
4
|
+
stdio: "inherit";
|
|
5
5
|
}) => PromiseLike<unknown>;
|
|
6
6
|
type DrizzleKitCommand = "generate" | "migrate" | "studio";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
declare function runDrizzleKitCommand(command: DrizzleKitCommand, args?: string[], spawn?: Spawn): Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { runDrizzleKitCommand };
|
package/dist/db/drizzle-kit.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import nanoSpawn from "nano-spawn";
|
|
5
|
-
const nodeModulesBinPath = path.resolve("node_modules", ".bin");
|
|
6
|
-
const drizzleKitCommand = process.platform === "win32" ? "drizzle-kit.cmd" : "drizzle-kit";
|
|
7
|
-
const pathEnvValue = process.env.PATH ?? process.env.Path ?? "";
|
|
8
|
-
export async function runDrizzleKitCommand(command, args = [], spawn = nanoSpawn) {
|
|
9
|
-
await spawn(drizzleKitCommand, [command, ...args], {
|
|
10
|
-
env: {
|
|
11
|
-
...process.env,
|
|
12
|
-
PATH: nodeModulesBinPath + path.delimiter + pathEnvValue,
|
|
13
|
-
},
|
|
14
|
-
stdio: "inherit",
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (import.meta.main) {
|
|
18
|
-
runDrizzleKitCommand(process.argv[2], process.argv.slice(3)).catch((error) => {
|
|
19
|
-
console.error(error);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
2
|
+
import e from"node:path";import t from"node:process";import n from"nano-spawn";const r=e.resolve(`node_modules`,`.bin`),i=t.platform===`win32`?`drizzle-kit.cmd`:`drizzle-kit`,a=t.env.PATH??t.env.Path??``;async function o(o,s=[],c=n){await c(i,[o,...s],{env:{...t.env,PATH:r+e.delimiter+a},stdio:`inherit`})}import.meta.main&&o(t.argv[2],t.argv.slice(3)).catch(e=>{console.error(e),t.exit(1)});export{o as runDrizzleKitCommand};
|
package/dist/db/ensure.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { importProjectModule } from "../project.js";
|
|
2
|
+
import { planLocalSchemaPush } from "./schema-push.js";
|
|
3
|
+
import { seedLocalDb } from "./seed.js";
|
|
4
|
+
import { setupLocalDb } from "./setup.js";
|
|
5
|
+
|
|
6
|
+
//#region db/ensure.d.ts
|
|
7
|
+
type EnsureLocalDbOptions = {
|
|
8
|
+
importProjectModule?: typeof importProjectModule;
|
|
9
|
+
planLocalSchemaPush?: typeof planLocalSchemaPush;
|
|
10
|
+
seedLocalDb?: typeof seedLocalDb;
|
|
11
|
+
setupLocalDb?: typeof setupLocalDb;
|
|
12
|
+
};
|
|
13
|
+
declare function ensureLocalDb({
|
|
14
|
+
importProjectModule: importModule,
|
|
15
|
+
planLocalSchemaPush: planSchemaPush,
|
|
16
|
+
seedLocalDb: seed,
|
|
17
|
+
setupLocalDb: setup
|
|
18
|
+
}?: EnsureLocalDbOptions): Promise<void>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ensureLocalDb };
|
package/dist/db/ensure.js
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { importProjectModule } from "../project.js";
|
|
4
|
-
import { LOCAL_DB_DIR, SEED_EMAILS, SEED_IDS } from "./config.js";
|
|
5
|
-
import { setupLocalDb } from "./setup.js";
|
|
6
|
-
async function hasSeededAdminUser() {
|
|
7
|
-
const [{ createLocalDb }, { users }] = await Promise.all([
|
|
8
|
-
importProjectModule("src/db/local.ts"),
|
|
9
|
-
importProjectModule("src/db/schema.ts"),
|
|
10
|
-
]);
|
|
11
|
-
const db = createLocalDb(LOCAL_DB_DIR);
|
|
12
|
-
try {
|
|
13
|
-
const [adminUser] = await db
|
|
14
|
-
.select({ id: users.id })
|
|
15
|
-
.from(users)
|
|
16
|
-
.where(eq(users.email, SEED_EMAILS.adminUser))
|
|
17
|
-
.limit(1);
|
|
18
|
-
return adminUser?.id === SEED_IDS.adminUser;
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
await db.$client.close();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export async function ensureLocalDb() {
|
|
28
|
-
if (await hasSeededAdminUser()) {
|
|
29
|
-
console.log("Local database already set up");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
console.log("Local database is missing or unseeded; running setup");
|
|
33
|
-
await setupLocalDb();
|
|
34
|
-
}
|
|
35
|
-
if (import.meta.main) {
|
|
36
|
-
ensureLocalDb().catch((error) => {
|
|
37
|
-
console.error(error);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
2
|
+
import{importProjectModule as e}from"../project.js";import{LOCAL_DB_DIR as t,SEED_EMAILS as n,SEED_IDS as r}from"./config.js";import{inferSchemaDialect as i,planLocalSchemaPush as a}from"./schema-push.js";import{seedLocalDb as o}from"./seed.js";import{setupLocalDb as s}from"./setup.js";import{eq as c}from"drizzle-orm";async function l(t=e){let[{createLocalDb:n},r]=await Promise.all([t(`src/db/local.ts`),t(`src/db/schema.ts`)]);return{createLocalDb:n,schema:r}}async function u({createLocalDb:e,schema:{users:i}}){let a=e(t);try{let[e]=await a.select({id:i.id}).from(i).where(c(i.email,n.adminUser)).limit(1);return e?.id===r.adminUser}catch{return!1}finally{await a.$client.close()}}async function d({createLocalDb:e,schema:n},r=a){let o=i(n),s=e(t);try{let e=await r(o,n,s);return e.sqlStatements.length===0?(console.log(`Local database schema already in sync`),{appliedStatements:0,plan:e}):(console.log(`Local database schema drift detected; applying ${e.sqlStatements.length} statement(s)`),await e.apply(),console.log(`Local database schema synced`),{appliedStatements:e.sqlStatements.length,plan:e})}finally{await s.$client.close()}}async function f({importProjectModule:t=e,planLocalSchemaPush:n=a,seedLocalDb:r=o,setupLocalDb:i=s}={}){let c=await l(t);await u(c)?console.log(`Local database already set up`):(console.log(`Local database is missing or unseeded; running setup`),await i(),c=await l(t)),(await d(c,n)).appliedStatements>0&&!await u(c)&&(console.log(`Local database seed data missing after schema sync; running seed`),await r())}import.meta.main&&f().catch(e=>{console.error(e),process.exit(1)});export{f as ensureLocalDb};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { DatabaseClient, DatabaseDialect } from "./client.js";
|
|
2
|
+
|
|
3
|
+
//#region db/migrate-held.d.ts
|
|
3
4
|
type MigrateHeldOptions = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
argv?: string[];
|
|
6
|
+
database?: DatabaseClient;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
declare function migrateHeldMigrations({
|
|
10
|
+
argv,
|
|
11
|
+
database,
|
|
12
|
+
env
|
|
13
|
+
}?: MigrateHeldOptions): Promise<void>;
|
|
14
|
+
declare function validateHeldMigrationHeader(sql: string, relativePath: string): void;
|
|
15
|
+
declare function heldMigrationSelectQuery(dialect: DatabaseDialect, id: string): string;
|
|
16
|
+
declare function heldMigrationInsertQuery(dialect: DatabaseDialect, id: string, sha256: string): string;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { heldMigrationInsertQuery, heldMigrationSelectQuery, migrateHeldMigrations, validateHeldMigrationHeader };
|