@cedarjs/cli 3.0.0-canary.13414 → 3.0.0-canary.13417

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.
@@ -28,7 +28,7 @@ const handler = async () => {
28
28
  const tomlContent = fs.readFileSync(configTomlPath, "utf8");
29
29
  console.log(
30
30
  output + ` ${path.basename(configTomlPath)}:
31
- ` + tomlContent.split("\n").filter((line) => line.trim().length > 0).filter((line) => !/^#/.test(line)).map((line) => ` ${line}`).join("\n")
31
+ ` + tomlContent.split("\n").filter((line) => line.trim().length > 0).filter((line) => !line.startsWith("#")).map((line) => ` ${line}`).join("\n")
32
32
  );
33
33
  };
34
34
  export {
@@ -29,7 +29,7 @@ function detectLegacyEslintConfig() {
29
29
  if (packageJson.eslint) {
30
30
  foundLegacyFiles.push("package.json (eslint field)");
31
31
  }
32
- } catch (error) {
32
+ } catch {
33
33
  }
34
34
  }
35
35
  return foundLegacyFiles;
@@ -63,7 +63,8 @@ const description = "Lint your files";
63
63
  const builder = (yargs) => {
64
64
  yargs.positional("paths", {
65
65
  description: "Specify file(s) or directory(ies) to lint relative to project root",
66
- type: "array"
66
+ type: "string",
67
+ array: true
67
68
  }).option("fix", {
68
69
  default: false,
69
70
  description: "Try to fix errors",
@@ -79,7 +80,11 @@ const builder = (yargs) => {
79
80
  )}`
80
81
  );
81
82
  };
82
- const handler = async ({ paths, fix, format }) => {
83
+ const handler = async ({
84
+ paths = [],
85
+ fix = false,
86
+ format = "stylish"
87
+ }) => {
83
88
  recordTelemetryAttributes({ command: "lint", fix, format });
84
89
  const config = getConfig();
85
90
  const legacyConfigFiles = detectLegacyEslintConfig();
@@ -98,13 +103,18 @@ const handler = async ({ paths, fix, format }) => {
98
103
  fs.existsSync(getPaths().api.src) && "api/src"
99
104
  );
100
105
  }
101
- const result = await execa("yarn", args.filter(Boolean), {
106
+ const filteredArgs = args.filter((arg) => Boolean(arg));
107
+ const result = await execa("yarn", filteredArgs, {
102
108
  cwd: getPaths().base,
103
109
  stdio: "inherit"
104
110
  });
105
111
  process.exitCode = result.exitCode;
106
112
  } catch (error) {
107
- process.exitCode = error.exitCode ?? 1;
113
+ if (error && typeof error === "object" && "exitCode" in error) {
114
+ process.exitCode = error.exitCode ?? 1;
115
+ return;
116
+ }
117
+ process.exitCode = 1;
108
118
  }
109
119
  };
110
120
  export {
@@ -1,7 +1,8 @@
1
+ import { terminalLink } from "termi-link";
1
2
  const command = "record <command>";
2
3
  const description = "Setup RedwoodRecord for your project. Caches a JSON version of your data model and adds api/src/models/index.js with some config.";
3
- import { terminalLink } from "termi-link";
4
- const builder = (yargs) => yargs.command({ command, description, handler }).demandCommand().epilogue(
4
+ const builder = (yargs) => yargs.command(command, description, () => {
5
+ }, handler).demandCommand().epilogue(
5
6
  `Also see the ${terminalLink(
6
7
  "RedwoodRecord Docs",
7
8
  "https://cedarjs.com/docs/redwoodrecord"
@@ -27,11 +27,11 @@ const builder = async (yargs) => {
27
27
  socket: argv.socket
28
28
  });
29
29
  if (serverFileExists()) {
30
- const { bothServerFileHandler } = await import("./serveBothHandler.js");
31
- await bothServerFileHandler(argv);
30
+ const serveBothHandlers = await import("./serveBothHandler.js");
31
+ await serveBothHandlers.bothServerFileHandler(argv);
32
32
  } else if (rscEnabled || streamingEnabled) {
33
- const { bothSsrRscServerHandler } = await import("./serveBothHandler.js");
34
- await bothSsrRscServerHandler(argv, rscEnabled);
33
+ const serveBothHandlers = await import("./serveBothHandler.js");
34
+ await serveBothHandlers.bothSsrRscServerHandler(argv, rscEnabled);
35
35
  } else {
36
36
  if (!projectIsEsm()) {
37
37
  const { handler } = await import("@cedarjs/api-server/cjs/bothCliConfigHandler");
@@ -88,7 +88,7 @@ const builder = async (yargs) => {
88
88
  command: "serve"
89
89
  });
90
90
  const positionalArgs = argv._;
91
- if (positionalArgs.includes("web") && !fs.existsSync(path.join(getPaths().web.dist), "index.html")) {
91
+ if (positionalArgs.includes("web") && !webSideIsBuilt(streamingEnabled || rscEnabled)) {
92
92
  console.error(
93
93
  c.error(
94
94
  "\n Please run `yarn cedar build web` before trying to serve web. \n"
@@ -119,15 +119,16 @@ const builder = async (yargs) => {
119
119
  if (!apiSideExists && !rscEnabled) {
120
120
  console.error(
121
121
  c.error(
122
- "\n Unable to serve the both sides as no `api` folder exists. Please use `yarn cedar serve web` instead. \n"
122
+ "\nUnable to serve web and api as no `api` folder exists. Please use `yarn cedar serve web` instead. \n"
123
123
  )
124
124
  );
125
125
  process.exit(1);
126
126
  }
127
- if (fs.existsSync(path.join(getPaths().api.base)) && !fs.existsSync(path.join(getPaths().api.dist)) || !fs.existsSync(path.join(getPaths().web.dist), "index.html")) {
127
+ const apiExistsButIsNotBuilt = apiSideExists && !fs.existsSync(getPaths().api.dist);
128
+ if (apiExistsButIsNotBuilt || !webSideIsBuilt(streamingEnabled || rscEnabled)) {
128
129
  console.error(
129
130
  c.error(
130
- "\n Please run `yarn cedar build` before trying to serve your redwood app. \n"
131
+ "\nPlease run `yarn cedar build` before trying to serve your Cedar app.\n"
131
132
  )
132
133
  );
133
134
  process.exit(1);
@@ -143,6 +144,15 @@ const builder = async (yargs) => {
143
144
  )}`
144
145
  );
145
146
  };
147
+ function webSideIsBuilt(isStreamingOrRSC) {
148
+ if (isStreamingOrRSC) {
149
+ return fs.existsSync(
150
+ path.join(getPaths().web.distBrowser, "client-build-manifest.json")
151
+ );
152
+ } else {
153
+ return fs.existsSync(path.join(getPaths().web.dist, "index.html"));
154
+ }
155
+ }
146
156
  export {
147
157
  builder,
148
158
  command,
@@ -121,7 +121,7 @@ const handler = async ({ force }) => {
121
121
  },
122
122
  {
123
123
  title: "One more thing...",
124
- task: (ctx) => {
124
+ task: (ctx, task) => {
125
125
  notes.push(
126
126
  colors.important(
127
127
  task.output = `You will need to add \`SENTRY_DSN\` to \`includeEnvironmentVariables\` in ${configFileName}.`
@@ -7,7 +7,8 @@ const builder = (yargs) => {
7
7
  yargs.strict(false).positional("filter", {
8
8
  default: workspaces(),
9
9
  description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
10
- type: "array"
10
+ type: "string",
11
+ array: true
11
12
  }).option("watch", {
12
13
  describe: "Run tests related to changed files based on hg/git. Specify the name or path to a file to focus on a specific set of tests",
13
14
  type: "boolean",
@@ -12,7 +12,8 @@ const builder = (yargs) => {
12
12
  yargs.strict(false).positional("filter", {
13
13
  default: workspaces(),
14
14
  description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
15
- type: "array"
15
+ type: "string",
16
+ array: true
16
17
  }).option("db-push", {
17
18
  describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
18
19
  type: "boolean",
@@ -7,7 +7,8 @@ const builder = (yargs) => {
7
7
  yargs.strict(false).positional("sides", {
8
8
  default: workspaces(),
9
9
  description: "Which side(s) to run a typecheck on",
10
- type: "array"
10
+ type: "string",
11
+ array: true
11
12
  }).option("prisma", {
12
13
  type: "boolean",
13
14
  default: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "3.0.0-canary.13414+7c6fed072",
3
+ "version": "3.0.0-canary.13417+a3ddd36d4",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,15 +34,15 @@
34
34
  "@babel/parser": "7.29.0",
35
35
  "@babel/preset-typescript": "7.28.5",
36
36
  "@babel/runtime-corejs3": "7.29.0",
37
- "@cedarjs/api-server": "3.0.0-canary.13414",
38
- "@cedarjs/cli-helpers": "3.0.0-canary.13414",
39
- "@cedarjs/fastify-web": "3.0.0-canary.13414",
40
- "@cedarjs/internal": "3.0.0-canary.13414",
41
- "@cedarjs/prerender": "3.0.0-canary.13414",
42
- "@cedarjs/project-config": "3.0.0-canary.13414",
43
- "@cedarjs/structure": "3.0.0-canary.13414",
44
- "@cedarjs/telemetry": "3.0.0-canary.13414",
45
- "@cedarjs/web-server": "3.0.0-canary.13414",
37
+ "@cedarjs/api-server": "3.0.0-canary.13417",
38
+ "@cedarjs/cli-helpers": "3.0.0-canary.13417",
39
+ "@cedarjs/fastify-web": "3.0.0-canary.13417",
40
+ "@cedarjs/internal": "3.0.0-canary.13417",
41
+ "@cedarjs/prerender": "3.0.0-canary.13417",
42
+ "@cedarjs/project-config": "3.0.0-canary.13417",
43
+ "@cedarjs/structure": "3.0.0-canary.13417",
44
+ "@cedarjs/telemetry": "3.0.0-canary.13417",
45
+ "@cedarjs/web-server": "3.0.0-canary.13417",
46
46
  "@listr2/prompt-adapter-enquirer": "2.0.16",
47
47
  "@opentelemetry/api": "1.9.0",
48
48
  "@opentelemetry/core": "1.30.1",
@@ -106,5 +106,5 @@
106
106
  "publishConfig": {
107
107
  "access": "public"
108
108
  },
109
- "gitHead": "7c6fed0720f1213e0cb7bf0741e0f767b8e8e633"
109
+ "gitHead": "a3ddd36d46942deb1eec0cd1f42694bcb43b6cdb"
110
110
  }