create-cloudflare 0.0.0-e1b77719 → 0.0.0-e1f2576e

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 (75) hide show
  1. package/dist/cli.js +20147 -18630
  2. package/package.json +5 -3
  3. package/templates/angular/c3.ts +10 -9
  4. package/templates/astro/c3.ts +81 -19
  5. package/templates/astro/snippets/runtimeDeclaration.ts +4 -0
  6. package/templates/astro/templates/wrangler.toml +52 -0
  7. package/templates/common/c3.ts +7 -5
  8. package/templates/common/js/.editorconfig +0 -1
  9. package/templates/common/js/wrangler.toml +68 -22
  10. package/templates/common/ts/.editorconfig +0 -1
  11. package/templates/common/ts/wrangler.toml +68 -22
  12. package/templates/docusaurus/c3.ts +5 -6
  13. package/templates/gatsby/c3.ts +7 -5
  14. package/templates/hello-world/c3.ts +7 -5
  15. package/templates/hello-world/js/.editorconfig +0 -1
  16. package/templates/hello-world/js/package.json +3 -1
  17. package/templates/hello-world/js/test/index.spec.js +20 -0
  18. package/templates/hello-world/js/vitest.config.js +11 -0
  19. package/templates/hello-world/js/wrangler.toml +69 -22
  20. package/templates/hello-world/ts/.editorconfig +0 -1
  21. package/templates/hello-world/ts/package.json +5 -2
  22. package/templates/hello-world/ts/test/index.spec.ts +25 -0
  23. package/templates/hello-world/ts/test/tsconfig.json +11 -0
  24. package/templates/hello-world/ts/tsconfig.json +3 -2
  25. package/templates/hello-world/ts/vitest.config.ts +11 -0
  26. package/templates/hello-world/ts/wrangler.toml +69 -22
  27. package/templates/hello-world-durable-object/c3.ts +7 -5
  28. package/templates/hello-world-durable-object/js/.editorconfig +0 -1
  29. package/templates/hello-world-durable-object/js/wrangler.toml +69 -23
  30. package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
  31. package/templates/hello-world-durable-object/ts/wrangler.toml +68 -21
  32. package/templates/hono/c3.ts +1 -1
  33. package/templates/next/README.md +58 -0
  34. package/templates/next/app/js/app/api/hello/route.js +21 -0
  35. package/templates/next/app/js/app/not-found.js +58 -0
  36. package/templates/next/app/ts/app/api/hello/route.ts +22 -0
  37. package/templates/next/app/ts/app/not-found.tsx +58 -0
  38. package/templates/next/c3.ts +79 -75
  39. package/templates/next/env.d.ts +7 -0
  40. package/templates/next/pages/js/pages/api/hello.js +23 -0
  41. package/templates/next/pages/ts/pages/api/hello.ts +24 -0
  42. package/templates/next/wrangler.toml +53 -0
  43. package/templates/nuxt/c3.ts +94 -19
  44. package/templates/nuxt/templates/env.d.ts +14 -0
  45. package/templates/nuxt/templates/worker-configuration.d.ts +3 -0
  46. package/templates/nuxt/templates/wrangler.toml +52 -0
  47. package/templates/pre-existing/c3.ts +2 -2
  48. package/templates/pre-existing/js/.editorconfig +0 -1
  49. package/templates/queues/c3.ts +7 -5
  50. package/templates/queues/js/.editorconfig +0 -1
  51. package/templates/queues/js/wrangler.toml +85 -2
  52. package/templates/queues/ts/.editorconfig +0 -1
  53. package/templates/queues/ts/wrangler.toml +85 -2
  54. package/templates/qwik/c3.ts +118 -8
  55. package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
  56. package/templates/qwik/templates/worker-configuration.d.ts +3 -0
  57. package/templates/qwik/templates/wrangler.toml +52 -0
  58. package/templates/react/c3.ts +7 -5
  59. package/templates/remix/c3.ts +39 -6
  60. package/templates/remix/templates/worker-configuration.d.ts +3 -0
  61. package/templates/remix/templates/wrangler.toml +52 -0
  62. package/templates/scheduled/c3.ts +7 -5
  63. package/templates/scheduled/js/.editorconfig +0 -1
  64. package/templates/scheduled/js/wrangler.toml +94 -0
  65. package/templates/scheduled/ts/.editorconfig +0 -1
  66. package/templates/scheduled/ts/wrangler.toml +94 -0
  67. package/templates/solid/c3.ts +58 -13
  68. package/templates/svelte/c3.ts +83 -30
  69. package/templates/svelte/js/wrangler.toml +52 -0
  70. package/templates/svelte/ts/wrangler.toml +52 -0
  71. package/templates/vue/c3.ts +7 -6
  72. package/templates/next/templates.ts +0 -281
  73. package/templates/solid/js/vite.config.js +0 -12
  74. package/templates/solid/ts/vite.config.ts +0 -12
  75. package/templates/svelte/templates.ts +0 -13
