create-cloudflare 2.64.8 → 2.65.0
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 +6821 -1554
- package/package.json +25 -28
- package/templates/analog/c3.ts +4 -4
- package/templates/angular/pages/c3.ts +2 -2
- package/templates/angular/workers/c3.ts +2 -2
- package/templates/astro/pages/c3.ts +3 -3
- package/templates/astro/workers/c3.ts +1 -1
- package/templates/hello-world/js/package.json +2 -2
- package/templates/hello-world/js/src/index.js +1 -1
- package/templates/hello-world/js/test/index.spec.js +13 -8
- package/templates/hello-world/js/vitest.config.js +2 -2
- package/templates/hello-world/py/pyproject.toml +2 -6
- package/templates/hello-world/ts/src/index.ts +1 -1
- package/templates/hello-world/ts/test/env.d.ts +1 -1
- package/templates/hello-world/ts/test/index.spec.ts +13 -8
- package/templates/hello-world/ts/vitest.config.mts +2 -2
- package/templates/hello-world-with-assets/js/test/index.spec.js +23 -14
- package/templates/hello-world-with-assets/ts/test/env.d.ts +1 -1
- package/templates/hello-world-with-assets/ts/test/index.spec.ts +27 -14
- package/templates/nuxt/pages/c3.ts +6 -6
- package/templates/nuxt/workers/c3.ts +6 -6
- package/templates/pre-existing/c3.ts +5 -5
- package/templates/qwik/pages/c3.ts +8 -2
- package/templates/qwik/workers/c3.ts +10 -7
- package/templates/react/pages/c3.ts +1 -1
- package/templates/react/workers/c3.ts +6 -6
- package/templates/solid/c3.ts +2 -2
- package/templates/svelte/pages/c3.ts +6 -6
- package/templates/svelte/workers/c3.ts +6 -6
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.65.0",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
7
|
-
"workers",
|
|
8
7
|
"cloudflare workers",
|
|
9
8
|
"serverless",
|
|
10
|
-
"serverless application"
|
|
9
|
+
"serverless application",
|
|
10
|
+
"workers"
|
|
11
11
|
],
|
|
12
|
+
"license": "MIT OR Apache-2.0",
|
|
13
|
+
"author": "wrangler@cloudflare.com",
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "https://github.com/cloudflare/workers-sdk.git",
|
|
15
17
|
"directory": "packages/create-cloudflare"
|
|
16
18
|
},
|
|
17
|
-
"license": "MIT OR Apache-2.0",
|
|
18
|
-
"author": "wrangler@cloudflare.com",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": "./dist/cli.js"
|
|
21
|
-
},
|
|
22
|
-
"main": "./dist/cli.js",
|
|
23
19
|
"bin": "./dist/cli.js",
|
|
24
20
|
"files": [
|
|
25
21
|
"dist",
|
|
26
22
|
"templates",
|
|
27
23
|
"templates-experimental"
|
|
28
24
|
],
|
|
25
|
+
"main": "./dist/cli.js",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./dist/cli.js"
|
|
28
|
+
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/parser": "^7.21.3",
|
|
31
31
|
"@babel/types": "^7.21.4",
|
|
32
32
|
"@clack/prompts": "^0.6.3",
|
|
33
|
-
"@cloudflare/workers-types": "^4.
|
|
33
|
+
"@cloudflare/workers-types": "^4.20260317.1",
|
|
34
34
|
"@types/command-exists": "^1.2.0",
|
|
35
35
|
"@types/cross-spawn": "^6.0.2",
|
|
36
36
|
"@types/deepmerge": "^2.2.0",
|
|
37
37
|
"@types/degit": "^2.8.6",
|
|
38
38
|
"@types/dns2": "^2.0.3",
|
|
39
39
|
"@types/esprima": "^4.0.3",
|
|
40
|
-
"@types/node": "^
|
|
40
|
+
"@types/node": "^22.10.1",
|
|
41
41
|
"@types/semver": "^7.5.1",
|
|
42
42
|
"@types/which-pm-runs": "^1.0.0",
|
|
43
43
|
"@types/yargs": "^17.0.22",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"dns2": "^2.1.0",
|
|
50
50
|
"dotenv": "^16.0.0",
|
|
51
51
|
"esbuild": "0.27.3",
|
|
52
|
-
"eslint": "^9.39.1",
|
|
53
52
|
"execa": "^7.1.1",
|
|
54
53
|
"exit-hook": "2.2.1",
|
|
55
54
|
"get-port": "^7.1.0",
|
|
@@ -64,41 +63,39 @@
|
|
|
64
63
|
"smol-toml": "^1.5.2",
|
|
65
64
|
"tree-kill": "^1.2.2",
|
|
66
65
|
"typescript": "~5.8.3",
|
|
67
|
-
"undici": "7.
|
|
68
|
-
"vite": "^
|
|
66
|
+
"undici": "7.24.4",
|
|
67
|
+
"vite": "^8.0.0",
|
|
69
68
|
"vite-tsconfig-paths": "^4.0.8",
|
|
70
|
-
"vitest": "
|
|
69
|
+
"vitest": "4.1.0",
|
|
71
70
|
"which-pm-runs": "^1.1.0",
|
|
72
71
|
"wrap-ansi": "^9.0.0",
|
|
73
72
|
"xdg-app-paths": "^8.3.0",
|
|
74
73
|
"yargs": "^17.7.2",
|
|
75
|
-
"@cloudflare/workers-utils": "0.12.0",
|
|
76
74
|
"@cloudflare/cli": "1.2.1",
|
|
77
|
-
"@cloudflare/
|
|
78
|
-
"@cloudflare/eslint-config-shared": "1.2.1",
|
|
79
|
-
"@cloudflare/vite-plugin": "1.29.0",
|
|
75
|
+
"@cloudflare/vite-plugin": "1.30.1",
|
|
80
76
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
81
|
-
"
|
|
77
|
+
"@cloudflare/workers-utils": "0.13.0",
|
|
78
|
+
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
79
|
+
"wrangler": "4.77.0"
|
|
82
80
|
},
|
|
83
81
|
"engines": {
|
|
84
82
|
"node": ">=18.14.1"
|
|
85
83
|
},
|
|
84
|
+
"volta": {
|
|
85
|
+
"extends": "../../package.json"
|
|
86
|
+
},
|
|
86
87
|
"workers-sdk": {
|
|
87
88
|
"prerelease": true,
|
|
88
89
|
"type": "cli"
|
|
89
90
|
},
|
|
90
|
-
"volta": {
|
|
91
|
-
"extends": "../../package.json"
|
|
92
|
-
},
|
|
93
91
|
"scripts": {
|
|
94
92
|
"build": "node -r esbuild-register scripts/build.ts",
|
|
95
|
-
"dev:codemod": "node -r esbuild-register scripts/codemodDev.ts",
|
|
96
|
-
"check:lint": "eslint . --max-warnings=0 --cache",
|
|
97
93
|
"check:type": "tsc",
|
|
94
|
+
"dev": "node -r esbuild-register scripts/build.ts --watch",
|
|
95
|
+
"dev:codemod": "node -r esbuild-register scripts/codemodDev.ts",
|
|
96
|
+
"test:ci": "vitest run --config ./vitest.config.mts",
|
|
98
97
|
"test:e2e": "vitest run --config ./vitest-e2e.config.mts",
|
|
99
98
|
"test:unit": "vitest run --config ./vitest.config.mts",
|
|
100
|
-
"test:unit:watch": "vitest --config ./vitest.config.mts"
|
|
101
|
-
"dev": "node -r esbuild-register scripts/build.ts --watch",
|
|
102
|
-
"test:ci": "vitest run --config ./vitest.config.mts"
|
|
99
|
+
"test:unit:watch": "vitest --config ./vitest.config.mts"
|
|
103
100
|
}
|
|
104
101
|
}
|
package/templates/analog/c3.ts
CHANGED
|
@@ -39,13 +39,13 @@ const configure = async (ctx: C3Context) => {
|
|
|
39
39
|
// preset: "cloudflare_module"
|
|
40
40
|
b.objectProperty(
|
|
41
41
|
b.identifier("preset"),
|
|
42
|
-
b.stringLiteral("cloudflare_module")
|
|
42
|
+
b.stringLiteral("cloudflare_module")
|
|
43
43
|
),
|
|
44
44
|
b.objectProperty(
|
|
45
45
|
b.identifier("compatibilityDate"),
|
|
46
|
-
b.stringLiteral(compatDate)
|
|
46
|
+
b.stringLiteral(compatDate)
|
|
47
47
|
),
|
|
48
|
-
])
|
|
48
|
+
])
|
|
49
49
|
),
|
|
50
50
|
];
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ const configure = async (ctx: C3Context) => {
|
|
|
54
54
|
} else {
|
|
55
55
|
mergeObjectProperties(
|
|
56
56
|
n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
|
|
57
|
-
presetDef
|
|
57
|
+
presetDef
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -41,7 +41,7 @@ async function updateAppCode() {
|
|
|
41
41
|
"import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
|
|
42
42
|
appConfig.replace(
|
|
43
43
|
"providers: [",
|
|
44
|
-
"providers: [provideHttpClient(withFetch()), "
|
|
44
|
+
"providers: [provideHttpClient(withFetch()), "
|
|
45
45
|
);
|
|
46
46
|
writeFile(resolve(appConfigPath), newAppConfig);
|
|
47
47
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
|
@@ -51,7 +51,7 @@ async function updateAppCode() {
|
|
|
51
51
|
const appRoutes = readFile(resolve(appServerRoutesPath));
|
|
52
52
|
const newAppRoutes = appRoutes.replace(
|
|
53
53
|
"RenderMode.Prerender",
|
|
54
|
-
"RenderMode.Server"
|
|
54
|
+
"RenderMode.Server"
|
|
55
55
|
);
|
|
56
56
|
writeFile(resolve(appServerRoutesPath), newAppRoutes);
|
|
57
57
|
s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
|
|
@@ -41,7 +41,7 @@ async function updateAppCode() {
|
|
|
41
41
|
"import { provideHttpClient, withFetch } from '@angular/common/http';\n" +
|
|
42
42
|
appConfig.replace(
|
|
43
43
|
"providers: [",
|
|
44
|
-
"providers: [provideHttpClient(withFetch()), "
|
|
44
|
+
"providers: [provideHttpClient(withFetch()), "
|
|
45
45
|
);
|
|
46
46
|
writeFile(resolve(appConfigPath), newAppConfig);
|
|
47
47
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
|
@@ -51,7 +51,7 @@ async function updateAppCode() {
|
|
|
51
51
|
const appRoutes = readFile(resolve(appServerRoutesPath));
|
|
52
52
|
const newAppRoutes = appRoutes.replace(
|
|
53
53
|
"RenderMode.Prerender",
|
|
54
|
-
"RenderMode.Server"
|
|
54
|
+
"RenderMode.Server"
|
|
55
55
|
);
|
|
56
56
|
writeFile(resolve(appServerRoutesPath), newAppRoutes);
|
|
57
57
|
s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
|
|
@@ -30,7 +30,7 @@ const configure = async () => {
|
|
|
30
30
|
silent: true,
|
|
31
31
|
startText: "Installing adapter",
|
|
32
32
|
doneText: `${brandColor("installed")} ${dim(
|
|
33
|
-
`via \`${npx} astro add cloudflare
|
|
33
|
+
`via \`${npx} astro add cloudflare\``
|
|
34
34
|
)}`,
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -56,12 +56,12 @@ const configure = async () => {
|
|
|
56
56
|
b.identifier("platformProxy"),
|
|
57
57
|
b.objectExpression([
|
|
58
58
|
b.objectProperty(b.identifier("enabled"), b.booleanLiteral(true)),
|
|
59
|
-
])
|
|
59
|
+
])
|
|
60
60
|
),
|
|
61
61
|
// imageService: "cloudflare",
|
|
62
62
|
b.objectProperty(
|
|
63
63
|
b.identifier("imageService"),
|
|
64
|
-
b.stringLiteral("cloudflare")
|
|
64
|
+
b.stringLiteral("cloudflare")
|
|
65
65
|
),
|
|
66
66
|
]),
|
|
67
67
|
];
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
env,
|
|
3
|
+
createExecutionContext,
|
|
4
|
+
waitOnExecutionContext,
|
|
5
|
+
SELF,
|
|
6
|
+
} from "cloudflare:test";
|
|
7
|
+
import { describe, it, expect } from "vitest";
|
|
8
|
+
import worker from "../src";
|
|
4
9
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
7
|
-
const request = new Request(
|
|
10
|
+
describe("Hello World worker", () => {
|
|
11
|
+
it("responds with Hello World! (unit style)", async () => {
|
|
12
|
+
const request = new Request("http://example.com");
|
|
8
13
|
// Create an empty context to pass to `worker.fetch()`.
|
|
9
14
|
const ctx = createExecutionContext();
|
|
10
15
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -13,8 +18,8 @@ describe('Hello World worker', () => {
|
|
|
13
18
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
14
19
|
});
|
|
15
20
|
|
|
16
|
-
it(
|
|
17
|
-
const response = await SELF.fetch(
|
|
21
|
+
it("responds with Hello World! (integration style)", async () => {
|
|
22
|
+
const response = await SELF.fetch("http://example.com");
|
|
18
23
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
19
24
|
});
|
|
20
25
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineWorkersConfig } from
|
|
1
|
+
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
|
|
2
2
|
|
|
3
3
|
export default defineWorkersConfig({
|
|
4
4
|
test: {
|
|
5
5
|
poolOptions: {
|
|
6
6
|
workers: {
|
|
7
|
-
wrangler: { configPath:
|
|
7
|
+
wrangler: { configPath: "./wrangler.jsonc" },
|
|
8
8
|
},
|
|
9
9
|
},
|
|
10
10
|
},
|
|
@@ -4,11 +4,7 @@ version = "0.1.0"
|
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
|
-
dependencies = [
|
|
8
|
-
"webtypy>=0.1.7",
|
|
9
|
-
]
|
|
7
|
+
dependencies = ["webtypy>=0.1.7"]
|
|
10
8
|
|
|
11
9
|
[dependency-groups]
|
|
12
|
-
dev = [
|
|
13
|
-
"workers-py"
|
|
14
|
-
]
|
|
10
|
+
dev = ["workers-py"]
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
env,
|
|
3
|
+
createExecutionContext,
|
|
4
|
+
waitOnExecutionContext,
|
|
5
|
+
SELF,
|
|
6
|
+
} from "cloudflare:test";
|
|
7
|
+
import { describe, it, expect } from "vitest";
|
|
8
|
+
import worker from "../src/index";
|
|
4
9
|
|
|
5
10
|
// For now, you'll need to do something like this to get a correctly-typed
|
|
6
11
|
// `Request` to pass to `worker.fetch()`.
|
|
7
12
|
const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
|
|
8
13
|
|
|
9
|
-
describe(
|
|
10
|
-
it(
|
|
11
|
-
const request = new IncomingRequest(
|
|
14
|
+
describe("Hello World worker", () => {
|
|
15
|
+
it("responds with Hello World! (unit style)", async () => {
|
|
16
|
+
const request = new IncomingRequest("http://example.com");
|
|
12
17
|
// Create an empty context to pass to `worker.fetch()`.
|
|
13
18
|
const ctx = createExecutionContext();
|
|
14
19
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -17,8 +22,8 @@ describe('Hello World worker', () => {
|
|
|
17
22
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
18
23
|
});
|
|
19
24
|
|
|
20
|
-
it(
|
|
21
|
-
const response = await SELF.fetch(
|
|
25
|
+
it("responds with Hello World! (integration style)", async () => {
|
|
26
|
+
const response = await SELF.fetch("https://example.com");
|
|
22
27
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
|
23
28
|
});
|
|
24
29
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineWorkersConfig } from
|
|
1
|
+
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
|
|
2
2
|
|
|
3
3
|
export default defineWorkersConfig({
|
|
4
4
|
test: {
|
|
5
5
|
poolOptions: {
|
|
6
6
|
workers: {
|
|
7
|
-
wrangler: { configPath:
|
|
7
|
+
wrangler: { configPath: "./wrangler.jsonc" },
|
|
8
8
|
},
|
|
9
9
|
},
|
|
10
10
|
},
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
env,
|
|
3
|
+
createExecutionContext,
|
|
4
|
+
waitOnExecutionContext,
|
|
5
|
+
SELF,
|
|
6
|
+
} from "cloudflare:test";
|
|
7
|
+
import { describe, it, expect } from "vitest";
|
|
8
|
+
import worker from "../src";
|
|
4
9
|
|
|
5
|
-
describe(
|
|
6
|
-
describe(
|
|
10
|
+
describe("Hello World user worker", () => {
|
|
11
|
+
describe("request for /message", () => {
|
|
7
12
|
it('/ responds with "Hello, World!" (unit style)', async () => {
|
|
8
|
-
const request = new Request(
|
|
13
|
+
const request = new Request("http://example.com/message");
|
|
9
14
|
// Create an empty context to pass to `worker.fetch()`.
|
|
10
15
|
const ctx = createExecutionContext();
|
|
11
16
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -15,27 +20,31 @@ describe('Hello World user worker', () => {
|
|
|
15
20
|
});
|
|
16
21
|
|
|
17
22
|
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
|
-
const request = new Request(
|
|
23
|
+
const request = new Request("http://example.com/message");
|
|
19
24
|
const response = await SELF.fetch(request);
|
|
20
25
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
26
|
});
|
|
22
27
|
});
|
|
23
28
|
|
|
24
|
-
describe(
|
|
25
|
-
it(
|
|
26
|
-
const request = new Request(
|
|
29
|
+
describe("request for /random", () => {
|
|
30
|
+
it("/ responds with a random UUID (unit style)", async () => {
|
|
31
|
+
const request = new Request("http://example.com/random");
|
|
27
32
|
// Create an empty context to pass to `worker.fetch()`.
|
|
28
33
|
const ctx = createExecutionContext();
|
|
29
34
|
const response = await worker.fetch(request, env, ctx);
|
|
30
35
|
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
31
36
|
await waitOnExecutionContext(ctx);
|
|
32
|
-
expect(await response.text()).toMatch(
|
|
37
|
+
expect(await response.text()).toMatch(
|
|
38
|
+
/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/
|
|
39
|
+
);
|
|
33
40
|
});
|
|
34
41
|
|
|
35
|
-
it(
|
|
36
|
-
const request = new Request(
|
|
42
|
+
it("responds with a random UUID (integration style)", async () => {
|
|
43
|
+
const request = new Request("http://example.com/random");
|
|
37
44
|
const response = await SELF.fetch(request);
|
|
38
|
-
expect(await response.text()).toMatch(
|
|
45
|
+
expect(await response.text()).toMatch(
|
|
46
|
+
/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/
|
|
47
|
+
);
|
|
39
48
|
});
|
|
40
49
|
});
|
|
41
50
|
});
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
env,
|
|
3
|
+
createExecutionContext,
|
|
4
|
+
waitOnExecutionContext,
|
|
5
|
+
SELF,
|
|
6
|
+
} from "cloudflare:test";
|
|
7
|
+
import { describe, it, expect } from "vitest";
|
|
8
|
+
import worker from "../src";
|
|
4
9
|
|
|
5
|
-
describe(
|
|
6
|
-
describe(
|
|
10
|
+
describe("Hello World user worker", () => {
|
|
11
|
+
describe("request for /message", () => {
|
|
7
12
|
it('/ responds with "Hello, World!" (unit style)', async () => {
|
|
8
|
-
const request = new Request<unknown, IncomingRequestCfProperties>(
|
|
13
|
+
const request = new Request<unknown, IncomingRequestCfProperties>(
|
|
14
|
+
"http://example.com/message"
|
|
15
|
+
);
|
|
9
16
|
// Create an empty context to pass to `worker.fetch()`.
|
|
10
17
|
const ctx = createExecutionContext();
|
|
11
18
|
const response = await worker.fetch(request, env, ctx);
|
|
@@ -15,27 +22,33 @@ describe('Hello World user worker', () => {
|
|
|
15
22
|
});
|
|
16
23
|
|
|
17
24
|
it('responds with "Hello, World!" (integration style)', async () => {
|
|
18
|
-
const request = new Request(
|
|
25
|
+
const request = new Request("http://example.com/message");
|
|
19
26
|
const response = await SELF.fetch(request);
|
|
20
27
|
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
|
|
21
28
|
});
|
|
22
29
|
});
|
|
23
30
|
|
|
24
|
-
describe(
|
|
25
|
-
it(
|
|
26
|
-
const request = new Request<unknown, IncomingRequestCfProperties>(
|
|
31
|
+
describe("request for /random", () => {
|
|
32
|
+
it("/ responds with a random UUID (unit style)", async () => {
|
|
33
|
+
const request = new Request<unknown, IncomingRequestCfProperties>(
|
|
34
|
+
"http://example.com/random"
|
|
35
|
+
);
|
|
27
36
|
// Create an empty context to pass to `worker.fetch()`.
|
|
28
37
|
const ctx = createExecutionContext();
|
|
29
38
|
const response = await worker.fetch(request, env, ctx);
|
|
30
39
|
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
|
31
40
|
await waitOnExecutionContext(ctx);
|
|
32
|
-
expect(await response.text()).toMatch(
|
|
41
|
+
expect(await response.text()).toMatch(
|
|
42
|
+
/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/
|
|
43
|
+
);
|
|
33
44
|
});
|
|
34
45
|
|
|
35
|
-
it(
|
|
36
|
-
const request = new Request(
|
|
46
|
+
it("responds with a random UUID (integration style)", async () => {
|
|
47
|
+
const request = new Request("http://example.com/random");
|
|
37
48
|
const response = await SELF.fetch(request);
|
|
38
|
-
expect(await response.text()).toMatch(
|
|
49
|
+
expect(await response.text()).toMatch(
|
|
50
|
+
/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/
|
|
51
|
+
);
|
|
39
52
|
});
|
|
40
53
|
});
|
|
41
54
|
});
|
|
@@ -59,24 +59,24 @@ const updateNuxtConfig = () => {
|
|
|
59
59
|
b.objectExpression([
|
|
60
60
|
b.objectProperty(
|
|
61
61
|
b.identifier("preset"),
|
|
62
|
-
b.stringLiteral("cloudflare-pages")
|
|
62
|
+
b.stringLiteral("cloudflare-pages")
|
|
63
63
|
),
|
|
64
64
|
b.objectProperty(
|
|
65
65
|
b.identifier("cloudflare"),
|
|
66
66
|
b.objectExpression([
|
|
67
67
|
b.objectProperty(
|
|
68
68
|
b.identifier("deployConfig"),
|
|
69
|
-
b.booleanLiteral(true)
|
|
69
|
+
b.booleanLiteral(true)
|
|
70
70
|
),
|
|
71
71
|
b.objectProperty(b.identifier("nodeCompat"), b.booleanLiteral(true)),
|
|
72
|
-
])
|
|
72
|
+
])
|
|
73
73
|
),
|
|
74
|
-
])
|
|
74
|
+
])
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
const moduleDef = b.objectProperty(
|
|
78
78
|
b.identifier("modules"),
|
|
79
|
-
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
|
|
79
|
+
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
transformFile(configFile, {
|
|
@@ -85,7 +85,7 @@ const updateNuxtConfig = () => {
|
|
|
85
85
|
if (callee.name === "defineNuxtConfig") {
|
|
86
86
|
mergeObjectProperties(
|
|
87
87
|
n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
|
|
88
|
-
[presetDef, moduleDef]
|
|
88
|
+
[presetDef, moduleDef]
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -59,24 +59,24 @@ const updateNuxtConfig = () => {
|
|
|
59
59
|
b.objectExpression([
|
|
60
60
|
b.objectProperty(
|
|
61
61
|
b.identifier("preset"),
|
|
62
|
-
b.stringLiteral("cloudflare_module")
|
|
62
|
+
b.stringLiteral("cloudflare_module")
|
|
63
63
|
),
|
|
64
64
|
b.objectProperty(
|
|
65
65
|
b.identifier("cloudflare"),
|
|
66
66
|
b.objectExpression([
|
|
67
67
|
b.objectProperty(
|
|
68
68
|
b.identifier("deployConfig"),
|
|
69
|
-
b.booleanLiteral(true)
|
|
69
|
+
b.booleanLiteral(true)
|
|
70
70
|
),
|
|
71
71
|
b.objectProperty(b.identifier("nodeCompat"), b.booleanLiteral(true)),
|
|
72
|
-
])
|
|
72
|
+
])
|
|
73
73
|
),
|
|
74
|
-
])
|
|
74
|
+
])
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
const moduleDef = b.objectProperty(
|
|
78
78
|
b.identifier("modules"),
|
|
79
|
-
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
|
|
79
|
+
b.arrayExpression([b.stringLiteral("nitro-cloudflare-dev")])
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
transformFile(configFile, {
|
|
@@ -85,7 +85,7 @@ const updateNuxtConfig = () => {
|
|
|
85
85
|
if (callee.name === "defineNuxtConfig") {
|
|
86
86
|
mergeObjectProperties(
|
|
87
87
|
n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
|
|
88
|
-
[presetDef, moduleDef]
|
|
88
|
+
[presetDef, moduleDef]
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -23,7 +23,7 @@ export async function copyExistingWorkerFiles(ctx: C3Context) {
|
|
|
23
23
|
"Please specify the name of the existing worker in this account?",
|
|
24
24
|
label: "worker",
|
|
25
25
|
defaultValue: ctx.project.name,
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -46,16 +46,16 @@ export async function copyExistingWorkerFiles(ctx: C3Context) {
|
|
|
46
46
|
env: { CLOUDFLARE_ACCOUNT_ID: ctx.account?.id },
|
|
47
47
|
startText: "Downloading existing worker files",
|
|
48
48
|
doneText: `${brandColor("downloaded")} ${dim(
|
|
49
|
-
`existing "${ctx.args.existingScript}" worker files
|
|
49
|
+
`existing "${ctx.args.existingScript}" worker files`
|
|
50
50
|
)}`,
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
// copy src/* files from the downloaded Worker
|
|
55
55
|
await cp(
|
|
56
56
|
join(tempdir, ctx.args.existingScript, "src"),
|
|
57
57
|
join(ctx.project.path, "src"),
|
|
58
|
-
{ recursive: true }
|
|
58
|
+
{ recursive: true }
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
// copy wrangler config file from the downloaded Worker
|
|
@@ -73,7 +73,7 @@ export async function copyExistingWorkerFiles(ctx: C3Context) {
|
|
|
73
73
|
|
|
74
74
|
if (!configFileCopied) {
|
|
75
75
|
throw new Error(
|
|
76
|
-
`No wrangler configuration file found in downloaded worker. Expected one of: ${configFiles.join(", ")}
|
|
76
|
+
`No wrangler configuration file found in downloaded worker. Expected one of: ${configFiles.join(", ")}`
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -19,7 +19,13 @@ const generate = async (ctx: C3Context) => {
|
|
|
19
19
|
const configure = async (ctx: C3Context) => {
|
|
20
20
|
// Add the pages integration
|
|
21
21
|
// For some reason `pnpx qwik add` fails for qwik so we use `pnpm qwik add` instead.
|
|
22
|
-
const cmd = [
|
|
22
|
+
const cmd = [
|
|
23
|
+
name === "pnpm" ? npm : npx,
|
|
24
|
+
"qwik",
|
|
25
|
+
"add",
|
|
26
|
+
"cloudflare-pages",
|
|
27
|
+
"--skipConfirmation=true",
|
|
28
|
+
];
|
|
23
29
|
endSection(`Running ${quoteShellArgs(cmd)}`);
|
|
24
30
|
await runCommand(cmd);
|
|
25
31
|
|
|
@@ -43,7 +49,7 @@ const addBindingsProxy = (ctx: C3Context) => {
|
|
|
43
49
|
// Insert the env declaration after the last import (but before the rest of the body)
|
|
44
50
|
visitProgram: function (n) {
|
|
45
51
|
const lastImportIndex = n.node.body.findLastIndex(
|
|
46
|
-
(t) => t.type === "ImportDeclaration"
|
|
52
|
+
(t) => t.type === "ImportDeclaration"
|
|
47
53
|
);
|
|
48
54
|
const lastImport = n.get("body", lastImportIndex);
|
|
49
55
|
lastImport.insertAfter(...snippets.getPlatformProxyTs);
|