@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,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
- import c from "../../../lib/colors.js";
4
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
5
5
  import { getPaths } from "../../../lib/index.js";
6
6
  const SIDE_MAP = {
7
7
  web: ["cell", "component", "layout", "page", "scaffold"],
@@ -36,7 +36,7 @@ const tasks = ({ name, force }) => {
36
36
  },
37
37
  {
38
38
  title: "Destination:",
39
- task: (ctx, task) => {
39
+ task: (_ctx, task) => {
40
40
  task.title = ` Wrote templates to ${destination.replace(
41
41
  getPaths().base,
42
42
  ""
@@ -44,7 +44,7 @@ const tasks = ({ name, force }) => {
44
44
  }
45
45
  }
46
46
  ],
47
- { rendererOptions: { collapseSubtasks: false }, errorOnExist: true }
47
+ { rendererOptions: { collapseSubtasks: false } }
48
48
  );
49
49
  };
50
50
  const handler = async ({ name, force }) => {
@@ -52,7 +52,8 @@ const handler = async ({ name, force }) => {
52
52
  try {
53
53
  await t.run();
54
54
  } catch (e) {
55
- console.log(c.error(e.message));
55
+ const message = e instanceof Error ? e.message : String(e);
56
+ console.log(c.error(message));
56
57
  }
57
58
  };
58
59
  export {
@@ -16,8 +16,11 @@ function isPropertyWithName(node, name) {
16
16
  function transform(file, api) {
17
17
  const j = api.jscodeshift;
18
18
  const root = j(file.source);
19
- const redwoodApolloProvider = root.findJSXElements("RedwoodApolloProvider");
20
- const graphQLClientConfigCollection = redwoodApolloProvider.find(
19
+ let apolloProviderElements = root.findJSXElements("CedarApolloProvider");
20
+ if (apolloProviderElements.length === 0) {
21
+ apolloProviderElements = root.findJSXElements("RedwoodApolloProvider");
22
+ }
23
+ const graphQLClientConfigCollection = apolloProviderElements.find(
21
24
  j.JSXAttribute,
22
25
  {
23
26
  name: { name: "graphQLClientConfig" }
@@ -104,7 +107,7 @@ function transform(file, api) {
104
107
  cacheConfigValue.properties.push(property);
105
108
  }
106
109
  graphQLClientConfigCollection.remove();
107
- redwoodApolloProvider.get(0).node.openingElement.attributes.push(
110
+ apolloProviderElements.get(0).node.openingElement.attributes.push(
108
111
  j.jsxAttribute(
109
112
  j.jsxIdentifier("graphQLClientConfig"),
110
113
  j.jsxExpressionContainer(j.identifier(graphQLClientConfigVariableName))
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "fragments";
3
3
  const description = "Set up Fragments for GraphQL";
4
4
  function builder(yargs) {
@@ -1,13 +1,11 @@
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
4
  import { format } from "prettier";
6
- import {
7
- colors,
8
- getPrettierOptions,
9
- setTomlSetting
10
- } from "@cedarjs/cli-helpers";
5
+ import { colors } from "@cedarjs/cli-helpers/colors";
6
+ import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
7
+ import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
8
+ import { setTomlSetting } from "@cedarjs/cli-helpers/project";
11
9
  import { getConfig, getPaths } from "@cedarjs/project-config";
12
10
  import { runTransform } from "../../../../../lib/runTransform.js";
13
11
  const command = "fragments";
@@ -34,7 +32,7 @@ async function handler({ force }) {
34
32
  {
35
33
  title: "Generate possibleTypes.ts",
36
34
  task: () => {
37
- execa.commandSync("yarn cedar generate types", { stdio: "ignore" });
35
+ runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
38
36
  }
39
37
  },
40
38
  {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "trusted-documents";
3
3
  const description = "Set up Trusted Documents for GraphQL";
4
4
  function builder(yargs) {
@@ -1,9 +1,10 @@
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
4
  import { format } from "prettier";
6
- import { getPrettierOptions, setTomlSetting } from "@cedarjs/cli-helpers";
5
+ import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
6
+ import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
7
+ import { setTomlSetting } from "@cedarjs/cli-helpers/project";
7
8
  import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
8
9
  import { runTransform } from "../../../../../lib/runTransform.js";
9
10
  async function handler({ force }) {
@@ -28,7 +29,7 @@ async function handler({ force }) {
28
29
  {
29
30
  title: "Generating Trusted Documents store ...",
30
31
  task: () => {
31
- execa.commandSync("yarn cedar generate types", { stdio: "ignore" });
32
+ runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
32
33
  }
33
34
  },
34
35
  {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "i18n";
3
3
  const description = "Set up i18n";
4
4
  const builder = (yargs) => {
@@ -1,21 +1,22 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
- import execa from "execa";
4
3
  import { Listr } from "listr2";
4
+ import { terminalLink } from "termi-link";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
5
7
  import { errorTelemetry } from "@cedarjs/telemetry";
6
- import c from "../../../lib/colors.js";
7
8
  import extendStorybookConfiguration from "../../../lib/configureStorybook.js";
8
9
  import { fileIncludes } from "../../../lib/extendFile.js";
9
10
  import { getPaths, writeFile } from "../../../lib/index.js";
10
11
  const APP_JS_PATH = getPaths().web.app;
11
12
  const i18nImportExist = (appJS) => {
12
- let content = appJS.toString();
13
+ const content = appJS.toString();
13
14
  const hasBaseImport = () => /import '.\/i18n'/.test(content);
14
15
  return hasBaseImport();
15
16
  };
16
17
  const addI18nImport = (appJS) => {
17
- var content = appJS.toString().split("\n").reverse();
18
- const index = content.findIndex((value) => /import/.test(value));
18
+ const content = appJS.toString().split("\n").reverse();
19
+ const index = content.findIndex((value) => value.includes("import"));
19
20
  content.splice(index, 0, "import './i18n'");
20
21
  return content.reverse().join(`
21
22
  `);
@@ -38,14 +39,15 @@ const handler = async ({ force }) => {
38
39
  {
39
40
  title: "Install i18next, react-i18next and i18next-browser-languagedetector",
40
41
  task: async () => {
41
- await execa("yarn", [
42
- "workspace",
42
+ await addWorkspacePackages(
43
43
  "web",
44
- "add",
45
- "i18next",
46
- "react-i18next",
47
- "i18next-browser-languagedetector"
48
- ]);
44
+ [
45
+ "i18next",
46
+ "react-i18next",
47
+ "i18next-browser-languagedetector"
48
+ ],
49
+ { cwd: rwPaths.base }
50
+ );
49
51
  }
50
52
  }
51
53
  ],
@@ -122,7 +124,7 @@ const handler = async ({ force }) => {
122
124
  {
123
125
  title: "Adding import to App.{jsx,tsx}...",
124
126
  task: (_ctx, task) => {
125
- let appJS = fs.readFileSync(APP_JS_PATH);
127
+ const appJS = fs.readFileSync(APP_JS_PATH);
126
128
  if (i18nImportExist(appJS)) {
127
129
  task.skip("Import already exists in App.js");
128
130
  } else {
@@ -149,7 +151,7 @@ const handler = async ({ force }) => {
149
151
 
150
152
  ${c.tip("Quick link to the docs:")}
151
153
 
152
- ${c.link("https://react.i18next.com/guides/quick-start/")}
154
+ ${terminalLink("react-i18next quick start guide", "https://react.i18next.com/guides/quick-start/")}
153
155
  `;
154
156
  }
155
157
  }
@@ -159,9 +161,11 @@ const handler = async ({ force }) => {
159
161
  try {
160
162
  await tasks.run();
161
163
  } catch (e) {
162
- errorTelemetry(process.argv, e.message);
163
- console.error(c.error(e.message));
164
- process.exit(e?.exitCode || 1);
164
+ const message = e instanceof Error ? e.message : String(e);
165
+ errorTelemetry(process.argv, message);
166
+ console.error(c.error(message));
167
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
168
+ process.exit(exitCode);
165
169
  }
166
170
  };
167
171
  export {
@@ -1,5 +1,5 @@
1
1
  import { terminalLink } from "termi-link";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
3
  const command = "jobs";
4
4
  const description = "Sets up the config file and parent directory for background jobs";
5
5
  const builder = (yargs) => {
@@ -2,12 +2,14 @@ import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import prismaInternals from "@prisma/internals";
4
4
  import { Listr } from "listr2";
5
- import { addApiPackages } from "@cedarjs/cli-helpers";
6
- import { getSchemaPath } from "@cedarjs/project-config";
7
- import c from "../../../lib/colors.js";
5
+ import { terminalLink } from "termi-link";
6
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
7
+ import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
8
+ import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
9
+ import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
8
10
  import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
9
11
  import { isTypeScriptProject } from "../../../lib/project.js";
10
- const { getDMMF, getSchemaWithPath } = prismaInternals;
12
+ const { getDMMF } = prismaInternals;
11
13
  const MODEL_SCHEMA = `
12
14
  model BackgroundJob {
13
15
  id Int @id @default(autoincrement())
@@ -26,8 +28,7 @@ model BackgroundJob {
26
28
  }
27
29
  `;
28
30
  const getModelNames = async () => {
29
- const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
30
- const { schemas } = await getSchemaWithPath(schemaPath);
31
+ const { schemas } = await getPrismaSchemas();
31
32
  const schema = await getDMMF({ datamodel: schemas });
32
33
  return schema.datamodel.models.map((model) => model.name);
33
34
  };
@@ -54,6 +55,7 @@ const tasks = async ({ force }) => {
54
55
  if (modelExists) {
55
56
  return "BackgroundJob model exists, skipping";
56
57
  }
58
+ return false;
57
59
  }
58
60
  },
59
61
  {
@@ -98,19 +100,22 @@ const tasks = async ({ force }) => {
98
100
  ${c.success("\nBackground jobs configured!\n")}
99
101
 
100
102
  ${!modelExists ? "Migrate your database to finish setting up jobs:\n" : ""}
101
- ${!modelExists ? c.highlight("\n\xA0\xA0yarn cedar prisma migrate dev\n") : ""}
103
+ ${!modelExists ? c.highlight(`
104
+ \xA0\xA0${formatCedarCommand(["prisma", "migrate", "dev"])}
105
+ `) : ""}
102
106
 
103
- Generate jobs with: ${c.highlight("yarn cedar g job <name>")}
104
- Execute jobs with: ${c.highlight("yarn cedar jobs work\n")}
107
+ Generate jobs with: ${c.highlight(formatCedarCommand(["g", "job", "<name>"]))}
108
+ Execute jobs with: ${c.highlight(`${formatCedarCommand(["jobs", "work"])}
109
+ `)}
105
110
 
106
111
  Check out the docs for more info:
107
- ${c.link("https://cedarjs.com/docs/background-jobs")}
112
+ ${terminalLink("", "https://cedarjs.com/docs/background-jobs")}
108
113
 
109
114
  `;
110
115
  }
111
116
  }
112
117
  ],
113
- { rendererOptions: { collapseSubtasks: false }, errorOnExist: true }
118
+ { rendererOptions: { collapseSubtasks: false }, exitOnError: true }
114
119
  );
115
120
  };
116
121
  const handler = async ({ force }) => {
@@ -118,7 +123,7 @@ const handler = async ({ force }) => {
118
123
  try {
119
124
  await t.run();
120
125
  } catch (e) {
121
- console.error(c.error(e.message));
126
+ console.error(c.error(e instanceof Error ? e.message : String(e)));
122
127
  }
123
128
  };
124
129
  export {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "mailer";
3
3
  const description = "Setup the Cedar mailer. This will install the required packages and add the required initial configuration to your Cedar app.";
4
4
  const builder = (yargs) => {
@@ -1,19 +1,19 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { pathToFileURL } from "node:url";
4
3
  import { Listr } from "listr2";
5
- import { addApiPackages } from "@cedarjs/cli-helpers";
4
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
5
+ import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
6
6
  import { errorTelemetry } from "@cedarjs/telemetry";
7
- import c from "../../../lib/colors.js";
8
7
  import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
9
8
  import { isTypeScriptProject } from "../../../lib/project.js";
10
- const handler = async ({ force, skipExamples }) => {
9
+ const handler = async ({
10
+ force,
11
+ skipExamples
12
+ }) => {
11
13
  const projectIsTypescript = isTypeScriptProject();
12
14
  const pkgJsonPath = path.join(getPaths().base, "package.json");
13
- const { default: pkgJson } = await import(pathToFileURL(pkgJsonPath), {
14
- with: { type: "json" }
15
- });
16
- const cedarVersion = pkgJson.devDependencies["@cedarjs/core"] ?? "latest";
15
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
16
+ const cedarVersion = pkgJson.devDependencies?.["@cedarjs/core"] ?? "latest";
17
17
  const extension = projectIsTypescript ? "ts" : "js";
18
18
  const tasks = new Listr(
19
19
  [
@@ -100,9 +100,11 @@ const handler = async ({ force, skipExamples }) => {
100
100
  try {
101
101
  await tasks.run();
102
102
  } catch (e) {
103
- errorTelemetry(process.argv, e.message);
104
- console.error(c.error(e.message));
105
- process.exit(e?.exitCode || 1);
103
+ const message = e instanceof Error ? e.message : String(e);
104
+ errorTelemetry(process.argv, message);
105
+ console.error(c.error(message));
106
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
107
+ process.exit(exitCode);
106
108
  }
107
109
  };
108
110
  export {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "og-image";
3
3
  const aliases = ["ogImage", "ogimage"];
4
4
  const description = "Set up OG Image generation middleware";
@@ -2,7 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
4
  import { format } from "prettier";
5
- import { addWebPackages, getPrettierOptions } from "@cedarjs/cli-helpers";
5
+ import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
6
+ import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
6
7
  import { getConfig, getPaths } from "@cedarjs/project-config";
7
8
  import { runTransform } from "../../../../lib/runTransform.js";
8
9
  async function handler({ force }) {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "sentry";
3
3
  const description = "Setup Sentry error and performance tracking";
4
4
  const builder = (yargs) => {
@@ -1,16 +1,17 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
+ import { colors } from "@cedarjs/cli-helpers/colors";
5
+ import { prettify, writeFilesTask } from "@cedarjs/cli-helpers/fileHelpers";
4
6
  import {
5
7
  addApiPackages,
8
+ addWebPackages
9
+ } from "@cedarjs/cli-helpers/installHelpers";
10
+ import { getPaths } from "@cedarjs/cli-helpers/paths";
11
+ import {
6
12
  addEnvVarTask,
7
- addWebPackages,
8
- colors,
9
- getPaths,
10
- isTypeScriptProject,
11
- prettify,
12
- writeFilesTask
13
- } from "@cedarjs/cli-helpers";
13
+ isTypeScriptProject
14
+ } from "@cedarjs/cli-helpers/project";
14
15
  import { getConfigPath } from "@cedarjs/project-config";
15
16
  import { errorTelemetry } from "@cedarjs/telemetry";
16
17
  const rwPaths = getPaths();
@@ -90,15 +91,20 @@ const handler = async ({ force }) => {
90
91
  title: "Replacing Redwood's Error boundary",
91
92
  task: async () => {
92
93
  const contentLines = fs.readFileSync(rwPaths.web.app).toString().split("\n");
94
+ const webImportRe = /^import \{ FatalErrorBoundary, ((?:Cedar|Redwood)Provider) \} from '@cedarjs\/web'$/;
93
95
  const webImportIndex = contentLines.findLastIndex(
94
- (line) => /^import { FatalErrorBoundary, RedwoodProvider } from '@cedarjs\/web'$/.test(
95
- line
96
- )
96
+ (line) => webImportRe.test(line)
97
97
  );
98
+ if (webImportIndex === -1) {
99
+ throw new Error(
100
+ `Could not find "import { FatalErrorBoundary, CedarProvider } from '@cedarjs/web'" in web/src/App`
101
+ );
102
+ }
103
+ const providerName = contentLines[webImportIndex].match(webImportRe)?.[1];
98
104
  contentLines.splice(
99
105
  webImportIndex,
100
106
  1,
101
- "import { RedwoodProvider } from '@cedarjs/web'"
107
+ `import { ${providerName} } from '@cedarjs/web'`
102
108
  );
103
109
  const boundaryOpenIndex = contentLines.findLastIndex(
104
110
  (line) => line.includes("<FatalErrorBoundary page={FatalErrorPage}>")
@@ -121,7 +127,7 @@ const handler = async ({ force }) => {
121
127
  },
122
128
  {
123
129
  title: "One more thing...",
124
- task: (ctx) => {
130
+ task: (ctx, task) => {
125
131
  notes.push(
126
132
  colors.important(
127
133
  task.output = `You will need to add \`SENTRY_DSN\` to \`includeEnvironmentVariables\` in ${configFileName}.`
@@ -0,0 +1,35 @@
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
+ const command = "neon";
3
+ const description = "Provision a Neon Postgres database and configure your project";
4
+ function builder(yargs) {
5
+ return yargs.option("force", {
6
+ alias: "f",
7
+ default: false,
8
+ description: "Overwrite existing DATABASE_URL in .env",
9
+ type: "boolean"
10
+ }).option("migrations", {
11
+ description: "Run Prisma migrations after setup. Omit to be prompted. Use --no-migrations to skip.",
12
+ type: "boolean"
13
+ }).option("verbose", {
14
+ alias: "v",
15
+ default: false,
16
+ description: "Show full output from migration commands (stderr visible in terminal)",
17
+ type: "boolean"
18
+ });
19
+ }
20
+ async function handler({ force, migrations, verbose }) {
21
+ recordTelemetryAttributes({
22
+ command: "setup neon",
23
+ force,
24
+ migrations,
25
+ verbose
26
+ });
27
+ const { handler: handler2 } = await import("./neonHandler.js");
28
+ return handler2({ force, migrations, verbose });
29
+ }
30
+ export {
31
+ builder,
32
+ command,
33
+ description,
34
+ handler
35
+ };