@cedarjs/cli 9.0.0-canary.1784 → 9.0.0-canary.3124

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 (277) hide show
  1. package/README.md +7 -10
  2. package/dist/cfw.js +10 -6
  3. package/dist/commands/build/buildHandler.js +220 -45
  4. package/dist/commands/build/buildPackagesTask.js +21 -20
  5. package/dist/commands/build.js +13 -2
  6. package/dist/commands/check.js +4 -6
  7. package/dist/commands/console.js +6 -4
  8. package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
  9. package/dist/commands/deploy/baremetal/baremetalHandler.js +116 -50
  10. package/dist/commands/deploy/baremetal.js +11 -4
  11. package/dist/commands/deploy/flightcontrolHandler.js +28 -15
  12. package/dist/commands/deploy/helpers/deployHandler.js +11 -6
  13. package/dist/commands/deploy/netlify.js +1 -1
  14. package/dist/commands/deploy/packing/nft.js +1 -2
  15. package/dist/commands/deploy/render.js +1 -1
  16. package/dist/commands/deploy/renderHandler.js +24 -13
  17. package/dist/commands/deploy/serverlessHandler.js +69 -27
  18. package/dist/commands/deploy/vercel.js +1 -1
  19. package/dist/commands/destroy/component/component.js +2 -3
  20. package/dist/commands/destroy/directive/directive.js +1 -3
  21. package/dist/commands/destroy/directive/directiveHandler.js +2 -4
  22. package/dist/commands/destroy/function/function.js +1 -3
  23. package/dist/commands/destroy/handlerHelpers.js +17 -17
  24. package/dist/commands/destroy/helpers.js +8 -2
  25. package/dist/commands/destroy/layout/layout.js +1 -2
  26. package/dist/commands/destroy/page/pageHandler.js +3 -3
  27. package/dist/commands/destroy/scaffold/scaffoldHandler.js +31 -12
  28. package/dist/commands/destroy/sdl/sdlHandler.js +3 -3
  29. package/dist/commands/dev/apiDebugFlag.js +5 -4
  30. package/dist/commands/dev/devHandler.js +219 -68
  31. package/dist/commands/dev/packageWatchCommands.js +8 -3
  32. package/dist/commands/dev.js +16 -6
  33. package/dist/commands/execHandler.js +49 -29
  34. package/dist/commands/experimental/live-queries/liveQueries.js +32 -0
  35. package/dist/commands/experimental/live-queries/liveQueriesHandler.js +448 -0
  36. package/dist/commands/experimental/live-queries/templates/liveQueriesListener.ts.template +153 -0
  37. package/dist/commands/experimental/live-queries/templates/migration.sql.template +100 -0
  38. package/dist/commands/experimental/setupInngest.js +2 -2
  39. package/dist/commands/experimental/setupInngestHandler.js +13 -12
  40. package/dist/commands/experimental/setupOpentelemetry.js +2 -2
  41. package/dist/commands/experimental/setupOpentelemetryHandler.js +14 -10
  42. package/dist/commands/experimental/setupReactCompiler.js +2 -2
  43. package/dist/commands/experimental/setupReactCompilerHandler.js +48 -33
  44. package/dist/commands/experimental/setupRsc.js +1 -1
  45. package/dist/commands/experimental/setupRscHandler.js +20 -16
  46. package/dist/commands/experimental/setupStreamingSsr.js +2 -2
  47. package/dist/commands/experimental/setupStreamingSsrHandler.js +49 -34
  48. package/dist/commands/experimental/templates/opentelemetry.ts.template +2 -1
  49. package/dist/commands/experimental/templates/rsc/Document.tsx.template +1 -1
  50. package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +8 -8
  51. package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +1 -1
  52. package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +6 -6
  53. package/dist/commands/experimental/templates/streamingSsr/tsconfig.json.template +6 -6
  54. package/dist/commands/experimental/util.js +27 -25
  55. package/dist/commands/experimental.js +3 -2
  56. package/dist/commands/generate/cell/cell.js +20 -0
  57. package/dist/commands/generate/cell/cellHandler.js +89 -40
  58. package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
  59. package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
  60. package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
  61. package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
  62. package/dist/commands/generate/cell/templates/test.js.template +1 -1
  63. package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
  64. package/dist/commands/generate/component/componentHandler.js +14 -16
  65. package/dist/commands/generate/dataMigration/dataMigration.js +36 -18
  66. package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +1 -1
  67. package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +1 -1
  68. package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
  69. package/dist/commands/generate/dbAuth/dbAuthHandler.js +63 -34
  70. package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
  71. package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
  72. package/dist/commands/generate/directive/directiveHandler.js +14 -16
  73. package/dist/commands/generate/function/function.js +1 -0
  74. package/dist/commands/generate/function/functionHandler.js +14 -19
  75. package/dist/commands/generate/helpers.js +34 -18
  76. package/dist/commands/generate/job/job.js +1 -0
  77. package/dist/commands/generate/job/jobHandler.js +20 -24
  78. package/dist/commands/generate/layout/layoutHandler.js +13 -16
  79. package/dist/commands/generate/model/model.js +1 -0
  80. package/dist/commands/generate/model/modelHandler.js +11 -5
  81. package/dist/commands/generate/ogImage/ogImage.js +1 -0
  82. package/dist/commands/generate/ogImage/ogImageHandler.js +18 -11
  83. package/dist/commands/generate/package/filesTask.js +9 -0
  84. package/dist/commands/generate/package/packageHandler.js +50 -61
  85. package/dist/commands/generate/package/templates/test.ts.template +2 -2
  86. package/dist/commands/generate/package/templates/vitest.config.ts.template +9 -0
  87. package/dist/commands/generate/page/pageHandler.js +27 -24
  88. package/dist/commands/generate/realtime/realtime.js +2 -2
  89. package/dist/commands/generate/realtime/realtimeHandler.js +51 -32
  90. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
  91. package/dist/commands/generate/scaffold/scaffold.js +1 -0
  92. package/dist/commands/generate/scaffold/scaffoldHandler.js +176 -49
  93. package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -1
  94. package/dist/commands/generate/script/script.js +1 -0
  95. package/dist/commands/generate/script/scriptHandler.js +10 -6
  96. package/dist/commands/generate/script/templates/script.ts.template +9 -4
  97. package/dist/commands/generate/script/templates/tsconfig.json.template +16 -2
  98. package/dist/commands/generate/sdl/sdl.js +4 -3
  99. package/dist/commands/generate/sdl/sdlHandler.js +135 -46
  100. package/dist/commands/generate/sdl/stubFiles.js +132 -0
  101. package/dist/commands/generate/sdl/templates/sdl.js.template +2 -1
  102. package/dist/commands/generate/sdl/templates/sdl.ts.template +2 -1
  103. package/dist/commands/generate/secret/secret.js +20 -20
  104. package/dist/commands/generate/service/service.js +5 -5
  105. package/dist/commands/generate/service/serviceHandler.js +126 -61
  106. package/dist/commands/generate/service/templates/scenarios.ts.template +4 -2
  107. package/dist/commands/generate/service/templates/service.ts.template +22 -8
  108. package/dist/commands/generate/service/templates/test.ts.template +2 -2
  109. package/dist/commands/generate/yargsCommandHelpers.js +7 -2
  110. package/dist/commands/generate/yargsHandlerHelpers.js +20 -18
  111. package/dist/commands/generate.js +4 -4
  112. package/dist/commands/info.js +2 -2
  113. package/dist/commands/jobsHandler.js +7 -4
  114. package/dist/commands/lint.js +26 -69
  115. package/dist/commands/prerenderHandler.js +95 -58
  116. package/dist/commands/prismaHandler.js +51 -26
  117. package/dist/commands/record/init.js +2 -2
  118. package/dist/commands/record.js +4 -3
  119. package/dist/commands/serve.js +245 -31
  120. package/dist/commands/serveApiHandler.js +7 -6
  121. package/dist/commands/serveBothHandler.js +22 -13
  122. package/dist/commands/serveWebHandler.js +3 -2
  123. package/dist/commands/setup/auth/auth.js +15 -11
  124. package/dist/commands/setup/cache/cache.js +1 -1
  125. package/dist/commands/setup/cache/cacheHandler.js +15 -9
  126. package/dist/commands/setup/database/database.js +15 -0
  127. package/dist/commands/setup/database/postgres.js +19 -0
  128. package/dist/commands/setup/database/postgresHandler.js +196 -0
  129. package/dist/commands/setup/database/templates/db.ts.template +32 -0
  130. package/dist/commands/setup/deploy/deploy.js +4 -3
  131. package/dist/commands/setup/deploy/helpers/helpers.js +5 -1
  132. package/dist/commands/setup/deploy/helpers/index.js +132 -6
  133. package/dist/commands/setup/deploy/providers/baremetalHandler.js +28 -6
  134. package/dist/commands/setup/deploy/providers/coherence.js +1 -1
  135. package/dist/commands/setup/deploy/providers/coherenceHandler.js +60 -31
  136. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +69 -51
  137. package/dist/commands/setup/deploy/providers/netlify.js +6 -0
  138. package/dist/commands/setup/deploy/providers/netlifyHandler.js +114 -13
  139. package/dist/commands/setup/deploy/providers/renderHandler.js +44 -41
  140. package/dist/commands/setup/deploy/providers/serverlessHandler.js +7 -5
  141. package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
  142. package/dist/commands/setup/deploy/providers/universalDeployHandler.js +186 -0
  143. package/dist/commands/setup/deploy/providers/vercel.js +6 -0
  144. package/dist/commands/setup/deploy/providers/vercelHandler.js +115 -14
  145. package/dist/commands/setup/deploy/templates/baremetal.js +3 -2
  146. package/dist/commands/setup/deploy/templates/flightcontrol.js +60 -49
  147. package/dist/commands/setup/deploy/templates/netlify.js +2 -1
  148. package/dist/commands/setup/deploy/templates/netlifyUD.js +31 -0
  149. package/dist/commands/setup/deploy/templates/render.js +32 -17
  150. package/dist/commands/setup/docker/docker.js +2 -2
  151. package/dist/commands/setup/docker/dockerHandler.js +74 -39
  152. package/dist/commands/setup/docker/templates/Dockerfile.npm +119 -0
  153. package/dist/commands/setup/docker/templates/Dockerfile.pnpm +112 -0
  154. package/dist/commands/setup/docker/templates/{Dockerfile → Dockerfile.yarn} +4 -7
  155. package/dist/commands/setup/docker/templates/docker-compose.dev.yml +3 -3
  156. package/dist/commands/setup/docker/templates/docker-compose.prod.yml +2 -5
  157. package/dist/commands/setup/docker/templates/dockerignore +1 -0
  158. package/dist/commands/setup/generator/generator.js +1 -1
  159. package/dist/commands/setup/generator/generatorHandler.js +5 -4
  160. package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +6 -3
  161. package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
  162. package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -7
  163. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
  164. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +4 -3
  165. package/dist/commands/setup/i18n/i18n.js +1 -1
  166. package/dist/commands/setup/i18n/i18nHandler.js +21 -17
  167. package/dist/commands/setup/jobs/jobs.js +1 -1
  168. package/dist/commands/setup/jobs/jobsHandler.js +17 -12
  169. package/dist/commands/setup/mailer/mailer.js +1 -1
  170. package/dist/commands/setup/mailer/mailerHandler.js +13 -11
  171. package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
  172. package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
  173. package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
  174. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +18 -12
  175. package/dist/commands/setup/neon/neon.js +35 -0
  176. package/dist/commands/setup/neon/neonHandler.js +264 -0
  177. package/dist/commands/setup/package/package.js +1 -1
  178. package/dist/commands/setup/package/packageHandler.js +18 -14
  179. package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
  180. package/dist/commands/setup/realtime/realtime.js +1 -1
  181. package/dist/commands/setup/realtime/realtimeHandler.js +26 -37
  182. package/dist/commands/setup/realtime/templates/realtime.ts.template +1 -1
  183. package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
  184. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
  185. package/dist/commands/setup/server-file/serverFile.js +1 -1
  186. package/dist/commands/setup/server-file/serverFileHandler.js +18 -10
  187. package/dist/commands/setup/tenancy/authCodemod.js +66 -0
  188. package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
  189. package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
  190. package/dist/commands/setup/tenancy/preflight.js +49 -0
  191. package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
  192. package/dist/commands/setup/tenancy/signupCodemod.js +153 -0
  193. package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +63 -0
  194. package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
  195. package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
  196. package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +59 -0
  197. package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
  198. package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +389 -0
  199. package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
  200. package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
  201. package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
  202. package/dist/commands/setup/tenancy/tenancy.js +30 -0
  203. package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
  204. package/dist/commands/setup/ui/helpers/helpers.js +5 -1
  205. package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +16 -8
  206. package/dist/commands/setup/ui/libraries/mantineHandler.js +26 -16
  207. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +40 -29
  208. package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
  209. package/dist/commands/setup/uploads/serverFile.js +151 -0
  210. package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
  211. package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
  212. package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
  213. package/dist/commands/setup/uploads/templates/uploads.ts.template +89 -0
  214. package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
  215. package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
  216. package/dist/commands/setup/uploads/uploads.js +49 -7
  217. package/dist/commands/setup/uploads/uploadsHandler.js +266 -72
  218. package/dist/commands/setup.js +5 -4
  219. package/dist/commands/studio.js +1 -1
  220. package/dist/commands/studioHandler.js +2 -2
  221. package/dist/commands/test/datasourceWarning.js +42 -0
  222. package/dist/commands/test/testHandler.js +104 -0
  223. package/dist/commands/test/viteVersionCheck.js +75 -0
  224. package/dist/commands/test.js +16 -19
  225. package/dist/commands/type-check.js +2 -1
  226. package/dist/commands/type-checkHandler.js +25 -18
  227. package/dist/commands/upgrade/preUpgradeScripts.js +11 -11
  228. package/dist/commands/upgrade/upgrade.js +4 -2
  229. package/dist/commands/upgrade/upgradeHandler.js +97 -73
  230. package/dist/index.js +15 -11
  231. package/dist/lib/background.js +22 -1
  232. package/dist/lib/configureStorybook.js +2 -2
  233. package/dist/lib/exec.js +68 -63
  234. package/dist/lib/exit.js +20 -5
  235. package/dist/lib/extendFile.js +23 -13
  236. package/dist/lib/generatePrismaClient.js +48 -12
  237. package/dist/lib/index.js +137 -106
  238. package/dist/lib/loadEnvFiles.js +1 -1
  239. package/dist/lib/locking.js +8 -4
  240. package/dist/lib/merge/algorithms.js +4 -1
  241. package/dist/lib/merge/index.js +78 -41
  242. package/dist/lib/merge/semanticIdentity.js +18 -6
  243. package/dist/lib/merge/strategy.js +86 -36
  244. package/dist/lib/packages.js +23 -13
  245. package/dist/lib/plugin.js +13 -7
  246. package/dist/lib/pluralHelpers.js +6 -2
  247. package/dist/lib/project.js +3 -1
  248. package/dist/lib/rollback.js +7 -7
  249. package/dist/lib/schemaHelpers.js +16 -19
  250. package/dist/lib/test.js +20 -5
  251. package/dist/lib/updateCheck.js +47 -18
  252. package/dist/middleware/checkNodeVersion.js +9 -4
  253. package/dist/middleware/{detectProjectRxVersion.js → detectProjectCedarVersion.js} +2 -2
  254. package/dist/plugin.js +18 -12
  255. package/dist/telemetry/exporter.js +12 -5
  256. package/dist/telemetry/index.js +4 -3
  257. package/dist/telemetry/resource.js +9 -12
  258. package/dist/telemetry/send.js +14 -10
  259. package/dist/testLib/cells.js +5 -3
  260. package/package.json +44 -41
  261. package/LICENSE +0 -21
  262. package/dist/commands/consoleHandler.js +0 -68
  263. package/dist/commands/setup/tsconfig/tsconfig.js +0 -25
  264. package/dist/commands/setup/tsconfig/tsconfigHandler.js +0 -59
  265. package/dist/commands/setup/uploads/dbCodemod.js +0 -28
  266. package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
  267. package/dist/commands/setup/vite/templates/vite.config.ts.template +0 -19
  268. package/dist/commands/setup/vite/vite.js +0 -38
  269. package/dist/commands/setup/vite/viteHandler.js +0 -83
  270. package/dist/commands/testEsm.js +0 -36
  271. package/dist/commands/testHandler.js +0 -137
  272. package/dist/commands/testHandlerEsm.js +0 -85
  273. package/dist/commands/ts-to-js.js +0 -20
  274. package/dist/lib/cedarPluralize.js +0 -56
  275. package/dist/lib/colors.js +0 -18
  276. package/dist/testLib/getFilesWithPattern.js +0 -21
  277. /package/dist/{index.d.js → global.d.js} +0 -0
