create-cloudflare 0.0.0-e7ccc859 → 0.0.0-e7f8dc32
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.
- package/dist/cli.js +26913 -24870
- package/package.json +8 -4
- package/templates/angular/c3.ts +10 -9
- package/templates/astro/c3.ts +81 -19
- package/templates/astro/snippets/runtimeDeclaration.ts +5 -0
- package/templates/astro/templates/wrangler.toml +52 -0
- package/templates/common/c3.ts +7 -5
- package/templates/common/js/.editorconfig +0 -1
- package/templates/common/js/wrangler.toml +68 -22
- package/templates/common/ts/.editorconfig +0 -1
- package/templates/common/ts/wrangler.toml +68 -22
- package/templates/docusaurus/c3.ts +5 -6
- package/templates/gatsby/c3.ts +7 -5
- package/templates/hello-world/c3.ts +7 -5
- package/templates/hello-world/js/.editorconfig +0 -1
- package/templates/hello-world/js/package.json +3 -1
- package/templates/hello-world/js/test/index.spec.js +20 -0
- package/templates/hello-world/js/vitest.config.js +11 -0
- package/templates/hello-world/js/wrangler.toml +69 -22
- package/templates/hello-world/ts/.editorconfig +0 -1
- package/templates/hello-world/ts/package.json +5 -2
- package/templates/hello-world/ts/test/index.spec.ts +25 -0
- package/templates/hello-world/ts/test/tsconfig.json +11 -0
- package/templates/hello-world/ts/tsconfig.json +3 -2
- package/templates/hello-world/ts/vitest.config.ts +11 -0
- package/templates/hello-world/ts/wrangler.toml +69 -22
- package/templates/hello-world-durable-object/c3.ts +7 -5
- package/templates/hello-world-durable-object/js/.editorconfig +0 -1
- package/templates/hello-world-durable-object/js/wrangler.toml +69 -23
- package/templates/hello-world-durable-object/ts/.editorconfig +0 -1
- package/templates/hello-world-durable-object/ts/wrangler.toml +68 -21
- package/templates/hello-world-python/c3.ts +9 -0
- package/templates/hello-world-python/py/__dot__gitignore +68 -0
- package/templates/hello-world-python/py/package.json +13 -0
- package/templates/hello-world-python/py/src/entry.py +4 -0
- package/templates/hello-world-python/py/wrangler.toml +4 -0
- package/templates/hono/c3.ts +1 -1
- package/templates/next/README.md +68 -0
- package/templates/next/app/js/app/api/hello/route.js +21 -0
- package/templates/next/app/js/app/not-found.js +58 -0
- package/templates/next/app/ts/app/api/hello/route.ts +22 -0
- package/templates/next/app/ts/app/not-found.tsx +58 -0
- package/templates/next/c3.ts +99 -76
- package/templates/next/env.d.ts +5 -0
- package/templates/next/pages/js/pages/api/hello.js +23 -0
- package/templates/next/pages/ts/pages/api/hello.ts +24 -0
- package/templates/next/wrangler.toml +54 -0
- package/templates/nuxt/c3.ts +94 -19
- package/templates/nuxt/templates/env.d.ts +14 -0
- package/templates/nuxt/templates/worker-configuration.d.ts +4 -0
- package/templates/nuxt/templates/wrangler.toml +52 -0
- package/templates/pre-existing/c3.ts +2 -2
- package/templates/pre-existing/js/.editorconfig +0 -1
- package/templates/queues/c3.ts +7 -5
- package/templates/queues/js/.editorconfig +0 -1
- package/templates/queues/js/wrangler.toml +85 -2
- package/templates/queues/ts/.editorconfig +0 -1
- package/templates/queues/ts/wrangler.toml +85 -2
- package/templates/qwik/c3.ts +82 -28
- package/templates/qwik/snippets/getPlatformProxy.ts +6 -0
- package/templates/qwik/templates/worker-configuration.d.ts +4 -0
- package/templates/qwik/templates/wrangler.toml +52 -0
- package/templates/react/c3.ts +7 -5
- package/templates/remix/c3.ts +39 -6
- package/templates/remix/templates/worker-configuration.d.ts +4 -0
- package/templates/remix/templates/wrangler.toml +52 -0
- package/templates/scheduled/c3.ts +7 -5
- package/templates/scheduled/js/.editorconfig +0 -1
- package/templates/scheduled/js/wrangler.toml +94 -0
- package/templates/scheduled/ts/.editorconfig +0 -1
- package/templates/scheduled/ts/wrangler.toml +94 -0
- package/templates/solid/c3.ts +58 -13
- package/templates/svelte/c3.ts +83 -30
- package/templates/svelte/js/wrangler.toml +52 -0
- package/templates/svelte/ts/wrangler.toml +52 -0
- package/templates/vue/c3.ts +7 -6
- package/templates/next/templates.ts +0 -281
- package/templates/solid/js/vite.config.js +0 -12
- package/templates/solid/ts/vite.config.ts +0 -12
- package/templates/svelte/templates.ts +0 -13
|
@@ -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"
|
|
@@ -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"
|
package/templates/solid/c3.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { logRaw } from "@cloudflare/cli";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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;
|
package/templates/svelte/c3.ts
CHANGED
|
@@ -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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { detectPackageManager } from "helpers/
|
|
7
|
-
import {
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
50
|
+
};
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
if (usesTypescript(ctx)) {
|
|
46
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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
|
-
|
|
127
|
+
deployScript: "deploy",
|
|
128
|
+
previewScript: "preview",
|
|
76
129
|
};
|
|
77
130
|
export default config;
|
|
@@ -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"
|
|
@@ -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"
|
package/templates/vue/c3.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { runFrameworkGenerator } from "
|
|
2
|
-
import {
|
|
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
|
-
|
|
22
|
-
|
|
20
|
+
deploy: `${npm} run build && wrangler pages deploy ./dist`,
|
|
21
|
+
preview: `${npm} run build && wrangler pages dev ./dist`,
|
|
23
22
|
},
|
|
24
23
|
}),
|
|
25
|
-
|
|
24
|
+
devScript: "dev",
|
|
25
|
+
deployScript: "deploy",
|
|
26
|
+
previewScript: "preview",
|
|
26
27
|
};
|
|
27
28
|
export default config;
|