From 32f9307862ced8d25c44fd3b0161b60354559cd8 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 12 Jun 2026 15:37:39 +0100 Subject: [PATCH 1/4] Graduate autoconfig from experimental to stable (#14276) --- .changeset/graduate-autoconfig-stable.md | 9 + .../src/__tests__/autoconfig/run.test.ts | 29 ++- .../src/__tests__/deploy/core.test.ts | 18 +- .../src/__tests__/deploy/entry-points.test.ts | 232 +----------------- .../src/__tests__/deploy/open-next.test.ts | 24 +- packages/wrangler/src/deploy/autoconfig.ts | 6 +- packages/wrangler/src/deploy/index.ts | 7 +- packages/wrangler/src/metrics/sanitization.ts | 2 +- 8 files changed, 62 insertions(+), 265 deletions(-) create mode 100644 .changeset/graduate-autoconfig-stable.md diff --git a/.changeset/graduate-autoconfig-stable.md b/.changeset/graduate-autoconfig-stable.md new file mode 100644 index 0000000000..0f6c26675d --- /dev/null +++ b/.changeset/graduate-autoconfig-stable.md @@ -0,0 +1,9 @@ +--- +"wrangler": minor +--- + +Graduate autoconfig from experimental to stable + +The `--experimental-autoconfig` and `--x-autoconfig` deploy CLI flags have been replaced with `--autoconfig`. + +Note that the `--autoconfig` flag defaults to `true` and that it can be used to disable Wrangler's auto-configuration logic by setting it to `false` via `--autoconfig=false` or `--no-autoconfig` diff --git a/packages/wrangler/src/__tests__/autoconfig/run.test.ts b/packages/wrangler/src/__tests__/autoconfig/run.test.ts index 4d5134bfb2..369a4aeeeb 100644 --- a/packages/wrangler/src/__tests__/autoconfig/run.test.ts +++ b/packages/wrangler/src/__tests__/autoconfig/run.test.ts @@ -92,21 +92,38 @@ describe("autoconfig (deploy)", () => { clearOutputFilePath(); }); - it("should not check for autoconfig when `deploy` is run with `--x-autoconfig=false`", async ({ + it("should not run autoconfig when `deploy` is run with `--no-autoconfig`", async ({ expect, }) => { writeWorkerSource(); writeWranglerConfig({ main: "index.js" }); const getDetailsSpy = vi.spyOn(details, "getDetailsForAutoConfig"); - await runDeploy(expect, `--x-autoconfig=false`); + const runSpy = vi.spyOn(run, "runAutoConfig"); + + await runDeploy(expect, `--no-autoconfig`); expect(getDetailsSpy).not.toHaveBeenCalled(); + expect(runSpy).not.toHaveBeenCalled(); + }); + + it("should not run autoconfig when `deploy` is run with `--autoconfig=false`", async ({ + expect, + }) => { + writeWorkerSource(); + writeWranglerConfig({ main: "index.js" }); + const getDetailsSpy = vi.spyOn(details, "getDetailsForAutoConfig"); + const runSpy = vi.spyOn(run, "runAutoConfig"); + + await runDeploy(expect, `--autoconfig=false`); + + expect(getDetailsSpy).not.toHaveBeenCalled(); + expect(runSpy).not.toHaveBeenCalled(); }); it("should check for autoconfig with flag", async ({ expect }) => { const getDetailsSpy = vi.spyOn(details, "getDetailsForAutoConfig"); - await runDeploy(expect, "--x-autoconfig"); + await runDeploy(expect, "--autoconfig"); expect(getDetailsSpy).toHaveBeenCalled(); }); @@ -128,7 +145,7 @@ describe("autoconfig (deploy)", () => { ); const runSpy = vi.spyOn(run, "runAutoConfig"); - await runDeploy(expect, "--x-autoconfig"); + await runDeploy(expect, "--autoconfig"); expect(getDetailsSpy).toHaveBeenCalled(); expect(runSpy).toHaveBeenCalled(); @@ -149,7 +166,7 @@ describe("autoconfig (deploy)", () => { ); const runSpy = vi.spyOn(run, "runAutoConfig"); - await runDeploy(expect, "--x-autoconfig"); + await runDeploy(expect, "--autoconfig"); expect(getDetailsSpy).toHaveBeenCalled(); expect(runSpy).not.toHaveBeenCalled(); @@ -182,7 +199,7 @@ describe("autoconfig (deploy)", () => { }); // Should not throw - just return early - await runWrangler("deploy --x-autoconfig"); + await runWrangler("deploy --autoconfig"); // Should show warning about Pages project expect(std.warn).toContain( diff --git a/packages/wrangler/src/__tests__/deploy/core.test.ts b/packages/wrangler/src/__tests__/deploy/core.test.ts index 0f4ea1fd99..a599b7f9c7 100644 --- a/packages/wrangler/src/__tests__/deploy/core.test.ts +++ b/packages/wrangler/src/__tests__/deploy/core.test.ts @@ -535,7 +535,7 @@ describe("deploy", () => { `); }); - it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --x-autoconfig=false", async ({ + it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --no-autoconfig", async ({ expect, }) => { writeWranglerConfig({ @@ -543,7 +543,7 @@ describe("deploy", () => { name: "test-name", }); await expect( - runWrangler("deploy --x-autoconfig=false") + runWrangler("deploy --no-autoconfig") ).rejects.toThrowErrorMatchingInlineSnapshot( ` [Error: It looks like you've run a Workers-specific command in a Pages project. @@ -552,7 +552,7 @@ describe("deploy", () => { ); }); - it("should error helpfully if pages_build_output_dir is set in wrangler.toml and --x-autoconfig is provided", async ({ + it("should error helpfully if pages_build_output_dir is set in wrangler.toml", async ({ expect, }) => { mockConfirm({ @@ -564,13 +564,13 @@ describe("deploy", () => { pages_build_output_dir: "public", name: "test-name", }); - await expect(runWrangler("deploy --x-autoconfig")).rejects.toThrowError(); + await expect(runWrangler("deploy")).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 ({ + it("should attempt to run the autoconfig flow when pages_build_output_dir", async ({ expect, }) => { writeWranglerConfig({ @@ -603,7 +603,7 @@ describe("deploy", () => { result: false, }); - await runWrangler("deploy --x-autoconfig"); + await runWrangler("deploy"); expect(getDetailsForAutoConfigSpy).toHaveBeenCalled(); @@ -612,7 +612,7 @@ describe("deploy", () => { ); }); - it("in non-interactive mode, attempts to deploy a Pages project when --x-autoconfig is used", async ({ + it("in non-interactive mode, attempts to deploy a Pages project using autoconfig", async ({ expect, }) => { setIsTTY(false); @@ -642,7 +642,7 @@ describe("deploy", () => { // The command will fail later due to missing entry-point, but we can still verify // that the deployment of the (Pages) project was attempted - await expect(runWrangler("deploy --x-autoconfig")).rejects.toThrow(); + await expect(runWrangler("deploy")).rejects.toThrow(); expect(getDetailsForAutoConfigSpy).toHaveBeenCalled(); @@ -1433,7 +1433,7 @@ describe("deploy", () => { }; }); - await runWrangler("deploy --x-autoconfig --dry-run", { + await runWrangler("deploy --dry-run", { ...process.env, WRANGLER_OUTPUT_FILE_PATH: outputFile, }); diff --git a/packages/wrangler/src/__tests__/deploy/entry-points.test.ts b/packages/wrangler/src/__tests__/deploy/entry-points.test.ts index f981ec791d..e0301090de 100644 --- a/packages/wrangler/src/__tests__/deploy/entry-points.test.ts +++ b/packages/wrangler/src/__tests__/deploy/entry-points.test.ts @@ -340,7 +340,7 @@ export default{ expect(std.err).toMatchInlineSnapshot(`""`); }); - it("should not trigger autoconfig on `wrangler deploy