@cedarjs/cli 3.0.0-canary.13548 → 3.0.0-canary.13549
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/build.js +2 -1
- package/dist/commands/generate.js +8 -1
- package/dist/commands/jobsHandler.js +4 -2
- package/dist/commands/prerenderHandler.js +56 -25
- package/dist/commands/prismaHandler.js +41 -18
- package/dist/commands/testHandler.js +34 -27
- package/dist/commands/testHandlerEsm.js +25 -17
- package/dist/commands/type-checkHandler.js +19 -9
- package/package.json +12 -12
package/dist/commands/build.js
CHANGED
|
@@ -9,7 +9,8 @@ const builder = (yargs) => {
|
|
|
9
9
|
yargs.positional("workspace", {
|
|
10
10
|
default: ["api", "web", "packages/*"],
|
|
11
11
|
description: "What workspace(s) to build. Valid values are: web, api, packages/*, <package-name>",
|
|
12
|
-
type: "
|
|
12
|
+
type: "string",
|
|
13
|
+
array: true
|
|
13
14
|
}).option("verbose", {
|
|
14
15
|
alias: "v",
|
|
15
16
|
default: false,
|
|
@@ -22,12 +22,19 @@ import * as generateService from "./generate/service/service.js";
|
|
|
22
22
|
const command = "generate <type>";
|
|
23
23
|
const aliases = ["g"];
|
|
24
24
|
const description = "Generate boilerplate code and type definitions";
|
|
25
|
+
const getExitCode = (error) => {
|
|
26
|
+
if (typeof error !== "object" || error === null) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
const exitCode = Reflect.get(error, "exitCode");
|
|
30
|
+
return typeof exitCode === "number" ? exitCode : void 0;
|
|
31
|
+
};
|
|
25
32
|
const builder = (yargs) => yargs.command("types", "Generate supplementary code", {}, () => {
|
|
26
33
|
recordTelemetryAttributes({ command: "generate types" });
|
|
27
34
|
try {
|
|
28
35
|
execa.sync("yarn", ["rw-gen"], { stdio: "inherit" });
|
|
29
36
|
} catch (error) {
|
|
30
|
-
process.exitCode = error
|
|
37
|
+
process.exitCode = getExitCode(error) ?? 1;
|
|
31
38
|
}
|
|
32
39
|
}).command(generateCell).command(generateComponent).command(generateDataMigration).command(generateDbAuth).command(generateDirective).command(generateFunction).command(generateJob).command(generateLayout).command(generateModel).command(generateOgImage).command(generatePackage).command(generatePage).command(generateRealtime).command(generateScaffold).command(generateScript).command(generateSdl).command(generateSecret).command(generateService).demandCommand().epilogue(
|
|
33
40
|
`Also see the ${terminalLink(
|
|
@@ -6,10 +6,12 @@ const handler = async ({
|
|
|
6
6
|
commands: _commands,
|
|
7
7
|
...options
|
|
8
8
|
}) => {
|
|
9
|
-
const
|
|
9
|
+
const positionalArgs = Array.isArray(_) ? [..._] : [];
|
|
10
|
+
const commandArg = positionalArgs.pop();
|
|
11
|
+
const args = [commandArg == null ? "" : String(commandArg)];
|
|
10
12
|
for (const [name, value] of Object.entries(options)) {
|
|
11
13
|
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
12
|
-
args.push(value);
|
|
14
|
+
args.push(String(value));
|
|
13
15
|
}
|
|
14
16
|
let command = `yarn rw-jobs ${args.join(" ")}`;
|
|
15
17
|
const originalLogLevel = process.env.LOG_LEVEL;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { getConfig, getPaths, projectIsEsm } from "@cedarjs/project-config";
|
|
@@ -9,12 +9,33 @@ import { runScriptFunction } from "../lib/exec.js";
|
|
|
9
9
|
import { configureBabel } from "../lib/execBabel.js";
|
|
10
10
|
class PathParamError extends Error {
|
|
11
11
|
}
|
|
12
|
+
const hasPath = (route) => {
|
|
13
|
+
return typeof route.path === "string" && route.path.length > 0;
|
|
14
|
+
};
|
|
15
|
+
const normalizeRoute = (route) => {
|
|
16
|
+
const normalizedPath = route.path;
|
|
17
|
+
const normalizedName = typeof route.name === "string" ? route.name : normalizedPath;
|
|
18
|
+
const normalizedRoutePath = typeof route.routePath === "string" ? route.routePath : normalizedPath;
|
|
19
|
+
const normalizedFilePath = typeof route.filePath === "string" ? route.filePath : "";
|
|
20
|
+
return {
|
|
21
|
+
...route,
|
|
22
|
+
name: normalizedName,
|
|
23
|
+
path: normalizedPath,
|
|
24
|
+
routePath: normalizedRoutePath,
|
|
25
|
+
filePath: normalizedFilePath
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const getErrorMessage = (error) => {
|
|
29
|
+
return error instanceof Error ? error.message : String(error);
|
|
30
|
+
};
|
|
31
|
+
const getErrorStack = (error) => {
|
|
32
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
33
|
+
};
|
|
12
34
|
const mapRouterPathToHtml = (routerPath) => {
|
|
13
35
|
if (routerPath === "/") {
|
|
14
36
|
return "web/dist/index.html";
|
|
15
|
-
} else {
|
|
16
|
-
return `web/dist${routerPath}.html`;
|
|
17
37
|
}
|
|
38
|
+
return `web/dist${routerPath}.html`;
|
|
18
39
|
};
|
|
19
40
|
function getRouteHooksFilePath(routeFilePath) {
|
|
20
41
|
const routeHooksFilePathTs = routeFilePath.replace(
|
|
@@ -49,27 +70,32 @@ async function expandRouteParameters(route) {
|
|
|
49
70
|
filePath: route.filePath
|
|
50
71
|
}
|
|
51
72
|
});
|
|
52
|
-
if (routeParameters) {
|
|
73
|
+
if (Array.isArray(routeParameters)) {
|
|
53
74
|
return routeParameters.map((pathParamValues) => {
|
|
54
75
|
let newPath = route.path;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
if (typeof pathParamValues === "object" && pathParamValues !== null && !Array.isArray(pathParamValues)) {
|
|
77
|
+
Object.entries(pathParamValues).forEach(
|
|
78
|
+
([paramName, paramValue]) => {
|
|
79
|
+
newPath = newPath.replace(
|
|
80
|
+
new RegExp(`{${paramName}:?[^}]*}`),
|
|
81
|
+
String(paramValue)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
59
84
|
);
|
|
60
|
-
}
|
|
85
|
+
}
|
|
61
86
|
return { ...route, path: newPath };
|
|
62
87
|
});
|
|
63
88
|
}
|
|
64
|
-
} catch (
|
|
65
|
-
console.error(c.error(
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error(c.error(getErrorStack(error)));
|
|
66
91
|
return [route];
|
|
67
92
|
}
|
|
68
93
|
return [route];
|
|
69
94
|
}
|
|
70
95
|
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
71
96
|
const detector = projectIsEsm() ? await import("@cedarjs/prerender/detection") : await import("@cedarjs/prerender/cjs/detection");
|
|
72
|
-
const
|
|
97
|
+
const detectedRoutes = detector.detectPrerenderRoutes();
|
|
98
|
+
const prerenderRoutes = detectedRoutes.filter(hasPath).map(normalizeRoute);
|
|
73
99
|
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
74
100
|
if (prerenderRoutes.length === 0) {
|
|
75
101
|
console.log("\nSkipping prerender...");
|
|
@@ -103,7 +129,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
103
129
|
return [
|
|
104
130
|
{
|
|
105
131
|
title: title(0),
|
|
106
|
-
task: async (
|
|
132
|
+
task: async (_ctx, task) => {
|
|
107
133
|
for (let i = 0; i < routesToPrerender.length; i++) {
|
|
108
134
|
const routeToPrerender = routesToPrerender[i];
|
|
109
135
|
if (routerPathFilter && routeToPrerender.path !== routerPathFilter) {
|
|
@@ -125,7 +151,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
125
151
|
}
|
|
126
152
|
];
|
|
127
153
|
}
|
|
128
|
-
return routesToPrerender.
|
|
154
|
+
return routesToPrerender.flatMap((routeToPrerender) => {
|
|
129
155
|
if (routerPathFilter && routeToPrerender.path !== routerPathFilter) {
|
|
130
156
|
return [];
|
|
131
157
|
}
|
|
@@ -174,7 +200,7 @@ const diagnosticCheck = () => {
|
|
|
174
200
|
}
|
|
175
201
|
];
|
|
176
202
|
console.log("Running diagnostic checks");
|
|
177
|
-
if (checks.some((
|
|
203
|
+
if (checks.some((check) => check.failure)) {
|
|
178
204
|
console.error(c.error("node_modules are being duplicated in `./web` \n"));
|
|
179
205
|
console.log("\u26A0\uFE0F Issues found: ");
|
|
180
206
|
console.log("-".repeat(50));
|
|
@@ -210,7 +236,7 @@ const prerenderRoute = async (prerenderer, queryCache, routeToPrerender, dryrun,
|
|
|
210
236
|
if (!dryrun) {
|
|
211
237
|
prerenderer.writePrerenderedHtmlFile(outputHtmlPath, prerenderedHtml);
|
|
212
238
|
}
|
|
213
|
-
} catch (
|
|
239
|
+
} catch (error) {
|
|
214
240
|
console.log();
|
|
215
241
|
console.log(
|
|
216
242
|
c.warning("You can use `yarn cedar prerender --dry-run` to debug")
|
|
@@ -219,13 +245,20 @@ const prerenderRoute = async (prerenderer, queryCache, routeToPrerender, dryrun,
|
|
|
219
245
|
console.log(
|
|
220
246
|
`${c.info("-".repeat(10))} Error rendering path "${routeToPrerender.path}" ${c.info("-".repeat(10))}`
|
|
221
247
|
);
|
|
222
|
-
errorTelemetry(
|
|
223
|
-
|
|
248
|
+
errorTelemetry(
|
|
249
|
+
process.argv,
|
|
250
|
+
`Error prerendering: ${getErrorMessage(error)}`
|
|
251
|
+
);
|
|
252
|
+
console.error(c.error(getErrorStack(error)));
|
|
224
253
|
console.log();
|
|
225
254
|
throw new Error(`Failed to render "${routeToPrerender.filePath}"`);
|
|
226
255
|
}
|
|
227
256
|
};
|
|
228
|
-
const handler = async ({
|
|
257
|
+
const handler = async ({
|
|
258
|
+
path: routerPath,
|
|
259
|
+
dryRun = false,
|
|
260
|
+
verbose = false
|
|
261
|
+
}) => {
|
|
229
262
|
if (getConfig().experimental?.streamingSsr?.enabled) {
|
|
230
263
|
console.log(
|
|
231
264
|
c.warning(
|
|
@@ -239,10 +272,9 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
239
272
|
dryRun,
|
|
240
273
|
verbose
|
|
241
274
|
});
|
|
242
|
-
const listrTasks = await getTasks(dryRun, routerPath);
|
|
275
|
+
const listrTasks = await getTasks(dryRun, routerPath ?? null);
|
|
243
276
|
const tasks = new Listr(listrTasks, {
|
|
244
277
|
renderer: verbose ? "verbose" : "default",
|
|
245
|
-
rendererOptions: { collapseSubtasks: false },
|
|
246
278
|
concurrent: false
|
|
247
279
|
});
|
|
248
280
|
try {
|
|
@@ -250,11 +282,11 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
250
282
|
console.log(c.info("::: Dry run, not writing changes :::"));
|
|
251
283
|
}
|
|
252
284
|
await tasks.run();
|
|
253
|
-
} catch (
|
|
285
|
+
} catch (error) {
|
|
254
286
|
console.log();
|
|
255
|
-
|
|
287
|
+
diagnosticCheck();
|
|
256
288
|
console.log(c.warning("Tips:"));
|
|
257
|
-
if (
|
|
289
|
+
if (error instanceof PathParamError) {
|
|
258
290
|
console.log(
|
|
259
291
|
c.info(
|
|
260
292
|
"- You most likely need to add or update a *.routeHooks.{js,ts} file next to the Page you're trying to prerender"
|
|
@@ -282,6 +314,5 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
282
314
|
}
|
|
283
315
|
};
|
|
284
316
|
export {
|
|
285
|
-
getTasks,
|
|
286
317
|
handler
|
|
287
318
|
};
|
|
@@ -1,58 +1,81 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import boxen from "boxen";
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
7
|
import c from "../lib/colors.js";
|
|
8
8
|
import { getPaths } from "../lib/index.js";
|
|
9
|
-
const
|
|
9
|
+
const getErrorMessage = (error) => {
|
|
10
|
+
return error instanceof Error ? error.message : String(error);
|
|
11
|
+
};
|
|
12
|
+
function getExitCode(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
return value.exitCode;
|
|
17
|
+
}
|
|
18
|
+
const handler = async ({
|
|
19
|
+
_: _positionals,
|
|
20
|
+
$0: _binName,
|
|
21
|
+
commands = [],
|
|
22
|
+
...options
|
|
23
|
+
}) => {
|
|
10
24
|
recordTelemetryAttributes({
|
|
11
25
|
command: "prisma"
|
|
12
26
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
27
|
+
const cedarPaths = getPaths();
|
|
28
|
+
const args = [...Array.isArray(commands) ? commands : []].filter(
|
|
29
|
+
(value) => typeof value === "string"
|
|
30
|
+
);
|
|
31
|
+
const helpIndex = args.indexOf("help");
|
|
15
32
|
if (helpIndex !== -1) {
|
|
16
33
|
options.help = true;
|
|
17
|
-
|
|
34
|
+
args.splice(helpIndex, 1);
|
|
18
35
|
}
|
|
19
36
|
const hasHelpOption = options.help || options.h;
|
|
20
37
|
if (!hasHelpOption) {
|
|
21
|
-
if (!fs.existsSync(
|
|
38
|
+
if (!fs.existsSync(cedarPaths.api.prismaConfig)) {
|
|
22
39
|
console.error();
|
|
23
40
|
console.error(c.error("No Prisma config file found."));
|
|
24
|
-
console.error(`Cedar searched here '${
|
|
41
|
+
console.error(`Cedar searched here '${cedarPaths.api.prismaConfig}'`);
|
|
25
42
|
console.error();
|
|
26
43
|
process.exit(1);
|
|
27
44
|
}
|
|
28
|
-
options.config = `${
|
|
45
|
+
options.config = `${cedarPaths.api.prismaConfig}`;
|
|
29
46
|
}
|
|
30
|
-
const args = commands;
|
|
31
47
|
for (const [name, value] of Object.entries(options)) {
|
|
32
48
|
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
33
49
|
if (typeof value === "string") {
|
|
34
|
-
value.split(" ").length > 1
|
|
50
|
+
if (value.split(" ").length > 1) {
|
|
51
|
+
args.push(`"${value}"`);
|
|
52
|
+
} else {
|
|
53
|
+
args.push(value);
|
|
54
|
+
}
|
|
35
55
|
} else if (typeof value === "number") {
|
|
36
|
-
args.push(value);
|
|
56
|
+
args.push(String(value));
|
|
37
57
|
}
|
|
38
58
|
}
|
|
39
59
|
console.log();
|
|
40
60
|
console.log(c.note("Running Prisma CLI..."));
|
|
41
|
-
console.log(c.underline(
|
|
61
|
+
console.log(c.underline(`$ yarn prisma ${args.join(" ")}`));
|
|
42
62
|
console.log();
|
|
43
63
|
try {
|
|
44
|
-
const prismaBin = path.join(
|
|
64
|
+
const prismaBin = path.join(cedarPaths.base, "node_modules/.bin/prisma");
|
|
45
65
|
execa.sync(prismaBin, args, {
|
|
46
|
-
cwd:
|
|
66
|
+
cwd: cedarPaths.base,
|
|
47
67
|
stdio: "inherit",
|
|
48
68
|
cleanup: true
|
|
49
69
|
});
|
|
50
|
-
if (hasHelpOption ||
|
|
70
|
+
if (hasHelpOption || args.length === 0) {
|
|
51
71
|
printWrapInfo();
|
|
52
72
|
}
|
|
53
|
-
} catch (
|
|
54
|
-
errorTelemetry(
|
|
55
|
-
|
|
73
|
+
} catch (error) {
|
|
74
|
+
errorTelemetry(
|
|
75
|
+
process.argv,
|
|
76
|
+
`Error generating prisma client: ${getErrorMessage(error)}`
|
|
77
|
+
);
|
|
78
|
+
process.exit(getExitCode(error) ?? 1);
|
|
56
79
|
}
|
|
57
80
|
};
|
|
58
81
|
const printWrapInfo = () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
@@ -7,6 +7,15 @@ import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
|
7
7
|
import c from "../lib/colors.js";
|
|
8
8
|
import { getPaths } from "../lib/index.js";
|
|
9
9
|
import * as project from "../lib/project.js";
|
|
10
|
+
function hasStringMessage(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
12
|
+
}
|
|
13
|
+
function getExitCode(value) {
|
|
14
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
return value.exitCode;
|
|
18
|
+
}
|
|
10
19
|
function isInGitRepository() {
|
|
11
20
|
try {
|
|
12
21
|
execa.commandSync("git rev-parse --is-inside-work-tree");
|
|
@@ -24,25 +33,24 @@ function isInMercurialRepository() {
|
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
function isJestConfigFile(sides) {
|
|
27
|
-
for (
|
|
36
|
+
for (const side of sides) {
|
|
28
37
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`
|
|
38
|
+
const jestConfigExists = fs.existsSync(path.join(side, "jest.config.js")) || fs.existsSync(path.join(side, "jest.config.ts"));
|
|
39
|
+
if (!jestConfigExists) {
|
|
40
|
+
console.error(
|
|
41
|
+
c.error(
|
|
42
|
+
`
|
|
35
43
|
Error: Missing Jest config file ${side}/jest.config.js
|
|
36
44
|
To add this file, run \`npx @cedarjs/codemods update-jest-config\`
|
|
37
45
|
`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
throw new Error(`Error: Jest config file not found in ${side} side`);
|
|
42
49
|
}
|
|
43
|
-
} catch (
|
|
44
|
-
|
|
45
|
-
process.
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const message = hasStringMessage(error) ? error.message : `Error: Jest config file not found in ${side} side`;
|
|
52
|
+
errorTelemetry(process.argv, message);
|
|
53
|
+
process.exit(getExitCode(error) ?? 1);
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
}
|
|
@@ -70,15 +78,13 @@ const handler = async ({
|
|
|
70
78
|
"_"
|
|
71
79
|
].includes(flagName)) {
|
|
72
80
|
return [];
|
|
73
|
-
} else {
|
|
74
|
-
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
75
|
-
const flagValue = others[flagName];
|
|
76
|
-
if (Array.isArray(flagValue)) {
|
|
77
|
-
return flagValue.flatMap((val) => [flag, val]);
|
|
78
|
-
} else {
|
|
79
|
-
return [flag, flagValue];
|
|
80
|
-
}
|
|
81
81
|
}
|
|
82
|
+
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
83
|
+
const flagValue = others[flagName];
|
|
84
|
+
if (Array.isArray(flagValue)) {
|
|
85
|
+
return flagValue.flatMap((val) => [flag, val]);
|
|
86
|
+
}
|
|
87
|
+
return [flag, flagValue];
|
|
82
88
|
});
|
|
83
89
|
const sides = filterParams.filter(
|
|
84
90
|
(filterString) => project.workspaces().includes(filterString)
|
|
@@ -117,7 +123,7 @@ const handler = async ({
|
|
|
117
123
|
await execa("yarn", ["jest", ...jestArgs], {
|
|
118
124
|
cwd: rwjsPaths.base,
|
|
119
125
|
stdio: "inherit",
|
|
120
|
-
env: { DATABASE_URL }
|
|
126
|
+
env: { ...process.env, DATABASE_URL }
|
|
121
127
|
});
|
|
122
128
|
};
|
|
123
129
|
if (watch) {
|
|
@@ -127,9 +133,10 @@ const handler = async ({
|
|
|
127
133
|
await runCommand();
|
|
128
134
|
});
|
|
129
135
|
}
|
|
130
|
-
} catch (
|
|
131
|
-
|
|
132
|
-
process.
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const message = hasStringMessage(error) ? error.message : "Test command failed";
|
|
138
|
+
errorTelemetry(process.argv, message);
|
|
139
|
+
process.exit(getExitCode(error) ?? 1);
|
|
133
140
|
}
|
|
134
141
|
};
|
|
135
142
|
export {
|
|
@@ -4,6 +4,15 @@ import { ensurePosixPath } from "@cedarjs/project-config";
|
|
|
4
4
|
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
5
5
|
import { getPaths } from "../lib/index.js";
|
|
6
6
|
import * as project from "../lib/project.js";
|
|
7
|
+
function hasStringMessage(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
9
|
+
}
|
|
10
|
+
function getExitCode(value) {
|
|
11
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
return value.exitCode;
|
|
15
|
+
}
|
|
7
16
|
const handler = async ({
|
|
8
17
|
filter: filterParams = [],
|
|
9
18
|
dbPush = true,
|
|
@@ -18,20 +27,18 @@ const handler = async ({
|
|
|
18
27
|
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
19
28
|
if (["db-push", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
20
29
|
return [];
|
|
21
|
-
} else {
|
|
22
|
-
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
23
|
-
const flagValue = others[flagName];
|
|
24
|
-
if (flagName === "watch") {
|
|
25
|
-
watch = flagValue === true;
|
|
26
|
-
} else if (flagName === "run" && flagValue) {
|
|
27
|
-
watch = false;
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(flagValue)) {
|
|
30
|
-
return flagValue.flatMap((val) => [flag, val]);
|
|
31
|
-
} else {
|
|
32
|
-
return [flag, flagValue];
|
|
33
|
-
}
|
|
34
30
|
}
|
|
31
|
+
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
32
|
+
const flagValue = others[flagName];
|
|
33
|
+
if (flagName === "watch") {
|
|
34
|
+
watch = flagValue === true;
|
|
35
|
+
} else if (flagName === "run" && flagValue) {
|
|
36
|
+
watch = false;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(flagValue)) {
|
|
39
|
+
return flagValue.flatMap((val) => [flag, val]);
|
|
40
|
+
}
|
|
41
|
+
return [flag, flagValue];
|
|
35
42
|
});
|
|
36
43
|
const sides = filterParams.filter(
|
|
37
44
|
(filterString) => project.workspaces().includes(filterString)
|
|
@@ -65,7 +72,7 @@ const handler = async ({
|
|
|
65
72
|
await execa("yarn", ["vitest", ...vitestArgs], {
|
|
66
73
|
cwd: rwjsPaths.base,
|
|
67
74
|
stdio: "inherit",
|
|
68
|
-
env: { DATABASE_URL }
|
|
75
|
+
env: { ...process.env, DATABASE_URL }
|
|
69
76
|
});
|
|
70
77
|
};
|
|
71
78
|
if (watch) {
|
|
@@ -75,9 +82,10 @@ const handler = async ({
|
|
|
75
82
|
await runCommand();
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
|
-
} catch (
|
|
79
|
-
|
|
80
|
-
process.
|
|
85
|
+
} catch (error) {
|
|
86
|
+
const message = hasStringMessage(error) ? error.message : "Test command failed";
|
|
87
|
+
errorTelemetry(process.argv, message);
|
|
88
|
+
process.exit(getExitCode(error) ?? 1);
|
|
81
89
|
}
|
|
82
90
|
};
|
|
83
91
|
export {
|
|
@@ -5,21 +5,32 @@ import { Listr } from "listr2";
|
|
|
5
5
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
6
|
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
7
7
|
import { getPaths } from "../lib/index.js";
|
|
8
|
-
const
|
|
8
|
+
const isConcurrentlyErrorArray = (value) => {
|
|
9
|
+
return Array.isArray(value);
|
|
10
|
+
};
|
|
11
|
+
const handler = async ({
|
|
12
|
+
sides,
|
|
13
|
+
verbose = false,
|
|
14
|
+
prisma = true,
|
|
15
|
+
generate = true
|
|
16
|
+
}) => {
|
|
17
|
+
const selectedSides = (Array.isArray(sides) ? sides : []).filter(
|
|
18
|
+
(side) => typeof side === "string"
|
|
19
|
+
);
|
|
9
20
|
recordTelemetryAttributes({
|
|
10
21
|
command: "type-check",
|
|
11
|
-
sides: JSON.stringify(
|
|
22
|
+
sides: JSON.stringify(selectedSides),
|
|
12
23
|
verbose,
|
|
13
24
|
prisma,
|
|
14
25
|
generate
|
|
15
26
|
});
|
|
16
27
|
const typeCheck = async () => {
|
|
17
28
|
let conclusiveExitCode = 0;
|
|
18
|
-
const tscForAllSides =
|
|
29
|
+
const tscForAllSides = selectedSides.map((side) => {
|
|
19
30
|
const projectDir = path.join(getPaths().base, side);
|
|
20
31
|
return {
|
|
21
32
|
cwd: projectDir,
|
|
22
|
-
command:
|
|
33
|
+
command: "yarn tsc --noEmit --skipLibCheck"
|
|
23
34
|
};
|
|
24
35
|
});
|
|
25
36
|
const { result } = concurrently(tscForAllSides, {
|
|
@@ -28,9 +39,9 @@ const handler = async ({ sides, verbose, prisma, generate }) => {
|
|
|
28
39
|
});
|
|
29
40
|
try {
|
|
30
41
|
await result;
|
|
31
|
-
} catch (
|
|
32
|
-
if (
|
|
33
|
-
const exitCodes =
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (isConcurrentlyErrorArray(error)) {
|
|
44
|
+
const exitCodes = error.map((entry) => entry.exitCode).filter((exitCode2) => Boolean(exitCode2));
|
|
34
45
|
conclusiveExitCode = Math.max(...exitCodes);
|
|
35
46
|
}
|
|
36
47
|
}
|
|
@@ -53,8 +64,7 @@ const handler = async ({ sides, verbose, prisma, generate }) => {
|
|
|
53
64
|
}
|
|
54
65
|
],
|
|
55
66
|
{
|
|
56
|
-
renderer: verbose
|
|
57
|
-
rendererOptions: { collapseSubtasks: false }
|
|
67
|
+
renderer: verbose ? "verbose" : void 0
|
|
58
68
|
}
|
|
59
69
|
).run();
|
|
60
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13549+6a5f903e0",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"@babel/parser": "7.29.0",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
36
|
"@babel/runtime-corejs3": "7.29.0",
|
|
37
|
-
"@cedarjs/api-server": "3.0.0-canary.
|
|
38
|
-
"@cedarjs/cli-helpers": "3.0.0-canary.
|
|
39
|
-
"@cedarjs/fastify-web": "3.0.0-canary.
|
|
40
|
-
"@cedarjs/internal": "3.0.0-canary.
|
|
41
|
-
"@cedarjs/prerender": "3.0.0-canary.
|
|
42
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
43
|
-
"@cedarjs/structure": "3.0.0-canary.
|
|
44
|
-
"@cedarjs/telemetry": "3.0.0-canary.
|
|
45
|
-
"@cedarjs/utils": "3.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "3.0.0-canary.
|
|
37
|
+
"@cedarjs/api-server": "3.0.0-canary.13549",
|
|
38
|
+
"@cedarjs/cli-helpers": "3.0.0-canary.13549",
|
|
39
|
+
"@cedarjs/fastify-web": "3.0.0-canary.13549",
|
|
40
|
+
"@cedarjs/internal": "3.0.0-canary.13549",
|
|
41
|
+
"@cedarjs/prerender": "3.0.0-canary.13549",
|
|
42
|
+
"@cedarjs/project-config": "3.0.0-canary.13549",
|
|
43
|
+
"@cedarjs/structure": "3.0.0-canary.13549",
|
|
44
|
+
"@cedarjs/telemetry": "3.0.0-canary.13549",
|
|
45
|
+
"@cedarjs/utils": "3.0.0-canary.13549",
|
|
46
|
+
"@cedarjs/web-server": "3.0.0-canary.13549",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.0",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "6a5f903e06fa7aeeb9cf70876341141cb7e5fc00"
|
|
111
111
|
}
|