@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
@@ -6,24 +6,40 @@ import { config } from "dotenv-defaults";
6
6
  import execa from "execa";
7
7
  import { Listr } from "listr2";
8
8
  import prompts from "prompts";
9
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
10
- import c from "../../lib/colors.js";
9
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
10
+ import {
11
+ formatAddRootPackagesCommand,
12
+ formatRunBinCommand
13
+ } from "@cedarjs/cli-helpers/packageManager/display";
14
+ import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
15
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
11
16
  import { getPaths } from "../../lib/index.js";
12
17
  const preRequisites = () => [
13
18
  {
14
19
  title: "Checking if Serverless framework is installed...",
15
- command: ["yarn serverless", ["--version"]],
16
- errorMessage: [
17
- "Looks like Serverless is not installed.",
18
- "Please run yarn add -W --dev serverless."
19
- ]
20
+ task: async () => {
21
+ try {
22
+ await runBin("serverless", ["--version"], { shell: true });
23
+ } catch (error) {
24
+ const msg = error instanceof Error ? error.message : String(error);
25
+ throw new Error(
26
+ `${msg}
27
+ Looks like Serverless is not installed.
28
+ Please run ${formatAddRootPackagesCommand(["serverless"], true)}.`
29
+ );
30
+ }
31
+ }
20
32
  }
21
33
  ];
