create-cloudflare 2.32.1 → 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 +34 -15
- 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
|
@@ -67118,7 +67118,7 @@ var logRaw = (msg) => {
|
|
|
67118
67118
|
`);
|
|
67119
67119
|
};
|
|
67120
67120
|
var log = (msg) => {
|
|
67121
|
-
const lines = msg.split("\n").map((ln) => `${gray(shapes.bar)}
|
|
67121
|
+
const lines = msg.split("\n").map((ln) => `${gray(shapes.bar)}${ln.length > 0 ? " " + white(ln) : ""}`);
|
|
67122
67122
|
logRaw(lines.join("\n"));
|
|
67123
67123
|
};
|
|
67124
67124
|
var newline = () => {
|
|
@@ -68818,7 +68818,10 @@ var spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
|
|
|
68818
68818
|
start(msg, helpText) {
|
|
68819
68819
|
helpText ||= ``;
|
|
68820
68820
|
currentMsg = msg;
|
|
68821
|
-
startMsg =
|
|
68821
|
+
startMsg = currentMsg;
|
|
68822
|
+
if (helpText !== void 0 && helpText.length > 0) {
|
|
68823
|
+
startMsg += ` ${dim(helpText)}`;
|
|
68824
|
+
}
|
|
68822
68825
|
if (isInteractive()) {
|
|
68823
68826
|
let index = 0;
|
|
68824
68827
|
clearLoop();
|
|
@@ -68831,7 +68834,7 @@ var spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
|
|
|
68831
68834
|
}
|
|
68832
68835
|
}, frameRate);
|
|
68833
68836
|
} else {
|
|
68834
|
-
|
|
68837
|
+
logRaw(`${leftT} ${startMsg}`);
|
|
68835
68838
|
}
|
|
68836
68839
|
},
|
|
68837
68840
|
update(msg) {
|
|
@@ -68849,17 +68852,20 @@ ${grayBar} ${msg}`);
|
|
|
68849
68852
|
clearLoop();
|
|
68850
68853
|
} else {
|
|
68851
68854
|
if (msg !== void 0) {
|
|
68852
|
-
|
|
68853
|
-
${grayBar} ${msg}`);
|
|
68855
|
+
logRaw(`${grayBar} ${msg}`);
|
|
68854
68856
|
}
|
|
68855
68857
|
newline();
|
|
68856
68858
|
}
|
|
68857
68859
|
}
|
|
68858
68860
|
};
|
|
68859
68861
|
};
|
|
68860
|
-
|
|
68861
|
-
|
|
68862
|
-
|
|
68862
|
+
function isInteractive() {
|
|
68863
|
+
try {
|
|
68864
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
68865
|
+
} catch {
|
|
68866
|
+
return false;
|
|
68867
|
+
}
|
|
68868
|
+
}
|
|
68863
68869
|
|
|
68864
68870
|
// ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/lib/platform-shims/esm.mjs
|
|
68865
68871
|
var import_assert = require("assert");
|
|
@@ -73719,7 +73725,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
73719
73725
|
var yargs_default = Yargs;
|
|
73720
73726
|
|
|
73721
73727
|
// package.json
|
|
73722
|
-
var version = "2.
|
|
73728
|
+
var version = "2.33.0";
|
|
73723
73729
|
|
|
73724
73730
|
// src/metrics.ts
|
|
73725
73731
|
var import_node_async_hooks = require("node:async_hooks");
|
|
@@ -73999,7 +74005,7 @@ var detectPmMismatch = (ctx) => {
|
|
|
73999
74005
|
case "pnpm":
|
|
74000
74006
|
return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "pnpm-lock.yaml"));
|
|
74001
74007
|
case "bun":
|
|
74002
|
-
return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb"));
|
|
74008
|
+
return !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lockb")) && !(0, import_fs5.existsSync)(import_path5.default.join(projectPath, "bun.lock"));
|
|
74003
74009
|
}
|
|
74004
74010
|
};
|
|
74005
74011
|
|
|
@@ -74476,7 +74482,7 @@ var package_default = {
|
|
|
74476
74482
|
dependencies: {
|
|
74477
74483
|
"create-astro": "4.10.0",
|
|
74478
74484
|
"create-analog": "1.8.1",
|
|
74479
|
-
"@angular/create": "
|
|
74485
|
+
"@angular/create": "19.0.0",
|
|
74480
74486
|
"create-docusaurus": "3.6.1",
|
|
74481
74487
|
"create-hono": "0.14.2",
|
|
74482
74488
|
"create-next-app": "14.2.5",
|
|
@@ -75590,7 +75596,11 @@ var c3_default15 = config13;
|
|
|
75590
75596
|
var import_node_path4 = require("node:path");
|
|
75591
75597
|
var { npm: npm10 } = detectPackageManager();
|
|
75592
75598
|
var generate13 = async (ctx) => {
|
|
75593
|
-
await runFrameworkGenerator(ctx, [
|
|
75599
|
+
await runFrameworkGenerator(ctx, [
|
|
75600
|
+
ctx.project.name,
|
|
75601
|
+
"--ssr",
|
|
75602
|
+
"--server-routing"
|
|
75603
|
+
]);
|
|
75594
75604
|
logRaw("");
|
|
75595
75605
|
};
|
|
75596
75606
|
var configure10 = async (ctx) => {
|
|
@@ -75619,10 +75629,17 @@ async function updateAppCode2() {
|
|
|
75619
75629
|
);
|
|
75620
75630
|
writeFile2((0, import_node_path4.resolve)(appConfigPath), newAppConfig);
|
|
75621
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)}`);
|
|
75622
75640
|
s.start(`Updating package.json`);
|
|
75623
75641
|
const packageJsonPath = (0, import_node_path4.resolve)("package.json");
|
|
75624
75642
|
const packageManifest = readJSON(packageJsonPath);
|
|
75625
|
-
delete packageManifest["dependencies"]["@angular/ssr"];
|
|
75626
75643
|
delete packageManifest["dependencies"]["express"];
|
|
75627
75644
|
delete packageManifest["devDependencies"]["@types/express"];
|
|
75628
75645
|
writeFile2(packageJsonPath, JSON.stringify(packageManifest, null, 2));
|
|
@@ -75634,6 +75651,8 @@ function updateAngularJson2(ctx) {
|
|
|
75634
75651
|
const angularJson = readJSON((0, import_node_path4.resolve)("angular.json"));
|
|
75635
75652
|
const architectSection = angularJson.projects[ctx.project.name].architect;
|
|
75636
75653
|
architectSection.build.options.outputPath = "dist";
|
|
75654
|
+
architectSection.build.options.outputMode = "server";
|
|
75655
|
+
architectSection.build.options.ssr.experimentalPlatform = "neutral";
|
|
75637
75656
|
architectSection.build.options.assets.push("src/_routes.json");
|
|
75638
75657
|
writeFile2((0, import_node_path4.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
|
|
75639
75658
|
s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
|
|
@@ -75655,7 +75674,7 @@ var config14 = {
|
|
|
75655
75674
|
scripts: {
|
|
75656
75675
|
start: `${npm10} run build && wrangler pages dev dist/cloudflare ${await compatDateFlag()} --experimental-local`,
|
|
75657
75676
|
build: `ng build && ${npm10} run process`,
|
|
75658
|
-
process: "node ./tools/copy-files.mjs
|
|
75677
|
+
process: "node ./tools/copy-files.mjs",
|
|
75659
75678
|
deploy: `${npm10} run build && wrangler pages deploy dist/cloudflare`
|
|
75660
75679
|
}
|
|
75661
75680
|
})
|
|
@@ -76831,7 +76850,7 @@ var config25 = {
|
|
|
76831
76850
|
var c3_default35 = config25;
|
|
76832
76851
|
|
|
76833
76852
|
// ../wrangler/package.json
|
|
76834
|
-
var version2 = "3.
|
|
76853
|
+
var version2 = "3.90.0";
|
|
76835
76854
|
|
|
76836
76855
|
// src/git.ts
|
|
76837
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",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"xdg-app-paths": "^8.3.0",
|
|
68
68
|
"yargs": "^17.7.2",
|
|
69
69
|
"@cloudflare/cli": "1.1.1",
|
|
70
|
-
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
71
70
|
"@cloudflare/eslint-config-worker": "1.1.0",
|
|
72
|
-
"wrangler": "3.
|
|
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");
|