create-cloudflare 0.0.0-8166eefc → 0.0.0-81d96158

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 (118) hide show
  1. package/dist/cli.js +31770 -29740
  2. package/package.json +9 -7
  3. package/templates/analog/c3.ts +134 -0
  4. package/templates/analog/snippets/devBindingsModule.ts +7 -0
  5. package/templates/analog/templates/env.d.ts +13 -0
  6. package/templates/analog/templates/src/dev-bindings.ts +18 -0
  7. package/templates/analog/templates/worker-configuration.d.ts +4 -0
  8. package/templates/analog/templates/wrangler.toml +78 -0
  9. package/templates/angular/c3.ts +12 -12
  10. package/templates/astro/c3.ts +80 -18
  11. package/templates/astro/snippets/runtimeDeclaration.ts +5 -0
  12. package/templates/astro/templates/wrangler.toml +78 -0
  13. package/templates/common/c3.ts +7 -6
  14. package/templates/common/js/.editorconfig +0 -1
  15. package/templates/common/js/wrangler.toml +71 -22
  16. package/templates/common/ts/.editorconfig +0 -1
  17. package/templates/common/ts/package.json +2 -1
  18. package/templates/common/ts/src/index.ts +3 -0
  19. package/templates/common/ts/worker-configuration.d.ts +2 -14
  20. package/templates/common/ts/wrangler.toml +71 -22
  21. package/templates/docusaurus/c3.ts +5 -6
  22. package/templates/gatsby/c3.ts +7 -5
  23. package/templates/hello-world/c3.ts +7 -6
  24. package/templates/hello-world/js/.editorconfig +0 -1
  25. package/templates/hello-world/js/package.json +5 -2
  26. package/templates/hello-world/js/test/index.spec.js +20 -0
  27. package/templates/hello-world/js/vitest.config.js +11 -0
  28. package/templates/hello-world/js/wrangler.toml +72 -22
  29. package/templates/hello-world/ts/.editorconfig +0 -1
  30. package/templates/hello-world/ts/package.json +6 -2
  31. package/templates/hello-world/ts/src/index.ts +3 -17
  32. package/templates/hello-world/ts/test/index.spec.ts +25 -0
  33. package/templates/hello-world/ts/test/tsconfig.json +11 -0
  34. package/templates/hello-world/ts/tsconfig.json +3 -2
  35. package/templates/hello-world/ts/vitest.config.ts +11 -0
  36. package/templates/hello-world/ts/worker-configuration.d.ts +4 -0
  37. package/templates/hello-world/ts/wrangler.toml +72 -22
  38. package/templates/hello-world-durable-object/c3.ts +7 -6
  39. package/templates/hello-world-durable-object/js/.editorconfig +0 -1
  40. package/templates/hello-world-durable-object/js/src/index.js +18 -14
  41. package/templates/hello-world-durable-object/js/wrangler.toml +72 -23
  42. package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
  43. package/templates/hello-world-durable-object/ts/package.json +2 -2
  44. package/templates/hello-world-durable-object/ts/src/index.ts +24 -16
  45. package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +6 -0
  46. package/templates/hello-world-durable-object/ts/wrangler.toml +71 -22
  47. package/templates/hello-world-python/c3.ts +9 -0
  48. package/templates/hello-world-python/py/__dot__gitignore +68 -0
  49. package/templates/{chatgptPlugin/ts → hello-world-python/py}/package.json +2 -5
  50. package/templates/hello-world-python/py/src/entry.py +4 -0
  51. package/templates/hello-world-python/py/wrangler.toml +101 -0
  52. package/templates/hono/c3.ts +56 -3
  53. package/templates/hono/snippets/appDeclaration.ts +1 -0
  54. package/templates/hono/snippets/bindingsType.ts +1 -0
  55. package/templates/hono/templates/worker-configuration.d.ts +4 -0
  56. package/templates/hono/templates/wrangler.toml +100 -0
  57. package/templates/next/README.md +68 -0
  58. package/templates/next/app/js/app/api/hello/route.js +21 -0
  59. package/templates/next/app/js/app/not-found.js +58 -0
  60. package/templates/next/app/ts/app/api/hello/route.ts +22 -0
  61. package/templates/next/app/ts/app/not-found.tsx +58 -0
  62. package/templates/next/c3.ts +99 -74
  63. package/templates/next/env.d.ts +5 -0
  64. package/templates/next/pages/js/pages/api/hello.js +23 -0
  65. package/templates/next/pages/ts/pages/api/hello.ts +24 -0
  66. package/templates/next/wrangler.toml +79 -0
  67. package/templates/nuxt/c3.ts +93 -18
  68. package/templates/nuxt/templates/env.d.ts +14 -0
  69. package/templates/nuxt/templates/worker-configuration.d.ts +4 -0
  70. package/templates/nuxt/templates/wrangler.toml +78 -0
  71. package/templates/openapi/c3.ts +0 -1
  72. package/templates/openapi/ts/package.json +2 -1
  73. package/templates/openapi/ts/worker-configuration.d.ts +4 -0
  74. package/templates/openapi/ts/wrangler.toml +97 -0
  75. package/templates/pre-existing/c3.ts +4 -6
  76. package/templates/pre-existing/js/.editorconfig +0 -1
  77. package/templates/pre-existing/js/wrangler.toml +1 -0
  78. package/templates/queues/c3.ts +7 -6
  79. package/templates/queues/js/.editorconfig +0 -1
  80. package/templates/queues/js/wrangler.toml +88 -2
  81. package/templates/queues/ts/.editorconfig +0 -1
  82. package/templates/queues/ts/package.json +2 -1
  83. package/templates/queues/ts/src/index.ts +3 -5
  84. package/templates/queues/ts/worker-configuration.d.ts +5 -0
  85. package/templates/queues/ts/wrangler.toml +88 -2
  86. package/templates/qwik/c3.ts +117 -7
  87. package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
  88. package/templates/qwik/templates/worker-configuration.d.ts +4 -0
  89. package/templates/qwik/templates/wrangler.toml +78 -0
  90. package/templates/react/c3.ts +7 -5
  91. package/templates/remix/c3.ts +40 -7
  92. package/templates/remix/templates/worker-configuration.d.ts +4 -0
  93. package/templates/remix/templates/wrangler.toml +78 -0
  94. package/templates/scheduled/c3.ts +7 -6
  95. package/templates/scheduled/js/.editorconfig +0 -1
  96. package/templates/scheduled/js/wrangler.toml +97 -0
  97. package/templates/scheduled/ts/.editorconfig +0 -1
  98. package/templates/scheduled/ts/package.json +2 -1
  99. package/templates/scheduled/ts/src/index.ts +3 -20
  100. package/templates/scheduled/ts/worker-configuration.d.ts +4 -0
  101. package/templates/scheduled/ts/wrangler.toml +97 -0
  102. package/templates/solid/c3.ts +53 -17
  103. package/templates/solid/templates/wrangler.toml +77 -0
  104. package/templates/svelte/c3.ts +84 -29
  105. package/templates/svelte/js/wrangler.toml +78 -0
  106. package/templates/svelte/ts/wrangler.toml +78 -0
  107. package/templates/vue/c3.ts +7 -6
  108. package/templates/chatgptPlugin/c3.ts +0 -10
  109. package/templates/chatgptPlugin/ts/.assets/example.png +0 -0
  110. package/templates/chatgptPlugin/ts/README.md +0 -25
  111. package/templates/chatgptPlugin/ts/__dot__gitignore +0 -171
  112. package/templates/chatgptPlugin/ts/src/index.ts +0 -33
  113. package/templates/chatgptPlugin/ts/src/search.ts +0 -59
  114. package/templates/chatgptPlugin/ts/wrangler.toml +0 -3
  115. package/templates/next/templates.ts +0 -281
  116. package/templates/solid/js/vite.config.js +0 -7
  117. package/templates/solid/ts/vite.config.ts +0 -7
  118. package/templates/svelte/templates.ts +0 -13
