@cedarjs/cli 1.0.0-canary.13129 → 1.0.0-canary.13130
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
CHANGED
|
@@ -7,7 +7,7 @@ const command = "build [workspace..]";
|
|
|
7
7
|
const description = "Build for production";
|
|
8
8
|
const builder = (yargs) => {
|
|
9
9
|
yargs.positional("workspace", {
|
|
10
|
-
default: ["
|
|
10
|
+
default: ["api", "web", "packages/*"],
|
|
11
11
|
description: "What workspace(s) to build. Valid values are: web, api, packages/*, <package-name>",
|
|
12
12
|
type: "array"
|
|
13
13
|
}).option("verbose", {
|
|
@@ -6,25 +6,25 @@ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
|
6
6
|
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
7
7
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
8
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
|
-
import c from "
|
|
10
|
-
import { exitWithError } from "
|
|
11
|
-
import { generatePrismaClient } from "
|
|
12
|
-
import { getPaths } from "
|
|
13
|
-
import { getFreePort } from "
|
|
14
|
-
import { serverFileExists } from "
|
|
9
|
+
import c from "../../lib/colors.js";
|
|
10
|
+
import { exitWithError } from "../../lib/exit.js";
|
|
11
|
+
import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
|
|
12
|
+
import { getPaths } from "../../lib/index.js";
|
|
13
|
+
import { getFreePort } from "../../lib/ports.js";
|
|
14
|
+
import { serverFileExists } from "../../lib/project.js";
|
|
15
15
|
const defaultApiDebugPort = 18911;
|
|
16
16
|
const handler = async ({
|
|
17
|
-
|
|
17
|
+
workspace = ["api", "web"],
|
|
18
18
|
forward = "",
|
|
19
19
|
generate = true,
|
|
20
20
|
apiDebugPort
|
|
21
21
|
}) => {
|
|
22
22
|
recordTelemetryAttributes({
|
|
23
23
|
command: "dev",
|
|
24
|
-
|
|
24
|
+
workspace: JSON.stringify(workspace),
|
|
25
25
|
generate
|
|
26
26
|
});
|
|
27
|
-
const
|
|
27
|
+
const cedarPaths = getPaths();
|
|
28
28
|
const serverFile = serverFileExists();
|
|
29
29
|
const apiPreferredPort = parseInt(String(getConfig().api.port));
|
|
30
30
|
let webPreferredPort = parseInt(
|
|
@@ -34,7 +34,7 @@ const handler = async ({
|
|
|
34
34
|
let apiPortChangeNeeded = false;
|
|
35
35
|
let webAvailablePort = webPreferredPort;
|
|
36
36
|
let webPortChangeNeeded = false;
|
|
37
|
-
if (
|
|
37
|
+
if (workspace.includes("api") && !serverFile) {
|
|
38
38
|
apiAvailablePort = await getFreePort(apiPreferredPort);
|
|
39
39
|
if (apiAvailablePort === -1) {
|
|
40
40
|
exitWithError(void 0, {
|
|
@@ -43,7 +43,7 @@ const handler = async ({
|
|
|
43
43
|
}
|
|
44
44
|
apiPortChangeNeeded = apiAvailablePort !== apiPreferredPort;
|
|
45
45
|
}
|
|
46
|
-
if (
|
|
46
|
+
if (workspace.includes("web")) {
|
|
47
47
|
const forwardedPortMatches = [
|
|
48
48
|
...forward.matchAll(/\-\-port(\=|\s)(?<port>[^\s]*)/g)
|
|
49
49
|
];
|
|
@@ -80,14 +80,14 @@ const handler = async ({
|
|
|
80
80
|
].filter(Boolean).join(" ");
|
|
81
81
|
exitWithError(void 0, { message });
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
83
|
+
if (workspace.includes("api")) {
|
|
84
84
|
try {
|
|
85
85
|
await generatePrismaClient({
|
|
86
86
|
verbose: false,
|
|
87
87
|
force: false
|
|
88
88
|
});
|
|
89
89
|
} catch (e) {
|
|
90
|
-
const message =
|
|
90
|
+
const message = getErrorMessage(e);
|
|
91
91
|
errorTelemetry(process.argv, `Error generating prisma client: ${message}`);
|
|
92
92
|
console.error(c.error(message));
|
|
93
93
|
}
|
|
@@ -95,7 +95,7 @@ const handler = async ({
|
|
|
95
95
|
try {
|
|
96
96
|
await shutdownPort(apiAvailablePort);
|
|
97
97
|
} catch (e) {
|
|
98
|
-
const message =
|
|
98
|
+
const message = getErrorMessage(e);
|
|
99
99
|
errorTelemetry(process.argv, `Error shutting down "api": ${message}`);
|
|
100
100
|
console.error(
|
|
101
101
|
`Error whilst shutting down "api" port: ${c.error(message)}`
|
|
@@ -103,11 +103,11 @@ const handler = async ({
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
if (
|
|
106
|
+
if (workspace.includes("web")) {
|
|
107
107
|
try {
|
|
108
108
|
await shutdownPort(webAvailablePort);
|
|
109
109
|
} catch (e) {
|
|
110
|
-
const message =
|
|
110
|
+
const message = getErrorMessage(e);
|
|
111
111
|
errorTelemetry(process.argv, `Error shutting down "web": ${message}`);
|
|
112
112
|
console.error(
|
|
113
113
|
`Error whilst shutting down "web" port: ${c.error(message)}`
|
|
@@ -126,7 +126,7 @@ const handler = async ({
|
|
|
126
126
|
}
|
|
127
127
|
return "";
|
|
128
128
|
};
|
|
129
|
-
const
|
|
129
|
+
const cedarConfigPath = getConfigPath();
|
|
130
130
|
const streamingSsrEnabled = getConfig().experimental?.streamingSsr?.enabled;
|
|
131
131
|
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
132
132
|
let webCommand = `yarn cross-env NODE_ENV=development rw-vite-dev ${forward}`;
|
|
@@ -134,7 +134,7 @@ const handler = async ({
|
|
|
134
134
|
webCommand = `yarn cross-env NODE_ENV=development rw-dev-fe ${forward}`;
|
|
135
135
|
}
|
|
136
136
|
const rootPackageJson = JSON.parse(
|
|
137
|
-
fs.readFileSync(path.join(
|
|
137
|
+
fs.readFileSync(path.join(cedarPaths.base, "package.json"), "utf8")
|
|
138
138
|
);
|
|
139
139
|
const isEsm = rootPackageJson.type === "module";
|
|
140
140
|
const serverWatchCommand = isEsm ? `cedarjs-api-server-watch` : `rw-api-server-watch`;
|
|
@@ -144,7 +144,7 @@ const handler = async ({
|
|
|
144
144
|
command: [
|
|
145
145
|
"yarn nodemon",
|
|
146
146
|
" --quiet",
|
|
147
|
-
` --watch "${
|
|
147
|
+
` --watch "${cedarConfigPath}"`,
|
|
148
148
|
` --exec "yarn ${serverWatchCommand}`,
|
|
149
149
|
` --port ${apiAvailablePort}`,
|
|
150
150
|
` ${getApiDebugFlag()}`,
|
|
@@ -155,14 +155,14 @@ const handler = async ({
|
|
|
155
155
|
NODE_OPTIONS: getDevNodeOptions()
|
|
156
156
|
},
|
|
157
157
|
prefixColor: "cyan",
|
|
158
|
-
runWhen: () => fs.existsSync(
|
|
158
|
+
runWhen: () => fs.existsSync(cedarPaths.api.src)
|
|
159
159
|
},
|
|
160
160
|
web: {
|
|
161
161
|
name: "web",
|
|
162
162
|
command: webCommand,
|
|
163
163
|
prefixColor: "blue",
|
|
164
|
-
cwd:
|
|
165
|
-
runWhen: () => fs.existsSync(
|
|
164
|
+
cwd: cedarPaths.web.base,
|
|
165
|
+
runWhen: () => fs.existsSync(cedarPaths.web.src)
|
|
166
166
|
},
|
|
167
167
|
gen: {
|
|
168
168
|
name: "gen",
|
|
@@ -172,7 +172,7 @@ const handler = async ({
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
const mappedJobs = Object.keys(jobs).map((job) => {
|
|
175
|
-
if (
|
|
175
|
+
if (workspace.includes(job) || job === "gen") {
|
|
176
176
|
return jobs[job];
|
|
177
177
|
}
|
|
178
178
|
return {
|
|
@@ -193,7 +193,7 @@ const handler = async ({
|
|
|
193
193
|
if (e?.message) {
|
|
194
194
|
errorTelemetry(
|
|
195
195
|
process.argv,
|
|
196
|
-
`Error concurrently starting
|
|
196
|
+
`Error concurrently starting workspaces: ${e.message}`
|
|
197
197
|
);
|
|
198
198
|
exitWithError(e);
|
|
199
199
|
}
|
|
@@ -210,6 +210,9 @@ function getDevNodeOptions() {
|
|
|
210
210
|
}
|
|
211
211
|
return `${NODE_OPTIONS} ${enableSourceMapsOption}`;
|
|
212
212
|
}
|
|
213
|
+
function getErrorMessage(error) {
|
|
214
|
+
return error instanceof Object && "message" in error ? error.message : String(error);
|
|
215
|
+
}
|
|
213
216
|
export {
|
|
214
217
|
getDevNodeOptions,
|
|
215
218
|
handler
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
2
|
import c from "../lib/colors.js";
|
|
3
3
|
import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
|
|
4
|
-
const command = "dev [
|
|
4
|
+
const command = "dev [workspace..]";
|
|
5
5
|
const description = "Start development servers for api, and web";
|
|
6
6
|
const builder = (yargs) => {
|
|
7
|
-
yargs.positional("
|
|
7
|
+
yargs.positional("workspace", {
|
|
8
8
|
choices: ["api", "web"],
|
|
9
9
|
default: ["api", "web"],
|
|
10
10
|
description: "Which dev server(s) to start",
|
|
@@ -14,6 +14,8 @@ const builder = (yargs) => {
|
|
|
14
14
|
alias: "fwd",
|
|
15
15
|
description: 'String of one or more vite dev server config options, for example: `--fwd="--port=1234 --open=false"`',
|
|
16
16
|
type: "string",
|
|
17
|
+
// The reason `forward` is hidden is that it's been broken with Vite and
|
|
18
|
+
// it's not clear how to fix it.
|
|
17
19
|
hidden: true
|
|
18
20
|
}).option("generate", {
|
|
19
21
|
type: "boolean",
|
|
@@ -37,7 +39,7 @@ const builder = (yargs) => {
|
|
|
37
39
|
);
|
|
38
40
|
};
|
|
39
41
|
const handler = async (options) => {
|
|
40
|
-
const { handler: handler2 } = await import("./devHandler.js");
|
|
42
|
+
const { handler: handler2 } = await import("./dev/devHandler.js");
|
|
41
43
|
return handler2(options);
|
|
42
44
|
};
|
|
43
45
|
export {
|
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.13130+38895e6ea",
|
|
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.13130",
|
|
36
|
+
"@cedarjs/cli-helpers": "1.0.0-canary.13130",
|
|
37
|
+
"@cedarjs/fastify-web": "1.0.0-canary.13130",
|
|
38
|
+
"@cedarjs/internal": "1.0.0-canary.13130",
|
|
39
|
+
"@cedarjs/prerender": "1.0.0-canary.13130",
|
|
40
|
+
"@cedarjs/project-config": "1.0.0-canary.13130",
|
|
41
|
+
"@cedarjs/structure": "1.0.0-canary.13130",
|
|
42
|
+
"@cedarjs/telemetry": "1.0.0-canary.13130",
|
|
43
|
+
"@cedarjs/web-server": "1.0.0-canary.13130",
|
|
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": "38895e6ea5228295d67e5dfcf31956265b18dae0"
|
|
106
106
|
}
|