@cedarjs/cli 1.0.0-canary.13124 → 1.0.0-canary.13126
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/commands/generate/package/templates/README.md.template +1 -1
- package/dist/commands/generate/package/templates/package.json.template +7 -0
- package/dist/commands/generate/package/templates/tsconfig.json.template +1 -0
- package/package.json +11 -11
- package/dist/commands/buildHandler.js +0 -180
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"build": "tsc",
|
|
9
16
|
"watch": "tsc --watch"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.13126+03db3fb39",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "7.28.5",
|
|
34
34
|
"@babel/runtime-corejs3": "7.28.4",
|
|
35
|
-
"@cedarjs/api-server": "1.0.0-canary.
|
|
36
|
-
"@cedarjs/cli-helpers": "1.0.0-canary.
|
|
37
|
-
"@cedarjs/fastify-web": "1.0.0-canary.
|
|
38
|
-
"@cedarjs/internal": "1.0.0-canary.
|
|
39
|
-
"@cedarjs/prerender": "1.0.0-canary.
|
|
40
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
41
|
-
"@cedarjs/structure": "1.0.0-canary.
|
|
42
|
-
"@cedarjs/telemetry": "1.0.0-canary.
|
|
43
|
-
"@cedarjs/web-server": "1.0.0-canary.
|
|
35
|
+
"@cedarjs/api-server": "1.0.0-canary.13126",
|
|
36
|
+
"@cedarjs/cli-helpers": "1.0.0-canary.13126",
|
|
37
|
+
"@cedarjs/fastify-web": "1.0.0-canary.13126",
|
|
38
|
+
"@cedarjs/internal": "1.0.0-canary.13126",
|
|
39
|
+
"@cedarjs/prerender": "1.0.0-canary.13126",
|
|
40
|
+
"@cedarjs/project-config": "1.0.0-canary.13126",
|
|
41
|
+
"@cedarjs/structure": "1.0.0-canary.13126",
|
|
42
|
+
"@cedarjs/telemetry": "1.0.0-canary.13126",
|
|
43
|
+
"@cedarjs/web-server": "1.0.0-canary.13126",
|
|
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": "03db3fb397b7e0cc00899fbec2d1ad522fb81317"
|
|
106
106
|
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import concurrently from "concurrently";
|
|
5
|
-
import execa from "execa";
|
|
6
|
-
import { Listr } from "listr2";
|
|
7
|
-
import { terminalLink } from "termi-link";
|
|
8
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
9
|
-
import { buildApi, cleanApiBuild } from "@cedarjs/internal/dist/build/api";
|
|
10
|
-
import { generate } from "@cedarjs/internal/dist/generate/generate";
|
|
11
|
-
import { loadAndValidateSdls } from "@cedarjs/internal/dist/validateSchema";
|
|
12
|
-
import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
|
|
13
|
-
import { timedTelemetry, errorTelemetry } from "@cedarjs/telemetry";
|
|
14
|
-
import { exitWithError } from "../lib/exit.js";
|
|
15
|
-
import { generatePrismaCommand } from "../lib/generatePrismaClient.js";
|
|
16
|
-
import { getPaths, getConfig } from "../lib/index.js";
|
|
17
|
-
const handler = async ({
|
|
18
|
-
workspace = ["api", "web", "packages/*"],
|
|
19
|
-
verbose = false,
|
|
20
|
-
prisma = true,
|
|
21
|
-
prerender = true
|
|
22
|
-
}) => {
|
|
23
|
-
recordTelemetryAttributes({
|
|
24
|
-
command: "build",
|
|
25
|
-
workspace: JSON.stringify(workspace),
|
|
26
|
-
verbose,
|
|
27
|
-
prisma,
|
|
28
|
-
prerender
|
|
29
|
-
});
|
|
30
|
-
const cedarPaths = getPaths();
|
|
31
|
-
const cedarConfig = getConfig();
|
|
32
|
-
const useFragments = cedarConfig.graphql?.fragments;
|
|
33
|
-
const useTrustedDocuments = cedarConfig.graphql?.trustedDocuments;
|
|
34
|
-
const prismaSchemaExists = fs.existsSync(cedarPaths.api.prismaConfig);
|
|
35
|
-
const prerenderRoutes = prerender && workspace.includes("web") ? detectPrerenderRoutes() : [];
|
|
36
|
-
const shouldGeneratePrismaClient = prisma && prismaSchemaExists && (workspace.includes("api") || prerenderRoutes.length > 0);
|
|
37
|
-
const packageJsonPath = path.join(cedarPaths.base, "package.json");
|
|
38
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
39
|
-
const packageJsonWorkspaces = packageJson.workspaces;
|
|
40
|
-
const restWorkspaces = Array.isArray(packageJsonWorkspaces) && packageJsonWorkspaces.length > 2 ? workspace.filter((w) => w !== "api" && w !== "web") : [];
|
|
41
|
-
const gqlFeaturesTaskTitle = `Generating types needed for ${[
|
|
42
|
-
useFragments && "GraphQL Fragments",
|
|
43
|
-
useTrustedDocuments && "Trusted Documents"
|
|
44
|
-
].filter(Boolean).join(" and ")} support...`;
|
|
45
|
-
const tasks = [
|
|
46
|
-
shouldGeneratePrismaClient && {
|
|
47
|
-
title: "Generating Prisma Client...",
|
|
48
|
-
task: async () => {
|
|
49
|
-
const { cmd, args } = await generatePrismaCommand();
|
|
50
|
-
return execa(cmd, args, {
|
|
51
|
-
stdio: verbose ? "inherit" : "pipe",
|
|
52
|
-
cwd: cedarPaths.api.base
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
restWorkspaces.length > 0 && {
|
|
57
|
-
title: "Building Packages...",
|
|
58
|
-
task: async () => {
|
|
59
|
-
const globPattern = path.join(cedarPaths.packages, "*").replaceAll("\\", "/");
|
|
60
|
-
const allPackagePaths = await Array.fromAsync(
|
|
61
|
-
fs.promises.glob(globPattern)
|
|
62
|
-
);
|
|
63
|
-
const workspacePaths = restWorkspaces.some((w) => w === "packages/*") ? allPackagePaths : restWorkspaces.map((w) => {
|
|
64
|
-
const workspacePath = path.join(
|
|
65
|
-
cedarPaths.packages,
|
|
66
|
-
w.split("/").at(-1)
|
|
67
|
-
);
|
|
68
|
-
if (!fs.existsSync(workspacePath)) {
|
|
69
|
-
throw new Error(`Workspace not found: ${workspacePath}`);
|
|
70
|
-
}
|
|
71
|
-
return workspacePath;
|
|
72
|
-
});
|
|
73
|
-
const { result } = concurrently(
|
|
74
|
-
workspacePaths.map((workspacePath) => {
|
|
75
|
-
return {
|
|
76
|
-
command: `yarn build`,
|
|
77
|
-
name: workspacePath.split("/").at(-1),
|
|
78
|
-
cwd: workspacePath
|
|
79
|
-
};
|
|
80
|
-
}),
|
|
81
|
-
{
|
|
82
|
-
prefix: "{name} |",
|
|
83
|
-
timestampFormat: "HH:mm:ss"
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
await result.catch((e) => {
|
|
87
|
-
if (e?.message) {
|
|
88
|
-
errorTelemetry(
|
|
89
|
-
process.argv,
|
|
90
|
-
`Error concurrently building sides: ${e.message}`
|
|
91
|
-
);
|
|
92
|
-
exitWithError(e);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
// If using GraphQL Fragments or Trusted Documents, then we need to use
|
|
98
|
-
// codegen to generate the types needed for possible types and the trusted
|
|
99
|
-
// document store hashes
|
|
100
|
-
(useFragments || useTrustedDocuments) && {
|
|
101
|
-
title: gqlFeaturesTaskTitle,
|
|
102
|
-
task: generate
|
|
103
|
-
},
|
|
104
|
-
workspace.includes("api") && {
|
|
105
|
-
title: "Verifying graphql schema...",
|
|
106
|
-
task: loadAndValidateSdls
|
|
107
|
-
},
|
|
108
|
-
workspace.includes("api") && {
|
|
109
|
-
title: "Building API...",
|
|
110
|
-
task: async () => {
|
|
111
|
-
await cleanApiBuild();
|
|
112
|
-
const { errors, warnings } = await buildApi();
|
|
113
|
-
if (errors.length) {
|
|
114
|
-
console.error(errors);
|
|
115
|
-
}
|
|
116
|
-
if (warnings.length) {
|
|
117
|
-
console.warn(warnings);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
workspace.includes("web") && {
|
|
122
|
-
title: "Building Web...",
|
|
123
|
-
task: async () => {
|
|
124
|
-
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
125
|
-
const createdRequire = createRequire(import.meta.url);
|
|
126
|
-
const buildBinPath = createdRequire.resolve(
|
|
127
|
-
"@cedarjs/vite/bins/rw-vite-build.mjs"
|
|
128
|
-
);
|
|
129
|
-
await execa(
|
|
130
|
-
`node ${buildBinPath} --webDir="${cedarPaths.web.base}" --verbose=${verbose}`,
|
|
131
|
-
{
|
|
132
|
-
stdio: verbose ? "inherit" : "pipe",
|
|
133
|
-
shell: true,
|
|
134
|
-
// `cwd` is needed for yarn to find the rw-vite-build binary
|
|
135
|
-
// It won't change process.cwd for anything else here, in this
|
|
136
|
-
// process
|
|
137
|
-
cwd: cedarPaths.web.base
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
if (!getConfig().experimental?.streamingSsr?.enabled) {
|
|
141
|
-
console.log("Creating 200.html...");
|
|
142
|
-
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
143
|
-
fs.copyFileSync(
|
|
144
|
-
indexHtmlPath,
|
|
145
|
-
path.join(getPaths().web.dist, "200.html")
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
].filter(Boolean);
|
|
151
|
-
const triggerPrerender = async () => {
|
|
152
|
-
console.log("Starting prerendering...");
|
|
153
|
-
if (prerenderRoutes.length === 0) {
|
|
154
|
-
console.log(
|
|
155
|
-
`You have not marked any routes to "prerender" in your ${terminalLink(
|
|
156
|
-
"Routes",
|
|
157
|
-
"file://" + cedarPaths.web.routes
|
|
158
|
-
)}.`
|
|
159
|
-
);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
await execa("yarn cedar prerender", {
|
|
163
|
-
stdio: "inherit",
|
|
164
|
-
shell: true,
|
|
165
|
-
cwd: cedarPaths.web.base
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
const jobs = new Listr(tasks, {
|
|
169
|
-
renderer: verbose ? "verbose" : void 0
|
|
170
|
-
});
|
|
171
|
-
await timedTelemetry(process.argv, { type: "build" }, async () => {
|
|
172
|
-
await jobs.run();
|
|
173
|
-
if (workspace.includes("web") && prerender && prismaSchemaExists) {
|
|
174
|
-
await triggerPrerender();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
export {
|
|
179
|
-
handler
|
|
180
|
-
};
|