@@ -0,0 +1,78 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+ pages_build_output_dir = "./dist"
5
+
6
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
+ # Docs:
8
+ # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
9
+ # Note: Use secrets to store sensitive data.
10
+ # - https://developers.cloudflare.com/pages/functions/bindings/#secrets
11
+ # [vars]
12
+ # MY_VARIABLE = "production_value"
13
+
14
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
15
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
16
+ # [ai]
17
+ # binding = "AI"
18
+
19
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
20
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
21
+ # [[d1_databases]]
22
+ # binding = "MY_DB"
23
+ # database_name = "my-database"
24
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
25
+
26
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
27
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
28
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
29
+ # [[durable_objects.bindings]]
30
+ # name = "MY_DURABLE_OBJECT"
31
+ # class_name = "MyDurableObject"
32
+ # script_name = 'my-durable-object'
33
+
34
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
35
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
36
+ # [[kv_namespaces]]
37
+ # binding = "MY_KV_NAMESPACE"
38
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
39
+
40
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
41
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
42
+ # [[queues.producers]]
43
+ # binding = "MY_QUEUE"
44
+ # queue = "my-queue"
45
+
46
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
47
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
48
+ # [[r2_buckets]]
49
+ # binding = "MY_BUCKET"
50
+ # bucket_name = "my-bucket"
51
+
52
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
53
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
54
+ # [[services]]
55
+ # binding = "MY_SERVICE"
56
+ # service = "my-service"
57
+
58
+ # To use different bindings for preview and production environments, follow the examples below.
59
+ # When using environment-specific overrides for bindings, ALL bindings must be specified on a per-environment basis.
60
+ # Docs: https://developers.cloudflare.com/pages/functions/wrangler-configuration#environment-specific-overrides
61
+
62
+ ######## PREVIEW environment config ########
63
+
64
+ # [env.preview.vars]
65
+ # API_KEY = "xyz789"
66
+
67
+ # [[env.preview.kv_namespaces]]
68
+ # binding = "MY_KV_NAMESPACE"
69
+ # id = "<PREVIEW_NAMESPACE_ID>"
70
+
71
+ ######## PRODUCTION environment config ########
72
+
73
+ # [env.production.vars]
74
+ # API_KEY = "abc123"
75
+
76
+ # [[env.production.kv_namespaces]]
77
+ # binding = "MY_KV_NAMESPACE"
78
+ # id = "<PRODUCTION_NAMESPACE_ID>"
@@ -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/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`,
58
+ preview: `${npm} run build && wrangler pages dev`,
59
+ "cf-typegen": `wrangler types`,
28
60
  },
29
61
  }),
30
- devCommand: ["dev"],
31
- testFlags: ["--typescript", "--no-install", "--no-git-init"],
62
+ devScript: "dev",
63
+ deployScript: "deploy",
64
+ previewScript: "preview",
32
65
  };
33
66
  export default config;
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ }
@@ -0,0 +1,78 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+ pages_build_output_dir = "./build/client"
5
+
6
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
7
+ # Docs:
8
+ # - https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
9
+ # Note: Use secrets to store sensitive data.
10
+ # - https://developers.cloudflare.com/pages/functions/bindings/#secrets
11
+ # [vars]
12
+ # MY_VARIABLE = "production_value"
13
+
14
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
15
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
16
+ # [ai]
17
+ # binding = "AI"
18
+
19
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
20
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
21
+ # [[d1_databases]]
22
+ # binding = "MY_DB"
23
+ # database_name = "my-database"
24
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
25
+
26
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
27
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
28
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
29
+ # [[durable_objects.bindings]]
30
+ # name = "MY_DURABLE_OBJECT"
31
+ # class_name = "MyDurableObject"
32
+ # script_name = 'my-durable-object'
33
+
34
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
35
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
36
+ # [[kv_namespaces]]
37
+ # binding = "MY_KV_NAMESPACE"
38
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
39
+
40
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
41
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
42
+ # [[queues.producers]]
43
+ # binding = "MY_QUEUE"
44
+ # queue = "my-queue"
45
+
46
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
47
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
48
+ # [[r2_buckets]]
49
+ # binding = "MY_BUCKET"
50
+ # bucket_name = "my-bucket"
51
+
52
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
53
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
54
+ # [[services]]
55
+ # binding = "MY_SERVICE"
56
+ # service = "my-service"
57
+
58
+ # To use different bindings for preview and production environments, follow the examples below.
59
+ # When using environment-specific overrides for bindings, ALL bindings must be specified on a per-environment basis.
60
+ # Docs: https://developers.cloudflare.com/pages/functions/wrangler-configuration#environment-specific-overrides
61
+
62
+ ######## PREVIEW environment config ########
63
+
64
+ # [env.preview.vars]
65
+ # API_KEY = "xyz789"
66
+
67
+ # [[env.preview.kv_namespaces]]
68
+ # binding = "MY_KV_NAMESPACE"
69
+ # id = "<PREVIEW_NAMESPACE_ID>"
70
+
71
+ ######## PRODUCTION environment config ########
72
+
73
+ # [env.production.vars]
74
+ # API_KEY = "abc123"
75
+
76
+ # [[env.production.kv_namespaces]]
77
+ # binding = "MY_KV_NAMESPACE"
78
+ # id = "<PRODUCTION_NAMESPACE_ID>"
@@ -3,13 +3,14 @@ export default {
3
3
  id: "scheduled",
4
4
  displayName: "Scheduled Worker (Cron Trigger)",
5
5
  platform: "workers",
6
- languages: ["js", "ts"],
7
6
  copyFiles: {
8
- js: {
9
- path: "./js",
10
- },
11
- ts: {
12
- path: "./ts",
7
+ variants: {
8
+ js: {
9
+ path: "./js",
10
+ },
11
+ ts: {
12
+ path: "./ts",
13
+ },
13
14
  },
14
15
  },
15
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
@@ -1,3 +1,4 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.js"
3
4
  compatibility_date = "<TBD>"
@@ -7,3 +8,99 @@ compatibility_date = "<TBD>"
7
8
  # Configuration: https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
8
9
  [triggers]
9
10
  crons = ["* * * * *"] # * * * * * = run every minute
11
+
12
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
13
+ # Docs:
14
+ # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
15
+ # Note: Use secrets to store sensitive data.
16
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
17
+ # [vars]
18
+ # MY_VARIABLE = "production_value"
19
+
20
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
21
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
22
+ # [ai]
23
+ # binding = "AI"
24
+
25
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
26
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
27
+ # [[analytics_engine_datasets]]
28
+ # binding = "MY_DATASET"
29
+
30
+ # Bind a headless browser instance running on Cloudflare's global network.
31
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
32
+ # [browser]
33
+ # binding = "MY_BROWSER"
34
+
35
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
36
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
37
+ # [[d1_databases]]
38
+ # binding = "MY_DB"
39
+ # database_name = "my-database"
40
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
41
+
42
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
43
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
44
+ # [[dispatch_namespaces]]
45
+ # binding = "MY_DISPATCHER"
46
+ # namespace = "my-namespace"
47
+
48
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
49
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
50
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
51
+ # [[durable_objects.bindings]]
52
+ # name = "MY_DURABLE_OBJECT"
53
+ # class_name = "MyDurableObject"
54
+
55
+ # Durable Object migrations.
56
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
57
+ # [[migrations]]
58
+ # tag = "v1"
59
+ # new_classes = ["MyDurableObject"]
60
+
61
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
62
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
63
+ # [[hyperdrive]]
64
+ # binding = "MY_HYPERDRIVE"
65
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
66
+
67
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
68
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
69
+ # [[kv_namespaces]]
70
+ # binding = "MY_KV_NAMESPACE"
71
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
72
+
73
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
74
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
75
+ # [[mtls_certificates]]
76
+ # binding = "MY_CERTIFICATE"
77
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
78
+
79
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
80
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
81
+ # [[queues.producers]]
82
+ # binding = "MY_QUEUE"
83
+ # queue = "my-queue"
84
+
85
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
86
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
87
+ # [[queues.consumers]]
88
+ # queue = "my-queue"
89
+
90
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
91
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
92
+ # [[r2_buckets]]
93
+ # binding = "MY_BUCKET"
94
+ # bucket_name = "my-bucket"
95
+
96
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
97
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
98
+ # [[services]]
99
+ # binding = "MY_SERVICE"
100
+ # service = "my-service"
101
+
102
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
103
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
104
+ # [[vectorize]]
105
+ # binding = "MY_INDEX"
106
+ # 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
@@ -5,7 +5,8 @@
5
5
  "scripts": {
6
6
  "deploy": "wrangler deploy",
7
7
  "dev": "wrangler dev",
8
- "start": "wrangler dev"
8
+ "start": "wrangler dev",
9
+ "cf-typegen": "wrangler types"
9
10
  },
10
11
  "devDependencies": {
11
12
  "typescript": "^5.0.4",
@@ -9,29 +9,12 @@
9
9
  * - Open a browser tab at http://localhost:8787/ to see your worker in action
10
10
  * - Run `npm run deploy` to publish your worker
11
11
  *
12
+ * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
13
+ * `Env` object can be regenerated with `npm run cf-typegen`.
14
+ *
12
15
  * Learn more at https://developers.cloudflare.com/workers/
13
16
  */
14
17
 
15
- export interface Env {
16
- // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
17
- // MY_KV_NAMESPACE: KVNamespace;
18
- //
19
- // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
20
- // MY_DURABLE_OBJECT: DurableObjectNamespace;
21
- //
22
- // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
23
- // MY_BUCKET: R2Bucket;
24
- //
25
- // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
26
- // MY_SERVICE: Fetcher;
27
- //
28
- // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/
29
- // MY_QUEUE: Queue;
30
- //
31
- // Example binding to a D1 Database. Learn more at https://developers.cloudflare.com/workers/platform/bindings/#d1-database-bindings
32
- // DB: D1Database
33
- }
34
-
35
18
  export default {
36
19
  // The scheduled handler is invoked at the interval set in our wrangler.toml's
37
20
  // [[triggers]] configuration.
@@ -0,0 +1,4 @@
1
+ // Generated by Wrangler
2
+ // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
3
+ interface Env {
4
+ }
@@ -1,3 +1,4 @@
1
+ #:schema node_modules/wrangler/config-schema.json
1
2
  name = "<TBD>"
2
3
  main = "src/index.ts"
3
4
  compatibility_date = "<TBD>"
@@ -7,3 +8,99 @@ compatibility_date = "<TBD>"
7
8
  # Configuration: https://developers.cloudflare.com/workers/wrangler/configuration/#triggers
8
9
  [triggers]
9
10
  crons = ["* * * * *"] # * * * * * = run every minute
11
+
12
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
13
+ # Docs:
14
+ # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
15
+ # Note: Use secrets to store sensitive data.
16
+ # - https://developers.cloudflare.com/workers/configuration/secrets/
17
+ # [vars]
18
+ # MY_VARIABLE = "production_value"
19
+
20
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
21
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
22
+ # [ai]
23
+ # binding = "AI"
24
+
25
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
26
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
27
+ # [[analytics_engine_datasets]]
28
+ # binding = "MY_DATASET"
29
+
30
+ # Bind a headless browser instance running on Cloudflare's global network.
31
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
32
+ # [browser]
33
+ # binding = "MY_BROWSER"
34
+
35
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
36
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
37
+ # [[d1_databases]]
38
+ # binding = "MY_DB"
39
+ # database_name = "my-database"
40
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
41
+
42
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
43
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
44
+ # [[dispatch_namespaces]]
45
+ # binding = "MY_DISPATCHER"
46
+ # namespace = "my-namespace"
47
+
48
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
49
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
50
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
51
+ # [[durable_objects.bindings]]
52
+ # name = "MY_DURABLE_OBJECT"
53
+ # class_name = "MyDurableObject"
54
+
55
+ # Durable Object migrations.
56
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
57
+ # [[migrations]]
58
+ # tag = "v1"
59
+ # new_classes = ["MyDurableObject"]
60
+
61
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
62
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
63
+ # [[hyperdrive]]
64
+ # binding = "MY_HYPERDRIVE"
65
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
66
+
67
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
68
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
69
+ # [[kv_namespaces]]
70
+ # binding = "MY_KV_NAMESPACE"
71
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
72
+
73
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
74
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
75
+ # [[mtls_certificates]]
76
+ # binding = "MY_CERTIFICATE"
77
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
78
+
79
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
80
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
81
+ # [[queues.producers]]
82
+ # binding = "MY_QUEUE"
83
+ # queue = "my-queue"
84
+
85
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
86
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
87
+ # [[queues.consumers]]
88
+ # queue = "my-queue"
89
+
90
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
91
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
92
+ # [[r2_buckets]]
93
+ # binding = "MY_BUCKET"
94
+ # bucket_name = "my-bucket"
95
+
96
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
97
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
98
+ # [[services]]
99
+ # binding = "MY_SERVICE"
100
+ # service = "my-service"
101
+
102
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
103
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
104
+ # [[vectorize]]
105
+ # binding = "MY_INDEX"
106
+ # index_name = "my-index"
@@ -1,8 +1,10 @@
1
1
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
- import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
- import { installPackages, runFrameworkGenerator } from "helpers/command";
4
- import { compatDateFlag } from "helpers/files";
5
- import { detectPackageManager } from "helpers/packages";
2
+ import { blue } from "@cloudflare/cli/colors";
3
+ import { runFrameworkGenerator } from "frameworks/index";
4
+ import { transformFile } from "helpers/codemod";
5
+ import { usesTypescript } from "helpers/files";
6
+ import { detectPackageManager } from "helpers/packageManagers";
7
+ import * as recast from "recast";
6
8
  import type { TemplateConfig } from "../../src/templates";
7
9
  import type { C3Context } from "types";
8
10
 
@@ -10,21 +12,52 @@ const { npm } = detectPackageManager();
10
12
 
11
13
  const generate = async (ctx: C3Context) => {
12
14
  // Run the create-solid command
13
- await runFrameworkGenerator(ctx, [ctx.project.name]);
15
+ // -s flag forces solid-start
16
+ await runFrameworkGenerator(ctx, ["-p", ctx.project.name, "-s"]);
14
17
 
15
18
  logRaw("");
16
19
  };
17
20
 
18
21
  const configure = async (ctx: C3Context) => {
19
- // Install the pages adapter
20
- const pkg = "solid-start-cloudflare-pages";
21
- await installPackages([pkg], {
22
- dev: true,
23
- startText: "Adding the Cloudflare Pages adapter",
24
- doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
25
- });
22
+ usesTypescript(ctx);
23
+ const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
24
+
25
+ updateStatus(`Updating configuration in ${blue(filePath)}`);
26
+
27
+ transformFile(filePath, {
28
+ visitCallExpression: function (n) {
29
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
30
+ if (callee.name !== "defineConfig") {
31
+ return this.traverse(n);
32
+ }
26
33
 
27
- updateStatus(`Adding the Cloudflare Pages adapter to vite config`);
34
+ const b = recast.types.builders;
35
+ n.node.arguments = [
36
+ b.objectExpression([
37
+ b.objectProperty(
38
+ b.identifier("server"),
39
+ b.objectExpression([
40
+ b.objectProperty(
41
+ b.identifier("preset"),
42
+ b.stringLiteral("cloudflare-pages")
43
+ ),
44
+ b.objectProperty(
45
+ b.identifier("rollupConfig"),
46
+ b.objectExpression([
47
+ b.objectProperty(
48
+ b.identifier("external"),
49
+ b.arrayExpression([b.stringLiteral("node:async_hooks")])
50
+ ),
51
+ ])
52
+ ),
53
+ ])
54
+ ),
55
+ ]),
56
+ ];
57
+
58
+ return false;
59
+ },
60
+ });
28
61
  };
29
62
 
30
63
  const config: TemplateConfig = {
@@ -33,16 +66,19 @@ const config: TemplateConfig = {
33
66
  displayName: "Solid",
34
67
  platform: "pages",
35
68
  copyFiles: {
36
- js: { path: "./js" },
37
- ts: { path: "./ts" },
69
+ path: "./templates",
38
70
  },
39
71
  generate,
40
72
  configure,
41
73
  transformPackageJson: async () => ({
42
74
  scripts: {
43
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 3000 -- ${npm} run dev`,
44
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist/public`,
75
+ preview: `${npm} run build && npx wrangler pages dev`,
76
+ deploy: `${npm} run build && wrangler pages deploy`,
45
77
  },
46
78
  }),
79
+ compatibilityFlags: ["nodejs_compat"],
80
+ devScript: "dev",
81
+ deployScript: "deploy",
82
+ previewScript: "preview",
47
83
  };
48
84
  export default config;