@cedarjs/cli 2.4.2-next.0 → 2.5.0-rc.146

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.
Files changed (28) hide show
  1. package/README.md +6 -2
  2. package/dist/commands/deploy/baremetal/baremetalHandler.js +4 -4
  3. package/dist/commands/deploy/serverlessHandler.js +1 -1
  4. package/dist/commands/dev/devHandler.js +31 -2
  5. package/dist/commands/experimental/setupOpentelemetryHandler.js +7 -6
  6. package/dist/commands/experimental/setupReactCompilerHandler.js +10 -9
  7. package/dist/commands/experimental/setupRscHandler.js +9 -9
  8. package/dist/commands/experimental/setupStreamingSsrHandler.js +9 -9
  9. package/dist/commands/generate/package/package.js +15 -2
  10. package/dist/commands/generate/package/packageHandler.js +297 -19
  11. package/dist/commands/generate/package/templates/tsconfig.json.template +2 -2
  12. package/dist/commands/generate/service/serviceHandler.js +5 -2
  13. package/dist/commands/generate/yargsCommandHelpers.js +16 -14
  14. package/dist/commands/info.js +6 -3
  15. package/dist/commands/setup/deploy/helpers/index.js +14 -18
  16. package/dist/commands/setup/deploy/providers/coherenceHandler.js +33 -34
  17. package/dist/commands/setup/deploy/providers/serverlessHandler.js +8 -7
  18. package/dist/commands/setup/deploy/templates/netlify.js +2 -2
  19. package/dist/commands/setup/docker/dockerHandler.js +5 -4
  20. package/dist/commands/setup/docker/templates/Dockerfile +3 -3
  21. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +4 -1
  22. package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +2 -2
  23. package/dist/commands/upgrade/preUpgradeScripts.js +7 -3
  24. package/dist/commands/upgrade/upgradeHandler.js +1 -1
  25. package/dist/index.js +13 -9
  26. package/dist/lib/index.js +5 -2
  27. package/dist/lib/plugin.js +1 -1
  28. package/package.json +27 -26
package/README.md CHANGED
@@ -111,9 +111,13 @@ cd packages/cli
111
111
  yarn dev <command>
112
112
  ```
113
113
 
114
- > **Note:** If you are implementing a command and wish to run via `yarn dev <command>` be sure to `yarn build:clean-dist` beforehand to run the latest version.
114
+ > **Note:** If you are implementing a command and wish to run via
115
+ > `yarn dev <command>` be sure to `yarn build:clean-dist` beforehand to run the
116
+ > latest version.
115
117
 
116
- > **Important:** If your command alters the `example-todo-main` project (adds a package, modifies redwood.toml, etc) be sure not to commit and push those changes as part of your PR.
118
+ > **Important:** If your command alters the `example-todo-main` project (adds a
119
+ > package, modifies cedar.toml, etc) be sure not to commit and push those changes
120
+ > as part of your PR.
117
121
 
118
122
  ### Best Practices
119
123
 
@@ -297,18 +297,18 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
297
297
  title: `DB Migrations...`,
298
298
  task: async () => {
299
299
  await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
300
- "rw",
300
+ "cedar",
301
301
  "prisma",
302
302
  "migrate",
303
303
  "deploy"
304
304
  ]);
305
305
  await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
306
- "rw",
306
+ "cedar",
307
307
  "prisma",
308
308
  "generate"
309
309
  ]);
310
310
  await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
311
- "rw",
311
+ "cedar",
312
312
  "dataMigrate",
313
313
  "up"
314
314
  ]);
@@ -326,7 +326,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
326
326
  title: `Building ${side}...`,
327
327
  task: async () => {
328
328
  await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
329
- "rw",
329
+ "cedar",
330
330
  "build",
331
331
  side
332
332
  ]);
@@ -23,7 +23,7 @@ const buildCommands = ({ sides }) => {
23
23
  return [
24
24
  {
25
25
  title: `Building ${sides.join(" & ")}...`,
26
- command: ["yarn", ["rw", "build", ...sides]]
26
+ command: ["yarn", ["cedar", "build", ...sides]]
27
27
  },
28
28
  {
29
29
  title: "Packing Functions...",
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { Writable } from "node:stream";
3
4
  import concurrently from "concurrently";
4
5
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
6
  import { shutdownPort } from "@cedarjs/internal/dist/dev";
@@ -66,7 +67,7 @@ const handler = async ({
66
67
  const message = [
67
68
  "The currently configured ports for the development server are",
68
69
  "unavailable. Suggested changes to your ports, which can be changed in",
69
- "redwood.toml, are:\n",
70
+ "cedar.toml (or redwood.toml), are:\n",
70
71
  apiPortChangeNeeded && ` - API to use port ${apiAvailablePort} instead`,
71
72
  apiPortChangeNeeded && "of your currently configured",
72
73
  apiPortChangeNeeded && `${apiPreferredPort}
