@cedarjs/cli 5.0.0-canary.2479 → 5.0.0-canary.2480
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/deploy/baremetal/baremetalHandler.js +3 -2
- package/dist/commands/deploy/flightcontrolHandler.js +18 -13
- package/dist/commands/deploy/helpers/deployHandler.js +4 -3
- package/dist/commands/deploy/renderHandler.js +11 -5
- package/dist/commands/deploy/serverlessHandler.js +28 -12
- package/dist/lib/index.js +13 -21
- package/dist/lib/updateCheck.js +6 -4
- package/package.json +12 -12
|
@@ -7,6 +7,7 @@ import * as toml from "smol-toml";
|
|
|
7
7
|
import { env as envInterpolation } from "string-env-interpolation";
|
|
8
8
|
import { titleCase } from "title-case";
|
|
9
9
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
10
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
10
11
|
import { getPaths } from "../../../lib/index.js";
|
|
11
12
|
const CONFIG_FILENAME = "deploy.toml";
|
|
12
13
|
const SYMLINK_FLAGS = "-nsf";
|
|
@@ -30,7 +31,7 @@ const throwMissingConfig = (name) => {
|
|
|
30
31
|
const verifyConfig = (config, yargs) => {
|
|
31
32
|
if (!yargs.environment) {
|
|
32
33
|
throw new Error(
|
|
33
|
-
|
|
34
|
+
`Must specify an environment to deploy to, ex: \`${formatCedarCommand(["deploy", "baremetal", "production"])}\``
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
if (!config[yargs.environment]) {
|
|
@@ -535,7 +536,7 @@ const handler = async (yargs) => {
|
|
|
535
536
|
const ecosystemPath = path.join(getPaths().base, "ecosystem.config.js");
|
|
536
537
|
if (!fs.existsSync(tomlPath) || !fs.existsSync(ecosystemPath)) {
|
|
537
538
|
console.error(
|
|
538
|
-
c.error("\nError: Baremetal deploy has not been properly setup.\n") +
|
|
539
|
+
c.error("\nError: Baremetal deploy has not been properly setup.\n") + `Please run \`${formatCedarCommand(["setup", "deploy", "baremetal"])}\` before deploying`
|
|
539
540
|
);
|
|
540
541
|
process.exit(1);
|
|
541
542
|
}
|
|
@@ -2,7 +2,18 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import {
|
|
6
|
+
getNodeRunnerArgs,
|
|
7
|
+
runBin
|
|
8
|
+
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
5
9
|
import { getPaths } from "@cedarjs/project-config";
|
|
10
|
+
async function runBinWithError(bin, args, options) {
|
|
11
|
+
const result = await runBin(bin, args, options);
|
|
12
|
+
if (result.failed) {
|
|
13
|
+
throw new Error(`Command (${bin} ${args.join(" ")}) failed`);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
6
17
|
const handler = async ({
|
|
7
18
|
side,
|
|
8
19
|
serve,
|
|
@@ -22,33 +33,27 @@ const handler = async ({
|
|
|
22
33
|
shell: true,
|
|
23
34
|
stdio: "inherit"
|
|
24
35
|
};
|
|
25
|
-
async function runExecaCommand(command) {
|
|
26
|
-
const result = await execa.command(command, execaConfig);
|
|
27
|
-
if (result.failed) {
|
|
28
|
-
throw new Error(`Command (${command}) failed`);
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
36
|
async function runApiCommands() {
|
|
33
37
|
if (!serve) {
|
|
34
38
|
console.log("Building api...");
|
|
35
|
-
await
|
|
39
|
+
await runBinWithError("cedar", ["build", "api", "--verbose"], execaConfig);
|
|
36
40
|
if (prisma) {
|
|
37
41
|
console.log("Running database migrations...");
|
|
38
|
-
await
|
|
39
|
-
`node_modules/.bin/prisma migrate deploy --config "${cedarPaths.api.prismaConfig}"
|
|
42
|
+
await execa.command(
|
|
43
|
+
`node_modules/.bin/prisma migrate deploy --config "${cedarPaths.api.prismaConfig}"`,
|
|
44
|
+
execaConfig
|
|
40
45
|
);
|
|
41
46
|
}
|
|
42
47
|
if (dataMigrate) {
|
|
43
48
|
console.log("Running data migrations...");
|
|
44
|
-
await
|
|
49
|
+
await runBinWithError("cedar", ["dataMigrate", "up"], execaConfig);
|
|
45
50
|
}
|
|
46
51
|
return;
|
|
47
52
|
}
|
|
48
53
|
const serverFilePath = path.join(cedarPaths.api.dist, "server.js");
|
|
49
54
|
const hasServerFile = fs.existsSync(serverFilePath);
|
|
50
55
|
if (hasServerFile) {
|
|
51
|
-
execa(
|
|
56
|
+
execa(...getNodeRunnerArgs(serverFilePath), execaConfig);
|
|
52
57
|
} else {
|
|
53
58
|
const { handler: handler2 } = await import("@cedarjs/api-server/apiCliConfigHandler");
|
|
54
59
|
handler2();
|
|
@@ -56,7 +61,7 @@ const handler = async ({
|
|
|
56
61
|
}
|
|
57
62
|
async function runWebCommands() {
|
|
58
63
|
console.log("Building web...");
|
|
59
|
-
await
|
|
64
|
+
await runBinWithError("cedar", ["build", "web", "--verbose"], execaConfig);
|
|
60
65
|
}
|
|
61
66
|
if (side === "api") {
|
|
62
67
|
await runApiCommands();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import execa from "execa";
|
|
2
2
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
3
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
5
|
const deployHandler = ({ build, prisma, dm: dataMigrate }) => {
|
|
5
6
|
const paths = getPaths();
|
|
6
7
|
let commandSet = [];
|
|
7
8
|
if (build) {
|
|
8
|
-
commandSet.push("
|
|
9
|
+
commandSet.push(formatCedarCommand(["build", "--verbose"]));
|
|
9
10
|
}
|
|
10
11
|
if (prisma) {
|
|
11
|
-
commandSet.push("
|
|
12
|
+
commandSet.push(formatCedarCommand(["prisma", "migrate", "deploy"]));
|
|
12
13
|
}
|
|
13
14
|
if (dataMigrate) {
|
|
14
|
-
commandSet.push("
|
|
15
|
+
commandSet.push(formatCedarCommand(["data-migrate", "up"]));
|
|
15
16
|
}
|
|
16
17
|
const joinedCommands = commandSet.join(" && ");
|
|
17
18
|
console.log(c.note("\nRunning:\n") + `${joinedCommands}
|
|
@@ -2,6 +2,12 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { formatAddRootPackagesCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
+
import {
|
|
7
|
+
getNodeRunnerArgs,
|
|
8
|
+
runBinSync
|
|
9
|
+
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
|
+
import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
5
11
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
12
|
const handler = async ({ side, prisma, dataMigrate }) => {
|
|
7
13
|
recordTelemetryAttributes({
|
|
@@ -38,26 +44,26 @@ const handler = async ({ side, prisma, dataMigrate }) => {
|
|
|
38
44
|
"If you want to run data migrations, add the package to your project's root package.json and deploy again:",
|
|
39
45
|
"",
|
|
40
46
|
"```",
|
|
41
|
-
"
|
|
47
|
+
formatAddRootPackagesCommand(["@cedarjs/cli-data-migrate"], true),
|
|
42
48
|
"```"
|
|
43
49
|
].join("\n")
|
|
44
50
|
);
|
|
45
51
|
} else {
|
|
46
|
-
|
|
52
|
+
runBinSync("cedar", ["dataMigrate", "up"], execaConfig);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
const serverFilePath = path.join(cedarPaths.api.dist, "server.js");
|
|
50
56
|
const hasServerFile = fs.existsSync(serverFilePath);
|
|
51
57
|
if (hasServerFile) {
|
|
52
|
-
execa(
|
|
58
|
+
execa(...getNodeRunnerArgs(serverFilePath), execaConfig);
|
|
53
59
|
} else {
|
|
54
60
|
const { handler: handler2 } = await import("@cedarjs/api-server/apiCliConfigHandler");
|
|
55
61
|
handler2();
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
async function runWebCommands() {
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
await installPackages(execaConfig);
|
|
66
|
+
runBinSync("cedar", ["build", "web", "--verbose"], execaConfig);
|
|
61
67
|
}
|
|
62
68
|
if (side === "api") {
|
|
63
69
|
runApiCommands();
|
|
@@ -7,22 +7,36 @@ import execa from "execa";
|
|
|
7
7
|
import { Listr } from "listr2";
|
|
8
8
|
import prompts from "prompts";
|
|
9
9
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
10
|
+
import {
|
|
11
|
+
formatAddRootPackagesCommand,
|
|
12
|
+
formatRunBinCommand
|
|
13
|
+
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
14
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
15
|
import { getPaths } from "../../lib/index.js";
|
|
11
16
|
const preRequisites = () => [
|
|
12
17
|
{
|
|
13
18
|
title: "Checking if Serverless framework is installed...",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
task: async () => {
|
|
20
|
+
try {
|
|
21
|
+
await runBin("serverless", ["--version"], { shell: true });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
24
|
+
throw new Error(
|
|
25
|
+
`${msg}
|
|
26
|
+
Looks like Serverless is not installed.
|
|
27
|
+
Please run ${formatAddRootPackagesCommand(["serverless"], true)}.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
];
|
|
21
33
|
const buildCommands = ({ sides }) => {
|
|
22
34
|
return [
|
|
23
35
|
{
|
|
24
36
|
title: `Building ${sides.join(" & ")}...`,
|
|
25
|
-
|
|
37
|
+
task: async () => {
|
|
38
|
+
await runBin("cedar", ["build", ...sides], { shell: true });
|
|
39
|
+
}
|
|
26
40
|
},
|
|
27
41
|
{
|
|
28
42
|
title: "Packing Functions...",
|
|
@@ -40,7 +54,7 @@ const deployCommands = ({ stage, sides, firstRun, packOnly }) => {
|
|
|
40
54
|
return {
|
|
41
55
|
title: `Deploying ${side}....`,
|
|
42
56
|
task: async () => {
|
|
43
|
-
await
|
|
57
|
+
await runBin("serverless", ["deploy", ...slsStage], {
|
|
44
58
|
cwd: path.join(getPaths().base, side),
|
|
45
59
|
shell: true,
|
|
46
60
|
stdio: "inherit",
|
|
@@ -93,8 +107,9 @@ const handler = async (yargs) => {
|
|
|
93
107
|
const SETUP_MARKER = ansis.bgBlue.black("First Setup ");
|
|
94
108
|
console.log();
|
|
95
109
|
console.log(SETUP_MARKER, c.success("Starting first setup wizard..."));
|
|
96
|
-
const { stdout: slsInfo } = await
|
|
97
|
-
|
|
110
|
+
const { stdout: slsInfo } = await runBin(
|
|
111
|
+
"serverless",
|
|
112
|
+
["info", "--verbose", `--stage=${yargs.stage}`],
|
|
98
113
|
{
|
|
99
114
|
shell: true,
|
|
100
115
|
cwd: getPaths().api.base
|
|
@@ -139,8 +154,9 @@ const handler = async (yargs) => {
|
|
|
139
154
|
}
|
|
140
155
|
);
|
|
141
156
|
await webDeployTasks.run();
|
|
142
|
-
const { stdout: slsInfo2 } = await
|
|
143
|
-
|
|
157
|
+
const { stdout: slsInfo2 } = await runBin(
|
|
158
|
+
"serverless",
|
|
159
|
+
["info", "--verbose", `--stage=${yargs.stage}`],
|
|
144
160
|
{
|
|
145
161
|
shell: true,
|
|
146
162
|
cwd: getPaths().web.base
|
|
@@ -153,7 +169,7 @@ const handler = async (yargs) => {
|
|
|
153
169
|
`View your deployed site at: ${c.success(deployedWebUrl)}`,
|
|
154
170
|
"",
|
|
155
171
|
"You can use serverless.com CI/CD by connecting/creating an app",
|
|
156
|
-
|
|
172
|
+
`To do this run \`${formatRunBinCommand("serverless")}\` on each of the sides, and connect your account`,
|
|
157
173
|
"",
|
|
158
174
|
"Find more information in our docs:",
|
|
159
175
|
c.underline("https://cedarjs.com/docs/deploy#serverless")
|
package/dist/lib/index.js
CHANGED
|
@@ -13,6 +13,10 @@ import template from "lodash/template.js";
|
|
|
13
13
|
import pascalcase from "pascalcase";
|
|
14
14
|
import { format } from "prettier";
|
|
15
15
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
16
|
+
import {
|
|
17
|
+
addRootPackages,
|
|
18
|
+
addWorkspacePackages
|
|
19
|
+
} from "@cedarjs/cli-helpers/packageManager/packages";
|
|
16
20
|
import {
|
|
17
21
|
getConfig as getRedwoodConfig,
|
|
18
22
|
getPaths as getRedwoodPaths,
|
|
@@ -364,30 +368,18 @@ const addPackagesTask = async ({
|
|
|
364
368
|
return pkg;
|
|
365
369
|
}
|
|
366
370
|
});
|
|
367
|
-
let installCommand;
|
|
368
|
-
if (side !== "project") {
|
|
369
|
-
installCommand = [
|
|
370
|
-
"yarn",
|
|
371
|
-
[
|
|
372
|
-
"workspace",
|
|
373
|
-
side,
|
|
374
|
-
"add",
|
|
375
|
-
devDependency && "--dev",
|
|
376
|
-
...packagesWithSameRWVersion
|
|
377
|
-
].filter(Boolean)
|
|
378
|
-
];
|
|
379
|
-
} else {
|
|
380
|
-
installCommand = [
|
|
381
|
-
"yarn",
|
|
382
|
-
["add", devDependency && "--dev", ...packagesWithSameRWVersion].filter(
|
|
383
|
-
Boolean
|
|
384
|
-
)
|
|
385
|
-
];
|
|
386
|
-
}
|
|
387
371
|
return {
|
|
388
372
|
title: `Adding dependencies to ${side}`,
|
|
389
373
|
task: async () => {
|
|
390
|
-
|
|
374
|
+
if (side !== "project") {
|
|
375
|
+
await addWorkspacePackages(side, packagesWithSameRWVersion, {
|
|
376
|
+
dev: devDependency
|
|
377
|
+
});
|
|
378
|
+
} else {
|
|
379
|
+
await addRootPackages(packagesWithSameRWVersion, {
|
|
380
|
+
dev: devDependency
|
|
381
|
+
});
|
|
382
|
+
}
|
|
391
383
|
}
|
|
392
384
|
};
|
|
393
385
|
};
|
package/dist/lib/updateCheck.js
CHANGED
|
@@ -4,6 +4,8 @@ import ansis from "ansis";
|
|
|
4
4
|
import boxen from "boxen";
|
|
5
5
|
import latestVersion from "latest-version";
|
|
6
6
|
import semver from "semver";
|
|
7
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
9
|
import { getConfig } from "@cedarjs/project-config";
|
|
8
10
|
import { spawnBackgroundProcess } from "./background.js";
|
|
9
11
|
import { isLockSet, setLock, unsetLock } from "./locking.js";
|
|
@@ -88,7 +90,7 @@ function getUpdateMessage() {
|
|
|
88
90
|
const data = readUpdateDataFile();
|
|
89
91
|
const localTag = extractTagFromVersion(data.localVersion) || "latest";
|
|
90
92
|
let updateCount = 0;
|
|
91
|
-
let message =
|
|
93
|
+
let message = ` New updates to Cedar are available via \`${formatCedarCommand(["upgrade#REPLACEME#"])}\` `;
|
|
92
94
|
data.remoteVersions.forEach((version, tag) => {
|
|
93
95
|
if (semver.gt(version, data.localVersion)) {
|
|
94
96
|
updateCount += 1;
|
|
@@ -182,10 +184,10 @@ function updateCheckMiddleware(argv) {
|
|
|
182
184
|
}
|
|
183
185
|
if (shouldCheck()) {
|
|
184
186
|
setLock(CHECK_LOCK_IDENTIFIER);
|
|
185
|
-
|
|
186
|
-
"node",
|
|
187
|
+
const [bgCmd, bgArgs] = getNodeRunnerArgs(
|
|
187
188
|
path.join(import.meta.dirname, "updateCheckExecute.js")
|
|
188
|
-
|
|
189
|
+
);
|
|
190
|
+
spawnBackgroundProcess("updateCheck", bgCmd, bgArgs);
|
|
189
191
|
} else if (shouldShow()) {
|
|
190
192
|
setLock(SHOW_LOCK_IDENTIFIER);
|
|
191
193
|
process.on("exit", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2480",
|
|
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.3",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "5.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.2480",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2480",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2480",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2480",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2480",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2480",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2480",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2480",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2480",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2480",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2480",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|