Skip to content

Commit 8d882fa

Browse files
Autoconfig GA (#12614)
1 parent d4e335e commit 8d882fa

File tree

9 files changed

+40
-15
lines changed

9 files changed

+40
-15
lines changed

.changeset/gentle-moons-argue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Enable autoconfig for `wrangler deploy` by default (while allowing users to still disable it via `--x-autoconfig=false` if necessary)

.changeset/yummy-snails-stand.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Mark the `wrangler setup` command as stable

packages/wrangler/src/__tests__/autoconfig/run.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ describe("autoconfig (deploy)", () => {
9494
clearOutputFilePath();
9595
});
9696

97-
it("should not check for autoconfig without flag", async () => {
97+
it("should not check for autoconfig when `deploy` is run with `--x-autoconfig=false`", async () => {
9898
writeWorkerSource();
9999
writeWranglerConfig({ main: "index.js" });
100100
const getDetailsSpy = vi.spyOn(details, "getDetailsForAutoConfig");
101-
await runDeploy();
101+
await runDeploy(`--x-autoconfig=false`);
102102

103103
expect(getDetailsSpy).not.toHaveBeenCalled();
104104
});

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ vi.mock("../package-manager", async (importOriginal) => ({
114114
},
115115
}));
116116

117-
vi.mock("../autoconfig/details");
118117
vi.mock("../autoconfig/run");
119-
vi.mock("../autoconfig/frameworks");
120118
vi.mock("../autoconfig/frameworks/utils/packages");
121119
vi.mock("../autoconfig/c3-vendor/command");
122120

@@ -566,13 +564,13 @@ describe("deploy", () => {
566564
`);
567565
});
568566

569-
it("should error helpfully if pages_build_output_dir is set in wrangler.toml", async () => {
567+
it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --x-autoconfig=false", async () => {
570568
writeWranglerConfig({
571569
pages_build_output_dir: "public",
572570
name: "test-name",
573571
});
574572
await expect(
575-
runWrangler("deploy")
573+
runWrangler("deploy --x-autoconfig=false")
576574
).rejects.toThrowErrorMatchingInlineSnapshot(
577575
`
578576
[Error: It looks like you've run a Workers-specific command in a Pages project.
@@ -581,6 +579,22 @@ describe("deploy", () => {
581579
);
582580
});
583581

582+
it("should error helpfully if pages_build_output_dir is set in wrangler.toml and --x-autoconfig is provided", async () => {
583+
mockConfirm({
584+
text: "Are you sure that you want to proceed?",
585+
result: true,
586+
});
587+
588+
writeWranglerConfig({
589+
pages_build_output_dir: "public",
590+
name: "test-name",
591+
});
592+
await expect(runWrangler("deploy --x-autoconfig")).rejects.toThrowError();
593+
expect(std.warn).toContain(
594+
"It seems that you have run `wrangler deploy` on a Pages project, `wrangler pages deploy` should be used instead."
595+
);
596+
});
597+
584598
it("should attempt to run the autoconfig flow when pages_build_output_dir and (--x-autoconfig is used)", async () => {
585599
writeWranglerConfig({
586600
pages_build_output_dir: "public",
@@ -589,7 +603,7 @@ describe("deploy", () => {
589603

590604
const getDetailsForAutoConfigSpy = vi
591605
.spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig")
592-
.mockResolvedValue({
606+
.mockResolvedValueOnce({
593607
configured: false,
594608
projectPath: process.cwd(),
595609
workerName: "test-name",
@@ -628,7 +642,7 @@ describe("deploy", () => {
628642

629643
const getDetailsForAutoConfigSpy = vi
630644
.spyOn(await import("../autoconfig/details"), "getDetailsForAutoConfig")
631-
.mockResolvedValue({
645+
.mockResolvedValueOnce({
632646
configured: false,
633647
projectPath: process.cwd(),
634648
workerName: "test-name",
@@ -16603,13 +16617,13 @@ export default{
1660316617
expect(std.warn).toMatchInlineSnapshot(`""`);
1660416618
});
1660516619

16606-
it("should not delegate to open-next deploy when the --x-autoconfig flag is not provided", async () => {
16620+
it("should not delegate to open-next deploy when --x-autoconfig=false is provided", async () => {
1660716621
const runCommandSpy = (await import("../autoconfig/c3-vendor/command"))
1660816622
.runCommand;
1660916623

1661016624
await mockOpenNextLikeProject();
1661116625

16612-
await runWrangler("deploy");
16626+
await runWrangler("deploy --x-autoconfig=false");
1661316627

1661416628
expect(runCommandSpy).not.toHaveBeenCalledOnce();
1661516629

packages/wrangler/src/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("wrangler", () => {
5858
wrangler queues 📬 Manage Workers Queues
5959
wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker
6060
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
61-
wrangler setup 🪄 Setup a project to work on Cloudflare [experimental]
61+
wrangler setup 🪄 Setup a project to work on Cloudflare
6262
wrangler tail [worker] 🦚 Start a log tailing session for a Worker
6363
wrangler triggers 🎯 Updates the triggers of your current deployment [experimental]
6464
wrangler types [path] 📝 Generate types from your Worker configuration
@@ -129,7 +129,7 @@ describe("wrangler", () => {
129129
wrangler queues 📬 Manage Workers Queues
130130
wrangler rollback [version-id] 🔙 Rollback a deployment for a Worker
131131
wrangler secret 🤫 Generate a secret that can be referenced in a Worker
132-
wrangler setup 🪄 Setup a project to work on Cloudflare [experimental]
132+
wrangler setup 🪄 Setup a project to work on Cloudflare
133133
wrangler tail [worker] 🦚 Start a log tailing session for a Worker
134134
wrangler triggers 🎯 Updates the triggers of your current deployment [experimental]
135135
wrangler types [path] 📝 Generate types from your Worker configuration

packages/wrangler/src/__tests__/setup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe("wrangler setup", () => {
3535
expect(std.out).toMatchInlineSnapshot(`
3636
"wrangler setup
3737
38-
🪄 Setup a project to work on Cloudflare [experimental]
38+
🪄 Setup a project to work on Cloudflare
3939
4040
GLOBAL FLAGS
4141
-c, --config Path to Wrangler configuration file [string]

packages/wrangler/src/autoconfig/details.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ async function detectFramework(
253253
name: "Cloudflare Pages",
254254
id: "cloudflare-pages",
255255
},
256+
dist: wranglerConfig?.pages_build_output_dir,
256257
},
257258
packageManager,
258259
};

packages/wrangler/src/deploy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const deployCommand = createCommand({
256256
describe:
257257
"Experimental: Enables framework detection and automatic configuration when deploying",
258258
type: "boolean",
259-
default: false,
259+
default: true,
260260
},
261261
},
262262
behaviour: {

packages/wrangler/src/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const setupCommand = createCommand({
1414
metadata: {
1515
description: "🪄 Setup a project to work on Cloudflare",
1616
owner: "Workers: Authoring and Testing",
17-
status: "experimental",
17+
status: "stable",
1818
category: "Compute & AI",
1919
},
2020
args: {

0 commit comments

Comments
 (0)