@cedarjs/cli 6.0.0-canary.2645 → 6.0.0-canary.2646
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/dev/devHandler.js +34 -4
- package/dist/commands/dev.js +3 -0
- package/package.json +12 -12
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { Writable } from "node:stream";
|
|
4
5
|
import concurrently from "concurrently";
|
|
@@ -7,6 +8,7 @@ import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display
|
|
|
7
8
|
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
8
9
|
import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
|
|
9
10
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
11
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
10
12
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
13
|
import { exitWithError } from "../../lib/exit.js";
|
|
12
14
|
import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
|
|
@@ -15,13 +17,38 @@ import { getFreePort } from "../../lib/ports.js";
|
|
|
15
17
|
import { serverFileExists } from "../../lib/project.js";
|
|
16
18
|
import { getApiDebugFlag } from "./apiDebugFlag.js";
|
|
17
19
|
import { getPackageWatchCommands } from "./packageWatchCommands.js";
|
|
20
|
+
const createdRequire = createRequire(import.meta.url);
|
|
21
|
+
function formatViteDevBinCommand(binName, extraNodeArgs = "") {
|
|
22
|
+
let vitePackageJsonPath;
|
|
23
|
+
let vitePackageJson;
|
|
24
|
+
try {
|
|
25
|
+
vitePackageJsonPath = createdRequire.resolve("@cedarjs/vite/package.json");
|
|
26
|
+
vitePackageJson = createdRequire("@cedarjs/vite/package.json");
|
|
27
|
+
} catch (e) {
|
|
28
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Could not resolve @cedarjs/vite, which the dev server needs to run. Is it installed? (${message})`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const binRelativePath = vitePackageJson.bin?.[binName];
|
|
34
|
+
if (!binRelativePath) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`@cedarjs/vite does not declare a "${binName}" bin. This is a bug in CedarJS.`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const binPath = path.join(path.dirname(vitePackageJsonPath), binRelativePath);
|
|
40
|
+
const nodeLauncher = getPackageManager() === "yarn" ? "yarn node" : "node";
|
|
41
|
+
const flags = extraNodeArgs ? `${extraNodeArgs} ` : "";
|
|
42
|
+
return `${nodeLauncher} ${flags}"${binPath}"`;
|
|
43
|
+
}
|
|
18
44
|
const handler = async ({
|
|
19
45
|
workspace = ["api", "web", "packages/*"],
|
|
20
46
|
forward = "",
|
|
21
47
|
generate = true,
|
|
22
48
|
apiDebugPort,
|
|
23
49
|
debugBrk,
|
|
24
|
-
ud = false
|
|
50
|
+
ud = false,
|
|
51
|
+
nodeArgs = ""
|
|
25
52
|
}) => {
|
|
26
53
|
recordTelemetryAttributes({
|
|
27
54
|
command: "dev",
|
|
@@ -174,7 +201,7 @@ const handler = async ({
|
|
|
174
201
|
return null;
|
|
175
202
|
}
|
|
176
203
|
return [
|
|
177
|
-
|
|
204
|
+
formatViteDevBinCommand("cedar-unified-dev", nodeArgs),
|
|
178
205
|
` --port ${webAvailablePort}`,
|
|
179
206
|
` --apiPort ${apiAvailablePort}`,
|
|
180
207
|
getApiDebugFlag(apiDebugPort, apiAvailablePort),
|
|
@@ -230,13 +257,16 @@ const handler = async ({
|
|
|
230
257
|
});
|
|
231
258
|
}
|
|
232
259
|
if (workspace.includes("web")) {
|
|
233
|
-
let webCommand = `${
|
|
260
|
+
let webCommand = `${formatViteDevBinCommand("cedar-vite-dev", nodeArgs)} ${forward}`;
|
|
234
261
|
if (streamingSsrEnabled) {
|
|
235
|
-
webCommand = `${
|
|
262
|
+
webCommand = `${formatViteDevBinCommand("cedar-dev-fe", nodeArgs)} ${forward}`;
|
|
236
263
|
}
|
|
237
264
|
jobs.push({
|
|
238
265
|
name: "web",
|
|
239
266
|
command: webCommand,
|
|
267
|
+
env: {
|
|
268
|
+
NODE_ENV: "development"
|
|
269
|
+
},
|
|
240
270
|
prefixColor: "blue",
|
|
241
271
|
cwd: cedarPaths.web.base,
|
|
242
272
|
runWhen: () => fs.existsSync(cedarPaths.web.src)
|
package/dist/commands/dev.js
CHANGED
|
@@ -31,6 +31,9 @@ const builder = (yargs) => {
|
|
|
31
31
|
type: "boolean",
|
|
32
32
|
default: false,
|
|
33
33
|
description: "Use the unified Vite dev server that handles both web and API in a single process (experimental)."
|
|
34
|
+
}).option("nodeArgs", {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: 'CLI args to pass to the node process running the web dev server, for example: `--node-args="--inspect --max-old-space-size=8192"`.'
|
|
34
37
|
}).middleware(() => {
|
|
35
38
|
const check = checkNodeVersion();
|
|
36
39
|
if (check.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2646",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.7",
|
|
35
35
|
"@babel/preset-typescript": "7.29.7",
|
|
36
|
-
"@cedarjs/api-server": "6.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "6.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "6.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "6.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "6.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "6.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "6.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "6.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "6.0.0-canary.2646",
|
|
37
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2646",
|
|
38
|
+
"@cedarjs/fastify-web": "6.0.0-canary.2646",
|
|
39
|
+
"@cedarjs/internal": "6.0.0-canary.2646",
|
|
40
|
+
"@cedarjs/prerender": "6.0.0-canary.2646",
|
|
41
|
+
"@cedarjs/project-config": "6.0.0-canary.2646",
|
|
42
|
+
"@cedarjs/structure": "6.0.0-canary.2646",
|
|
43
|
+
"@cedarjs/telemetry": "6.0.0-canary.2646",
|
|
44
|
+
"@cedarjs/utils": "6.0.0-canary.2646",
|
|
45
|
+
"@cedarjs/vite": "6.0.0-canary.2646",
|
|
46
|
+
"@cedarjs/web-server": "6.0.0-canary.2646",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|