create-cloudflare 0.0.0-a64aa1b94 → 0.0.0-a67cdbfc4
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 +28425 -27396
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/templates/common/js/wrangler.toml +6 -0
- package/templates/common/ts/wrangler.toml +6 -0
- 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/next/c3.ts +6 -7
- package/templates/openapi/ts/wrangler.toml +6 -0
- package/templates/pre-existing/c3.ts +2 -2
- package/templates/queues/js/wrangler.toml +6 -0
- package/templates/queues/ts/wrangler.toml +6 -0
- package/templates/qwik/c3.ts +3 -3
- package/templates/qwik/templates/wrangler.toml +1 -0
- package/templates/react/c3.ts +2 -2
- 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/c3.ts +15 -0
- package/templates-experimental/hello-world-assets-only/templates/package.json +13 -0
- package/templates-experimental/hello-world-assets-only/templates/public/index.html +11 -0
- package/templates-experimental/hello-world-assets-only/templates/wrangler.toml +10 -0
- package/templates-experimental/hello-world-durable-object-with-assets/c3.ts +23 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/.editorconfig +12 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/.prettierrc +6 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/__dot__gitignore +172 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/package.json +13 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/public/index.html +19 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/src/index.js +69 -0
- package/templates-experimental/hello-world-durable-object-with-assets/js/wrangler.toml +24 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/.editorconfig +12 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/.prettierrc +6 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/__dot__gitignore +172 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/package.json +15 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/public/index.html +19 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/src/index.ts +66 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/tsconfig.json +101 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/worker-configuration.d.ts +5 -0
- package/templates-experimental/hello-world-durable-object-with-assets/ts/wrangler.toml +24 -0
- package/templates-experimental/hello-world-with-assets/c3.ts +2 -2
- package/templates-experimental/hello-world-with-assets/js/public/index.html +13 -1
- package/templates-experimental/hello-world-with-assets/js/src/index.js +9 -1
- package/templates-experimental/hello-world-with-assets/js/test/index.spec.js +34 -13
- package/templates-experimental/hello-world-with-assets/js/wrangler.toml +7 -1
- package/templates-experimental/hello-world-with-assets/py/public/index.html +14 -2
- package/templates-experimental/hello-world-with-assets/py/src/entry.py +7 -2
- package/templates-experimental/hello-world-with-assets/py/wrangler.toml +7 -1
- package/templates-experimental/hello-world-with-assets/ts/public/index.html +13 -1
- package/templates-experimental/hello-world-with-assets/ts/src/index.ts +10 -2
- package/templates-experimental/hello-world-with-assets/ts/test/index.spec.ts +34 -18
- 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/c3.ts +1 -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
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
1
|
+
import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
2
2
|
import { describe, it, expect } from 'vitest';
|
|
3
3
|
import worker from '../src';
|
|
4
4
|
|
|
5
|
-
describe('Hello World worker', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
describe('Hello World user worker', () => {
|
|
6
|
+
describe('request for /message', () => {
|
|
7
|
+
it('/ responds with "Hello, World!" (unit style)', async () => {
|
|
8
|
+
const request = new Request('http://example.com/message');
|
|
9
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
10
|
+
const ctx = createExecutionContext();
|
|
11
|
+
const response = await worker.fetch(request, env, ctx);
|
|
12
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
13
|
+
await waitOnExecutionContext(ctx);
|
|
14
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
|
+
const request = new Request('http://example.com/message');
|
|
19
|
+
const response = await SELF.fetch(request, env, ctx);
|
|
20
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
|
+
});
|
|
14
22
|
});
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
describe('request for /random', () => {
|
|
25
|
+
it('/ responds with a random UUID (unit style)', async () => {
|
|
26
|
+
const request = new Request('http://example.com/random');
|
|
27
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
28
|
+
const ctx = createExecutionContext();
|
|
29
|
+
const response = await worker.fetch(request, env, ctx);
|
|
30
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
31
|
+
await waitOnExecutionContext(ctx);
|
|
32
|
+
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}/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('responds with a random UUID (integration style)', async () => {
|
|
36
|
+
const request = new Request('http://example.com/random');
|
|
37
|
+
const response = await SELF.fetch(request, env, ctx);
|
|
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
|
+
});
|
|
19
40
|
});
|
|
20
41
|
});
|
|
@@ -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
|
|
@@ -7,13 +7,25 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<h1 id="heading"></h1>
|
|
10
|
+
<button id="button">Fetch a random UUID</button>
|
|
11
|
+
<div id="random"></div>
|
|
10
12
|
<script>
|
|
11
|
-
fetch(
|
|
13
|
+
fetch('/message')
|
|
12
14
|
.then((resp) => resp.text())
|
|
13
15
|
.then((text) => {
|
|
14
|
-
const h1 = document.getElementById(
|
|
16
|
+
const h1 = document.getElementById('heading');
|
|
15
17
|
h1.textContent = text;
|
|
16
18
|
});
|
|
19
|
+
|
|
20
|
+
const button = document.getElementById("button");
|
|
21
|
+
button.addEventListener("click", () => {
|
|
22
|
+
fetch('/random')
|
|
23
|
+
.then((resp) => resp.text())
|
|
24
|
+
.then((text) => {
|
|
25
|
+
const random = document.getElementById('random');
|
|
26
|
+
random.textContent = text;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
17
29
|
</script>
|
|
18
30
|
</body>
|
|
19
31
|
</html>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
from js import Response
|
|
1
|
+
from js import Response, URL, crypto
|
|
2
2
|
|
|
3
3
|
async def on_fetch(request, env):
|
|
4
|
-
|
|
4
|
+
url = URL.new(request.url)
|
|
5
|
+
if url.pathname == '/message':
|
|
6
|
+
return Response.new('Hello, World!')
|
|
7
|
+
if url.pathname == '/random':
|
|
8
|
+
return Response.new(crypto.randomUUID())
|
|
9
|
+
return Response.new('Not Found', {'status': 404})
|
|
@@ -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
|
|
@@ -7,13 +7,25 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<h1 id="heading"></h1>
|
|
10
|
+
<button id="button">Fetch a random UUID</button>
|
|
11
|
+
<div id="random"></div>
|
|
10
12
|
<script>
|
|
11
|
-
fetch('/
|
|
13
|
+
fetch('/message')
|
|
12
14
|
.then((resp) => resp.text())
|
|
13
15
|
.then((text) => {
|
|
14
16
|
const h1 = document.getElementById('heading');
|
|
15
17
|
h1.textContent = text;
|
|
16
18
|
});
|
|
19
|
+
|
|
20
|
+
const button = document.getElementById("button");
|
|
21
|
+
button.addEventListener("click", () => {
|
|
22
|
+
fetch('/random')
|
|
23
|
+
.then((resp) => resp.text())
|
|
24
|
+
.then((text) => {
|
|
25
|
+
const random = document.getElementById('random');
|
|
26
|
+
random.textContent = text;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
17
29
|
</script>
|
|
18
30
|
</body>
|
|
19
31
|
</html>
|
|
@@ -12,7 +12,15 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export default {
|
|
15
|
-
async fetch(
|
|
16
|
-
|
|
15
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
16
|
+
const url = new URL(request.url);
|
|
17
|
+
switch (url.pathname) {
|
|
18
|
+
case '/message':
|
|
19
|
+
return new Response('Hello, World!');
|
|
20
|
+
case '/random':
|
|
21
|
+
return new Response(crypto.randomUUID());
|
|
22
|
+
default:
|
|
23
|
+
return new Response('Not Found', { status: 404 });
|
|
24
|
+
}
|
|
17
25
|
},
|
|
18
26
|
} satisfies ExportedHandler<Env>;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
1
|
+
import { env, ctx, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
|
3
2
|
import { describe, it, expect } from 'vitest';
|
|
4
|
-
import worker from '../src
|
|
3
|
+
import worker from '../src';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
describe('Hello World user worker', () => {
|
|
6
|
+
describe('request for /message', () => {
|
|
7
|
+
it('/ responds with "Hello, World!" (unit style)', async () => {
|
|
8
|
+
const request = new Request('http://example.com/message');
|
|
9
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
10
|
+
const ctx = createExecutionContext();
|
|
11
|
+
const response = await worker.fetch(request, env, ctx);
|
|
12
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
13
|
+
await waitOnExecutionContext(ctx);
|
|
14
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
15
|
+
});
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const response = await worker.fetch(request, env, ctx);
|
|
16
|
-
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
17
|
-
await waitOnExecutionContext(ctx);
|
|
18
|
-
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
17
|
+
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
|
+
const request = new Request('http://example.com/message');
|
|
19
|
+
const response = await SELF.fetch(request, env, ctx);
|
|
20
|
+
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
|
+
});
|
|
19
22
|
});
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
describe('request for /random', () => {
|
|
25
|
+
it('/ responds with a random UUID (unit style)', async () => {
|
|
26
|
+
const request = new Request('http://example.com/random');
|
|
27
|
+
// Create an empty context to pass to `worker.fetch()`.
|
|
28
|
+
const ctx = createExecutionContext();
|
|
29
|
+
const response = await worker.fetch(request, env, ctx);
|
|
30
|
+
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
31
|
+
await waitOnExecutionContext(ctx);
|
|
32
|
+
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}/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('responds with a random UUID (integration style)', async () => {
|
|
36
|
+
const request = new Request('http://example.com/random');
|
|
37
|
+
const response = await SELF.fetch(request, env, ctx);
|
|
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
|
+
});
|
|
24
40
|
});
|
|
25
41
|
});
|
|
@@ -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;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.js
|
|
7
|
+
.yarn/install-state.gz
|
|
8
|
+
|
|
9
|
+
# testing
|
|
10
|
+
/coverage
|
|
11
|
+
|
|
12
|
+
# next.js
|
|
13
|
+
/.next/
|
|
14
|
+
/out/
|
|
15
|
+
|
|
16
|
+
# production
|
|
17
|
+
/build
|
|
18
|
+
|
|
19
|
+
# misc
|
|
20
|
+
.DS_Store
|
|
21
|
+
*.pem
|
|
22
|
+
|
|
23
|
+
# debug
|
|
24
|
+
npm-debug.log*
|
|
25
|
+
yarn-debug.log*
|
|
26
|
+
yarn-error.log*
|
|
27
|
+
|
|
28
|
+
# local env files
|
|
29
|
+
.env*.local
|
|
30
|
+
|
|
31
|
+
# vercel
|
|
32
|
+
.vercel
|
|
33
|
+
|
|
34
|
+
# typescript
|
|
35
|
+
*.tsbuildinfo
|
|
36
|
+
next-env.d.ts
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Cloudflare related
|
|
40
|
+
/.save.next
|
|
41
|
+
/.worker-next
|
|
42
|
+
/.wrangler
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
2
|
+
name = "<app-name>"
|
|
3
|
+
main = ".worker-next/index.mjs"
|
|
4
|
+
|
|
5
|
+
compatibility_date = "2024-09-26"
|
|
6
|
+
compatibility_flags = ["nodejs_compat"]
|
|
7
|
+
|
|
8
|
+
# Minification helps to keep the Worker bundle size down and improve start up time.
|
|
9
|
+
minify = true
|
|
10
|
+
|
|
11
|
+
# Use the new Workers + Assets to host the static frontend files
|
|
12
|
+
assets = { directory = ".worker-next/assets", binding = "ASSETS" }
|
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
main = "./dist/worker/index.js"
|
|
5
|
-
|
|
5
|
+
assets = { directory = "./dist/public", 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
|
|
@@ -13,7 +13,7 @@ import type { C3Context } from "types";
|
|
|
13
13
|
const { npm, npx } = detectPackageManager();
|
|
14
14
|
|
|
15
15
|
const generate = async (ctx: C3Context) => {
|
|
16
|
-
await runFrameworkGenerator(ctx, ["
|
|
16
|
+
await runFrameworkGenerator(ctx, ["playground", ctx.project.name]);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const configure = async (ctx: C3Context) => {
|
|
@@ -3,4 +3,10 @@ name = "<TBD>"
|
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
compatibility_flags = ["nodejs_compat"]
|
|
5
5
|
main = "./dist/_worker.js"
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./dist", binding = "ASSET" }
|
|
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
|
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
main = "./build/worker/index.js"
|
|
5
|
-
|
|
5
|
+
assets = { directory = "./build/client" }
|
|
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"]
|
|
5
5
|
main = "./dist/worker/index.js"
|
|
6
|
-
|
|
6
|
+
assets = { directory = "./dist/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
|
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
main = ".svelte-kit/cloudflare/_worker.js"
|
|
5
|
-
|
|
5
|
+
assets = { directory = ".svelte-kit/cloudflare", 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
|
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
main = ".svelte-kit/cloudflare/_worker.js"
|
|
5
|
-
|
|
5
|
+
assets = { directory = ".svelte-kit/cloudflare", 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
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copy the files over so that they can be uploaded by the pages publish command.
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { client, cloudflare, ssr, worker } from "./paths.mjs";
|
|
5
|
-
|
|
6
|
-
fs.cpSync(client, cloudflare, { recursive: true });
|
|
7
|
-
fs.cpSync(ssr, worker, { recursive: true });
|
|
8
|
-
|
|
9
|
-
fs.renameSync(join(worker, "server.mjs"), join(worker, "index.js"));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
export const root = path.resolve(dirname, "..");
|
|
6
|
-
export const client = path.resolve(root, "dist/browser");
|
|
7
|
-
export const ssr = path.resolve(root, "dist/server");
|
|
8
|
-
export const cloudflare = path.resolve(root, "dist/cloudflare");
|
|
9
|
-
export const worker = path.resolve(cloudflare, "_worker.js");
|