@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,13 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import ${pascalName}Page from './${pascalName}Page'
4
+
5
+ const meta: Meta<typeof ${pascalName}Page> = {
6
+ component: ${pascalName}Page,
7
+ }
8
+
9
+ export default meta
10
+
11
+ type Story = StoryObj<typeof ${pascalName}Page>
12
+
13
+ export const Primary: Story = {}
@@ -0,0 +1,13 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import ${pascalName}Page from './${pascalName}Page'
4
+
5
+ const meta: Meta<typeof ${pascalName}Page> = {
6
+ component: ${pascalName}Page,
7
+ }
8
+
9
+ export default meta
10
+
11
+ type Story = StoryObj<typeof ${pascalName}Page>
12
+
13
+ export const Primary: Story = {}
@@ -0,0 +1,14 @@
1
+ import { render } from '@cedarjs/testing/web'
2
+
3
+ import ${pascalName}Page from './${pascalName}Page'
4
+
5
+ // Improve this test with help from the Redwood Testing Doc:
6
+ // https://redwoodjs.com/docs/testing#testing-pages-layouts
7
+
8
+ describe('${pascalName}Page', () => {
9
+ it('renders successfully', () => {
10
+ expect(() => {
11
+ render(<${pascalName}Page ${propValueParam}/>)
12
+ }).not.toThrow()
13
+ })
14
+ })
@@ -0,0 +1,41 @@
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ const command = "realtime <name>";
3
+ const description = "Generate a subscription or live query used with RedwoodJS Realtime";
4
+ function builder(yargs) {
5
+ yargs.positional("name", {
6
+ type: "string",
7
+ description: "Name of the realtime event to setup. This should be a type or model name like: Widget, Sprocket, etc.",
8
+ demandOption: true
9
+ }).option("type", {
10
+ alias: "t",
11
+ type: "string",
12
+ choices: ["liveQuery", "subscription"],
13
+ description: "Type of realtime event to setup"
14
+ }).option("force", {
15
+ alias: "f",
16
+ default: false,
17
+ description: "Overwrite existing configuration",
18
+ type: "boolean"
19
+ }).option("verbose", {
20
+ alias: "v",
21
+ default: false,
22
+ description: "Print more logs",
23
+ type: "boolean"
24
+ });
25
+ }
26
+ async function handler(options) {
27
+ recordTelemetryAttributes({
28
+ command: "generate realtime",
29
+ type: options.type,
30
+ force: options.force,
31
+ verbose: options.verbose
32
+ });
33
+ const { handler: handler2 } = await import("./realtimeHandler.js");
34
+ return handler2(options);
35
+ }
36
+ export {
37
+ builder,
38
+ command,
39
+ description,
40
+ handler
41
+ };
@@ -0,0 +1,215 @@
1
+ import path from "path";
2
+ import camelcase from "camelcase";
3
+ import { Listr } from "listr2";
4
+ import pascalcase from "pascalcase";
5
+ import pluralize, { singular } from "pluralize";
6
+ import prompts from "prompts";
7
+ import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
8
+ import { errorTelemetry } from "@cedarjs/telemetry";
9
+ import c from "../../../lib/colors.js";
10
+ import {
11
+ generateTemplate,
12
+ getPaths,
13
+ transformTSToJS,
14
+ writeFile
15
+ } from "../../../lib/index.js";
16
+ import { isTypeScriptProject } from "../../../lib/project.js";
17
+ import { isRealtimeSetup, isServerFileSetup } from "../../experimental/util.js";
18
+ const templateVariables = (name) => {
19
+ name = singular(name.toLowerCase());
20
+ return {
21
+ name,
22
+ collectionName: pluralize(name),
23
+ pluralName: pluralize(name),
24
+ pluralPascalName: pascalcase(pluralize(name)),
25
+ camelName: camelcase(name),
26
+ functionName: camelcase(name),
27
+ liveQueryName: `recent${pascalcase(pluralize(name))}`,
28
+ subscriptionQueryName: `recent${pascalcase(pluralize(name))}`,
29
+ subscriptionName: `listenTo${pascalcase(name)}Channel`,
30
+ modelName: pascalcase(name),
31
+ typeName: pascalcase(name),
32
+ channelName: `${pascalcase(name)}Channel`,
33
+ subscriptionInputType: `Publish${pascalcase(name)}Input`,
34
+ subscriptionServiceResolver: `publishTo${pascalcase(name)}Channel`
35
+ };
36
+ };
37
+ async function handler({ name, type, force, verbose }) {
38
+ const redwoodPaths = getPaths();
39
+ const ts = isTypeScriptProject();
40
+ name = singular(name.toLowerCase());
41
+ let functionType = type;
42
+ if (!functionType) {
43
+ const response = await prompts({
44
+ type: "select",
45
+ name: "functionType",
46
+ choices: [
47
+ {
48
+ value: "liveQuery",
49
+ title: "Live Query",
50
+ description: "Create a Live Query to watch for changes in data"
51
+ },
52
+ {
53
+ value: "subscription",
54
+ title: "Subscription",
55
+ description: "Create a Subscription to watch for events"
56
+ }
57
+ ],
58
+ message: "What type of realtime event would you like to create?"
59
+ });
60
+ functionType = response.functionType;
61
+ }
62
+ const tasks = new Listr(
63
+ [
64
+ {
65
+ title: "Checking for realtime environment prerequisites ...",
66
+ task: () => {
67
+ isServerFileSetup() && isRealtimeSetup();
68
+ }
69
+ },
70
+ {
71
+ title: `Adding ${name} example subscription ...`,
72
+ enabled: () => functionType === "subscription",
73
+ task: async () => {
74
+ const exampleSdlTemplateContent = path.resolve(
75
+ import.meta.dirname,
76
+ "templates",
77
+ "subscriptions",
78
+ "blank",
79
+ `blank.sdl.ts.template`
80
+ );
81
+ const sdlFile = path.join(
82
+ redwoodPaths.api.graphql,
83
+ `${name}.sdl.${isTypeScriptProject() ? "ts" : "js"}`
84
+ );
85
+ const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
86
+ const exampleServiceTemplateContent = path.resolve(
87
+ import.meta.dirname,
88
+ "templates",
89
+ "subscriptions",
90
+ "blank",
91
+ `blank.service.ts.template`
92
+ );
93
+ const serviceFile = path.join(
94
+ redwoodPaths.api.services,
95
+ `${name}`,
96
+ `${name}.${isTypeScriptProject() ? "ts" : "js"}`
97
+ );
98
+ const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
99
+ const exampleSubscriptionTemplateContent = path.resolve(
100
+ import.meta.dirname,
101
+ "templates",
102
+ "subscriptions",
103
+ "blank",
104
+ `blank.ts.template`
105
+ );
106
+ const exampleFile = path.join(
107
+ redwoodPaths.api.subscriptions,
108
+ `${name}`,
109
+ `${name}.${isTypeScriptProject() ? "ts" : "js"}`
110
+ );
111
+ const setupScriptContent = ts ? exampleSubscriptionTemplateContent : await transformTSToJS(
112
+ exampleFile,
113
+ exampleSubscriptionTemplateContent
114
+ );
115
+ return [
116
+ writeFile(
117
+ sdlFile,
118
+ await generateTemplate(sdlContent, templateVariables(name)),
119
+ {
120
+ overwriteExisting: force
121
+ }
122
+ ),
123
+ writeFile(
124
+ serviceFile,
125
+ await generateTemplate(serviceContent, templateVariables(name)),
126
+ {
127
+ overwriteExisting: force
128
+ }
129
+ ),
130
+ writeFile(
131
+ exampleFile,
132
+ await generateTemplate(
133
+ setupScriptContent,
134
+ templateVariables(name)
135
+ ),
136
+ {
137
+ overwriteExisting: force
138
+ }
139
+ )
140
+ ];
141
+ }
142
+ },
143
+ {
144
+ title: `Adding ${name} example live query ...`,
145
+ enabled: () => functionType === "liveQuery",
146
+ task: async () => {
147
+ const exampleSdlTemplateContent = path.resolve(
148
+ import.meta.dirname,
149
+ "templates",
150
+ "liveQueries",
151
+ "blank",
152
+ `blank.sdl.ts.template`
153
+ );
154
+ const sdlFile = path.join(
155
+ redwoodPaths.api.graphql,
156
+ `${name}.sdl.${isTypeScriptProject() ? "ts" : "js"}`
157
+ );
158
+ const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
159
+ const exampleServiceTemplateContent = path.resolve(
160
+ import.meta.dirname,
161
+ "templates",
162
+ "liveQueries",
163
+ "blank",
164
+ "blank.service.ts.template"
165
+ );
166
+ const serviceFile = path.join(
167
+ redwoodPaths.api.services,
168
+ `${name}`,
169
+ `${name}.${isTypeScriptProject() ? "ts" : "js"}`
170
+ );
171
+ const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
172
+ return [
173
+ writeFile(
174
+ sdlFile,
175
+ await generateTemplate(sdlContent, templateVariables(name)),
176
+ {
177
+ overwriteExisting: force
178
+ }
179
+ ),
180
+ writeFile(
181
+ serviceFile,
182
+ await generateTemplate(serviceContent, templateVariables(name)),
183
+ {
184
+ overwriteExisting: force
185
+ }
186
+ )
187
+ ];
188
+ }
189
+ },
190
+ {
191
+ title: `Generating types ...`,
192
+ task: async () => {
193
+ await generateTypes();
194
+ console.log(
195
+ "Note: You may need to manually restart GraphQL in VSCode to see the new types take effect.\n\n"
196
+ );
197
+ }
198
+ }
199
+ ],
200
+ {
201
+ rendererOptions: { collapseSubtasks: false, persistentOutput: true },
202
+ renderer: verbose ? "verbose" : "default"
203
+ }
204
+ );
205
+ try {
206
+ await tasks.run();
207
+ } catch (e) {
208
+ errorTelemetry(process.argv, e.message);
209
+ console.error(c.error(e.message));
210
+ process.exit(e?.exitCode || 1);
211
+ }
212
+ }
213
+ export {
214
+ handler
215
+ };
@@ -0,0 +1,27 @@
1
+ // api/src/graphql/auctions.sdl.ts
2
+
3
+ export const schema = gql`
4
+ type Query {
5
+ ${liveQueryName}(id: ID!): ${typeName} @requireAuth
6
+ }
7
+
8
+ type ${typeName} {
9
+ id: ID!
10
+ title: String!
11
+ largest${typeName}Item: ${typeName}Item
12
+ items: [${typeName}Item!]!
13
+ }
14
+
15
+ type ${typeName}Item {
16
+ amount: Int!
17
+ }
18
+
19
+ type Mutation {
20
+ create${typeName}Item(input: ${typeName}ItemInput!): ${typeName}Item @requireAuth
21
+ }
22
+
23
+ input ${typeName}ItemInput {
24
+ ${camelName}Id: ID!
25
+ amount: Int!
26
+ }
27
+ `
@@ -0,0 +1,73 @@
1
+ // api/src/services/${name}s/${name}s.ts
2
+ import type { LiveQueryStorageMechanism } from '@cedarjs/realtime'
3
+
4
+ import { logger } from 'src/lib/logger'
5
+
6
+ const ${collectionName} = [
7
+ { id: '1', title: 'First ${modelName}', items: [{ amount: 11 }] },
8
+ { id: '2', title: '2nd ${modelName}', items: [{ amount: 22 }] },
9
+ { id: '3', title: 'Third ${modelName}', items: [{ amount: 33 }] },
10
+ { id: '4', title: '4th ${modelName}', items: [{ amount: 44 }] },
11
+ { id: '5', title: 'Fifth ${modelName}', items: [{ amount: 55 }] },
12
+ ]
13
+
14
+ /**
15
+ * To test this live query, run the following in the GraphQL Playground:
16
+ *
17
+ * query GetRecent${pluralPascalName} @live {
18
+ * ${liveQueryName}(id: "1") {
19
+ * items {
20
+ * amount
21
+ * }
22
+ * largest${typeName}Item {
23
+ * amount
24
+ * }
25
+ * id
26
+ * title
27
+ * }
28
+ * }
29
+ *
30
+ * And then make a related item with the following mutation:
31
+ *
32
+ * mutation Create${typeName}Item {
33
+ * create${typeName}Item(input: {${camelName}Id: "1", amount: 100}) {
34
+ * amount
35
+ * }
36
+ * }
37
+ */
38
+ export const ${liveQueryName} = async ({ id }) => {
39
+ const found${modelName} = ${collectionName}.find((a) => a.id === id)
40
+ logger.debug({ id, ${name}: found${modelName} }, `${name} details`)
41
+ return found${modelName}
42
+ }
43
+
44
+ export const create${typeName}Item = async (
45
+ { input },
46
+ { context }: { context: { liveQueryStore: LiveQueryStorageMechanism } }
47
+ ) => {
48
+ const { ${camelName}Id, amount } = input
49
+
50
+ const index = ${collectionName}.findIndex((a) => a.id === ${camelName}Id)
51
+
52
+ const item = { amount }
53
+
54
+ ${collectionName}[index].items.push(item)
55
+ logger.debug({ ${camelName}Id, item }, 'Added item to ${collectionName}')
56
+
57
+ const key = `${typeName}:<%= '$' %>{${camelName}Id}`
58
+ context.liveQueryStore.invalidate(key)
59
+
60
+ logger.debug({ key }, 'Invalidated ${typeName} key in liveQueryStore')
61
+
62
+ return item
63
+ }
64
+
65
+ export const ${modelName} = {
66
+ largest${typeName}Item: (obj, { root }) => {
67
+ const [largest] = root.items.sort((a, b) => b.amount - a.amount)
68
+
69
+ logger.debug({ obj, root }, 'largest ${typeName}Item')
70
+
71
+ return largest
72
+ },
73
+ }
@@ -0,0 +1,42 @@
1
+ import { RedwoodRealtimeOptions } from '@cedarjs/realtime'
2
+
3
+ import subscriptions from 'src/subscriptions/**/*.{js,ts}'
4
+
5
+ // if using a Redis store
6
+ // import { Redis } from 'ioredis'
7
+ // const publishClient = new Redis()
8
+ // const subscribeClient = new Redis()
9
+
10
+ /**
11
+ * Configure RedwoodJS Realtime
12
+ *
13
+ * See https://redwoodjs.com/docs/realtime
14
+ *
15
+ * Realtime supports Live Queries and Subscriptions over GraphQL SSE.
16
+ *
17
+ * Live Queries are GraphQL queries that are automatically re-run when the data they depend on changes.
18
+ *
19
+ * Subscriptions are GraphQL queries that are run when a client subscribes to a channel.
20
+ *
21
+ * Redwood Realtime
22
+ * - uses a publish/subscribe model to broadcast data to clients.
23
+ * - uses a store to persist Live Query and Subscription data.
24
+ *
25
+ * Redwood Realtime supports in-memory and Redis stores:
26
+ * - In-memory stores are useful for development and testing.
27
+ * - Redis stores are useful for production.
28
+ *
29
+ */
30
+ export const realtime: RedwoodRealtimeOptions = {
31
+ subscriptions: {
32
+ subscriptions,
33
+ store: 'in-memory',
34
+ // if using a Redis store
35
+ // store: { redis: { publishClient, subscribeClient } },
36
+ },
37
+ liveQueries: {
38
+ store: 'in-memory',
39
+ // if using a Redis store
40
+ // store: { redis: { publishClient, subscribeClient } },
41
+ },
42
+ }
@@ -0,0 +1,20 @@
1
+ export const schema = gql`
2
+ type ${typeName} {
3
+ from: String
4
+ body: String
5
+ }
6
+
7
+ type Query {
8
+ ${subscriptionQueryName}(id: ID!): [${typeName}!]! @skipAuth
9
+ }
10
+
11
+ input ${subscriptionInputType} {
12
+ id: ID!
13
+ from: String!
14
+ body: String!
15
+ }
16
+
17
+ type Mutation {
18
+ ${subscriptionServiceResolver}(input: ${subscriptionInputType}!): ${typeName}! @skipAuth
19
+ }
20
+ `
@@ -0,0 +1,19 @@
1
+ import type { ${subscriptionInputType} } from 'types/graphql'
2
+
3
+ import { logger } from 'src/lib/logger'
4
+ import type { Publish${typeName}ChannelType } from 'src/subscriptions/${name}/${name}'
5
+
6
+ export const ${subscriptionQueryName} = ({ id }) => [id]
7
+
8
+ export const ${subscriptionServiceResolver} = async (
9
+ { input }: { input: ${subscriptionInputType} },
10
+ { context }: { context: { pubSub: Publish${typeName}ChannelType } }
11
+ ) => {
12
+ logger.debug({ input }, 'publishing ${name} ....')
13
+
14
+ const { id, from, body } = input
15
+
16
+ context.pubSub.publish('${typeName}', id, { from, body })
17
+
18
+ return input
19
+ }
@@ -0,0 +1,58 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ import type { PubSub } from '@cedarjs/realtime'
4
+
5
+ import { logger } from 'src/lib/logger'
6
+
7
+ export const schema = gql`
8
+ type Subscription {
9
+ ${subscriptionName}(id: ID!): ${typeName}! @requireAuth
10
+ }
11
+ `
12
+
13
+ export type Publish${typeName}Channel = {
14
+ ${typeName}: [id: string, payload: { from: string; body: string }]
15
+ }
16
+
17
+ export type Publish${typeName}ChannelType = PubSub<Publish${typeName}Channel>
18
+
19
+ /**
20
+ * To test this ${typeName} subscription, run the following in one GraphQL Playground to subscribe:
21
+ *
22
+ * subscription ListenTo${channelName} {
23
+ * ${subscriptionName}(id: "1") {
24
+ * body
25
+ * from
26
+ * }
27
+ * }
28
+ *
29
+ *
30
+ * And run the following in another GraphQL Playground to publish and send a new ${name} to the channel:
31
+ *
32
+ * mutation PublishTo${channelName} {
33
+ * ${subscriptionServiceResolver}(input: {id: "1", from: "hello", body: "bob"}) {
34
+ * body
35
+ * from
36
+ * }
37
+ * }
38
+ */
39
+ const ${subscriptionName}Subscription = {
40
+ ${subscriptionName}: {
41
+ subscribe: (
42
+ _,
43
+ { id },
44
+ { pubSub }: { pubSub: Publish${typeName}ChannelType }
45
+ ) => {
46
+ logger.debug({ id }, '${name} subscription')
47
+
48
+ return pubSub.subscribe('${typeName}', id)
49
+ },
50
+ resolve: (payload) => {
51
+ logger.debug({ payload }, '${name} subscription resolve')
52
+
53
+ return payload
54
+ },
55
+ },
56
+ }
57
+
58
+ export default ${subscriptionName}Subscription
@@ -0,0 +1,38 @@
1
+ import terminalLink from "terminal-link";
2
+ import { createHandler, getYargsDefaults } from "../yargsCommandHelpers.js";
3
+ const command = "scaffold <model>";
4
+ const description = "Generate Pages, SDL, and Services files based on a given DB schema Model. Also accepts <path/model>";
5
+ const builder = (yargs) => {
6
+ yargs.positional("model", {
7
+ description: "Model to scaffold. You can also use <path/model> to nest files by type at the given path directory (or directories). For example, 'rw g scaffold admin/post'"
8
+ }).option("docs", {
9
+ description: "Generate SDL and GraphQL comments to use in documentation",
10
+ type: "boolean",
11
+ default: false
12
+ }).option("tests", {
13
+ description: "Generate test files",
14
+ type: "boolean"
15
+ }).option("tailwind", {
16
+ description: "Generate TailwindCSS version of scaffold.css (automatically set to `true` if TailwindCSS config exists)",
17
+ type: "boolean"
18
+ }).option("rollback", {
19
+ description: "Revert all generator actions if an error occurs",
20
+ type: "boolean",
21
+ default: true
22
+ }).epilogue(
23
+ `Also see the ${terminalLink(
24
+ "Redwood CLI Reference",
25
+ "https://redwoodjs.com/docs/cli-commands#generate-scaffold"
26
+ )}`
27
+ );
28
+ Object.entries(getYargsDefaults()).forEach(([option, config]) => {
29
+ yargs.option(option, config);
30
+ });
31
+ };
32
+ const handler = createHandler("scaffold");
33
+ export {
34
+ builder,
35
+ command,
36
+ description,
37
+ handler
38
+ };