@cedarjs/cli 5.0.0-canary.2478 → 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/commands/generate/cell/cellHandler.js +2 -1
- package/dist/commands/generate/dataMigration/dataMigration.js +10 -6
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +13 -4
- package/dist/commands/generate/directive/directiveHandler.js +3 -3
- package/dist/commands/generate/job/jobHandler.js +2 -3
- package/dist/commands/generate/package/packageHandler.js +5 -5
- package/dist/commands/generate/scaffold/scaffoldHandler.js +6 -3
- package/dist/commands/generate.js +2 -2
- package/dist/lib/index.js +13 -21
- package/dist/lib/test.js +4 -0
- 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")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import pascalcase from "pascalcase";
|
|
2
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
2
3
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
3
4
|
import { isPlural, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
4
5
|
import { nameVariants, transformTSToJS } from "../../../lib/index.js";
|
|
@@ -141,7 +142,7 @@ const handler = createHandler({
|
|
|
141
142
|
addFunctionToRollback(generateTypes, true);
|
|
142
143
|
} else {
|
|
143
144
|
task.skip(
|
|
144
|
-
`Skipping type generation: no SDL defined for "${queryFieldName}". To generate types, run '
|
|
145
|
+
`Skipping type generation: no SDL defined for "${queryFieldName}". To generate types, run '${formatCedarCommand(["generate", "sdl", queryFieldName])}'.`
|
|
145
146
|
);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
@@ -3,6 +3,7 @@ import { paramCase } from "change-case";
|
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
5
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
7
|
import { getDataMigrationsPath } from "@cedarjs/project-config";
|
|
7
8
|
import {
|
|
8
9
|
generateTemplate,
|
|
@@ -12,14 +13,16 @@ import {
|
|
|
12
13
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
13
14
|
import { validateName } from "../helpers.js";
|
|
14
15
|
import { getYargsDefaults } from "../yargsCommandHelpers.js";
|
|
15
|
-
|
|
16
|
+
function getPostRunInstructions() {
|
|
17
|
+
const text = c.warning("After writing your migration, you can run it with:");
|
|
18
|
+
const command2 = formatCedarCommand(["dataMigrate", "up"]);
|
|
19
|
+
return `Next steps...
|
|
16
20
|
|
|
17
|
-
${
|
|
18
|
-
"After writing your migration, you can run it with:"
|
|
19
|
-
)}
|
|
21
|
+
${text}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
${command2}
|
|
22
24
|
`;
|
|
25
|
+
}
|
|
23
26
|
const TEMPLATE_PATHS = {
|
|
24
27
|
js: path.resolve(
|
|
25
28
|
import.meta.dirname,
|
|
@@ -89,7 +92,7 @@ const handler = async (args) => {
|
|
|
89
92
|
{
|
|
90
93
|
title: "Next steps...",
|
|
91
94
|
task: (_ctx, task) => {
|
|
92
|
-
task.title =
|
|
95
|
+
task.title = getPostRunInstructions();
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
].filter(Boolean),
|
|
@@ -111,5 +114,6 @@ export {
|
|
|
111
114
|
command,
|
|
112
115
|
description,
|
|
113
116
|
files,
|
|
117
|
+
getPostRunInstructions,
|
|
114
118
|
handler
|
|
115
119
|
};
|
|
@@ -2,10 +2,11 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4
4
|
import { camelCase } from "camel-case";
|
|
5
|
-
import execa from "execa";
|
|
6
5
|
import { Listr } from "listr2";
|
|
7
6
|
import { titleCase } from "title-case";
|
|
8
7
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
8
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
9
10
|
import {
|
|
10
11
|
addRoutesToRouterTask,
|
|
11
12
|
addScaffoldImport,
|
|
@@ -36,7 +37,11 @@ function getPostInstallMessage(isDbAuthSetup2) {
|
|
|
36
37
|
" logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
|
|
37
38
|
" and ResetPasswordPage to change where the user redirects to after submitting",
|
|
38
39
|
" those forms.\n",
|
|
39
|
-
!isDbAuthSetup2 &&
|
|
40
|
+
!isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
|
|
41
|
+
app setup by running:
|
|
42
|
+
|
|
43
|
+
${formatCedarCommand(["setup", "auth", "dbAuth"])}
|
|
44
|
+
`,
|
|
40
45
|
" Happy authenticating!"
|
|
41
46
|
].filter(Boolean).join("\n");
|
|
42
47
|
}
|
|
@@ -55,7 +60,11 @@ function getPostInstallWebauthnMessage(isDbAuthSetup2) {
|
|
|
55
60
|
" logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
|
|
56
61
|
" and ResetPasswordPage to change where the user redirects to after submitting",
|
|
57
62
|
" those forms.\n",
|
|
58
|
-
!isDbAuthSetup2 &&
|
|
63
|
+
!isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
|
|
64
|
+
app setup by running:
|
|
65
|
+
|
|
66
|
+
${formatCedarCommand(["setup", "auth", "dbAuth"])}
|
|
67
|
+
`,
|
|
59
68
|
" Happy authenticating!"
|
|
60
69
|
].filter(Boolean).join("\n");
|
|
61
70
|
}
|
|
@@ -303,7 +312,7 @@ const tasks = ({
|
|
|
303
312
|
{
|
|
304
313
|
title: "Generate types...",
|
|
305
314
|
task: () => {
|
|
306
|
-
|
|
315
|
+
runBinSync("cedar", ["g", "types"]);
|
|
307
316
|
}
|
|
308
317
|
},
|
|
309
318
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import camelcase from "camelcase";
|
|
2
|
-
import execa from "execa";
|
|
3
2
|
import { Listr } from "listr2";
|
|
4
3
|
import prompts from "prompts";
|
|
5
4
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
6
6
|
import { getConfig } from "@cedarjs/project-config";
|
|
7
7
|
import { writeFilesTask, transformTSToJS } from "../../../lib/index.js";
|
|
8
8
|
import {
|
|
@@ -109,9 +109,9 @@ const handler = async (args) => {
|
|
|
109
109
|
title: "Generating TypeScript definitions and GraphQL schemas ...",
|
|
110
110
|
task: () => {
|
|
111
111
|
addFunctionToRollback(async () => {
|
|
112
|
-
await
|
|
112
|
+
await runBin("cedar-gen", [], { stdio: "pipe" });
|
|
113
113
|
}, true);
|
|
114
|
-
return
|
|
114
|
+
return runBin("cedar-gen", [], { stdio: "inherit" });
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import * as changeCase from "change-case";
|
|
4
|
-
import execa from "execa";
|
|
5
4
|
import { Listr } from "listr2";
|
|
6
5
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import {
|
|
9
9
|
getPaths,
|
|
@@ -100,8 +100,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
100
100
|
{
|
|
101
101
|
title: "Cleaning up...",
|
|
102
102
|
task: () => {
|
|
103
|
-
|
|
104
|
-
"eslint",
|
|
103
|
+
runBinSync("eslint", [
|
|
105
104
|
"--fix",
|
|
106
105
|
"--config",
|
|
107
106
|
`${getPaths().base}/node_modules/@cedarjs/eslint-config/shared.js`,
|
|
@@ -2,13 +2,14 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4
4
|
import { paramCase, camelCase } from "change-case";
|
|
5
|
-
import execa from "execa";
|
|
6
5
|
import { modify, applyEdits } from "jsonc-parser";
|
|
7
6
|
import { Listr } from "listr2";
|
|
8
7
|
import { terminalLink } from "termi-link";
|
|
9
8
|
import ts from "typescript";
|
|
10
9
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
11
10
|
import { workspacePackageSpecifier } from "@cedarjs/cli-helpers/packageManager";
|
|
11
|
+
import { runScript, runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
12
|
+
import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
12
13
|
import { getConfig } from "@cedarjs/project-config";
|
|
13
14
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
14
15
|
import { getPaths, writeFilesTask } from "../../../lib/index.js";
|
|
@@ -244,8 +245,8 @@ function updateWorkspaceTsconfigReferences(task, folderName, targetWorkspaces) {
|
|
|
244
245
|
}
|
|
245
246
|
async function installAndBuild(folderName) {
|
|
246
247
|
const packagePath = path.join("packages", folderName);
|
|
247
|
-
await
|
|
248
|
-
await
|
|
248
|
+
await installPackages({ stdio: "inherit", cwd: getPaths().base });
|
|
249
|
+
await runScript("build", [], { stdio: "inherit", cwd: packagePath });
|
|
249
250
|
}
|
|
250
251
|
const handler = async ({ name, force, ...rest }) => {
|
|
251
252
|
recordTelemetryAttributes({
|
|
@@ -425,8 +426,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
425
426
|
{
|
|
426
427
|
title: "Cleaning up...",
|
|
427
428
|
task: () => {
|
|
428
|
-
|
|
429
|
-
"eslint",
|
|
429
|
+
runBinSync("eslint", [
|
|
430
430
|
"--fix",
|
|
431
431
|
"--config",
|
|
432
432
|
`${getPaths().base}/node_modules/@cedarjs/eslint-config/index.js`,
|
|
@@ -2,11 +2,14 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import camelcase from "camelcase";
|
|
4
4
|
import { paramCase } from "change-case";
|
|
5
|
-
import execa from "execa";
|
|
6
5
|
import humanize from "humanize-string";
|
|
7
6
|
import { Listr } from "listr2";
|
|
8
7
|
import pascalcase from "pascalcase";
|
|
9
8
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
9
|
+
import {
|
|
10
|
+
addWorkspacePackages,
|
|
11
|
+
removeWorkspacePackages
|
|
12
|
+
} from "@cedarjs/cli-helpers/packageManager/packages";
|
|
10
13
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
11
14
|
import { getConfig } from "@cedarjs/project-config";
|
|
12
15
|
import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
@@ -500,9 +503,9 @@ const addHelperPackages = async (task) => {
|
|
|
500
503
|
if (packageJson.default.dependencies["humanize-string"]) {
|
|
501
504
|
return task.skip("Skipping. Already installed");
|
|
502
505
|
}
|
|
503
|
-
await
|
|
506
|
+
await addWorkspacePackages("web", ["humanize-string@2.1.0"]);
|
|
504
507
|
addFunctionToRollback(async () => {
|
|
505
|
-
await
|
|
508
|
+
await removeWorkspacePackages("web", ["humanize-string"]);
|
|
506
509
|
});
|
|
507
510
|
};
|
|
508
511
|
const addSetImport = (task) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import execa from "execa";
|
|
2
1
|
import { terminalLink } from "termi-link";
|
|
3
2
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
4
|
import * as generateCell from "./generate/cell/cell.js";
|
|
5
5
|
import * as generateComponent from "./generate/component/component.js";
|
|
6
6
|
import * as generateDataMigration from "./generate/dataMigration/dataMigration.js";
|
|
@@ -32,7 +32,7 @@ const getExitCode = (error) => {
|
|
|
32
32
|
const builder = (yargs) => yargs.command("types", "Generate supplementary code", {}, () => {
|
|
33
33
|
recordTelemetryAttributes({ command: "generate types" });
|
|
34
34
|
try {
|
|
35
|
-
|
|
35
|
+
runBinSync("cedar-gen", [], { stdio: "inherit" });
|
|
36
36
|
} catch (error) {
|
|
37
37
|
process.exitCode = getExitCode(error) ?? 1;
|
|
38
38
|
}
|
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/test.js
CHANGED
|
@@ -76,6 +76,10 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
|
+
vi.mock("@cedarjs/project-config/packageManager", () => ({
|
|
80
|
+
getPackageManager: vi.fn(() => "yarn"),
|
|
81
|
+
resetPackageManagerCache: vi.fn()
|
|
82
|
+
}));
|
|
79
83
|
vi.mock("@cedarjs/cli-helpers", async (importOriginal) => {
|
|
80
84
|
const originalCliHelpers = await importOriginal();
|
|
81
85
|
return {
|
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",
|