@cedarjs/cli 0.0.4

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 (360) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +706 -0
  3. package/dist/commands/build.js +54 -0
  4. package/dist/commands/buildHandler.js +134 -0
  5. package/dist/commands/check.js +28 -0
  6. package/dist/commands/console.js +13 -0
  7. package/dist/commands/consoleHandler.js +68 -0
  8. package/dist/commands/deploy/baremetal/SshExecutor.js +41 -0
  9. package/dist/commands/deploy/baremetal/baremetalHandler.js +558 -0
  10. package/dist/commands/deploy/baremetal.js +89 -0
  11. package/dist/commands/deploy/flightcontrol.js +40 -0
  12. package/dist/commands/deploy/flightcontrolHandler.js +58 -0
  13. package/dist/commands/deploy/helpers/deployBuilder.js +25 -0
  14. package/dist/commands/deploy/helpers/deployHandler.js +31 -0
  15. package/dist/commands/deploy/netlify.js +21 -0
  16. package/dist/commands/deploy/packing/nft.js +61 -0
  17. package/dist/commands/deploy/render.js +37 -0
  18. package/dist/commands/deploy/renderHandler.js +70 -0
  19. package/dist/commands/deploy/serverless.js +51 -0
  20. package/dist/commands/deploy/serverlessHandler.js +211 -0
  21. package/dist/commands/deploy/vercel.js +21 -0
  22. package/dist/commands/deploy.js +21 -0
  23. package/dist/commands/destroy/cell/cell.js +12 -0
  24. package/dist/commands/destroy/cell/cellHandler.js +10 -0
  25. package/dist/commands/destroy/component/component.js +15 -0
  26. package/dist/commands/destroy/component/componentHandler.js +10 -0
  27. package/dist/commands/destroy/directive/directive.js +14 -0
  28. package/dist/commands/destroy/directive/directiveHandler.js +12 -0
  29. package/dist/commands/destroy/function/function.js +20 -0
  30. package/dist/commands/destroy/function/functionHandler.js +10 -0
  31. package/dist/commands/destroy/handlerHelpers.js +34 -0
  32. package/dist/commands/destroy/helpers.js +22 -0
  33. package/dist/commands/destroy/layout/layout.js +12 -0
  34. package/dist/commands/destroy/layout/layoutHandler.js +10 -0
  35. package/dist/commands/destroy/page/page.js +20 -0
  36. package/dist/commands/destroy/page/pageHandler.js +51 -0
  37. package/dist/commands/destroy/scaffold/scaffold.js +16 -0
  38. package/dist/commands/destroy/scaffold/scaffoldHandler.js +105 -0
  39. package/dist/commands/destroy/sdl/sdl.js +16 -0
  40. package/dist/commands/destroy/sdl/sdlHandler.js +33 -0
  41. package/dist/commands/destroy/service/service.js +10 -0
  42. package/dist/commands/destroy/service/serviceHandler.js +17 -0
  43. package/dist/commands/destroy.js +25 -0
  44. package/dist/commands/dev.js +47 -0
  45. package/dist/commands/devHandler.js +202 -0
  46. package/dist/commands/exec.js +38 -0
  47. package/dist/commands/execHandler.js +180 -0
  48. package/dist/commands/experimental/setupInngest.js +28 -0
  49. package/dist/commands/experimental/setupInngestHandler.js +46 -0
  50. package/dist/commands/experimental/setupOpentelemetry.js +34 -0
  51. package/dist/commands/experimental/setupOpentelemetryHandler.js +215 -0
  52. package/dist/commands/experimental/setupReactCompiler.js +28 -0
  53. package/dist/commands/experimental/setupReactCompilerHandler.js +124 -0
  54. package/dist/commands/experimental/setupRsc.js +28 -0
  55. package/dist/commands/experimental/setupRscHandler.js +408 -0
  56. package/dist/commands/experimental/setupStreamingSsr.js +28 -0
  57. package/dist/commands/experimental/setupStreamingSsrHandler.js +208 -0
  58. package/dist/commands/experimental/templates/opentelemetry.ts.template +55 -0
  59. package/dist/commands/experimental/templates/rsc/AboutCounter.tsx.template +20 -0
  60. package/dist/commands/experimental/templates/rsc/AboutPage.css.template +2 -0
  61. package/dist/commands/experimental/templates/rsc/AboutPage.tsx.template +17 -0
  62. package/dist/commands/experimental/templates/rsc/Counter.css.template +7 -0
  63. package/dist/commands/experimental/templates/rsc/Counter.module.css.template +3 -0
  64. package/dist/commands/experimental/templates/rsc/Counter.tsx.template +18 -0
  65. package/dist/commands/experimental/templates/rsc/Document.tsx.template +27 -0
  66. package/dist/commands/experimental/templates/rsc/HomePage.css.template +2 -0
  67. package/dist/commands/experimental/templates/rsc/HomePage.module.css.template +3 -0
  68. package/dist/commands/experimental/templates/rsc/HomePage.tsx.template +19 -0
  69. package/dist/commands/experimental/templates/rsc/NavigationLayout.css.template +32 -0
  70. package/dist/commands/experimental/templates/rsc/NavigationLayout.tsx.template +31 -0
  71. package/dist/commands/experimental/templates/rsc/Routes.tsx.template +29 -0
  72. package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +35 -0
  73. package/dist/commands/experimental/templates/rsc/entry.server.tsx.template +20 -0
  74. package/dist/commands/experimental/templates/rsc/index.css.template +4 -0
  75. package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +27 -0
  76. package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +40 -0
  77. package/dist/commands/experimental/templates/streamingSsr/entry.server.tsx.template +20 -0
  78. package/dist/commands/experimental/templates/streamingSsr/tsconfig.json.template +54 -0
  79. package/dist/commands/experimental/util.js +69 -0
  80. package/dist/commands/experimental.js +22 -0
  81. package/dist/commands/generate/cell/cell.js +35 -0
  82. package/dist/commands/generate/cell/cellHandler.js +153 -0
  83. package/dist/commands/generate/cell/templates/cell.tsx.template +34 -0
  84. package/dist/commands/generate/cell/templates/cellList.tsx.template +40 -0
  85. package/dist/commands/generate/cell/templates/mock.ts.template +7 -0
  86. package/dist/commands/generate/cell/templates/mockList.ts.template +14 -0
  87. package/dist/commands/generate/cell/templates/stories.tsx.template +35 -0
  88. package/dist/commands/generate/cell/templates/test.js.template +42 -0
  89. package/dist/commands/generate/cell/utils/utils.js +43 -0
  90. package/dist/commands/generate/component/component.js +15 -0
  91. package/dist/commands/generate/component/componentHandler.js +55 -0
  92. package/dist/commands/generate/component/templates/component.tsx.template +10 -0
  93. package/dist/commands/generate/component/templates/stories.jsx.template +17 -0
  94. package/dist/commands/generate/component/templates/stories.tsx.template +26 -0
  95. package/dist/commands/generate/component/templates/test.tsx.template +14 -0
  96. package/dist/commands/generate/dataMigration/dataMigration.js +105 -0
  97. package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +7 -0
  98. package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +5 -0
  99. package/dist/commands/generate/dbAuth/dbAuth.js +55 -0
  100. package/dist/commands/generate/dbAuth/dbAuthHandler.js +375 -0
  101. package/dist/commands/generate/dbAuth/templates/forgotPassword.tsx.template +94 -0
  102. package/dist/commands/generate/dbAuth/templates/login.tsx.template +130 -0
  103. package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +264 -0
  104. package/dist/commands/generate/dbAuth/templates/resetPassword.tsx.template +121 -0
  105. package/dist/commands/generate/dbAuth/templates/signup.tsx.template +123 -0
  106. package/dist/commands/generate/directive/directive.js +15 -0
  107. package/dist/commands/generate/directive/directiveHandler.js +159 -0
  108. package/dist/commands/generate/directive/templates/transformer.directive.test.ts.template +18 -0
  109. package/dist/commands/generate/directive/templates/transformer.directive.ts.template +38 -0
  110. package/dist/commands/generate/directive/templates/validator.directive.test.ts.template +17 -0
  111. package/dist/commands/generate/directive/templates/validator.directive.ts.template +39 -0
  112. package/dist/commands/generate/function/function.js +29 -0
  113. package/dist/commands/generate/function/functionHandler.js +131 -0
  114. package/dist/commands/generate/function/templates/function.ts.template +33 -0
  115. package/dist/commands/generate/function/templates/scenarios.ts.template +8 -0
  116. package/dist/commands/generate/function/templates/test.ts.template +30 -0
  117. package/dist/commands/generate/helpers.js +71 -0
  118. package/dist/commands/generate/job/job.js +39 -0
  119. package/dist/commands/generate/job/jobHandler.js +138 -0
  120. package/dist/commands/generate/job/templates/job.ts.template +8 -0
  121. package/dist/commands/generate/job/templates/scenarios.ts.template +8 -0
  122. package/dist/commands/generate/job/templates/test.ts.template +7 -0
  123. package/dist/commands/generate/layout/layout.js +25 -0
  124. package/dist/commands/generate/layout/layoutHandler.js +59 -0
  125. package/dist/commands/generate/layout/templates/layout.tsx.a11y.template +27 -0
  126. package/dist/commands/generate/layout/templates/layout.tsx.template +9 -0
  127. package/dist/commands/generate/layout/templates/stories.tsx.template +13 -0
  128. package/dist/commands/generate/layout/templates/test.tsx.template +14 -0
  129. package/dist/commands/generate/model/model.js +29 -0
  130. package/dist/commands/generate/model/modelHandler.js +63 -0
  131. package/dist/commands/generate/model/templates/model.js.template +3 -0
  132. package/dist/commands/generate/ogImage/ogImage.js +43 -0
  133. package/dist/commands/generate/ogImage/ogImageHandler.js +111 -0
  134. package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +13 -0
  135. package/dist/commands/generate/page/page.js +22 -0
  136. package/dist/commands/generate/page/pageHandler.js +227 -0
  137. package/dist/commands/generate/page/templates/page.tsx.template +35 -0
  138. package/dist/commands/generate/page/templates/stories.tsx.parameters.template +13 -0
  139. package/dist/commands/generate/page/templates/stories.tsx.template +13 -0
  140. package/dist/commands/generate/page/templates/test.tsx.template +14 -0
  141. package/dist/commands/generate/realtime/realtime.js +41 -0
  142. package/dist/commands/generate/realtime/realtimeHandler.js +215 -0
  143. package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.sdl.ts.template +27 -0
  144. package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +73 -0
  145. package/dist/commands/generate/realtime/templates/realtime.ts.template +42 -0
  146. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.sdl.ts.template +20 -0
  147. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +19 -0
  148. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +58 -0
  149. package/dist/commands/generate/scaffold/scaffold.js +38 -0
  150. package/dist/commands/generate/scaffold/scaffoldHandler.js +663 -0
  151. package/dist/commands/generate/scaffold/templates/assets/scaffold.css.template +398 -0
  152. package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +243 -0
  153. package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +74 -0
  154. package/dist/commands/generate/scaffold/templates/components/Name.tsx.template +79 -0
  155. package/dist/commands/generate/scaffold/templates/components/NameCell.tsx.template +32 -0
  156. package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +123 -0
  157. package/dist/commands/generate/scaffold/templates/components/Names.tsx.template +88 -0
  158. package/dist/commands/generate/scaffold/templates/components/NamesCell.tsx.template +45 -0
  159. package/dist/commands/generate/scaffold/templates/components/NewName.tsx.template +55 -0
  160. package/dist/commands/generate/scaffold/templates/layouts/ScaffoldLayout.tsx.template +37 -0
  161. package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +192 -0
  162. package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +58 -0
  163. package/dist/commands/generate/scaffold/templates/pages/EditNamePage.tsx.template +11 -0
  164. package/dist/commands/generate/scaffold/templates/pages/NamePage.tsx.template +11 -0
  165. package/dist/commands/generate/scaffold/templates/pages/NamesPage.tsx.template +7 -0
  166. package/dist/commands/generate/scaffold/templates/pages/NewNamePage.tsx.template +7 -0
  167. package/dist/commands/generate/script/script.js +29 -0
  168. package/dist/commands/generate/script/scriptHandler.js +85 -0
  169. package/dist/commands/generate/script/templates/script.ts.template +15 -0
  170. package/dist/commands/generate/script/templates/tsconfig.json.template +33 -0
  171. package/dist/commands/generate/sdl/sdl.js +48 -0
  172. package/dist/commands/generate/sdl/sdlHandler.js +282 -0
  173. package/dist/commands/generate/sdl/templates/sdl.js.template +70 -0
  174. package/dist/commands/generate/sdl/templates/sdl.ts.template +70 -0
  175. package/dist/commands/generate/secret/secret.js +52 -0
  176. package/dist/commands/generate/service/service.js +50 -0
  177. package/dist/commands/generate/service/serviceHandler.js +301 -0
  178. package/dist/commands/generate/service/templates/scenarios.ts.template +7 -0
  179. package/dist/commands/generate/service/templates/service.ts.template +38 -0
  180. package/dist/commands/generate/service/templates/test.ts.template +84 -0
  181. package/dist/commands/generate/yargsCommandHelpers.js +77 -0
  182. package/dist/commands/generate/yargsHandlerHelpers.js +155 -0
  183. package/dist/commands/generate.js +44 -0
  184. package/dist/commands/info.js +36 -0
  185. package/dist/commands/jobs.js +17 -0
  186. package/dist/commands/jobsHandler.js +30 -0
  187. package/dist/commands/lint.js +57 -0
  188. package/dist/commands/prerender.js +34 -0
  189. package/dist/commands/prerenderHandler.js +282 -0
  190. package/dist/commands/prisma.js +17 -0
  191. package/dist/commands/prismaHandler.js +90 -0
  192. package/dist/commands/record/init.js +11 -0
  193. package/dist/commands/record.js +19 -0
  194. package/dist/commands/serve.js +139 -0
  195. package/dist/commands/serveApiHandler.js +15 -0
  196. package/dist/commands/serveBothHandler.js +95 -0
  197. package/dist/commands/serveWebHandler.js +17 -0
  198. package/dist/commands/setup/auth/auth.js +265 -0
  199. package/dist/commands/setup/cache/cache.js +37 -0
  200. package/dist/commands/setup/cache/cacheHandler.js +69 -0
  201. package/dist/commands/setup/cache/templates/memcached.ts.template +30 -0
  202. package/dist/commands/setup/cache/templates/redis.ts.template +24 -0
  203. package/dist/commands/setup/deploy/deploy.js +26 -0
  204. package/dist/commands/setup/deploy/helpers/helpers.js +9 -0
  205. package/dist/commands/setup/deploy/helpers/index.js +110 -0
  206. package/dist/commands/setup/deploy/providers/baremetal.js +9 -0
  207. package/dist/commands/setup/deploy/providers/baremetalHandler.js +64 -0
  208. package/dist/commands/setup/deploy/providers/coherence.js +24 -0
  209. package/dist/commands/setup/deploy/providers/coherenceHandler.js +203 -0
  210. package/dist/commands/setup/deploy/providers/flightcontrol.js +19 -0
  211. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +294 -0
  212. package/dist/commands/setup/deploy/providers/netlify.js +9 -0
  213. package/dist/commands/setup/deploy/providers/netlifyHandler.js +42 -0
  214. package/dist/commands/setup/deploy/providers/render.js +17 -0
  215. package/dist/commands/setup/deploy/providers/renderHandler.js +111 -0
  216. package/dist/commands/setup/deploy/providers/serverless.js +11 -0
  217. package/dist/commands/setup/deploy/providers/serverlessHandler.js +141 -0
  218. package/dist/commands/setup/deploy/providers/vercel.js +9 -0
  219. package/dist/commands/setup/deploy/providers/vercelHandler.js +56 -0
  220. package/dist/commands/setup/deploy/templates/baremetal.js +128 -0
  221. package/dist/commands/setup/deploy/templates/flightcontrol.js +85 -0
  222. package/dist/commands/setup/deploy/templates/netlify.js +32 -0
  223. package/dist/commands/setup/deploy/templates/render.js +72 -0
  224. package/dist/commands/setup/deploy/templates/serverless/api.js +78 -0
  225. package/dist/commands/setup/deploy/templates/serverless/web.js +32 -0
  226. package/dist/commands/setup/docker/docker.js +26 -0
  227. package/dist/commands/setup/docker/dockerHandler.js +265 -0
  228. package/dist/commands/setup/docker/templates/Dockerfile +154 -0
  229. package/dist/commands/setup/docker/templates/docker-compose.dev.yml +58 -0
  230. package/dist/commands/setup/docker/templates/docker-compose.prod.yml +63 -0
  231. package/dist/commands/setup/docker/templates/dockerignore +18 -0
  232. package/dist/commands/setup/generator/generator.js +49 -0
  233. package/dist/commands/setup/generator/generatorHandler.js +55 -0
  234. package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +117 -0
  235. package/dist/commands/setup/graphql/features/fragments/appImportTransform.js +20 -0
  236. package/dist/commands/setup/graphql/features/fragments/fragments.js +25 -0
  237. package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +89 -0
  238. package/dist/commands/setup/graphql/features/trustedDocuments/graphqlTransform.js +51 -0
  239. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +25 -0
  240. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +74 -0
  241. package/dist/commands/setup/graphql/graphql.js +18 -0
  242. package/dist/commands/setup/i18n/i18n.js +25 -0
  243. package/dist/commands/setup/i18n/i18nHandler.js +169 -0
  244. package/dist/commands/setup/i18n/templates/en.json.template +11 -0
  245. package/dist/commands/setup/i18n/templates/fr.json.template +11 -0
  246. package/dist/commands/setup/i18n/templates/i18n.js.template +52 -0
  247. package/dist/commands/setup/i18n/templates/storybook.preview.tsx.template +43 -0
  248. package/dist/commands/setup/jobs/jobs.js +31 -0
  249. package/dist/commands/setup/jobs/jobsHandler.js +122 -0
  250. package/dist/commands/setup/jobs/templates/jobs.ts.template +32 -0
  251. package/dist/commands/setup/mailer/mailer.js +30 -0
  252. package/dist/commands/setup/mailer/mailerHandler.js +106 -0
  253. package/dist/commands/setup/mailer/templates/mailer.ts.template +30 -0
  254. package/dist/commands/setup/mailer/templates/re-example.tsx.template +40 -0
  255. package/dist/commands/setup/middleware/middleware.js +17 -0
  256. package/dist/commands/setup/middleware/ogImage/__codemod_tests__/middleware.js +15 -0
  257. package/dist/commands/setup/middleware/ogImage/__codemod_tests__/vitePlugin.js +6 -0
  258. package/dist/commands/setup/middleware/ogImage/codemodMiddleware.js +97 -0
  259. package/dist/commands/setup/middleware/ogImage/codemodVitePlugin.js +65 -0
  260. package/dist/commands/setup/middleware/ogImage/ogImage.js +27 -0
  261. package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +121 -0
  262. package/dist/commands/setup/monitoring/monitoring.js +17 -0
  263. package/dist/commands/setup/monitoring/sentry/sentry.js +25 -0
  264. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +163 -0
  265. package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +15 -0
  266. package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +31 -0
  267. package/dist/commands/setup/package/package.js +33 -0
  268. package/dist/commands/setup/package/packageHandler.js +134 -0
  269. package/dist/commands/setup/realtime/realtime.js +37 -0
  270. package/dist/commands/setup/realtime/realtimeHandler.js +309 -0
  271. package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.sdl.template +14 -0
  272. package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +14 -0
  273. package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.sdl.ts.template +27 -0
  274. package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +73 -0
  275. package/dist/commands/setup/realtime/templates/realtime.ts.template +46 -0
  276. package/dist/commands/setup/realtime/templates/stream/alphabet/alphabet.sdl.template +9 -0
  277. package/dist/commands/setup/realtime/templates/stream/alphabet/alphabet.ts.template +31 -0
  278. package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +58 -0
  279. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +57 -0
  280. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/rooms.sdl.ts.template +20 -0
  281. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/rooms.ts.template +20 -0
  282. package/dist/commands/setup/server-file/serverFile.js +31 -0
  283. package/dist/commands/setup/server-file/serverFileHandler.js +56 -0
  284. package/dist/commands/setup/server-file/templates/server.ts.template +13 -0
  285. package/dist/commands/setup/tsconfig/tsconfig.js +25 -0
  286. package/dist/commands/setup/tsconfig/tsconfigHandler.js +59 -0
  287. package/dist/commands/setup/ui/helpers/helpers.js +9 -0
  288. package/dist/commands/setup/ui/libraries/chakra-ui.js +24 -0
  289. package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +98 -0
  290. package/dist/commands/setup/ui/libraries/mantine.js +32 -0
  291. package/dist/commands/setup/ui/libraries/mantineHandler.js +138 -0
  292. package/dist/commands/setup/ui/libraries/tailwindcss.js +26 -0
  293. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +386 -0
  294. package/dist/commands/setup/ui/templates/chakra.storybook.preview.tsx.template +20 -0
  295. package/dist/commands/setup/ui/templates/mantine-postcss.config.js.template +35 -0
  296. package/dist/commands/setup/ui/templates/mantine.storybook.preview.tsx.template +18 -0
  297. package/dist/commands/setup/ui/templates/postcss.config.js.template +9 -0
  298. package/dist/commands/setup/ui/ui.js +17 -0
  299. package/dist/commands/setup/uploads/dbCodemod.js +28 -0
  300. package/dist/commands/setup/uploads/templates/signedUrl.ts.template +21 -0
  301. package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +25 -0
  302. package/dist/commands/setup/uploads/uploads.js +26 -0
  303. package/dist/commands/setup/uploads/uploadsHandler.js +147 -0
  304. package/dist/commands/setup/vite/templates/vite.config.ts.template +19 -0
  305. package/dist/commands/setup/vite/vite.js +38 -0
  306. package/dist/commands/setup/vite/viteHandler.js +83 -0
  307. package/dist/commands/setup.js +33 -0
  308. package/dist/commands/studio.js +23 -0
  309. package/dist/commands/studioHandler.js +61 -0
  310. package/dist/commands/test.js +44 -0
  311. package/dist/commands/testHandler.js +138 -0
  312. package/dist/commands/ts-to-js.js +20 -0
  313. package/dist/commands/type-check.js +41 -0
  314. package/dist/commands/type-checkHandler.js +71 -0
  315. package/dist/commands/upgrade.js +441 -0
  316. package/dist/index.d.js +0 -0
  317. package/dist/index.js +146 -0
  318. package/dist/lib/background.js +45 -0
  319. package/dist/lib/colors.js +18 -0
  320. package/dist/lib/configureStorybook.js +50 -0
  321. package/dist/lib/exec.js +85 -0
  322. package/dist/lib/exit.js +44 -0
  323. package/dist/lib/extendFile.js +114 -0
  324. package/dist/lib/generatePrismaClient.js +60 -0
  325. package/dist/lib/index.js +485 -0
  326. package/dist/lib/loadEnvFiles.js +12 -0
  327. package/dist/lib/locking.js +60 -0
  328. package/dist/lib/merge/algorithms.js +30 -0
  329. package/dist/lib/merge/index.js +163 -0
  330. package/dist/lib/merge/semanticIdentity.js +18 -0
  331. package/dist/lib/merge/strategy.js +136 -0
  332. package/dist/lib/mockTelemetry.js +7 -0
  333. package/dist/lib/packages.js +77 -0
  334. package/dist/lib/plugin.js +206 -0
  335. package/dist/lib/pluralHelpers.js +50 -0
  336. package/dist/lib/ports.js +17 -0
  337. package/dist/lib/project.js +30 -0
  338. package/dist/lib/rollback.js +72 -0
  339. package/dist/lib/runTransform.js +66 -0
  340. package/dist/lib/rwPluralize.js +56 -0
  341. package/dist/lib/schemaHelpers.js +95 -0
  342. package/dist/lib/templates/storybook.preview.tsx.template +19 -0
  343. package/dist/lib/test.js +106 -0
  344. package/dist/lib/updateCheck.js +202 -0
  345. package/dist/lib/updateCheckExecute.js +2 -0
  346. package/dist/middleware/checkNodeVersion.js +23 -0
  347. package/dist/middleware/detectProjectRxVersion.js +12 -0
  348. package/dist/plugin.js +223 -0
  349. package/dist/rwfw.js +47 -0
  350. package/dist/telemetry/exporter.js +63 -0
  351. package/dist/telemetry/index.js +84 -0
  352. package/dist/telemetry/resource.js +98 -0
  353. package/dist/telemetry/send.js +80 -0
  354. package/dist/testLib/cells.js +188 -0
  355. package/dist/testLib/fetchFileFromTemplate.js +9 -0
  356. package/dist/testLib/getFilesWithPattern.js +21 -0
  357. package/dist/testLib/getRootPackageJSON.js +14 -0
  358. package/dist/testLib/isTSProject.js +9 -0
  359. package/dist/testLib/runTransform.js +42 -0
  360. package/package.json +102 -0