@@ -0,0 +1,52 @@
1
+ name = "<TBD>"
2
+ compatibility_date = "<TBD>"
3
+
4
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
5
+ # Note: Use secrets to store sensitive data.
6
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
7
+ # [vars]
8
+ # MY_VARIABLE = "production_value"
9
+
10
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
11
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
12
+ # [ai]
13
+ # binding = "AI"
14
+
15
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
16
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
17
+ # [[d1_databases]]
18
+ # binding = "MY_DB"
19
+ # database_name = "my-database"
20
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
21
+
22
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
23
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
24
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
25
+ # [[durable_objects.bindings]]
26
+ # name = "MY_DURABLE_OBJECT"
27
+ # class_name = "MyDurableObject"
28
+ # script_name = 'my-durable-object'
29
+
30
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
31
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
32
+ # [[kv_namespaces]]
33
+ # binding = "MY_KV_NAMESPACE"
34
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
35
+
36
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
37
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
38
+ # [[queues.producers]]
39
+ # binding = "MY_QUEUE"
40
+ # queue = "my-queue"
41
+
42
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
43
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
44
+ # [[r2_buckets]]
45
+ # binding = "MY_BUCKET"
46
+ # bucket_name = "my-bucket"
47
+
48
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
49
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
50
+ # [[services]]
51
+ # binding = "MY_SERVICE"
52
+ # service = "my-service"
@@ -1,7 +1,6 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
- import { runFrameworkGenerator } from "helpers/command";
3
- import { compatDateFlag } from "helpers/files";
4
- import { detectPackageManager } from "helpers/packages";
2
+ import { runFrameworkGenerator } from "frameworks/index";
3
+ import { detectPackageManager } from "helpers/packageManagers";
5
4
  import type { TemplateConfig } from "../../src/templates";
6
5
  import type { C3Context } from "types";
7
6
 
