create-cloudflare 0.0.0-d8d46b2d → 0.0.0-d95450f0

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 (82) hide show
  1. package/dist/cli.js +27466 -25365
  2. package/package.json +9 -5
  3. package/templates/angular/c3.ts +10 -9
  4. package/templates/astro/c3.ts +81 -19
  5. package/templates/astro/snippets/runtimeDeclaration.ts +5 -0
  6. package/templates/astro/templates/wrangler.toml +53 -0
  7. package/templates/common/c3.ts +7 -5
  8. package/templates/common/js/.editorconfig +0 -1
  9. package/templates/common/js/wrangler.toml +69 -22
  10. package/templates/common/ts/.editorconfig +0 -1
  11. package/templates/common/ts/wrangler.toml +69 -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 +5 -2
  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 +70 -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 +70 -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 +70 -23
  30. package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
  31. package/templates/hello-world-durable-object/ts/wrangler.toml +69 -21
  32. package/templates/hello-world-python/c3.ts +9 -0
  33. package/templates/hello-world-python/py/__dot__gitignore +68 -0
  34. package/templates/hello-world-python/py/package.json +13 -0
  35. package/templates/hello-world-python/py/src/entry.py +4 -0
  36. package/templates/hello-world-python/py/wrangler.toml +99 -0
  37. package/templates/hono/c3.ts +1 -1
  38. package/templates/next/README.md +68 -0
  39. package/templates/next/app/js/app/api/hello/route.js +21 -0
  40. package/templates/next/app/js/app/not-found.js +58 -0
  41. package/templates/next/app/ts/app/api/hello/route.ts +22 -0
  42. package/templates/next/app/ts/app/not-found.tsx +58 -0
  43. package/templates/next/c3.ts +99 -76
  44. package/templates/next/env.d.ts +5 -0
  45. package/templates/next/pages/js/pages/api/hello.js +23 -0
  46. package/templates/next/pages/ts/pages/api/hello.ts +24 -0
  47. package/templates/next/wrangler.toml +55 -0
  48. package/templates/nuxt/c3.ts +94 -19
  49. package/templates/nuxt/templates/env.d.ts +14 -0
  50. package/templates/nuxt/templates/worker-configuration.d.ts +4 -0
  51. package/templates/nuxt/templates/wrangler.toml +53 -0
  52. package/templates/openapi/ts/wrangler.toml +1 -0
  53. package/templates/pre-existing/c3.ts +2 -2
  54. package/templates/pre-existing/js/.editorconfig +0 -1
  55. package/templates/pre-existing/js/wrangler.toml +1 -0
  56. package/templates/queues/c3.ts +7 -5
  57. package/templates/queues/js/.editorconfig +0 -1
  58. package/templates/queues/js/wrangler.toml +86 -2
  59. package/templates/queues/ts/.editorconfig +0 -1
  60. package/templates/queues/ts/wrangler.toml +86 -2
  61. package/templates/qwik/c3.ts +118 -8
  62. package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
  63. package/templates/qwik/templates/worker-configuration.d.ts +4 -0
  64. package/templates/qwik/templates/wrangler.toml +53 -0
  65. package/templates/react/c3.ts +7 -5
  66. package/templates/remix/c3.ts +39 -6
  67. package/templates/remix/templates/worker-configuration.d.ts +4 -0
  68. package/templates/remix/templates/wrangler.toml +53 -0
  69. package/templates/scheduled/c3.ts +7 -5
  70. package/templates/scheduled/js/.editorconfig +0 -1
  71. package/templates/scheduled/js/wrangler.toml +95 -0
  72. package/templates/scheduled/ts/.editorconfig +0 -1
  73. package/templates/scheduled/ts/wrangler.toml +95 -0
  74. package/templates/solid/c3.ts +58 -13
  75. package/templates/svelte/c3.ts +83 -30
  76. package/templates/svelte/js/wrangler.toml +53 -0
  77. package/templates/svelte/ts/wrangler.toml +53 -0
  78. package/templates/vue/c3.ts +7 -6
  79. package/templates/next/templates.ts +0 -281
  80. package/templates/solid/js/vite.config.js +0 -12
  81. package/templates/solid/ts/vite.config.ts +0 -12
  82. package/templates/svelte/templates.ts +0 -13