@@ -0,0 +1,294 @@
1
+ import { EOL } from "os";
2
+ import path from "path";
3
+ import prismaInternals from "@prisma/internals";
4
+ import fs from "fs-extra";
5
+ import { Listr } from "listr2";
6
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
7
+ import { errorTelemetry } from "@cedarjs/telemetry";
8
+ import c from "../../../../lib/colors.js";
9
+ import {
10
+ getPaths,
11
+ writeFilesTask,
12
+ printSetupNotes
13
+ } from "../../../../lib/index.js";
14
+ import { updateApiURLTask } from "../helpers/index.js";
15
+ import {
16
+ flightcontrolConfig,
17
+ databaseEnvVariables,
18
+ postgresDatabaseService,
19
+ mysqlDatabaseService
20
+ } from "../templates/flightcontrol.js";
21
+ const { getSchema, getConfig } = prismaInternals;
22
+ const getFlightcontrolJson = async (database) => {
23
+ if (database === "none") {
24
+ return {
25
+ path: path.join(getPaths().base, "flightcontrol.json"),
26
+ content: flightcontrolConfig
27
+ };
28
+ }
29
+ if (!fs.existsSync(path.join(getPaths().base, "api/db/schema.prisma"))) {
30
+ throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
31
+ }
32
+ const schema = await getSchema(
33
+ path.join(getPaths().base, "api/db/schema.prisma")
34
+ );
35
+ const config = await getConfig({ datamodel: schema });
36
+ const detectedDatabase = config.datasources[0].activeProvider;
37
+ if (detectedDatabase === database) {
38
+ let dbService;
39
+ switch (database) {
40
+ case "postgresql":
41
+ dbService = postgresDatabaseService;
42
+ break;
43
+ case "mysql":
44
+ dbService = mysqlDatabaseService;
45
+ break;
46
+ default:
47
+ throw new Error(`
48
+ Unexpected datasource provider found: ${database}`);
49
+ }
50
+ return {
51
+ path: path.join(getPaths().base, "flightcontrol.json"),
52
+ content: {
53
+ ...flightcontrolConfig,
54
+ environments: [
55
+ {
56
+ ...flightcontrolConfig.environments[0],
57
+ services: [
58
+ ...flightcontrolConfig.environments[0].services.map((service) => {
59
+ if (service.id === "redwood-api") {
60
+ return {
61
+ ...service,
62
+ envVariables: {
63
+ ...service.envVariables,
64
+ ...databaseEnvVariables
65
+ }
66
+ };
67
+ }
68
+ return service;
69
+ }),
70
+ dbService
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ };
76
+ } else {
77
+ throw new Error(`
78
+ Prisma datasource provider is detected to be ${detectedDatabase}.
79
+
80
+ Update your schema.prisma provider to be postgresql or mysql, then run
81
+ yarn rw prisma migrate dev
82
+ yarn rw setup deploy flightcontrol
83
+ `);
84
+ }
85
+ };
86
+ const updateGraphQLFunction = () => {
87
+ return {
88
+ title: "Adding CORS config to createGraphQLHandler...",
89
+ task: (_ctx) => {
90
+ const graphqlTsPath = path.join(
91
+ getPaths().base,
92
+ "api/src/functions/graphql.ts"
93
+ );
94
+ const graphqlJsPath = path.join(
95
+ getPaths().base,
96
+ "api/src/functions/graphql.js"
97
+ );
98
+ let graphqlFunctionsPath;
99
+ if (fs.existsSync(graphqlTsPath)) {
100
+ graphqlFunctionsPath = graphqlTsPath;
101
+ } else if (fs.existsSync(graphqlJsPath)) {
102
+ graphqlFunctionsPath = graphqlJsPath;
103
+ } else {
104
+ console.log(`
105
+ Couldn't find graphql handler in api/src/functions/graphql.js.
106
+ You'll have to add the following cors config manually:
107
+
108
+ cors: { origin: process.env.REDWOOD_WEB_URL, credentials: true}
109
+ `);
110
+ return;
111
+ }
112
+ const graphqlContent = fs.readFileSync(graphqlFunctionsPath, "utf8").split(EOL);
113
+ const graphqlHanderIndex = graphqlContent.findIndex(
114
+ (line) => line.includes("createGraphQLHandler({")
115
+ );
116
+ if (graphqlHanderIndex === -1) {
117
+ console.log(`
118
+ Couldn't find graphql handler in api/src/functions/graphql.js.
119
+ You'll have to add the following cors config manually:
120
+
121
+ cors: { origin: process.env.REDWOOD_WEB_URL, credentials: true}
122
+ `);
123
+ return;
124
+ }
125
+ graphqlContent.splice(
126
+ graphqlHanderIndex + 1,
127
+ 0,
128
+ " cors: { origin: process.env.REDWOOD_WEB_URL, credentials: true },"
129
+ );
130
+ fs.writeFileSync(graphqlFunctionsPath, graphqlContent.join(EOL));
131
+ }
132
+ };
133
+ };
134
+ const updateDbAuth = () => {
135
+ return {
136
+ title: "Updating dbAuth cookie config (if used)...",
137
+ task: (_ctx) => {
138
+ const authTsPath = path.join(getPaths().base, "api/src/functions/auth.ts");
139
+ const authJsPath = path.join(getPaths().base, "api/src/functions/auth.js");
140
+ let authFnPath;
141
+ if (fs.existsSync(authTsPath)) {
142
+ authFnPath = authTsPath;
143
+ } else if (fs.existsSync(authJsPath)) {
144
+ authFnPath = authJsPath;
145
+ } else {
146
+ console.log(`Skipping, did not detect api/src/functions/auth.js`);
147
+ return;
148
+ }
149
+ const authContent = fs.readFileSync(authFnPath, "utf8").split(EOL);
150
+ const sameSiteLineIndex = authContent.findIndex(
151
+ (line) => line.match(/SameSite:.*,/)
152
+ );
153
+ if (sameSiteLineIndex === -1) {
154
+ console.log(`
155
+ Couldn't find cookie SameSite config in api/src/functions/auth.js.
156
+
157
+ You need to ensure SameSite is set to "None"
158
+ `);
159
+ return;
160
+ }
161
+ authContent[sameSiteLineIndex] = ` SameSite: process.env.NODE_ENV === 'development' ? 'Strict' : 'None',`;
162
+ const dbHandlerIndex = authContent.findIndex(
163
+ (line) => line.includes("new DbAuthHandler(")
164
+ );
165
+ if (dbHandlerIndex === -1) {
166
+ console.log(`
167
+ Couldn't find DbAuthHandler in api/src/functions/auth.js.
168
+ You'll have to add the following cors config manually:
169
+
170
+ cors: { origin: process.env.REDWOOD_WEB_URL, credentials: true}
171
+ `);
172
+ return;
173
+ }
174
+ authContent.splice(
175
+ dbHandlerIndex + 1,
176
+ 0,
177
+ " cors: { origin: process.env.REDWOOD_WEB_URL, credentials: true },"
178
+ );
179
+ fs.writeFileSync(authFnPath, authContent.join(EOL));
180
+ }
181
+ };
182
+ };
183
+ const updateApp = () => {
184
+ return {
185
+ title: "Updating App.jsx fetch config...",
186
+ task: (_ctx) => {
187
+ const appTsPath = path.join(getPaths().base, "web/src/App.tsx");
188
+ const appJsPath = path.join(getPaths().base, "web/src/App.jsx");
189
+ let appPath;
190
+ if (fs.existsSync(appTsPath)) {
191
+ appPath = appTsPath;
192
+ } else if (fs.existsSync(appJsPath)) {
193
+ appPath = appJsPath;
194
+ } else {
195
+ console.log(`Skipping, did not detect web/src/App.jsx|tsx`);
196
+ return;
197
+ }
198
+ const appContent = fs.readFileSync(appPath, "utf8").split(EOL);
199
+ const authLineIndex = appContent.findIndex(
200
+ (line) => line.includes("<AuthProvider")
201
+ );
202
+ if (authLineIndex === -1) {
203
+ console.log(`
204
+ Couldn't find <AuthProvider /> in web/src/App.js
205
+ If (and when) you use *dbAuth*, you'll have to add the following fetch config to <AuthProvider />:
206
+
207
+ config={{ fetchConfig: { credentials: 'include' } }}
208
+ `);
209
+ } else if (appContent.toString().match(/dbAuth/)) {
210
+ appContent[authLineIndex] = ` <AuthProvider type="dbAuth" config={{ fetchConfig: { credentials: 'include' } }}>
211
+ `;
212
+ }
213
+ const gqlLineIndex = appContent.findIndex(
214
+ (line) => line.includes("<RedwoodApolloProvider")
215
+ );
216
+ if (gqlLineIndex === -1) {
217
+ console.log(`
218
+ Couldn't find <RedwoodApolloProvider in web/src/App.js
219
+ If (and when) you use *dbAuth*, you'll have to add the following fetch config manually:
220
+
221
+ graphQLClientConfig={{ httpLinkConfig: { credentials: 'include' }}}
222
+ `);
223
+ } else if (appContent.toString().match(/dbAuth/)) {
224
+ appContent[gqlLineIndex] = ` <RedwoodApolloProvider graphQLClientConfig={{ httpLinkConfig: { credentials: 'include' }}} >
225
+ `;
226
+ }
227
+ fs.writeFileSync(appPath, appContent.join(EOL));
228
+ }
229
+ };
230
+ };
231
+ const addToDotEnvDefaultTask = () => {
232
+ return {
233
+ title: "Updating .env.defaults...",
234
+ skip: () => {
235
+ if (!fs.existsSync(path.resolve(getPaths().base, ".env.defaults"))) {
236
+ return `
237
+ WARNING: could not update .env.defaults
238
+
239
+ You'll have to add the following env var manually:
240
+
241
+ REDWOOD_API_URL=/.redwood/functions
242
+ `;
243
+ }
244
+ },
245
+ task: async (_ctx) => {
246
+ const env = path.resolve(getPaths().base, ".env.defaults");
247
+ const line = "\n\nREDWOOD_API_URL=/.redwood/functions\n";
248
+ fs.appendFileSync(env, line);
249
+ }
250
+ };
251
+ };
252
+ const notes = [
253
+ "You are ready to deploy to Flightcontrol!\n",
254
+ "\u{1F449} Create your project at https://app.flightcontrol.dev/signup?ref=redwood\n",
255
+ "Check out the deployment docs at https://app.flightcontrol.dev/docs for detailed instructions\n",
256
+ "NOTE: If you are using yarn v1, remove the installCommand's from flightcontrol.json"
257
+ ];
258
+ const handler = async ({ force, database }) => {
259
+ recordTelemetryAttributes({
260
+ command: "setup deploy flightcontrol",
261
+ force,
262
+ database
263
+ });
264
+ const tasks = new Listr(
265
+ [
266
+ {
267
+ title: "Adding flightcontrol.json",
268
+ task: async () => {
269
+ const fileData = await getFlightcontrolJson(database);
270
+ let files = {};
271
+ files[fileData.path] = JSON.stringify(fileData.content, null, 2);
272
+ return writeFilesTask(files, { overwriteExisting: force });
273
+ }
274
+ },
275
+ updateGraphQLFunction(),
276
+ updateDbAuth(),
277
+ updateApp(),
278
+ updateApiURLTask("${REDWOOD_API_URL}"),
279
+ addToDotEnvDefaultTask(),
280
+ printSetupNotes(notes)
281
+ ],
282
+ { rendererOptions: { collapseSubtasks: false } }
283
+ );
284
+ try {
285
+ await tasks.run();
286
+ } catch (e) {
287
+ errorTelemetry(process.argv, e.message);
288
+ console.error(c.error(e.message));
289
+ process.exit(e?.exitCode || 1);
290
+ }
291
+ };
292
+ export {
293
+ handler
294
+ };
@@ -0,0 +1,9 @@
1
+ import { createHandler } from "../helpers/helpers.js";
2
+ const command = "netlify";
3
+ const description = "Setup Netlify deploy";
4
+ const handler = createHandler("netlify");
5
+ export {
6
+ command,
7
+ description,
8
+ handler
9
+ };
@@ -0,0 +1,42 @@
1
+ import path from "path";
2
+ import { Listr } from "listr2";
3
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
+ import { errorTelemetry } from "@cedarjs/telemetry";
5
+ import c from "../../../../lib/colors.js";
6
+ import { getPaths, printSetupNotes } from "../../../../lib/index.js";
7
+ import { addFilesTask, updateApiURLTask } from "../helpers/index.js";
8
+ import { NETLIFY_TOML } from "../templates/netlify.js";
9
+ const files = [
10
+ {
11
+ path: path.join(getPaths().base, "netlify.toml"),
12
+ content: NETLIFY_TOML
13
+ }
14
+ ];
15
+ const notes = [
16
+ "You are ready to deploy to Netlify!",
17
+ "See: https://redwoodjs.com/docs/deploy/netlify"
18
+ ];
19
+ const handler = async ({ force }) => {
20
+ recordTelemetryAttributes({
21
+ command: "setup deploy netlify",
22
+ force
23
+ });
24
+ const tasks = new Listr(
25
+ [
26
+ updateApiURLTask("/.netlify/functions"),
27
+ addFilesTask({ files, force }),
28
+ printSetupNotes(notes)
29
+ ],
30
+ { rendererOptions: { collapseSubtasks: false } }
31
+ );
32
+ try {
33
+ await tasks.run();
34
+ } catch (e) {
35
+ errorTelemetry(process.argv, e.message);
36
+ console.error(c.error(e.message));
37
+ process.exit(e?.exitCode || 1);
38
+ }
39
+ };
40
+ export {
41
+ handler
42
+ };
@@ -0,0 +1,17 @@
1
+ import { createHandler } from "../helpers/helpers.js";
2
+ const command = "render";
3
+ const description = "Setup Render deploy";
4
+ const builder = (yargs) => yargs.option("database", {
5
+ alias: "d",
6
+ choices: ["none", "postgresql", "sqlite"],
7
+ description: "Database deployment for Render only",
8
+ default: "postgresql",
9
+ type: "string"
10
+ });
11
+ const handler = createHandler("render");
12
+ export {
13
+ builder,
14
+ command,
15
+ description,
16
+ handler
17
+ };
@@ -0,0 +1,111 @@
1
+ import path from "path";
2
+ import prismaInternals from "@prisma/internals";
3
+ import fs from "fs-extra";
4
+ import { Listr } from "listr2";
5
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
6
+ import { errorTelemetry } from "@cedarjs/telemetry";
7
+ import c from "../../../../lib/colors.js";
8
+ import {
9
+ getPaths,
10
+ writeFilesTask,
11
+ printSetupNotes
12
+ } from "../../../../lib/index.js";
13
+ import { addFilesTask, updateApiURLTask } from "../helpers/index.js";
14
+ import {
15
+ POSTGRES_YAML,
16
+ RENDER_HEALTH_CHECK,
17
+ RENDER_YAML,
18
+ SQLITE_YAML
19
+ } from "../templates/render.js";
20
+ const { getSchema, getConfig } = prismaInternals;
21
+ const getRenderYamlContent = async (database) => {
22
+ if (database === "none") {
23
+ return {
24
+ path: path.join(getPaths().base, "render.yaml"),
25
+ content: RENDER_YAML("")
26
+ };
27
+ }
28
+ if (!fs.existsSync("api/db/schema.prisma")) {
29
+ throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
30
+ }
31
+ const schema = await getSchema("api/db/schema.prisma");
32
+ const config = await getConfig({ datamodel: schema });
33
+ const detectedDatabase = config.datasources[0].activeProvider;
34
+ if (detectedDatabase === database) {
35
+ switch (database) {
36
+ case "postgresql":
37
+ return {
38
+ path: path.join(getPaths().base, "render.yaml"),
39
+ content: RENDER_YAML(POSTGRES_YAML)
40
+ };
41
+ case "sqlite":
42
+ return {
43
+ path: path.join(getPaths().base, "render.yaml"),
44
+ content: RENDER_YAML(SQLITE_YAML)
45
+ };
46
+ default:
47
+ throw new Error(`
48
+ Unexpected datasource provider found: ${database}`);
49
+ }
50
+ } else {
51
+ throw new Error(`
52
+ Prisma datasource provider is detected to be ${detectedDatabase}.
53
+
54
+ Option 1: Update your schema.prisma provider to be ${database}, then run
55
+ yarn rw prisma migrate dev
56
+ yarn rw setup deploy render --database ${database}
57
+
58
+ Option 2: Rerun setup deploy command with current schema.prisma provider:
59
+ yarn rw setup deploy render --database ${detectedDatabase}`);
60
+ }
61
+ };
62
+ const notes = [
63
+ "You are ready to deploy to Render!\n",
64
+ "Go to https://dashboard.render.com/iacs to create your account and deploy to Render",
65
+ "Check out the deployment docs at https://render.com/docs/deploy-redwood for detailed instructions",
66
+ "Note: After first deployment to Render update the rewrite rule destination in `./render.yaml`"
67
+ ];
68
+ const additionalFiles = [
69
+ {
70
+ path: path.join(getPaths().base, "api/src/functions/healthz.js"),
71
+ content: RENDER_HEALTH_CHECK
72
+ }
73
+ ];
74
+ const handler = async ({ force, database }) => {
75
+ recordTelemetryAttributes({
76
+ command: "setup deploy render",
77
+ force,
78
+ database
79
+ });
80
+ const tasks = new Listr(
81
+ [
82
+ {
83
+ title: "Adding render.yaml",
84
+ task: async () => {
85
+ const fileData = await getRenderYamlContent(database);
86
+ let files = {};
87
+ files[fileData.path] = fileData.content;
88
+ return writeFilesTask(files, { overwriteExisting: force });
89
+ }
90
+ },
91
+ updateApiURLTask("/.redwood/functions"),
92
+ // Add health check api function
93
+ addFilesTask({
94
+ files: additionalFiles,
95
+ force
96
+ }),
97
+ printSetupNotes(notes)
98
+ ],
99
+ { rendererOptions: { collapseSubtasks: false } }
100
+ );
101
+ try {
102
+ await tasks.run();
103
+ } catch (e) {
104
+ errorTelemetry(process.argv, e.message);
105
+ console.error(c.error(e.message));
106
+ process.exit(e?.exitCode || 1);
107
+ }
108
+ };
109
+ export {
110
+ handler
111
+ };
@@ -0,0 +1,11 @@
1
+ import { createHandler } from "../helpers/helpers.js";
2
+ const command = "serverless";
3
+ const description = "[DEPRECATED]\nSetup Serverless Framework AWS deploy\nFor more information:\nhttps://redwoodjs.com/docs/deploy/serverless";
4
+ const aliases = ["aws-serverless"];
5
+ const handler = createHandler("serverless");
6
+ export {
7
+ aliases,
8
+ command,
9
+ description,
10
+ handler
11
+ };
@@ -0,0 +1,141 @@
1
+ import path from "path";
2
+ import fs from "fs-extra";
3
+ import { Listr } from "listr2";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
+ import { errorTelemetry } from "@cedarjs/telemetry";
6
+ import c from "../../../../lib/colors.js";
7
+ import {
8
+ addPackagesTask,
9
+ getPaths,
10
+ printSetupNotes
11
+ } from "../../../../lib/index.js";
12
+ import {
13
+ addToGitIgnoreTask,
14
+ addToDotEnvTask,
15
+ addFilesTask
16
+ } from "../helpers/index.js";
17
+ import { SERVERLESS_API_YML } from "../templates/serverless/api.js";
18
+ import { SERVERLESS_WEB_YML } from "../templates/serverless/web.js";
19
+ const notes = [
20
+ c.error("DEPRECATED option not officially supported"),
21
+ "",
22
+ "For more information:",
23
+ "https://redwoodjs.com/docs/deploy/serverless",
24
+ "",
25
+ "",
26
+ c.success("You're almost ready to deploy using the Serverless framework!"),
27
+ "",
28
+ "\u2022 See https://redwoodjs.com/docs/deploy#serverless-deploy for more info. If you ",
29
+ " want to give it a shot, open your `.env` file and add your AWS credentials,",
30
+ " then run: ",
31
+ "",
32
+ " yarn rw deploy serverless --first-run",
33
+ "",
34
+ " For subsequent deploys you can just run `yarn rw deploy serverless`.",
35
+ "",
36
+ "\u2022 If you want to use the Serverless Dashboard to manage your app, plug in",
37
+ " the values for `org` and `app` in `web/serverless.yml` and `api/serverless.yml`",
38
+ "",
39
+ "\u2022 If you haven't already, familiarize yourself with the docs for your",
40
+ " preferred provider: https://www.serverless.com/framework/docs/providers"
41
+ ];
42
+ const projectDevPackages = [
43
+ "serverless",
44
+ "serverless-lift",
45
+ "@vercel/nft",
46
+ "archiver",
47
+ "fs-extra"
48
+ ];
49
+ const files = [
50
+ {
51
+ path: path.join(getPaths().api.base, "serverless.yml"),
52
+ content: SERVERLESS_API_YML
53
+ },
54
+ {
55
+ path: path.join(getPaths().web.base, "serverless.yml"),
56
+ content: SERVERLESS_WEB_YML
57
+ }
58
+ ];
59
+ const prismaBinaryTargetAdditions = () => {
60
+ const content = fs.readFileSync(getPaths().api.dbSchema).toString();
61
+ if (!content.includes("rhel-openssl-1.0.x")) {
62
+ const result = content.replace(
63
+ /binaryTargets =.*\n/,
64
+ `binaryTargets = ["native", "rhel-openssl-1.0.x"]
65
+ `
66
+ );
67
+ fs.writeFileSync(getPaths().api.dbSchema, result);
68
+ }
69
+ };
70
+ const updateRedwoodTomlTask = () => {
71
+ return {
72
+ title: "Updating redwood.toml apiUrl...",
73
+ task: () => {
74
+ const configPath = path.join(getPaths().base, "redwood.toml");
75
+ const content = fs.readFileSync(configPath).toString();
76
+ const newContent = content.replace(
77
+ /apiUrl.*?\n/m,
78
+ 'apiUrl = "${API_URL:/api}" # Set API_URL in production to the Serverless deploy endpoint of your api service, see https://redwoodjs.com/docs/deploy/serverless-deploy\n'
79
+ );
80
+ fs.writeFileSync(configPath, newContent);
81
+ }
82
+ };
83
+ };
84
+ const handler = async ({ force }) => {
85
+ recordTelemetryAttributes({
86
+ command: "setup deploy serverless",
87
+ force
88
+ });
89
+ const [serverless, serverlessLift, ...rest] = projectDevPackages;
90
+ const tasks = new Listr(
91
+ [
92
+ await addPackagesTask({
93
+ packages: [serverless, ...rest],
94
+ devDependency: true
95
+ }),
96
+ await addPackagesTask({
97
+ packages: [serverless, serverlessLift],
98
+ side: "web",
99
+ devDependency: true
100
+ }),
101
+ await addPackagesTask({
102
+ packages: [serverless],
103
+ side: "api",
104
+ devDependency: true
105
+ }),
106
+ addFilesTask({
107
+ files,
108
+ force
109
+ }),
110
+ updateRedwoodTomlTask(),
111
+ addToGitIgnoreTask({
112
+ paths: [".serverless"]
113
+ }),
114
+ addToDotEnvTask({
115
+ lines: [
116
+ "AWS_ACCESS_KEY_ID=<your-key-here>",
117
+ "AWS_SECRET_ACCESS_KEY=<your-secret-key-here>"
118
+ ]
119
+ }),
120
+ {
121
+ title: "Adding necessary Prisma binaries...",
122
+ task: () => prismaBinaryTargetAdditions()
123
+ },
124
+ printSetupNotes(notes)
125
+ ],
126
+ {
127
+ exitOnError: true,
128
+ rendererOptions: { collapseSubtasks: false }
129
+ }
130
+ );
131
+ try {
132
+ await tasks.run();
133
+ } catch (e) {
134
+ errorTelemetry(process.argv, e.message);
135
+ console.error(c.error(e.message));
136
+ process.exit(e?.exitCode || 1);
137
+ }
138
+ };
139
+ export {
140
+ handler
141
+ };
@@ -0,0 +1,9 @@
1
+ import { createHandler } from "../helpers/helpers.js";
2
+ const command = "vercel";
3
+ const description = "Setup Vercel deploy";
4
+ const handler = createHandler("vercel");
5
+ export {
6
+ command,
7
+ description,
8
+ handler
9
+ };
@@ -0,0 +1,56 @@
1
+ import path from "path";
2
+ import { Listr } from "listr2";
3
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
+ import { errorTelemetry } from "@cedarjs/telemetry";
5
+ import c from "../../../../lib/colors.js";
6
+ import { getPaths, printSetupNotes, writeFile } from "../../../../lib/index.js";
7
+ import { updateApiURLTask } from "../helpers/index.js";
8
+ async function handler(options) {
9
+ recordTelemetryAttributes({
10
+ command: "setup deploy vercel"
11
+ });
12
+ const tasks = new Listr(
13
+ [
14
+ updateApiURLTask("/api"),
15
+ writeVercelConfigTask({ overwriteExisting: options.force }),
16
+ printSetupNotes(notes)
17
+ ],
18
+ {
19
+ rendererOptions: { collapseSubtasks: false }
20
+ }
21
+ );
22
+ try {
23
+ await tasks.run();
24
+ } catch (e) {
25
+ errorTelemetry(process.argv, e.message);
26
+ console.error(c.error(e.message));
27
+ process.exit(e?.exitCode || 1);
28
+ }
29
+ }
30
+ function writeVercelConfigTask({ overwriteExisting = false } = {}) {
31
+ return {
32
+ title: "Writing vercel.json...",
33
+ task: (_ctx, task) => {
34
+ writeFile(
35
+ path.join(getPaths().base, "vercel.json"),
36
+ JSON.stringify(vercelConfig, null, 2),
37
+ { overwriteExisting },
38
+ task
39
+ );
40
+ }
41
+ };
42
+ }
43
+ const vercelConfig = {
44
+ build: {
45
+ env: {
46
+ ENABLE_EXPERIMENTAL_COREPACK: "1"
47
+ }
48
+ }
49
+ };
50
+ const notes = [
51
+ "You are ready to deploy to Vercel!",
52
+ "See: https://redwoodjs.com/docs/deploy#vercel-deploy"
53
+ ];
54
+ export {
55
+ handler
56
+ };