@@ -21,9 +20,12 @@ const config: TemplateConfig = {
21
20
  generate,
22
21
  transformPackageJson: async () => ({
23
22
  scripts: {
24
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --port 3000 -- ${npm} start`,
25
- "pages:deploy": `${npm} run build && wrangler pages deploy ./build`,
23
+ deploy: `${npm} run build && wrangler pages deploy ./build`,
24
+ preview: `${npm} run build && wrangler pages dev ./build`,
26
25
  },
27
26
  }),
27
+ devScript: "dev",
28
+ deployScript: "deploy",
29
+ previewScript: "preview",
28
30
  };
29
31
  export default config;
@@ -1,6 +1,9 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
- import { runFrameworkGenerator } from "helpers/command.js";
3
- import { detectPackageManager } from "helpers/packages";
2
+ import { brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { spinner } from "@cloudflare/cli/interactive";
4
+ import { runFrameworkGenerator } from "frameworks/index";
5
+ import { transformFile } from "helpers/codemod";
6
+ import { detectPackageManager } from "helpers/packageManagers";
4
7
  import type { TemplateConfig } from "../../src/templates";
5
8
  import type { C3Context } from "types";
6
9
 
@@ -10,24 +13,54 @@ const generate = async (ctx: C3Context) => {
10
13
  await runFrameworkGenerator(ctx, [
11
14
  ctx.project.name,
12
15
  "--template",
13
- "https://github.com/remix-run/remix/tree/main/templates/cloudflare-pages",
16
+ "https://github.com/remix-run/remix/tree/main/templates/vite-cloudflare",
14
17
  ]);
15
18
 
16
19
  logRaw(""); // newline
17
20
  };
18
21
 
22
+ const configure = async () => {
23
+ const typeDefsPath = "load-context.ts";
24
+
25
+ const s = spinner();
26
+ s.start(`Updating \`${typeDefsPath}\``);
27
+
28
+ // Remove the empty Env declaration from the template to allow the type from
29
+ // worker-configuration.d.ts to take over
30
+ transformFile(typeDefsPath, {
31
+ visitTSInterfaceDeclaration(n) {
32
+ if (n.node.id.type === "Identifier" && n.node.id.name !== "Env") {
33
+ return this.traverse(n);
34
+ }
35
+
36
+ // Removes the node
37
+ n.replace();
38
+ return false;
39
+ },
40
+ });
41
+
42
+ s.stop(`${brandColor("updated")} \`${dim(typeDefsPath)}\``);
43
+ };
44
+
19
45
  const config: TemplateConfig = {
20
46
  configVersion: 1,
21
47
  id: "remix",
22
- displayName: "Remix",
23
48
  platform: "pages",
49
+ displayName: "Remix",
50
+ copyFiles: {
51
+ path: "./templates",
52
+ },
24
53
  generate,
54
+ configure,
25
55
  transformPackageJson: async () => ({
26
56
  scripts: {
27
- "pages:deploy": `${npm} run build && wrangler pages deploy ./public`,
57
+ deploy: `${npm} run build && wrangler pages deploy ./build/client`,
58
+ preview: `${npm} run build && wrangler pages dev ./build/client`,
59
+ "build-cf-types": `wrangler types`,
28
60
  },
29
61
  }),
30
62
  devScript: "dev",
31
- testFlags: ["--typescript", "--no-install", "--no-git-init"],
63
+ deployScript: "deploy",
64
+ previewScript: "preview",
32
65
  };
33
66
  export default config;
@@ -0,0 +1,3 @@
1
+ // Generated by Wrangler on Fri Feb 16 2024 15:52:18 GMT-0600 (Central Standard Time)
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm build-cf-types`
3
+ interface Env {}
@@ -0,0 +1,52 @@
1
+ name = "<TBD>"
2
+ compatibility_date = "<TBD>"
3
+
4
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
5
+ # Note: Use secrets to store sensitive data.
6
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
7
+ # [vars]
8
+ # MY_VARIABLE = "production_value"
9
+
10
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
11
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
12
+ # [ai]
13
+ # binding = "AI"
14
+
15
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
16
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
17
+ # [[d1_databases]]
18
+ # binding = "MY_DB"
19
+ # database_name = "my-database"
20
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
21
+
22
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
23
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
24
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
25
+ # [[durable_objects.bindings]]
26
+ # name = "MY_DURABLE_OBJECT"
27
+ # class_name = "MyDurableObject"
28
+ # script_name = 'my-durable-object'
29
+
30
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
31
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
32
+ # [[kv_namespaces]]
33
+ # binding = "MY_KV_NAMESPACE"
34
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
35
+
36
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
37
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
38
+ # [[queues.producers]]
39
+ # binding = "MY_QUEUE"
40
+ # queue = "my-queue"
41
+
42
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
43
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
44
+ # [[r2_buckets]]
45
+ # binding = "MY_BUCKET"
46
+ # bucket_name = "my-bucket"
47
+
48
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
49
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
50
+ # [[services]]
51
+ # binding = "MY_SERVICE"
52
+ # service = "my-service"
@@ -4,11 +4,13 @@ export default {
4
4
  displayName: "Scheduled Worker (Cron Trigger)",
5
5
  platform: "workers",
6
6
  copyFiles: {
7
- js: {
8
- path: "./js",
9
- },
10
- ts: {
11
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
12
14
  },
13
15
  },
14
16
  };
@@ -3,7 +3,6 @@ root = true
3
3
 
4
4
  [*]
5
5
  indent_style = tab
6
- tab_width = 2
7
6
  end_of_line = lf
8
7
  charset = utf-8
9
8
  trim_trailing_whitespace = true
@@ -7,3 +7,97 @@ compatibility_date = "<TBD>"
7
7
  # Configuration: https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
8
8
  [triggers]
9
9
  crons = ["* * * * *"] # * * * * * = run every minute
10
+
11
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
12
+ # Note: Use secrets to store sensitive data.
13
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
14
+ # [vars]
15
+ # MY_VARIABLE = "production_value"
16
+
17
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
18
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
19
+ # [ai]
20
+ # binding = "AI"
21
+
22
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
23
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
24
+ # [[analytics_engine_datasets]]
25
+ # binding = "MY_DATASET"
26
+
27
+ # Bind a headless browser instance running on Cloudflare's global network.
28
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
29
+ # [browser]
30
+ # binding = "MY_BROWSER"
31
+
32
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
33
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
34
+ # [[d1_databases]]
35
+ # binding = "MY_DB"
36
+ # database_name = "my-database"
37
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
38
+
39
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
40
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
41
+ # [[dispatch_namespaces]]
42
+ # binding = "MY_DISPATCHER"
43
+ # namespace = "my-namespace"
44
+
45
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
46
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
47
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
48
+ # [[durable_objects.bindings]]
49
+ # name = "MY_DURABLE_OBJECT"
50
+ # class_name = "MyDurableObject"
51
+
52
+ # Durable Object migrations.
53
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
54
+ # [[migrations]]
55
+ # tag = "v1"
56
+ # new_classes = ["MyDurableObject"]
57
+
58
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
59
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
60
+ # [[hyperdrive]]
61
+ # binding = "MY_HYPERDRIVE"
62
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
63
+
64
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
65
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
66
+ # [[kv_namespaces]]
67
+ # binding = "MY_KV_NAMESPACE"
68
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
69
+
70
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
71
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
72
+ # [[mtls_certificates]]
73
+ # binding = "MY_CERTIFICATE"
74
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
75
+
76
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
77
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
78
+ # [[queues.producers]]
79
+ # binding = "MY_QUEUE"
80
+ # queue = "my-queue"
81
+
82
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
83
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
84
+ # [[queues.consumers]]
85
+ # queue = "my-queue"
86
+
87
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
88
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
89
+ # [[r2_buckets]]
90
+ # binding = "MY_BUCKET"
91
+ # bucket_name = "my-bucket"
92
+
93
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
94
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
95
+ # [[services]]
96
+ # binding = "MY_SERVICE"
97
+ # service = "my-service"
98
+
99
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
100
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
101
+ # [[vectorize]]
102
+ # binding = "MY_INDEX"
103
+ # index_name = "my-index"
@@ -3,7 +3,6 @@ root = true
3
3
 
4
4
  [*]
5
5
  indent_style = tab
6
- tab_width = 2
7
6
  end_of_line = lf
8
7
  charset = utf-8
9
8
  trim_trailing_whitespace = true
@@ -7,3 +7,97 @@ compatibility_date = "<TBD>"
7
7
  # Configuration: https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
8
8
  [triggers]
9
9
  crons = ["* * * * *"] # * * * * * = run every minute
10
+
11
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
12
+ # Note: Use secrets to store sensitive data.
13
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
14
+ # [vars]
15
+ # MY_VARIABLE = "production_value"
16
+
17
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
18
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
19
+ # [ai]
20
+ # binding = "AI"
21
+
22
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
23
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
24
+ # [[analytics_engine_datasets]]
25
+ # binding = "MY_DATASET"
26
+
27
+ # Bind a headless browser instance running on Cloudflare's global network.
28
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
29
+ # [browser]
30
+ # binding = "MY_BROWSER"
31
+
32
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
33
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
34
+ # [[d1_databases]]
35
+ # binding = "MY_DB"
36
+ # database_name = "my-database"
37
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
38
+
39
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
40
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
41
+ # [[dispatch_namespaces]]
42
+ # binding = "MY_DISPATCHER"
43
+ # namespace = "my-namespace"
44
+
45
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
46
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
47
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
48
+ # [[durable_objects.bindings]]
49
+ # name = "MY_DURABLE_OBJECT"
50
+ # class_name = "MyDurableObject"
51
+
52
+ # Durable Object migrations.
53
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
54
+ # [[migrations]]
55
+ # tag = "v1"
56
+ # new_classes = ["MyDurableObject"]
57
+
58
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
59
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
60
+ # [[hyperdrive]]
61
+ # binding = "MY_HYPERDRIVE"
62
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
63
+
64
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
65
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
66
+ # [[kv_namespaces]]
67
+ # binding = "MY_KV_NAMESPACE"
68
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
69
+
70
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
71
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
72
+ # [[mtls_certificates]]
73
+ # binding = "MY_CERTIFICATE"
74
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
75
+
76
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
77
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
78
+ # [[queues.producers]]
79
+ # binding = "MY_QUEUE"
80
+ # queue = "my-queue"
81
+
82
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
83
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
84
+ # [[queues.consumers]]
85
+ # queue = "my-queue"
86
+
87
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
88
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
89
+ # [[r2_buckets]]
90
+ # binding = "MY_BUCKET"
91
+ # bucket_name = "my-bucket"
92
+
93
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
94
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
95
+ # [[services]]
96
+ # binding = "MY_SERVICE"
97
+ # service = "my-service"
98
+
99
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
100
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
101
+ # [[vectorize]]
102
+ # binding = "MY_INDEX"
103
+ # index_name = "my-index"
@@ -1,7 +1,11 @@
1
- import { logRaw } from "@cloudflare/cli";
2
- import { runFrameworkGenerator } from "helpers/command";
3
- import { compatDateFlag } from "helpers/files";
4
- import { detectPackageManager } from "helpers/packages";
1
+ import { logRaw, updateStatus } from "@cloudflare/cli";
2
+ import { blue } from "@cloudflare/cli/colors";
3
+ import { runFrameworkGenerator } from "frameworks/index";
4
+ import { transformFile } from "helpers/codemod";
5
+ import { compatDateFlag } from "helpers/compatDate";
6
+ import { usesTypescript } from "helpers/files";
7
+ import { detectPackageManager } from "helpers/packageManagers";
8
+ import * as recast from "recast";
5
9
  import type { TemplateConfig } from "../../src/templates";
6
10
  import type { C3Context } from "types";
7
11
 
@@ -9,29 +13,70 @@ const { npm } = detectPackageManager();
9
13
 
10
14
  const generate = async (ctx: C3Context) => {
11
15
  // Run the create-solid command
12
- await runFrameworkGenerator(ctx, [ctx.project.name]);
16
+ // -s flag forces solid-start
17
+ await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
13
18
 
14
19
  logRaw("");
15
20
  };
16
21
 
22
+ const configure = async (ctx: C3Context) => {
23
+ usesTypescript(ctx);
24
+ const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
25
+
26
+ updateStatus(`Updating configuration in ${blue(filePath)}`);
27
+
28
+ transformFile(filePath, {
29
+ visitCallExpression: function (n) {
30
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
31
+ if (callee.name !== "defineConfig") {
32
+ return this.traverse(n);
33
+ }
34
+
35
+ const b = recast.types.builders;
36
+ n.node.arguments = [
37
+ b.objectExpression([
38
+ b.objectProperty(
39
+ b.identifier("server"),
40
+ b.objectExpression([
41
+ b.objectProperty(
42
+ b.identifier("preset"),
43
+ b.stringLiteral("cloudflare-pages")
44
+ ),
45
+ b.objectProperty(
46
+ b.identifier("rollupConfig"),
47
+ b.objectExpression([
48
+ b.objectProperty(
49
+ b.identifier("external"),
50
+ b.arrayExpression([b.stringLiteral("node:async_hooks")])
51
+ ),
52
+ ])
53
+ ),
54
+ ])
55
+ ),
56
+ ]),
57
+ ];
58
+
59
+ return false;
60
+ },
61
+ });
62
+ };
63
+
17
64
  const config: TemplateConfig = {
18
65
  configVersion: 1,
19
66
  id: "solid",
20
67
  displayName: "Solid",
21
68
  platform: "pages",
22
- copyFiles: {
23
- js: { path: "./js" },
24
- ts: { path: "./ts" },
25
- },
26
69
  generate,
70
+ configure,
27
71
  transformPackageJson: async () => ({
28
72
  scripts: {
29
- "pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
30
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
73
+ preview: `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
74
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
31
75
  },
32
76
  }),
33
- devScript: "dev",
34
- previewScript: "pages:preview",
35
77
  compatibilityFlags: ["nodejs_compat"],
78
+ devScript: "dev",
79
+ deployScript: "deploy",
80
+ previewScript: "preview",
36
81
  };
37
82
  export default config;