@@ -177,10 +178,38 @@ const handler = async ({
177
178
  }
178
179
  }
179
180
  const filteredJobs = jobs.filter((job) => !job.runWhen || job.runWhen());
181
+ class FilterEmptyLinesStream extends Writable {
182
+ buffer = "";
183
+ _write(chunk, _encoding, callback) {
184
+ this.buffer += chunk.toString();
185
+ const lines = this.buffer.split("\n");
186
+ this.buffer = lines.pop() || "";
187
+ for (const line of lines) {
188
+ const strippedLine = line.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
189
+ const isEmptyPrefixLine = /^[^|]+\|\s*$/.test(strippedLine);
190
+ if (!isEmptyPrefixLine) {
191
+ process.stdout.write(line + "\n");
192
+ }
193
+ }
194
+ callback();
195
+ }
196
+ _final(callback) {
197
+ if (this.buffer.length > 0) {
198
+ const strippedLine = this.buffer.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
199
+ const isEmptyPrefixLine = /^[^|]+\|\s*$/.test(strippedLine);
200
+ if (!isEmptyPrefixLine) {
201
+ process.stdout.write(this.buffer);
202
+ }
203
+ }
204
+ callback();
205
+ }
206
+ }
207
+ const outputStream = new FilterEmptyLinesStream();
180
208
  const { result } = concurrently(filteredJobs, {
181
209
  prefix: "{name} |",
182
210
  timestampFormat: "HH:mm:ss",
183
- handleInput: true
211
+ handleInput: true,
212
+ outputStream
184
213
  });
