@cedarjs/cli 0.5.1-next.0 → 0.6.0

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/README.md CHANGED
@@ -659,7 +659,7 @@ We also use methods that we want to affect all commands here, like `demandComman
659
659
 
660
660
  #### lib/colors.js
661
661
 
662
- [colors.js](https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/lib/colors.js) provides a declarative way of coloring output to the console using [chalk](https://github.com/chalk/chalk#styles). You'll see it imported like:
662
+ [colors.js](https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/lib/colors.js) provides a declarative way of coloring output to the console using [ansis](https://github.com/webdiscus/ansis#styles). You'll see it imported like:
663
663
 
664
664
  ```javascript
665
665
  import c from '../lib/colors'
@@ -685,10 +685,10 @@ Adding a new color is as simple as adding a new property to the default export:
685
685
  // ./src/lib/colors.js
686
686
 
687
687
  export default {
688
- error: chalk.bold.red,
689
- warning: chalk.keyword('orange'),
690
- green: chalk.green,
691
- info: chalk.grey,
688
+ error: ansis.bold.red,
689
+ warning: ansis.hex('#ffa500'),
690
+ green: ansis.green,
691
+ info: ansis.gray,
692
692
  }
693
693
  ```
694
694
 
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
+ import ansis from "ansis";
2
3
  import boxen from "boxen";
3
- import chalk from "chalk";
4
4
  import { config } from "dotenv-defaults";
5
5
  import execa from "execa";
6
6
  import fs from "fs-extra";
@@ -91,7 +91,7 @@ const handler = async (yargs) => {
91
91
  try {
92
92
  await tasks.run();
93
93
  if (yargs.firstRun) {
94
- const SETUP_MARKER = chalk.bgBlue(chalk.black("First Setup "));
94
+ const SETUP_MARKER = ansis.bgBlue.black("First Setup ");
95
95
  console.log();
96
96
  console.log(SETUP_MARKER, c.success("Starting first setup wizard..."));
97
97
  const { stdout: slsInfo } = await execa(
@@ -1,5 +1,3 @@
1
- const command = "deploy <target>";
2
- const description = "Deploy your Redwood project";
3
1
  import { terminalLink } from "termi-link";
4
2
  import * as deployBaremetal from "./deploy/baremetal.js";
5
3
  import * as deployFlightcontrol from "./deploy/flightcontrol.js";
@@ -7,6 +5,8 @@ import * as deployNetlify from "./deploy/netlify.js";
7
5
  import * as deployRender from "./deploy/render.js";
8
6
  import * as deployServerless from "./deploy/serverless.js";
9
7
  import * as deployVercel from "./deploy/vercel.js";
8
+ const command = "deploy <target>";
9
+ const description = "Deploy your Redwood project";
10
10
  const builder = (yargs) => yargs.command(deployBaremetal).command(deployFlightcontrol).command(deployNetlify).command(deployRender).command(deployServerless).command(deployVercel).demandCommand().epilogue(
11
11
  `Also see the ${terminalLink(
12
12
  "Redwood CLI Reference",
@@ -1,7 +1,6 @@
1
- import { files as cellFiles } from "../../generate/cell/cellHandler.js";
2
1
  import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
3
2
  const { command, description, builder } = createYargsForComponentDestroy(
4
- { componentName: "cell", filesFn: cellFiles }
3
+ { componentName: "cell" }
5
4
  );
6
5
  const handler = createHandler("cell");
7
6
  export {
@@ -1,4 +1,4 @@
1
- import { files as cellFiles } from "../../generate/cell/cell.js";
1
+ import { files as cellFiles } from "../../generate/cell/cellHandler.js";
2
2
  import { createHandler } from "../handlerHelpers.js";
3
3
  const { handler, tasks } = createHandler({
4
4
  componentName: "cell",
@@ -1,9 +1,7 @@
1
- import { files as componentFiles } from "../../generate/component/componentHandler.js";
2
1
  import { createHandler, createYargsForComponentDestroy } from "../helpers.js";
3
2
  const description = "Destroy a component";
4
3
  const { command, builder, tasks } = createYargsForComponentDestroy({
5
- componentName: "component",
6
- filesFn: componentFiles
4
+ componentName: "component"
7
5
  });
8
6
  const handler = createHandler("component");
9
7
  export {
@@ -1,6 +1,3 @@
1
- const command = "destroy <type>";
2
- const aliases = ["d"];
3
- const description = "Rollback changes made by the generate command";
4
1
  import { terminalLink } from "termi-link";
5
2
  import * as destroyCell from "./destroy/cell/cell.js";
6
3
  import * as destroyComponent from "./destroy/component/component.js";
@@ -11,6 +8,9 @@ import * as destroyPage from "./destroy/page/page.js";
11
8
  import * as destroyScaffold from "./destroy/scaffold/scaffold.js";
12
9
  import * as destroySdl from "./destroy/sdl/sdl.js";
13
10
  import * as destroyService from "./destroy/service/service.js";
11
+ const command = "destroy <type>";
12
+ const aliases = ["d"];
13
+ const description = "Rollback changes made by the generate command";
14
14
  const builder = (yargs) => yargs.command(destroyCell).command(destroyComponent).command(destroyDirective).command(destroyFunction).command(destroyLayout).command(destroyPage).command(destroyScaffold).command(destroySdl).command(destroyService).demandCommand().epilogue(
15
15
  `Also see the ${terminalLink(
16
16
  "Redwood CLI Reference",
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import chalk from "chalk";
2
+ import ansis from "ansis";
3
3
  import fs from "fs-extra";
4
4
  import { terminalLink } from "termi-link";
5
5
  import { getPaths } from "../../lib/index.js";
@@ -21,9 +21,9 @@ Please find documentation and links to provide feedback for ${command} at:
21
21
  )}`;
22
22
  const printTaskEpilogue = (command, description, topicId) => {
23
23
  console.log(
24
- `${chalk.hex("#ff845e")(
24
+ `${ansis.hex("#ff845e")(
25
25
  `------------------------------------------------------------------
26
- \u{1F9EA} ${chalk.green(
26
+ \u{1F9EA} ${ansis.green(
27
27
  "Experimental Feature"
28
28
  )} \u{1F9EA}
29
29
  ------------------------------------------------------------------`
@@ -31,7 +31,7 @@ const printTaskEpilogue = (command, description, topicId) => {
31
31
  );
32
32
  console.log(getEpilogue(command, description, topicId, false));
33
33
  console.log(
34
- `${chalk.hex("#ff845e")(
34
+ `${ansis.hex("#ff845e")(
35
35
  "------------------------------------------------------------------"
36
36
  )}
37
37
  `
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
+ import ansis from "ansis";
2
3
  import boxen from "boxen";
3
4
  import camelcase from "camelcase";
4
- import chalk from "chalk";
5
5
  import { Listr } from "listr2";
6
6
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
7
7
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
@@ -29,11 +29,11 @@ import { files as serviceFiles } from "../service/serviceHandler.js";
29
29
  import { customOrDefaultTemplatePath } from "../yargsHandlerHelpers.js";
30
30
  const DEFAULT_IGNORE_FIELDS_FOR_INPUT = ["createdAt", "updatedAt"];
31
31
  const missingIdConsoleMessage = () => {
32
- const line1 = chalk.bold.yellow("WARNING") + ": Cannot generate CRUD SDL without an `@id` database column.";
32
+ const line1 = ansis.bold.yellow("WARNING") + ": Cannot generate CRUD SDL without an `@id` database column.";
33
33
  const line2 = "If you are trying to generate for a many-to-many join table ";
34
34
  const line3 = "you'll need to update your schema definition to include";
35
35
  const line4 = "an `@id` column. Read more here: ";
36
- const line5 = chalk.underline.blue(
36
+ const line5 = ansis.underline.blue(
37
37
  "https://redwoodjs.com/docs/schema-relations"
38
38
  );
39
39
  console.error(
@@ -1,15 +1,18 @@
1
1
  import { describe, it } from "vitest";
2
- describe("Middleware codemod", () => {
3
- it("Handles the default TSX case", async () => {
4
- await matchTransformSnapshot("codemodMiddleware", "defaultTsx");
5
- });
6
- it("Handles when OgImageMiddleware is already imported", async () => {
7
- await matchTransformSnapshot("codemodMiddleware", "alreadyContainsImport");
8
- });
9
- it("Handles when registerMiddleware function is already defined", async () => {
10
- await matchTransformSnapshot(
11
- "codemodMiddleware",
12
- "registerFunctionAlreadyDefined"
13
- );
14
- });
15
- });
2
+ describe.skipIf(process.env.CI && process.platform === "win32")(
3
+ "Middleware codemod",
4
+ () => {
5
+ it("Handles the default TSX case", async () => {
6
+ await matchTransformSnapshot("codemodMiddleware", "defaultTsx");
7
+ });
8
+ it("Handles when OgImageMiddleware is already imported", async () => {
9
+ await matchTransformSnapshot("codemodMiddleware", "alreadyContainsImport");
10
+ });
11
+ it("Handles when registerMiddleware function is already defined", async () => {
12
+ await matchTransformSnapshot(
13
+ "codemodMiddleware",
14
+ "registerFunctionAlreadyDefined"
15
+ );
16
+ });
17
+ }
18
+ );
@@ -1,6 +1,9 @@
1
1
  import { describe, it } from "vitest";
2
- describe("Vite plugin codemod", () => {
3
- it("Handles the default vite config case", async () => {
4
- await matchTransformSnapshot("codemodVitePlugin", "defaultViteConfig");
5
- });
6
- });
2
+ describe.skipIf(process.env.CI && process.platform === "win32")(
3
+ "Vite plugin codemod",
4
+ () => {
5
+ it("Handles the default vite config case", async () => {
6
+ await matchTransformSnapshot("codemodVitePlugin", "defaultViteConfig");
7
+ });
8
+ }
9
+ );
@@ -37,8 +37,8 @@ const builder = (yargs) => {
37
37
  default: true
38
38
  }).epilogue(
39
39
  `Also see the ${terminalLink(
40
- "Cedar CLI Reference for the upgrade command",
41
- "https://redwoodjs.com/docs/cli-commands#upgrade"
40
+ "CedarJS CLI Reference for the upgrade command",
41
+ "https://cedarjs.com/docs/cli-commands#upgrade"
42
42
  )}.
43
43
  And the ${terminalLink(
44
44
  "GitHub releases page",
@@ -50,11 +50,11 @@ const SEMVER_REGEX = /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*
50
50
  const isValidSemver = (string) => {
51
51
  return SEMVER_REGEX.test(string);
52
52
  };
53
- const isValidCedarTag = (tag) => {
53
+ const isValidCedarJSTag = (tag) => {
54
54
  return ["rc", "canary", "latest", "next", "experimental"].includes(tag);
55
55
  };
56
56
  const validateTag = (tag) => {
57
- const isTagValid = isValidSemver(tag) || isValidCedarTag(tag);
57
+ const isTagValid = isValidSemver(tag) || isValidCedarJSTag(tag);
58
58
  if (!isTagValid) {
59
59
  throw new Error(
60
60
  c.error(
@@ -80,7 +80,7 @@ const handler = async ({ dryRun, tag, verbose, dedupe }) => {
80
80
  },
81
81
  {
82
82
  title: "Updating your CedarJS version",
83
- task: (ctx) => updateCedarDepsForAllSides(ctx, { dryRun, verbose }),
83
+ task: (ctx) => updateCedarJSDepsForAllSides(ctx, { dryRun, verbose }),
84
84
  enabled: (ctx) => !!ctx.versionToUpgradeTo
85
85
  },
86
86
  {
@@ -126,24 +126,26 @@ const handler = async ({ dryRun, tag, verbose, dedupe }) => {
126
126
  `
127
127
  ];
128
128
  if ([void 0, "latest", "rc"].includes(tag)) {
129
+ const ghReleasesLink = terminalLink(
130
+ `GitHub Release notes`,
131
+ `https://github.com/cedarjs/cedar/releases`
132
+ // intentionally not linking to specific version
133
+ );
134
+ const discordLink = terminalLink(
135
+ `Discord`,
136
+ `https://cedarjs.com/discord`
137
+ );
129
138
  messageSections.push(
130
- ` Please review the release notes for any manual steps:
131
- \u2756 ${terminalLink(
132
- `Redwood community discussion`,
133
- `https://community.redwoodjs.com/c/announcements/releases-and-upgrade-guides/`
134
- )}
135
- \u2756 ${terminalLink(
136
- `GitHub Release notes`,
137
- `https://github.com/cedarjs/cedar/releases`
138
- // intentionally not linking to specific version
139
- )}
140
-
139
+ ` Please review the release notes for any manual steps:
140
+ \u2756 ${ghReleasesLink}
141
+ Join our Discord community if you have any questions or need support:
142
+ \u2756 ${discordLink}
141
143
  `
142
144
  );
143
145
  }
144
146
  if (tag) {
145
147
  const additionalMessages = [];
146
- if (!getConfig().notifications.versionUpdates.includes(tag) && isValidCedarTag(tag)) {
148
+ if (!getConfig().notifications.versionUpdates.includes(tag) && isValidCedarJSTag(tag)) {
147
149
  additionalMessages.push(
148
150
  ` \u2756 You may want to update your redwood.toml config so that \`notifications.versionUpdates\` includes "${tag}"
149
151
  `
@@ -246,7 +248,7 @@ function updatePackageJsonVersion(pkgPath, version, { dryRun, verbose }) {
246
248
  );
247
249
  }
248
250
  }
249
- function updateCedarDepsForAllSides(ctx, options) {
251
+ function updateCedarJSDepsForAllSides(ctx, options) {
250
252
  if (!ctx.versionToUpgradeTo) {
251
253
  throw new Error("Failed to upgrade");
252
254
  }
@@ -1,17 +1,17 @@
1
- import chalk from "chalk";
1
+ import ansis from "ansis";
2
2
  var colors_default = {
3
- error: chalk.bold.red,
4
- warning: chalk.hex("#ffa500"),
5
- highlight: chalk.hex("#ffa500"),
6
- success: chalk.green,
7
- info: chalk.grey,
8
- bold: chalk.bold,
9
- underline: chalk.underline,
10
- note: chalk.blue,
11
- tip: chalk.green,
12
- important: chalk.magenta,
13
- caution: chalk.red,
14
- link: chalk.underline
3
+ error: ansis.bold.red,
4
+ warning: ansis.hex("#ffa500"),
5
+ highlight: ansis.hex("#ffa500"),
6
+ success: ansis.green,
7
+ info: ansis.gray,
8
+ bold: ansis.bold,
9
+ underline: ansis.underline,
10
+ note: ansis.blue,
11
+ tip: ansis.green,
12
+ important: ansis.magenta,
13
+ caution: ansis.red,
14
+ link: ansis.underline
15
15
  };
16
16
  export {
17
17
  colors_default as default
@@ -1,25 +1,8 @@
1
- import { createRequire } from "node:module";
2
- import path from "node:path";
3
1
  import {
4
2
  getWebSideDefaultBabelConfig,
5
3
  registerApiSideBabelHook
6
4
  } from "@cedarjs/babel-config";
7
5
  import { getPaths } from "@cedarjs/project-config";
8
- async function runScriptFunction({
9
- path: scriptPath,
10
- functionName,
11
- args
12
- }) {
13
- const createdRequire = createRequire(import.meta.url);
14
- const script = createdRequire(scriptPath);
15
- const returnValue = await script[functionName](args);
16
- try {
17
- const { db } = createdRequire(path.join(getPaths().api.lib, "db"));
18
- db.$disconnect();
19
- } catch (e) {
20
- }
21
- return returnValue;
22
- }
23
6
  function configureBabel() {
24
7
  const {
25
8
  overrides: _overrides,
@@ -80,6 +63,5 @@ function configureBabel() {
80
63
  });
81
64
  }
82
65
  export {
83
- configureBabel,
84
- runScriptFunction
66
+ configureBabel
85
67
  };
package/dist/lib/exit.js CHANGED
@@ -1,4 +1,4 @@
1
- import chalk from "chalk";
1
+ import ansis from "ansis";
2
2
  import { terminalLink } from "termi-link";
3
3
  import { v4 as uuidv4 } from "uuid";
4
4
  import {
@@ -23,7 +23,7 @@ function exitWithError(error, { exitCode, message, epilogue, includeEpilogue, in
23
23
  includeReferenceCode ??= true;
24
24
  message ??= error.stack ?? (error.toString() || "Unknown error");
25
25
  const errorReferenceCode = uuidv4();
26
- const line = chalk.red("-".repeat(process.stderr.columns));
26
+ const line = ansis.red("-".repeat(process.stderr.columns));
27
27
  const content = !includeEpilogue ? message : [
28
28
  "",
29
29
  line,
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import chalk from "chalk";
2
+ import ansis from "ansis";
3
3
  import enquirer from "enquirer";
4
4
  import fs from "fs-extra";
5
5
  import { getCompatibilityData } from "@cedarjs/cli-helpers";
@@ -100,14 +100,14 @@ function checkPluginListAndWarn(plugins) {
100
100
  for (const plugin of plugins) {
101
101
  if (!plugin.package) {
102
102
  console.warn(
103
- chalk.yellow(`\u26A0\uFE0F A plugin is missing a package, it cannot be loaded.`)
103
+ ansis.yellow(`\u26A0\uFE0F A plugin is missing a package, it cannot be loaded.`)
104
104
  );
105
105
  }
106
106
  }
107
107
  const pluginPackages = plugins.map((p) => p.package).filter((p) => p !== void 0);
108
108
  if (pluginPackages.length !== new Set(pluginPackages).size) {
109
109
  console.warn(
110
- chalk.yellow(
110
+ ansis.yellow(
111
111
  "\u26A0\uFE0F Duplicate plugin packages found in redwood.toml, duplicates will be ignored."
112
112
  )
113
113
  );
@@ -116,7 +116,7 @@ function checkPluginListAndWarn(plugins) {
116
116
  namespaces.forEach((ns) => {
117
117
  if (ns !== void 0 && !ns.startsWith("@")) {
118
118
  console.warn(
119
- chalk.yellow(
119
+ ansis.yellow(
120
120
  `\u26A0\uFE0F Plugin "${ns}" is missing a scope/namespace, it will not be loaded.`
121
121
  )
122
122
  );
@@ -129,13 +129,13 @@ async function loadPluginPackage(packageName, packageVersion, autoInstall) {
129
129
  }
130
130
  if (!autoInstall) {
131
131
  console.warn(
132
- chalk.yellow(
132
+ ansis.yellow(
133
133
  `\u26A0\uFE0F Plugin "${packageName}" cannot be loaded because it is not installed and "autoInstall" is disabled.`
134
134
  )
135
135
  );
136
136
  return null;
137
137
  }
138
- console.log(chalk.green(`Installing plugin "${packageName}"...`));
138
+ console.log(ansis.green(`Installing plugin "${packageName}"...`));
139
139
  const installed = await installPluginPackage(packageName, packageVersion);
140
140
  if (installed) {
141
141
  return await import(packageName);
@@ -154,7 +154,7 @@ async function installPluginPackage(packageName, packageVersion) {
154
154
  );
155
155
  versionToInstall = compatibilityData.compatible.version;
156
156
  console.log(
157
- chalk.green(
157
+ ansis.green(
158
158
  `Installing the latest compatible version: ${versionToInstall}`
159
159
  )
160
160
  );
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
+ import ansis from "ansis";
2
3
  import boxen from "boxen";
3
- import chalk from "chalk";
4
4
  import fs from "fs-extra";
5
5
  import latestVersion from "latest-version";
6
6
  import semver from "semver";
@@ -95,7 +95,7 @@ function getUpdateMessage() {
95
95
  if (tag === localTag) {
96
96
  message += `
97
97
 
98
- \u2756 ${chalk.underline(chalk.bold(tag))}:
98
+ \u2756 ${ansis.underline.bold(tag)}:
99
99
  v${data.localVersion} -> v${version} `;
100
100
  } else {
101
101
  message += `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "0.5.1-next.0+9c48e99f3",
3
+ "version": "0.6.0",
4
4
  "description": "The Redwood Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,15 +31,15 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime-corejs3": "7.27.6",
34
- "@cedarjs/api-server": "0.5.1-next.0+9c48e99f3",
35
- "@cedarjs/cli-helpers": "0.5.1-next.0+9c48e99f3",
36
- "@cedarjs/fastify-web": "0.5.1-next.0+9c48e99f3",
37
- "@cedarjs/internal": "0.5.1-next.0+9c48e99f3",
38
- "@cedarjs/prerender": "0.5.1-next.0+9c48e99f3",
39
- "@cedarjs/project-config": "0.5.1-next.0+9c48e99f3",
40
- "@cedarjs/structure": "0.5.1-next.0+9c48e99f3",
41
- "@cedarjs/telemetry": "0.5.1-next.0+9c48e99f3",
42
- "@cedarjs/web-server": "0.5.1-next.0+9c48e99f3",
34
+ "@cedarjs/api-server": "0.6.0",
35
+ "@cedarjs/cli-helpers": "0.6.0",
36
+ "@cedarjs/fastify-web": "0.6.0",
37
+ "@cedarjs/internal": "0.6.0",
38
+ "@cedarjs/prerender": "0.6.0",
39
+ "@cedarjs/project-config": "0.6.0",
40
+ "@cedarjs/structure": "0.6.0",
41
+ "@cedarjs/telemetry": "0.6.0",
42
+ "@cedarjs/web-server": "0.6.0",
43
43
  "@listr2/prompt-adapter-enquirer": "2.0.16",
44
44
  "@opentelemetry/api": "1.8.0",
45
45
  "@opentelemetry/core": "1.22.0",
@@ -48,10 +48,10 @@
48
48
  "@opentelemetry/sdk-trace-node": "1.22.0",
49
49
  "@opentelemetry/semantic-conventions": "1.22.0",
50
50
  "@prisma/internals": "5.20.0",
51
+ "ansis": "4.1.0",
51
52
  "archiver": "7.0.1",
52
53
  "boxen": "5.1.2",
53
54
  "camelcase": "6.3.0",
54
- "chalk": "4.1.2",
55
55
  "change-case": "4.1.2",
56
56
  "ci-info": "4.0.0",
57
57
  "concurrently": "8.2.2",
@@ -101,5 +101,5 @@
101
101
  "publishConfig": {
102
102
  "access": "public"
103
103
  },
104
- "gitHead": "9c48e99f37468ae011bc39c5d405044ccef0e77c"
104
+ "gitHead": "dbb79eb24110276fc52803bb3874acd62b76f7c8"
105
105
  }