create-cloudflare 2.70.4 → 2.70.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1011 -916
- package/package.json +6 -6
- package/templates/waku/c3.ts +45 -2
- package/templates/waku/templates/public/404.html +1 -0
- package/templates/waku/templates/public/_headers +4 -0
- package/templates/waku/templates/src/waku.server.tsx +18 -0
- package/templates/waku/templates/waku.config.ts +41 -0
- package/templates/waku/templates/wrangler.jsonc +26 -0
- package/templates/waku/wrangler.jsonc +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.70.
|
|
3
|
+
"version": "2.70.6",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/parser": "^7.21.3",
|
|
32
32
|
"@babel/types": "^7.21.4",
|
|
33
33
|
"@clack/prompts": "^1.2.0",
|
|
34
|
-
"@cloudflare/workers-types": "^4.
|
|
34
|
+
"@cloudflare/workers-types": "^4.20260623.1",
|
|
35
35
|
"@types/command-exists": "^1.2.0",
|
|
36
36
|
"@types/cross-spawn": "^6.0.2",
|
|
37
37
|
"@types/deepmerge": "^2.2.0",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
"wrap-ansi": "^9.0.0",
|
|
73
73
|
"xdg-app-paths": "^8.3.0",
|
|
74
74
|
"yargs": "^17.7.2",
|
|
75
|
-
"@cloudflare/cli-shared-helpers": "0.1.
|
|
75
|
+
"@cloudflare/cli-shared-helpers": "0.1.10",
|
|
76
76
|
"@cloudflare/codemod": "1.1.0",
|
|
77
77
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
78
|
-
"@cloudflare/vite-plugin": "1.42.0",
|
|
79
78
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
80
|
-
"@cloudflare/
|
|
81
|
-
"
|
|
79
|
+
"@cloudflare/vite-plugin": "1.42.2",
|
|
80
|
+
"@cloudflare/workers-utils": "0.24.0",
|
|
81
|
+
"wrangler": "4.104.0"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=22.0.0"
|
package/templates/waku/c3.ts
CHANGED
|
@@ -1,17 +1,54 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { logRaw } from "@cloudflare/cli-shared-helpers";
|
|
3
|
+
import { brandColor, dim } from "@cloudflare/cli-shared-helpers/colors";
|
|
4
|
+
import { spinner } from "@cloudflare/cli-shared-helpers/interactive";
|
|
1
5
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
6
|
+
import { removeFile } from "helpers/files";
|
|
2
7
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
8
|
+
import { installPackages } from "helpers/packages";
|
|
3
9
|
import type { TemplateConfig } from "../../src/templates";
|
|
4
10
|
import type { C3Context } from "types";
|
|
5
11
|
|
|
6
12
|
const { npm } = detectPackageManager();
|
|
7
13
|
|
|
8
14
|
const generate = async (ctx: C3Context) => {
|
|
15
|
+
// We use the default `create-waku` template and overlay our Cloudflare-specific
|
|
16
|
+
// files via `copyFiles`. This avoids depending on an external example repository
|
|
17
|
+
// for the scaffolded project content (which could be renamed, moved, or deleted).
|
|
9
18
|
await runFrameworkGenerator(ctx, [
|
|
10
19
|
"--project-name",
|
|
11
20
|
ctx.project.name,
|
|
12
|
-
|
|
13
|
-
"
|
|
21
|
+
// c3 installs dependencies itself once the template files have been copied over
|
|
22
|
+
"--skip-install",
|
|
14
23
|
]);
|
|
24
|
+
|
|
25
|
+
logRaw(""); // newline
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const configure = async (ctx: C3Context) => {
|
|
29
|
+
// `npmInstall` has already run with the default Waku template's `package.json`,
|
|
30
|
+
// which doesn't include the Cloudflare build dependencies that our overlaid
|
|
31
|
+
// `waku.config.ts` and Workers setup need. Install them now (this also adds them
|
|
32
|
+
// to `package.json`). `wrangler` is installed separately by `installWrangler()`
|
|
33
|
+
// in the main configure flow before this runs.
|
|
34
|
+
await installPackages(
|
|
35
|
+
["@cloudflare/vite-plugin", "miniflare", "@types/node"],
|
|
36
|
+
{
|
|
37
|
+
dev: true,
|
|
38
|
+
startText: "Installing Cloudflare build dependencies",
|
|
39
|
+
doneText: `${brandColor("installed")} ${dim(
|
|
40
|
+
"@cloudflare/vite-plugin, miniflare, @types/node"
|
|
41
|
+
)}`,
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// The default Waku template ships a Hono trailing-slash dev middleware. On
|
|
46
|
+
// Cloudflare this is handled by `html_handling: "drop-trailing-slash"` in
|
|
47
|
+
// `wrangler.jsonc` (and `public/_headers`), so remove the redundant middleware.
|
|
48
|
+
const s = spinner();
|
|
49
|
+
s.start("Removing non-Cloudflare artifacts from template");
|
|
50
|
+
removeFile(resolve(ctx.project.path, "src/middleware/no-trailing-slash.ts"));
|
|
51
|
+
s.stop(`${brandColor("removed")} ${dim("trailing-slash dev middleware")}`);
|
|
15
52
|
};
|
|
16
53
|
|
|
17
54
|
const config: TemplateConfig = {
|
|
@@ -20,12 +57,18 @@ const config: TemplateConfig = {
|
|
|
20
57
|
frameworkCli: "create-waku",
|
|
21
58
|
platform: "workers",
|
|
22
59
|
displayName: "Waku",
|
|
60
|
+
copyFiles: {
|
|
61
|
+
path: "./templates",
|
|
62
|
+
},
|
|
23
63
|
path: "templates/waku",
|
|
24
64
|
generate,
|
|
65
|
+
configure,
|
|
25
66
|
transformPackageJson: async () => ({
|
|
26
67
|
scripts: {
|
|
27
68
|
deploy: `${npm} run build && wrangler deploy`,
|
|
28
69
|
preview: `NODE_ENV=production ${npm} run build && wrangler dev`,
|
|
70
|
+
start: `wrangler dev`,
|
|
71
|
+
"cf-typegen": `wrangler types`,
|
|
29
72
|
},
|
|
30
73
|
}),
|
|
31
74
|
devScript: "dev",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Not Found</h1>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fsRouter } from 'waku';
|
|
2
|
+
import adapter from 'waku/adapters/cloudflare';
|
|
3
|
+
|
|
4
|
+
export default adapter(fsRouter(import.meta.glob('./pages/**/*.{tsx,ts}')), {
|
|
5
|
+
handlers: {
|
|
6
|
+
// Define additional Cloudflare Workers handlers here
|
|
7
|
+
// https://developers.cloudflare.com/workers/runtime-apis/handlers/
|
|
8
|
+
// async queue(
|
|
9
|
+
// batch: MessageBatch,
|
|
10
|
+
// _env: Env,
|
|
11
|
+
// _ctx: ExecutionContext,
|
|
12
|
+
// ): Promise<void> {
|
|
13
|
+
// for (const message of batch.messages) {
|
|
14
|
+
// console.log('Received', message);
|
|
15
|
+
// }
|
|
16
|
+
// },
|
|
17
|
+
} satisfies ExportedHandler<Env>,
|
|
18
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
2
|
+
import babel from '@rolldown/plugin-babel';
|
|
3
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
+
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
|
|
5
|
+
import { defineConfig } from 'waku/config';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
vite: {
|
|
9
|
+
environments: {
|
|
10
|
+
rsc: {
|
|
11
|
+
optimizeDeps: {
|
|
12
|
+
include: ['hono/tiny'],
|
|
13
|
+
},
|
|
14
|
+
build: {
|
|
15
|
+
rolldownOptions: {
|
|
16
|
+
platform: 'neutral',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
ssr: {
|
|
21
|
+
optimizeDeps: {
|
|
22
|
+
include: ['waku > rsc-html-stream/server'],
|
|
23
|
+
},
|
|
24
|
+
build: {
|
|
25
|
+
rolldownOptions: {
|
|
26
|
+
platform: 'neutral',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
plugins: [
|
|
32
|
+
tailwindcss(),
|
|
33
|
+
react(),
|
|
34
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
35
|
+
cloudflare({
|
|
36
|
+
viteEnvironment: { name: 'rsc', childEnvironments: ['ssr'] },
|
|
37
|
+
inspectorPort: false,
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "<WORKER_NAME>",
|
|
4
|
+
"main": "./src/waku.server",
|
|
5
|
+
// nodejs_als is required for Waku server-side request context
|
|
6
|
+
// It can be removed if only building static pages
|
|
7
|
+
"compatibility_flags": ["nodejs_als"],
|
|
8
|
+
// https://developers.cloudflare.com/workers/platform/compatibility-dates
|
|
9
|
+
"compatibility_date": "<COMPATIBILITY_DATE>",
|
|
10
|
+
"assets": {
|
|
11
|
+
// https://developers.cloudflare.com/workers/static-assets/binding/
|
|
12
|
+
"binding": "ASSETS",
|
|
13
|
+
"directory": "./dist/public",
|
|
14
|
+
"html_handling": "drop-trailing-slash"
|
|
15
|
+
},
|
|
16
|
+
"vars": {
|
|
17
|
+
"MAX_ITEMS": 10
|
|
18
|
+
},
|
|
19
|
+
"rules": [
|
|
20
|
+
{
|
|
21
|
+
"type": "ESModule",
|
|
22
|
+
"globs": ["**/*.js", "**/*.mjs"]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"no_bundle": true
|
|
26
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<WORKER_NAME>",
|
|
3
|
-
"main": "./dist/server/serve-cloudflare.js",
|
|
4
|
-
// nodejs_als is required for Waku server-side request context
|
|
5
|
-
// It can be removed if only building static pages
|
|
6
|
-
"compatibility_flags": ["nodejs_als"],
|
|
7
|
-
// https://developers.cloudflare.com/workers/platform/compatibility-dates
|
|
8
|
-
"compatibility_date": "<COMPATIBILITY_DATE>",
|
|
9
|
-
"assets": {
|
|
10
|
-
// https://developers.cloudflare.com/workers/static-assets/binding/
|
|
11
|
-
"binding": "ASSETS",
|
|
12
|
-
"directory": "./dist/public",
|
|
13
|
-
"html_handling": "drop-trailing-slash"
|
|
14
|
-
},
|
|
15
|
-
"vars": {
|
|
16
|
-
"MAX_ITEMS": 10
|
|
17
|
-
}
|
|
18
|
-
}
|