@@ -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,97 @@ 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
+ # Note: Use secrets to store sensitive data.
14
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
15
+ # [vars]
16
+ # MY_VARIABLE = "production_value"
17
+
18
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
19
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
20
+ # [ai]
21
+ # binding = "AI"
22
+
23
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
24
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
25
+ # [[analytics_engine_datasets]]
26
+ # binding = "MY_DATASET"
27
+
28
+ # Bind a headless browser instance running on Cloudflare's global network.
29
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
30
+ # [browser]
31
+ # binding = "MY_BROWSER"
32
+
33
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
34
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
35
+ # [[d1_databases]]
36
+ # binding = "MY_DB"
37
+ # database_name = "my-database"
38
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
39
+
40
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
41
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
42
+ # [[dispatch_namespaces]]
43
+ # binding = "MY_DISPATCHER"
44
+ # namespace = "my-namespace"
45
+
46
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
47
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
48
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
49
+ # [[durable_objects.bindings]]
50
+ # name = "MY_DURABLE_OBJECT"
51
+ # class_name = "MyDurableObject"
52
+
53
+ # Durable Object migrations.
54
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
55
+ # [[migrations]]
56
+ # tag = "v1"
57
+ # new_classes = ["MyDurableObject"]
58
+
59
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
60
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
61
+ # [[hyperdrive]]
62
+ # binding = "MY_HYPERDRIVE"
63
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
64
+
65
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
66
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
67
+ # [[kv_namespaces]]
68
+ # binding = "MY_KV_NAMESPACE"
69
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
70
+
71
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
72
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
73
+ # [[mtls_certificates]]
74
+ # binding = "MY_CERTIFICATE"
75
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
76
+
77
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
78
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
79
+ # [[queues.producers]]
80
+ # binding = "MY_QUEUE"
81
+ # queue = "my-queue"
82
+
83
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
84
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
85
+ # [[queues.consumers]]
86
+ # queue = "my-queue"
87
+
88
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
89
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
90
+ # [[r2_buckets]]
91
+ # binding = "MY_BUCKET"
92
+ # bucket_name = "my-bucket"
93
+
94
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
95
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
96
+ # [[services]]
97
+ # binding = "MY_SERVICE"
98
+ # service = "my-service"
99
+
100
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
101
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
102
+ # [[vectorize]]
103
+ # binding = "MY_INDEX"
104
+ # 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
@@ -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,97 @@ 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
+ # Note: Use secrets to store sensitive data.
14
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
15
+ # [vars]
16
+ # MY_VARIABLE = "production_value"
17
+
18
+ # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
19
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
20
+ # [ai]
21
+ # binding = "AI"
22
+
23
+ # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
24
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
25
+ # [[analytics_engine_datasets]]
26
+ # binding = "MY_DATASET"
27
+
28
+ # Bind a headless browser instance running on Cloudflare's global network.
29
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
30
+ # [browser]
31
+ # binding = "MY_BROWSER"
32
+
33
+ # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
34
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
35
+ # [[d1_databases]]
36
+ # binding = "MY_DB"
37
+ # database_name = "my-database"
38
+ # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
39
+
40
+ # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
41
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
42
+ # [[dispatch_namespaces]]
43
+ # binding = "MY_DISPATCHER"
44
+ # namespace = "my-namespace"
45
+
46
+ # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
47
+ # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
48
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
49
+ # [[durable_objects.bindings]]
50
+ # name = "MY_DURABLE_OBJECT"
51
+ # class_name = "MyDurableObject"
52
+
53
+ # Durable Object migrations.
54
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
55
+ # [[migrations]]
56
+ # tag = "v1"
57
+ # new_classes = ["MyDurableObject"]
58
+
59
+ # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
60
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
61
+ # [[hyperdrive]]
62
+ # binding = "MY_HYPERDRIVE"
63
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
64
+
65
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
66
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
67
+ # [[kv_namespaces]]
68
+ # binding = "MY_KV_NAMESPACE"
69
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
70
+
71
+ # Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
72
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
73
+ # [[mtls_certificates]]
74
+ # binding = "MY_CERTIFICATE"
75
+ # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
76
+
77
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
78
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
79
+ # [[queues.producers]]
80
+ # binding = "MY_QUEUE"
81
+ # queue = "my-queue"
82
+
83
+ # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
84
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
85
+ # [[queues.consumers]]
86
+ # queue = "my-queue"
87
+
88
+ # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
89
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
90
+ # [[r2_buckets]]
91
+ # binding = "MY_BUCKET"
92
+ # bucket_name = "my-bucket"
93
+
94
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
95
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
96
+ # [[services]]
97
+ # binding = "MY_SERVICE"
98
+ # service = "my-service"
99
+
100
+ # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
101
+ # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
102
+ # [[vectorize]]
103
+ # binding = "MY_INDEX"
104
+ # 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;
@@ -1,13 +1,14 @@
1
+ import { platform } from "node:os";
1
2
  import { logRaw, updateStatus } from "@cloudflare/cli";