22
- const buildCommands = ({ sides }) => {
34
+ const buildCommands = ({
35
+ sides
36
+ }) => {
23
37
  return [
24
38
  {
25
39
  title: `Building ${sides.join(" & ")}...`,
26
- command: ["yarn", ["cedar", "build", ...sides]]
40
+ task: async () => {
41
+ await runBin("cedar", ["build", ...sides], { shell: true });
42
+ }
27
43
  },
28
44
  {
29
45
  title: "Packing Functions...",
@@ -35,13 +51,18 @@ const buildCommands = ({ sides }) => {
35
51
  }
36
52
  ];
37
53
  };
38
- const deployCommands = ({ stage, sides, firstRun, packOnly }) => {
54
+ const deployCommands = ({
55
+ stage,
56
+ sides,
57
+ firstRun,
58
+ packOnly
59
+ }) => {
39
60
  const slsStage = stage ? ["--stage", stage] : [];
40
61
  return sides.map((side) => {
41
62
  return {
42
63
  title: `Deploying ${side}....`,
43
64
  task: async () => {
44
- await execa("yarn", ["serverless", "deploy", ...slsStage], {
65
+ await runBin("serverless", ["deploy", ...slsStage], {
45
66
  cwd: path.join(getPaths().base, side),
46
67
  shell: true,
47
68
  stdio: "inherit",
@@ -55,6 +76,7 @@ const deployCommands = ({ stage, sides, firstRun, packOnly }) => {
55
76
  if (packOnly) {
56
77
  return "Finishing early due to --pack-only flag. Your Redwood project is packaged and ready to deploy";
57
78
  }
79
+ return false;
58
80
  }
59
81
  };
60
82
  });
@@ -79,13 +101,13 @@ const handler = async (yargs) => {
79
101
  loadDotEnvForStage(dotEnvPath);
80
102
  const tasks = new Listr(
81
103
  [
82
- ...preRequisites(yargs).map(mapCommandsToListr),
104
+ ...preRequisites().map(mapCommandsToListr),
83
105
  ...buildCommands(yargs).map(mapCommandsToListr),
84
106
  ...deployCommands(yargs).map(mapCommandsToListr)
85
107
  ],
86
108
  {
87
109
  exitOnError: true,
88
- renderer: yargs.verbose && "verbose"
110
+ renderer: yargs.verbose ? "verbose" : void 0
89
111
  }
90
112
  );
91
113
  try {
@@ -94,14 +116,21 @@ const handler = async (yargs) => {
94
116
  const SETUP_MARKER = ansis.bgBlue.black("First Setup ");
95
117
  console.log();
96
118
  console.log(SETUP_MARKER, c.success("Starting first setup wizard..."));
97
- const { stdout: slsInfo } = await execa(
98
- `yarn serverless info --verbose --stage=${yargs.stage}`,
119
+ const { stdout: slsInfo } = await runBin(
120
+ "serverless",
121
+ ["info", "--verbose", `--stage=${yargs.stage}`],
99
122
  {
100
123
  shell: true,
101
124
  cwd: getPaths().api.base
102
125
  }
103
126
  );
104
- const deployedApiUrl = slsInfo.match(/HttpApiUrl: (https:\/\/.*)/)[1];
127
+ const apiMatch = slsInfo.match(/HttpApiUrl: (https:\/\/.*)/);
128
+ if (!apiMatch) {
129
+ throw new Error(
130
+ "Could not find HttpApiUrl in serverless info output. Deploy may have failed."
131
+ );
132
+ }
133
+ const deployedApiUrl = apiMatch[1];
105
134
  console.log();
106
135
  console.log(SETUP_MARKER, `Found ${c.success(deployedApiUrl)}`);
107
136
  console.log();
@@ -125,7 +154,7 @@ const handler = async (yargs) => {
125
154
  const webDeployTasks = new Listr(
126
155
  [
127
156
  // Rebuild web with the new API_URL
128
- ...buildCommands({ ...yargs, sides: ["web"], firstRun: false }).map(
157
+ ...buildCommands({ ...yargs, sides: ["web"] }).map(
129
158
  mapCommandsToListr
130
159
  ),
131
160
  ...deployCommands({
@@ -136,25 +165,32 @@ const handler = async (yargs) => {
136
165
  ],
137
166
  {
138
167
  exitOnError: true,
139
- renderer: yargs.verbose && "verbose"
168
+ renderer: yargs.verbose ? "verbose" : void 0
140
169
  }
141
170
  );
142
171
  await webDeployTasks.run();
143
- const { stdout: slsInfo2 } = await execa(
144
- `yarn serverless info --verbose --stage=${yargs.stage}`,
172
+ const { stdout: webSlsInfo } = await runBin(
173
+ "serverless",
174
+ ["info", "--verbose", `--stage=${yargs.stage}`],
145
175
  {
146
176
  shell: true,
147
177
  cwd: getPaths().web.base
148
178
  }
149
179
  );
150
- const deployedWebUrl = slsInfo2.match(/url: (https:\/\/.*)/)[1];
180
+ const webMatch = webSlsInfo.match(/url: (https:\/\/.*)/);
181
+ if (!webMatch) {
182
+ throw new Error(
183
+ "Could not find url in serverless info output. Deploy may have failed."
184
+ );
185
+ }
186
+ const deployedWebUrl = webMatch[1];
151
187
  const message = [
152
188
  c.bold("Successful first deploy!"),
153
189
  "",
154
190
  `View your deployed site at: ${c.success(deployedWebUrl)}`,
155
191
  "",
156
192
  "You can use serverless.com CI/CD by connecting/creating an app",
157
- "To do this run `yarn serverless` on each of the sides, and connect your account",
193
+ `To do this run \`${formatRunBinCommand("serverless")}\` on each of the sides, and connect your account`,
158
194
  "",
159
195
  "Find more information in our docs:",
160
196
  c.underline("https://cedarjs.com/docs/deploy#serverless")
@@ -169,8 +205,9 @@ const handler = async (yargs) => {
169
205
  }
170
206
  }
171
207
  } catch (e) {
172
- console.error(c.error(e.message));
173
- process.exit(e?.exitCode || 1);
208
+ console.error(c.error(e instanceof Error ? e.message : String(e)));
209
+ const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
210
+ process.exit(exitCode);
174
211
  }
175
212
  };
176
213
  const mapCommandsToListr = ({
@@ -186,14 +223,19 @@ const mapCommandsToListr = ({
186
223
  title,
187
224
  task: task ? task : async () => {
188
225
  try {
189
- const executingCommand = execa(...command, {
226
+ if (!command) {
227
+ throw new Error(
228
+ "No command or task provided to mapCommandsToListr"
229
+ );
230
+ }
231
+ const executingCommand = execa(command[0], command[1], {
190
232
  cwd: cwd || getPaths().base,
191
233
  shell: true
192
234
  });
193
- executingCommand.stdout.pipe(process.stdout);
235
+ executingCommand.stdout?.pipe(process.stdout);
194
236
  await executingCommand;
195
237
  } catch (error) {
196
- if (errorMessage) {
238
+ if (errorMessage && error instanceof Error) {
197
239
  error.message = error.message + "\n" + errorMessage.join(" ");
198
240
  }
199
241
  throw error;
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { deployBuilder } from "./helpers/deployBuilder.js";
3
3
  const command = "vercel [...commands]";
4
4
  const description = "Build command for Vercel deploy";
@@ -1,6 +1,6 @@
1
1
  import { createHandler, createYargsForComponentDestroy } from "../helpers.js";
2
2
  const description = "Destroy a component";
3
- const { command, builder, tasks } = createYargsForComponentDestroy({
3
+ const { command, builder } = createYargsForComponentDestroy({
4
4
  componentName: "component"
5
5
  });
6
6
  const handler = createHandler("component");
@@ -8,6 +8,5 @@ export {
8
8
  builder,
9
9
  command,
10
10
  description,
11
- handler,
12
- tasks
11
+ handler
13
12
  };
@@ -1,9 +1,7 @@
1
- import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
2
1
  import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
3
2
  const description = "Destroy a directive";
4
3
  const { command, builder } = createYargsForComponentDestroy({
5
- componentName: "directive",
6
- filesFn: (args) => directiveFiles({ ...args, type: "validator" })
4
+ componentName: "directive"
7
5
  });
8
6
  const handler = createHandler("directive");
9
7
  export {
@@ -1,12 +1,10 @@
1
1
  import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
2
2
  import { createHandler } from "../handlerHelpers.js";
3
- const description = "Destroy a directive";
4
- const { builder, tasks } = createHandler({
3
+ const { handler, tasks } = createHandler({
5
4
  componentName: "directive",
6
5
  filesFn: (args) => directiveFiles({ ...args, type: "validator" })
7
6
  });
8
7
  export {
9
- builder,
10
- description,
8
+ handler,
11
9
  tasks
12
10
  };
@@ -1,4 +1,3 @@
1
- import { files as functionFiles } from "../../generate/function/functionHandler.js";
2
1
  import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
3
2
  const description = "Destroy a Function";
4
3
  const builder = (yargs) => {
@@ -8,8 +7,7 @@ const builder = (yargs) => {
8
7
  });
9
8
  };
10
9
  const { command } = createYargsForComponentDestroy({
11
- componentName: "function",
12
- filesFn: functionFiles
10
+ componentName: "function"
13
11
  });
14
12
  const handler = createHandler("function");
15
13
  export {
@@ -1,18 +1,20 @@
1
1
  import { Listr } from "listr2";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
3
  import { deleteFilesTask } from "../../lib/index.js";
4
- const tasks = ({ componentName, filesFn, name }) => new Listr(
5
- [
6
- {
7
- title: `Destroying ${componentName} files...`,
8
- task: async () => {
9
- const f = await filesFn({ name, stories: true, tests: true });
10
- return deleteFilesTask(f);
4
+ function tasks({ componentName, filesFn, name }) {
5
+ return new Listr(
6
+ [
7
+ {
8
+ title: `Destroying ${componentName} files...`,
9
+ task: async () => {
10
+ const f = await filesFn({ name, stories: true, tests: true });
11
+ return deleteFilesTask(f);
12
+ }
11
13
  }
12
- }
13
- ],
14
- { rendererOptions: { collapseSubtasks: false }, exitOnError: true }
15
- );
14
+ ],
15
+ { rendererOptions: { collapseSubtasks: false }, exitOnError: true }
16
+ );
17
+ }
16
18
  function createHandler({
17
19
  componentName,
18
20
  preTasksFn = (options) => options,
@@ -20,11 +22,9 @@ function createHandler({
20
22
  }) {
21
23
  return {
22
24
  handler: async (options) => {
23
- recordTelemetryAttributes({
24
- command: `destroy ${componentName}`
25
- });
26
- options = await preTasksFn({ ...options, isDestroyer: true });
27
- await tasks({ componentName, filesFn, name: options.name }).run();
25
+ recordTelemetryAttributes({ command: `destroy ${componentName}` });
26
+ const { name } = await preTasksFn({ ...options, isDestroyer: true });
27
+ await tasks({ componentName, filesFn, name }).run();
28
28
  },
29
29
  tasks
30
30
  };
@@ -1,4 +1,6 @@
1
- const createYargsForComponentDestroy = ({ componentName }) => {
1
+ const createYargsForComponentDestroy = ({
2
+ componentName
3
+ }) => {
2
4
  return {
3
5
  command: `${componentName} <name>`,
4
6
  description: `Destroy a ${componentName} component`,
@@ -12,7 +14,11 @@ const createYargsForComponentDestroy = ({ componentName }) => {
12
14
  };
13
15
  function createHandler(componentName) {
14
16
  return async (argv) => {
15
- const importedHandler = await import(`./${componentName}/${componentName}Handler.js`);
17
+ const { existsSync } = await import("node:fs");
18
+ const tsPath = `./${componentName}/${componentName}Handler.ts`;
19
+ const jsPath = `./${componentName}/${componentName}Handler.js`;
20
+ const resolvedPath = existsSync(new URL(tsPath, import.meta.url)) ? tsPath : jsPath;
21
+ const importedHandler = await import(resolvedPath);
16
22
  const fn = importedHandler.default ?? importedHandler.handler ?? importedHandler;
17
23
  return typeof fn === "function" ? fn(argv) : fn;
18
24
  };
@@ -1,7 +1,6 @@
1
- import { files as layoutFiles } from "../../generate/layout/layoutHandler.js";
2
1
  import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
3
2
  const { command, description, builder } = createYargsForComponentDestroy(
4
- { componentName: "layout", filesFn: layoutFiles }
3
+ { componentName: "layout" }
5
4
  );
6
5
  const handler = createHandler("layout");
7
6
  export {
@@ -1,7 +1,7 @@
1
1
  import camelcase from "camelcase";
2
2
  import { Listr } from "listr2";
3
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
- import c from "../../../lib/colors.js";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
5
5
  import {
6
6
  deleteFilesTask,
7
7
  removeRoutesFromRouterTask
@@ -42,7 +42,7 @@ const handler = async ({ name, path }) => {
42
42
  try {
43
43
  await t.run();
44
44
  } catch (e) {
45
- console.log(c.error(e.message));
45
+ console.log(c.error(e instanceof Error ? e.message : String(e)));
46
46
  }
47
47
  };
48
48
  export {
@@ -1,8 +1,8 @@
1
1
  import { Listr } from "listr2";
2
2
  import pascalcase from "pascalcase";
3
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
- import { pluralize } from "../../../lib/cedarPluralize.js";
5
- import c from "../../../lib/colors.js";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
5
+ import { pluralize } from "@cedarjs/utils/cedarPluralize";
6
6
  import {
7
7
  deleteFilesTask,
8
8
  getPaths,
@@ -16,7 +16,11 @@ import {
16
16
  routes as scaffoldRoutes,
17
17
  splitPathAndModel
18
18
  } from "../../generate/scaffold/scaffoldHandler.js";
19
- const removeRoutesWithSet = async ({ model, path, nestScaffoldByModel }) => {
19
+ const removeRoutesWithSet = async ({
20
+ model,
21
+ path,
22
+ nestScaffoldByModel
23
+ }) => {
20
24
  const routes = await scaffoldRoutes({ model, path, nestScaffoldByModel });
21
25
  const routeNames = routes.map(extractRouteName);
22
26
  const pluralPascalName = pascalcase(pluralize(model));
@@ -29,18 +33,25 @@ const removeSetImport = () => {
29
33
  if (routesContent.match("<Set")) {
30
34
  return "Skipping removal of Set import in Routes.{jsx,tsx}";
31
35
  }
32
- const [redwoodRouterImport] = routesContent.match(
36
+ const cedarRouterImportMatch = routesContent.match(
33
37
  /import {[^]*} from '@cedarjs\/router'/
34
38
  );
35
- const removedSetImport = redwoodRouterImport.replace(/,*\s*Set,*/, "");
39
+ if (!cedarRouterImportMatch) {
40
+ return "No @cedarjs/router import found in Routes.{jsx,tsx}";
41
+ }
42
+ const [cedarRouterImport] = cedarRouterImportMatch;
43
+ const removedSetImport = cedarRouterImport.replace(/,*\s*Set,*/, "");
36
44
  const newRoutesContent = routesContent.replace(
37
- redwoodRouterImport,
45
+ cedarRouterImport,
38
46
  removedSetImport
39
47
  );
40
48
  writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
41
49
  return "Removed Set import in Routes.{jsx,tsx}";
42
50
  };
43
- const removeLayoutImport = ({ model: name, path: scaffoldPath = "" }) => {
51
+ const removeLayoutImport = ({
52
+ model: name,
53
+ path: scaffoldPath = ""
54
+ }) => {
44
55
  const pluralPascalName = pascalcase(pluralize(name));
45
56
  const pascalScaffoldPath = scaffoldPath === "" ? scaffoldPath : scaffoldPath.split("/").map(pascalcase).join("/") + "/";
46
57
  const layoutName = `${pluralPascalName}Layout`;
@@ -54,7 +65,12 @@ const removeLayoutImport = ({ model: name, path: scaffoldPath = "" }) => {
54
65
  writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
55
66
  return "Removed layout import from Routes.{jsx,tsx}";
56
67
  };
57
- const tasks = ({ model, path, tests, nestScaffoldByModel }) => new Listr(
68
+ const tasks = ({
69
+ model,
70
+ path,
71
+ tests,
72
+ nestScaffoldByModel
73
+ }) => new Listr(
58
74
  [
59
75
  {
60
76
  title: "Destroying scaffold files...",
@@ -92,12 +108,15 @@ const handler = async ({ model: modelArg }) => {
92
108
  const { name } = await verifyModelName({ name: model, isDestroyer: true });
93
109
  await tasks({ model: name, path }).run();
94
110
  } catch (e) {
95
- console.log(c.error(e.message));
111
+ console.log(c.error(e instanceof Error ? e.message : String(e)));
96
112
  }
97
113
  };
98
114
  const extractRouteName = (route) => {
99
- const { groups } = route.match(/.*name="?(?<routeName>\w+)"?/);
100
- return groups.routeName;
115
+ const match = route.match(/.*name="?(?<routeName>\w+)"?/);
116
+ if (!match?.groups?.routeName) {
117
+ throw new Error(`Could not extract route name from route: ${route}`);
118
+ }
119
+ return match.groups.routeName;
101
120
  };
102
121
  export {
103
122
  handler,
@@ -1,6 +1,6 @@
1
1
  import { Listr } from "listr2";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
3
- import c from "../../../lib/colors.js";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
4
  import { deleteFilesTask } from "../../../lib/index.js";
5
5
  import { verifyModelName } from "../../../lib/schemaHelpers.js";
6
6
  import { files } from "../../generate/sdl/sdlHandler.js";
@@ -24,7 +24,7 @@ const handler = async ({ model }) => {
24
24
  const { name } = await verifyModelName({ name: model, isDestroyer: true });
25
25
  await tasks({ model: name }).run();
26
26
  } catch (e) {
27
- console.log(c.error(e.message));
27
+ console.log(c.error(e instanceof Error ? e.message : String(e)));
28
28
  }
29
29
  };
30
30
  export {
@@ -1,17 +1,18 @@
1
1
  import { argv } from "node:process";
2
2
  import { getConfig } from "@cedarjs/project-config";
3
- const defaultApiDebugPort = 18911;
4
- function getApiDebugFlag(apiDebugPort) {
3
+ function getApiDebugFlag(apiDebugPort, apiAvailablePort) {
5
4
  if (apiDebugPort) {
6
5
  return `--debug-port ${apiDebugPort}`;
7
6
  } else if (argv.includes("--apiDebugPort")) {
8
- return `--debug-port ${defaultApiDebugPort}`;
7
+ return `--debug-port ${"1" + apiAvailablePort}`;
9
8
  }
10
9
  const apiDebugPortInConfig = getConfig().api.debugPort;
11
10
  if (apiDebugPortInConfig) {
12
11
  return `--debug-port ${apiDebugPortInConfig}`;
12
+ } else if (apiDebugPortInConfig === false) {
13
+ return "";
13
14
  }
14
- return "";
15
+ return `--debug-port ${"1" + apiAvailablePort}`;
15
16
  }
16
17
  export {
17
18
  getApiDebugFlag