create-cloudflare 2.40.0 → 2.40.2

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.
Files changed (20) hide show
  1. package/dist/cli.js +610 -549
  2. package/package.json +6 -5
  3. package/templates/docusaurus/c3.ts +5 -25
  4. package/templates/docusaurus/pages/c3.ts +30 -0
  5. package/{templates-experimental/docusaurus → templates/docusaurus/workers}/c3.ts +2 -2
  6. package/templates/hello-world/py/README.md +8 -3
  7. package/templates/react/c3.ts +5 -57
  8. package/templates/react/pages/c3.ts +62 -0
  9. package/{templates-experimental/react → templates/react/workers}/c3.ts +4 -3
  10. package/{templates-experimental/react → templates/react/workers}/ts/api/index.ts +0 -4
  11. package/{templates-experimental/react → templates/react/workers}/ts/tsconfig.worker.json +1 -1
  12. package/templates/react/workers/ts/worker-configuration.d.ts +5 -0
  13. /package/{templates-experimental/docusaurus → templates/docusaurus/workers}/templates/wrangler.jsonc +0 -0
  14. /package/{templates-experimental/react → templates/react/workers}/js/api/index.js +0 -0
  15. /package/{templates-experimental/react → templates/react/workers}/js/src/App.jsx +0 -0
  16. /package/{templates-experimental/react → templates/react/workers}/js/src/assets/Cloudflare_Logo.svg +0 -0
  17. /package/{templates-experimental/react/js/wrangler.json → templates/react/workers/js/wrangler.jsonc} +0 -0
  18. /package/{templates-experimental/react → templates/react/workers}/ts/src/App.tsx +0 -0
  19. /package/{templates-experimental/react → templates/react/workers}/ts/src/assets/Cloudflare_Logo.svg +0 -0
  20. /package/{templates-experimental/react/ts/wrangler.json → templates/react/workers/ts/wrangler.jsonc} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cloudflare",
3
- "version": "2.40.0",
3
+ "version": "2.40.2",
4
4
  "description": "A CLI for creating and deploying new applications to Cloudflare.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -30,7 +30,7 @@
30
30
  "@babel/parser": "^7.21.3",
31
31
  "@babel/types": "^7.21.4",
32
32
  "@clack/prompts": "^0.6.3",
33
- "@cloudflare/workers-types": "^4.20250214.0",
33
+ "@cloudflare/workers-types": "^4.20250224.0",
34
34
  "@iarna/toml": "^3.0.0",
35
35
  "@types/command-exists": "^1.2.0",
36
36
  "@types/cross-spawn": "^6.0.2",
@@ -71,10 +71,11 @@
71
71
  "xdg-app-paths": "^8.3.0",
72
72
  "yargs": "^17.7.2",
73
73
  "@cloudflare/cli": "1.1.1",
74
- "@cloudflare/eslint-config-worker": "1.1.0",
75
- "wrangler": "3.112.0",
76
74
  "@cloudflare/mock-npm-registry": "0.0.0",
77
- "@cloudflare/workers-tsconfig": "0.0.0"
75
+ "@cloudflare/workers-tsconfig": "0.0.0",
76
+ "@cloudflare/eslint-config-worker": "1.1.0",
77
+ "wrangler": "3.113.0",
78
+ "@cloudflare/vite-plugin": "0.1.9"
78
79
  },
79
80
  "engines": {
80
81
  "node": ">=18.14.1"
@@ -1,29 +1,9 @@
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";
1
+ import pages from "./pages/c3";
2
+ import workers from "./workers/c3";
3
+ import type { MultiPlatformTemplateConfig } from "../../src/templates";
5
4
 
6
- const { npm } = detectPackageManager();
7
-
8
- const generate = async (ctx: C3Context) => {
9
- await runFrameworkGenerator(ctx, [ctx.project.name, "classic"]);
10
- };
11
-
12
- const config: TemplateConfig = {
13
- configVersion: 1,
14
- id: "docusaurus",
15
- frameworkCli: "create-docusaurus",
16
- platform: "pages",
5
+ const config: MultiPlatformTemplateConfig = {
17
6
  displayName: "Docusaurus",
18
- generate,
19
- transformPackageJson: async () => ({
20
- scripts: {
21
- preview: `${npm} run build && wrangler pages dev ./build`,
22
- deploy: `${npm} run build && wrangler pages deploy ./build`,
23
- },
24
- }),
25
- devScript: "preview",
26
- deployScript: "deploy",
27
- previewScript: "preview",
7
+ platformVariants: { pages, workers },
28
8
  };
29
9
  export default config;
@@ -0,0 +1,30 @@
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, [ctx.project.name, "classic"]);
10
+ };
11
+
12
+ const config: TemplateConfig = {
13
+ configVersion: 1,
14
+ id: "docusaurus",
15
+ frameworkCli: "create-docusaurus",
16
+ platform: "pages",
17
+ displayName: "Docusaurus",
18
+ path: "templates/docusaurus/pages",
19
+ generate,
20
+ transformPackageJson: async () => ({
21
+ scripts: {
22
+ preview: `${npm} run build && wrangler pages dev ./build`,
23
+ deploy: `${npm} run build && wrangler pages deploy ./build`,
24
+ },
25
+ }),
26
+ devScript: "preview",
27
+ deployScript: "deploy",
28
+ previewScript: "preview",
29
+ };
30
+ export default config;
@@ -1,6 +1,6 @@
1
1
  import { runFrameworkGenerator } from "frameworks/index";
