diff --git a/.changeset/gentle-moons-argue.md b/.changeset/gentle-moons-argue.md new file mode 100644 index 000000000000..0897c5b60adb --- /dev/null +++ b/.changeset/gentle-moons-argue.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Enable autoconfig for `wrangler deploy` by default (while allowing users to still disable it via `--x-autoconfig=false` if necessary) diff --git a/.changeset/yummy-snails-stand.md b/.changeset/yummy-snails-stand.md new file mode 100644 index 000000000000..74280af9141e --- /dev/null +++ b/.changeset/yummy-snails-stand.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Mark the `wrangler setup` command as stable diff --git a/packages/wrangler/src/__tests__/autoconfig/run.test.ts b/packages/wrangler/src/__tests__/autoconfig/run.test.ts index 0bcae87a286c..8612a3eae0c6 100644 --- a/packages/wrangler/src/__tests__/autoconfig/run.test.ts +++ b/packages/wrangler/src/__tests__/autoconfig/run.test.ts @@ -94,11 +94,11 @@ describe("autoconfig (deploy)", () => { clearOutputFilePath(); }); - it("should not check for autoconfig without flag", async () => { + it("should not check for autoconfig when `deploy` is run with `--x-autoconfig=false`", async () => { writeWorkerSource(); writeWranglerConfig({ main: "index.js" }); const getDetailsSpy = vi.spyOn(details, "getDetailsForAutoConfig"); - await runDeploy(); + await runDeploy(`--x-autoconfig=false`); expect(getDetailsSpy).not.toHaveBeenCalled(); }); diff --git a/packages/wrangler/src/__tests__/deploy.test.ts b/packages/wrangler/src/__tests__/deploy.test.ts index 3ddebe6797e5..8204d1859bd1 100644 --- a/packages/wrangler/src/__tests__/deploy.test.ts +++ b/packages/wrangler/src/__tests__/deploy.test.ts @@ -114,9 +114,7 @@ vi.mock("../package-manager", async (importOriginal) => ({ }, })); -vi.mock("../autoconfig/details"); vi.mock("../autoconfig/run"); -vi.mock("../autoconfig/frameworks"); vi.mock("../autoconfig/frameworks/utils/packages"); vi.mock("../autoconfig/c3-vendor/command"); @@ -566,13 +564,13 @@ describe("deploy", () => { `); }); - it("should error helpfully if pages_build_output_dir is set in wrangler.toml", async () => { + it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --x-autoconfig=false", async () => { writeWranglerConfig({ pages_build_output_dir: "public", name: "test-name", }); await expect( - runWrangler("deploy") + runWrangler("deploy --x-autoconfig=false") ).rejects.toThrowErrorMatchingInlineSnapshot( ` [Error: It looks like you've run a Workers-specific command in a Pages project. @@ -581,6 +579,22 @@ describe("deploy", () => { ); }); + it("should error helpfully if pages_build_output_dir is set in wrangler.toml and --x-autoconfig is provided", async () => { + mockConfirm({ + text: "Are you sure that you want to proceed?", + result: true, + }); + + writeWranglerConfig({ + pages_build_output_dir: "public", + name: "test-name", + }); + await expect(runWrangler("deploy --x-autoconfig")).rejects.toThrowError(); + expect(std.warn).toContain( + "It seems that you have run `wrangler deploy` on a Pages project, `wrangler pages deploy` should be used instead." + ); + }); + it("should attempt to run the autoconfig flow when pages_build_output_dir and (--x-autoconfig is used)", async () => { writeWranglerConfig({ pages_build_output_dir: "public", @@ -589,7 +603,7 @@ describe("deploy", () => { const getDetailsForAutoConfigSpy = vi .spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig") - .mockResolvedValue({ + .mockResolvedValueOnce({ configured: false, projectPath: process.cwd(), workerName: "test-name", @@ -628,7 +642,7 @@ describe("deploy", () => { const getDetailsForAutoConfigSpy = vi .spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig") - .mockResolvedValue({ + .mockResolvedValueOnce({ configured: false, projectPath: process.cwd(), workerName: "test-name", @@ -16603,13 +16617,13 @@ export default{ expect(std.warn).toMatchInlineSnapshot(`""`); }); - it("should not delegate to open-next deploy when the --x-autoconfig flag is not provided", async () => { + it("should not delegate to open-next deploy when --x-autoconfig=false is provided", async () => { const runCommandSpy = (await import("../autoconfig/c3-vendor/command")) .runCommand; await mockOpenNextLikeProject(); - await runWrangler("deploy"); + await runWrangler("deploy --x-autoconfig=false"); expect(runCommandSpy).not.toHaveBeenCalledOnce(); diff --git a/packages/wrangler/src/__tests__/index.test.ts b/packages/wrangler/src/__tests__/index.test.ts index e5d715125782..7d5fd7c23c6c 100644 --- a/packages/wrangler/src/__tests__/index.test.ts +++ b/packages/wrangler/src/__tests__/index.test.ts @@ -58,7 +58,7 @@ describe("wrangler", () => { wrangler queues 📬 Manage Workers Queues wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker wrangler secret 🤫 Generate a secret that can be referenced in a Worker - wrangler setup 🪄 Setup a project to work on Cloudflare [experimental] + wrangler setup 🪄 Setup a project to work on Cloudflare wrangler tail [worker] 🦚 Start a log tailing session for a Worker wrangler triggers 🎯 Updates the triggers of your current deployment [experimental] wrangler types [path] 📝 Generate types from your Worker configuration @@ -129,7 +129,7 @@ describe("wrangler", () => { wrangler queues 📬 Manage Workers Queues wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker wrangler secret 🤫 Generate a secret that can be referenced in a Worker - wrangler setup 🪄 Setup a project to work on Cloudflare [experimental] + wrangler setup 🪄 Setup a project to work on Cloudflare wrangler tail [worker] 🦚 Start a log tailing session for a Worker wrangler triggers 🎯 Updates the triggers of your current deployment [experimental] wrangler types [path] 📝 Generate types from your Worker configuration diff --git a/packages/wrangler/src/__tests__/setup.test.ts b/packages/wrangler/src/__tests__/setup.test.ts index 69c55a858bf4..e55ebb422007 100644 --- a/packages/wrangler/src/__tests__/setup.test.ts +++ b/packages/wrangler/src/__tests__/setup.test.ts @@ -35,7 +35,7 @@ describe("wrangler setup", () => { expect(std.out).toMatchInlineSnapshot(` "wrangler setup - 🪄 Setup a project to work on Cloudflare [experimental] + 🪄 Setup a project to work on Cloudflare GLOBAL FLAGS -c, --config Path to Wrangler configuration file [string] diff --git a/packages/wrangler/src/autoconfig/details.ts b/packages/wrangler/src/autoconfig/details.ts index 0275dcf5e914..18ce1a91dcf0 100644 --- a/packages/wrangler/src/autoconfig/details.ts +++ b/packages/wrangler/src/autoconfig/details.ts @@ -238,6 +238,7 @@ async function detectFramework( name: "Cloudflare Pages", id: "cloudflare-pages", }, + dist: wranglerConfig?.pages_build_output_dir, }, packageManager, }; diff --git a/packages/wrangler/src/deploy/index.ts b/packages/wrangler/src/deploy/index.ts index 399028ac80ae..6acbab3e035f 100644 --- a/packages/wrangler/src/deploy/index.ts +++ b/packages/wrangler/src/deploy/index.ts @@ -256,7 +256,7 @@ export const deployCommand = createCommand({ describe: "Experimental: Enables framework detection and automatic configuration when deploying", type: "boolean", - default: false, + default: true, }, }, behaviour: { diff --git a/packages/wrangler/src/setup.ts b/packages/wrangler/src/setup.ts index b02a6703c168..b30ae5727d31 100644 --- a/packages/wrangler/src/setup.ts +++ b/packages/wrangler/src/setup.ts @@ -14,7 +14,7 @@ export const setupCommand = createCommand({ metadata: { description: "🪄 Setup a project to work on Cloudflare", owner: "Workers: Authoring and Testing", - status: "experimental", + status: "stable", category: "Compute & AI", }, args: {