Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-moons-argue.md
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions .changeset/yummy-snails-stand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

Mark the `wrangler setup` command as stable
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/autoconfig/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
30 changes: 22 additions & 8 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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.
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/__tests__/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/autoconfig/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ async function detectFramework(
name: "Cloudflare Pages",
id: "cloudflare-pages",
},
dist: wranglerConfig?.pages_build_output_dir,
},
packageManager,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading