-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing hono with assets experimental template (#6827)
- Loading branch information
1 parent
5043749
commit 66ad6df
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-cloudflare": patch | ||
--- | ||
|
||
fix: add missing hono with assets experimental template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/create-cloudflare/templates-experimental/hono/c3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { logRaw } from "@cloudflare/cli"; | ||
import { runFrameworkGenerator } from "frameworks/index"; | ||
import { detectPackageManager } from "helpers/packageManagers"; | ||
import type { TemplateConfig } from "../../src/templates"; | ||
import type { C3Context } from "types"; | ||
|
||
const generate = async (ctx: C3Context) => { | ||
const { name: pm } = detectPackageManager(); | ||
|
||
await runFrameworkGenerator(ctx, [ | ||
ctx.project.name, | ||
"--template", | ||
"cloudflare-workers", | ||
"--install", | ||
"--pm", | ||
pm, | ||
]); | ||
|
||
logRaw(""); // newline | ||
}; | ||
|
||
const config: TemplateConfig = { | ||
configVersion: 1, | ||
id: "hono", | ||
frameworkCli: "create-hono", | ||
displayName: "Hono", | ||
copyFiles: { | ||
path: "./templates", | ||
}, | ||
platform: "workers", | ||
path: "templates-experimental/hono", | ||
generate, | ||
transformPackageJson: async () => ({ | ||
scripts: { | ||
dev: "wrangler dev", | ||
deploy: "wrangler deploy --minify", | ||
"cf-typegen": "wrangler types --env-interface CloudflareBindings", | ||
}, | ||
}), | ||
devScript: "dev", | ||
deployScript: "deploy", | ||
}; | ||
export default config; |
19 changes: 19 additions & 0 deletions
19
packages/create-cloudflare/templates-experimental/hono/templates/public/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Hello, World!</title> | ||
</head> | ||
<body> | ||
<h1 id="heading"></h1> | ||
<script> | ||
fetch('/message') | ||
.then((resp) => resp.text()) | ||
.then((text) => { | ||
const h1 = document.getElementById('heading'); | ||
h1.textContent = text; | ||
}); | ||
</script> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
packages/create-cloudflare/templates-experimental/hono/templates/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Hono } from "hono"; | ||
|
||
const app = new Hono<{ Bindings: CloudflareBindings }>(); | ||
|
||
app.get("/message", (c) => { | ||
return c.text("Hello Hono!"); | ||
}); | ||
|
||
export default app; |
4 changes: 4 additions & 0 deletions
4
packages/create-cloudflare/templates-experimental/hono/templates/worker-configuration.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Generated by Wrangler | ||
// After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen` | ||
interface CloudflareBindings { | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/create-cloudflare/templates-experimental/hono/templates/wrangler.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#:schema node_modules/wrangler/config-schema.json | ||
name = "<TBD>" | ||
main = "src/index.ts" | ||
compatibility_date = "<TBD>" | ||
assets = { directory = "./public", binding = "ASSETS" } |