@cedarjs/cli 1.1.1-next.18 → 1.1.1-next.21

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.
@@ -26,6 +26,7 @@ const builder = (yargs) => {
26
26
  "https://cedarjs.com/docs/cli-commands#deploy"
27
27
  )}`
28
28
  );
29
+ return yargs;
29
30
  };
30
31
  async function handler(yargs) {
31
32
  const { handler: importedHandler } = await import("./flightcontrolHandler.js");
@@ -3,7 +3,12 @@ import execa from "execa";
3
3
  import fs from "fs-extra";
4
4
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
5
  import { getPaths } from "@cedarjs/project-config";
6
- const handler = async ({ side, serve, prisma, dm: dataMigrate }) => {
6
+ const handler = async ({
7
+ side,
8
+ serve,
9
+ prisma,
10
+ dm: dataMigrate
11
+ }) => {
7
12
  recordTelemetryAttributes({
8
13
  command: "deploy flightcontrol",
9
14
  side,
@@ -17,20 +22,26 @@ const handler = async ({ side, serve, prisma, dm: dataMigrate }) => {
17
22
  shell: true,
18
23
  stdio: "inherit"
19
24
  };
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
+ }
20
32
  async function runApiCommands() {
21
33
  if (!serve) {
22
34
  console.log("Building api...");
23
- execa.commandSync("yarn rw build api --verbose", execaConfig);
35
+ await runExecaCommand("yarn rw build api --verbose");
24
36
  if (prisma) {
25
37
  console.log("Running database migrations...");
26
- execa.commandSync(
27
- `node_modules/.bin/prisma migrate deploy --config "${rwjsPaths.api.prismaConfig}"`,
28
- execaConfig
38
+ await runExecaCommand(
39
+ `node_modules/.bin/prisma migrate deploy --config "${rwjsPaths.api.prismaConfig}"`
29
40
  );
30
41
  }
31
42
  if (dataMigrate) {
32
43
  console.log("Running data migrations...");
33
- execa.commandSync("yarn rw dataMigrate up", execaConfig);
44
+ await runExecaCommand("yarn rw dataMigrate up");
34
45
  }
35
46
  return;
36
47
  }
@@ -45,12 +56,12 @@ const handler = async ({ side, serve, prisma, dm: dataMigrate }) => {
45
56
  }
46
57
  async function runWebCommands() {
47
58
  console.log("Building web...");
48
- execa.commandSync("yarn rw build web --verbose", execaConfig);
59
+ await runExecaCommand("yarn rw build web --verbose");
49
60
  }
50
61
  if (side === "api") {
51
- runApiCommands();
62
+ await runApiCommands();
52
63
  } else if (side === "web") {
53
- runWebCommands();
64
+ await runWebCommands();
54
65
  }
55
66
  };
56
67
  export {
@@ -35,6 +35,11 @@ const builder = (yargs) => {
35
35
  description: "Skip dedupe check with --no-dedupe",
36
36
  type: "boolean",
37
37
  default: true
38
+ }).option("yes", {
39
+ alias: "y",
40
+ describe: "Skip prompts and use defaults",
41
+ default: false,
42
+ type: "boolean"
38
43
  }).epilogue(
39
44
  `Also see the ${terminalLink(
40
45
  "CedarJS CLI Reference for the upgrade command",
@@ -64,16 +69,42 @@ const validateTag = (tag) => {
64
69
  }
65
70
  return tag;
66
71
  };
67
- const handler = async ({ dryRun, tag, verbose, dedupe }) => {
72
+ const handler = async ({ dryRun, tag, verbose, dedupe, yes }) => {
68
73
  recordTelemetryAttributes({
69
74
  command: "upgrade",
70
75
  dryRun,
71
76
  tag,
72
77
  verbose,
73
- dedupe
78
+ dedupe,
79
+ yes
74
80
  });
75
81
  const tasks = new Listr(
76
82
  [
83
+ {
84
+ title: "Confirm upgrade",
85
+ task: async (ctx, task) => {
86
+ if (yes) {
87
+ task.skip("Skipping confirmation prompt because of --yes flag.");
88
+ return;
89
+ }
90
+ const proceed = await task.prompt({
91
+ type: "Confirm",
92
+ message: "This will upgrade your RedwoodJS project to the latest version. Do you want to proceed?",
93
+ initial: "Y",
94
+ default: "(Yes/no)",
95
+ format: function(value) {
96
+ if (this.state.submitted) {
97
+ return this.isTrue(value) ? "yes" : "no";
98
+ }
99
+ return "Yes";
100
+ }
101
+ });
102
+ if (!proceed) {
103
+ task.skip("Upgrade cancelled by user.");
104
+ process.exit(0);
105
+ }
106
+ }
107
+ },
77
108
  {
78
109
  title: "Checking latest version",
79
110
  task: async (ctx) => setLatestVersionToContext(ctx, tag)
@@ -164,7 +195,7 @@ const handler = async ({ dryRun, tag, verbose, dedupe }) => {
164
195
  }
165
196
  ],
166
197
  {
167
- renderer: verbose && "verbose",
198
+ renderer: verbose ? "verbose" : "default",
168
199
  rendererOptions: { collapseSubtasks: false }
169
200
  }
170
201
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "1.1.1-next.18+5ffd3124d",
3
+ "version": "1.1.1-next.21+77cfbaa90",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,15 +31,15 @@
31
31
  "dependencies": {
32
32
  "@babel/preset-typescript": "7.27.1",
33
33
  "@babel/runtime-corejs3": "7.27.6",
34
- "@cedarjs/api-server": "1.1.1-next.18+5ffd3124d",
35
- "@cedarjs/cli-helpers": "1.1.1-next.18+5ffd3124d",
36
- "@cedarjs/fastify-web": "1.1.1-next.18+5ffd3124d",
37
- "@cedarjs/internal": "1.1.1-next.18+5ffd3124d",
38
- "@cedarjs/prerender": "1.1.1-next.18+5ffd3124d",
39
- "@cedarjs/project-config": "1.1.1-next.18+5ffd3124d",
40
- "@cedarjs/structure": "1.1.1-next.18+5ffd3124d",
41
- "@cedarjs/telemetry": "1.1.1-next.18+5ffd3124d",
42
- "@cedarjs/web-server": "1.1.1-next.18+5ffd3124d",
34
+ "@cedarjs/api-server": "1.1.1-next.21+77cfbaa90",
35
+ "@cedarjs/cli-helpers": "1.1.1-next.21+77cfbaa90",
36
+ "@cedarjs/fastify-web": "1.1.1-next.21+77cfbaa90",
37
+ "@cedarjs/internal": "1.1.1-next.21+77cfbaa90",
38
+ "@cedarjs/prerender": "1.1.1-next.21+77cfbaa90",
39
+ "@cedarjs/project-config": "1.1.1-next.21+77cfbaa90",
40
+ "@cedarjs/structure": "1.1.1-next.21+77cfbaa90",
41
+ "@cedarjs/telemetry": "1.1.1-next.21+77cfbaa90",
42
+ "@cedarjs/web-server": "1.1.1-next.21+77cfbaa90",
43
43
  "@listr2/prompt-adapter-enquirer": "2.0.16",
44
44
  "@opentelemetry/api": "1.8.0",
45
45
  "@opentelemetry/core": "1.22.0",
@@ -101,5 +101,5 @@
101
101
  "publishConfig": {
102
102
  "access": "public"
103
103
  },
104
- "gitHead": "5ffd3124d3d4ceb7843408264c96ecceff8542f5"
104
+ "gitHead": "77cfbaa90a726923a763fb33b836638d94b2d431"
105
105
  }