@@ -1,7 +1,8 @@
1
- import execa from "execa";
2
1
  import { Listr } from "listr2";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
+ import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
4
+ import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
3
5
  import { errorTelemetry } from "@cedarjs/telemetry";
4
- import c from "../../lib/colors.js";
5
6
  import { getPaths } from "../../lib/index.js";
6
7
  import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupInngest.js";
7
8
  import { printTaskEpilogue } from "./util.js";
@@ -10,18 +11,16 @@ const handler = async ({ force }) => {
10
11
  {
11
12
  title: `Adding Inngest setup packages for RedwoodJS ...`,
12
13
  task: async () => {
13
- await execa("yarn", ["add", "-D", "inngest-setup-redwoodjs"], {
14
- cwd: getPaths().base
14
+ await addRootPackages(["inngest-setup-redwoodjs"], {
15
+ cwd: getPaths().base,
16
+ dev: true
15
17
  });
16
18
  }
17
19
  },
18
20
  {
19
21
  task: async () => {
20
- const pluginCommands = ["inngest-setup-redwoodjs", "plugin"];
21
- if (force) {
22
- pluginCommands.push("--force");
23
- }
24
- await execa("yarn", [...pluginCommands], {
22
+ const pluginArgs = force ? ["--force"] : [];
23
+ await runBin("inngest-setup-redwoodjs", ["plugin", ...pluginArgs], {
25
24
  stdout: "inherit",
26
25
  cwd: getPaths().base
27
26
  });
@@ -36,9 +35,11 @@ const handler = async ({ force }) => {
36
35
  try {
37
36
  await tasks.run();
38
37
  } catch (e) {
39
- errorTelemetry(process.argv, e.message);
40
- console.error(c.error(e.message));
41
- process.exit(e?.exitCode || 1);
38
+ const message = e instanceof Error ? e.message : String(e);
39
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
40
+ errorTelemetry(process.argv, message);
41
+ console.error(c.error(message));
42
+ process.exit(exitCode);
42
43
  }
43
44
  };
44
45
  export {
@@ -1,8 +1,8 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-opentelemetry";
4
4
  const description = "Setup OpenTelemetry within the API side";
5
- const EXPERIMENTAL_TOPIC_ID = 4772;
5
+ const EXPERIMENTAL_TOPIC_ID = "4772";
6
6
  const builder = (yargs) => {
7
7
  yargs.option("force", {
8
8
  alias: "f",
@@ -1,16 +1,16 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
4
- import execa from "execa";
5
4
  import { Listr } from "listr2";
6
- import { addApiPackages } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
7
+ import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
7
8
  import {
8
9
  getConfigPath,
9
10
  resolveFile,
10
11
  getSchemaPath
11
12
  } from "@cedarjs/project-config";
12
13
  import { errorTelemetry } from "@cedarjs/telemetry";
13
- import c from "../../lib/colors.js";
14
14
  import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
15
15
  import { isTypeScriptProject } from "../../lib/project.js";
16
16
  import {
@@ -19,7 +19,10 @@ import {
19
19
  EXPERIMENTAL_TOPIC_ID
20
20
  } from "./setupOpentelemetry.js";
21
21
  import { printTaskEpilogue } from "./util.js";
22
- const handler = async ({ force, verbose }) => {
22
+ const handler = async ({
23
+ force,
24
+ verbose
25
+ }) => {
23
26
  const ts = isTypeScriptProject();
24
27
  const configTomlPath = getConfigPath();
25
28
  const configFileName = path.basename(configTomlPath);
@@ -112,7 +115,7 @@ const handler = async ({ force, verbose }) => {
112
115
  },
113
116
  task: (_ctx, task) => {
114
117
  task.output = [
115
- "Please add the following to your 'redwoodFastifyGraphQLServer' plugin options to enable OTel for your graphql",
118
+ "Please add the following to your 'cedarFastifyGraphQLServer' plugin options to enable OTel for your graphql",
116
119
  "openTelemetryOptions: {",
117
120
  " resolvers: true,",
118
121
  " result: true,",
@@ -171,9 +174,8 @@ const handler = async ({ force, verbose }) => {
171
174
  {
172
175
  title: "Regenerate the Prisma client...",
173
176
  task: (_ctx, _task) => {
174
- return execa(`yarn cedar prisma generate`, {
177
+ return runBin("cedar", ["prisma", "generate"], {
175
178
  stdio: "inherit",
176
- shell: true,
177
179
  cwd: getPaths().web.base
178
180
  });
179
181
  }
@@ -210,9 +212,11 @@ const handler = async ({ force, verbose }) => {
210
212
  try {
211
213
  await tasks.run();
212
214
  } catch (e) {
213
- errorTelemetry(process.argv, e.message);
214
- console.error(c.error(e.message));
215
- process.exit(e?.exitCode || 1);
215
+ const message = e instanceof Error ? e.message : String(e);
216
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
217
+ errorTelemetry(process.argv, message);
218
+ console.error(c.error(message));
219
+ process.exit(exitCode);
216
220
  }
217
221
  };
218
222
  export {
@@ -1,8 +1,8 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-react-compiler";
4
4
  const description = "Enable the experimental React Compiler";
5
- const EXPERIMENTAL_TOPIC_ID = 7128;
5
+ const EXPERIMENTAL_TOPIC_ID = "7128";
6
6
  const builder = (yargs) => {
7
7
  yargs.option("force", {
8
8
  alias: "f",
@@ -1,11 +1,14 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import execa from "execa";
4
3
  import { Listr } from "listr2";
5
- import semver from "semver";
4
+ import { coerce, isGreaterOrEqual } from "verkit";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import {
7
+ addRootPackages,
8
+ addWorkspacePackages
9
+ } from "@cedarjs/cli-helpers/packageManager/packages";
6
10
  import { getConfigPath } from "@cedarjs/project-config";
7
11
  import { errorTelemetry } from "@cedarjs/telemetry";
8
- import c from "../../lib/colors.js";
9
12
  import { getPaths, writeFile } from "../../lib/index.js";
10
13
  import {
11
14
  command,
@@ -13,16 +16,16 @@ import {
13
16
  EXPERIMENTAL_TOPIC_ID
14
17
  } from "./setupReactCompiler.js";
15
18
  import { printTaskEpilogue } from "./util.js";
16
- const handler = async ({ force, verbose }) => {
19
+ const handler = async (options) => {
17
20
  const rwPaths = getPaths();
18
21
  const configTomlPath = getConfigPath();
19
22
  const configFileName = path.basename(configTomlPath);
20
23
  const configContent = fs.readFileSync(configTomlPath, "utf-8");
21
- const tasks = new Listr(
22
- [
24
+ function buildTaskData() {
25
+ return [
23
26
  {
24
27
  title: "Check prerequisites",
25
- skip: force,
28
+ skip: options.force,
26
29
  task: () => {
27
30
  if (!rwPaths.web.entryClient || !rwPaths.web.viteConfig) {
28
31
  throw new Error(
@@ -36,8 +39,8 @@ const handler = async ({ force, verbose }) => {
36
39
  )
37
40
  );
38
41
  const reactVersion = webPkgJson["dependencies"]["react"];
39
- const coercedReactVersion = semver.coerce(reactVersion);
40
- if (!semver.gte(coercedReactVersion, "19.0.0")) {
42
+ const coercedReactVersion = coerce(reactVersion);
43
+ if (!coercedReactVersion || !isGreaterOrEqual(coercedReactVersion, "19.0.0")) {
41
44
  throw new Error(
42
45
  "You need to be using at least React version 19 to enable the React Compiler"
43
46
  );
@@ -59,7 +62,7 @@ const handler = async ({ force, verbose }) => {
59
62
  }
60
63
  );
61
64
  } else {
62
- if (force) {
65
+ if (options.force) {
63
66
  task.output = `Overwriting config in ${configFileName}`;
64
67
  writeFile(
65
68
  configTomlPath,
@@ -79,29 +82,27 @@ const handler = async ({ force, verbose }) => {
79
82
  );
80
83
  }
81
84
  }
82
- },
83
- rendererOptions: { persistentOutput: true }
85
+ }
84
86
  },
85
- // We are using two different yarn commands here which is fine because they're operating on different
86
- // workspaces - web and the root
87
+ // We are using two different package manager commands here which is
88
+ // fine because they're operating on different workspaces - web and the
89
+ // root
87
90
  {
88
91
  title: "Installing eslint-plugin-react-compiler",
89
92
  task: async () => {
90
- await execa("yarn", ["add", "-D", "eslint-plugin-react-compiler"], {
91
- cwd: getPaths().base
93
+ await addRootPackages(["eslint-plugin-react-compiler"], {
94
+ cwd: getPaths().base,
95
+ dev: true
92
96
  });
93
97
  }
94
98
  },
95
99
  {
96
100
  title: "Installing babel-plugin-react-compiler",
97
101
  task: async () => {
98
- await execa(
99
- "yarn",
100
- ["web/", "add", "-D", "babel-plugin-react-compiler"],
101
- {
102
- cwd: getPaths().base
103
- }
104
- );
102
+ await addWorkspacePackages("web", ["babel-plugin-react-compiler"], {
103
+ cwd: getPaths().base,
104
+ dev: true
105
+ });
105
106
  }
106
107
  },
107
108
  {
@@ -109,18 +110,32 @@ const handler = async ({ force, verbose }) => {
109
110
  printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
110
111
  }
111
112
  }
112
- ],
113
- {
114
- rendererOptions: { collapseSubtasks: false, persistentOutput: true },
115
- renderer: verbose ? "verbose" : "default"
116
- }
117
- );
113
+ ];
114
+ }
118
115
  try {
119
- await tasks.run();
116
+ if (options.verbose) {
117
+ await new Listr(buildTaskData(), {
118
+ exitOnError: true,
119
+ renderer: "verbose"
120
+ }).run();
121
+ } else {
122
+ await new Listr(
123
+ buildTaskData().map((t) => ({
124
+ ...t,
125
+ rendererOptions: { persistentOutput: true }
126
+ })),
127
+ {
128
+ exitOnError: true,
129
+ rendererOptions: { collapseSubtasks: false }
130
+ }
131
+ ).run();
132
+ }
120
133
  } catch (e) {
121
- errorTelemetry(process.argv, e.message);
122
- console.error(c.error(e.message));
123
- process.exit(e?.exitCode || 1);
134
+ const message = e instanceof Error ? e.message : String(e);
135
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
136
+ errorTelemetry(process.argv, message);
137
+ console.error(c.error(message));
138
+ process.exit(exitCode);
124
139
  }
125
140
  };
126
141
  export {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-rsc";
4
4
  const description = "Enable React Server Components (RSC)";
@@ -2,15 +2,20 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import execa from "execa";
4
4
  import { Listr } from "listr2";
5
- import { prettify } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { prettify } from "@cedarjs/cli-helpers/fileHelpers";
7
+ import { install } from "@cedarjs/cli-helpers/packageManager";
6
8
  import { getConfig, getConfigPath } from "@cedarjs/project-config";
9
+ import { getPackageManager } from "@cedarjs/project-config/packageManager";
7
10
  import { errorTelemetry } from "@cedarjs/telemetry";
8
- import c from "../../lib/colors.js";
9
11
  import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
10
12
  import { isTypeScriptProject } from "../../lib/project.js";
11
13
  import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupRsc.js";
12
14
  import { printTaskEpilogue } from "./util.js";
13
- const handler = async ({ force, verbose }) => {
15
+ const handler = async ({
16
+ force,
17
+ verbose
18
+ }) => {
14
19
  const rwPaths = getPaths();
15
20
  const configTomlPath = getConfigPath();
16
21
  const configContent = fs.readFileSync(configTomlPath, "utf-8");
@@ -83,11 +88,9 @@ const handler = async ({ force, verbose }) => {
83
88
  ),
84
89
  "utf-8"
85
90
  );
86
- const entryClientContent = isTypeScriptProject() ? entryClientTemplate : await transformTSToJS(
87
- rwPaths.web.entryClient,
88
- entryClientTemplate
89
- );
90
- writeFile(rwPaths.web.entryClient, entryClientContent, {
91
+ const entryClient = rwPaths.web.entryClient ?? "";
92
+ const entryClientContent = isTypeScriptProject() ? entryClientTemplate : await transformTSToJS(entryClient, entryClientTemplate);
93
+ writeFile(entryClient, entryClientContent, {
91
94
  overwriteExisting: true
92
95
  });
93
96
  }
@@ -219,7 +222,7 @@ const handler = async ({ force, verbose }) => {
219
222
  {
220
223
  title: "Adding CSS files...",
221
224
  task: async () => {
222
- const files = [
225
+ const cssFiles = [
223
226
  {
224
227
  template: "Counter.css.template",
225
228
  path: ["components", "Counter", "Counter.css"]
@@ -241,7 +244,7 @@ const handler = async ({ force, verbose }) => {
241
244
  path: ["pages", "AboutPage", "AboutPage.css"]
242
245
  }
243
246
  ];
244
- files.forEach((file) => {
247
+ cssFiles.forEach((file) => {
245
248
  const template = fs.readFileSync(
246
249
  path.resolve(
247
250
  import.meta.dirname,
@@ -379,9 +382,8 @@ const handler = async ({ force, verbose }) => {
379
382
  overwriteExisting: true
380
383
  }
381
384
  );
382
- await execa("yarn", [], {
383
- cwd: getPaths().web.base
384
- });
385
+ const pm = getPackageManager();
386
+ await execa(pm, [install()], { cwd: getPaths().web.base });
385
387
  }
386
388
  },
387
389
  {
@@ -398,9 +400,11 @@ const handler = async ({ force, verbose }) => {
398
400
  try {
399
401
  await tasks.run();
400
402
  } catch (e) {
401
- errorTelemetry(process.argv, e.message);
402
- console.error(c.error(e.message));
403
- process.exit(e?.exitCode || 1);
403
+ const message = e instanceof Error ? e.message : String(e);
404
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
405
+ errorTelemetry(process.argv, message);
406
+ console.error(c.error(message));
407
+ process.exit(exitCode);
404
408
  }
405
409
  };
406
410
  export {
@@ -1,8 +1,8 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-streaming-ssr";
4
4
  const description = "Enable React Streaming and Server Side Rendering (SSR)";
5
- const EXPERIMENTAL_TOPIC_ID = 5052;
5
+ const EXPERIMENTAL_TOPIC_ID = "5052";
6
6
  const builder = (yargs) => {
7
7
  yargs.option("force", {
8
8
  alias: "f",
@@ -2,10 +2,10 @@ import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
4
4
  import { Listr } from "listr2";
5
- import { addWebPackages } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
6
7
  import { getConfigPath } from "@cedarjs/project-config";
7
8
  import { errorTelemetry } from "@cedarjs/telemetry";
8
- import c from "../../lib/colors.js";
9
9
  import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
10
10
  import { isTypeScriptProject } from "../../lib/project.js";
11
11
  import {
@@ -14,18 +14,18 @@ import {
14
14
  EXPERIMENTAL_TOPIC_ID
15
15
  } from "./setupStreamingSsr.js";
16
16
  import { printTaskEpilogue } from "./util.js";
17
- const handler = async ({ force, verbose }) => {
18
- const rwPaths = getPaths();
17
+ const handler = async (options) => {
18
+ const cedarPaths = getPaths();
19
19
  const configPath = getConfigPath();
20
20
  const configContent = fs.readFileSync(configPath, "utf-8");
21
21
  const ts = isTypeScriptProject();
22
- const ext = path.extname(rwPaths.web.entryClient || "");
23
- const tasks = new Listr(
24
- [
22
+ const ext = path.extname(cedarPaths.web.entryClient || "");
23
+ function buildTaskData() {
24
+ return [
25
25
  {
26
26
  title: "Check prerequisites",
27
27
  task: () => {
28
- if (!rwPaths.web.entryClient || !rwPaths.web.viteConfig) {
28
+ if (!cedarPaths.web.entryClient || !cedarPaths.web.viteConfig) {
29
29
  throw new Error(
30
30
  "Vite needs to be setup before you can enable Streaming SSR"
31
31
  );
@@ -50,7 +50,7 @@ const handler = async ({ force, verbose }) => {
50
50
  }
51
51
  );
52
52
  } else {
53
- if (force) {
53
+ if (options.force) {
54
54
  task.output = "Overwriting config in cedar.toml";
55
55
  writeFile(
56
56
  configPath,
@@ -76,8 +76,7 @@ const handler = async ({ force, verbose }) => {
76
76
  );
77
77
  }
78
78
  }
79
- },
80
- rendererOptions: { persistentOutput: true }
79
+ }
81
80
  },
82
81
  {
83
82
  title: `Adding entry.client${ext}...`,
@@ -91,10 +90,13 @@ const handler = async ({ force, verbose }) => {
91
90
  ),
92
91
  "utf-8"
93
92
  );
94
- let entryClientPath = rwPaths.web.entryClient;
93
+ let entryClientPath = cedarPaths.web.entryClient;
94
+ if (!entryClientPath) {
95
+ throw new Error("entryClient is not set");
96
+ }
95
97
  const entryClientContent = ts ? entryClientTemplate : await transformTSToJS(entryClientPath, entryClientTemplate);
96
- let overwriteExisting = force;
97
- if (!force) {
98
+ let overwriteExisting = options.force;
99
+ if (!options.force) {
98
100
  const prompt = task.prompt(ListrEnquirerPromptAdapter);
99
101
  overwriteExisting = await prompt.run({
100
102
  type: "Confirm",
@@ -107,8 +109,7 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
107
109
  }
108
110
  }
109
111
  writeFile(entryClientPath, entryClientContent, { overwriteExisting });
110
- },
111
- rendererOptions: { persistentOutput: true }
112
+ }
112
113
  },
113
114
  {
114
115
  title: `Adding entry.server${ext}...`,
@@ -123,12 +124,12 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
123
124
  "utf-8"
124
125
  );
125
126
  const entryServerPath = path.join(
126
- rwPaths.web.src,
127
+ cedarPaths.web.src,
127
128
  `entry.server${ext}`
128
129
  );
129
130
  const entryServerContent = ts ? entryServerTemplate : await transformTSToJS(entryServerPath, entryServerTemplate);
130
131
  writeFile(entryServerPath, entryServerContent, {
131
- overwriteExisting: force
132
+ overwriteExisting: options.force
132
133
  });
133
134
  }
134
135
  },
@@ -144,10 +145,10 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
144
145
  ),
145
146
  "utf-8"
146
147
  );
147
- const documentPath = path.join(rwPaths.web.src, `Document${ext}`);
148
+ const documentPath = path.join(cedarPaths.web.src, `Document${ext}`);
148
149
  const documentContent = ts ? documentTemplate : await transformTSToJS(documentPath, documentTemplate);
149
150
  writeFile(documentPath, documentContent, {
150
- overwriteExisting: force
151
+ overwriteExisting: options.force
151
152
  });
152
153
  }
153
154
  },
@@ -164,18 +165,18 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
164
165
  "utf-8"
165
166
  );
166
167
  const tsconfigPath = path.join(
167
- rwPaths.web.base,
168
+ cedarPaths.web.base,
168
169
  ts ? "tsconfig.json" : "jsconfig.json"
169
170
  );
170
171
  writeFile(tsconfigPath, tsconfigTemplate, {
171
- overwriteExisting: force
172
+ overwriteExisting: options.force
172
173
  });
173
174
  }
174
175
  },
175
176
  {
176
177
  title: 'Adding resolution for "@apollo/client-react-streaming/superjson"',
177
178
  task: () => {
178
- const pkgJsonPath = path.join(rwPaths.base, "package.json");
179
+ const pkgJsonPath = path.join(cedarPaths.base, "package.json");
179
180
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
180
181
  const resolutions = pkgJson.resolutions || {};
181
182
  resolutions["@apollo/client-react-streaming/superjson"] = "^1.12.2";
@@ -183,24 +184,38 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
183
184
  fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
184
185
  }
185
186
  },
186
- addWebPackages(["@apollo/client-react-streaming@0.10.0"]),
187
+ addWebPackages(["@apollo/client-react-streaming@0.14.5"]),
187
188
  {
188
189
  task: () => {
189
190
  printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
190
191
  }
191
192
  }
192
- ],
193
- {
194
- rendererOptions: { collapseSubtasks: false, persistentOutput: true },
195
- renderer: verbose ? "verbose" : "default"
196
- }
197
- );
193
+ ];
194
+ }
198
195
  try {
199
- await tasks.run();
196
+ if (options.verbose) {
197
+ await new Listr(buildTaskData(), {
198
+ exitOnError: true,
199
+ renderer: "verbose"
200
+ }).run();
201
+ } else {
202
+ await new Listr(
203
+ buildTaskData().map((t) => ({
204
+ ...t,
205
+ rendererOptions: { persistentOutput: true }
206
+ })),
207
+ {
208
+ exitOnError: true,
209
+ rendererOptions: { collapseSubtasks: false }
210
+ }
211
+ ).run();
212
+ }
200
213
  } catch (e) {
201
- errorTelemetry(process.argv, e.message);
202
- console.error(c.error(e.message));
203
- process.exit(e?.exitCode || 1);
214
+ const message = e instanceof Error ? e.message : String(e);
215
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
216
+ errorTelemetry(process.argv, message);
217
+ console.error(c.error(message));
218
+ process.exit(exitCode);
204
219
  }
205
220
  };
206
221
  export {
@@ -24,11 +24,12 @@ const resource = Resource.default().merge(
24
24
  )
25
25
 
26
26
  const studioPort = getConfig().studio.basePort
27
+ const apiUrl = getConfig().web.apiUrl.replace(/\/$/, '')
27
28
  const exporter = new OTLPTraceExporter({
28
29
  // Update this URL to point to where your OTLP compatible collector is listening
29
30
  // The redwood development studio (`yarn cedar exp studio`) can collect your
30
31
  // telemetry at `http://127.0.0.1:<PORT>/v1/traces` (default PORT is 4318)
31
- url: `http://127.0.0.1:${studioPort}/.redwood/functions/otel-trace`,
32
+ url: `http://127.0.0.1:${studioPort}${apiUrl}/otel-trace`,
32
33
  concurrencyLimit: 64,
33
34
  })
34
35
 
@@ -20,7 +20,7 @@ export const Document: React.FC<DocumentProps> = ({ children, css, meta }) => {
20
20
  <Meta tags={meta} />
21
21
  </head>
22
22
  <body>
23
- <div id="redwood-app">{children}</div>
23
+ <div id="cedar-app">{children}</div>
24
24
  </body>
25
25
  </html>
26
26
  )
@@ -4,29 +4,29 @@ import App from './App'
4
4
  import Routes from './Routes'
5
5
 
6
6
  /**
7
- * When `#redwood-app` isn't empty then it's very likely that you're using
7
+ * When `#cedar-app` isn't empty then it's very likely that you're using
8
8
  * pre-rendering. So React attaches event listeners to the existing markup
9
9
  * rather than replacing it.
10
10
  * https://react.dev/reference/react-dom/client/hydrateRoot
11
11
  */
12
- const redwoodAppElement = document.getElementById('redwood-app')
12
+ const cedarAppElement = document.getElementById('cedar-app')
13
13
 
14
- if (!redwoodAppElement) {
14
+ if (!cedarAppElement) {
15
15
  throw new Error(
16
- "Could not find an element with ID 'redwood-app'. Please ensure it " +
17
- "exists in your 'web/src/index.html' file."
16
+ 'Could not find an element with ID "cedar-app". Please ensure it exists ' +
17
+ 'in your `web/index.html` file.'
18
18
  )
19
19
  }
20
20
 
21
- if (redwoodAppElement.children?.length > 0) {
21
+ if (cedarAppElement.children?.length > 0) {
22
22
  hydrateRoot(
23
- redwoodAppElement,
23
+ cedarAppElement,
24
24
  <App>
25
25
  <Routes />
26
26
  </App>
27
27
  )
28
28
  } else {
29
- const root = createRoot(redwoodAppElement)
29
+ const root = createRoot(cedarAppElement)
30
30
  root.render(
31
31
  <App>
32
32
  <Routes />
@@ -20,7 +20,7 @@ export const Document: React.FC<DocumentProps> = ({ children, css, meta }) => {
20
20
  <Meta tags={meta} />
21
21
  </head>
22
22
  <body>
23
- <div id="redwood-app">{children}</div>
23
+ <div id="cedar-app">{children}</div>
24
24
  </body>
25
25
  </html>
26
26
  )