create-cloudflare 0.0.0-c46e02dfd → 0.0.0-c4cf040dc
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 +3308 -3260
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/templates/angular/c3.ts +25 -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 +17 -33
- package/templates/astro/templates/ts/worker-configuration.d.ts +4 -0
- package/templates/{svelte → astro/templates}/ts/wrangler.toml +2 -1
- package/templates/hello-world/js/package.json +1 -1
- package/templates/hello-world/ts/package.json +1 -1
- package/templates/hello-world/ts/test/tsconfig.json +1 -1
- package/templates/next/README.md +1 -1
- 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 +3 -3
- package/templates/nuxt/c3.ts +1 -1
- package/templates/svelte/c3.ts +31 -4
- package/templates-experimental/angular/c3.ts +21 -7
- package/templates-experimental/angular/templates/src/server.ts +15 -0
- package/templates-experimental/astro/c3.ts +17 -33
- 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/hello-world-with-assets/js/package.json +1 -1
- package/templates-experimental/hello-world-with-assets/ts/package.json +1 -1
- package/templates-experimental/next/c3.ts +4 -0
- package/templates-experimental/nuxt/c3.ts +2 -2
- package/templates-experimental/nuxt/templates/wrangler.toml +2 -2
- package/templates-experimental/solid/c3.ts +7 -50
- package/templates-experimental/solid/templates/wrangler.toml +2 -2
- package/templates-experimental/svelte/c3.ts +1 -4
- package/templates-experimental/vue/c3.ts +33 -0
- package/templates-experimental/{svelte/ts → vue/templates}/wrangler.toml +1 -2
- 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-experimental/angular/templates/server.ts +0 -34
- package/templates-experimental/angular/templates/tools/alter-polyfills.mjs +0 -32
- package/templates-experimental/nuxt/templates/cloudflare-preset/nitro.config.ts +0 -27
- /package/templates/astro/templates/{wrangler.toml → js/wrangler.toml} +0 -0
- /package/templates/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
- /package/templates/svelte/{js → templates}/wrangler.toml +0 -0
- /package/templates-experimental/astro/templates/{public → js/public}/.assetsignore +0 -0
- /package/templates-experimental/astro/templates/{wrangler.toml → js/wrangler.toml} +0 -0
- /package/templates-experimental/{svelte/js/static → astro/templates/ts/public}/.assetsignore +0 -0
- /package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts} +0 -0
- /package/templates-experimental/svelte/{ts → templates}/static/.assetsignore +0 -0
- /package/templates-experimental/svelte/{js → templates}/wrangler.toml +0 -0
|
@@ -24,7 +24,7 @@ const generate = async (ctx: C3Context) => {
|
|
|
24
24
|
gitFlag,
|
|
25
25
|
]);
|
|
26
26
|
|
|
27
|
-
writeFile("./.node-version", "
|
|
27
|
+
writeFile("./.node-version", "18");
|
|
28
28
|
|
|
29
29
|
logRaw(""); // newline
|
|
30
30
|
};
|
|
@@ -82,7 +82,7 @@ const updateNuxtConfig = () => {
|
|
|
82
82
|
b.objectExpression([
|
|
83
83
|
b.objectProperty(
|
|
84
84
|
b.identifier("preset"),
|
|
85
|
-
b.stringLiteral("
|
|
85
|
+
b.stringLiteral("cloudflare_module"),
|
|
86
86
|
),
|
|
87
87
|
]),
|
|
88
88
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
main = "
|
|
5
|
-
assets = { directory = "
|
|
4
|
+
main = "./.output/server/index.mjs"
|
|
5
|
+
assets = { directory = "./.output/public/", binding = "ASSETS" }
|
|
6
6
|
|
|
7
7
|
# Workers Logs
|
|
8
8
|
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
@@ -2,6 +2,7 @@ import { logRaw, updateStatus } from "@cloudflare/cli";
|
|
|
2
2
|
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
|
|
3
3
|
import { runFrameworkGenerator } from "frameworks/index";
|
|
4
4
|
import { mergeObjectProperties, transformFile } from "helpers/codemod";
|
|
5
|
+
import { getWorkerdCompatibilityDate } from "helpers/compatDate";
|
|
5
6
|
import { usesTypescript } from "helpers/files";
|
|
6
7
|
import { detectPackageManager } from "helpers/packageManagers";
|
|
7
8
|
import { installPackages } from "helpers/packages";
|
|
@@ -30,6 +31,8 @@ const configure = async (ctx: C3Context) => {
|
|
|
30
31
|
usesTypescript(ctx);
|
|
31
32
|
const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
|
|
32
33
|
|
|
34
|
+
const compatDate = await getWorkerdCompatibilityDate();
|
|
35
|
+
|
|
33
36
|
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
34
37
|
|
|
35
38
|
transformFile(filePath, {
|
|
@@ -46,60 +49,14 @@ const configure = async (ctx: C3Context) => {
|
|
|
46
49
|
b.objectProperty(
|
|
47
50
|
b.identifier("server"),
|
|
48
51
|
b.objectExpression([
|
|
49
|
-
// preset: "
|
|
52
|
+
// preset: "cloudflare_module"
|
|
50
53
|
b.objectProperty(
|
|
51
54
|
b.identifier("preset"),
|
|
52
|
-
b.stringLiteral("
|
|
53
|
-
),
|
|
54
|
-
// output: {
|
|
55
|
-
// dir: "{{ rootDir }}/dist",
|
|
56
|
-
// publicDir: "{{ output.dir }}/public",
|
|
57
|
-
// serverDir: "{{ output.dir }}/worker",
|
|
58
|
-
// },
|
|
59
|
-
b.objectProperty(
|
|
60
|
-
b.identifier("output"),
|
|
61
|
-
b.objectExpression([
|
|
62
|
-
b.objectProperty(
|
|
63
|
-
b.identifier("dir"),
|
|
64
|
-
b.stringLiteral("{{ rootDir }}/dist"),
|
|
65
|
-
),
|
|
66
|
-
b.objectProperty(
|
|
67
|
-
b.identifier("publicDir"),
|
|
68
|
-
b.stringLiteral("{{ output.dir }}/public"),
|
|
69
|
-
),
|
|
70
|
-
b.objectProperty(
|
|
71
|
-
b.identifier("serverDir"),
|
|
72
|
-
b.stringLiteral("{{ output.dir }}/worker"),
|
|
73
|
-
),
|
|
74
|
-
]),
|
|
75
|
-
),
|
|
76
|
-
// rollupConfig: {
|
|
77
|
-
// external: ["node:async_hooks"],
|
|
78
|
-
// },
|
|
79
|
-
b.objectProperty(
|
|
80
|
-
b.identifier("rollupConfig"),
|
|
81
|
-
b.objectExpression([
|
|
82
|
-
b.objectProperty(
|
|
83
|
-
b.identifier("external"),
|
|
84
|
-
b.arrayExpression([b.stringLiteral("node:async_hooks")]),
|
|
85
|
-
),
|
|
86
|
-
]),
|
|
55
|
+
b.stringLiteral("cloudflare_module"),
|
|
87
56
|
),
|
|
88
|
-
// hooks: {
|
|
89
|
-
// // Prevent the Pages preset from writing the _routes.json etc.
|
|
90
|
-
// compiled() {},
|
|
91
|
-
// },
|
|
92
57
|
b.objectProperty(
|
|
93
|
-
b.identifier("
|
|
94
|
-
b.
|
|
95
|
-
b.objectMethod(
|
|
96
|
-
"method",
|
|
97
|
-
b.identifier("compiled"),
|
|
98
|
-
[],
|
|
99
|
-
b.blockStatement([]),
|
|
100
|
-
false,
|
|
101
|
-
),
|
|
102
|
-
]),
|
|
58
|
+
b.identifier("compatibilityDate"),
|
|
59
|
+
b.stringLiteral(compatDate),
|
|
103
60
|
),
|
|
104
61
|
]),
|
|
105
62
|
),
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
4
|
compatibility_flags = ["nodejs_compat"]
|
|
5
|
-
main = "
|
|
6
|
-
assets = { directory = "
|
|
5
|
+
main = "./.output/server/index.mjs"
|
|
6
|
+
assets = { directory = "./.output/public", binding = "ASSETS" }
|
|
7
7
|
|
|
8
8
|
# Workers Logs
|
|
9
9
|
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
@@ -101,10 +101,7 @@ const config: TemplateConfig = {
|
|
|
101
101
|
displayName: "SvelteKit",
|
|
102
102
|
platform: "workers",
|
|
103
103
|
copyFiles: {
|
|
104
|
-
|
|
105
|
-
js: { path: "./js" },
|
|
106
|
-
ts: { path: "./ts" },
|
|
107
|
-
},
|
|
104
|
+
path: "./templates",
|
|
108
105
|
},
|
|
109
106
|
path: "templates-experimental/svelte",
|
|
110
107
|
generate,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { runFrameworkGenerator } from "frameworks/index";
|
|
2
|
+
import { detectPackageManager } from "helpers/packageManagers";
|
|
3
|
+
import type { TemplateConfig } from "../../src/templates";
|
|
4
|
+
import type { C3Context } from "types";
|
|
5
|
+
|
|
6
|
+
const { npm } = detectPackageManager();
|
|
7
|
+
|
|
8
|
+
const generate = async (ctx: C3Context) => {
|
|
9
|
+
await runFrameworkGenerator(ctx, [ctx.project.name]);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const config: TemplateConfig = {
|
|
13
|
+
configVersion: 1,
|
|
14
|
+
id: "vue",
|
|
15
|
+
frameworkCli: "create-vue",
|
|
16
|
+
platform: "workers",
|
|
17
|
+
displayName: "Vue",
|
|
18
|
+
copyFiles: {
|
|
19
|
+
path: "./templates",
|
|
20
|
+
},
|
|
21
|
+
path: "templates-experimental/vue",
|
|
22
|
+
generate,
|
|
23
|
+
transformPackageJson: async () => ({
|
|
24
|
+
scripts: {
|
|
25
|
+
deploy: `${npm} run build && wrangler deploy`,
|
|
26
|
+
preview: `${npm} run build && wrangler dev`,
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
devScript: "dev",
|
|
30
|
+
deployScript: "deploy",
|
|
31
|
+
previewScript: "preview",
|
|
32
|
+
};
|
|
33
|
+
export default config;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "<TBD>"
|
|
3
3
|
compatibility_date = "<TBD>"
|
|
4
|
-
|
|
5
|
-
assets = { directory = ".svelte-kit/cloudflare", binding = "ASSETS" }
|
|
4
|
+
assets = { directory = "./dist" }
|
|
6
5
|
|
|
7
6
|
# Workers Logs
|
|
8
7
|
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { renderApplication } from "@angular/platform-server";
|
|
2
|
-
import bootstrap from "./src/main.server";
|
|
3
|
-
|
|
4
|
-
interface Env {
|
|
5
|
-
ASSETS: { fetch: typeof fetch };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// We attach the Cloudflare `fetch()` handler to the global scope
|
|
9
|
-
// so that we can export it when we process the Angular output.
|
|
10
|
-
// See tools/bundle.mjs
|
|
11
|
-
async function workerFetchHandler(request: Request, env: Env) {
|
|
12
|
-
const url = new URL(request.url);
|
|
13
|
-
console.log("render SSR", url.href);
|
|
14
|
-
|
|
15
|
-
// Get the root `index.html` content.
|
|
16
|
-
const indexUrl = new URL("/", url);
|
|
17
|
-
const indexResponse = await env.ASSETS.fetch(new Request(indexUrl));
|
|
18
|
-
const document = await indexResponse.text();
|
|
19
|
-
|
|
20
|
-
const content = await renderApplication(bootstrap, {
|
|
21
|
-
document,
|
|
22
|
-
url: url.pathname,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// console.log("rendered SSR", content);
|
|
26
|
-
return new Response(content, indexResponse);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
fetch: (request: Request, env: Env) =>
|
|
31
|
-
(globalThis as any)["__zone_symbol__Promise"].resolve(
|
|
32
|
-
workerFetchHandler(request, env)
|
|
33
|
-
),
|
|
34
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { EOL } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { worker } from "./paths.mjs";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Split by lines and comment the banner
|
|
8
|
-
* ```
|
|
9
|
-
* import { createRequire } from 'node:module';
|
|
10
|
-
* globalThis['require'] ??= createRequire(import.meta.url);
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
const serverPolyfillsFile = join(worker, "polyfills.server.mjs");
|
|
14
|
-
const serverPolyfillsData = fs
|
|
15
|
-
.readFileSync(serverPolyfillsFile, "utf8")
|
|
16
|
-
.split(/\r?\n/);
|
|
17
|
-
|
|
18
|
-
for (let index = 0; index < 2; index++) {
|
|
19
|
-
if (serverPolyfillsData[index].includes("createRequire")) {
|
|
20
|
-
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Add needed polyfills
|
|
25
|
-
serverPolyfillsData.unshift(`globalThis['process'] = {};`);
|
|
26
|
-
|
|
27
|
-
fs.writeFileSync(serverPolyfillsFile, serverPolyfillsData.join(EOL));
|
|
@@ -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");
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { renderApplication } from "@angular/platform-server";
|
|
2
|
-
import bootstrap from "./src/main.server";
|
|
3
|
-
|
|
4
|
-
interface Env {
|
|
5
|
-
ASSETS: { fetch: typeof fetch };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// We attach the Cloudflare `fetch()` handler to the global scope
|
|
9
|
-
// so that we can export it when we process the Angular output.
|
|
10
|
-
// See tools/bundle.mjs
|
|
11
|
-
async function workerFetchHandler(request: Request, env: Env) {
|
|
12
|
-
const url = new URL(request.url);
|
|
13
|
-
console.log("render SSR", url.href);
|
|
14
|
-
|
|
15
|
-
// Get the root `index.html` content.
|
|
16
|
-
const indexUrl = new URL("/index.html", url);
|
|
17
|
-
const indexResponse = await env.ASSETS.fetch(new Request(indexUrl));
|
|
18
|
-
const document = await indexResponse.text();
|
|
19
|
-
|
|
20
|
-
const content = await renderApplication(bootstrap, {
|
|
21
|
-
document,
|
|
22
|
-
url: url.pathname,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// console.log("rendered SSR", content);
|
|
26
|
-
return new Response(content, indexResponse);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
fetch: (request: Request, env: Env) =>
|
|
31
|
-
(globalThis as any)["__zone_symbol__Promise"].resolve(
|
|
32
|
-
workerFetchHandler(request, env),
|
|
33
|
-
),
|
|
34
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { EOL } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Split by lines and comment the banner
|
|
10
|
-
* ```
|
|
11
|
-
* import { createRequire } from 'node:module';
|
|
12
|
-
* globalThis['require'] ??= createRequire(import.meta.url);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
const serverPolyfillsFile = join(
|
|
16
|
-
dirname,
|
|
17
|
-
"../dist/server/polyfills.server.mjs"
|
|
18
|
-
);
|
|
19
|
-
const serverPolyfillsData = fs
|
|
20
|
-
.readFileSync(serverPolyfillsFile, "utf8")
|
|
21
|
-
.split(/\r?\n/);
|
|
22
|
-
|
|
23
|
-
for (let index = 0; index < 2; index++) {
|
|
24
|
-
if (serverPolyfillsData[index].includes("createRequire")) {
|
|
25
|
-
serverPolyfillsData[index] = "// " + serverPolyfillsData[index];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Add needed polyfills
|
|
30
|
-
serverPolyfillsData.unshift(`globalThis['process'] = {};`);
|
|
31
|
-
|
|
32
|
-
fs.writeFileSync(serverPolyfillsFile, serverPolyfillsData.join(EOL));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type NitroPreset } from "nitropack";
|
|
2
|
-
|
|
3
|
-
export default <NitroPreset>{
|
|
4
|
-
extends: "cloudflare",
|
|
5
|
-
exportConditions: ["workerd"],
|
|
6
|
-
output: {
|
|
7
|
-
dir: "{{ rootDir }}/dist",
|
|
8
|
-
publicDir: "{{ output.dir }}/public",
|
|
9
|
-
serverDir: "{{ output.dir }}/worker",
|
|
10
|
-
},
|
|
11
|
-
commands: {
|
|
12
|
-
preview: "npx wrangler dev",
|
|
13
|
-
deploy: "npx wrangler deploy",
|
|
14
|
-
},
|
|
15
|
-
wasm: {
|
|
16
|
-
lazy: false,
|
|
17
|
-
esmImport: true,
|
|
18
|
-
},
|
|
19
|
-
rollupConfig: {
|
|
20
|
-
output: {
|
|
21
|
-
entryFileNames: "index.js",
|
|
22
|
-
format: "esm",
|
|
23
|
-
exports: "named",
|
|
24
|
-
inlineDynamicImports: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates-experimental/{svelte/js/static → astro/templates/ts/public}/.assetsignore
RENAMED
|
File without changes
|
/package/templates-experimental/astro/{snippets/runtimeDeclaration.ts → templates/ts/src/env.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|