Skip to content

Commit 7e0d750

Browse files
rmarscherCarmenPopoviciupetebacondarwin
authored
feat: add Waku to C3 (#8314)
* feat: add Waku to C3 Fixes #7594. Adding a C3 template for Waku, a minimal React framework. https://waku.gg/ - Tests - [ ] TODO (before merge) - [x] Tests included - [ ] Tests not necessary because: - E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately) - [ ] I don't know - [x] Required - [ ] Not required because: - Public documentation - [ ] TODO (before merge) - [x] Cloudflare docs PR(s): <cloudflare/cloudflare-docs#20444> - [ ] Documentation not necessary because: * Update .changeset/moody-hands-sort.md * fix up snapshots * update snapshots more * Latest create-waku * Fix waku build by forcing NODE_ENV=production --------- Co-authored-by: Carmen Popoviciu <[email protected]> Co-authored-by: Peter Bacon Darwin <[email protected]>
1 parent a7f6966 commit 7e0d750

File tree

7 files changed

+78
-1
lines changed

7 files changed

+78
-1
lines changed

.changeset/moody-hands-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": minor
3+
---
4+
5+
feat(create-cloudflare): Add Waku Workers template

packages/create-cloudflare/e2e/tests/cli/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ describe("Create Cloudflare CLI", () => {
584584
npm create cloudflare -- --framework next -- --ts
585585
pnpm create cloudflare --framework next -- --ts
586586
Allowed Values:
587-
analog, angular, astro, docusaurus, gatsby, hono, next, nuxt, qwik, react, react-router, solid, svelte, vue
587+
analog, angular, astro, docusaurus, gatsby, hono, next, nuxt, qwik, react, react-router, solid, svelte, vue, waku
588588
--platform=<value>
589589
Whether the application should be deployed to Pages or Workers. This is only applicable for Frameworks templates that support both Pages and Workers.
590590
Allowed Values:

packages/create-cloudflare/e2e/tests/frameworks/test-config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,21 @@ function getFrameworkTestConfig(pm: string): NamedFrameworkTestConfig[] {
567567
},
568568
nodeCompat: false,
569569
},
570+
{
571+
name: "waku",
572+
testCommitMessage: true,
573+
timeout: LONG_TIMEOUT,
574+
unsupportedOSs: ["win32"],
575+
verifyDeploy: {
576+
route: "/",
577+
expectedText: "Waku",
578+
},
579+
verifyPreview: {
580+
route: "/",
581+
expectedText: "Waku",
582+
},
583+
nodeCompat: false,
584+
},
570585
];
571586
}
572587

packages/create-cloudflare/src/frameworks/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"create-react-router": "7.8.2",
1717
"create-solid": "0.6.7",
1818
"create-vue": "3.18.0",
19+
"create-waku": "0.12.5-0.26.1-0",
1920
"gatsby": "5.15.0",
2021
"sv": "0.9.6",
2122
"nuxi": "3.28.0"

packages/create-cloudflare/src/templates.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import scheduledTemplate from "templates/scheduled/c3";
4343
import solidTemplate from "templates/solid/c3";
4444
import svelteTemplate from "templates/svelte/c3";
4545
import vueTemplate from "templates/vue/c3";
46+
import wakuTemplate from "templates/waku/c3";
4647
import { isInsideGitRepo } from "./git";
4748
import { validateProjectDirectory, validateTemplateUrl } from "./validators";
4849
import type { Option } from "@cloudflare/cli/interactive";
@@ -204,6 +205,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
204205
solid: solidTemplate,
205206
svelte: svelteTemplate,
206207
vue: vueTemplate,
208+
waku: wakuTemplate,
207209
};
208210
}
209211
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { runFrameworkGenerator } from "frameworks/index";
2+
import { detectPackageManager } from "helpers/packageManagers";
3+
import type { TemplateConfig } from "../../src/templates";
4+
import type { C3Context } from "types";
5+
6+
const { npm } = detectPackageManager();
7+
8+
const generate = async (ctx: C3Context) => {
9+
await runFrameworkGenerator(ctx, [
10+
"--project-name",
11+
ctx.project.name,
12+
"--template",
13+
"07_cloudflare",
14+
]);
15+
};
16+
17+
const config: TemplateConfig = {
18+
configVersion: 1,
19+
id: "waku",
20+
frameworkCli: "create-waku",
21+
platform: "workers",
22+
displayName: "Waku",
23+
path: "templates/waku",
24+
generate,
25+
transformPackageJson: async () => ({
26+
scripts: {
27+
deploy: `${npm} run build && wrangler deploy`,
28+
preview: `NODE_ENV=production ${npm} run build && wrangler dev`,
29+
},
30+
}),
31+
devScript: "dev",
32+
deployScript: "deploy",
33+
previewScript: "preview",
34+
};
35+
export default config;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "<TBD>",
3+
"main": "./dist/worker/serve-cloudflare.js",
4+
// https://developers.cloudflare.com/workers/platform/compatibility-dates
5+
"compatibility_date": "<TBD>",
6+
// nodejs_als is required for Waku server-side request context
7+
// It can be removed if only building static pages
8+
"compatibility_flags": ["nodejs_als"],
9+
// https://developers.cloudflare.com/workers/static-assets/binding/
10+
"assets": {
11+
"binding": "ASSETS",
12+
"directory": "./dist/assets",
13+
"html_handling": "drop-trailing-slash",
14+
"not_found_handling": "404-page"
15+
},
16+
"vars": {
17+
"MAX_ITEMS": 10
18+
}
19+
}

0 commit comments

Comments
 (0)