Skip to content

Commit

Permalink
fix: add missing hono with assets experimental template (#6827)
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Sep 25, 2024
1 parent 5043749 commit 66ad6df
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-fishes-rest.md
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
2 changes: 2 additions & 0 deletions packages/create-cloudflare/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import gatsbyTemplateExperimental from "templates-experimental/gatsby/c3";
import assetsOnlyTemplateExperimental from "templates-experimental/hello-world-assets-only/c3";
import helloWorldWithDurableObjectAssetsTemplateExperimental from "templates-experimental/hello-world-durable-object-with-assets/c3";
import helloWorldWithAssetsTemplateExperimental from "templates-experimental/hello-world-with-assets/c3";
import honoTemplateExperimental from "templates-experimental/hono/c3";
import nuxtTemplateExperimental from "templates-experimental/nuxt/c3";
import qwikTemplateExperimental from "templates-experimental/qwik/c3";
import remixTemplateExperimental from "templates-experimental/remix/c3";
Expand Down Expand Up @@ -165,6 +166,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
astro: astroTemplateExperimental,
docusaurus: docusaurusTemplateExperimental,
gatsby: gatsbyTemplateExperimental,
hono: honoTemplateExperimental,
nuxt: nuxtTemplateExperimental,
qwik: qwikTemplateExperimental,
remix: remixTemplateExperimental,
Expand Down
43 changes: 43 additions & 0 deletions packages/create-cloudflare/templates-experimental/hono/c3.ts
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;
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>
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;
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 {
}
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" }

0 comments on commit 66ad6df

Please sign in to comment.