@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,65 @@
1
+ function transform(file, api) {
2
+ const j = api.jscodeshift;
3
+ const ast = j(file.source);
4
+ const needsImport = ast.find(j.ImportDeclaration, {
5
+ specifiers: [
6
+ {
7
+ type: "ImportDefaultSpecifier",
8
+ local: {
9
+ name: "vitePluginOgImageGen"
10
+ }
11
+ }
12
+ ],
13
+ source: {
14
+ value: "@cedarjs/ogimage-gen/plugin",
15
+ type: "StringLiteral"
16
+ }
17
+ }).length === 0;
18
+ if (needsImport) {
19
+ ast.find(j.ImportDeclaration).at(0).insertBefore(
20
+ j.importDeclaration(
21
+ [j.importDefaultSpecifier(j.identifier("vitePluginOgImageGen"))],
22
+ j.stringLiteral("@cedarjs/ogimage-gen/plugin")
23
+ )
24
+ );
25
+ }
26
+ const viteConfigVariable = ast.find(j.VariableDeclaration, {
27
+ declarations(value) {
28
+ if (value.length !== 1) {
29
+ return false;
30
+ }
31
+ const declaration = value[0];
32
+ if (declaration.type !== "VariableDeclarator") {
33
+ return false;
34
+ }
35
+ return declaration.id.type === "Identifier" && declaration.id.name === "viteConfig";
36
+ }
37
+ });
38
+ if (viteConfigVariable.length === 0) {
39
+ throw new Error("Could not find the `viteConfig` variable");
40
+ }
41
+ const pluginsArray = viteConfigVariable.find(j.ObjectExpression, {
42
+ properties(value) {
43
+ if (!value) {
44
+ return false;
45
+ }
46
+ return value.some(
47
+ (property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "plugins"
48
+ );
49
+ }
50
+ });
51
+ if (pluginsArray.length === 0) {
52
+ throw new Error(
53
+ "Could not find the `plugins` array in the `viteConfig` variable"
54
+ );
55
+ }
56
+ pluginsArray.find(j.ArrayExpression).at(0).replaceWith((nodePath) => {
57
+ const elements = nodePath.value.elements;
58
+ elements.push(j.callExpression(j.identifier("vitePluginOgImageGen"), []));
59
+ return nodePath.value;
60
+ });
61
+ return ast.toSource();
62
+ }
63
+ export {
64
+ transform as default
65
+ };
@@ -0,0 +1,27 @@
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ const command = "og-image";
3
+ const aliases = ["ogImage", "ogimage"];
4
+ const description = "Set up OG Image generation middleware";
5
+ function builder(yargs) {
6
+ return yargs.option("force", {
7
+ alias: "f",
8
+ default: false,
9
+ description: "Overwrite existing configuration",
10
+ type: "boolean"
11
+ });
12
+ }
13
+ async function handler({ force }) {
14
+ recordTelemetryAttributes({
15
+ command: "setup middleware og-image",
16
+ force
17
+ });
18
+ const { handler: handler2 } = await import("./ogImageHandler.js");
19
+ return handler2({ force });
20
+ }
21
+ export {
22
+ aliases,
23
+ builder,
24
+ command,
25
+ description,
26
+ handler
27
+ };
@@ -0,0 +1,121 @@
1
+ import path from "node:path";
2
+ import fs from "fs-extra";
3
+ import { Listr } from "listr2";
4
+ import { format } from "prettier";
5
+ import { addWebPackages, getPrettierOptions } from "@cedarjs/cli-helpers";
6
+ import { getConfig, getPaths } from "@cedarjs/project-config";
7
+ import { runTransform } from "../../../../lib/runTransform.js";
8
+ async function handler({ force }) {
9
+ const rwPaths = getPaths();
10
+ const rootPkgJson = fs.readJSONSync(path.join(rwPaths.base, "package.json"));
11
+ const currentProjectVersion = rootPkgJson.devDependencies["@cedarjs/core"];
12
+ const notes = [""];
13
+ const tasks = new Listr(
14
+ [
15
+ {
16
+ title: "Check prerequisites",
17
+ skip: force,
18
+ task: () => {
19
+ if (!getConfig().experimental?.streamingSsr?.enabled) {
20
+ throw new Error(
21
+ "The Streaming SSR experimental feature must be enabled before you can setup middleware.\n\nRun this command to setup streaming ssr: \n yarn rw exp setup-streaming-ssr\n"
22
+ );
23
+ }
24
+ }
25
+ },
26
+ addWebPackages([`@cedarjs/ogimage-gen@${currentProjectVersion}`]),
27
+ {
28
+ title: "Add OG Image middleware ...",
29
+ task: async () => {
30
+ const serverEntryPath = rwPaths.web.entryServer;
31
+ if (serverEntryPath === null) {
32
+ throw new Error(
33
+ "Could not find the server entry file. Is your project using the default structure?"
34
+ );
35
+ }
36
+ const transformResult = await runTransform({
37
+ transformPath: path.join(
38
+ import.meta.dirname,
39
+ "codemodMiddleware.js"
40
+ ),
41
+ targetPaths: [serverEntryPath]
42
+ });
43
+ if (transformResult.error) {
44
+ throw new Error(transformResult.error);
45
+ }
46
+ }
47
+ },
48
+ {
49
+ title: "Add OG Image vite plugin ...",
50
+ task: async () => {
51
+ const viteConfigPath = rwPaths.web.viteConfig;
52
+ if (viteConfigPath === null) {
53
+ throw new Error("Could not find the Vite config file");
54
+ }
55
+ const transformResult = await runTransform({
56
+ transformPath: path.join(
57
+ import.meta.dirname,
58
+ "codemodVitePlugin.js"
59
+ ),
60
+ targetPaths: [viteConfigPath]
61
+ });
62
+ if (transformResult.error) {
63
+ throw new Error(transformResult.error);
64
+ }
65
+ }
66
+ },
67
+ {
68
+ title: "Prettifying changed files",
69
+ task: async (_ctx, task) => {
70
+ const prettifyPaths = [
71
+ rwPaths.web.entryServer,
72
+ rwPaths.web.viteConfig
73
+ ];
74
+ for (const prettifyPath of prettifyPaths) {
75
+ if (prettifyPath === null) {
76
+ throw new Error("Could not find the file to be prettified");
77
+ }
78
+ try {
79
+ const source = fs.readFileSync(prettifyPath, "utf-8");
80
+ const prettierOptions = await getPrettierOptions();
81
+ const prettifiedApp = await format(source, {
82
+ ...prettierOptions,
83
+ parser: "babel-ts"
84
+ });
85
+ fs.writeFileSync(prettifyPath, prettifiedApp, "utf-8");
86
+ } catch {
87
+ task.output = "Couldn't prettify the changes. Please reformat the files manually if needed.";
88
+ }
89
+ }
90
+ }
91
+ },
92
+ {
93
+ title: "One more thing...",
94
+ task: () => {
95
+ notes.push(
96
+ "og:image generation is almost ready to go! You'll need to add playwright as a dependency to the web side and then install the headless browser packages:"
97
+ );
98
+ notes.push("");
99
+ notes.push(" yarn workspace web add playwright");
100
+ notes.push(" yarn workspace web playwright install");
101
+ notes.push("");
102
+ notes.push(
103
+ "Depending on how your host is configured you may need to install additional dependencies first. If so, the `playwright install` step will error out and give you the command to run to install those deps."
104
+ );
105
+ notes.push("");
106
+ }
107
+ }
108
+ ],
109
+ { rendererOptions: { collapseSubtasks: false } }
110
+ );
111
+ try {
112
+ await tasks.run();
113
+ console.log(notes.join("\n"));
114
+ } catch (e) {
115
+ console.error(e.message);
116
+ process.exit(e?.exitCode || 1);
117
+ }
118
+ }
119
+ export {
120
+ handler
121
+ };
@@ -0,0 +1,17 @@
1
+ import terminalLink from "terminal-link";
2
+ import * as sentryCommand from "./sentry/sentry.js";
3
+ const command = "monitoring <provider>";
4
+ const description = "Set up monitoring in your Redwood app";
5
+ function builder(yargs) {
6
+ return yargs.command(sentryCommand).epilogue(
7
+ `Also see the ${terminalLink(
8
+ "Redwood CLI Reference",
9
+ "https://redwoodjs.com/docs/cli-commands#setup-graphql"
10
+ )}`
11
+ );
12
+ }
13
+ export {
14
+ builder,
15
+ command,
16
+ description
17
+ };
@@ -0,0 +1,25 @@
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ const command = "sentry";
3
+ const description = "Setup Sentry error and performance tracking";
4
+ const builder = (yargs) => {
5
+ return yargs.option("force", {
6
+ alias: "f",
7
+ default: false,
8
+ description: "Overwrite existing Sentry config files",
9
+ type: "boolean"
10
+ });
11
+ };
12
+ async function handler({ force }) {
13
+ recordTelemetryAttributes({
14
+ command: "setup monitoring sentry",
15
+ force
16
+ });
17
+ const { handler: handler2 } = await import("./sentryHandler.js");
18
+ return handler2({ force });
19
+ }
20
+ export {
21
+ builder,
22
+ command,
23
+ description,
24
+ handler
25
+ };
@@ -0,0 +1,163 @@
1
+ import path from "path";
2
+ import fs from "fs-extra";
3
+ import { Listr } from "listr2";
4
+ import {
5
+ addApiPackages,
6
+ addEnvVarTask,
7
+ addWebPackages,
8
+ colors,
9
+ getPaths,
10
+ isTypeScriptProject,
11
+ prettify,
12
+ writeFilesTask
13
+ } from "@cedarjs/cli-helpers";
14
+ import { errorTelemetry } from "@cedarjs/telemetry";
15
+ const rwPaths = getPaths();
16
+ const handler = async ({ force }) => {
17
+ const extension = isTypeScriptProject() ? "ts" : "js";
18
+ const notes = [];
19
+ const tasks = new Listr([
20
+ addApiPackages(["@envelop/sentry@5", "@sentry/node@7"]),
21
+ addWebPackages(["@sentry/react@7", "@sentry/browser@7"]),
22
+ addEnvVarTask(
23
+ "SENTRY_DSN",
24
+ "",
25
+ "https://docs.sentry.io/product/sentry-basics/dsn-explainer/"
26
+ ),
27
+ {
28
+ title: "Setting up Sentry on the API and web sides",
29
+ task: () => {
30
+ return writeFilesTask(
31
+ {
32
+ [path.join(rwPaths.api.lib, `sentry.${extension}`)]: fs.readFileSync(
33
+ path.join(
34
+ import.meta.dirname,
35
+ "templates/sentryApi.ts.template"
36
+ )
37
+ ).toString(),
38
+ [path.join(rwPaths.web.src, "lib", `sentry.${extension}`)]: fs.readFileSync(
39
+ path.join(
40
+ import.meta.dirname,
41
+ "templates/sentryWeb.ts.template"
42
+ )
43
+ ).toString()
44
+ },
45
+ { existingFiles: force ? "OVERWRITE" : "SKIP" }
46
+ );
47
+ }
48
+ },
49
+ {
50
+ title: "Implementing the Envelop plugin",
51
+ task: async (ctx) => {
52
+ const graphqlHandlerPath = path.join(
53
+ rwPaths.api.functions,
54
+ `graphql.${extension}`
55
+ );
56
+ const contentLines = fs.readFileSync(graphqlHandlerPath).toString().split("\n");
57
+ const handlerIndex = contentLines.findLastIndex(
58
+ (line) => line.startsWith("export const handler = createGraphQLHandler({")
59
+ );
60
+ const pluginsIndex = contentLines.findLastIndex(
61
+ (line) => line.includes("extraPlugins:")
62
+ );
63
+ if (handlerIndex === -1 || pluginsIndex !== -1) {
64
+ ctx.addEnvelopPluginSkipped = true;
65
+ return;
66
+ }
67
+ contentLines.splice(
68
+ handlerIndex,
69
+ 1,
70
+ "import 'src/lib/sentry'",
71
+ "",
72
+ "export const handler = createGraphQLHandler({",
73
+ "extraPlugins: [useSentry({",
74
+ " includeRawResult: true,",
75
+ " includeResolverArgs: true,",
76
+ " includeExecuteVariables: true,",
77
+ "})],"
78
+ );
79
+ contentLines.splice(0, 0, "import { useSentry } from '@envelop/sentry'");
80
+ fs.writeFileSync(
81
+ graphqlHandlerPath,
82
+ await prettify("graphql.ts", contentLines.join("\n"))
83
+ );
84
+ }
85
+ },
86
+ {
87
+ title: "Replacing Redwood's Error boundary",
88
+ task: async () => {
89
+ const contentLines = fs.readFileSync(rwPaths.web.app).toString().split("\n");
90
+ const webImportIndex = contentLines.findLastIndex(
91
+ (line) => /^import { FatalErrorBoundary, RedwoodProvider } from '@cedarjs\/web'$/.test(
92
+ line
93
+ )
94
+ );
95
+ contentLines.splice(
96
+ webImportIndex,
97
+ 1,
98
+ "import { RedwoodProvider } from '@cedarjs/web'"
99
+ );
100
+ const boundaryOpenIndex = contentLines.findLastIndex(
101
+ (line) => line.includes("<FatalErrorBoundary page={FatalErrorPage}>")
102
+ );
103
+ contentLines.splice(
104
+ boundaryOpenIndex,
105
+ 1,
106
+ "<Sentry.ErrorBoundary fallback={FatalErrorPage}>"
107
+ );
108
+ const boundaryCloseIndex = contentLines.findLastIndex(
109
+ (line) => line.includes("</FatalErrorBoundary>")
110
+ );
111
+ contentLines.splice(boundaryCloseIndex, 1, "</Sentry.ErrorBoundary>");
112
+ contentLines.splice(0, 0, "import Sentry from 'src/lib/sentry'");
113
+ fs.writeFileSync(
114
+ rwPaths.web.app,
115
+ await prettify("App.tsx", contentLines.join("\n"))
116
+ );
117
+ }
118
+ },
119
+ {
120
+ title: "One more thing...",
121
+ task: (ctx) => {
122
+ notes.push(
123
+ colors.important(
124
+ "You will need to add `SENTRY_DSN` to `includeEnvironmentVariables` in redwood.toml."
125
+ )
126
+ );
127
+ if (ctx.addEnvelopPluginSkipped) {
128
+ notes.push(
129
+ `${colors.underline(
130
+ "Make sure you implement the Sentry Envelop plugin:"
131
+ )} https://redwoodjs.com/docs/cli-commands#sentry-envelop-plugin`
132
+ );
133
+ } else {
134
+ notes.push(
135
+ "Check out the RedwoodJS forums for more: https://community.redwoodjs.com/t/sentry-error-and-performance-monitoring-experimental/4880"
136
+ );
137
+ }
138
+ }
139
+ }
140
+ ]);
141
+ try {
142
+ await tasks.run();
143
+ console.log(notes.join("\n"));
144
+ } catch (e) {
145
+ if (isErrorWithMessage(e)) {
146
+ errorTelemetry(process.argv, e.message);
147
+ console.error(colors.error(e.message));
148
+ }
149
+ if (isErrorWithExitCode(e)) {
150
+ process.exit(e.exitCode);
151
+ }
152
+ process.exit(1);
153
+ }
154
+ };
155
+ function isErrorWithMessage(e) {
156
+ return !!e && typeof e === "object" && "message" in e;
157
+ }
158
+ function isErrorWithExitCode(e) {
159
+ return !!e && typeof e === "object" && "exitCode" in e && typeof e.exitCode === "number";
160
+ }
161
+ export {
162
+ handler
163
+ };
@@ -0,0 +1,15 @@
1
+ import * as Sentry from '@sentry/node'
2
+
3
+ import { db as client } from 'src/lib/db'
4
+
5
+ Sentry.init({
6
+ dsn: process.env.SENTRY_DSN,
7
+ environment: process.env.NODE_ENV,
8
+ integrations: [
9
+ new Sentry.Integrations.Prisma({ client }),
10
+ new Sentry.Integrations.Http({ tracing: true }),
11
+ ],
12
+ tracesSampleRate: 1.0,
13
+ })
14
+
15
+ export default Sentry
@@ -0,0 +1,31 @@
1
+ import * as Sentry from '@sentry/react'
2
+
3
+ let dsn = ''
4
+ let environment = 'development'
5
+
6
+ if (typeof process === 'undefined' || !process.env?.SENTRY_DSN) {
7
+ console.error(
8
+ 'Missing SENTRY_DSN environment variable. Did you forget to add it to ' +
9
+ 'your redwood.toml file in `includeEnvironmentVariables`?'
10
+ )
11
+ console.info(`Copy this into your redwood.toml file:`)
12
+ console.info(`
13
+ includeEnvironmentVariables = [
14
+ "SENTRY_DSN"
15
+ ]
16
+
17
+ `)
18
+ console.error('Sentry is disabled for now')
19
+ } else {
20
+ dsn = process.env.SENTRY_DSN
21
+ environment = process.env.NODE_ENV
22
+ }
23
+
24
+ Sentry.init({
25
+ dsn,
26
+ environment,
27
+ integrations: [new Sentry.BrowserTracing()],
28
+ tracesSampleRate: 1.0,
29
+ })
30
+
31
+ export default Sentry
@@ -0,0 +1,33 @@
1
+ import terminalLink from "terminal-link";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
3
+ const command = "package <npm-package>";
4
+ const description = "Run a bin from an NPM package with version compatibility checks";
5
+ const builder = (yargs) => {
6
+ yargs.positional("npm-package", {
7
+ description: "The NPM package to run. This can be a package name or a package name with a version or tag.",
8
+ type: "string"
9
+ }).option("force", {
10
+ default: false,
11
+ description: "Proceed with a potentially incompatible version of the package",
12
+ type: "boolean",
13
+ alias: "f"
14
+ }).epilogue(
15
+ `Also see the ${terminalLink(
16
+ "Redwood CLI Reference",
17
+ "https://redwoodjs.com/docs/cli-commands#lint"
18
+ )}`
19
+ );
20
+ };
21
+ const handler = async (options) => {
22
+ recordTelemetryAttributes({
23
+ command: "setup package"
24
+ });
25
+ const { handler: handler2 } = await import("./packageHandler.js");
26
+ return handler2(options);
27
+ };
28
+ export {
29
+ builder,
30
+ command,
31
+ description,
32
+ handler
33
+ };
@@ -0,0 +1,134 @@
1
+ import enq from "enquirer";
2
+ import execa from "execa";
3
+ import semver from "semver";
4
+ import { getCompatibilityData } from "@cedarjs/cli-helpers";
5
+ import { getPaths } from "@cedarjs/project-config";
6
+ async function handler({ npmPackage, force, _: _args }) {
7
+ const isScoped = npmPackage.startsWith("@");
8
+ const packageName = (isScoped ? "@" : "") + npmPackage.split("@")[isScoped ? 1 : 0];
9
+ const packageVersion = npmPackage.split("@")[isScoped ? 2 : 1] ?? "latest";
10
+ const additionalOptionsToForward = _args.slice(2) ?? [];
11
+ if (force) {
12
+ console.log(
13
+ "No compatibility check will be performed because you used the --force flag."
14
+ );
15
+ if (semver.parse(packageVersion) !== null && semver.lt(packageVersion, "1.0.0")) {
16
+ console.log(
17
+ "Be aware that this package is under version 1.0.0 and so should be considered experimental."
18
+ );
19
+ }
20
+ await runPackage(packageName, packageVersion, additionalOptionsToForward);
21
+ return;
22
+ }
23
+ console.log("Checking compatibility...");
24
+ let compatibilityData;
25
+ try {
26
+ compatibilityData = await getCompatibilityData(packageName, packageVersion);
27
+ } catch (error) {
28
+ console.log("The following error occurred while checking compatibility:");
29
+ const errorMessage = error.message ?? error;
30
+ console.log(errorMessage);
31
+ if (errorMessage.includes("does not have a tag") || errorMessage.includes("does not have a version")) {
32
+ process.exit(1);
33
+ }
34
+ const decision2 = await promptWithChoices("What would you like to do?", [
35
+ {
36
+ name: "cancel",
37
+ message: "Cancel"
38
+ },
39
+ {
40
+ name: "continue",
41
+ message: "Continue regardless of potential incompatibility"
42
+ }
43
+ ]);
44
+ if (decision2 === "continue") {
45
+ await runPackage(packageName, packageVersion, additionalOptionsToForward);
46
+ }
47
+ return;
48
+ }
49
+ const { preferred, compatible } = compatibilityData;
50
+ const preferredVersionIsCompatible = preferred.version === compatible.version;
51
+ if (preferredVersionIsCompatible) {
52
+ await showExperimentalWarning(preferred.version);
53
+ await runPackage(packageName, preferred.version, additionalOptionsToForward);
54
+ return;
55
+ }
56
+ const preferredVersionText = `${preferred.version}${preferred.tag ? ` (${preferred.tag})` : ""}`;
57
+ const latestCompatibleVersionText = `${compatible.version}${compatible.tag ? ` (${compatible.tag})` : ""}`;
58
+ console.log(
59
+ `The version ${preferredVersionText} of '${packageName}' is not compatible with your RedwoodJS project version.
60
+ The latest version compatible with your project is ${latestCompatibleVersionText}.`
61
+ );
62
+ const decision = await promptWithChoices("What would you like to do?", [
63
+ {
64
+ name: "useLatestCompatibleVersion",
65
+ message: `Use the latest compatible version: ${latestCompatibleVersionText}`
66
+ },
67
+ {
68
+ name: "usePreferredVersion",
69
+ message: `Continue anyway with version: ${preferredVersionText}`
70
+ },
71
+ {
72
+ name: "cancel",
73
+ message: "Cancel"
74
+ }
75
+ ]);
76
+ if (decision === "cancel") {
77
+ process.exitCode = 1;
78
+ return;
79
+ }
80
+ const versionToUse = decision === "useLatestCompatibleVersion" ? compatible.version : preferred.version;
81
+ await showExperimentalWarning(versionToUse);
82
+ await runPackage(packageName, versionToUse, additionalOptionsToForward);
83
+ }
84
+ async function showExperimentalWarning(version) {
85
+ if (version === void 0 || semver.parse(version) === null || semver.gte(version, "1.0.0")) {
86
+ return;
87
+ }
88
+ const decision = await promptWithChoices(
89
+ "This package is under version 1.0.0 and so should be considered experimental. Would you like to continue?",
90
+ [
91
+ {
92
+ name: "yes",
93
+ message: "Yes"
94
+ },
95
+ {
96
+ name: "no",
97
+ message: "No"
98
+ }
99
+ ]
100
+ );
101
+ if (decision === "no") {
102
+ process.exit();
103
+ }
104
+ }
105
+ async function runPackage(packageName, version, options = []) {
106
+ const versionString = version === void 0 ? "" : `@${version}`;
107
+ console.log(`Running ${packageName}${versionString}...`);
108
+ try {
109
+ await execa("yarn", ["dlx", `${packageName}${versionString}`, ...options], {
110
+ stdio: "inherit",
111
+ cwd: getPaths().base
112
+ });
113
+ } catch (error) {
114
+ process.exitCode = error.exitCode ?? 1;
115
+ }
116
+ }
117
+ async function promptWithChoices(message, choices) {
118
+ try {
119
+ const prompt = new enq.Select({
120
+ name: message.substring(0, 8).toLowerCase(),
121
+ message,
122
+ choices
123
+ });
124
+ return await prompt.run();
125
+ } catch (error) {
126
+ if (error) {
127
+ throw error;
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ export {
133
+ handler
134
+ };
@@ -0,0 +1,37 @@
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ const command = "realtime";
3
+ const description = "Setup RedwoodJS Realtime";
4
+ function builder(yargs) {
5
+ yargs.option("includeExamples", {
6
+ alias: ["e", "examples"],
7
+ default: true,
8
+ description: "Include examples of how to implement liveQueries and subscriptions",
9
+ type: "boolean"
10
+ }).option("force", {
11
+ alias: "f",
12
+ default: false,
13
+ description: "Overwrite existing configuration",
14
+ type: "boolean"
15
+ }).option("verbose", {
16
+ alias: "v",
17
+ default: false,
18
+ description: "Print more logs",
19
+ type: "boolean"
20
+ });
21
+ }
22
+ async function handler(options) {
23
+ recordTelemetryAttributes({
24
+ command: "setup realtime",
25
+ includeExamples: options.includeExamples,
26
+ force: options.force,
27
+ verbose: options.verbose
28
+ });
29
+ const { handler: handler2 } = await import("./realtimeHandler.js");
30
+ return handler2(options);
31
+ }
32
+ export {
33
+ builder,
34
+ command,
35
+ description,
36
+ handler
37
+ };