Auto-apply dev:once migrations
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
6793dde597
commit
868cfa8c50
2 changed files with 7 additions and 5 deletions
|
|
@ -39,6 +39,8 @@ This starts:
|
|||
|
||||
`pnpm dev` runs the server in watch mode and restarts on changes from workspace packages (including adapter packages). Use `pnpm dev:once` to run without file watching.
|
||||
|
||||
`pnpm dev:once` auto-applies pending local migrations by default before starting the dev server.
|
||||
|
||||
`pnpm dev` and `pnpm dev:once` are now idempotent for the current repo and instance: if the matching Paperclip dev runner is already alive, Paperclip reports the existing process instead of starting a duplicate.
|
||||
|
||||
Inspect or stop the current repo's managed dev runner:
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ const env: NodeJS.ProcessEnv = {
|
|||
|
||||
if (mode === "dev") {
|
||||
env.PAPERCLIP_DEV_SERVER_STATUS_FILE = devServerStatusFilePath;
|
||||
env.PAPERCLIP_MIGRATION_AUTO_APPLY ??= "true";
|
||||
}
|
||||
|
||||
if (mode === "watch") {
|
||||
|
|
@ -304,11 +305,13 @@ async function updateDevServiceRecord(extra?: Record<string, unknown>) {
|
|||
async function runPnpm(args: string[], options: {
|
||||
stdio?: "inherit" | ["ignore", "pipe", "pipe"];
|
||||
env?: NodeJS.ProcessEnv;
|
||||
cwd?: string;
|
||||
} = {}) {
|
||||
return await new Promise<{ code: number; signal: NodeJS.Signals | null; stdout: string; stderr: string }>((resolve, reject) => {
|
||||
const spawned = spawn(pnpmBin, args, {
|
||||
stdio: options.stdio ?? ["ignore", "pipe", "pipe"],
|
||||
env: options.env ?? process.env,
|
||||
cwd: options.cwd,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
|
||||
|
|
@ -416,13 +419,10 @@ async function maybePreflightMigrations(options: { interactive?: boolean; autoAp
|
|||
return;
|
||||
}
|
||||
|
||||
const migrate = spawn(pnpmBin, ["db:migrate"], {
|
||||
const exit = await runPnpm(["db:migrate"], {
|
||||
stdio: "inherit",
|
||||
env,
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
const exit = await new Promise<{ code: number; signal: NodeJS.Signals | null }>((resolve) => {
|
||||
migrate.on("exit", (code, signal) => resolve({ code: code ?? 0, signal }));
|
||||
cwd: repoRoot,
|
||||
});
|
||||
if (exit.signal) {
|
||||
exitForSignal(exit.signal);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue