create-cloudflare 0.0.0-bd935cfd → 0.0.0-bdc121de

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 (52) hide show
  1. package/dist/cli.js +25855 -25859
  2. package/package.json +2 -2
  3. package/templates/angular/c3.ts +5 -3
  4. package/templates/astro/c3.ts +3 -2
  5. package/templates/astro/templates/wrangler.toml +30 -28
  6. package/templates/common/js/wrangler.toml +68 -22
  7. package/templates/common/ts/wrangler.toml +68 -22
  8. package/templates/docusaurus/c3.ts +2 -2
  9. package/templates/gatsby/c3.ts +2 -2
  10. package/templates/hello-world/js/package.json +3 -1
  11. package/templates/hello-world/js/test/index.spec.js +20 -0
  12. package/templates/hello-world/js/vitest.config.js +11 -0
  13. package/templates/hello-world/js/wrangler.toml +69 -22
  14. package/templates/hello-world/ts/package.json +5 -2
  15. package/templates/hello-world/ts/test/index.spec.ts +25 -0
  16. package/templates/hello-world/ts/test/tsconfig.json +11 -0
  17. package/templates/hello-world/ts/tsconfig.json +3 -2
  18. package/templates/hello-world/ts/vitest.config.ts +11 -0
  19. package/templates/hello-world/ts/wrangler.toml +69 -22
  20. package/templates/hello-world-durable-object/js/wrangler.toml +69 -23
  21. package/templates/hello-world-durable-object/ts/wrangler.toml +68 -21
  22. package/templates/hono/c3.ts +1 -1
  23. package/templates/next/README.md +11 -1
  24. package/templates/next/app/js/app/api/hello/route.js +1 -1
  25. package/templates/next/app/ts/app/api/hello/route.ts +1 -1
  26. package/templates/next/c3.ts +26 -6
  27. package/templates/next/env.d.ts +3 -5
  28. package/templates/next/pages/js/pages/api/hello.js +1 -1
  29. package/templates/next/pages/ts/pages/api/hello.ts +1 -1
  30. package/templates/next/wrangler.toml +29 -32
  31. package/templates/nuxt/c3.ts +4 -3
  32. package/templates/nuxt/templates/worker-configuration.d.ts +3 -2
  33. package/templates/nuxt/templates/wrangler.toml +30 -28
  34. package/templates/pre-existing/c3.ts +2 -2
  35. package/templates/queues/js/wrangler.toml +85 -2
  36. package/templates/queues/ts/wrangler.toml +85 -2
  37. package/templates/qwik/c3.ts +3 -3
  38. package/templates/qwik/templates/worker-configuration.d.ts +3 -2
  39. package/templates/qwik/templates/wrangler.toml +30 -28
  40. package/templates/react/c3.ts +2 -2
  41. package/templates/remix/c3.ts +3 -3
  42. package/templates/remix/templates/worker-configuration.d.ts +3 -2
  43. package/templates/remix/templates/wrangler.toml +30 -28
  44. package/templates/scheduled/js/wrangler.toml +94 -0
  45. package/templates/scheduled/ts/wrangler.toml +94 -0
  46. package/templates/solid/c3.ts +4 -3
  47. package/templates/svelte/c3.ts +3 -2
  48. package/templates/svelte/js/wrangler.toml +30 -28
  49. package/templates/svelte/ts/wrangler.toml +30 -28
  50. package/templates/vue/c3.ts +2 -2
  51. package/templates/svelte/js/src/hooks.server.js +0 -25
  52. package/templates/svelte/ts/src/hooks.server.ts +0 -24
@@ -1,51 +1,98 @@
1
1
  name = "<TBD>"
2
2
  main = "src/index.ts"
3
3
  compatibility_date = "<TBD>"
4
+ compatibility_flags = ["nodejs_compat"]
4
5
 
5
6
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
6
7
  # Note: Use secrets to store sensitive data.
7
- # Docs: https://developers.cloudflare.com/workers/platform/environment-variables
8
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
8
9
  # [vars]
9
10
  # MY_VARIABLE = "production_value"
10
11
 
12
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
13
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
14
+ # [ai]
15
+ # binding = "AI"
16
+
17
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
18
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
19
+ # [[analytics_engine_datasets]]
20
+ # binding = "MY_DATASET"
21
+
22
+ # Bind a headless browser instance running on Cloudflare's global network.
23
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
24
+ # [browser]
25
+ # binding = "MY_BROWSER"
26
+
27
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
28
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
29
+ # [[d1_databases]]
30
+ # binding = "MY_DB"
31
+ # database_name = "my-database"
32
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
33
+
34
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
35
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
36
+ # [[dispatch_namespaces]]
37
+ # binding = "MY_DISPATCHER"
38
+ # namespace = "my-namespace"
39
+
40
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
41
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
42
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
43
+ # [[durable_objects.bindings]]
44
+ # name = "MY_DURABLE_OBJECT"
45
+ # class_name = "MyDurableObject"
46
+
47
+ # Durable Object migrations.
48
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
49
+ # [[migrations]]
50
+ # tag = "v1"
51
+ # new_classes = ["MyDurableObject"]
52
+
53
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
54
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
55
+ # [[hyperdrive]]
56
+ # binding = "MY_HYPERDRIVE"
57
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
58
+
11
59
  # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
12
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
60
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
13
61
  # [[kv_namespaces]]
14
62
  # binding = "MY_KV_NAMESPACE"
15
63
  # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
16
64
 
17
- # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
18
- # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
19
- # [[r2_buckets]]
20
- # binding = "MY_BUCKET"
21
- # bucket_name = "my-bucket"
65
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
66
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
67
+ # [[mtls_certificates]]
68
+ # binding = "MY_CERTIFICATE"
69
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22
70
 
23
71
  # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
24
- # Docs: https://developers.cloudflare.com/queues/get-started
72
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
25
73
  # [[queues.producers]]
26
74
  # binding = "MY_QUEUE"
27
75
  # queue = "my-queue"
28
76
 
29
77
  # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
30
- # Docs: https://developers.cloudflare.com/queues/get-started
78
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
31
79
  # [[queues.consumers]]
32
80
  # queue = "my-queue"
33
81
 
82
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
83
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
84
+ # [[r2_buckets]]
85
+ # binding = "MY_BUCKET"
86
+ # bucket_name = "my-bucket"
87
+
34
88
  # Bind another Worker service. Use this binding to call another Worker without network overhead.
35
- # Docs: https://developers.cloudflare.com/workers/platform/services
89
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
36
90
  # [[services]]
37
91
  # binding = "MY_SERVICE"
38
92
  # service = "my-service"
39
93
 
40
- # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
41
- # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
42
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
43
- # [[durable_objects.bindings]]
44
- # name = "MY_DURABLE_OBJECT"
45
- # class_name = "MyDurableObject"
46
-
47
- # Durable Object migrations.
48
- # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
49
- # [[migrations]]
50
- # tag = "v1"
51
- # new_classes = ["MyDurableObject"]
94
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
95
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
96
+ # [[vectorize]]
97
+ # binding = "MY_INDEX"
98
+ # index_name = "my-index"
@@ -1,51 +1,97 @@
1
1
  name = "<TBD>"
2
- main = "src/index.js"
2
+ main = "src/index.ts"
3
3
  compatibility_date = "<TBD>"
4
4
 
5
5
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
6
6
  # Note: Use secrets to store sensitive data.
7
- # Docs: https://developers.cloudflare.com/workers/platform/environment-variables
7
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
8
8
  # [vars]
9
9
  # MY_VARIABLE = "production_value"
10
10
 
11
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
12
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
13
+ # [ai]
14
+ # binding = "AI"
15
+
16
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
17
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
18
+ # [[analytics_engine_datasets]]
19
+ # binding = "MY_DATASET"
20
+
21
+ # Bind a headless browser instance running on Cloudflare's global network.
22
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
23
+ # [browser]
24
+ # binding = "MY_BROWSER"
25
+
26
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
27
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
28
+ # [[d1_databases]]
29
+ # binding = "MY_DB"
30
+ # database_name = "my-database"
31
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
32
+
33
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
34
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
35
+ # [[dispatch_namespaces]]
36
+ # binding = "MY_DISPATCHER"
37
+ # namespace = "my-namespace"
38
+
39
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
40
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
41
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
42
+ [[durable_objects.bindings]]
43
+ name = "MY_DURABLE_OBJECT"
44
+ class_name = "MyDurableObject"
45
+
46
+ # Durable Object migrations.
47
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
48
+ [[migrations]]
49
+ tag = "v1"
50
+ new_classes = ["MyDurableObject"]
51
+
52
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
53
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
54
+ # [[hyperdrive]]
55
+ # binding = "MY_HYPERDRIVE"
56
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
57
+
11
58
  # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
12
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
59
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
13
60
  # [[kv_namespaces]]
14
61
  # binding = "MY_KV_NAMESPACE"
15
62
  # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
16
63
 
17
- # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
18
- # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
19
- # [[r2_buckets]]
20
- # binding = "MY_BUCKET"
21
- # bucket_name = "my-bucket"
64
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
65
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
66
+ # [[mtls_certificates]]
67
+ # binding = "MY_CERTIFICATE"
68
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22
69
 
23
70
  # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
24
- # Docs: https://developers.cloudflare.com/queues/get-started
71
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
25
72
  # [[queues.producers]]
26
73
  # binding = "MY_QUEUE"
27
74
  # queue = "my-queue"
28
75
 
29
76
  # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
30
- # Docs: https://developers.cloudflare.com/queues/get-started
77
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
31
78
  # [[queues.consumers]]
32
79
  # queue = "my-queue"
33
80
 
81
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
82
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
83
+ # [[r2_buckets]]
84
+ # binding = "MY_BUCKET"
85
+ # bucket_name = "my-bucket"
86
+
34
87
  # Bind another Worker service. Use this binding to call another Worker without network overhead.
35
- # Docs: https://developers.cloudflare.com/workers/platform/services
88
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
36
89
  # [[services]]
37
90
  # binding = "MY_SERVICE"
38
91
  # service = "my-service"
39
92
 
40
- # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
41
- # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
42
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
43
- [[durable_objects.bindings]]
44
- name = "MY_DURABLE_OBJECT"
45
- class_name = "MyDurableObject"
46
-
47
- # Durable Object migrations.
48
- # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
49
- [[migrations]]
50
- tag = "v1"
51
- new_classes = ["MyDurableObject"]
93
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
94
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
95
+ # [[vectorize]]
96
+ # binding = "MY_INDEX"
97
+ # index_name = "my-index"
@@ -4,48 +4,95 @@ compatibility_date = "<TBD>"
4
4
 
5
5
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
6
6
  # Note: Use secrets to store sensitive data.
7
- # Docs: https://developers.cloudflare.com/workers/platform/environment-variables
7
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
8
8
  # [vars]
9
9
  # MY_VARIABLE = "production_value"
10
10
 
11
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
12
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
13
+ # [ai]
14
+ # binding = "AI"
15
+
16
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
17
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
18
+ # [[analytics_engine_datasets]]
19
+ # binding = "MY_DATASET"
20
+
21
+ # Bind a headless browser instance running on Cloudflare's global network.
22
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
23
+ # [browser]
24
+ # binding = "MY_BROWSER"
25
+
26
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
27
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
28
+ # [[d1_databases]]
29
+ # binding = "MY_DB"
30
+ # database_name = "my-database"
31
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
32
+
33
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
34
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
35
+ # [[dispatch_namespaces]]
36
+ # binding = "MY_DISPATCHER"
37
+ # namespace = "my-namespace"
38
+
39
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
40
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
41
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
42
+ [[durable_objects.bindings]]
43
+ name = "MY_DURABLE_OBJECT"
44
+ class_name = "MyDurableObject"
45
+
46
+ # Durable Object migrations.
47
+ # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
48
+ [[migrations]]
49
+ tag = "v1"
50
+ new_classes = ["MyDurableObject"]
51
+
52
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
53
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
54
+ # [[hyperdrive]]
55
+ # binding = "MY_HYPERDRIVE"
56
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
57
+
11
58
  # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
12
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
59
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
13
60
  # [[kv_namespaces]]
14
61
  # binding = "MY_KV_NAMESPACE"
15
62
  # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
16
63
 
17
- # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
18
- # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
19
- # [[r2_buckets]]
20
- # binding = "MY_BUCKET"
21
- # bucket_name = "my-bucket"
64
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
65
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
66
+ # [[mtls_certificates]]
67
+ # binding = "MY_CERTIFICATE"
68
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22
69
 
23
70
  # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
24
- # Docs: https://developers.cloudflare.com/queues/get-started
71
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
25
72
  # [[queues.producers]]
26
73
  # binding = "MY_QUEUE"
27
74
  # queue = "my-queue"
28
75
 
29
76
  # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
30
- # Docs: https://developers.cloudflare.com/queues/get-started
77
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
31
78
  # [[queues.consumers]]
32
79
  # queue = "my-queue"
33
80
 
81
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
82
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
83
+ # [[r2_buckets]]
84
+ # binding = "MY_BUCKET"
85
+ # bucket_name = "my-bucket"
86
+
34
87
  # Bind another Worker service. Use this binding to call another Worker without network overhead.
35
- # Docs: https://developers.cloudflare.com/workers/platform/services
88
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
36
89
  # [[services]]
37
90
  # binding = "MY_SERVICE"
38
91
  # service = "my-service"
39
92
 
40
- # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
41
- # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
42
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
43
- [[durable_objects.bindings]]
44
- name = "MY_DURABLE_OBJECT"
45
- class_name = "MyDurableObject"
93
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
94
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
95
+ # [[vectorize]]
96
+ # binding = "MY_INDEX"
97
+ # index_name = "my-index"
46
98
 
47
- # Durable Object migrations.
48
- # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
49
- [[migrations]]
50
- tag = "v1"
51
- new_classes = ["MyDurableObject"]
@@ -1,5 +1,5 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
- import { runFrameworkGenerator } from "helpers/command";
2
+ import { runFrameworkGenerator } from "frameworks/index";
3
3
  import type { TemplateConfig } from "../../src/templates";
4
4
  import type { C3Context } from "types";
5
5
 
@@ -52,7 +52,17 @@ In order to enable the example:
52
52
  ```
53
53
  # KV Example:
54
54
  ```
55
+ - If you're using TypeScript run the `build-cf-types` script to update the `env.d.ts` file:
56
+ ```bash
57
+ npm run build-cf-types
58
+ # or
59
+ yarn build-cf-types
60
+ # or
61
+ pnpm build-cf-types
62
+ # or
63
+ bun build-cf-types
64
+ ```
55
65
 
56
66
  After doing this you can run the `dev` or `preview` script and visit the `/api/hello` route to see the example in action.
57
67
 
58
- Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
68
+ Finally, if you also want to see the example work in the deployed application make sure to add a `MY_KV_NAMESPACE` binding to your Pages application in its [dashboard kv bindings settings section](https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/settings/functions#kv_namespace_bindings_section). After having configured it make sure to re-deploy your application.
@@ -12,7 +12,7 @@ export async function GET(request) {
12
12
  // )
13
13
  //
14
14
  // KV Example:
15
- // const myKv = getRequestContext().env.MY_KV
15
+ // const myKv = getRequestContext().env.MY_KV_NAMESPACE
16
16
  // await myKv.put('suffix', ' from a KV store!')
17
17
  // const suffix = await myKv.get('suffix')
18
18
  // responseText += suffix
@@ -13,7 +13,7 @@ export async function GET(request: NextRequest) {
13
13
  // )
14
14
  //
15
15
  // KV Example:
16
- // const myKv = getRequestContext().env.MY_KV
16
+ // const myKv = getRequestContext().env.MY_KV_NAMESPACE
17
17
  // await myKv.put('suffix', ' from a KV store!')
18
18
  // const suffix = await myKv.get('suffix')
19
19
  // responseText += suffix
@@ -3,7 +3,7 @@ import { crash, updateStatus, warn } from "@cloudflare/cli";
3
3
  import { processArgument } from "@cloudflare/cli/args";
4
4
  import { brandColor, dim } from "@cloudflare/cli/colors";
5
5
  import { spinner } from "@cloudflare/cli/interactive";
6
- import { installPackages, runFrameworkGenerator } from "helpers/command";
6
+ import { runFrameworkGenerator } from "frameworks/index";
7
7
  import {
8
8
  copyFile,
9
9
  probePaths,
@@ -14,7 +14,8 @@ import {
14
14
  writeFile,
15
15
  writeJSON,
16
16
  } from "helpers/files";
17
- import { detectPackageManager } from "helpers/packages";
17
+ import { detectPackageManager } from "helpers/packageManagers";
18
+ import { installPackages } from "helpers/packages";
18
19
  import { getTemplatePath } from "../../src/templates";
19
20
  import type { TemplateConfig } from "../../src/templates";
20
21
  import type { C3Args, C3Context } from "types";
@@ -26,10 +27,26 @@ const generate = async (ctx: C3Context) => {
26
27
 
27
28
  await runFrameworkGenerator(ctx, [projectName]);
28
29
 
29
- copyFile(
30
- join(getTemplatePath(ctx), "wrangler.toml"),
31
- join(ctx.project.path, "wrangler.toml")
30
+ const wranglerToml = readFile(join(getTemplatePath(ctx), "wrangler.toml"));
31
+
32
+ // Note: here we add `# KV Example:` to the toml file for the KV example, we don't actually
33
+ // include the comment in the template wrangler.toml file just so to keep it identical
34
+ // and consistent with that of all the other frameworks
35
+ // (instead of making it a special case which needs extra care)
36
+ const newTomlContent = wranglerToml.replace(
37
+ /#\s+\[\[kv_namespaces\]\]\n#\s+binding\s+=\s+"MY_KV_NAMESPACE"\n#\s+id\s+=\s+"[a-zA-Z0-9]+?"/,
38
+ ($1) => `# KV Example:\n${$1}`
32
39
  );
40
+
41
+ if (!/# KV Example/.test(newTomlContent)) {
42
+ // This should never happen to users, it is a check mostly so that
43
+ // if the toml file is changed in a way that breaks the "KV Example" addition
44
+ // the C3 Next.js e2e runs will fail with this
45
+ crash("Failed to properly generate the wrangler.toml file");
46
+ }
47
+
48
+ writeFile(join(ctx.project.path, "wrangler.toml"), newTomlContent);
49
+
33
50
  updateStatus("Created wrangler.toml file");
34
51
  };
35
52
 
@@ -191,7 +208,7 @@ export default {
191
208
  },
192
209
  },
193
210
  },
194
- transformPackageJson: async () => {
211
+ transformPackageJson: async (_, ctx) => {
195
212
  const isNpm = npm === "npm";
196
213
  const isBun = npm === "bun";
197
214
  const isNpmOrBun = isNpm || isBun;
@@ -206,6 +223,9 @@ export default {
206
223
  "pages:build": `${pmCommand} ${nextOnPagesCommand}`,
207
224
  preview: `${pagesBuildRunCommand} && wrangler pages dev .vercel/output/static`,
208
225
  deploy: `${pagesBuildRunCommand} && wrangler pages deploy .vercel/output/static`,
226
+ ...(usesTypescript(ctx) && {
227
+ "build-cf-types": `wrangler types --env-interface CloudflareEnv env.d.ts`,
228
+ }),
209
229
  },
210
230
  };
211
231
  },
@@ -1,7 +1,5 @@
1
+ // Generated by Wrangler
2
+ // by running `wrangler types --env-interface CloudflareEnv env.d.ts`
3
+
1
4
  interface CloudflareEnv {
2
- // Add here the Cloudflare Bindings you want to have available in your application
3
- // (for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
4
- //
5
- // KV Example:
6
- // MY_KV: KVNamespace
7
5
  }
@@ -14,7 +14,7 @@ export default async function handler(req) {
14
14
  // )
15
15
  //
16
16
  // KV Example:
17
- // const myKv = getRequestContext().env.MY_KV
17
+ // const myKv = getRequestContext().env.MY_KV_NAMESPACE
18
18
  // await myKv.put('suffix', ' from a KV store!')
19
19
  // const suffix = await myKv.get('suffix')
20
20
  // responseText += suffix
@@ -15,7 +15,7 @@ export default async function handler(req: NextRequest) {
15
15
  // )
16
16
  //
17
17
  // KV Example:
18
- // const myKv = getRequestContext().env.MY_KV;
18
+ // const myKv = getRequestContext().env.MY_KV_NAMESPACE
19
19
  // await myKv.put('suffix', ' from a KV store!')
20
20
  // const suffix = await myKv.get('suffix')
21
21
  // responseText += suffix
@@ -1,57 +1,54 @@
1
1
  name = "<TBD>"
2
2
  compatibility_date = "<TBD>"
3
-
4
3
  compatibility_flags = ["nodejs_compat"]
5
4
 
6
5
  # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
6
  # Note: Use secrets to store sensitive data.
8
- # Docs: https://developers.cloudflare.com/workers/platform/environment-variables
7
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
9
8
  # [vars]
10
9
  # MY_VARIABLE = "production_value"
11
10
 
11
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
12
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
13
+ # [ai]
14
+ # binding = "AI"
15
+
16
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
17
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
18
+ # [[d1_databases]]
19
+ # binding = "MY_DB"
20
+ # database_name = "my-database"
21
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22
+
23
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
24
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
25
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
26
+ # [[durable_objects.bindings]]
27
+ # name = "MY_DURABLE_OBJECT"
28
+ # class_name = "MyDurableObject"
29
+ # script_name = 'my-durable-object'
30
+
12
31
  # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
13
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
32
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
14
33
  # [[kv_namespaces]]
15
34
  # binding = "MY_KV_NAMESPACE"
16
35
  # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
17
36
 
18
- # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
19
- # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
20
- # [[r2_buckets]]
21
- # binding = "MY_BUCKET"
22
- # bucket_name = "my-bucket"
23
-
24
37
  # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
25
- # Docs: https://developers.cloudflare.com/queues/get-started
38
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
26
39
  # [[queues.producers]]
27
40
  # binding = "MY_QUEUE"
28
41
  # queue = "my-queue"
29
42
 
30
- # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
31
- # Docs: https://developers.cloudflare.com/queues/get-started
32
- # [[queues.consumers]]
33
- # queue = "my-queue"
43
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
44
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
45
+ # [[r2_buckets]]
46
+ # binding = "MY_BUCKET"
47
+ # bucket_name = "my-bucket"
34
48
 
35
49
  # Bind another Worker service. Use this binding to call another Worker without network overhead.
36
- # Docs: https://developers.cloudflare.com/workers/platform/services
50
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
37
51
  # [[services]]
38
52
  # binding = "MY_SERVICE"
39
53
  # service = "my-service"
40
54
 
41
- # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
42
- # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
43
- # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
44
- # [[durable_objects.bindings]]
45
- # name = "MY_DURABLE_OBJECT"
46
- # class_name = "MyDurableObject"
47
-
48
- # Durable Object migrations.
49
- # Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
50
- # [[migrations]]
51
- # tag = "v1"
52
- # new_classes = ["MyDurableObject"]
53
-
54
- # KV Example:
55
- # [[kv_namespaces]]
56
- # binding = "MY_KV"
57
- # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
@@ -1,12 +1,13 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
2
  import { brandColor, dim } from "@cloudflare/cli/colors";
3
3
  import { spinner } from "@cloudflare/cli/interactive";
4
+ import { runFrameworkGenerator } from "frameworks/index";
4
5
  import { transformFile } from "helpers/codemod";
5
- import { installPackages, runFrameworkGenerator } from "helpers/command";
6
+ import { getLatestTypesEntrypoint } from "helpers/compatDate";
6
7
  import { readFile, writeFile } from "helpers/files";
7
- import { detectPackageManager } from "helpers/packages";
8
+ import { detectPackageManager } from "helpers/packageManagers";
9
+ import { installPackages } from "helpers/packages";
8
10
  import * as recast from "recast";
9
- import { getLatestTypesEntrypoint } from "../../src/workers";
10
11
  import type { TemplateConfig } from "../../src/templates";
11
12
  import type { C3Context } from "types";
12
13
 
@@ -1,3 +1,4 @@
1
- // Generated by Wrangler on Fri Feb 16 2024 15:52:18 GMT-0600 (Central Standard Time)
1
+ // Generated by Wrangler
2
2
  // After adding bindings to `wrangler.toml`, regenerate this interface via `npm build-cf-types`
3
- interface Env {}
3
+ interface Env {
4
+ }