create-cloudflare 2.32.2 → 2.33.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 +19 -6
- package/package.json +3 -3
- package/templates/angular/c3.ts +18 -4
- package/templates/angular/templates/src/server.ts +15 -0
- package/templates/angular/templates/tools/copy-files.mjs +8 -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/dist/cli.js
CHANGED
|
@@ -73725,7 +73725,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
73725
73725
|
var yargs_default = Yargs;
|
|
73726
73726
|
|
|
73727
73727
|
// package.json
|
|
73728
|
-
var version = "2.
|
|
73728
|
+
var version = "2.33.0";
|
|
73729
73729
|
|
|
73730
73730
|
// src/metrics.ts
|
|
73731
73731
|
var import_node_async_hooks = require("node:async_hooks");
|
|
@@ -74482,7 +74482,7 @@ var package_default = {
|
|
|
74482
74482
|
dependencies: {
|
|
74483
74483
|
"create-astro": "4.10.0",
|
|
74484
74484
|
"create-analog": "1.8.1",
|
|
74485
|
-
"@angular/create": "
|
|
74485
|
+
"@angular/create": "19.0.0",
|
|
74486
74486
|
"create-docusaurus": "3.6.1",
|
|
74487
74487
|
"create-hono": "0.14.2",
|
|
74488
74488
|
"create-next-app": "14.2.5",
|
|
@@ -75596,7 +75596,11 @@ var c3_default15 = config13;
|
|
|
75596
75596
|
var import_node_path4 = require("node:path");
|
|
75597
75597
|
var { npm: npm10 } = detectPackageManager();
|
|
75598
75598
|
var generate13 = async (ctx) => {
|
|
75599
|
-
await runFrameworkGenerator(ctx, [
|
|
75599
|
+
await runFrameworkGenerator(ctx, [
|
|
75600
|
+
ctx.project.name,
|
|
75601
|
+
"--ssr",
|
|
75602
|
+
"--server-routing"
|
|
75603
|
+
]);
|
|
75600
75604
|
logRaw("");
|
|
75601
75605
|
};
|
|
75602
75606
|
var configure10 = async (ctx) => {
|
|
@@ -75625,10 +75629,17 @@ async function updateAppCode2() {
|
|
|
75625
75629
|
);
|
|
75626
75630
|
writeFile2((0, import_node_path4.resolve)(appConfigPath), newAppConfig);
|
|
75627
75631
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
|
75632
|
+
const appServerRoutesPath = "src/app/app.routes.server.ts";
|
|
75633
|
+
const appRoutes = readFile((0, import_node_path4.resolve)(appServerRoutesPath));
|
|
75634
|
+
const newAppRoutes = appRoutes.replace(
|
|
75635
|
+
"RenderMode.Prerender",
|
|
75636
|
+
"RenderMode.Server"
|
|
75637
|
+
);
|
|
75638
|
+
writeFile2((0, import_node_path4.resolve)(appServerRoutesPath), newAppRoutes);
|
|
75639
|
+
s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
|
|
75628
75640
|
s.start(`Updating package.json`);
|
|
75629
75641
|
const packageJsonPath = (0, import_node_path4.resolve)("package.json");
|
|
75630
75642
|
const packageManifest = readJSON(packageJsonPath);
|
|
75631
|
-
delete packageManifest["dependencies"]["@angular/ssr"];
|
|
75632
75643
|
delete packageManifest["dependencies"]["express"];
|
|
75633
75644
|
delete packageManifest["devDependencies"]["@types/express"];
|
|
75634
75645
|
writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
|
|
@@ -75640,6 +75651,8 @@ function updateAngularJson2(ctx) {
|
|
|
75640
75651
|
const angularJson = readJSON((0, import_node_path4.resolve)("angular.json"));
|
|
75641
75652
|
const architectSection = angularJson.projects[ctx.project.name].architect;
|
|
75642
75653
|
architectSection.build.options.outputPath = "dist";
|
|
75654
|
+
architectSection.build.options.outputMode = "server";
|
|
75655
|
+
architectSection.build.options.ssr.experimentalPlatform = "neutral";
|
|
75643
75656
|
architectSection.build.options.assets.push("src/_routes.json");
|
|
75644
75657
|
writeFile2((0, import_node_path4.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
|
|
75645
75658
|
s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
|
|
@@ -75661,7 +75674,7 @@ var config14 = {
|
|
|
75661
75674
|
scripts: {
|
|
75662
75675
|
start: `${npm10} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
|
|
75663
75676
|
build: `ng build && ${npm10} run process`,
|
|
75664
|
-
process: "node ./tools/copy-files.mjs
|
|
75677
|
+
process: "node ./tools/copy-files.mjs",
|
|
75665
75678
|
deploy: `${npm10} run build && wrangler pages deploy dist/cloudflare`
|
|
75666
75679
|
}
|
|
75667
75680
|
})
|
|
@@ -76837,7 +76850,7 @@ var config25 = {
|
|
|
76837
76850
|
var c3_default35 = config25;
|
|
76838
76851
|
|
|
76839
76852
|
// ../wrangler/package.json
|
|
76840
|
-
var version2 = "3.
|
|
76853
|
+
var version2 = "3.90.0";
|
|
76841
76854
|
|
|
76842
76855
|
// src/git.ts
|
|
76843
76856
|
var offerGit = async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cloudflare",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "A CLI for creating and deploying new applications to Cloudflare.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"yargs": "^17.7.2",
|
|
69
69
|
"@cloudflare/cli": "1.1.1",
|
|
70
70
|
"@cloudflare/eslint-config-worker": "1.1.0",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
71
|
+
"wrangler": "3.90.0",
|
|
72
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=18.14.1"
|
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
|
|
|
@@ -50,12 +54,21 @@ async function updateAppCode() {
|
|
|
50
54
|
writeFile(resolve(appConfigPath), newAppConfig);
|
|
51
55
|
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
|
|
52
56
|
|
|
57
|
+
// Update an app server routes file to:
|
|
58
|
+
const appServerRoutesPath = "src/app/app.routes.server.ts";
|
|
59
|
+
const appRoutes = readFile(resolve(appServerRoutesPath));
|
|
60
|
+
const newAppRoutes = appRoutes.replace(
|
|
61
|
+
"RenderMode.Prerender",
|
|
62
|
+
"RenderMode.Server",
|
|
63
|
+
);
|
|
64
|
+
writeFile(resolve(appServerRoutesPath), newAppRoutes);
|
|
65
|
+
s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
|
|
66
|
+
|
|
53
67
|
// Remove unwanted dependencies
|
|
54
68
|
s.start(`Updating package.json`);
|
|
55
69
|
const packageJsonPath = resolve("package.json");
|
|
56
70
|
const packageManifest = readJSON(packageJsonPath);
|
|
57
71
|
|
|
58
|
-
delete packageManifest["dependencies"]["@angular/ssr"];
|
|
59
72
|
delete packageManifest["dependencies"]["express"];
|
|
60
73
|
delete packageManifest["devDependencies"]["@types/express"];
|
|
61
74
|
|
|
@@ -70,6 +83,8 @@ function updateAngularJson(ctx: C3Context) {
|
|
|
70
83
|
// Update builder
|
|
71
84
|
const architectSection = angularJson.projects[ctx.project.name].architect;
|
|
72
85
|
architectSection.build.options.outputPath = "dist";
|
|
86
|
+
architectSection.build.options.outputMode = "server";
|
|
87
|
+
architectSection.build.options.ssr.experimentalPlatform = "neutral";
|
|
73
88
|
architectSection.build.options.assets.push("src/_routes.json");
|
|
74
89
|
|
|
75
90
|
writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
|
|
@@ -93,8 +108,7 @@ const config: TemplateConfig = {
|
|
|
93
108
|
scripts: {
|
|
94
109
|
start: `${npm} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
|
|
95
110
|
build: `ng build && ${npm} run process`,
|
|
96
|
-
process:
|
|
97
|
-
"node ./tools/copy-files.mjs && node ./tools/alter-polyfills.mjs",
|
|
111
|
+
process: "node ./tools/copy-files.mjs",
|
|
98
112
|
deploy: `${npm} run build && wrangler pages deploy dist/cloudflare`,
|
|
99
113
|
},
|
|
100
114
|
}),
|
|
@@ -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.render(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 });
|
|
@@ -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");
|