create-cloudflare 0.0.0-7d7f19a2c → 0.0.0-7dbd0c82a
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 +417 -324
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/templates/common/js/wrangler.toml +6 -0
- package/templates/common/ts/wrangler.toml +6 -0
- package/templates/docusaurus/c3.ts +2 -1
- package/templates/hello-world/js/wrangler.toml +6 -0
- package/templates/hello-world/py/wrangler.toml +6 -0
- package/templates/hello-world/ts/wrangler.toml +6 -0
- package/templates/hello-world-durable-object/js/wrangler.toml +6 -0
- package/templates/hello-world-durable-object/ts/src/index.ts +0 -21
- package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +3 -4
- package/templates/hello-world-durable-object/ts/wrangler.toml +6 -0
- package/templates/hono/templates/wrangler.toml +6 -0
- package/templates/nuxt/templates/wrangler.toml +1 -0
- package/templates/openapi/ts/wrangler.toml +6 -0
- package/templates/queues/js/wrangler.toml +6 -0
- package/templates/queues/ts/wrangler.toml +6 -0
- package/templates/scheduled/js/wrangler.toml +6 -0
- package/templates/scheduled/ts/wrangler.toml +6 -0
- package/templates-experimental/angular/c3.ts +6 -10
- package/templates-experimental/angular/templates/tools/alter-polyfills.mjs +12 -7
- package/templates-experimental/angular/templates/wrangler.toml +8 -2
- package/templates-experimental/astro/templates/wrangler.toml +7 -1
- package/templates-experimental/docusaurus/templates/wrangler.toml +7 -1
- package/templates-experimental/gatsby/templates/wrangler.toml +7 -1
- package/templates-experimental/hello-world-assets-only/templates/wrangler.toml +7 -1
- package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.toml +6 -1
- package/templates-experimental/hello-world-durable-object-with-assets/ts/src/index.ts +0 -20
- package/templates-experimental/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +3 -4
- package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.toml +6 -1
- package/templates-experimental/hello-world-with-assets/js/test/index.spec.js +3 -3
- package/templates-experimental/hello-world-with-assets/js/wrangler.toml +7 -1
- package/templates-experimental/hello-world-with-assets/py/wrangler.toml +7 -1
- package/templates-experimental/hello-world-with-assets/ts/test/index.spec.ts +5 -5
- package/templates-experimental/hello-world-with-assets/ts/wrangler.toml +7 -1
- package/templates-experimental/hono/c3.ts +43 -0
- package/templates-experimental/hono/templates/public/index.html +19 -0
- package/templates-experimental/hono/templates/src/index.ts +9 -0
- package/templates-experimental/hono/templates/worker-configuration.d.ts +4 -0
- package/templates-experimental/hono/templates/wrangler.toml +5 -0
- package/templates-experimental/next/c3.ts +52 -0
- package/templates-experimental/next/templates/__dot__gitignore +42 -0
- package/templates-experimental/next/templates/env.d.ts +5 -0
- package/templates-experimental/next/templates/wrangler.toml +12 -0
- package/templates-experimental/nuxt/templates/wrangler.toml +7 -1
- package/templates-experimental/qwik/templates/wrangler.toml +7 -1
- package/templates-experimental/remix/templates/wrangler.toml +7 -1
- package/templates-experimental/solid/templates/wrangler.toml +7 -1
- package/templates-experimental/svelte/js/wrangler.toml +7 -1
- package/templates-experimental/svelte/ts/wrangler.toml +7 -1
- package/templates-experimental/angular/templates/src/.assetsignore +0 -4
- package/templates-experimental/angular/templates/tools/copy-files.mjs +0 -9
- package/templates-experimental/angular/templates/tools/paths.mjs +0 -9
|
@@ -4,6 +4,12 @@ main = "src/index.ts"
|
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
compatibility_flags = ["nodejs_compat"]
|
|
6
6
|
|
|
7
|
+
# Workers Logs
|
|
8
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
9
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
10
|
+
[observability]
|
|
11
|
+
enabled = true
|
|
12
|
+
|
|
7
13
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
8
14
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
9
15
|
# rather than the end user may result in better performance.
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.js"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -13,27 +13,6 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
13
13
|
* Learn more at https://developers.cloudflare.com/durable-objects
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Associate bindings declared in wrangler.toml with the TypeScript type system
|
|
19
|
-
*/
|
|
20
|
-
export interface Env {
|
|
21
|
-
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
|
22
|
-
// MY_KV_NAMESPACE: KVNamespace;
|
|
23
|
-
//
|
|
24
|
-
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
|
25
|
-
MY_DURABLE_OBJECT: DurableObjectNamespace<MyDurableObject>;
|
|
26
|
-
//
|
|
27
|
-
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
28
|
-
// MY_BUCKET: R2Bucket;
|
|
29
|
-
//
|
|
30
|
-
// Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
|
|
31
|
-
// MY_SERVICE: Fetcher;
|
|
32
|
-
//
|
|
33
|
-
// Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/
|
|
34
|
-
// MY_QUEUE: Queue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
16
|
/** A Durable Object's behavior is defined in an exported Javascript class */
|
|
38
17
|
export class MyDurableObject extends DurableObject {
|
|
39
18
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// Generated by Wrangler
|
|
2
|
-
|
|
1
|
+
// Generated by Wrangler by running `wrangler types`
|
|
2
|
+
|
|
3
3
|
interface Env {
|
|
4
|
-
MY_DURABLE_OBJECT: DurableObjectNamespace
|
|
4
|
+
MY_DURABLE_OBJECT: DurableObjectNamespace<import("./src/index").MyDurableObject>;
|
|
5
5
|
}
|
|
6
|
-
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.js"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -3,6 +3,12 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
11
|
+
|
|
6
12
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
13
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
8
14
|
# rather than the end user may result in better performance.
|
|
@@ -9,6 +9,12 @@ compatibility_date = "<TBD>"
|
|
|
9
9
|
[triggers]
|
|
10
10
|
crons = ["* * * * *"] # * * * * * = run every minute
|
|
11
11
|
|
|
12
|
+
# Workers Logs
|
|
13
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
14
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
15
|
+
[observability]
|
|
16
|
+
enabled = true
|
|
17
|
+
|
|
12
18
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
13
19
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
14
20
|
# rather than the end user may result in better performance.
|
|
@@ -9,6 +9,12 @@ compatibility_date = "<TBD>"
|
|
|
9
9
|
[triggers]
|
|
10
10
|
crons = ["* * * * *"] # * * * * * = run every minute
|
|
11
11
|
|
|
12
|
+
# Workers Logs
|
|
13
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
14
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
15
|
+
[observability]
|
|
16
|
+
enabled = true
|
|
17
|
+
|
|
12
18
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
13
19
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
|
14
20
|
# rather than the end user may result in better performance.
|
|
@@ -23,14 +23,11 @@ const configure = async (ctx: C3Context) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
async function installCFWorker() {
|
|
26
|
-
await installPackages(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
32
|
-
},
|
|
33
|
-
);
|
|
26
|
+
await installPackages(["@cloudflare/workers-types", "wrangler"], {
|
|
27
|
+
dev: true,
|
|
28
|
+
startText: "Installing adapter dependencies",
|
|
29
|
+
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
30
|
+
});
|
|
34
31
|
}
|
|
35
32
|
async function updateAppCode() {
|
|
36
33
|
const s = spinner();
|
|
@@ -93,8 +90,7 @@ const config: TemplateConfig = {
|
|
|
93
90
|
scripts: {
|
|
94
91
|
start: `${npm} run build && wrangler dev`,
|
|
95
92
|
build: `ng build && ${npm} run process`,
|
|
96
|
-
process:
|
|
97
|
-
"node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
|
|
93
|
+
process: "node ./tools/alter-polyfills.mjs",
|
|
98
94
|
deploy: `${npm} run build && wrangler deploy`,
|
|
99
95
|
},
|
|
100
96
|
}),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { EOL } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Split by lines and comment the banner
|
|
@@ -10,15 +12,18 @@ import { worker } from "./paths.mjs";
|
|
|
10
12
|
* globalThis['require'] ??= createRequire(import.meta.url);
|
|
11
13
|
* ```
|
|
12
14
|
*/
|
|
13
|
-
const serverPolyfillsFile = join(
|
|
15
|
+
const serverPolyfillsFile = join(
|
|
16
|
+
dirname,
|
|
17
|
+
"../dist/server/polyfills.server.mjs"
|
|
18
|
+
);
|
|
14
19
|
const serverPolyfillsData = fs
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
.readFileSync(serverPolyfillsFile, "utf8")
|
|
21
|
+
.split(/\r?\n/);
|
|
17
22
|
|
|
18
23
|
for (let index = 0; index < 2; index++) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
if (serverPolyfillsData[index].includes("createRequire")) {
|
|
25
|
+
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
// Add needed polyfills
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
main = "./dist/
|
|
5
|
-
|
|
4
|
+
main = "./dist/server/server.mjs"
|
|
5
|
+
assets = { directory = "./dist/browser", binding = "ASSETS" }
|
|
6
|
+
|
|
7
|
+
# Workers Logs
|
|
8
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
9
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
10
|
+
[observability]
|
|
11
|
+
enabled = true
|
|
@@ -3,4 +3,10 @@ name = "<TBD>"
|
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
compatibility_flags = ["nodejs_compat_v2"]
|
|
5
5
|
main = "./dist/_worker.js"
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./dist", binding = "ASSETS" }
|
|
7
|
+
|
|
8
|
+
# Workers Logs
|
|
9
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
10
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
11
|
+
[observability]
|
|
12
|
+
enabled = true
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
|
|
4
|
+
assets = { directory = "./build" }
|
|
5
|
+
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
|
|
4
|
+
assets = { directory = "./public" }
|
|
5
|
+
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
|
|
4
|
+
assets = { directory = "./public" }
|
|
5
|
+
|
|
6
|
+
# Workers Logs
|
|
7
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
8
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
9
|
+
[observability]
|
|
10
|
+
enabled = true
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
main = "src/index.js"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
|
-
|
|
5
|
+
assets = { directory = "./public", binding = "ASSETS" }
|
|
6
6
|
|
|
7
7
|
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
8
8
|
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
@@ -17,3 +17,8 @@ class_name = "MyDurableObject"
|
|
|
17
17
|
tag = "v1"
|
|
18
18
|
new_classes = ["MyDurableObject"]
|
|
19
19
|
|
|
20
|
+
# Workers Logs
|
|
21
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
22
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
23
|
+
[observability]
|
|
24
|
+
enabled = true
|
|
@@ -14,26 +14,6 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Associate bindings declared in wrangler.toml with the TypeScript type system
|
|
19
|
-
*/
|
|
20
|
-
export interface Env {
|
|
21
|
-
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
|
22
|
-
// MY_KV_NAMESPACE: KVNamespace;
|
|
23
|
-
//
|
|
24
|
-
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
|
25
|
-
MY_DURABLE_OBJECT: DurableObjectNamespace<MyDurableObject>;
|
|
26
|
-
//
|
|
27
|
-
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
28
|
-
// MY_BUCKET: R2Bucket;
|
|
29
|
-
//
|
|
30
|
-
// Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
|
|
31
|
-
// MY_SERVICE: Fetcher;
|
|
32
|
-
//
|
|
33
|
-
// Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/
|
|
34
|
-
// MY_QUEUE: Queue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
17
|
/** A Durable Object's behavior is defined in an exported Javascript class */
|
|
38
18
|
export class MyDurableObject extends DurableObject {
|
|
39
19
|
/**
|
package/templates-experimental/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// Generated by Wrangler
|
|
2
|
-
|
|
1
|
+
// Generated by Wrangler by running `wrangler types`
|
|
2
|
+
|
|
3
3
|
interface Env {
|
|
4
|
-
MY_DURABLE_OBJECT: DurableObjectNamespace
|
|
4
|
+
MY_DURABLE_OBJECT: DurableObjectNamespace<import("./src/index").MyDurableObject>;
|
|
5
5
|
}
|
|
6
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
|
-
|
|
5
|
+
assets = { directory = "./public", binding = "ASSETS" }
|
|
6
6
|
|
|
7
7
|
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
8
8
|
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
@@ -17,3 +17,8 @@ class_name = "MyDurableObject"
|
|
|
17
17
|
tag = "v1"
|
|
18
18
|
new_classes = ["MyDurableObject"]
|
|
19
19
|
|
|
20
|
+
# Workers Logs
|
|
21
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
22
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
23
|
+
[observability]
|
|
24
|
+
enabled = true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { env,
|
|
1
|
+
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
2
2
|
import { describe, it, expect } from 'vitest';
|
|
3
3
|
import worker from '../src';
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ describe('Hello World user worker', () => {
|
|
|
16
16
|
|
|
17
17
|
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
18
|
const request = new Request('http://example.com/message');
|
|
19
|
-
const response = await SELF.fetch(request
|
|
19
|
+
const response = await SELF.fetch(request);
|
|
20
20
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -34,7 +34,7 @@ describe('Hello World user worker', () => {
|
|
|
34
34
|
|
|
35
35
|
it('responds with a random UUID (integration style)', async () => {
|
|
36
36
|
const request = new Request('http://example.com/random');
|
|
37
|
-
const response = await SELF.fetch(request
|
|
37
|
+
const response = await SELF.fetch(request);
|
|
38
38
|
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -3,4 +3,10 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.js"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
compatibility_flags = ["nodejs_compat"]
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./public", binding = "ASSETS" }
|
|
7
|
+
|
|
8
|
+
# Workers Logs
|
|
9
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
10
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
11
|
+
[observability]
|
|
12
|
+
enabled = true
|
|
@@ -3,4 +3,10 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/entry.py"
|
|
4
4
|
compatibility_flags = ["python_workers"]
|
|
5
5
|
compatibility_date = "<TBD>"
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./public", binding = "ASSETS" }
|
|
7
|
+
|
|
8
|
+
# Workers Logs
|
|
9
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
10
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
11
|
+
[observability]
|
|
12
|
+
enabled = true
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { env,
|
|
1
|
+
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
2
2
|
import { describe, it, expect } from 'vitest';
|
|
3
3
|
import worker from '../src';
|
|
4
4
|
|
|
5
5
|
describe('Hello World user worker', () => {
|
|
6
6
|
describe('request for /message', () => {
|
|
7
7
|
it('/ responds with "Hello, World!" (unit style)', async () => {
|
|
8
|
-
const request = new Request('http://example.com/message');
|
|
8
|
+
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/message');
|
|
9
9
|
// Create an empty context to pass to `worker.fetch()`.
|
|
10
10
|
const ctx = createExecutionContext();
|
|
11
11
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -16,14 +16,14 @@ describe('Hello World user worker', () => {
|
|
|
16
16
|
|
|
17
17
|
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
18
|
const request = new Request('http://example.com/message');
|
|
19
|
-
const response = await SELF.fetch(request
|
|
19
|
+
const response = await SELF.fetch(request);
|
|
20
20
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
describe('request for /random', () => {
|
|
25
25
|
it('/ responds with a random UUID (unit style)', async () => {
|
|
26
|
-
const request = new Request('http://example.com/random');
|
|
26
|
+
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/random');
|
|
27
27
|
// Create an empty context to pass to `worker.fetch()`.
|
|
28
28
|
const ctx = createExecutionContext();
|
|
29
29
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -34,7 +34,7 @@ describe('Hello World user worker', () => {
|
|
|
34
34
|
|
|
35
35
|
it('responds with a random UUID (integration style)', async () => {
|
|
36
36
|
const request = new Request('http://example.com/random');
|
|
37
|
-
const response = await SELF.fetch(request
|
|
37
|
+
const response = await SELF.fetch(request);
|
|
38
38
|
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -3,4 +3,10 @@ name = "<TBD>"
|
|
|
3
3
|
main = "src/index.ts"
|
|
4
4
|
compatibility_date = "<TBD>"
|
|
5
5
|
compatibility_flags = ["nodejs_compat"]
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./public", binding = "ASSETS" }
|
|
7
|
+
|
|
8
|
+
# Workers Logs
|
|
9
|
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
10
|
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
|
11
|
+
[observability]
|
|
12
|
+
enabled = true
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { logRaw } from "@cloudflare/cli";
|
|
2
|
+
import { runFrameworkGenerator } from "frameworks/index";
|
|
3
|
+
import { detectPackageManager } from "helpers/packageManagers";
|
|
4
|
+
import type { TemplateConfig } from "../../src/templates";
|
|
5
|
+
import type { C3Context } from "types";
|
|
6
|
+
|
|
7
|
+
const generate = async (ctx: C3Context) => {
|
|
8
|
+
const { name: pm } = detectPackageManager();
|
|
9
|
+
|
|
10
|
+
await runFrameworkGenerator(ctx, [
|
|
11
|
+
ctx.project.name,
|
|
12
|
+
"--template",
|
|
13
|
+
"cloudflare-workers",
|
|
14
|
+
"--install",
|
|
15
|
+
"--pm",
|
|
16
|
+
pm,
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
logRaw(""); // newline
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const config: TemplateConfig = {
|
|
23
|
+
configVersion: 1,
|
|
24
|
+
id: "hono",
|
|
25
|
+
frameworkCli: "create-hono",
|
|
26
|
+
displayName: "Hono",
|
|
27
|
+
copyFiles: {
|
|
28
|
+
path: "./templates",
|
|
29
|
+
},
|
|
30
|
+
platform: "workers",
|
|
31
|
+
path: "templates-experimental/hono",
|
|
32
|
+
generate,
|
|
33
|
+
transformPackageJson: async () => ({
|
|
34
|
+
scripts: {
|
|
35
|
+
dev: "wrangler dev",
|
|
36
|
+
deploy: "wrangler deploy --minify",
|
|
37
|
+
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
devScript: "dev",
|
|
41
|
+
deployScript: "deploy",
|
|
42
|
+
};
|
|
43
|
+
export default config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Hello, World!</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<h1 id="heading"></h1>
|
|
10
|
+
<script>
|
|
11
|
+
fetch('/message')
|
|
12
|
+
.then((resp) => resp.text())
|
|
13
|
+
.then((text) => {
|
|
14
|
+
const h1 = document.getElementById('heading');
|
|
15
|
+
h1.textContent = text;
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { brandColor, dim } from "@cloudflare/cli/colors";
|
|
2
|
+
import { runFrameworkGenerator } from "frameworks/index";
|
|
3
|
+
import { installPackages } from "helpers/packages";
|
|
4
|
+
import type { TemplateConfig } from "../../src/templates";
|
|
5
|
+
import type { C3Context } from "types";
|
|
6
|
+
|
|
7
|
+
const generate = async (ctx: C3Context) => {
|
|
8
|
+
await runFrameworkGenerator(ctx, [
|
|
9
|
+
ctx.project.name,
|
|
10
|
+
"--ts",
|
|
11
|
+
"--tailwind",
|
|
12
|
+
"--eslint",
|
|
13
|
+
"--app",
|
|
14
|
+
"--import-alias",
|
|
15
|
+
"@/*",
|
|
16
|
+
"--src-dir",
|
|
17
|
+
]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const configure = async () => {
|
|
21
|
+
const packages = ["@opennextjs/cloudflare", "@cloudflare/workers-types"];
|
|
22
|
+
await installPackages(packages, {
|
|
23
|
+
dev: true,
|
|
24
|
+
startText: "Adding the Cloudflare adapter",
|
|
25
|
+
doneText: `${brandColor(`installed`)} ${dim(packages.join(", "))}`,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
configVersion: 1,
|
|
31
|
+
id: "next",
|
|
32
|
+
frameworkCli: "create-next-app",
|
|
33
|
+
platform: "workers",
|
|
34
|
+
displayName: "Next (using Node.js compat + Workers Assets)",
|
|
35
|
+
path: "templates-experimental/next",
|
|
36
|
+
copyFiles: {
|
|
37
|
+
path: "./templates",
|
|
38
|
+
},
|
|
39
|
+
generate,
|
|
40
|
+
configure,
|
|
41
|
+
transformPackageJson: async () => ({
|
|
42
|
+
scripts: {
|
|
43
|
+
deploy: `cloudflare && wrangler deploy`,
|
|
44
|
+
preview: `cloudflare && wrangler dev`,
|
|
45
|
+
"cf-typegen": `wrangler types --env-interface CloudflareEnv env.d.ts`,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
devScript: "dev",
|
|
49
|
+
previewScript: "preview",
|
|
50
|
+
deployScript: "deploy",
|
|
51
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
52
|
+
} as TemplateConfig;
|