@coreframe/scripts 0.0.0 → 0.1.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/bin/coreframe.js +35 -0
- package/config.test.ts +15 -0
- package/config.ts +9 -0
- package/coreframe.ts +272 -0
- package/db/client.ts +72 -0
- package/db/config.ts +41 -0
- package/db/drizzle-kit.test.ts +27 -0
- package/db/drizzle-kit.ts +39 -0
- package/db/ensure.ts +67 -0
- package/db/migrate-held.test.ts +81 -0
- package/db/migrate-held.ts +166 -0
- package/db/migrate.ts +39 -0
- package/db/project.ts +28 -0
- package/db/reset.ts +24 -0
- package/db/seed.ts +38 -0
- package/db/setup.ts +18 -0
- package/deploy/check-migrations.ts +31 -0
- package/deploy/checks.ts +38 -0
- package/deploy/config.test.ts +24 -0
- package/deploy/config.ts +68 -0
- package/deploy/migrations.test.ts +110 -0
- package/deploy/migrations.ts +317 -0
- package/deploy/pending-migrations.test.ts +93 -0
- package/deploy/pending-migrations.ts +45 -0
- package/deploy/tauri-release.test.ts +196 -0
- package/deploy/tauri-release.ts +816 -0
- package/deploy/version.test.ts +29 -0
- package/deploy/version.ts +65 -0
- package/deploy.test.ts +101 -0
- package/deploy.ts +346 -0
- package/dev.test.ts +153 -0
- package/dev.ts +155 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +3 -0
- package/dist/coreframe.d.ts +280 -0
- package/dist/coreframe.js +240 -0
- package/dist/db/client.d.ts +22 -0
- package/dist/db/client.js +29 -0
- package/dist/db/config.d.ts +21 -0
- package/dist/db/config.js +32 -0
- package/dist/db/drizzle-kit.d.ts +8 -0
- package/dist/db/drizzle-kit.js +22 -0
- package/dist/db/ensure.d.ts +2 -0
- package/dist/db/ensure.js +40 -0
- package/dist/db/migrate-held.d.ts +12 -0
- package/dist/db/migrate-held.js +119 -0
- package/dist/db/migrate.d.ts +2 -0
- package/dist/db/migrate.js +25 -0
- package/dist/db/project.d.ts +8 -0
- package/dist/db/project.js +9 -0
- package/dist/db/reset.d.ts +2 -0
- package/dist/db/reset.js +19 -0
- package/dist/db/seed.d.ts +3 -0
- package/dist/db/seed.js +23 -0
- package/dist/db/setup.d.ts +3 -0
- package/dist/db/setup.js +15 -0
- package/dist/deploy/check-migrations.d.ts +2 -0
- package/dist/deploy/check-migrations.js +18 -0
- package/dist/deploy/checks.d.ts +2 -0
- package/dist/deploy/checks.js +27 -0
- package/dist/deploy/config.d.ts +50 -0
- package/dist/deploy/config.js +9 -0
- package/dist/deploy/migrations.d.ts +21 -0
- package/dist/deploy/migrations.js +203 -0
- package/dist/deploy/pending-migrations.d.ts +5 -0
- package/dist/deploy/pending-migrations.js +30 -0
- package/dist/deploy/tauri-release.d.ts +85 -0
- package/dist/deploy/tauri-release.js +512 -0
- package/dist/deploy/version.d.ts +18 -0
- package/dist/deploy/version.js +41 -0
- package/dist/deploy.d.ts +17 -0
- package/dist/deploy.js +247 -0
- package/dist/dev.d.ts +13 -0
- package/dist/dev.js +96 -0
- package/dist/image-generator.d.ts +2 -0
- package/dist/image-generator.js +59 -0
- package/dist/project.d.ts +1 -0
- package/dist/project.js +13 -0
- package/dist/typecheck.d.ts +2 -0
- package/dist/typecheck.js +45 -0
- package/dist/upgrade/check-skill-current.d.ts +6 -0
- package/dist/upgrade/check-skill-current.js +88 -0
- package/dist/upgrade/ensure-template-remote.d.ts +6 -0
- package/dist/upgrade/ensure-template-remote.js +57 -0
- package/dist/upgrade/fast-forward-template-files.d.ts +7 -0
- package/dist/upgrade/fast-forward-template-files.js +280 -0
- package/image-generator.ts +84 -0
- package/package.json +48 -8
- package/project.ts +6 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +20 -0
- package/typecheck.ts +55 -0
- package/upgrade/check-skill-current.ts +112 -0
- package/upgrade/ensure-template-remote.ts +79 -0
- package/upgrade/fast-forward-template-files.ts +408 -0
- package/readme.md +0 -1
package/dev.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn as nodeSpawn } from "node:child_process"
|
|
3
|
+
import { createWriteStream } from "node:fs"
|
|
4
|
+
import { mkdir } from "node:fs/promises"
|
|
5
|
+
import path from "node:path"
|
|
6
|
+
import process from "node:process"
|
|
7
|
+
import type { Readable } from "node:stream"
|
|
8
|
+
|
|
9
|
+
type Spawn = typeof nodeSpawn
|
|
10
|
+
type TeeProcess = {
|
|
11
|
+
on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): void
|
|
12
|
+
on(event: "error", listener: (error: Error) => void): void
|
|
13
|
+
stderr: Readable | null
|
|
14
|
+
stdout: Readable | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type DevServerOptions = {
|
|
18
|
+
cwd?: string
|
|
19
|
+
env?: NodeJS.ProcessEnv
|
|
20
|
+
logPath?: string
|
|
21
|
+
platform?: DevPlatform
|
|
22
|
+
spawn?: Spawn
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type DevPlatform = "android" | "desktop" | "ios" | "web"
|
|
26
|
+
|
|
27
|
+
const defaultLogPath = ".agents/logs/dev-server.log"
|
|
28
|
+
const nodeModulesBinPath = path.resolve("node_modules", ".bin")
|
|
29
|
+
const pnpmCommand = process.platform === "win32" ? "pnpm.cmd" : "pnpm"
|
|
30
|
+
const reactRouterCommand =
|
|
31
|
+
process.platform === "win32" ? "react-router.cmd" : "react-router"
|
|
32
|
+
|
|
33
|
+
export async function runDevServer({
|
|
34
|
+
cwd = process.cwd(),
|
|
35
|
+
env = process.env,
|
|
36
|
+
logPath = defaultLogPath,
|
|
37
|
+
platform = "web",
|
|
38
|
+
spawn = nodeSpawn,
|
|
39
|
+
}: DevServerOptions = {}) {
|
|
40
|
+
const pathEnvValue = env.PATH ?? env.Path ?? ""
|
|
41
|
+
const shouldTee = !("TAURI_ENV_PLATFORM" in env)
|
|
42
|
+
const log = shouldTee ? await createDevLog(logPath) : undefined
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (platform === "web") {
|
|
46
|
+
await runDevProcess(spawn, pnpmCommand, ["db", "ensure"], {
|
|
47
|
+
cwd,
|
|
48
|
+
env,
|
|
49
|
+
log,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
await runDevProcess(spawn, reactRouterCommand, ["dev"], {
|
|
53
|
+
cwd,
|
|
54
|
+
env: {
|
|
55
|
+
...env,
|
|
56
|
+
CLOUDFLARE_ENV: "development",
|
|
57
|
+
PATH: nodeModulesBinPath + path.delimiter + pathEnvValue,
|
|
58
|
+
},
|
|
59
|
+
log,
|
|
60
|
+
})
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
await runDevProcess(spawn, pnpmCommand, tauriDevArgs(platform), {
|
|
65
|
+
cwd,
|
|
66
|
+
env,
|
|
67
|
+
log,
|
|
68
|
+
})
|
|
69
|
+
} finally {
|
|
70
|
+
await closeLog(log)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function createDevLog(logPath: string) {
|
|
75
|
+
await mkdir(path.dirname(logPath), { recursive: true })
|
|
76
|
+
return createWriteStream(logPath, { flags: "w" })
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function closeLog(log: NodeJS.WritableStream | undefined) {
|
|
80
|
+
if (!log) {
|
|
81
|
+
return Promise.resolve()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return new Promise<void>((resolve, reject) => {
|
|
85
|
+
log.once("error", reject)
|
|
86
|
+
log.end(resolve)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function tauriDevArgs(platform: Exclude<DevPlatform, "web">) {
|
|
91
|
+
return ["--dir=tauri", "tauri", ...(platform === "desktop" ? [] : [platform]), "dev"]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function runDevProcess(
|
|
95
|
+
spawn: Spawn,
|
|
96
|
+
command: string,
|
|
97
|
+
args: string[],
|
|
98
|
+
{
|
|
99
|
+
cwd,
|
|
100
|
+
env,
|
|
101
|
+
log,
|
|
102
|
+
}: {
|
|
103
|
+
cwd: string
|
|
104
|
+
env: NodeJS.ProcessEnv
|
|
105
|
+
log: NodeJS.WritableStream | undefined
|
|
106
|
+
},
|
|
107
|
+
) {
|
|
108
|
+
return new Promise<void>((resolve, reject) => {
|
|
109
|
+
const child = spawn(command, args, {
|
|
110
|
+
cwd,
|
|
111
|
+
env,
|
|
112
|
+
stdio: log ? ["inherit", "pipe", "pipe"] : "inherit",
|
|
113
|
+
}) as unknown as TeeProcess
|
|
114
|
+
|
|
115
|
+
if (log) {
|
|
116
|
+
if (!child.stdout || !child.stderr) {
|
|
117
|
+
reject(new Error(`${[command, ...args].join(" ")} did not provide output streams`))
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
child.stdout.on("data", (chunk) => {
|
|
122
|
+
process.stdout.write(chunk)
|
|
123
|
+
log.write(chunk)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
child.stderr.on("data", (chunk) => {
|
|
127
|
+
process.stderr.write(chunk)
|
|
128
|
+
log.write(chunk)
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
child.on("error", reject)
|
|
133
|
+
|
|
134
|
+
child.on("close", (code, signal) => {
|
|
135
|
+
if (code === 0) {
|
|
136
|
+
resolve()
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const commandText = [command, ...args].join(" ")
|
|
141
|
+
reject(
|
|
142
|
+
new Error(
|
|
143
|
+
`${commandText} failed${signal ? ` with signal ${signal}` : ` with exit code ${code ?? 1}`}`,
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (import.meta.main) {
|
|
151
|
+
runDevServer().catch((error) => {
|
|
152
|
+
console.error(error)
|
|
153
|
+
process.exit(1)
|
|
154
|
+
})
|
|
155
|
+
}
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
|
|
3
|
+
parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
|
|
4
|
+
command: "db";
|
|
5
|
+
args: {
|
|
6
|
+
command: "generate";
|
|
7
|
+
args: {
|
|
8
|
+
args: string[];
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
command: "migrate";
|
|
12
|
+
args: {
|
|
13
|
+
args: string[];
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
command: "studio";
|
|
17
|
+
args: {
|
|
18
|
+
args: string[];
|
|
19
|
+
};
|
|
20
|
+
} | {
|
|
21
|
+
command: "ensure";
|
|
22
|
+
args: {};
|
|
23
|
+
} | {
|
|
24
|
+
command: "migrate-held";
|
|
25
|
+
args: {
|
|
26
|
+
confirm: "run-held-migrations" | undefined;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
command: "migrate-local";
|
|
30
|
+
args: {};
|
|
31
|
+
} | {
|
|
32
|
+
command: "migrations-check";
|
|
33
|
+
args: {};
|
|
34
|
+
} | {
|
|
35
|
+
command: "reset";
|
|
36
|
+
args: {};
|
|
37
|
+
} | {
|
|
38
|
+
command: "seed";
|
|
39
|
+
args: {};
|
|
40
|
+
} | {
|
|
41
|
+
command: "setup";
|
|
42
|
+
args: {};
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
command: "deploy";
|
|
46
|
+
args: {
|
|
47
|
+
runMigrations: boolean;
|
|
48
|
+
skipMigrations: boolean;
|
|
49
|
+
skipPostDeployChecks: boolean;
|
|
50
|
+
tauriLocalPlatforms: ("macos" | "windows" | "linux" | "ios" | "android")[];
|
|
51
|
+
tauriWorkflowName: string | undefined;
|
|
52
|
+
tauriWorkflowPlatforms: ("macos" | "windows" | "linux" | "ios" | "android")[];
|
|
53
|
+
tauriWorkflowRef: string | undefined;
|
|
54
|
+
yes: boolean;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
command: "dev";
|
|
58
|
+
args: {
|
|
59
|
+
platform: "ios" | "android" | "desktop" | "web" | undefined;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
command: "typecheck";
|
|
63
|
+
args: {};
|
|
64
|
+
} | {
|
|
65
|
+
command: "upgrade";
|
|
66
|
+
args: {
|
|
67
|
+
command: "ensure-template-remote";
|
|
68
|
+
args: {
|
|
69
|
+
remote: string;
|
|
70
|
+
noFetch: boolean;
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
command: "check-skill-current";
|
|
74
|
+
args: {
|
|
75
|
+
target: string;
|
|
76
|
+
apply: boolean;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
command: "fast-forward-template-files";
|
|
80
|
+
args: {
|
|
81
|
+
target: string;
|
|
82
|
+
base: string | undefined;
|
|
83
|
+
apply: boolean;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}>>;
|
|
87
|
+
} & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{
|
|
88
|
+
command: "db";
|
|
89
|
+
args: {
|
|
90
|
+
command: "generate";
|
|
91
|
+
args: {
|
|
92
|
+
args: string[];
|
|
93
|
+
};
|
|
94
|
+
} | {
|
|
95
|
+
command: "migrate";
|
|
96
|
+
args: {
|
|
97
|
+
args: string[];
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
command: "studio";
|
|
101
|
+
args: {
|
|
102
|
+
args: string[];
|
|
103
|
+
};
|
|
104
|
+
} | {
|
|
105
|
+
command: "ensure";
|
|
106
|
+
args: {};
|
|
107
|
+
} | {
|
|
108
|
+
command: "migrate-held";
|
|
109
|
+
args: {
|
|
110
|
+
confirm: "run-held-migrations" | undefined;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
command: "migrate-local";
|
|
114
|
+
args: {};
|
|
115
|
+
} | {
|
|
116
|
+
command: "migrations-check";
|
|
117
|
+
args: {};
|
|
118
|
+
} | {
|
|
119
|
+
command: "reset";
|
|
120
|
+
args: {};
|
|
121
|
+
} | {
|
|
122
|
+
command: "seed";
|
|
123
|
+
args: {};
|
|
124
|
+
} | {
|
|
125
|
+
command: "setup";
|
|
126
|
+
args: {};
|
|
127
|
+
};
|
|
128
|
+
} | {
|
|
129
|
+
command: "deploy";
|
|
130
|
+
args: {
|
|
131
|
+
runMigrations: boolean;
|
|
132
|
+
skipMigrations: boolean;
|
|
133
|
+
skipPostDeployChecks: boolean;
|
|
134
|
+
tauriLocalPlatforms: ("macos" | "windows" | "linux" | "ios" | "android")[];
|
|
135
|
+
tauriWorkflowName: string | undefined;
|
|
136
|
+
tauriWorkflowPlatforms: ("macos" | "windows" | "linux" | "ios" | "android")[];
|
|
137
|
+
tauriWorkflowRef: string | undefined;
|
|
138
|
+
yes: boolean;
|
|
139
|
+
};
|
|
140
|
+
} | {
|
|
141
|
+
command: "dev";
|
|
142
|
+
args: {
|
|
143
|
+
platform: "ios" | "android" | "desktop" | "web" | undefined;
|
|
144
|
+
};
|
|
145
|
+
} | {
|
|
146
|
+
command: "typecheck";
|
|
147
|
+
args: {};
|
|
148
|
+
} | {
|
|
149
|
+
command: "upgrade";
|
|
150
|
+
args: {
|
|
151
|
+
command: "ensure-template-remote";
|
|
152
|
+
args: {
|
|
153
|
+
remote: string;
|
|
154
|
+
noFetch: boolean;
|
|
155
|
+
};
|
|
156
|
+
} | {
|
|
157
|
+
command: "check-skill-current";
|
|
158
|
+
args: {
|
|
159
|
+
target: string;
|
|
160
|
+
apply: boolean;
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
command: "fast-forward-template-files";
|
|
164
|
+
args: {
|
|
165
|
+
target: string;
|
|
166
|
+
base: string | undefined;
|
|
167
|
+
apply: boolean;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
}, {
|
|
171
|
+
command: "db";
|
|
172
|
+
value: {
|
|
173
|
+
command: "generate";
|
|
174
|
+
value: Promise<void>;
|
|
175
|
+
} | {
|
|
176
|
+
command: "migrate";
|
|
177
|
+
value: Promise<void>;
|
|
178
|
+
} | {
|
|
179
|
+
command: "studio";
|
|
180
|
+
value: Promise<void>;
|
|
181
|
+
} | {
|
|
182
|
+
command: "ensure";
|
|
183
|
+
value: Promise<void>;
|
|
184
|
+
} | {
|
|
185
|
+
command: "migrate-held";
|
|
186
|
+
value: Promise<void>;
|
|
187
|
+
} | {
|
|
188
|
+
command: "migrate-local";
|
|
189
|
+
value: Promise<void>;
|
|
190
|
+
} | {
|
|
191
|
+
command: "migrations-check";
|
|
192
|
+
value: Promise<void>;
|
|
193
|
+
} | {
|
|
194
|
+
command: "reset";
|
|
195
|
+
value: Promise<void>;
|
|
196
|
+
} | {
|
|
197
|
+
command: "seed";
|
|
198
|
+
value: Promise<void>;
|
|
199
|
+
} | {
|
|
200
|
+
command: "setup";
|
|
201
|
+
value: Promise<void>;
|
|
202
|
+
};
|
|
203
|
+
} | {
|
|
204
|
+
command: "deploy";
|
|
205
|
+
value: Promise<void>;
|
|
206
|
+
} | {
|
|
207
|
+
command: "dev";
|
|
208
|
+
value: Promise<void>;
|
|
209
|
+
} | {
|
|
210
|
+
command: "typecheck";
|
|
211
|
+
value: Promise<void>;
|
|
212
|
+
} | {
|
|
213
|
+
command: "upgrade";
|
|
214
|
+
value: {
|
|
215
|
+
command: "ensure-template-remote";
|
|
216
|
+
value: void;
|
|
217
|
+
} | {
|
|
218
|
+
command: "check-skill-current";
|
|
219
|
+
value: void;
|
|
220
|
+
} | {
|
|
221
|
+
command: "fast-forward-template-files";
|
|
222
|
+
value: void;
|
|
223
|
+
};
|
|
224
|
+
}> & {
|
|
225
|
+
run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
|
|
226
|
+
command: "db";
|
|
227
|
+
value: {
|
|
228
|
+
command: "generate";
|
|
229
|
+
value: Promise<void>;
|
|
230
|
+
} | {
|
|
231
|
+
command: "migrate";
|
|
232
|
+
value: Promise<void>;
|
|
233
|
+
} | {
|
|
234
|
+
command: "studio";
|
|
235
|
+
value: Promise<void>;
|
|
236
|
+
} | {
|
|
237
|
+
command: "ensure";
|
|
238
|
+
value: Promise<void>;
|
|
239
|
+
} | {
|
|
240
|
+
command: "migrate-held";
|
|
241
|
+
value: Promise<void>;
|
|
242
|
+
} | {
|
|
243
|
+
command: "migrate-local";
|
|
244
|
+
value: Promise<void>;
|
|
245
|
+
} | {
|
|
246
|
+
command: "migrations-check";
|
|
247
|
+
value: Promise<void>;
|
|
248
|
+
} | {
|
|
249
|
+
command: "reset";
|
|
250
|
+
value: Promise<void>;
|
|
251
|
+
} | {
|
|
252
|
+
command: "seed";
|
|
253
|
+
value: Promise<void>;
|
|
254
|
+
} | {
|
|
255
|
+
command: "setup";
|
|
256
|
+
value: Promise<void>;
|
|
257
|
+
};
|
|
258
|
+
} | {
|
|
259
|
+
command: "deploy";
|
|
260
|
+
value: Promise<void>;
|
|
261
|
+
} | {
|
|
262
|
+
command: "dev";
|
|
263
|
+
value: Promise<void>;
|
|
264
|
+
} | {
|
|
265
|
+
command: "typecheck";
|
|
266
|
+
value: Promise<void>;
|
|
267
|
+
} | {
|
|
268
|
+
command: "upgrade";
|
|
269
|
+
value: {
|
|
270
|
+
command: "ensure-template-remote";
|
|
271
|
+
value: void;
|
|
272
|
+
} | {
|
|
273
|
+
command: "check-skill-current";
|
|
274
|
+
value: void;
|
|
275
|
+
} | {
|
|
276
|
+
command: "fast-forward-template-files";
|
|
277
|
+
value: void;
|
|
278
|
+
};
|
|
279
|
+
}>>;
|
|
280
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { array, binary, command, flag, multioption, oneOf, option, optional, positional, rest, run, string, subcommands, } from "cmd-ts";
|
|
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
|
+
}
|