2
3
  import { blue, brandColor, dim } from "@cloudflare/cli/colors";
3
- import { parseTs, transformFile } from "helpers/codemod";
4
- import { installPackages, runFrameworkGenerator } from "helpers/command";
5
- import { compatDateFlag, usesTypescript } from "helpers/files";
6
- import { detectPackageManager } from "helpers/packages";
7
- import { platformInterface } from "./templates";
4
+ import { runFrameworkGenerator } from "frameworks/index";
5
+ import { transformFile } from "helpers/codemod";
6
+ import { usesTypescript } from "helpers/files";
7
+ import { detectPackageManager } from "helpers/packageManagers";
8
+ import { installPackages } from "helpers/packages";
9
+ import * as recast from "recast";
8
10
  import type { TemplateConfig } from "../../src/templates";
9
- import type * as recast from "recast";
10
- import type { C3Context } from "types";
11
+ import type { C3Context, PackageJson } from "types";
11
12
 
12
13
  const { npm } = detectPackageManager();
13
14
 
@@ -26,7 +27,14 @@ const configure = async (ctx: C3Context) => {
26
27
  doneText: `${brandColor(`installed`)} ${dim(pkg)}`,
27
28
  });
28
29
 
29
- // Change the import statement in svelte.config.js
30
+ updateSvelteConfig();
31
+ updateTypeDefinitions(ctx);
32
+ };
33
+
34
+ const updateSvelteConfig = () => {
35
+ // All we need to do is change the import statement in svelte.config.js
36
+ updateStatus(`Changing adapter in ${blue("svelte.config.js")}`);
37
+
30
38
  transformFile("svelte.config.js", {
31
39
  visitImportDeclaration: function (n) {
32
40
  // importSource is the `x` in `import y from "x"`
@@ -39,23 +47,51 @@ const configure = async (ctx: C3Context) => {
39
47
  return false;
40
48
  },
41
49
  });
42
- updateStatus(`Changing adapter in ${blue("svelte.config.js")}`);
50
+ };
43
51
 
44
- // If using typescript, add the platform interface to the `App` interface
45
- if (usesTypescript(ctx)) {
46
- transformFile("src/app.d.ts", {
47
- visitTSModuleDeclaration(n) {
48
- if (n.value.id.name === "App") {
49
- const patchAst = parseTs(platformInterface);
50
- const body = n.node.body as recast.types.namedTypes.TSModuleBlock;
51
- body.body.push(patchAst.program.body[0]);
52
- }
53
-
54
- this.traverse(n);
55
- },
56
- });
57
- updateStatus(`Updating global type definitions in ${blue("app.d.ts")}`);
52
+ const updateTypeDefinitions = (ctx: C3Context) => {
53
+ if (!usesTypescript(ctx)) {
54
+ return;
58
55
  }
56
+
57
+ updateStatus(`Updating global type definitions in ${blue("app.d.ts")}`);
58
+
59
+ const b = recast.types.builders;
60
+
61
+ transformFile("src/app.d.ts", {
62
+ visitTSModuleDeclaration(n) {
63
+ if (n.value.id.name === "App" && n.node.body) {
64
+ const moduleBlock = n.node
65
+ .body as recast.types.namedTypes.TSModuleBlock;
66
+
67
+ const platformInterface = b.tsInterfaceDeclaration(
68
+ b.identifier("Platform"),
69
+ b.tsInterfaceBody([
70
+ b.tsPropertySignature(
71
+ b.identifier("env"),
72
+ b.tsTypeAnnotation(b.tsTypeReference(b.identifier("Env")))
73
+ ),
74
+ b.tsPropertySignature(
75
+ b.identifier("cf"),
76
+ b.tsTypeAnnotation(
77
+ b.tsTypeReference(b.identifier("CfProperties"))
78
+ )
79
+ ),
80
+ b.tsPropertySignature(
81
+ b.identifier("ctx"),
82
+ b.tsTypeAnnotation(
83
+ b.tsTypeReference(b.identifier("ExecutionContext"))
84
+ )
85
+ ),
86
+ ])
87
+ );
88
+
89
+ moduleBlock.body.unshift(platformInterface);
90
+ }
91
+
92
+ this.traverse(n);
93
+ },
94
+ });
59
95
  };
60
96
 
61
97
  const config: TemplateConfig = {
@@ -63,15 +99,32 @@ const config: TemplateConfig = {
63
99
  id: "svelte",
64
100
  displayName: "Svelte",
65
101
  platform: "pages",
102
+ copyFiles: {
103
+ variants: {
104
+ js: { path: "./js" },
105
+ ts: { path: "./ts" },
106
+ },
107
+ },
66
108
  generate,
67
109
  configure,
68
- transformPackageJson: async () => ({
69
- scripts: {
70
- "pages:preview": `${npm} run build && wrangler pages dev ${await compatDateFlag()} .svelte-kit/cloudflare`,
71
- "pages:deploy": `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
72
- },
73
- }),
110
+ transformPackageJson: async (original: PackageJson, ctx: C3Context) => {
111
+ let scripts: Record<string, string> = {
112
+ preview: `${npm} run build && wrangler pages dev .svelte-kit/cloudflare`,
113
+ deploy: `${npm} run build && wrangler pages deploy .svelte-kit/cloudflare`,
114
+ };
115
+
116
+ if (usesTypescript(ctx)) {
117
+ const mv = platform() === "win32" ? "move" : "mv";
118
+ scripts = {
119
+ ...scripts,
120
+ "build-cf-types": `wrangler types && ${mv} worker-configuration.d.ts src/`,
121
+ };
122
+ }
123
+
124
+ return { scripts };
125
+ },
74
126
  devScript: "dev",
75
- previewScript: "pages:preview",
127
+ deployScript: "deploy",
128
+ previewScript: "preview",
76
129
  };
77
130
  export default config;
@@ -0,0 +1,53 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+
5
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
6
+ # Note: Use secrets to store sensitive data.
7
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
8
+ # [vars]
9
+ # MY_VARIABLE = "production_value"
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
+
31
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
32
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
33
+ # [[kv_namespaces]]
34
+ # binding = "MY_KV_NAMESPACE"
35
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
36
+
37
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
38
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
39
+ # [[queues.producers]]
40
+ # binding = "MY_QUEUE"
41
+ # queue = "my-queue"
42
+
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"
48
+
49
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
50
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
51
+ # [[services]]
52
+ # binding = "MY_SERVICE"
53
+ # service = "my-service"
@@ -0,0 +1,53 @@
1
+ #:schema node_modules/wrangler/config-schema.json
2
+ name = "<TBD>"
3
+ compatibility_date = "<TBD>"
4
+
5
+ # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
6
+ # Note: Use secrets to store sensitive data.
7
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
8
+ # [vars]
9
+ # MY_VARIABLE = "production_value"
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
+
31
+ # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
32
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
33
+ # [[kv_namespaces]]
34
+ # binding = "MY_KV_NAMESPACE"
35
+ # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
36
+
37
+ # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
38
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
39
+ # [[queues.producers]]
40
+ # binding = "MY_QUEUE"
41
+ # queue = "my-queue"
42
+
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"
48
+
49
+ # Bind another Worker service. Use this binding to call another Worker without network overhead.
50
+ # Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
51
+ # [[services]]
52
+ # binding = "MY_SERVICE"
53
+ # service = "my-service"
@@ -1,6 +1,5 @@
1
- import { runFrameworkGenerator } from "helpers/command";
2
- import { compatDateFlag } from "helpers/files";
3
- import { detectPackageManager } from "helpers/packages";
1
+ import { runFrameworkGenerator } from "frameworks/index";
2
+ import { detectPackageManager } from "helpers/packageManagers";
4
3
  import type { TemplateConfig } from "../../src/templates";
5
4
  import type { C3Context } from "types";
6
5
 
@@ -18,10 +17,12 @@ const config: TemplateConfig = {
18
17
  generate,
19
18
  transformPackageJson: async () => ({
20
19
  scripts: {
21
- "pages:dev": `wrangler pages dev ${await compatDateFlag()} --proxy 5173 -- ${npm} run dev`,
22
- "pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
20
+ deploy: `${npm} run build && wrangler pages deploy ./dist`,
21
+ preview: `${npm} run build && wrangler pages dev ./dist`,
23
22
  },
24
23
  }),
25
- testFlags: ["--ts"],
24
+ devScript: "dev",
25
+ deployScript: "deploy",
26
+ previewScript: "preview",
26
27
  };
27
28
  export default config;