@cedarjs/cli 0.0.4 → 1.0.0-canary.12245

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.
@@ -5,10 +5,8 @@ import { Listr } from "listr2";
5
5
  import * as toml from "smol-toml";
6
6
  import { env as envInterpolation } from "string-env-interpolation";
7
7
  import { titleCase } from "title-case";
8
- import { recordTelemetryAttributes } from "@redmix/cli-helpers";
9
8
  import c from "../../../lib/colors.js";
10
9
  import { getPaths } from "../../../lib/index.js";
11
- import { SshExecutor } from "./SshExecutor.js";
12
10
  const CONFIG_FILENAME = "deploy.toml";
13
11
  const SYMLINK_FLAGS = "-nsf";
14
12
  const CURRENT_RELEASE_SYMLINK_NAME = "current";
@@ -19,7 +17,8 @@ const DEFAULT_SERVER_CONFIG = {
19
17
  packageManagerCommand: "yarn",
20
18
  monitorCommand: "pm2",
21
19
  sides: ["api", "web"],
22
- keepReleases: 5
20
+ keepReleases: 5,
21
+ freeSpaceRequired: 2048
23
22
  };
24
23
  const pathJoin = path.posix.join;
25
24
  const throwMissingConfig = (name) => {
@@ -48,7 +47,7 @@ const verifyServerConfig = (config) => {
48
47
  if (!config.repo) {
49
48
  throwMissingConfig("repo");
50
49
  }
51
- if (config.freeSpaceRequired && !/^\d+$/.test(config.freeSpaceRequired)) {
50
+ if (!/^\d+$/.test(config.freeSpaceRequired)) {
52
51
  throw new Error('"freeSpaceRequired" must be an integer >= 0');
53
52
  }
54
53
  return true;
@@ -232,15 +231,8 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
232
231
  10
233
232
  );
234
233
  if (dfMb < freeSpaceRequired) {
235
- if (typeof serverConfig.freeSpaceRequired === "undefined") {
236
- return task.skip(
237
- c.warning(
238
- `Warning: Your server is running low on disk space. (${Math.round(dfMb)}MB available)`
239
- )
240
- );
241
- }
242
234
  throw new Error(
243
- `Not enough disk space. You need at least ${freeSpaceRequired}MB free space to continue.`
235
+ `Not enough disk space. You need at least ${freeSpaceRequired}MB free space to continue. (Currently ${Math.round(dfMb)}MB available)`
244
236
  );
245
237
  }
246
238
  }
@@ -499,20 +491,7 @@ const commands = (yargs, ssh) => {
499
491
  return servers;
500
492
  };
501
493
  const handler = async (yargs) => {
502
- recordTelemetryAttributes({
503
- command: "deploy baremetal",
504
- firstRun: yargs.firstRun,
505
- df: yargs.df,
506
- update: yargs.update,
507
- install: yargs.install,
508
- migrate: yargs.migrate,
509
- build: yargs.build,
510
- restart: yargs.restart,
511
- cleanup: yargs.cleanup,
512
- maintenance: yargs.maintenance,
513
- rollback: yargs.rollback,
514
- verbose: yargs.verbose
515
- });
494
+ const { SshExecutor } = await import("./SshExecutor.js");
516
495
  const tomlPath = path.join(getPaths().base, "deploy.toml");
517
496
  const ecosystemPath = path.join(getPaths().base, "ecosystem.config.js");
518
497
  if (!fs.existsSync(tomlPath) || !fs.existsSync(ecosystemPath)) {
@@ -1,4 +1,5 @@
1
1
  import terminalLink from "terminal-link";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
3
  const command = "baremetal [environment]";
3
4
  const description = "Deploy to baremetal server(s)";
4
5
  const builder = (yargs) => {
@@ -78,8 +79,22 @@ const builder = (yargs) => {
78
79
  );
79
80
  };
80
81
  async function handler(yargs) {
81
- const { handler: importedHandler } = await import("./baremetal/baremetalHandler.js");
82
- return importedHandler(yargs);
82
+ recordTelemetryAttributes({
83
+ command: "deploy baremetal",
84
+ firstRun: yargs.firstRun,
85
+ df: yargs.df,
86
+ update: yargs.update,
87
+ install: yargs.install,
88
+ migrate: yargs.migrate,
89
+ build: yargs.build,
90
+ restart: yargs.restart,
91
+ cleanup: yargs.cleanup,
92
+ maintenance: yargs.maintenance,
93
+ rollback: yargs.rollback,
94
+ verbose: yargs.verbose
95
+ });
96
+ const { handler: baremetalHandler } = await import("./baremetal/baremetalHandler.js");
97
+ return baremetalHandler(yargs);
83
98
  }
84
99
  export {
85
100
  builder,
@@ -26,6 +26,7 @@ const builder = (yargs) => {
26
26
  "https://redwoodjs.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 --schema "${rwjsPaths.api.dbSchema}"`,
28
- execaConfig
38
+ await runExecaCommand(
39
+ `node_modules/.bin/prisma migrate deploy --schema "${rwjsPaths.api.dbSchema}"`
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 {
@@ -45,6 +45,11 @@ const handler = async (args) => {
45
45
  printAvailableScriptsToConsole();
46
46
  return;
47
47
  }
48
+ scriptArgs._ = scriptArgs._.slice(1);
49
+ delete scriptArgs.$0;
50
+ delete scriptArgs.l;
51
+ delete scriptArgs.s;
52
+ delete scriptArgs.silent;
48
53
  const {
49
54
  overrides: _overrides,
50
55
  plugins: webPlugins,
@@ -1,5 +1,5 @@
1
1
  {
2
- "Welcome to Cedar": "Welcome to Cedar",
2
+ "Welcome to CedarJS": "Welcome to CedarJS",
3
3
  "info": "This is your English translation file",
4
4
  "see": "https://www.i18next.com/translation-function/essentials",
5
5
  "HomePage": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "Welcome to Cedar": "Bienvenu sur Cedar",
2
+ "Welcome to CedarJS": "Bienvenu sur CedarJS",
3
3
  "info": "Ceci est votre fichier de traduction",
4
4
  "see": "https://www.i18next.com/translation-function/essentials",
5
5
  "HomePage": {
@@ -1,4 +1,5 @@
1
1
  import path from "path";
2
+ import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
2
3
  import execa from "execa";
3
4
  import fs from "fs-extra";
4
5
  import latestVersion from "latest-version";
@@ -35,6 +36,11 @@ const builder = (yargs) => {
35
36
  description: "Skip dedupe check with --no-dedupe",
36
37
  type: "boolean",
37
38
  default: true
39
+ }).option("yes", {
40
+ alias: "y",
41
+ describe: "Skip prompts and use defaults",
42
+ default: false,
43
+ type: "boolean"
38
44
  }).epilogue(
39
45
  `Also see the ${terminalLink(
40
46
  "Cedar CLI Reference for the upgrade command",
@@ -64,16 +70,43 @@ const validateTag = (tag) => {
64
70
  }
65
71
  return tag;
66
72
  };
67
- const handler = async ({ dryRun, tag, verbose, dedupe }) => {
73
+ const handler = async ({ dryRun, tag, verbose, dedupe, yes }) => {
68
74
  recordTelemetryAttributes({
69
75
  command: "upgrade",
70
76
  dryRun,
71
77
  tag,
72
78
  verbose,
73
- dedupe
79
+ dedupe,
80
+ yes
74
81
  });
75
82
  const tasks = new Listr(
76
83
  [
84
+ {
85
+ title: "Confirm upgrade",
86
+ task: async (ctx, task) => {
87
+ if (yes) {
88
+ task.skip("Skipping confirmation prompt because of --yes flag.");
89
+ return;
90
+ }
91
+ const prompt = task.prompt(ListrEnquirerPromptAdapter);
92
+ const proceed = await prompt.run({
93
+ type: "Confirm",
94
+ message: "This will upgrade your Cedar project to the latest version. Do you want to proceed?",
95
+ initial: "Y",
96
+ default: "(Yes/no)",
97
+ format: function(value) {
98
+ if (this.state.submitted) {
99
+ return this.isTrue(value) ? "yes" : "no";
100
+ }
101
+ return "Yes";
102
+ }
103
+ });
104
+ if (!proceed) {
105
+ task.skip("Upgrade cancelled by user.");
106
+ process.exit(0);
107
+ }
108
+ }
109
+ },
77
110
  {
78
111
  title: "Checking latest version",
79
112
  task: async (ctx) => setLatestVersionToContext(ctx, tag)
@@ -162,7 +195,7 @@ const handler = async ({ dryRun, tag, verbose, dedupe }) => {
162
195
  }
163
196
  ],
164
197
  {
165
- renderer: verbose && "verbose",
198
+ renderer: verbose ? "verbose" : "default",
166
199
  rendererOptions: { collapseSubtasks: false }
167
200
  }
168
201
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "0.0.4",
3
+ "version": "1.0.0-canary.12245+706940287",
4
4
  "description": "The Redwood Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "tsx ./build.mts",
22
- "build:pack": "yarn pack -o cedar-cli.tgz",
22
+ "build:pack": "yarn pack -o cedarjs-cli.tgz",
23
23
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build && yarn fix:permissions\"",
24
24
  "dev": "RWJS_CWD=../../__fixtures__/example-todo-main node dist/index.js",
25
25
  "fix:permissions": "chmod +x dist/index.js dist/rwfw.js",
@@ -29,15 +29,15 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime-corejs3": "7.26.10",
32
- "@cedarjs/api-server": "0.0.4",
33
- "@cedarjs/cli-helpers": "0.0.4",
34
- "@cedarjs/fastify-web": "0.0.4",
35
- "@cedarjs/internal": "0.0.4",
36
- "@cedarjs/prerender": "0.0.4",
37
- "@cedarjs/project-config": "0.0.4",
38
- "@cedarjs/structure": "0.0.4",
39
- "@cedarjs/telemetry": "0.0.4",
40
- "@cedarjs/web-server": "0.0.4",
32
+ "@cedarjs/api-server": "1.0.0-canary.12245",
33
+ "@cedarjs/cli-helpers": "1.0.0-canary.12245",
34
+ "@cedarjs/fastify-web": "1.0.0-canary.12245",
35
+ "@cedarjs/internal": "1.0.0-canary.12245",
36
+ "@cedarjs/prerender": "1.0.0-canary.12245",
37
+ "@cedarjs/project-config": "1.0.0-canary.12245",
38
+ "@cedarjs/structure": "1.0.0-canary.12245",
39
+ "@cedarjs/telemetry": "1.0.0-canary.12245",
40
+ "@cedarjs/web-server": "1.0.0-canary.12245",
41
41
  "@listr2/prompt-adapter-enquirer": "2.0.12",
42
42
  "@opentelemetry/api": "1.8.0",
43
43
  "@opentelemetry/core": "1.22.0",
@@ -95,8 +95,5 @@
95
95
  "typescript": "5.6.2",
96
96
  "vitest": "2.1.9"
97
97
  },
98
- "publishConfig": {
99
- "access": "public"
100
- },
101
- "gitHead": "5b4f77f985bd86ee31ee7338312627accf0cb85b"
98
+ "gitHead": "7069402874ee21cec078b429514ebb1b273e4031"
102
99
  }