Skip to content

Commit c0e249e

Browse files
Properly error on Hono projects in auto-config (#11647)
* bump `@netlify/build-info` * Properly error on Hono projects in auto-config * add wrangler e2e tests for hono auto-config * Update .changeset/slow-moose-cross.md Co-authored-by: Matt Kane <m@mk.gg> --------- Co-authored-by: Matt Kane <m@mk.gg>
1 parent 2cf3b70 commit c0e249e

File tree

19 files changed

+181
-23
lines changed

19 files changed

+181
-23
lines changed

.changeset/slow-moose-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
The auto-configuration logic present in `wrangler setup` and `wrangler deploy --x-autoconfig` cannot reliably handle Hono projects, so in these cases make sure to properly error saying that automatically configuring such projects is not supported.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "hono-cf-workers-app",
3+
"type": "module",
4+
"scripts": {
5+
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
6+
"deploy": "wrangler deploy --minify",
7+
"dev": "wrangler dev"
8+
},
9+
"dependencies": {
10+
"hono": "^4.11.1"
11+
},
12+
"devDependencies": {
13+
"wrangler": "^4.4.0"
14+
}
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Hono } from "hono";
2+
3+
const app = new Hono();
4+
5+
app.get("/", (c) => {
6+
return c.text("Hello Hono!");
7+
});
8+
9+
export default app;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"strict": true,
7+
"skipLibCheck": true,
8+
"lib": ["ESNext"],
9+
"jsx": "react-jsx",
10+
"jsxImportSource": "hono/jsx"
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "node_modules/wrangler/config-schema.json",
3+
"name": "my-hono-cf-workers-app",
4+
"main": "src/index.ts",
5+
"compatibility_date": "2025-12-15",
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "hono-nodejs-app",
3+
"type": "module",
4+
"scripts": {
5+
"build": "tsc",
6+
"dev": "tsx watch src/index.ts",
7+
"start": "node dist/index.js"
8+
},
9+
"dependencies": {
10+
"@hono/node-server": "^1.19.6",
11+
"hono": "^4.11.1"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^20.11.17",
15+
"tsx": "^4.7.1",
16+
"typescript": "^5.8.3"
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { serve } from "@hono/node-server";
2+
import { Hono } from "hono";
3+
4+
const app = new Hono();
5+
6+
app.get("/", (c) => {
7+
return c.text("Hello Hono!");
8+
});
9+
10+
serve(
11+
{
12+
fetch: app.fetch,
13+
port: 3000,
14+
},
15+
(info) => {
16+
console.log(`Server is running on http://localhost:${info.port}`);
17+
}
18+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "NodeNext",
5+
"strict": true,
6+
"verbatimModuleSyntax": true,
7+
"skipLibCheck": true,
8+
"types": ["node"],
9+
"jsx": "react-jsx",
10+
"jsxImportSource": "hono/jsx",
11+
"outDir": "./dist"
12+
},
13+
"exclude": ["node_modules"]
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { resolve } from "node:path";
2+
import { describe, expect, test } from "vitest";
3+
import { WranglerE2ETestHelper } from "../helpers/e2e-wrangler-test";
4+
5+
describe("wrangler setup", () => {
6+
describe("run on a hono project", () => {
7+
test("detects when a hono app is already configured for Cloudflare", async () => {
8+
const helper = new WranglerE2ETestHelper();
9+
await helper.seed(resolve(__dirname, "./fixtures/hono-cf-workers-app"));
10+
11+
const { status, stdout } = await helper.run("wrangler setup --yes");
12+
13+
expect(stdout).toContain(
14+
"🎉 Your project is already setup to deploy to Cloudflare"
15+
);
16+
expect(status).toBe(0);
17+
});
18+
19+
test("errors for a hono app that is not configured for Cloudflare, mentioning that auto-configuring it is not supported", async () => {
20+
const helper = new WranglerE2ETestHelper();
21+
await helper.seed(resolve(__dirname, "./fixtures/hono-nodejs-app"));
22+
23+
const { status, stderr } = await helper.run("wrangler setup --yes");
24+
25+
expect(stderr).toContain(
26+
'[ERROR] The detected framework ("Hono") cannot be automatically configured.'
27+
);
28+
expect(status).not.toBe(0);
29+
});
30+
});
31+
});

packages/wrangler/e2e/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"jsx": "preserve" // not used, but required for import of types (which transitively import jsx)
77
},
88
"include": ["vitest.config.mts", "**/*.ts", "../src/*.d.ts", "**/*.js"],
9-
"exclude": []
9+
"exclude": ["**/fixtures"]
1010
}

0 commit comments

Comments
 (0)