@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.
- package/LICENSE +21 -0
- package/README.md +706 -0
- package/dist/commands/build.js +54 -0
- package/dist/commands/buildHandler.js +134 -0
- package/dist/commands/check.js +28 -0
- package/dist/commands/console.js +13 -0
- package/dist/commands/consoleHandler.js +68 -0
- package/dist/commands/deploy/baremetal/SshExecutor.js +41 -0
- package/dist/commands/deploy/baremetal/baremetalHandler.js +558 -0
- package/dist/commands/deploy/baremetal.js +89 -0
- package/dist/commands/deploy/flightcontrol.js +40 -0
- package/dist/commands/deploy/flightcontrolHandler.js +58 -0
- package/dist/commands/deploy/helpers/deployBuilder.js +25 -0
- package/dist/commands/deploy/helpers/deployHandler.js +31 -0
- package/dist/commands/deploy/netlify.js +21 -0
- package/dist/commands/deploy/packing/nft.js +61 -0
- package/dist/commands/deploy/render.js +37 -0
- package/dist/commands/deploy/renderHandler.js +70 -0
- package/dist/commands/deploy/serverless.js +51 -0
- package/dist/commands/deploy/serverlessHandler.js +211 -0
- package/dist/commands/deploy/vercel.js +21 -0
- package/dist/commands/deploy.js +21 -0
- package/dist/commands/destroy/cell/cell.js +12 -0
- package/dist/commands/destroy/cell/cellHandler.js +10 -0
- package/dist/commands/destroy/component/component.js +15 -0
- package/dist/commands/destroy/component/componentHandler.js +10 -0
- package/dist/commands/destroy/directive/directive.js +14 -0
- package/dist/commands/destroy/directive/directiveHandler.js +12 -0
- package/dist/commands/destroy/function/function.js +20 -0
- package/dist/commands/destroy/function/functionHandler.js +10 -0
- package/dist/commands/destroy/handlerHelpers.js +34 -0
- package/dist/commands/destroy/helpers.js +22 -0
- package/dist/commands/destroy/layout/layout.js +12 -0
- package/dist/commands/destroy/layout/layoutHandler.js +10 -0
- package/dist/commands/destroy/page/page.js +20 -0
- package/dist/commands/destroy/page/pageHandler.js +51 -0
- package/dist/commands/destroy/scaffold/scaffold.js +16 -0
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +105 -0
- package/dist/commands/destroy/sdl/sdl.js +16 -0
- package/dist/commands/destroy/sdl/sdlHandler.js +33 -0
- package/dist/commands/destroy/service/service.js +10 -0
- package/dist/commands/destroy/service/serviceHandler.js +17 -0
- package/dist/commands/destroy.js +25 -0
- package/dist/commands/dev.js +47 -0
- package/dist/commands/devHandler.js +202 -0
- package/dist/commands/exec.js +38 -0
- package/dist/commands/execHandler.js +180 -0
- package/dist/commands/experimental/setupInngest.js +28 -0
- package/dist/commands/experimental/setupInngestHandler.js +46 -0
- package/dist/commands/experimental/setupOpentelemetry.js +34 -0
- package/dist/commands/experimental/setupOpentelemetryHandler.js +215 -0
- package/dist/commands/experimental/setupReactCompiler.js +28 -0
- package/dist/commands/experimental/setupReactCompilerHandler.js +124 -0
- package/dist/commands/experimental/setupRsc.js +28 -0
- package/dist/commands/experimental/setupRscHandler.js +408 -0
- package/dist/commands/experimental/setupStreamingSsr.js +28 -0
- package/dist/commands/experimental/setupStreamingSsrHandler.js +208 -0
- package/dist/commands/experimental/templates/opentelemetry.ts.template +55 -0
- package/dist/commands/experimental/templates/rsc/AboutCounter.tsx.template +20 -0
- package/dist/commands/experimental/templates/rsc/AboutPage.css.template +2 -0
- package/dist/commands/experimental/templates/rsc/AboutPage.tsx.template +17 -0
- package/dist/commands/experimental/templates/rsc/Counter.css.template +7 -0
- package/dist/commands/experimental/templates/rsc/Counter.module.css.template +3 -0
- package/dist/commands/experimental/templates/rsc/Counter.tsx.template +18 -0
- package/dist/commands/experimental/templates/rsc/Document.tsx.template +27 -0
- package/dist/commands/experimental/templates/rsc/HomePage.css.template +2 -0
- package/dist/commands/experimental/templates/rsc/HomePage.module.css.template +3 -0
- package/dist/commands/experimental/templates/rsc/HomePage.tsx.template +19 -0
- package/dist/commands/experimental/templates/rsc/NavigationLayout.css.template +32 -0
- package/dist/commands/experimental/templates/rsc/NavigationLayout.tsx.template +31 -0
- package/dist/commands/experimental/templates/rsc/Routes.tsx.template +29 -0
- package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +35 -0
- package/dist/commands/experimental/templates/rsc/entry.server.tsx.template +20 -0
- package/dist/commands/experimental/templates/rsc/index.css.template +4 -0
- package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +27 -0
- package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +40 -0
- package/dist/commands/experimental/templates/streamingSsr/entry.server.tsx.template +20 -0
- package/dist/commands/experimental/templates/streamingSsr/tsconfig.json.template +54 -0
- package/dist/commands/experimental/util.js +69 -0
- package/dist/commands/experimental.js +22 -0
- package/dist/commands/generate/cell/cell.js +35 -0
- package/dist/commands/generate/cell/cellHandler.js +153 -0
- package/dist/commands/generate/cell/templates/cell.tsx.template +34 -0
- package/dist/commands/generate/cell/templates/cellList.tsx.template +40 -0
- package/dist/commands/generate/cell/templates/mock.ts.template +7 -0
- package/dist/commands/generate/cell/templates/mockList.ts.template +14 -0
- package/dist/commands/generate/cell/templates/stories.tsx.template +35 -0
- package/dist/commands/generate/cell/templates/test.js.template +42 -0
- package/dist/commands/generate/cell/utils/utils.js +43 -0
- package/dist/commands/generate/component/component.js +15 -0
- package/dist/commands/generate/component/componentHandler.js +55 -0
- package/dist/commands/generate/component/templates/component.tsx.template +10 -0
- package/dist/commands/generate/component/templates/stories.jsx.template +17 -0
- package/dist/commands/generate/component/templates/stories.tsx.template +26 -0
- package/dist/commands/generate/component/templates/test.tsx.template +14 -0
- package/dist/commands/generate/dataMigration/dataMigration.js +105 -0
- package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +7 -0
- package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +5 -0
- package/dist/commands/generate/dbAuth/dbAuth.js +55 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +375 -0
- package/dist/commands/generate/dbAuth/templates/forgotPassword.tsx.template +94 -0
- package/dist/commands/generate/dbAuth/templates/login.tsx.template +130 -0
- package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +264 -0
- package/dist/commands/generate/dbAuth/templates/resetPassword.tsx.template +121 -0
- package/dist/commands/generate/dbAuth/templates/signup.tsx.template +123 -0
- package/dist/commands/generate/directive/directive.js +15 -0
- package/dist/commands/generate/directive/directiveHandler.js +159 -0
- package/dist/commands/generate/directive/templates/transformer.directive.test.ts.template +18 -0
- package/dist/commands/generate/directive/templates/transformer.directive.ts.template +38 -0
- package/dist/commands/generate/directive/templates/validator.directive.test.ts.template +17 -0
- package/dist/commands/generate/directive/templates/validator.directive.ts.template +39 -0
- package/dist/commands/generate/function/function.js +29 -0
- package/dist/commands/generate/function/functionHandler.js +131 -0
- package/dist/commands/generate/function/templates/function.ts.template +33 -0
- package/dist/commands/generate/function/templates/scenarios.ts.template +8 -0
- package/dist/commands/generate/function/templates/test.ts.template +30 -0
- package/dist/commands/generate/helpers.js +71 -0
- package/dist/commands/generate/job/job.js +39 -0
- package/dist/commands/generate/job/jobHandler.js +138 -0
- package/dist/commands/generate/job/templates/job.ts.template +8 -0
- package/dist/commands/generate/job/templates/scenarios.ts.template +8 -0
- package/dist/commands/generate/job/templates/test.ts.template +7 -0
- package/dist/commands/generate/layout/layout.js +25 -0
- package/dist/commands/generate/layout/layoutHandler.js +59 -0
- package/dist/commands/generate/layout/templates/layout.tsx.a11y.template +27 -0
- package/dist/commands/generate/layout/templates/layout.tsx.template +9 -0
- package/dist/commands/generate/layout/templates/stories.tsx.template +13 -0
- package/dist/commands/generate/layout/templates/test.tsx.template +14 -0
- package/dist/commands/generate/model/model.js +29 -0
- package/dist/commands/generate/model/modelHandler.js +63 -0
- package/dist/commands/generate/model/templates/model.js.template +3 -0
- package/dist/commands/generate/ogImage/ogImage.js +43 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +111 -0
- package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +13 -0
- package/dist/commands/generate/page/page.js +22 -0
- package/dist/commands/generate/page/pageHandler.js +227 -0
- package/dist/commands/generate/page/templates/page.tsx.template +35 -0
- package/dist/commands/generate/page/templates/stories.tsx.parameters.template +13 -0
- package/dist/commands/generate/page/templates/stories.tsx.template +13 -0
- package/dist/commands/generate/page/templates/test.tsx.template +14 -0
- package/dist/commands/generate/realtime/realtime.js +41 -0
- package/dist/commands/generate/realtime/realtimeHandler.js +215 -0
- package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.sdl.ts.template +27 -0
- package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +73 -0
- package/dist/commands/generate/realtime/templates/realtime.ts.template +42 -0
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.sdl.ts.template +20 -0
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +19 -0
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +58 -0
- package/dist/commands/generate/scaffold/scaffold.js +38 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +663 -0
- package/dist/commands/generate/scaffold/templates/assets/scaffold.css.template +398 -0
- package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +243 -0
- package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +74 -0
- package/dist/commands/generate/scaffold/templates/components/Name.tsx.template +79 -0
- package/dist/commands/generate/scaffold/templates/components/NameCell.tsx.template +32 -0
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +123 -0
- package/dist/commands/generate/scaffold/templates/components/Names.tsx.template +88 -0
- package/dist/commands/generate/scaffold/templates/components/NamesCell.tsx.template +45 -0
- package/dist/commands/generate/scaffold/templates/components/NewName.tsx.template +55 -0
- package/dist/commands/generate/scaffold/templates/layouts/ScaffoldLayout.tsx.template +37 -0
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +192 -0
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +58 -0
- package/dist/commands/generate/scaffold/templates/pages/EditNamePage.tsx.template +11 -0
- package/dist/commands/generate/scaffold/templates/pages/NamePage.tsx.template +11 -0
- package/dist/commands/generate/scaffold/templates/pages/NamesPage.tsx.template +7 -0
- package/dist/commands/generate/scaffold/templates/pages/NewNamePage.tsx.template +7 -0
- package/dist/commands/generate/script/script.js +29 -0
- package/dist/commands/generate/script/scriptHandler.js +85 -0
- package/dist/commands/generate/script/templates/script.ts.template +15 -0
- package/dist/commands/generate/script/templates/tsconfig.json.template +33 -0
- package/dist/commands/generate/sdl/sdl.js +48 -0
- package/dist/commands/generate/sdl/sdlHandler.js +282 -0
- package/dist/commands/generate/sdl/templates/sdl.js.template +70 -0
- package/dist/commands/generate/sdl/templates/sdl.ts.template +70 -0
- package/dist/commands/generate/secret/secret.js +52 -0
- package/dist/commands/generate/service/service.js +50 -0
- package/dist/commands/generate/service/serviceHandler.js +301 -0
- package/dist/commands/generate/service/templates/scenarios.ts.template +7 -0
- package/dist/commands/generate/service/templates/service.ts.template +38 -0
- package/dist/commands/generate/service/templates/test.ts.template +84 -0
- package/dist/commands/generate/yargsCommandHelpers.js +77 -0
- package/dist/commands/generate/yargsHandlerHelpers.js +155 -0
- package/dist/commands/generate.js +44 -0
- package/dist/commands/info.js +36 -0
- package/dist/commands/jobs.js +17 -0
- package/dist/commands/jobsHandler.js +30 -0
- package/dist/commands/lint.js +57 -0
- package/dist/commands/prerender.js +34 -0
- package/dist/commands/prerenderHandler.js +282 -0
- package/dist/commands/prisma.js +17 -0
- package/dist/commands/prismaHandler.js +90 -0
- package/dist/commands/record/init.js +11 -0
- package/dist/commands/record.js +19 -0
- package/dist/commands/serve.js +139 -0
- package/dist/commands/serveApiHandler.js +15 -0
- package/dist/commands/serveBothHandler.js +95 -0
- package/dist/commands/serveWebHandler.js +17 -0
- package/dist/commands/setup/auth/auth.js +265 -0
- package/dist/commands/setup/cache/cache.js +37 -0
- package/dist/commands/setup/cache/cacheHandler.js +69 -0
- package/dist/commands/setup/cache/templates/memcached.ts.template +30 -0
- package/dist/commands/setup/cache/templates/redis.ts.template +24 -0
- package/dist/commands/setup/deploy/deploy.js +26 -0
- package/dist/commands/setup/deploy/helpers/helpers.js +9 -0
- package/dist/commands/setup/deploy/helpers/index.js +110 -0
- package/dist/commands/setup/deploy/providers/baremetal.js +9 -0
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +64 -0
- package/dist/commands/setup/deploy/providers/coherence.js +24 -0
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +203 -0
- package/dist/commands/setup/deploy/providers/flightcontrol.js +19 -0
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +294 -0
- package/dist/commands/setup/deploy/providers/netlify.js +9 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +42 -0
- package/dist/commands/setup/deploy/providers/render.js +17 -0
- package/dist/commands/setup/deploy/providers/renderHandler.js +111 -0
- package/dist/commands/setup/deploy/providers/serverless.js +11 -0
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +141 -0
- package/dist/commands/setup/deploy/providers/vercel.js +9 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +56 -0
- package/dist/commands/setup/deploy/templates/baremetal.js +128 -0
- package/dist/commands/setup/deploy/templates/flightcontrol.js +85 -0
- package/dist/commands/setup/deploy/templates/netlify.js +32 -0
- package/dist/commands/setup/deploy/templates/render.js +72 -0
- package/dist/commands/setup/deploy/templates/serverless/api.js +78 -0
- package/dist/commands/setup/deploy/templates/serverless/web.js +32 -0
- package/dist/commands/setup/docker/docker.js +26 -0
- package/dist/commands/setup/docker/dockerHandler.js +265 -0
- package/dist/commands/setup/docker/templates/Dockerfile +154 -0
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +58 -0
- package/dist/commands/setup/docker/templates/docker-compose.prod.yml +63 -0
- package/dist/commands/setup/docker/templates/dockerignore +18 -0
- package/dist/commands/setup/generator/generator.js +49 -0
- package/dist/commands/setup/generator/generatorHandler.js +55 -0
- package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +117 -0
- package/dist/commands/setup/graphql/features/fragments/appImportTransform.js +20 -0
- package/dist/commands/setup/graphql/features/fragments/fragments.js +25 -0
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +89 -0
- package/dist/commands/setup/graphql/features/trustedDocuments/graphqlTransform.js +51 -0
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +25 -0
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +74 -0
- package/dist/commands/setup/graphql/graphql.js +18 -0
- package/dist/commands/setup/i18n/i18n.js +25 -0
- package/dist/commands/setup/i18n/i18nHandler.js +169 -0
- package/dist/commands/setup/i18n/templates/en.json.template +11 -0
- package/dist/commands/setup/i18n/templates/fr.json.template +11 -0
- package/dist/commands/setup/i18n/templates/i18n.js.template +52 -0
- package/dist/commands/setup/i18n/templates/storybook.preview.tsx.template +43 -0
- package/dist/commands/setup/jobs/jobs.js +31 -0
- package/dist/commands/setup/jobs/jobsHandler.js +122 -0
- package/dist/commands/setup/jobs/templates/jobs.ts.template +32 -0
- package/dist/commands/setup/mailer/mailer.js +30 -0
- package/dist/commands/setup/mailer/mailerHandler.js +106 -0
- package/dist/commands/setup/mailer/templates/mailer.ts.template +30 -0
- package/dist/commands/setup/mailer/templates/re-example.tsx.template +40 -0
- package/dist/commands/setup/middleware/middleware.js +17 -0
- package/dist/commands/setup/middleware/ogImage/__codemod_tests__/middleware.js +15 -0
- package/dist/commands/setup/middleware/ogImage/__codemod_tests__/vitePlugin.js +6 -0
- package/dist/commands/setup/middleware/ogImage/codemodMiddleware.js +97 -0
- package/dist/commands/setup/middleware/ogImage/codemodVitePlugin.js +65 -0
- package/dist/commands/setup/middleware/ogImage/ogImage.js +27 -0
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +121 -0
- package/dist/commands/setup/monitoring/monitoring.js +17 -0
- package/dist/commands/setup/monitoring/sentry/sentry.js +25 -0
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +163 -0
- package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +15 -0
- package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +31 -0
- package/dist/commands/setup/package/package.js +33 -0
- package/dist/commands/setup/package/packageHandler.js +134 -0
- package/dist/commands/setup/realtime/realtime.js +37 -0
- package/dist/commands/setup/realtime/realtimeHandler.js +309 -0
- package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.sdl.template +14 -0
- package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +14 -0
- package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.sdl.ts.template +27 -0
- package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +73 -0
- package/dist/commands/setup/realtime/templates/realtime.ts.template +46 -0
- package/dist/commands/setup/realtime/templates/stream/alphabet/alphabet.sdl.template +9 -0
- package/dist/commands/setup/realtime/templates/stream/alphabet/alphabet.ts.template +31 -0
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +58 -0
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +57 -0
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/rooms.sdl.ts.template +20 -0
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/rooms.ts.template +20 -0
- package/dist/commands/setup/server-file/serverFile.js +31 -0
- package/dist/commands/setup/server-file/serverFileHandler.js +56 -0
- package/dist/commands/setup/server-file/templates/server.ts.template +13 -0
- package/dist/commands/setup/tsconfig/tsconfig.js +25 -0
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +59 -0
- package/dist/commands/setup/ui/helpers/helpers.js +9 -0
- package/dist/commands/setup/ui/libraries/chakra-ui.js +24 -0
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +98 -0
- package/dist/commands/setup/ui/libraries/mantine.js +32 -0
- package/dist/commands/setup/ui/libraries/mantineHandler.js +138 -0
- package/dist/commands/setup/ui/libraries/tailwindcss.js +26 -0
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +386 -0
- package/dist/commands/setup/ui/templates/chakra.storybook.preview.tsx.template +20 -0
- package/dist/commands/setup/ui/templates/mantine-postcss.config.js.template +35 -0
- package/dist/commands/setup/ui/templates/mantine.storybook.preview.tsx.template +18 -0
- package/dist/commands/setup/ui/templates/postcss.config.js.template +9 -0
- package/dist/commands/setup/ui/ui.js +17 -0
- package/dist/commands/setup/uploads/dbCodemod.js +28 -0
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +21 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +25 -0
- package/dist/commands/setup/uploads/uploads.js +26 -0
- package/dist/commands/setup/uploads/uploadsHandler.js +147 -0
- package/dist/commands/setup/vite/templates/vite.config.ts.template +19 -0
- package/dist/commands/setup/vite/vite.js +38 -0
- package/dist/commands/setup/vite/viteHandler.js +83 -0
- package/dist/commands/setup.js +33 -0
- package/dist/commands/studio.js +23 -0
- package/dist/commands/studioHandler.js +61 -0
- package/dist/commands/test.js +44 -0
- package/dist/commands/testHandler.js +138 -0
- package/dist/commands/ts-to-js.js +20 -0
- package/dist/commands/type-check.js +41 -0
- package/dist/commands/type-checkHandler.js +71 -0
- package/dist/commands/upgrade.js +441 -0
- package/dist/index.d.js +0 -0
- package/dist/index.js +146 -0
- package/dist/lib/background.js +45 -0
- package/dist/lib/colors.js +18 -0
- package/dist/lib/configureStorybook.js +50 -0
- package/dist/lib/exec.js +85 -0
- package/dist/lib/exit.js +44 -0
- package/dist/lib/extendFile.js +114 -0
- package/dist/lib/generatePrismaClient.js +60 -0
- package/dist/lib/index.js +485 -0
- package/dist/lib/loadEnvFiles.js +12 -0
- package/dist/lib/locking.js +60 -0
- package/dist/lib/merge/algorithms.js +30 -0
- package/dist/lib/merge/index.js +163 -0
- package/dist/lib/merge/semanticIdentity.js +18 -0
- package/dist/lib/merge/strategy.js +136 -0
- package/dist/lib/mockTelemetry.js +7 -0
- package/dist/lib/packages.js +77 -0
- package/dist/lib/plugin.js +206 -0
- package/dist/lib/pluralHelpers.js +50 -0
- package/dist/lib/ports.js +17 -0
- package/dist/lib/project.js +30 -0
- package/dist/lib/rollback.js +72 -0
- package/dist/lib/runTransform.js +66 -0
- package/dist/lib/rwPluralize.js +56 -0
- package/dist/lib/schemaHelpers.js +95 -0
- package/dist/lib/templates/storybook.preview.tsx.template +19 -0
- package/dist/lib/test.js +106 -0
- package/dist/lib/updateCheck.js +202 -0
- package/dist/lib/updateCheckExecute.js +2 -0
- package/dist/middleware/checkNodeVersion.js +23 -0
- package/dist/middleware/detectProjectRxVersion.js +12 -0
- package/dist/plugin.js +223 -0
- package/dist/rwfw.js +47 -0
- package/dist/telemetry/exporter.js +63 -0
- package/dist/telemetry/index.js +84 -0
- package/dist/telemetry/resource.js +98 -0
- package/dist/telemetry/send.js +80 -0
- package/dist/testLib/cells.js +188 -0
- package/dist/testLib/fetchFileFromTemplate.js +9 -0
- package/dist/testLib/getFilesWithPattern.js +21 -0
- package/dist/testLib/getRootPackageJSON.js +14 -0
- package/dist/testLib/isTSProject.js +9 -0
- package/dist/testLib/runTransform.js +42 -0
- package/package.json +102 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
const command = "exec [name]";
|
|
3
|
+
const description = "Run scripts generated with yarn generate script";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("name", {
|
|
6
|
+
description: "The file name (extension is optional) of the script to run",
|
|
7
|
+
type: "string"
|
|
8
|
+
}).option("prisma", {
|
|
9
|
+
type: "boolean",
|
|
10
|
+
default: true,
|
|
11
|
+
description: "Generate the Prisma client"
|
|
12
|
+
}).option("list", {
|
|
13
|
+
alias: "l",
|
|
14
|
+
type: "boolean",
|
|
15
|
+
default: false,
|
|
16
|
+
description: "List available scripts"
|
|
17
|
+
}).option("silent", {
|
|
18
|
+
alias: "s",
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: false,
|
|
21
|
+
description: "Silence Redwood's output, leaving only the script output"
|
|
22
|
+
}).strict(false).epilogue(
|
|
23
|
+
`Also see the ${terminalLink(
|
|
24
|
+
"Redwood CLI Reference",
|
|
25
|
+
"https://redwoodjs.com/docs/cli-commands#up"
|
|
26
|
+
)}`
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
const handler = async (options) => {
|
|
30
|
+
const { handler: handler2 } = await import("./execHandler.js");
|
|
31
|
+
return handler2(options);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
builder,
|
|
35
|
+
command,
|
|
36
|
+
description,
|
|
37
|
+
handler
|
|
38
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { context } from "@opentelemetry/api";
|
|
4
|
+
import { suppressTracing } from "@opentelemetry/core";
|
|
5
|
+
import { Listr } from "listr2";
|
|
6
|
+
import {
|
|
7
|
+
getWebSideDefaultBabelConfig,
|
|
8
|
+
registerApiSideBabelHook
|
|
9
|
+
} from "@cedarjs/babel-config";
|
|
10
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
11
|
+
import { findScripts } from "@cedarjs/internal/dist/files";
|
|
12
|
+
import c from "../lib/colors.js";
|
|
13
|
+
import { runScriptFunction } from "../lib/exec.js";
|
|
14
|
+
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
15
|
+
import { getPaths } from "../lib/index.js";
|
|
16
|
+
const printAvailableScriptsToConsole = () => {
|
|
17
|
+
const scripts = findScripts(getPaths().scripts).reduce((acc, scriptPath) => {
|
|
18
|
+
const relativePath = path.relative(getPaths().scripts, scriptPath);
|
|
19
|
+
const ext = path.parse(relativePath).ext;
|
|
20
|
+
const pathNoExt = relativePath.slice(0, -ext.length);
|
|
21
|
+
acc[pathNoExt] ||= [];
|
|
22
|
+
acc[pathNoExt].push(relativePath);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
console.log("Available scripts:");
|
|
26
|
+
Object.entries(scripts).forEach(([name, paths]) => {
|
|
27
|
+
if (paths.length > 1) {
|
|
28
|
+
paths.forEach((scriptPath) => {
|
|
29
|
+
console.log(c.info(`- ${scriptPath}`));
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
console.log(c.info(`- ${name}`));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
console.log();
|
|
36
|
+
};
|
|
37
|
+
const handler = async (args) => {
|
|
38
|
+
recordTelemetryAttributes({
|
|
39
|
+
command: "exec",
|
|
40
|
+
prisma: args.prisma,
|
|
41
|
+
list: args.list
|
|
42
|
+
});
|
|
43
|
+
const { name, prisma, list, ...scriptArgs } = args;
|
|
44
|
+
if (list || !name) {
|
|
45
|
+
printAvailableScriptsToConsole();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const {
|
|
49
|
+
overrides: _overrides,
|
|
50
|
+
plugins: webPlugins,
|
|
51
|
+
...otherWebConfig
|
|
52
|
+
} = getWebSideDefaultBabelConfig();
|
|
53
|
+
registerApiSideBabelHook({
|
|
54
|
+
plugins: [
|
|
55
|
+
[
|
|
56
|
+
"babel-plugin-module-resolver",
|
|
57
|
+
{
|
|
58
|
+
alias: {
|
|
59
|
+
$api: getPaths().api.base,
|
|
60
|
+
$web: getPaths().web.base,
|
|
61
|
+
api: getPaths().api.base,
|
|
62
|
+
web: getPaths().web.base
|
|
63
|
+
},
|
|
64
|
+
loglevel: "silent"
|
|
65
|
+
// to silence the unnecessary warnings
|
|
66
|
+
},
|
|
67
|
+
"exec-$side-module-resolver"
|
|
68
|
+
]
|
|
69
|
+
],
|
|
70
|
+
overrides: [
|
|
71
|
+
{
|
|
72
|
+
test: ["./api/"],
|
|
73
|
+
plugins: [
|
|
74
|
+
[
|
|
75
|
+
"babel-plugin-module-resolver",
|
|
76
|
+
{
|
|
77
|
+
alias: {
|
|
78
|
+
src: getPaths().api.src
|
|
79
|
+
},
|
|
80
|
+
loglevel: "silent"
|
|
81
|
+
},
|
|
82
|
+
"exec-api-src-module-resolver"
|
|
83
|
+
]
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
test: ["./web/"],
|
|
88
|
+
plugins: [
|
|
89
|
+
...webPlugins,
|
|
90
|
+
[
|
|
91
|
+
"babel-plugin-module-resolver",
|
|
92
|
+
{
|
|
93
|
+
alias: {
|
|
94
|
+
src: getPaths().web.src
|
|
95
|
+
},
|
|
96
|
+
loglevel: "silent"
|
|
97
|
+
},
|
|
98
|
+
"exec-web-src-module-resolver"
|
|
99
|
+
]
|
|
100
|
+
],
|
|
101
|
+
...otherWebConfig
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
const scriptPath = resolveScriptPath(name);
|
|
106
|
+
if (!scriptPath) {
|
|
107
|
+
console.error(
|
|
108
|
+
c.error(`
|
|
109
|
+
No script called \`${name}\` in the ./scripts folder.
|
|
110
|
+
`)
|
|
111
|
+
);
|
|
112
|
+
printAvailableScriptsToConsole();
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
const scriptTasks = [
|
|
116
|
+
{
|
|
117
|
+
title: "Generating Prisma client",
|
|
118
|
+
enabled: () => prisma,
|
|
119
|
+
task: () => generatePrismaClient({
|
|
120
|
+
force: false,
|
|
121
|
+
verbose: !args.silent,
|
|
122
|
+
silent: args.silent
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
title: "Running script",
|
|
127
|
+
task: async () => {
|
|
128
|
+
try {
|
|
129
|
+
await runScriptFunction({
|
|
130
|
+
path: scriptPath,
|
|
131
|
+
functionName: "default",
|
|
132
|
+
args: { args: scriptArgs }
|
|
133
|
+
});
|
|
134
|
+
} catch (e) {
|
|
135
|
+
console.error(c.error(`Error in script: ${e.message}`));
|
|
136
|
+
throw e;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
const tasks = new Listr(scriptTasks, {
|
|
142
|
+
rendererOptions: { collapseSubtasks: false },
|
|
143
|
+
renderer: args.silent ? "silent" : "verbose"
|
|
144
|
+
});
|
|
145
|
+
await context.with(suppressTracing(context.active()), async () => {
|
|
146
|
+
await tasks.run();
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
function resolveScriptPath(name) {
|
|
150
|
+
const scriptPath = path.join(getPaths().scripts, name);
|
|
151
|
+
if (fs.existsSync(scriptPath)) {
|
|
152
|
+
return scriptPath;
|
|
153
|
+
}
|
|
154
|
+
const extensions = [".js", ".jsx", ".ts", ".tsx"];
|
|
155
|
+
const matches = [];
|
|
156
|
+
for (const extension of extensions) {
|
|
157
|
+
const p = scriptPath + extension;
|
|
158
|
+
if (fs.existsSync(p)) {
|
|
159
|
+
matches.push(p);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (matches.length === 1) {
|
|
163
|
+
return matches[0];
|
|
164
|
+
} else if (matches.length > 1) {
|
|
165
|
+
console.error(
|
|
166
|
+
c.error(
|
|
167
|
+
`
|
|
168
|
+
Multiple scripts found for \`${name}\`. Please specify the extension.`
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
matches.forEach((match) => {
|
|
172
|
+
console.log(c.info(`- ${path.relative(getPaths().scripts, match)}`));
|
|
173
|
+
});
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
handler
|
|
180
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { getEpilogue } from "./util.js";
|
|
3
|
+
const command = "setup-inngest";
|
|
4
|
+
const description = "Setup Inngest for background, scheduled, delayed, multi-step, and fan-out jobs";
|
|
5
|
+
const EXPERIMENTAL_TOPIC_ID = 4866;
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.option("force", {
|
|
8
|
+
alias: "f",
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Overwrite existing configuration",
|
|
11
|
+
type: "boolean"
|
|
12
|
+
}).epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true));
|
|
13
|
+
};
|
|
14
|
+
const handler = async (options) => {
|
|
15
|
+
recordTelemetryAttributes({
|
|
16
|
+
command: "experimental setup-inngest",
|
|
17
|
+
force: options.force
|
|
18
|
+
});
|
|
19
|
+
const { handler: handler2 } = await import("./setupInngestHandler.js");
|
|
20
|
+
return handler2(options);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
EXPERIMENTAL_TOPIC_ID,
|
|
24
|
+
builder,
|
|
25
|
+
command,
|
|
26
|
+
description,
|
|
27
|
+
handler
|
|
28
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { Listr } from "listr2";
|
|
3
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
4
|
+
import c from "../../lib/colors.js";
|
|
5
|
+
import { getPaths } from "../../lib/index.js";
|
|
6
|
+
import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupInngest.js";
|
|
7
|
+
import { printTaskEpilogue } from "./util.js";
|
|
8
|
+
const handler = async ({ force }) => {
|
|
9
|
+
const tasks = new Listr([
|
|
10
|
+
{
|
|
11
|
+
title: `Adding Inngest setup packages for RedwoodJS ...`,
|
|
12
|
+
task: async () => {
|
|
13
|
+
await execa("yarn", ["add", "-D", "inngest-setup-redwoodjs"], {
|
|
14
|
+
cwd: getPaths().base
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
task: async () => {
|
|
20
|
+
const pluginCommands = ["inngest-setup-redwoodjs", "plugin"];
|
|
21
|
+
if (force) {
|
|
22
|
+
pluginCommands.push("--force");
|
|
23
|
+
}
|
|
24
|
+
await execa("yarn", [...pluginCommands], {
|
|
25
|
+
stdout: "inherit",
|
|
26
|
+
cwd: getPaths().base
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
task: () => {
|
|
32
|
+
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]);
|
|
36
|
+
try {
|
|
37
|
+
await tasks.run();
|
|
38
|
+
} catch (e) {
|
|
39
|
+
errorTelemetry(process.argv, e.message);
|
|
40
|
+
console.error(c.error(e.message));
|
|
41
|
+
process.exit(e?.exitCode || 1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
handler
|
|
46
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { getEpilogue } from "./util.js";
|
|
3
|
+
const command = "setup-opentelemetry";
|
|
4
|
+
const description = "Setup OpenTelemetry within the API side";
|
|
5
|
+
const EXPERIMENTAL_TOPIC_ID = 4772;
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.option("force", {
|
|
8
|
+
alias: "f",
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Overwrite existing configuration",
|
|
11
|
+
type: "boolean"
|
|
12
|
+
}).option("verbose", {
|
|
13
|
+
alias: "v",
|
|
14
|
+
default: false,
|
|
15
|
+
description: "Print more logs",
|
|
16
|
+
type: "boolean"
|
|
17
|
+
}).epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true));
|
|
18
|
+
};
|
|
19
|
+
const handler = async (options) => {
|
|
20
|
+
recordTelemetryAttributes({
|
|
21
|
+
command: "experimental setup-opentelemetry",
|
|
22
|
+
force: options.force,
|
|
23
|
+
verbose: options.verbose
|
|
24
|
+
});
|
|
25
|
+
const { handler: handler2 } = await import("./setupOpentelemetryHandler.js");
|
|
26
|
+
return handler2(options);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
EXPERIMENTAL_TOPIC_ID,
|
|
30
|
+
builder,
|
|
31
|
+
command,
|
|
32
|
+
description,
|
|
33
|
+
handler
|
|
34
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
3
|
+
import execa from "execa";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { Listr } from "listr2";
|
|
6
|
+
import { addApiPackages } from "@cedarjs/cli-helpers";
|
|
7
|
+
import { getConfigPath, resolveFile } from "@cedarjs/project-config";
|
|
8
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
|
+
import c from "../../lib/colors.js";
|
|
10
|
+
import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
|
|
11
|
+
import { isTypeScriptProject } from "../../lib/project.js";
|
|
12
|
+
import {
|
|
13
|
+
command,
|
|
14
|
+
description,
|
|
15
|
+
EXPERIMENTAL_TOPIC_ID
|
|
16
|
+
} from "./setupOpentelemetry.js";
|
|
17
|
+
import { printTaskEpilogue } from "./util.js";
|
|
18
|
+
const handler = async ({ force, verbose }) => {
|
|
19
|
+
const ts = isTypeScriptProject();
|
|
20
|
+
const opentelemetryScriptPath = `${getPaths().api.src}/opentelemetry.${ts ? "ts" : "js"}`;
|
|
21
|
+
const opentelemetryPackages = [
|
|
22
|
+
"@opentelemetry/api",
|
|
23
|
+
"@opentelemetry/instrumentation",
|
|
24
|
+
"@opentelemetry/exporter-trace-otlp-http",
|
|
25
|
+
"@opentelemetry/resources",
|
|
26
|
+
"@opentelemetry/sdk-node",
|
|
27
|
+
"@opentelemetry/semantic-conventions",
|
|
28
|
+
"@opentelemetry/instrumentation-http",
|
|
29
|
+
"@opentelemetry/instrumentation-fastify",
|
|
30
|
+
"@prisma/instrumentation"
|
|
31
|
+
];
|
|
32
|
+
const opentelemetryTasks = [
|
|
33
|
+
{
|
|
34
|
+
title: `Adding OpenTelemetry setup files...`,
|
|
35
|
+
task: async () => {
|
|
36
|
+
const setupTemplateContent = fs.readFileSync(
|
|
37
|
+
path.resolve(
|
|
38
|
+
import.meta.dirname,
|
|
39
|
+
"templates",
|
|
40
|
+
"opentelemetry.ts.template"
|
|
41
|
+
),
|
|
42
|
+
"utf-8"
|
|
43
|
+
);
|
|
44
|
+
const setupScriptContent = ts ? setupTemplateContent : await transformTSToJS(opentelemetryScriptPath, setupTemplateContent);
|
|
45
|
+
return [
|
|
46
|
+
writeFile(opentelemetryScriptPath, setupScriptContent, {
|
|
47
|
+
overwriteExisting: force
|
|
48
|
+
})
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Adding config to redwood.toml...",
|
|
54
|
+
task: (_ctx, task) => {
|
|
55
|
+
const redwoodTomlPath = getConfigPath();
|
|
56
|
+
const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
|
|
57
|
+
if (!configContent.includes("[experimental.opentelemetry]")) {
|
|
58
|
+
writeFile(
|
|
59
|
+
redwoodTomlPath,
|
|
60
|
+
configContent.concat(
|
|
61
|
+
`
|
|
62
|
+
[experimental.opentelemetry]
|
|
63
|
+
enabled = true
|
|
64
|
+
wrapApi = true`
|
|
65
|
+
),
|
|
66
|
+
{
|
|
67
|
+
overwriteExisting: true
|
|
68
|
+
// redwood.toml always exists
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
task.skip(
|
|
73
|
+
`The [experimental.opentelemetry] config block already exists in your 'redwood.toml' file.`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: "Notice: GraphQL function update...",
|
|
80
|
+
enabled: () => {
|
|
81
|
+
return fs.existsSync(
|
|
82
|
+
resolveFile(path.join(getPaths().api.functions, "graphql"))
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
task: (_ctx, task) => {
|
|
86
|
+
task.output = [
|
|
87
|
+
"Please add the following to your 'createGraphQLHandler' function options to enable OTel for your graphql",
|
|
88
|
+
"openTelemetryOptions: {",
|
|
89
|
+
" resolvers: true,",
|
|
90
|
+
" result: true,",
|
|
91
|
+
" variables: true,",
|
|
92
|
+
"}",
|
|
93
|
+
"",
|
|
94
|
+
`Which can found at ${c.info(
|
|
95
|
+
path.join(getPaths().api.functions, "graphql")
|
|
96
|
+
)}`
|
|
97
|
+
].join("\n");
|
|
98
|
+
},
|
|
99
|
+
rendererOptions: { persistentOutput: true }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
title: "Notice: GraphQL function update (server file)...",
|
|
103
|
+
enabled: () => {
|
|
104
|
+
return fs.existsSync(
|
|
105
|
+
resolveFile(path.join(getPaths().api.src, "server"))
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
task: (_ctx, task) => {
|
|
109
|
+
task.output = [
|
|
110
|
+
"Please add the following to your 'redwoodFastifyGraphQLServer' plugin options to enable OTel for your graphql",
|
|
111
|
+
"openTelemetryOptions: {",
|
|
112
|
+
" resolvers: true,",
|
|
113
|
+
" result: true,",
|
|
114
|
+
" variables: true,",
|
|
115
|
+
"}",
|
|
116
|
+
"",
|
|
117
|
+
`Which can found at ${c.info(
|
|
118
|
+
path.join(getPaths().api.src, "server")
|
|
119
|
+
)}`
|
|
120
|
+
].join("\n");
|
|
121
|
+
},
|
|
122
|
+
rendererOptions: { persistentOutput: true }
|
|
123
|
+
},
|
|
124
|
+
addApiPackages(opentelemetryPackages)
|
|
125
|
+
];
|
|
126
|
+
const prismaTasks = [
|
|
127
|
+
{
|
|
128
|
+
title: "Setup Prisma OpenTelemetry...",
|
|
129
|
+
task: (_ctx, task) => {
|
|
130
|
+
const schemaPath = path.join(getPaths().api.db, "schema.prisma");
|
|
131
|
+
const schemaContent = fs.readFileSync(schemaPath, {
|
|
132
|
+
encoding: "utf-8",
|
|
133
|
+
flag: "r"
|
|
134
|
+
});
|
|
135
|
+
const clientConfig = schemaContent.slice(
|
|
136
|
+
schemaContent.indexOf("generator client") + "generator client".length,
|
|
137
|
+
schemaContent.indexOf(
|
|
138
|
+
"}",
|
|
139
|
+
schemaContent.indexOf("generator client")
|
|
140
|
+
) + 1
|
|
141
|
+
).trim();
|
|
142
|
+
const previewLineExists = clientConfig.includes("previewFeatures");
|
|
143
|
+
let newSchemaContents = schemaContent;
|
|
144
|
+
if (previewLineExists) {
|
|
145
|
+
task.skip(
|
|
146
|
+
'Please add "tracing" to your previewFeatures in prisma.schema'
|
|
147
|
+
);
|
|
148
|
+
} else {
|
|
149
|
+
const newClientConfig = clientConfig.trim().split("\n");
|
|
150
|
+
newClientConfig.splice(
|
|
151
|
+
newClientConfig.length - 1,
|
|
152
|
+
0,
|
|
153
|
+
'previewFeatures = ["tracing"]'
|
|
154
|
+
);
|
|
155
|
+
newSchemaContents = newSchemaContents.replace(
|
|
156
|
+
clientConfig,
|
|
157
|
+
newClientConfig.join("\n")
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return writeFile(schemaPath, newSchemaContents, {
|
|
161
|
+
overwriteExisting: true
|
|
162
|
+
// We'll likely always already have this file in the project
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title: "Regenerate the Prisma client...",
|
|
168
|
+
task: (_ctx, _task) => {
|
|
169
|
+
return execa(`yarn rw prisma generate`, {
|
|
170
|
+
stdio: "inherit",
|
|
171
|
+
shell: true,
|
|
172
|
+
cwd: getPaths().web.base
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
];
|
|
177
|
+
const tasks = new Listr(
|
|
178
|
+
[
|
|
179
|
+
{
|
|
180
|
+
title: "Confirmation",
|
|
181
|
+
task: async (_ctx, task) => {
|
|
182
|
+
const prompt = task.prompt(ListrEnquirerPromptAdapter);
|
|
183
|
+
const confirmation = await prompt.run({
|
|
184
|
+
type: "Confirm",
|
|
185
|
+
message: "OpenTelemetry support is experimental. Continue?"
|
|
186
|
+
});
|
|
187
|
+
if (!confirmation) {
|
|
188
|
+
throw new Error("User aborted");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
...opentelemetryTasks,
|
|
193
|
+
...prismaTasks,
|
|
194
|
+
{
|
|
195
|
+
task: () => {
|
|
196
|
+
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
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,28 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { getEpilogue } from "./util.js";
|
|
3
|
+
const command = "setup-react-compiler";
|
|
4
|
+
const description = "Enable the experimental React Compiler";
|
|
5
|
+
const EXPERIMENTAL_TOPIC_ID = 7128;
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.option("force", {
|
|
8
|
+
alias: "f",
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Overwrite existing configuration",
|
|
11
|
+
type: "boolean"
|
|
12
|
+
}).epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true));
|
|
13
|
+
};
|
|
14
|
+
const handler = async (options) => {
|
|
15
|
+
recordTelemetryAttributes({
|
|
16
|
+
command: ["experimental", command].join(" "),
|
|
17
|
+
force: options.force
|
|
18
|
+
});
|
|
19
|
+
const { handler: handler2 } = await import("./setupReactCompilerHandler.js");
|
|
20
|
+
return handler2(options);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
EXPERIMENTAL_TOPIC_ID,
|
|
24
|
+
builder,
|
|
25
|
+
command,
|
|
26
|
+
description,
|
|
27
|
+
handler
|
|
28
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import execa from "execa";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import semver from "semver";
|
|
6
|
+
import { getConfigPath } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../../lib/colors.js";
|
|
9
|
+
import { getPaths, writeFile } from "../../lib/index.js";
|
|
10
|
+
import {
|
|
11
|
+
command,
|
|
12
|
+
description,
|
|
13
|
+
EXPERIMENTAL_TOPIC_ID
|
|
14
|
+
} from "./setupReactCompiler.js";
|
|
15
|
+
import { printTaskEpilogue } from "./util.js";
|
|
16
|
+
const handler = async ({ force, verbose }) => {
|
|
17
|
+
const rwPaths = getPaths();
|
|
18
|
+
const redwoodTomlPath = getConfigPath();
|
|
19
|
+
const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
|
|
20
|
+
const tasks = new Listr(
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
title: "Check prerequisites",
|
|
24
|
+
skip: force,
|
|
25
|
+
task: () => {
|
|
26
|
+
if (!rwPaths.web.entryClient || !rwPaths.web.viteConfig) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"Vite needs to be setup before you can enable React Compiler"
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const webPkgJson = fs.readJSONSync(
|
|
32
|
+
path.join(rwPaths.web.base, "package.json")
|
|
33
|
+
);
|
|
34
|
+
const reactVersion = webPkgJson["dependencies"]["react"];
|
|
35
|
+
const coercedReactVersion = semver.coerce(reactVersion);
|
|
36
|
+
if (!semver.gte(coercedReactVersion, "19.0.0")) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"You need to be using at least React version 19 to enable the React Compiler"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: "Adding config to redwood.toml...",
|
|
45
|
+
task: (_ctx, task) => {
|
|
46
|
+
if (!configContent.includes("[experimental.reactCompiler]")) {
|
|
47
|
+
writeFile(
|
|
48
|
+
redwoodTomlPath,
|
|
49
|
+
configContent.concat(
|
|
50
|
+
"\n[experimental.reactCompiler]\n enabled = true\n lintOnly = false\n"
|
|
51
|
+
),
|
|
52
|
+
{
|
|
53
|
+
overwriteExisting: true
|
|
54
|
+
// redwood.toml always exists
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
if (force) {
|
|
59
|
+
task.output = "Overwriting config in redwood.toml";
|
|
60
|
+
writeFile(
|
|
61
|
+
redwoodTomlPath,
|
|
62
|
+
configContent.replace(
|
|
63
|
+
// Enable if it's currently disabled
|
|
64
|
+
"\n[experimental.reactCompiler]\n enabled = false\n",
|
|
65
|
+
"\n[experimental.reactCompiler]\n enabled = true\n"
|
|
66
|
+
),
|
|
67
|
+
{
|
|
68
|
+
overwriteExisting: true
|
|
69
|
+
// redwood.toml always exists
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
task.skip(
|
|
74
|
+
"The [experimental.reactCompiler] config block already exists in your `redwood.toml` file."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
rendererOptions: { persistentOutput: true }
|
|
80
|
+
},
|
|
81
|
+
// We are using two different yarn commands here which is fine because they're operating on different
|
|
82
|
+
// workspaces - web and the root
|
|
83
|
+
{
|
|
84
|
+
title: "Installing eslint-plugin-react-compiler",
|
|
85
|
+
task: async () => {
|
|
86
|
+
await execa("yarn", ["add", "-D", "eslint-plugin-react-compiler"], {
|
|
87
|
+
cwd: getPaths().base
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
title: "Installing babel-plugin-react-compiler",
|
|
93
|
+
task: async () => {
|
|
94
|
+
await execa(
|
|
95
|
+
"yarn",
|
|
96
|
+
["web/", "add", "-D", "babel-plugin-react-compiler"],
|
|
97
|
+
{
|
|
98
|
+
cwd: getPaths().base
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
task: () => {
|
|
105
|
+
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
{
|
|
110
|
+
rendererOptions: { collapseSubtasks: false, persistentOutput: true },
|
|
111
|
+
renderer: verbose ? "verbose" : "default"
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
try {
|
|
115
|
+
await tasks.run();
|
|
116
|
+
} catch (e) {
|
|
117
|
+
errorTelemetry(process.argv, e.message);
|
|
118
|
+
console.error(c.error(e.message));
|
|
119
|
+
process.exit(e?.exitCode || 1);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
handler
|
|
124
|
+
};
|