create-cloudflare 0.0.0-e42f3207 → 0.0.0-e4716cc87
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/README.md +1 -1
- package/dist/cli.js +32221 -31996
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -18
- package/templates/analog/c3.ts +1 -0
- package/templates/angular/c3.ts +27 -13
- package/templates/angular/templates/src/server.ts +15 -0
- package/templates/angular/templates/tools/copy-files.mjs +8 -2
- package/templates/astro/c3.ts +18 -33
- package/templates/astro/templates/{wrangler.toml → js/wrangler.toml} +1 -0
- package/templates/astro/templates/ts/src/env.d.ts +5 -0
- package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
- package/templates/{svelte → astro/templates}/ts/wrangler.toml +2 -1
- package/templates/common/c3.ts +3 -0
- package/templates/common/js/package.json +1 -1
- package/templates/common/js/wrangler.toml +6 -0
- package/templates/common/ts/package.json +2 -2
- package/templates/common/ts/src/ab-test.ts +2 -2
- package/templates/common/ts/src/index.ts +2 -2
- package/templates/common/ts/src/proxy.ts +2 -2
- package/templates/common/ts/src/redirect.ts +2 -2
- package/templates/common/ts/tsconfig.json +37 -95
- package/templates/common/ts/wrangler.toml +6 -0
- package/templates/docusaurus/c3.ts +3 -1
- package/templates/gatsby/c3.ts +1 -0
- package/templates/hello-world/c3.ts +5 -1
- package/templates/hello-world/js/package.json +3 -3
- package/templates/hello-world/js/vitest.config.js +8 -8
- package/templates/hello-world/js/wrangler.toml +6 -0
- package/templates/hello-world/py/__dot__gitignore +68 -0
- package/templates/hello-world/py/package.json +13 -0
- package/templates/{hello-world-python → hello-world}/py/wrangler.toml +6 -0
- package/templates/hello-world/ts/package.json +4 -4
- package/templates/hello-world/ts/src/index.ts +2 -2
- package/templates/hello-world/ts/test/tsconfig.json +6 -9
- package/templates/hello-world/ts/tsconfig.json +38 -96
- package/templates/hello-world/ts/vitest.config.mts +11 -0
- package/templates/hello-world/ts/wrangler.toml +6 -0
- package/templates/hello-world-durable-object/c3.ts +3 -1
- package/templates/hello-world-durable-object/js/package.json +1 -1
- package/templates/hello-world-durable-object/js/wrangler.toml +7 -1
- package/templates/hello-world-durable-object/ts/package.json +2 -2
- package/templates/hello-world-durable-object/ts/src/index.ts +2 -23
- package/templates/hello-world-durable-object/ts/tsconfig.json +36 -95
- package/templates/hello-world-durable-object/ts/worker-configuration.d.ts +3 -4
- package/templates/hello-world-durable-object/ts/wrangler.toml +8 -2
- package/templates/hono/c3.ts +1 -10
- package/templates/hono/snippets/appDeclaration.ts +1 -1
- package/templates/hono/templates/wrangler.toml +6 -0
- package/templates/next/README.md +2 -2
- package/templates/next/app/js/app/api/hello/route.js +4 -4
- package/templates/next/app/ts/app/api/hello/route.ts +4 -5
- package/templates/next/c3.ts +12 -12
- package/templates/nuxt/c3.ts +7 -7
- package/templates/nuxt/templates/wrangler.toml +1 -0
- package/templates/openapi/c3.ts +1 -0
- package/templates/openapi/ts/README.md +3 -3
- package/templates/openapi/ts/package.json +5 -3
- package/templates/openapi/ts/src/endpoints/taskCreate.ts +26 -16
- package/templates/openapi/ts/src/endpoints/taskDelete.ts +20 -19
- package/templates/openapi/ts/src/endpoints/taskFetch.ts +30 -23
- package/templates/openapi/ts/src/endpoints/taskList.ts +27 -24
- package/templates/openapi/ts/src/index.ts +14 -20
- package/templates/openapi/ts/src/types.ts +9 -8
- package/templates/openapi/ts/wrangler.toml +6 -0
- package/templates/pre-existing/c3.ts +28 -9
- package/templates/pre-existing/js/package.json +1 -1
- package/templates/queues/c3.ts +2 -0
- package/templates/queues/js/package.json +1 -1
- package/templates/queues/js/wrangler.toml +6 -0
- package/templates/queues/ts/package.json +2 -2
- package/templates/queues/ts/src/index.ts +3 -3
- package/templates/queues/ts/tsconfig.json +36 -95
- package/templates/queues/ts/wrangler.toml +6 -0
- package/templates/qwik/c3.ts +4 -3
- package/templates/qwik/templates/wrangler.toml +1 -0
- package/templates/react/c3.ts +33 -3
- package/templates/remix/c3.ts +1 -0
- package/templates/scheduled/c3.ts +2 -0
- package/templates/scheduled/js/package.json +1 -1
- package/templates/scheduled/js/wrangler.toml +6 -0
- package/templates/scheduled/ts/package.json +2 -2
- package/templates/scheduled/ts/src/index.ts +2 -2
- package/templates/scheduled/ts/tsconfig.json +36 -95
- package/templates/scheduled/ts/wrangler.toml +6 -0
- package/templates/solid/c3.ts +9 -6
- package/templates/svelte/c3.ts +34 -6
- package/templates/vue/c3.ts +1 -0
- package/templates-experimental/angular/c3.ts +112 -0
- package/templates-experimental/angular/templates/src/server.ts +15 -0
- package/templates-experimental/angular/templates/wrangler.toml +11 -0
- package/templates-experimental/astro/c3.ts +98 -0
- package/templates-experimental/astro/templates/js/public/.assetsignore +4 -0
- package/templates-experimental/astro/templates/js/wrangler.toml +12 -0
- package/templates-experimental/astro/templates/ts/public/.assetsignore +4 -0
- package/templates-experimental/astro/templates/ts/worker-configuration.d.ts +4 -0
- package/templates-experimental/astro/templates/ts/wrangler.toml +12 -0
- package/templates-experimental/docusaurus/c3.ts +32 -0
- package/templates-experimental/docusaurus/templates/wrangler.toml +10 -0
- package/templates-experimental/gatsby/c3.ts +53 -0
- package/templates-experimental/gatsby/templates/wrangler.toml +10 -0
- package/templates-experimental/hello-world-assets-only/c3.ts +15 -0
- package/{templates/hello-world-python/py → templates-experimental/hello-world-assets-only/templates}/package.json +1 -1
- 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 +42 -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 +22 -0
- package/templates-experimental/hello-world-with-assets/js/.editorconfig +12 -0
- package/templates-experimental/hello-world-with-assets/js/.prettierrc +6 -0
- package/templates-experimental/hello-world-with-assets/js/__dot__gitignore +172 -0
- package/templates-experimental/hello-world-with-assets/js/package.json +16 -0
- package/templates-experimental/hello-world-with-assets/js/public/index.html +31 -0
- package/templates-experimental/hello-world-with-assets/js/src/index.js +23 -0
- package/templates-experimental/hello-world-with-assets/js/test/index.spec.js +41 -0
- package/templates-experimental/hello-world-with-assets/js/vitest.config.js +11 -0
- package/templates-experimental/hello-world-with-assets/js/wrangler.toml +12 -0
- package/templates-experimental/hello-world-with-assets/py/package.json +13 -0
- package/templates-experimental/hello-world-with-assets/py/public/index.html +31 -0
- package/templates-experimental/hello-world-with-assets/py/src/entry.py +9 -0
- package/templates-experimental/hello-world-with-assets/py/wrangler.toml +12 -0
- package/templates-experimental/hello-world-with-assets/ts/.editorconfig +12 -0
- package/templates-experimental/hello-world-with-assets/ts/.prettierrc +6 -0
- package/templates-experimental/hello-world-with-assets/ts/__dot__gitignore +172 -0
- package/templates-experimental/hello-world-with-assets/ts/package.json +18 -0
- package/templates-experimental/hello-world-with-assets/ts/public/index.html +31 -0
- package/templates-experimental/hello-world-with-assets/ts/src/index.ts +26 -0
- package/templates-experimental/hello-world-with-assets/ts/test/index.spec.ts +41 -0
- package/templates-experimental/hello-world-with-assets/ts/test/tsconfig.json +8 -0
- package/templates-experimental/hello-world-with-assets/ts/tsconfig.json +44 -0
- package/templates-experimental/hello-world-with-assets/ts/vitest.config.mts +11 -0
- package/templates-experimental/hello-world-with-assets/ts/worker-configuration.d.ts +4 -0
- package/templates-experimental/hello-world-with-assets/ts/wrangler.toml +12 -0
- 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 +59 -0
- package/templates-experimental/next/templates/.dev.vars +2 -0
- package/templates-experimental/next/templates/__dot__gitignore +39 -0
- package/templates-experimental/next/templates/env.d.ts +5 -0
- package/templates-experimental/next/templates/open-next.config.ts +28 -0
- package/templates-experimental/next/templates/wrangler.toml +12 -0
- package/templates-experimental/nuxt/c3.ts +135 -0
- package/templates-experimental/nuxt/templates/env.d.ts +14 -0
- package/templates-experimental/nuxt/templates/worker-configuration.d.ts +4 -0
- package/templates-experimental/nuxt/templates/wrangler.toml +11 -0
- package/templates-experimental/qwik/c3.ts +153 -0
- package/templates-experimental/qwik/snippets/getPlatformProxy.ts +6 -0
- package/templates-experimental/qwik/templates/public/.assetsignore +4 -0
- package/templates-experimental/qwik/templates/worker-configuration.d.ts +4 -0
- package/templates-experimental/qwik/templates/wrangler.toml +12 -0
- package/templates-experimental/remix/c3.ts +52 -0
- package/templates-experimental/remix/templates/public/.assetsignore +0 -0
- package/templates-experimental/remix/templates/worker-configuration.d.ts +4 -0
- package/templates-experimental/remix/templates/wrangler.toml +11 -0
- package/templates-experimental/solid/c3.ts +94 -0
- package/templates-experimental/solid/templates/wrangler.toml +12 -0
- package/templates-experimental/svelte/c3.ts +129 -0
- package/templates-experimental/svelte/templates/static/.assetsignore +4 -0
- package/templates-experimental/svelte/templates/wrangler.toml +11 -0
- package/templates-experimental/vue/c3.ts +33 -0
- package/templates-experimental/vue/templates/wrangler.toml +10 -0
- package/templates/angular/templates/server.ts +0 -34
- package/templates/angular/templates/tools/alter-polyfills.mjs +0 -27
- package/templates/angular/templates/tools/paths.mjs +0 -9
- package/templates/hello-world/ts/vitest.config.ts +0 -11
- package/templates/hello-world-python/c3.ts +0 -9
- package/templates/hono/snippets/bindingsType.ts +0 -3
- /package/templates/{hello-world-python → hello-world}/py/src/entry.py +0 -0
- /package/templates/svelte/{js → templates}/wrangler.toml +0 -0
- /package/{templates/astro/snippets/runtimeDeclaration.ts → templates-experimental/astro/templates/ts/src/env.d.ts} +0 -0
- /package/{templates/hello-world-python → templates-experimental/hello-world-with-assets}/py/__dot__gitignore +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e4716cc87",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"bin": "./dist/cli.js",
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
-
"templates"
|
|
26
|
+
"templates",
|
|
27
|
+
"templates-experimental"
|
|
27
28
|
],
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@babel/parser": "^7.21.3",
|
|
30
31
|
"@babel/types": "^7.21.4",
|
|
31
32
|
"@clack/prompts": "^0.6.3",
|
|
32
|
-
"@cloudflare/workers-types": "^4.
|
|
33
|
+
"@cloudflare/workers-types": "^4.20241230.0",
|
|
33
34
|
"@iarna/toml": "^3.0.0",
|
|
34
35
|
"@types/command-exists": "^1.2.0",
|
|
35
36
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -37,12 +38,12 @@
|
|
|
37
38
|
"@types/degit": "^2.8.6",
|
|
38
39
|
"@types/dns2": "^2.0.3",
|
|
39
40
|
"@types/esprima": "^4.0.3",
|
|
40
|
-
"@types/node": "^18.
|
|
41
|
+
"@types/node": "^18.19.59",
|
|
41
42
|
"@types/semver": "^7.5.1",
|
|
42
43
|
"@types/which-pm-runs": "^1.0.0",
|
|
43
44
|
"@types/yargs": "^17.0.22",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.9.0",
|
|
46
47
|
"chalk": "^5.2.0",
|
|
47
48
|
"command-exists": "^1.2.9",
|
|
48
49
|
"cross-spawn": "^7.0.3",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"degit": "^2.8.4",
|
|
51
52
|
"dns2": "^2.1.0",
|
|
52
53
|
"dotenv": "^16.0.0",
|
|
53
|
-
"esbuild": "
|
|
54
|
+
"esbuild": "0.17.19",
|
|
54
55
|
"execa": "^7.1.1",
|
|
55
56
|
"glob": "^10.3.3",
|
|
56
57
|
"haikunator": "^2.1.2",
|
|
@@ -59,32 +60,40 @@
|
|
|
59
60
|
"open": "^8.4.0",
|
|
60
61
|
"recast": "^0.22.0",
|
|
61
62
|
"semver": "^7.5.1",
|
|
62
|
-
"undici": "5.28.4",
|
|
63
|
+
"undici": "^5.28.4",
|
|
63
64
|
"vite-tsconfig-paths": "^4.0.8",
|
|
64
65
|
"which-pm-runs": "^1.1.0",
|
|
65
66
|
"wrap-ansi": "^9.0.0",
|
|
66
|
-
"
|
|
67
|
+
"xdg-app-paths": "^8.3.0",
|
|
68
|
+
"yargs": "^17.7.2",
|
|
67
69
|
"@cloudflare/cli": "1.1.1",
|
|
68
|
-
"
|
|
70
|
+
"wrangler": "0.0.0-e4716cc87",
|
|
69
71
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
70
|
-
"
|
|
72
|
+
"@cloudflare/eslint-config-worker": "1.1.0"
|
|
71
73
|
},
|
|
72
74
|
"engines": {
|
|
73
75
|
"node": ">=18.14.1"
|
|
74
76
|
},
|
|
75
77
|
"workers-sdk": {
|
|
76
|
-
"prerelease": true
|
|
78
|
+
"prerelease": true,
|
|
79
|
+
"type": "cli"
|
|
80
|
+
},
|
|
81
|
+
"volta": {
|
|
82
|
+
"extends": "../../package.json"
|
|
77
83
|
},
|
|
78
84
|
"scripts": {
|
|
79
85
|
"build": "node -r esbuild-register scripts/build.ts",
|
|
80
86
|
"dev:codemod": "node -r esbuild-register scripts/codemodDev.ts",
|
|
81
|
-
"check:lint": "eslint .",
|
|
87
|
+
"check:lint": "eslint . --max-warnings=0",
|
|
82
88
|
"check:type": "tsc",
|
|
83
|
-
"
|
|
84
|
-
"test:e2e": "vitest run --config ./vitest-e2e.config.
|
|
85
|
-
"test:
|
|
86
|
-
"test:
|
|
89
|
+
"test:e2e": "vitest run --config ./vitest-e2e.config.mts",
|
|
90
|
+
"test:e2e:npm": "pnpm run build && cross-env TEST_PM=npm vitest run --config ./vitest-e2e.config.mts",
|
|
91
|
+
"test:e2e:pnpm": "pnpm run build && cross-env TEST_PM=pnpm vitest run --config ./vitest-e2e.config.mts",
|
|
92
|
+
"test:e2e:bun": "pnpm run build && cross-env TEST_PM=bun vitest run --config ./vitest-e2e.config.mts",
|
|
93
|
+
"test:e2e:yarn": "pnpm run build && cross-env TEST_PM=yarn vitest run --config ./vitest-e2e.config.mts",
|
|
94
|
+
"test:unit": "vitest run --config ./vitest.config.mts",
|
|
95
|
+
"test:unit:watch": "vitest --config ./vitest.config.mts",
|
|
87
96
|
"watch": "node -r esbuild-register scripts/build.ts --watch",
|
|
88
|
-
"test:ci": "vitest run --config ./vitest.config.
|
|
97
|
+
"test:ci": "vitest run --config ./vitest.config.mts"
|
|
89
98
|
}
|
|
90
99
|
}
|
package/templates/analog/c3.ts
CHANGED
package/templates/angular/c3.ts
CHANGED
|
@@ -13,7 +13,11 @@ import type { C3Context } from "types";
|
|
|
13
13
|
const { npm } = detectPackageManager();
|
|
14
14
|
|
|
15
15
|
const generate = async (ctx: C3Context) => {
|
|
16
|
-
await runFrameworkGenerator(ctx, [
|
|
16
|
+
await runFrameworkGenerator(ctx, [
|
|
17
|
+
ctx.project.name,
|
|
18
|
+
"--ssr",
|
|
19
|
+
"--server-routing" /** Dev Preview API */,
|
|
20
|
+
]);
|
|
17
21
|
logRaw("");
|
|
18
22
|
};
|
|
19
23
|
|
|
@@ -24,14 +28,11 @@ const configure = async (ctx: C3Context) => {
|
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
async function installCFWorker() {
|
|
27
|
-
await installPackages(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
33
|
-
},
|
|
34
|
-
);
|
|
31
|
+
await installPackages(["xhr2"], {
|
|
32
|
+
dev: true,
|
|
33
|
+
startText: "Installing additional dependencies",
|
|
34
|
+
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
|
|
35
|
+
});
|
|
35
36
|
}
|
|
36
37
|
async function updateAppCode() {
|
|
37
38
|
const s = spinner();
|
|
@@ -50,13 +51,23 @@ async function updateAppCode() {
|
|
|
50
51
|
writeFile(resolve(appConfigPath), newAppConfig);
|
|
51
52
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
|
52
53
|
|
|
54
|
+
// Update an app server routes file to:
|
|
55
|
+
const appServerRoutesPath = "src/app/app.routes.server.ts";
|
|
56
|
+
const appRoutes = readFile(resolve(appServerRoutesPath));
|
|
57
|
+
const newAppRoutes = appRoutes.replace(
|
|
58
|
+
"RenderMode.Prerender",
|
|
59
|
+
"RenderMode.Server",
|
|
60
|
+
);
|
|
61
|
+
writeFile(resolve(appServerRoutesPath), newAppRoutes);
|
|
62
|
+
s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
|
|
63
|
+
|
|
53
64
|
// Remove unwanted dependencies
|
|
54
65
|
s.start(`Updating package.json`);
|
|
55
66
|
const packageJsonPath = resolve("package.json");
|
|
56
67
|
const packageManifest = readJSON(packageJsonPath);
|
|
57
68
|
|
|
58
|
-
delete packageManifest["dependencies"]["@angular/ssr"];
|
|
59
69
|
delete packageManifest["dependencies"]["express"];
|
|
70
|
+
delete packageManifest["devDependencies"]["@types/express"];
|
|
60
71
|
|
|
61
72
|
writeFile(packageJsonPath, JSON.stringify(packageManifest, null, 2));
|
|
62
73
|
s.stop(`${brandColor(`updated`)} ${dim(`\`package.json\``)}`);
|
|
@@ -69,6 +80,8 @@ function updateAngularJson(ctx: C3Context) {
|
|
|
69
80
|
// Update builder
|
|
70
81
|
const architectSection = angularJson.projects[ctx.project.name].architect;
|
|
71
82
|
architectSection.build.options.outputPath = "dist";
|
|
83
|
+
architectSection.build.options.outputMode = "server";
|
|
84
|
+
architectSection.build.options.ssr.experimentalPlatform = "neutral";
|
|
72
85
|
architectSection.build.options.assets.push("src/_routes.json");
|
|
73
86
|
|
|
74
87
|
writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
|
|
@@ -78,6 +91,7 @@ function updateAngularJson(ctx: C3Context) {
|
|
|
78
91
|
const config: TemplateConfig = {
|
|
79
92
|
configVersion: 1,
|
|
80
93
|
id: "angular",
|
|
94
|
+
frameworkCli: "@angular/create",
|
|
81
95
|
displayName: "Angular",
|
|
82
96
|
platform: "pages",
|
|
83
97
|
copyFiles: {
|
|
@@ -85,14 +99,14 @@ const config: TemplateConfig = {
|
|
|
85
99
|
},
|
|
86
100
|
devScript: "start",
|
|
87
101
|
deployScript: "deploy",
|
|
102
|
+
previewScript: "start",
|
|
88
103
|
generate,
|
|
89
104
|
configure,
|
|
90
105
|
transformPackageJson: async () => ({
|
|
91
106
|
scripts: {
|
|
92
|
-
start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}
|
|
107
|
+
start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()}`,
|
|
93
108
|
build: `ng build && ${npm} run process`,
|
|
94
|
-
process:
|
|
95
|
-
"node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
|
|
109
|
+
process: "node ./tools/copy-files.mjs",
|
|
96
110
|
deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
|
|
97
111
|
},
|
|
98
112
|
}),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AngularAppEngine, createRequestHandler } from '@angular/ssr';
|
|
2
|
+
|
|
3
|
+
const angularApp = new AngularAppEngine();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is a request handler used by the Angular CLI (dev-server and during build).
|
|
7
|
+
*/
|
|
8
|
+
export const reqHandler = createRequestHandler(async (req) => {
|
|
9
|
+
const res = await angularApp.handle(req);
|
|
10
|
+
|
|
11
|
+
return res ?? new Response('Page not found.', { status: 404 });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export default { fetch: reqHandler };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// Copy the files over so that they can be uploaded by the pages publish command.
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import {
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = resolve(fileURLToPath(import.meta.url), "../../");
|
|
7
|
+
const client = resolve(root, "dist/browser");
|
|
8
|
+
const ssr = resolve(root, "dist/server");
|
|
9
|
+
const cloudflare = resolve(root, "dist/cloudflare");
|
|
10
|
+
const worker = resolve(cloudflare, "_worker.js");
|
|
5
11
|
|
|
6
12
|
fs.cpSync(client, cloudflare, { recursive: true });
|
|
7
13
|
fs.cpSync(ssr, worker, { recursive: true });
|
package/templates/astro/c3.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logRaw, updateStatus } from "@cloudflare/cli";
|
|
2
2
|
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
|
|
3
3
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
4
|
-
import {
|
|
4
|
+
import { transformFile } from "helpers/codemod";
|
|
5
5
|
import { runCommand } from "helpers/command";
|
|
6
6
|
import { usesTypescript } from "helpers/files";
|
|
7
7
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
@@ -17,7 +17,7 @@ const generate = async (ctx: C3Context) => {
|
|
|
17
17
|
logRaw(""); // newline
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const configure = async (
|
|
20
|
+
const configure = async () => {
|
|
21
21
|
await runCommand([npx, "astro", "add", "cloudflare", "-y"], {
|
|
22
22
|
silent: true,
|
|
23
23
|
startText: "Installing adapter",
|
|
@@ -27,7 +27,6 @@ const configure = async (ctx: C3Context) => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
updateAstroConfig();
|
|
30
|
-
updateEnvDeclaration(ctx);
|
|
31
30
|
};
|
|
32
31
|
|
|
33
32
|
const updateAstroConfig = () => {
|
|
@@ -59,42 +58,28 @@ const updateAstroConfig = () => {
|
|
|
59
58
|
});
|
|
60
59
|
};
|
|
61
60
|
|
|
62
|
-
const updateEnvDeclaration = (ctx: C3Context) => {
|
|
63
|
-
if (!usesTypescript(ctx)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const filePath = "src/env.d.ts";
|
|
68
|
-
|
|
69
|
-
updateStatus(`Adding type declarations in ${blue(filePath)}`);
|
|
70
|
-
|
|
71
|
-
transformFile(filePath, {
|
|
72
|
-
visitProgram: function (n) {
|
|
73
|
-
const snippets = loadTemplateSnippets(ctx);
|
|
74
|
-
const patch = snippets.runtimeDeclarationTs;
|
|
75
|
-
const b = recast.types.builders;
|
|
76
|
-
|
|
77
|
-
// Preserve comments with the new body
|
|
78
|
-
const comments = n.get("comments").value;
|
|
79
|
-
n.node.comments = comments.map((c: recast.types.namedTypes.CommentLine) =>
|
|
80
|
-
b.commentLine(c.value),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// Add the patch
|
|
84
|
-
n.get("body").push(...patch);
|
|
85
|
-
|
|
86
|
-
return false;
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
61
|
const config: TemplateConfig = {
|
|
92
62
|
configVersion: 1,
|
|
93
63
|
id: "astro",
|
|
64
|
+
frameworkCli: "create-astro",
|
|
94
65
|
platform: "pages",
|
|
95
66
|
displayName: "Astro",
|
|
96
67
|
copyFiles: {
|
|
97
|
-
|
|
68
|
+
async selectVariant(ctx) {
|
|
69
|
+
// Note: this `selectVariant` function should not be needed
|
|
70
|
+
// this is just a quick workaround until
|
|
71
|
+
// https://github.com/cloudflare/workers-sdk/issues/7495
|
|
72
|
+
// is resolved
|
|
73
|
+
return usesTypescript(ctx) ? "ts" : "js";
|
|
74
|
+
},
|
|
75
|
+
variants: {
|
|
76
|
+
js: {
|
|
77
|
+
path: "./templates/js",
|
|
78
|
+
},
|
|
79
|
+
ts: {
|
|
80
|
+
path: "./templates/ts",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
98
83
|
},
|
|
99
84
|
devScript: "dev",
|
|
100
85
|
deployScript: "deploy",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
|
|
4
|
+
compatibility_flags = ["nodejs_compat"]
|
|
5
|
+
pages_build_output_dir = "./dist"
|
|
5
6
|
|
|
6
7
|
# Automatically place your workloads in an optimal location to minimize latency.
|
|
7
8
|
# If you are running back-end logic in a Pages Function, running it closer to your back-end infrastructure
|
package/templates/common/c3.ts
CHANGED
|
@@ -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.
|
|
@@ -6,7 +6,7 @@ const EXPERIMENTS = [
|
|
|
6
6
|
];
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
async fetch(request
|
|
9
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
10
10
|
const fingerprint = [request.headers.get('cf-connecting-ip'), request.cf?.postalCode]; // add any values you want considered as a fingerprint
|
|
11
11
|
const activeExperiments = await getActiveExperiments(fingerprint, EXPERIMENTS);
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
|
|
23
23
|
return rewriter.transform(res);
|
|
24
24
|
},
|
|
25
|
-
}
|
|
25
|
+
} satisfies ExportedHandler<Env>;
|
|
26
26
|
|
|
27
27
|
// Get active experiments by hashing a fingerprint
|
|
28
28
|
async function getActiveExperiments(fingerprint: unknown, experiments: Array<{ name: string; threshold: number }>) {
|
|
@@ -19,7 +19,7 @@ import apiRouter from './router';
|
|
|
19
19
|
export default {
|
|
20
20
|
// The fetch handler is invoked when this worker receives a HTTP(S) request
|
|
21
21
|
// and should return a Response (optionally wrapped in a Promise)
|
|
22
|
-
async fetch(request
|
|
22
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
23
23
|
// You'll find it helpful to parse the request.url string into a URL object. Learn more at https://developer.mozilla.org/en-US/docs/Web/API/URL
|
|
24
24
|
const url = new URL(request.url);
|
|
25
25
|
|
|
@@ -46,4 +46,4 @@ export default {
|
|
|
46
46
|
{ headers: { 'Content-Type': 'text/html' } }
|
|
47
47
|
);
|
|
48
48
|
},
|
|
49
|
-
}
|
|
49
|
+
} satisfies ExportedHandler<Env>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
async fetch(request
|
|
2
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
3
3
|
const url = new URL(request.url);
|
|
4
4
|
|
|
5
5
|
const proxyUrl = url.searchParams.get('proxyUrl'); // get a query param value (?proxyUrl=...)
|
|
@@ -20,4 +20,4 @@ export default {
|
|
|
20
20
|
|
|
21
21
|
return res;
|
|
22
22
|
},
|
|
23
|
-
}
|
|
23
|
+
} satisfies ExportedHandler<Env>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
async fetch(request
|
|
2
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
3
3
|
const url = new URL(request.url);
|
|
4
4
|
const redirectUrl = url.searchParams.get('redirectUrl'); // get a query param value (?redirectUrl=...)
|
|
5
5
|
|
|
@@ -10,4 +10,4 @@ export default {
|
|
|
10
10
|
// The Response class has static methods to create common Response objects as a convenience
|
|
11
11
|
return Response.redirect(redirectUrl);
|
|
12
12
|
},
|
|
13
|
-
}
|
|
13
|
+
} satisfies ExportedHandler<Env>;
|
|
@@ -2,100 +2,42 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
4
|
|
|
5
|
-
/*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
|
43
|
-
|
|
44
|
-
/* Emit */
|
|
45
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
46
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
47
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
48
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
49
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
|
50
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
51
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
52
|
-
"noEmit": true /* Disable emitting files from a compilation. */,
|
|
53
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
54
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
|
55
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
56
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
57
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
60
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
61
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
62
|
-
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
|
63
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
|
64
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
65
|
-
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
|
66
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
67
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
68
|
-
|
|
69
|
-
/* Interop Constraints */
|
|
70
|
-
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
71
|
-
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
|
|
72
|
-
// "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
|
73
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
74
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
75
|
-
|
|
76
|
-
/* Type Checking */
|
|
77
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
78
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
79
|
-
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
80
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
81
|
-
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
|
82
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
83
|
-
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
|
84
|
-
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
|
85
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
86
|
-
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
|
87
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
|
88
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
89
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
90
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
91
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
92
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
93
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
|
94
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
95
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
96
|
-
|
|
97
|
-
/* Completeness */
|
|
98
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
99
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
5
|
+
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
6
|
+
"target": "es2021",
|
|
7
|
+
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
8
|
+
"lib": ["es2021"],
|
|
9
|
+
/* Specify what JSX code is generated. */
|
|
10
|
+
"jsx": "react-jsx" ,
|
|
11
|
+
|
|
12
|
+
/* Specify what module code is generated. */
|
|
13
|
+
"module": "es2022",
|
|
14
|
+
/* Specify how TypeScript looks up a file from a given module specifier. */
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
/* Enable importing .json files */
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
|
|
19
|
+
/* Specify type package names to be included without being referenced in a source file. */
|
|
20
|
+
"types": ["@cloudflare/workers-types"],
|
|
21
|
+
|
|
22
|
+
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
|
23
|
+
"allowJs": true,
|
|
24
|
+
/* Enable error reporting in type-checked JavaScript files. */
|
|
25
|
+
"checkJs": false,
|
|
26
|
+
|
|
27
|
+
/* Disable emitting files from a compilation. */
|
|
28
|
+
"noEmit": true,
|
|
29
|
+
|
|
30
|
+
/* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
31
|
+
"isolatedModules": true,
|
|
32
|
+
/* Allow 'import x from y' when a module doesn't have a default export. */
|
|
33
|
+
"allowSyntheticDefaultImports": true,
|
|
34
|
+
/* Ensure that casing is correct in imports. */
|
|
35
|
+
"forceConsistentCasingInFileNames": true,
|
|
36
|
+
|
|
37
|
+
/* Enable all strict type-checking options. */
|
|
38
|
+
"strict": true,
|
|
39
|
+
|
|
40
|
+
/* Skip type checking all .d.ts files. */
|
|
41
|
+
"skipLibCheck": true
|
|
100
42
|
}
|
|
101
43
|
}
|
|
@@ -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.
|