185
214
  result.catch((e) => {
186
215
  if (e?.message) {
@@ -21,6 +21,9 @@ import {
21
21
  import { printTaskEpilogue } from "./util.js";
22
22
  const handler = async ({ force, verbose }) => {
23
23
  const ts = isTypeScriptProject();
24
+ const configTomlPath = getConfigPath();
25
+ const configFileName = path.basename(configTomlPath);
26
+ const configContent = fs.readFileSync(configTomlPath, "utf-8");
24
27
  const opentelemetryScriptPath = `${getPaths().api.src}/opentelemetry.${ts ? "ts" : "js"}`;
25
28
  const opentelemetryPackages = [
26
29
  "@opentelemetry/api",
@@ -54,13 +57,11 @@ const handler = async ({ force, verbose }) => {
54
57
  }
55
58
  },
56
59
  {
57
- title: "Adding config to redwood.toml...",
60
+ title: `Adding config to ${configFileName}...`,
58
61
  task: (_ctx, task) => {
59
- const redwoodTomlPath = getConfigPath();
60
- const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
61
62
  if (!configContent.includes("[experimental.opentelemetry]")) {
62
63
  writeFile(
63
- redwoodTomlPath,
64
+ configTomlPath,
64
65
  configContent.concat(
65
66
  `
66
67
  [experimental.opentelemetry]
@@ -69,12 +70,12 @@ const handler = async ({ force, verbose }) => {
69
70
  ),
70
71
  {
71
72
  overwriteExisting: true
72
- // redwood.toml always exists
73
+ // cedar.toml or redwood.toml always exists
73
74
  }
74
75
  );
75
76
  } else {
76
77
  task.skip(
77
- `The [experimental.opentelemetry] config block already exists in your 'redwood.toml' file.`
78
+ `The [experimental.opentelemetry] config block already exists in your ${configFileName} file.`
78
79
  );
79
80
  }
80
81
  }
@@ -15,8 +15,9 @@ import {
15
15
  import { printTaskEpilogue } from "./util.js";
16
16
  const handler = async ({ force, verbose }) => {
17
17
  const rwPaths = getPaths();
18
- const redwoodTomlPath = getConfigPath();
19
- const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
18
+ const configTomlPath = getConfigPath();
19
+ const configFileName = path.basename(configTomlPath);
20
+ const configContent = fs.readFileSync(configTomlPath, "utf-8");
20
21
  const tasks = new Listr(
21
22
  [
22
23
  {
@@ -44,24 +45,24 @@ const handler = async ({ force, verbose }) => {
44
45
  }
45
46
  },
46
47
  {
47
- title: "Adding config to redwood.toml...",
48
+ title: `Adding config to ${configFileName}...`,
48
49
  task: (_ctx, task) => {
49
50
  if (!configContent.includes("[experimental.reactCompiler]")) {
50
51
  writeFile(
51
- redwoodTomlPath,
52
+ configTomlPath,
52
53
  configContent.concat(
53
54
  "\n[experimental.reactCompiler]\n enabled = true\n lintOnly = false\n"
54
55
  ),
55
56
  {
56
57
  overwriteExisting: true
57
- // redwood.toml always exists
58
+ // configuration file always exists
58
59
  }
59
60
  );
60
61
  } else {
61
62
  if (force) {
62
- task.output = "Overwriting config in redwood.toml";
63
+ task.output = `Overwriting config in ${configFileName}`;
63
64
  writeFile(
64
- redwoodTomlPath,
65
+ configTomlPath,
65
66
  configContent.replace(
66
67
  // Enable if it's currently disabled
67
68
  "\n[experimental.reactCompiler]\n enabled = false\n",
@@ -69,12 +70,12 @@ const handler = async ({ force, verbose }) => {
69
70
  ),
70
71
  {
71
72
  overwriteExisting: true
72
- // redwood.toml always exists
73
+ // configuration file always exists
73
74
  }
74
75
  );
75
76
  } else {
76
77
  task.skip(
77
- "The [experimental.reactCompiler] config block already exists in your `redwood.toml` file."
78
+ `The [experimental.reactCompiler] config block already exists in ${configFileName}.`
78
79
  );
79
80
  }
80
81
  }
@@ -12,8 +12,8 @@ import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupRsc.js";
12
12
  import { printTaskEpilogue } from "./util.js";
13
13
  const handler = async ({ force, verbose }) => {
14
14
  const rwPaths = getPaths();
15
- const redwoodTomlPath = getConfigPath();
16
- const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
15
+ const configTomlPath = getConfigPath();
16
+ const configContent = fs.readFileSync(configTomlPath, "utf-8");
17
17
  const ext = path.extname(rwPaths.web.entryClient || "");
18
18
  const tasks = new Listr(
19
19
  [
@@ -36,22 +36,22 @@ const handler = async ({ force, verbose }) => {
36
36
  }
37
37
  },
38
38
  {
39
- title: "Adding config to redwood.toml...",
39
+ title: "Adding config to cedar.toml...",
40
40
  task: (_ctx, task) => {
41
41
  if (!configContent.includes("[experimental.rsc]")) {
42
42
  writeFile(
43
- redwoodTomlPath,
43
+ configTomlPath,
44
44
  configContent.concat("\n[experimental.rsc]\n enabled = true\n"),
45
45
  {
46
46
  overwriteExisting: true
47
- // redwood.toml always exists
47
+ // cedar.toml always exists
48
48
  }
49
49
  );
50
50
  } else {
51
51
  if (force) {
52
- task.output = "Overwriting config in redwood.toml";
52
+ task.output = "Overwriting config in cedar.toml";
53
53
  writeFile(
54
- redwoodTomlPath,
54
+ configTomlPath,
55
55
  configContent.replace(
56
56
  // Enable if it's currently disabled
57
57
  "\n[experimental.rsc]\n enabled = false\n",
@@ -59,12 +59,12 @@ const handler = async ({ force, verbose }) => {
59
59
  ),
60
60
  {
61
61
  overwriteExisting: true
62
- // redwood.toml always exists
62
+ // cedar.toml always exists
63
63
  }
64
64
  );
65
65
  } else {
66
66
  task.skip(
67
- "The [experimental.rsc] config block already exists in your `redwood.toml` file."
67
+ "The [experimental.rsc] config block already exists in your cedar.toml file."
68
68
  );
69
69
  }
70
70
  }
@@ -16,8 +16,8 @@ import {
16
16
  import { printTaskEpilogue } from "./util.js";
17
17
  const handler = async ({ force, verbose }) => {
18
18
  const rwPaths = getPaths();
19
- const redwoodTomlPath = getConfigPath();
20
- const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
19
+ const configPath = getConfigPath();
20
+ const configContent = fs.readFileSync(configPath, "utf-8");
21
21
  const ts = isTypeScriptProject();
22
22
  const ext = path.extname(rwPaths.web.entryClient || "");
23
23
  const tasks = new Listr(
@@ -33,11 +33,11 @@ const handler = async ({ force, verbose }) => {
33
33
  }
34
34
  },
35
35
  {
36
- title: "Adding config to redwood.toml...",
36
+ title: "Adding config to cedar.toml...",
37
37
  task: (_ctx, task) => {
38
38
  if (!configContent.includes("[experimental.streamingSsr]")) {
39
39
  writeFile(
40
- redwoodTomlPath,
40
+ configPath,
41
41
  configContent.concat(
42
42
  `
43
43
  [experimental.streamingSsr]
@@ -46,14 +46,14 @@ const handler = async ({ force, verbose }) => {
46
46
  ),
47
47
  {
48
48
  overwriteExisting: true
49
- // redwood.toml always exists
49
+ // cedar.toml always exists
50
50
  }
51
51
  );
52
52
  } else {
53
53
  if (force) {
54
- task.output = "Overwriting config in redwood.toml";
54
+ task.output = "Overwriting config in cedar.toml";
55
55
  writeFile(
56
- redwoodTomlPath,
56
+ configPath,
57
57
  configContent.replace(
58
58
  // Enable if it's currently disabled
59
59
  `
@@ -67,12 +67,12 @@ const handler = async ({ force, verbose }) => {
67
67
  ),
68
68
  {
69
69
  overwriteExisting: true
70
- // redwood.toml always exists
70
+ // cedar.toml always exists
71
71
  }
72
72
  );
73
73
  } else {
74
74
  task.skip(
75
- `The [experimental.streamingSsr] config block already exists in your 'redwood.toml' file.`
75
+ "The [experimental.streamingSsr] config block already exists in your cedar.toml file."
76
76
  );
77
77
  }
78
78
  }
@@ -1,9 +1,22 @@
1
- import { createHandler, createBuilder } from "../yargsCommandHelpers.js";
1
+ import {
2
+ createHandler,
3
+ createBuilder,
4
+ getYargsDefaults
5
+ } from "../yargsCommandHelpers.js";
2
6
  const command = "package <name>";
3
7
  const description = "Generate a workspace Package";
4
8
  const builder = createBuilder({
5
9
  componentName: "package",
6
- addStories: false
10
+ addStories: false,
11
+ optionsObj: () => ({
12
+ ...getYargsDefaults(),
13
+ workspace: {
14
+ alias: "w",
15
+ description: "Which workspace(s) should use this package? One of: 'none', 'api', 'web', 'both'. If provided, the generator will skip the interactive prompt and apply the chosen workspace.",
16
+ type: "string",
17
+ choices: ["none", "api", "web", "both"]
18
+ }
19
+ })
7
20
  });
8
21
  const handler = createHandler("package");
9
22
  export {