Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: auto-confirm D1 migrations

tianma-ifc7dd1ed75462
diff --git a/scripts/wrangler-runner.mjs b/scripts/wrangler-runner.mjs
index 13878888..41060a8d 100644
--- a/scripts/wrangler-runner.mjs
+++ b/scripts/wrangler-runner.mjs
@@ -20,6 +20,22 @@ export const buildWranglerEnvironment = (args, env = process.env) => ({
...(isD1MigrationApplyCommand(args) ? { CI: "true" } : {}),
});
+export const buildWranglerSpawnOptions = (args, options = {}) => {
+ if (!isD1MigrationApplyCommand(args) || options.input !== undefined) {
+ return options;
+ }
+
+ return {
+ ...options,
+ // Wrangler 4.105 can still prompt in an interactive Windows Git Bash even
+ // when CI=true. Explicitly answer yes so automated deployments never wait.
+ input: "y\n",
+ ...(options.stdio === "inherit"
+ ? { stdio: ["pipe", "inherit", "inherit"] }
+ : {}),
+ };
+};
+
export const runWranglerSync = (args, options = {}) => {
const cwd = options.cwd ?? resolve(".");
const cliPath = resolveWranglerCliPath(cwd);
@@ -34,10 +50,11 @@ export const runWranglerSync = (args, options = {}) => {
}
const { runtimeExecutable, ...spawnOptions } = options;
+ const finalSpawnOptions = buildWranglerSpawnOptions(args, spawnOptions);
return spawnSync(runtimeExecutable ?? process.execPath, [cliPath, ...args], {
cwd,
shell: false,
- ...spawnOptions,
- env: buildWranglerEnvironment(args, spawnOptions.env),
+ ...finalSpawnOptions,
+ env: buildWranglerEnvironment(args, finalSpawnOptions.env),
});
};
diff --git a/tests/wrangler-runner.test.ts b/tests/wrangler-runner.test.ts
index 9fd1e306..7fff349e 100644
--- a/tests/wrangler-runner.test.ts
+++ b/tests/wrangler-runner.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
import {
buildWranglerInvocation,
buildWranglerEnvironment,
+ buildWranglerSpawnOptions,
isD1MigrationApplyCommand,
resolveWranglerCliPath,
runWranglerSync,
@@ -36,5 +37,9 @@ describe("cross-platform Wrangler runner", () => {
CI: "true",
});
expect(buildWranglerEnvironment(["d1", "migrations", "list", "DB"], {})).not.toHaveProperty("CI");
+ expect(buildWranglerSpawnOptions(args, { stdio: "inherit" })).toEqual({
+ input: "y\n",
+ stdio: ["pipe", "inherit", "inherit"],
+ });
});
});