create-cloudflare 2.12.1 → 2.13.1

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.
@@ -0,0 +1,50 @@
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/workers/platform/environment-variables
7
+ # [vars]
8
+ # MY_VARIABLE = "production_value"
9
+
10
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
11
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
12
+ # [[kv_namespaces]]
13
+ # binding = "MY_KV_NAMESPACE"
14
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
15
+
16
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
17
+ # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
18
+ # [[r2_buckets]]
19
+ # binding = "MY_BUCKET"
20
+ # bucket_name = "my-bucket"
21
+
22
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
23
+ # Docs: https://developers.cloudflare.com/queues/get-started
24
+ # [[queues.producers]]
25
+ # binding = "MY_QUEUE"
26
+ # queue = "my-queue"
27
+
28
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
29
+ # Docs: https://developers.cloudflare.com/queues/get-started
30
+ # [[queues.consumers]]
31
+ # queue = "my-queue"
32
+
33
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
34
+ # Docs: https://developers.cloudflare.com/workers/platform/services
35
+ # [[services]]
36
+ # binding = "MY_SERVICE"
37
+ # service = "my-service"
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"]
@@ -81,10 +81,10 @@ const config: TemplateConfig = {
81
81
  configVersion: 1,
82
82
  id: "nuxt",
83
83
  platform: "pages",
84
+ displayName: "Nuxt",
84
85
  copyFiles: {
85
86
  path: "./templates",
86
87
  },
87
- displayName: "Nuxt",
88
88
  devScript: "dev",
89
89
  deployScript: "deploy",
90
90
  generate,
@@ -1,4 +1,7 @@
1
1
  import { logRaw } from "@cloudflare/cli";
2
+ import { brandColor, dim } from "@cloudflare/cli/colors";
3
+ import { spinner } from "@cloudflare/cli/interactive";
4
+ import { transformFile } from "helpers/codemod";
2
5
  import { runFrameworkGenerator } from "helpers/command.js";
3
6
  import { detectPackageManager } from "helpers/packages";
4
7
  import type { TemplateConfig } from "../../src/templates";
@@ -10,24 +13,55 @@ 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",
63
+ deployScript: "deploy",
64
+ previewScript: "preview",
31
65
  testFlags: ["--typescript", "--no-install", "--no-git-init"],
32
66
  };
33
67
  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,50 @@
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/workers/platform/environment-variables
7
+ # [vars]
8
+ # MY_VARIABLE = "production_value"
9
+
10
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
11
+ # Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
12
+ # [[kv_namespaces]]
13
+ # binding = "MY_KV_NAMESPACE"
14
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
15
+
16
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
17
+ # Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
18
+ # [[r2_buckets]]
19
+ # binding = "MY_BUCKET"
20
+ # bucket_name = "my-bucket"
21
+
22
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
23
+ # Docs: https://developers.cloudflare.com/queues/get-started
24
+ # [[queues.producers]]
25
+ # binding = "MY_QUEUE"
26
+ # queue = "my-queue"
27
+
28
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
29
+ # Docs: https://developers.cloudflare.com/queues/get-started
30
+ # [[queues.consumers]]
31
+ # queue = "my-queue"
32
+
33
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
34
+ # Docs: https://developers.cloudflare.com/workers/platform/services
35
+ # [[services]]
36
+ # binding = "MY_SERVICE"
37
+ # service = "my-service"
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"]
@@ -1,7 +1,10 @@
1
- import { logRaw } from "@cloudflare/cli";
1
+ import { logRaw, updateStatus } from "@cloudflare/cli";
2
+ import { blue } from "@cloudflare/cli/colors";
3
+ import { transformFile } from "helpers/codemod";
2
4
  import { runFrameworkGenerator } from "helpers/command";
3
- import { compatDateFlag } from "helpers/files";
5
+ import { compatDateFlag, usesTypescript } from "helpers/files";
4
6
  import { detectPackageManager } from "helpers/packages";
7
+ import * as recast from "recast";
5
8
  import type { TemplateConfig } from "../../src/templates";
6
9
  import type { C3Context } from "types";
7
10
 
@@ -14,26 +17,64 @@ const generate = async (ctx: C3Context) => {
14
17
  logRaw("");
15
18
  };
16
19
 
20
+ const configure = async (ctx: C3Context) => {
21
+ usesTypescript(ctx);
22
+ const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
23
+
24
+ updateStatus(`Updating configuration in ${blue(filePath)}`);
25
+
26
+ transformFile(filePath, {
27
+ visitCallExpression: function (n) {
28
+ const callee = n.node.callee as recast.types.namedTypes.Identifier;
29
+ if (callee.name !== "defineConfig") {
30
+ return this.traverse(n);
31
+ }
32
+
33
+ const b = recast.types.builders;
34
+ n.node.arguments = [
35
+ b.objectExpression([
36
+ b.objectProperty(
37
+ b.identifier("server"),
38
+ b.objectExpression([
39
+ b.objectProperty(
40
+ b.identifier("preset"),
41
+ b.stringLiteral("cloudflare-pages")
42
+ ),
43
+ b.objectProperty(
44
+ b.identifier("rollupConfig"),
45
+ b.objectExpression([
46
+ b.objectProperty(
47
+ b.identifier("external"),
48
+ b.arrayExpression([b.stringLiteral("node:async_hooks")])
49
+ ),
50
+ ])
51
+ ),
52
+ ])
53
+ ),
54
+ ]),
55
+ ];
56
+
57
+ return false;
58
+ },
59
+ });
60
+ };
61
+
17
62
  const config: TemplateConfig = {
18
63
  configVersion: 1,
19
64
  id: "solid",
20
65
  displayName: "Solid",
21
66
  platform: "pages",
22
- copyFiles: {
23
- variants: {
24
- js: { path: "./js" },
25
- ts: { path: "./ts" },
26
- },
27
- },
28
67
  generate,
68
+ configure,
29
69
  transformPackageJson: async () => ({
30
70
  scripts: {
31
- "pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
32
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
71
+ preview: `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
72
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
33
73
  },
34
74
  }),
35
75
  devScript: "dev",
36
- previewScript: "pages:preview",
76
+ deployScript: "deploy",
77
+ previewScript: "preview",
37
78
  compatibilityFlags: ["nodejs_compat"],
38
79
  };
39
80
  export default config;
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "@solidjs/start/config";
2
-
3
- export default defineConfig({
4
- start: {
5
- server: {
6
- preset: "cloudflare-pages",
7
- rollupConfig: {
8
- external: ["node:async_hooks"]
9
- },
10
- }
11
- }
12
- });
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "@solidjs/start/config";
2
-
3
- export default defineConfig({
4
- start: {
5
- server: {
6
- preset: "cloudflare-pages",
7
- rollupConfig: {
8
- external: ["node:async_hooks"]
9
- },
10
- }
11
- }
12
- });