@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,90 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import boxen from "boxen";
|
|
3
|
+
import execa from "execa";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
|
+
import c from "../lib/colors.js";
|
|
8
|
+
import { getPaths } from "../lib/index.js";
|
|
9
|
+
const handler = async ({ _, $0, commands = [], ...options }) => {
|
|
10
|
+
recordTelemetryAttributes({
|
|
11
|
+
command: "prisma"
|
|
12
|
+
});
|
|
13
|
+
const rwjsPaths = getPaths();
|
|
14
|
+
const helpIndex = commands.indexOf("help");
|
|
15
|
+
if (helpIndex !== -1) {
|
|
16
|
+
options.help = true;
|
|
17
|
+
commands.splice(helpIndex, 1);
|
|
18
|
+
}
|
|
19
|
+
const hasHelpOption = options.help || options.h;
|
|
20
|
+
if (!hasHelpOption) {
|
|
21
|
+
if (["generate", "introspect", "db", "migrate", "studio", "format"].includes(
|
|
22
|
+
commands[0]
|
|
23
|
+
)) {
|
|
24
|
+
const schemaDir = path.dirname(rwjsPaths.api.dbSchema);
|
|
25
|
+
if (!fs.existsSync(rwjsPaths.api.dbSchema) && !fs.existsSync(schemaDir)) {
|
|
26
|
+
console.error();
|
|
27
|
+
console.error(c.error("No Prisma Schema found."));
|
|
28
|
+
console.error(`Redwood searched here '${rwjsPaths.api.dbSchema}'`);
|
|
29
|
+
console.error();
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
options.schema = `${rwjsPaths.api.dbSchema}`;
|
|
33
|
+
if (["seed", "diff"].includes(commands[1])) {
|
|
34
|
+
delete options.schema;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const args = commands;
|
|
39
|
+
for (const [name, value] of Object.entries(options)) {
|
|
40
|
+
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
value.split(" ").length > 1 ? args.push(`"${value}"`) : args.push(value);
|
|
43
|
+
} else if (typeof value === "number") {
|
|
44
|
+
args.push(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log();
|
|
48
|
+
console.log(c.note("Running Prisma CLI..."));
|
|
49
|
+
console.log(c.underline("$ yarn prisma " + args.join(" ")));
|
|
50
|
+
console.log();
|
|
51
|
+
try {
|
|
52
|
+
execa.sync(
|
|
53
|
+
`"${path.join(rwjsPaths.base, "node_modules/.bin/prisma")}"`,
|
|
54
|
+
args,
|
|
55
|
+
{
|
|
56
|
+
shell: true,
|
|
57
|
+
cwd: rwjsPaths.base,
|
|
58
|
+
stdio: "inherit",
|
|
59
|
+
cleanup: true
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
if (hasHelpOption || commands.length === 0) {
|
|
63
|
+
printWrapInfo();
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
errorTelemetry(process.argv, `Error generating prisma client: ${e.message}`);
|
|
67
|
+
process.exit(e?.exitCode || 1);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const printWrapInfo = () => {
|
|
71
|
+
const message = [
|
|
72
|
+
c.bold("Redwood CLI wraps Prisma CLI"),
|
|
73
|
+
"",
|
|
74
|
+
"Use `yarn rw prisma` to automatically pass `--schema` and `--preview-feature` options.",
|
|
75
|
+
"Use `yarn prisma` to skip Redwood CLI automatic options.",
|
|
76
|
+
"",
|
|
77
|
+
"Find more information in our docs:",
|
|
78
|
+
c.underline("https://redwoodjs.com/docs/cli-commands#prisma")
|
|
79
|
+
];
|
|
80
|
+
console.log(
|
|
81
|
+
boxen(message.join("\n"), {
|
|
82
|
+
padding: { top: 0, bottom: 0, right: 1, left: 1 },
|
|
83
|
+
margin: 1,
|
|
84
|
+
borderColor: "gray"
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
handler
|
|
90
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
const handler = async () => {
|
|
3
|
+
recordTelemetryAttributes({
|
|
4
|
+
command: "record"
|
|
5
|
+
});
|
|
6
|
+
const { parseDatamodel } = await import("@cedarjs/record");
|
|
7
|
+
parseDatamodel();
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
handler
|
|
11
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const command = "record <command>";
|
|
2
|
+
const description = "Setup RedwoodRecord for your project. Caches a JSON version of your data model and adds api/src/models/index.js with some config.";
|
|
3
|
+
import terminalLink from "terminal-link";
|
|
4
|
+
const builder = (yargs) => yargs.command({ command, description, handler }).demandCommand().epilogue(
|
|
5
|
+
`Also see the ${terminalLink(
|
|
6
|
+
"RedwoodRecord Docs",
|
|
7
|
+
"https://redwoodjs.com/docs/redwoodrecord"
|
|
8
|
+
)}
|
|
9
|
+
`
|
|
10
|
+
);
|
|
11
|
+
async function handler(argv) {
|
|
12
|
+
const recordInit = await import("./record/init.js");
|
|
13
|
+
recordInit(argv);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
builder,
|
|
17
|
+
command,
|
|
18
|
+
description
|
|
19
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import terminalLink from "terminal-link";
|
|
4
|
+
import * as apiServerCLIConfig from "@cedarjs/api-server/dist/apiCLIConfig.js";
|
|
5
|
+
import * as bothServerCLIConfig from "@cedarjs/api-server/dist/bothCLIConfig.js";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
7
|
+
import * as webServerCLIConfig from "@cedarjs/web-server";
|
|
8
|
+
import c from "../lib/colors.js";
|
|
9
|
+
import { getPaths, getConfig } from "../lib/index.js";
|
|
10
|
+
import { serverFileExists } from "../lib/project.js";
|
|
11
|
+
import { webSsrServerHandler } from "./serveWebHandler.js";
|
|
12
|
+
const command = "serve [side]";
|
|
13
|
+
const description = "Start a server for serving both the api and web sides";
|
|
14
|
+
const builder = async (yargs) => {
|
|
15
|
+
const rscEnabled = getConfig().experimental?.rsc?.enabled;
|
|
16
|
+
const streamingEnabled = getConfig().experimental?.streamingSsr?.enabled;
|
|
17
|
+
yargs.command({
|
|
18
|
+
command: "$0",
|
|
19
|
+
description: bothServerCLIConfig.description,
|
|
20
|
+
builder: bothServerCLIConfig.builder,
|
|
21
|
+
handler: async (argv) => {
|
|
22
|
+
recordTelemetryAttributes({
|
|
23
|
+
command: "serve",
|
|
24
|
+
port: argv.port,
|
|
25
|
+
host: argv.host,
|
|
26
|
+
socket: argv.socket
|
|
27
|
+
});
|
|
28
|
+
if (serverFileExists()) {
|
|
29
|
+
const { bothServerFileHandler } = await import("./serveBothHandler.js");
|
|
30
|
+
await bothServerFileHandler(argv);
|
|
31
|
+
} else if (rscEnabled || streamingEnabled) {
|
|
32
|
+
const { bothSsrRscServerHandler } = await import("./serveBothHandler.js");
|
|
33
|
+
await bothSsrRscServerHandler(argv, rscEnabled);
|
|
34
|
+
} else {
|
|
35
|
+
await bothServerCLIConfig.handler(argv);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}).command({
|
|
39
|
+
command: "api",
|
|
40
|
+
description: apiServerCLIConfig.description,
|
|
41
|
+
builder: apiServerCLIConfig.builder,
|
|
42
|
+
handler: async (argv) => {
|
|
43
|
+
recordTelemetryAttributes({
|
|
44
|
+
command: "serve",
|
|
45
|
+
port: argv.port,
|
|
46
|
+
host: argv.host,
|
|
47
|
+
socket: argv.socket,
|
|
48
|
+
apiRootPath: argv.apiRootPath
|
|
49
|
+
});
|
|
50
|
+
if (serverFileExists()) {
|
|
51
|
+
const { apiServerFileHandler } = await import("./serveApiHandler.js");
|
|
52
|
+
await apiServerFileHandler(argv);
|
|
53
|
+
} else {
|
|
54
|
+
await apiServerCLIConfig.handler(argv);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}).command({
|
|
58
|
+
command: "web",
|
|
59
|
+
description: webServerCLIConfig.description,
|
|
60
|
+
builder: webServerCLIConfig.builder,
|
|
61
|
+
handler: async (argv) => {
|
|
62
|
+
recordTelemetryAttributes({
|
|
63
|
+
command: "serve",
|
|
64
|
+
port: argv.port,
|
|
65
|
+
host: argv.host,
|
|
66
|
+
socket: argv.socket,
|
|
67
|
+
apiHost: argv.apiHost
|
|
68
|
+
});
|
|
69
|
+
if (streamingEnabled) {
|
|
70
|
+
await webSsrServerHandler(rscEnabled);
|
|
71
|
+
} else {
|
|
72
|
+
await webServerCLIConfig.handler(argv);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}).middleware((argv) => {
|
|
76
|
+
recordTelemetryAttributes({
|
|
77
|
+
command: "serve"
|
|
78
|
+
});
|
|
79
|
+
const positionalArgs = argv._;
|
|
80
|
+
if (positionalArgs.includes("web") && !fs.existsSync(path.join(getPaths().web.dist), "index.html")) {
|
|
81
|
+
console.error(
|
|
82
|
+
c.error(
|
|
83
|
+
"\n Please run `yarn rw build web` before trying to serve web. \n"
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
const apiSideExists = fs.existsSync(getPaths().api.base);
|
|
89
|
+
if (positionalArgs.includes("api")) {
|
|
90
|
+
if (!apiSideExists) {
|
|
91
|
+
console.error(
|
|
92
|
+
c.error(
|
|
93
|
+
"\n Unable to serve the api side as no `api` folder exists. \n"
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
if (!fs.existsSync(path.join(getPaths().api.dist))) {
|
|
99
|
+
console.error(
|
|
100
|
+
c.error(
|
|
101
|
+
"\n Please run `yarn rw build api` before trying to serve api. \n"
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (positionalArgs.length === 1) {
|
|
108
|
+
if (!apiSideExists && !rscEnabled) {
|
|
109
|
+
console.error(
|
|
110
|
+
c.error(
|
|
111
|
+
"\n Unable to serve the both sides as no `api` folder exists. Please use `yarn rw serve web` instead. \n"
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
if (fs.existsSync(path.join(getPaths().api.base)) && !fs.existsSync(path.join(getPaths().api.dist)) || !fs.existsSync(path.join(getPaths().web.dist), "index.html")) {
|
|
117
|
+
console.error(
|
|
118
|
+
c.error(
|
|
119
|
+
"\n Please run `yarn rw build` before trying to serve your redwood app. \n"
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!process.env.NODE_ENV) {
|
|
126
|
+
process.env.NODE_ENV = "production";
|
|
127
|
+
}
|
|
128
|
+
}).epilogue(
|
|
129
|
+
`Also see the ${terminalLink(
|
|
130
|
+
"Redwood CLI Reference",
|
|
131
|
+
"https://redwoodjs.com/docs/cli-commands#serve"
|
|
132
|
+
)}`
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
builder,
|
|
137
|
+
command,
|
|
138
|
+
description
|
|
139
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
3
|
+
const apiServerFileHandler = async (argv) => {
|
|
4
|
+
const args = ["node", "server.js", "--apiRootPath", argv.apiRootPath];
|
|
5
|
+
if (argv.port) {
|
|
6
|
+
args.push("--apiPort", argv.port);
|
|
7
|
+
}
|
|
8
|
+
await execa("yarn", args, {
|
|
9
|
+
cwd: getPaths().api.dist,
|
|
10
|
+
stdio: "inherit"
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
apiServerFileHandler
|
|
15
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import concurrently from "concurrently";
|
|
3
|
+
import execa from "execa";
|
|
4
|
+
import { handler as apiServerHandler } from "@cedarjs/api-server/dist/apiCLIConfigHandler.js";
|
|
5
|
+
import {
|
|
6
|
+
getAPIHost,
|
|
7
|
+
getAPIPort,
|
|
8
|
+
getWebHost,
|
|
9
|
+
getWebPort
|
|
10
|
+
} from "@cedarjs/api-server/dist/cliHelpers.js";
|
|
11
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
12
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
13
|
+
import { exitWithError } from "../lib/exit.js";
|
|
14
|
+
const bothServerFileHandler = async (argv) => {
|
|
15
|
+
if (getConfig().experimental?.rsc?.enabled || getConfig().experimental?.streamingSsr?.enabled) {
|
|
16
|
+
logSkippingFastifyWebServer();
|
|
17
|
+
await execa("yarn", ["rw-serve-fe"], {
|
|
18
|
+
cwd: getPaths().web.base,
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
shell: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
argv.apiPort ??= getAPIPort();
|
|
24
|
+
argv.apiHost ??= getAPIHost();
|
|
25
|
+
argv.webPort ??= getWebPort();
|
|
26
|
+
argv.webHost ??= getWebHost();
|
|
27
|
+
const apiProxyTarget = [
|
|
28
|
+
"http://",
|
|
29
|
+
argv.apiHost.includes(":") ? `[${argv.apiHost}]` : argv.apiHost,
|
|
30
|
+
":",
|
|
31
|
+
argv.apiPort,
|
|
32
|
+
argv.apiRootPath
|
|
33
|
+
].join("");
|
|
34
|
+
const { result } = concurrently(
|
|
35
|
+
[
|
|
36
|
+
{
|
|
37
|
+
name: "api",
|
|
38
|
+
command: `yarn node ${path.join("dist", "server.js")} --apiPort ${argv.apiPort} --apiHost ${argv.apiHost} --apiRootPath ${argv.apiRootPath}`,
|
|
39
|
+
cwd: getPaths().api.base,
|
|
40
|
+
prefixColor: "cyan"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "web",
|
|
44
|
+
command: `yarn rw-web-server --port ${argv.webPort} --host ${argv.webHost} --api-proxy-target ${apiProxyTarget}`,
|
|
45
|
+
cwd: getPaths().base,
|
|
46
|
+
prefixColor: "blue"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
{
|
|
50
|
+
prefix: "{name} |",
|
|
51
|
+
timestampFormat: "HH:mm:ss",
|
|
52
|
+
handleInput: true
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
try {
|
|
56
|
+
await result;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (typeof error?.message !== "undefined") {
|
|
59
|
+
errorTelemetry(
|
|
60
|
+
process.argv,
|
|
61
|
+
`Error concurrently starting sides: ${error.message}`
|
|
62
|
+
);
|
|
63
|
+
exitWithError(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const bothSsrRscServerHandler = async (argv, rscEnabled) => {
|
|
69
|
+
const apiPromise = apiServerHandler({
|
|
70
|
+
apiRootPath: argv.apiRootPath,
|
|
71
|
+
host: argv.apiHost,
|
|
72
|
+
port: argv.apiPort
|
|
73
|
+
});
|
|
74
|
+
const fePromise = execa("yarn", ["rw-serve-fe"], {
|
|
75
|
+
cwd: getPaths().web.base,
|
|
76
|
+
stdio: "inherit",
|
|
77
|
+
shell: true,
|
|
78
|
+
env: rscEnabled ? {
|
|
79
|
+
// TODO (RSC): Is this how we want to do it? If so, we need to find a way
|
|
80
|
+
// to merge this with users' NODE_OPTIONS
|
|
81
|
+
NODE_OPTIONS: "--conditions react-server"
|
|
82
|
+
} : void 0
|
|
83
|
+
});
|
|
84
|
+
await Promise.all([apiPromise, fePromise]);
|
|
85
|
+
};
|
|
86
|
+
function logSkippingFastifyWebServer() {
|
|
87
|
+
console.warn("");
|
|
88
|
+
console.warn("\u26A0\uFE0F Skipping Fastify web server \u26A0\uFE0F");
|
|
89
|
+
console.warn("\u26A0\uFE0F Using new RSC server instead \u26A0\uFE0F");
|
|
90
|
+
console.warn("");
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
bothServerFileHandler,
|
|
94
|
+
bothSsrRscServerHandler
|
|
95
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
3
|
+
const webSsrServerHandler = async (rscEnabled) => {
|
|
4
|
+
await execa("yarn", ["rw-serve-fe"], {
|
|
5
|
+
cwd: getPaths().web.base,
|
|
6
|
+
stdio: "inherit",
|
|
7
|
+
shell: true,
|
|
8
|
+
env: rscEnabled ? {
|
|
9
|
+
// TODO (RSC): Is this how we want to do it? If so, we need to find a way
|
|
10
|
+
// to merge this with users' NODE_OPTIONS
|
|
11
|
+
NODE_OPTIONS: "--conditions react-server"
|
|
12
|
+
} : void 0
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
webSsrServerHandler
|
|
17
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import execa from "execa";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import terminalLink from "terminal-link";
|
|
5
|
+
import {
|
|
6
|
+
recordTelemetryAttributes,
|
|
7
|
+
standardAuthBuilder
|
|
8
|
+
} from "@cedarjs/cli-helpers";
|
|
9
|
+
import { getPaths } from "../../../lib/index.js";
|
|
10
|
+
const command = "auth <provider>";
|
|
11
|
+
const description = "Set up an auth configuration";
|
|
12
|
+
async function builder(yargs) {
|
|
13
|
+
yargs.demandCommand().epilogue(
|
|
14
|
+
`Also see the ${terminalLink(
|
|
15
|
+
"Redwood CLI Reference",
|
|
16
|
+
"https://redwoodjs.com/docs/cli-commands#setup-auth"
|
|
17
|
+
)}`
|
|
18
|
+
).command(...directToCustomAuthCommand("ethereum")).command(...directToCustomAuthCommand("goTrue")).command(...directToCustomAuthCommand("magicLink")).command(...directToCustomAuthCommand("nhost")).command(...directToCustomAuthCommand("okta")).command(
|
|
19
|
+
"auth0",
|
|
20
|
+
"Set up auth for Auth0",
|
|
21
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
22
|
+
async (args) => {
|
|
23
|
+
recordTelemetryAttributes({
|
|
24
|
+
command: "setup auth auth0",
|
|
25
|
+
force: args.force,
|
|
26
|
+
verbose: args.verbose
|
|
27
|
+
});
|
|
28
|
+
const handler = await getAuthSetupHandler("@cedarjs/auth-auth0-setup");
|
|
29
|
+
console.log();
|
|
30
|
+
handler(args);
|
|
31
|
+
}
|
|
32
|
+
).command(
|
|
33
|
+
["azure-active-directory", "azureActiveDirectory"],
|
|
34
|
+
"Set up auth for Azure Active Directory",
|
|
35
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
36
|
+
async (args) => {
|
|
37
|
+
recordTelemetryAttributes({
|
|
38
|
+
command: "setup auth azure-active-directory",
|
|
39
|
+
force: args.force,
|
|
40
|
+
verbose: args.verbose
|
|
41
|
+
});
|
|
42
|
+
const handler = await getAuthSetupHandler(
|
|
43
|
+
"@cedarjs/auth-azure-active-directory-setup"
|
|
44
|
+
);
|
|
45
|
+
console.log();
|
|
46
|
+
handler(args);
|
|
47
|
+
}
|
|
48
|
+
).command(
|
|
49
|
+
"clerk",
|
|
50
|
+
"Set up auth for Clerk",
|
|
51
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
52
|
+
async (args) => {
|
|
53
|
+
recordTelemetryAttributes({
|
|
54
|
+
command: "setup auth clerk",
|
|
55
|
+
force: args.force,
|
|
56
|
+
verbose: args.verbose
|
|
57
|
+
});
|
|
58
|
+
const handler = await getAuthSetupHandler("@cedarjs/auth-clerk-setup");
|
|
59
|
+
console.log();
|
|
60
|
+
handler(args);
|
|
61
|
+
}
|
|
62
|
+
).command(
|
|
63
|
+
"custom",
|
|
64
|
+
"Set up a custom auth provider",
|
|
65
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
66
|
+
async (args) => {
|
|
67
|
+
recordTelemetryAttributes({
|
|
68
|
+
command: "setup auth custom",
|
|
69
|
+
force: args.force,
|
|
70
|
+
verbose: args.verbose
|
|
71
|
+
});
|
|
72
|
+
const handler = await getAuthSetupHandler("@cedarjs/auth-custom-setup");
|
|
73
|
+
console.log();
|
|
74
|
+
handler(args);
|
|
75
|
+
}
|
|
76
|
+
).command(
|
|
77
|
+
"dbAuth",
|
|
78
|
+
"Set up auth for dbAuth",
|
|
79
|
+
(yargs2) => {
|
|
80
|
+
return standardAuthBuilder(yargs2).option("webauthn", {
|
|
81
|
+
alias: "w",
|
|
82
|
+
default: null,
|
|
83
|
+
description: "Include WebAuthn support (TouchID/FaceID)",
|
|
84
|
+
type: "boolean"
|
|
85
|
+
}).option("createUserModel", {
|
|
86
|
+
alias: "u",
|
|
87
|
+
default: null,
|
|
88
|
+
description: "Create a User database model",
|
|
89
|
+
type: "boolean"
|
|
90
|
+
}).option("generateAuthPages", {
|
|
91
|
+
alias: "g",
|
|
92
|
+
default: null,
|
|
93
|
+
description: "Generate auth pages (login, signup, etc.)",
|
|
94
|
+
type: "boolean"
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
async (args) => {
|
|
98
|
+
recordTelemetryAttributes({
|
|
99
|
+
command: "setup auth dbAuth",
|
|
100
|
+
force: args.force,
|
|
101
|
+
verbose: args.verbose,
|
|
102
|
+
webauthn: args.webauthn
|
|
103
|
+
});
|
|
104
|
+
const handler = await getAuthSetupHandler("@cedarjs/auth-dbauth-setup");
|
|
105
|
+
console.log();
|
|
106
|
+
handler(args);
|
|
107
|
+
}
|
|
108
|
+
).command(
|
|
109
|
+
"firebase",
|
|
110
|
+
"Set up auth for Firebase",
|
|
111
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
112
|
+
async (args) => {
|
|
113
|
+
recordTelemetryAttributes({
|
|
114
|
+
command: "setup auth firebase",
|
|
115
|
+
force: args.force,
|
|
116
|
+
verbose: args.verbose
|
|
117
|
+
});
|
|
118
|
+
const handler = await getAuthSetupHandler(
|
|
119
|
+
"@cedarjs/auth-firebase-setup"
|
|
120
|
+
);
|
|
121
|
+
console.log();
|
|
122
|
+
handler(args);
|
|
123
|
+
}
|
|
124
|
+
).command(
|
|
125
|
+
"netlify",
|
|
126
|
+
"Set up auth for Netlify",
|
|
127
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
128
|
+
async (args) => {
|
|
129
|
+
recordTelemetryAttributes({
|
|
130
|
+
command: "setup auth netlify",
|
|
131
|
+
force: args.force,
|
|
132
|
+
verbose: args.verbose
|
|
133
|
+
});
|
|
134
|
+
const handler = await getAuthSetupHandler("@cedarjs/auth-netlify-setup");
|
|
135
|
+
console.log();
|
|
136
|
+
handler(args);
|
|
137
|
+
}
|
|
138
|
+
).command(
|
|
139
|
+
"supabase",
|
|
140
|
+
"Set up auth for Supabase",
|
|
141
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
142
|
+
async (args) => {
|
|
143
|
+
recordTelemetryAttributes({
|
|
144
|
+
command: "setup auth supabase",
|
|
145
|
+
force: args.force,
|
|
146
|
+
verbose: args.verbose
|
|
147
|
+
});
|
|
148
|
+
const handler = await getAuthSetupHandler(
|
|
149
|
+
"@cedarjs/auth-supabase-setup"
|
|
150
|
+
);
|
|
151
|
+
console.log();
|
|
152
|
+
handler(args);
|
|
153
|
+
}
|
|
154
|
+
).command(
|
|
155
|
+
"supertokens",
|
|
156
|
+
"Set up auth for SuperTokens",
|
|
157
|
+
(yargs2) => standardAuthBuilder(yargs2),
|
|
158
|
+
async (args) => {
|
|
159
|
+
recordTelemetryAttributes({
|
|
160
|
+
command: "setup auth supertokens",
|
|
161
|
+
force: args.force,
|
|
162
|
+
verbose: args.verbose
|
|
163
|
+
});
|
|
164
|
+
const handler = await getAuthSetupHandler(
|
|
165
|
+
"@cedarjs/auth-supertokens-setup"
|
|
166
|
+
);
|
|
167
|
+
console.log();
|
|
168
|
+
handler(args);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function directToCustomAuthCommand(provider) {
|
|
173
|
+
return [
|
|
174
|
+
provider,
|
|
175
|
+
false,
|
|
176
|
+
() => {
|
|
177
|
+
},
|
|
178
|
+
() => {
|
|
179
|
+
recordTelemetryAttributes({
|
|
180
|
+
command: `setup auth ${provider}`
|
|
181
|
+
});
|
|
182
|
+
const customAuthLink = terminalLink(
|
|
183
|
+
"Custom Auth",
|
|
184
|
+
"https://redwoodjs.com/docs/auth/custom"
|
|
185
|
+
);
|
|
186
|
+
console.log(
|
|
187
|
+
`${provider} is no longer supported out of the box. But you can still integrate it yourself with ${customAuthLink}`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
async function getAuthSetupHandler(module) {
|
|
193
|
+
let customRequire;
|
|
194
|
+
try {
|
|
195
|
+
if (typeof require === "undefined") {
|
|
196
|
+
const { createRequire } = await import("node:module");
|
|
197
|
+
customRequire = createRequire(import.meta.url);
|
|
198
|
+
} else {
|
|
199
|
+
customRequire = require;
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
customRequire = require;
|
|
203
|
+
}
|
|
204
|
+
const packageJsonPath = customRequire.resolve("@cedarjs/cli/package.json");
|
|
205
|
+
let { version } = fs.readJSONSync(packageJsonPath);
|
|
206
|
+
if (!isInstalled(module)) {
|
|
207
|
+
if (version.includes("+")) {
|
|
208
|
+
version = version.split("+")[0];
|
|
209
|
+
}
|
|
210
|
+
let packument;
|
|
211
|
+
try {
|
|
212
|
+
const packumentResponse = await fetch(
|
|
213
|
+
`https://registry.npmjs.org/${module}`
|
|
214
|
+
);
|
|
215
|
+
packument = await packumentResponse.json();
|
|
216
|
+
if (packument.error) {
|
|
217
|
+
throw new Error(packument.error);
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
throw new Error(
|
|
221
|
+
`Couldn't fetch packument for ${module}: ${error.message}`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
const versionIsPublished = Object.keys(packument.versions).includes(version);
|
|
225
|
+
if (!versionIsPublished) {
|
|
226
|
+
version = "canary";
|
|
227
|
+
}
|
|
228
|
+
await execa.command(`yarn add -D ${module}@${version}`, {
|
|
229
|
+
stdio: "inherit",
|
|
230
|
+
cwd: getPaths().base
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const setupModule = await import(module);
|
|
234
|
+
return setupModule.default.handler;
|
|
235
|
+
}
|
|
236
|
+
function isInstalled(module) {
|
|
237
|
+
const { dependencies, devDependencies } = fs.readJSONSync(
|
|
238
|
+
path.join(getPaths().base, "package.json")
|
|
239
|
+
);
|
|
240
|
+
const deps = {
|
|
241
|
+
...dependencies,
|
|
242
|
+
...devDependencies
|
|
243
|
+
};
|
|
244
|
+
if (deps[module]) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const possiblePaths = [
|
|
249
|
+
path.join(getPaths().base, "node_modules", module),
|
|
250
|
+
path.join(getPaths().base, "..", "node_modules", module),
|
|
251
|
+
path.join(getPaths().api.base, "node_modules", module),
|
|
252
|
+
path.join(getPaths().web.base, "node_modules", module)
|
|
253
|
+
];
|
|
254
|
+
return possiblePaths.some((modulePath) => {
|
|
255
|
+
return fs.existsSync(path.join(modulePath, "package.json"));
|
|
256
|
+
});
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
export {
|
|
262
|
+
builder,
|
|
263
|
+
command,
|
|
264
|
+
description
|
|
265
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
const command = "cache <client>";
|
|
4
|
+
const description = "Sets up an init file for service caching";
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs.positional("client", {
|
|
7
|
+
choices: ["memcached", "redis"],
|
|
8
|
+
description: "Cache client",
|
|
9
|
+
type: "string",
|
|
10
|
+
required: true
|
|
11
|
+
}).option("force", {
|
|
12
|
+
alias: "f",
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Overwrite existing cache.js file",
|
|
15
|
+
type: "boolean"
|
|
16
|
+
}).epilogue(
|
|
17
|
+
`Also see the ${terminalLink(
|
|
18
|
+
"Redwood CLI Reference",
|
|
19
|
+
"https://redwoodjs.com/docs/cli-commands#setup-cache"
|
|
20
|
+
)}`
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const handler = async (options) => {
|
|
24
|
+
recordTelemetryAttributes({
|
|
25
|
+
command: "setup cache",
|
|
26
|
+
client: options.client,
|
|
27
|
+
force: options.force
|
|
28
|
+
});
|
|
29
|
+
const { handler: handler2 } = await import("./cacheHandler.js");
|
|
30
|
+
return handler2(options);
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
builder,
|
|
34
|
+
command,
|
|
35
|
+
description,
|
|
36
|
+
handler
|
|
37
|
+
};
|