2
2
  import { detectPackageManager } from "helpers/packageManagers";
3
- import type { TemplateConfig } from "../../src/templates";
3
+ import type { TemplateConfig } from "../../../src/templates";
4
4
  import type { C3Context } from "types";
5
5
 
6
6
  const { npm } = detectPackageManager();
@@ -18,7 +18,7 @@ const config: TemplateConfig = {
18
18
  copyFiles: {
19
19
  path: "./templates",
20
20
  },
21
- path: "templates-experimental/docusaurus",
21
+ path: "templates/docusaurus/workers",
22
22
  generate,
23
23
  transformPackageJson: async () => ({
24
24
  scripts: {
@@ -7,12 +7,17 @@ worker without having to restart `wrangler`.
7
7
  ### Types and autocomplete
8
8
 
9
9
  This project also includes a pyproject.toml and uv.lock file with some requirements which
10
- set up autocomplete and type hints for this Python Workers project. To get these installed
11
- you can run the following:
10
+ set up autocomplete and type hints for this Python Workers project.
11
+
12
+ To get these installed you'll need `uv`, which you can install by following
13
+ https://docs.astral.sh/uv/getting-started/installation/.
14
+
15
+ Once `uv` is installed, you can run the following:
12
16
 
13
17
  ```
14
18
  uv venv
15
19
  uv sync
16
20
  ```
17
21
 
18
- Then point your editor's Python plugin at the `.venv` directory.
22
+ Then point your editor's Python plugin at the `.venv` directory. You should then have working
23
+ autocomplete and type information in your editor.
@@ -1,61 +1,9 @@
1
- import { logRaw } from "@cloudflare/cli";
2
- import { inputPrompt } from "@cloudflare/cli/interactive";
3
- import { runFrameworkGenerator } from "frameworks/index";
4
- import { detectPackageManager } from "helpers/packageManagers";
5
- import type { TemplateConfig } from "../../src/templates";
6
- import type { C3Context } from "types";
1
+ import pages from "./pages/c3";
2
+ import workers from "./workers/c3";
3
+ import type { MultiPlatformTemplateConfig } from "../../src/templates";
7
4
 
8
- const { npm } = detectPackageManager();
9
-
10
- const generate = async (ctx: C3Context) => {
11
- const variant = await inputPrompt({
12
- type: "select",
13
- question: "Select a variant:",
14
- label: "variant",
15
- options: variantsOptions,
16
- defaultValue: variantsOptions[0].value,
17
- });
18
-
19
- await runFrameworkGenerator(ctx, [ctx.project.name, "--template", variant]);
20
-
21
- logRaw("");
22
- };
23
-
24
- const variantsOptions = [
25
- {
26
- value: "react-ts",
27
- label: "TypeScript",
28
- },
29
- {
30
- value: "react-swc-ts",
31
- label: "TypeScript + SWC",
32
- },
33
- {
34
- value: "react",
35
- label: "JavaScript",
36
- },
37
- {
38
- value: "react-swc",
39
- label: "JavaScript + SWC",
40
- },
41
- ];
42
-
43
- const config: TemplateConfig = {
44
- configVersion: 1,
45
- id: "react",
46
- // React's documentation now recommends using create-vite.
47
- frameworkCli: "create-vite",
5
+ const config: MultiPlatformTemplateConfig = {
48
6
  displayName: "React",
49
- platform: "pages",
50
- generate,
51
- transformPackageJson: async () => ({
52
- scripts: {
53
- deploy: `${npm} run build && wrangler pages deploy ./dist`,
54
- preview: `${npm} run build && wrangler pages dev ./dist`,
55
- },
56
- }),
57
- devScript: "dev",
58
- deployScript: "deploy",
59
- previewScript: "preview",
7
+ platformVariants: { pages, workers },
60
8
  };
61
9
  export default config;
@@ -0,0 +1,62 @@
1
+ import { logRaw } from "@cloudflare/cli";
2
+ import { inputPrompt } from "@cloudflare/cli/interactive";
3
+ import { runFrameworkGenerator } from "frameworks/index";
4
+ import { detectPackageManager } from "helpers/packageManagers";
5
+ import type { TemplateConfig } from "../../../src/templates";
6
+ import type { C3Context } from "types";
7
+
8
+ const { npm } = detectPackageManager();
9
+
10
+ const generate = async (ctx: C3Context) => {
11
+ const variant = await inputPrompt({
12
+ type: "select",
13
+ question: "Select a variant:",
14
+ label: "variant",
15
+ options: variantsOptions,
16
+ defaultValue: variantsOptions[0].value,
17
+ });
18
+
19
+ await runFrameworkGenerator(ctx, [ctx.project.name, "--template", variant]);
20
+
21
+ logRaw("");
22
+ };
23
+
24
+ const variantsOptions = [
25
+ {
26
+ value: "react-ts",
27
+ label: "TypeScript",
28
+ },
29
+ {
30
+ value: "react-swc-ts",
31
+ label: "TypeScript + SWC",
32
+ },
33
+ {
34
+ value: "react",
35
+ label: "JavaScript",
36
+ },
37
+ {
38
+ value: "react-swc",
39
+ label: "JavaScript + SWC",
40
+ },
41
+ ];
42
+
43
+ const config: TemplateConfig = {
44
+ configVersion: 1,
45
+ id: "react",
46
+ // React's documentation now recommends using create-vite.
47
+ frameworkCli: "create-vite",
48
+ displayName: "React",
49
+ platform: "pages",
50
+ path: "templates/react/pages",
51
+ generate,
52
+ transformPackageJson: async () => ({
53
+ scripts: {
54
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
55
+ preview: `${npm} run build && wrangler pages dev ./dist`,
56
+ },
57
+ }),
58
+ devScript: "dev",
59
+ deployScript: "deploy",
60
+ previewScript: "preview",
61
+ };
62
+ export default config;
@@ -8,7 +8,7 @@ import { readJSON, usesTypescript, writeJSON } from "helpers/files";
8
8
  import { detectPackageManager } from "helpers/packageManagers";
9
9
  import { installPackages } from "helpers/packages";
10
10
  import * as recast from "recast";
11
- import type { TemplateConfig } from "../../src/templates";
11
+ import type { TemplateConfig } from "../../../src/templates";
12
12
  import type { types } from "recast";
13
13
  import type { C3Context } from "types";
14
14
 
@@ -156,7 +156,7 @@ const config: TemplateConfig = {
156
156
  frameworkCli: "create-vite",
157
157
  displayName: "React",
158
158
  platform: "workers",
159
- path: "templates-experimental/react",
159
+ path: "templates/react/workers",
160
160
  copyFiles: {
161
161
  variants: {
162
162
  ts: {
@@ -169,10 +169,11 @@ const config: TemplateConfig = {
169
169
  },
170
170
  generate,
171
171
  configure,
172
- transformPackageJson: async () => ({
172
+ transformPackageJson: async (_, ctx) => ({
173
173
  scripts: {
174
174
  deploy: `${npm} run build && wrangler deploy`,
175
175
  preview: `${npm} run build && vite preview`,
176
+ ...(usesTypescript(ctx) && { "cf-typegen": `wrangler types` }),
176
177
  },
177
178
  }),
178
179
  devScript: "dev",
@@ -1,7 +1,3 @@
1
- interface Env {
2
- ASSETS: Fetcher;
3
- }
4
-
5
1
  export default {
6
2
  fetch(request, env) {
7
3
  const url = new URL(request.url);
@@ -2,7 +2,7 @@
2
2
  "extends": "./tsconfig.node.json",
3
3
  "compilerOptions": {
4
4
  "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
5
- "types": ["@cloudflare/workers-types/2023-07-01", "vite/client"],
5
+ "types": ["@cloudflare/workers-types/2023-07-01", "./worker-configuration.d.ts", "vite/client"],
6
6
  },
7
7
  "include": ["api"],
8
8
  }
@@ -0,0 +1,5 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.jsonc`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ ASSETS: Fetcher;
5
+ }