@cedarjs/cli 0.9.1-next.21 → 0.9.1-next.23
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.
|
@@ -2,9 +2,7 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
-
import {
|
|
6
|
-
import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
|
|
7
|
-
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
5
|
+
import { getConfig, getPaths, projectIsEsm } from "@cedarjs/project-config";
|
|
8
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
7
|
import c from "../lib/colors.js";
|
|
10
8
|
import { runScriptFunction } from "../lib/exec.js";
|
|
@@ -70,7 +68,8 @@ async function expandRouteParameters(route) {
|
|
|
70
68
|
return [route];
|
|
71
69
|
}
|
|
72
70
|
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
73
|
-
const
|
|
71
|
+
const detector = projectIsEsm() ? await import("@cedarjs/prerender/detection") : await import("@cedarjs/prerender/cjs/detection");
|
|
72
|
+
const prerenderRoutes = detector.detectPrerenderRoutes().filter((route) => route.path);
|
|
74
73
|
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
75
74
|
if (prerenderRoutes.length === 0) {
|
|
76
75
|
console.log("\nSkipping prerender...");
|
|
@@ -91,6 +90,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
91
90
|
const expandedRouteParameters = await Promise.all(
|
|
92
91
|
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
93
92
|
);
|
|
93
|
+
const prerenderer = projectIsEsm() ? await import("@cedarjs/prerender") : await import("@cedarjs/prerender/cjs");
|
|
94
94
|
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
95
95
|
const queryCache = {};
|
|
96
96
|
const shouldFold = routesToPrerender.length > 16;
|
|
@@ -110,6 +110,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
112
|
await prerenderRoute(
|
|
113
|
+
prerenderer,
|
|
113
114
|
queryCache,
|
|
114
115
|
routeToPrerender,
|
|
115
116
|
dryrun,
|
|
@@ -133,6 +134,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
133
134
|
title: `Prerendering ${routeToPrerender.path} -> ${outputHtmlPath}`,
|
|
134
135
|
task: async () => {
|
|
135
136
|
await prerenderRoute(
|
|
137
|
+
prerenderer,
|
|
136
138
|
queryCache,
|
|
137
139
|
routeToPrerender,
|
|
138
140
|
dryrun,
|
|
@@ -194,19 +196,19 @@ const diagnosticCheck = () => {
|
|
|
194
196
|
console.log("\u2714 Diagnostics checks passed \n");
|
|
195
197
|
}
|
|
196
198
|
};
|
|
197
|
-
const prerenderRoute = async (queryCache, routeToPrerender, dryrun, outputHtmlPath) => {
|
|
199
|
+
const prerenderRoute = async (prerenderer, queryCache, routeToPrerender, dryrun, outputHtmlPath) => {
|
|
198
200
|
if (/\{.*}/.test(routeToPrerender.path)) {
|
|
199
201
|
throw new PathParamError(
|
|
200
202
|
`Could not retrieve route parameters for ${routeToPrerender.path}`
|
|
201
203
|
);
|
|
202
204
|
}
|
|
203
205
|
try {
|
|
204
|
-
const prerenderedHtml = await runPrerender({
|
|
206
|
+
const prerenderedHtml = await prerenderer.runPrerender({
|
|
205
207
|
queryCache,
|
|
206
208
|
renderPath: routeToPrerender.path
|
|
207
209
|
});
|
|
208
210
|
if (!dryrun) {
|
|
209
|
-
writePrerenderedHtmlFile(outputHtmlPath, prerenderedHtml);
|
|
211
|
+
prerenderer.writePrerenderedHtmlFile(outputHtmlPath, prerenderedHtml);
|
|
210
212
|
}
|
|
211
213
|
} catch (e) {
|
|
212
214
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "0.9.1-next.
|
|
3
|
+
"version": "0.9.1-next.23+f994b4719",
|
|
4
4
|
"description": "The Redwood Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "7.27.1",
|
|
34
34
|
"@babel/runtime-corejs3": "7.27.6",
|
|
35
|
-
"@cedarjs/api-server": "0.9.1-next.
|
|
36
|
-
"@cedarjs/cli-helpers": "0.9.1-next.
|
|
37
|
-
"@cedarjs/fastify-web": "0.9.1-next.
|
|
38
|
-
"@cedarjs/internal": "0.9.1-next.
|
|
39
|
-
"@cedarjs/prerender": "0.9.1-next.
|
|
40
|
-
"@cedarjs/project-config": "0.9.1-next.
|
|
41
|
-
"@cedarjs/structure": "0.9.1-next.
|
|
42
|
-
"@cedarjs/telemetry": "0.9.1-next.
|
|
43
|
-
"@cedarjs/web-server": "0.9.1-next.
|
|
35
|
+
"@cedarjs/api-server": "0.9.1-next.23+f994b4719",
|
|
36
|
+
"@cedarjs/cli-helpers": "0.9.1-next.23+f994b4719",
|
|
37
|
+
"@cedarjs/fastify-web": "0.9.1-next.23+f994b4719",
|
|
38
|
+
"@cedarjs/internal": "0.9.1-next.23+f994b4719",
|
|
39
|
+
"@cedarjs/prerender": "0.9.1-next.23+f994b4719",
|
|
40
|
+
"@cedarjs/project-config": "0.9.1-next.23+f994b4719",
|
|
41
|
+
"@cedarjs/structure": "0.9.1-next.23+f994b4719",
|
|
42
|
+
"@cedarjs/telemetry": "0.9.1-next.23+f994b4719",
|
|
43
|
+
"@cedarjs/web-server": "0.9.1-next.23+f994b4719",
|
|
44
44
|
"@listr2/prompt-adapter-enquirer": "2.0.16",
|
|
45
45
|
"@opentelemetry/api": "1.8.0",
|
|
46
46
|
"@opentelemetry/core": "1.22.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "f994b471993683ea2bdfab8d339b3e26c4d25c20"
|
|
106
106
|
}
|