@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,155 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Listr } from "listr2";
|
|
4
|
+
import pascalcase from "pascalcase";
|
|
5
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { ensurePosixPath, getConfig } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../../lib/colors.js";
|
|
9
|
+
import { generateTemplate, getPaths, writeFilesTask } from "../../lib/index.js";
|
|
10
|
+
import { prepareForRollback } from "../../lib/rollback.js";
|
|
11
|
+
import {
|
|
12
|
+
createCommand,
|
|
13
|
+
createDescription,
|
|
14
|
+
createBuilder
|
|
15
|
+
} from "./yargsCommandHelpers.js";
|
|
16
|
+
const customOrDefaultTemplatePath = ({
|
|
17
|
+
side,
|
|
18
|
+
generator,
|
|
19
|
+
templatePath
|
|
20
|
+
}) => {
|
|
21
|
+
const defaultPath = path.join(
|
|
22
|
+
import.meta.dirname,
|
|
23
|
+
generator,
|
|
24
|
+
"templates",
|
|
25
|
+
templatePath
|
|
26
|
+
);
|
|
27
|
+
const customPath = path.join(
|
|
28
|
+
getPaths()[side].generators,
|
|
29
|
+
generator,
|
|
30
|
+
templatePath
|
|
31
|
+
);
|
|
32
|
+
if (fs.existsSync(customPath)) {
|
|
33
|
+
return customPath;
|
|
34
|
+
} else {
|
|
35
|
+
return defaultPath;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const templateForComponentFile = async ({
|
|
39
|
+
name,
|
|
40
|
+
suffix = "",
|
|
41
|
+
extension = ".js",
|
|
42
|
+
webPathSection,
|
|
43
|
+
apiPathSection,
|
|
44
|
+
generator,
|
|
45
|
+
templatePath,
|
|
46
|
+
templateVars,
|
|
47
|
+
componentName,
|
|
48
|
+
outputPath
|
|
49
|
+
}) => {
|
|
50
|
+
const basePath = webPathSection ? getPaths().web[webPathSection] : getPaths().api[apiPathSection];
|
|
51
|
+
const outputComponentName = componentName || pascalcase(name) + suffix;
|
|
52
|
+
const componentOutputPath = outputPath || path.join(basePath, outputComponentName, outputComponentName + extension);
|
|
53
|
+
const fullTemplatePath = customOrDefaultTemplatePath({
|
|
54
|
+
generator,
|
|
55
|
+
templatePath,
|
|
56
|
+
side: webPathSection ? "web" : "api"
|
|
57
|
+
});
|
|
58
|
+
const content = await generateTemplate(fullTemplatePath, {
|
|
59
|
+
name,
|
|
60
|
+
outputPath: ensurePosixPath(
|
|
61
|
+
`./${path.relative(getPaths().base, componentOutputPath)}`
|
|
62
|
+
),
|
|
63
|
+
...templateVars
|
|
64
|
+
});
|
|
65
|
+
return [componentOutputPath, content];
|
|
66
|
+
};
|
|
67
|
+
const validateName = (name) => {
|
|
68
|
+
if (name.match(/^\W/)) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"The <name> argument must start with a letter, number or underscore."
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function createHandler({
|
|
75
|
+
componentName,
|
|
76
|
+
preTasksFn = (argv) => argv,
|
|
77
|
+
filesFn,
|
|
78
|
+
includeAdditionalTasks = () => []
|
|
79
|
+
}) {
|
|
80
|
+
return async (argv) => {
|
|
81
|
+
recordTelemetryAttributes({
|
|
82
|
+
command: `generate ${componentName}`,
|
|
83
|
+
tests: argv.tests,
|
|
84
|
+
stories: argv.stories,
|
|
85
|
+
verbose: argv.verbose,
|
|
86
|
+
rollback: argv.rollback,
|
|
87
|
+
force: argv.force
|
|
88
|
+
// TODO: This does not cover the specific options that each generator might pass in
|
|
89
|
+
});
|
|
90
|
+
if (argv.tests === void 0) {
|
|
91
|
+
argv.tests = getConfig().generate.tests;
|
|
92
|
+
}
|
|
93
|
+
if (argv.stories === void 0) {
|
|
94
|
+
argv.stories = getConfig().generate.stories;
|
|
95
|
+
}
|
|
96
|
+
validateName(argv.name);
|
|
97
|
+
try {
|
|
98
|
+
argv = await preTasksFn(argv);
|
|
99
|
+
const tasks = new Listr(
|
|
100
|
+
[
|
|
101
|
+
{
|
|
102
|
+
title: `Generating ${componentName} files...`,
|
|
103
|
+
task: async () => {
|
|
104
|
+
const f = await filesFn(argv);
|
|
105
|
+
return writeFilesTask(f, { overwriteExisting: argv.force });
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
...includeAdditionalTasks(argv)
|
|
109
|
+
],
|
|
110
|
+
{
|
|
111
|
+
rendererOptions: { collapseSubtasks: false },
|
|
112
|
+
exitOnError: true,
|
|
113
|
+
renderer: argv.verbose && "verbose"
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
if (argv.rollback && !argv.force) {
|
|
117
|
+
prepareForRollback(tasks);
|
|
118
|
+
}
|
|
119
|
+
await tasks.run();
|
|
120
|
+
} catch (e) {
|
|
121
|
+
errorTelemetry(process.argv, e.message);
|
|
122
|
+
console.error(c.error(e.message));
|
|
123
|
+
process.exit(e?.exitCode || 1);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const createYargsForComponentGeneration = ({
|
|
128
|
+
componentName,
|
|
129
|
+
preTasksFn = (options) => options,
|
|
130
|
+
/** filesFn is not used if generator implements its own `handler` */
|
|
131
|
+
filesFn = () => ({}),
|
|
132
|
+
optionsObj,
|
|
133
|
+
positionalsObj = {},
|
|
134
|
+
/** function that takes the options object and returns an array of listr tasks */
|
|
135
|
+
includeAdditionalTasks = () => []
|
|
136
|
+
}) => {
|
|
137
|
+
return {
|
|
138
|
+
command: createCommand(componentName, positionalsObj),
|
|
139
|
+
description: createDescription(componentName),
|
|
140
|
+
builder: createBuilder({ componentName, optionsObj, positionalsObj }),
|
|
141
|
+
handler: createHandler({
|
|
142
|
+
componentName,
|
|
143
|
+
preTasksFn,
|
|
144
|
+
filesFn,
|
|
145
|
+
includeAdditionalTasks
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
createHandler,
|
|
151
|
+
createYargsForComponentGeneration,
|
|
152
|
+
customOrDefaultTemplatePath,
|
|
153
|
+
templateForComponentFile,
|
|
154
|
+
validateName
|
|
155
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import terminalLink from "terminal-link";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import * as generateCell from "./generate/cell/cell.js";
|
|
5
|
+
import * as generateComponent from "./generate/component/component.js";
|
|
6
|
+
import * as generateDataMigration from "./generate/dataMigration/dataMigration.js";
|
|
7
|
+
import * as generateDbAuth from "./generate/dbAuth/dbAuth.js";
|
|
8
|
+
import * as generateDirective from "./generate/directive/directive.js";
|
|
9
|
+
import * as generateFunction from "./generate/function/function.js";
|
|
10
|
+
import * as generateJob from "./generate/job/job.js";
|
|
11
|
+
import * as generateLayout from "./generate/layout/layout.js";
|
|
12
|
+
import * as generateModel from "./generate/model/model.js";
|
|
13
|
+
import * as generateOgImage from "./generate/ogImage/ogImage.js";
|
|
14
|
+
import * as generatePage from "./generate/page/page.js";
|
|
15
|
+
import * as generateRealtime from "./generate/realtime/realtime.js";
|
|
16
|
+
import * as generateScaffold from "./generate/scaffold/scaffold.js";
|
|
17
|
+
import * as generateScript from "./generate/script/script.js";
|
|
18
|
+
import * as generateSdl from "./generate/sdl/sdl.js";
|
|
19
|
+
import * as generateSecret from "./generate/secret/secret.js";
|
|
20
|
+
import * as generateService from "./generate/service/service.js";
|
|
21
|
+
const command = "generate <type>";
|
|
22
|
+
const aliases = ["g"];
|
|
23
|
+
const description = "Generate boilerplate code and type definitions";
|
|
24
|
+
const builder = (yargs) => yargs.command("types", "Generate supplementary code", {}, () => {
|
|
25
|
+
recordTelemetryAttributes({
|
|
26
|
+
command: "generate types"
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
execa.sync("yarn rw-gen", { shell: true, stdio: "inherit" });
|
|
30
|
+
} catch (error) {
|
|
31
|
+
process.exitCode = error.exitCode ?? 1;
|
|
32
|
+
}
|
|
33
|
+
}).command(generateCell).command(generateComponent).command(generateDataMigration).command(generateDbAuth).command(generateDirective).command(generateFunction).command(generateJob).command(generateLayout).command(generateModel).command(generateOgImage).command(generatePage).command(generateRealtime).command(generateScaffold).command(generateScript).command(generateSdl).command(generateSecret).command(generateService).demandCommand().epilogue(
|
|
34
|
+
`Also see the ${terminalLink(
|
|
35
|
+
"Redwood CLI Reference",
|
|
36
|
+
"https://redwoodjs.com/docs/cli-commands#generate-alias-g"
|
|
37
|
+
)}`
|
|
38
|
+
);
|
|
39
|
+
export {
|
|
40
|
+
aliases,
|
|
41
|
+
builder,
|
|
42
|
+
command,
|
|
43
|
+
description
|
|
44
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import envinfo from "envinfo";
|
|
3
|
+
import terminalLink from "terminal-link";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
+
const command = "info";
|
|
7
|
+
const description = "Print your system environment information";
|
|
8
|
+
const builder = (yargs) => {
|
|
9
|
+
yargs.epilogue(
|
|
10
|
+
`Also see the ${terminalLink(
|
|
11
|
+
"Redwood CLI Reference",
|
|
12
|
+
"https://redwoodjs.com/docs/cli-commands#info"
|
|
13
|
+
)}`
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
const handler = async () => {
|
|
17
|
+
recordTelemetryAttributes({ command: "info" });
|
|
18
|
+
const output = await envinfo.run({
|
|
19
|
+
System: ["OS", "Shell"],
|
|
20
|
+
Binaries: ["Node", "Yarn"],
|
|
21
|
+
Browsers: ["Chrome", "Edge", "Firefox", "Safari"],
|
|
22
|
+
// yarn workspaces not supported :-/
|
|
23
|
+
npmPackages: "@cedarjs/*",
|
|
24
|
+
Databases: ["SQLite"]
|
|
25
|
+
});
|
|
26
|
+
const redwoodToml = fs.readFileSync(getPaths().base + "/redwood.toml", "utf8");
|
|
27
|
+
console.log(
|
|
28
|
+
output + " redwood.toml:\n" + redwoodToml.split("\n").filter((line) => line.trim().length > 0).filter((line) => !/^#/.test(line)).map((line) => ` ${line}`).join("\n")
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
builder,
|
|
33
|
+
command,
|
|
34
|
+
description,
|
|
35
|
+
handler
|
|
36
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const command = "jobs";
|
|
2
|
+
const description = "Starts the RedwoodJob runner to process background jobs";
|
|
3
|
+
const builder = (yargs) => {
|
|
4
|
+
yargs.strictOptions(false).strictCommands(false).strict(false).parserConfiguration({
|
|
5
|
+
"camel-case-expansion": false
|
|
6
|
+
}).help(false).version(false);
|
|
7
|
+
};
|
|
8
|
+
const handler = async (options) => {
|
|
9
|
+
const { handler: handler2 } = await import("./jobsHandler.js");
|
|
10
|
+
return handler2(options);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
builder,
|
|
14
|
+
command,
|
|
15
|
+
description,
|
|
16
|
+
handler
|
|
17
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { getPaths } from "../lib/index.js";
|
|
3
|
+
const handler = async ({
|
|
4
|
+
_,
|
|
5
|
+
$0: _rw,
|
|
6
|
+
commands: _commands,
|
|
7
|
+
...options
|
|
8
|
+
}) => {
|
|
9
|
+
const args = [_.pop()];
|
|
10
|
+
for (const [name, value] of Object.entries(options)) {
|
|
11
|
+
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
12
|
+
args.push(value);
|
|
13
|
+
}
|
|
14
|
+
let command = `yarn rw-jobs ${args.join(" ")}`;
|
|
15
|
+
const originalLogLevel = process.env.LOG_LEVEL;
|
|
16
|
+
process.env.LOG_LEVEL = originalLogLevel || "warn";
|
|
17
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18
|
+
command += " | yarn rw-log-formatter";
|
|
19
|
+
process.env.LOG_LEVEL = originalLogLevel || "debug";
|
|
20
|
+
}
|
|
21
|
+
execa.commandSync(command, {
|
|
22
|
+
shell: true,
|
|
23
|
+
cwd: getPaths().base,
|
|
24
|
+
stdio: "inherit",
|
|
25
|
+
cleanup: true
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
handler
|
|
30
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import terminalLink from "terminal-link";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { getPaths } from "../lib/index.js";
|
|
6
|
+
const command = "lint [path..]";
|
|
7
|
+
const description = "Lint your files";
|
|
8
|
+
const builder = (yargs) => {
|
|
9
|
+
yargs.positional("path", {
|
|
10
|
+
description: "Specify file(s) or directory(ies) to lint relative to project root",
|
|
11
|
+
type: "array"
|
|
12
|
+
}).option("fix", {
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Try to fix errors",
|
|
15
|
+
type: "boolean"
|
|
16
|
+
}).epilogue(
|
|
17
|
+
`Also see the ${terminalLink(
|
|
18
|
+
"Redwood CLI Reference",
|
|
19
|
+
"https://redwoodjs.com/docs/cli-commands#lint"
|
|
20
|
+
)}`
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const handler = async ({ path, fix }) => {
|
|
24
|
+
recordTelemetryAttributes({
|
|
25
|
+
command: "lint",
|
|
26
|
+
fix
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
const pathString = path?.join(" ");
|
|
30
|
+
const result = await execa(
|
|
31
|
+
"yarn eslint",
|
|
32
|
+
[
|
|
33
|
+
fix && "--fix",
|
|
34
|
+
!pathString && fs.existsSync(getPaths().web.src) && "web/src",
|
|
35
|
+
!pathString && fs.existsSync(getPaths().web.config) && "web/config",
|
|
36
|
+
!pathString && fs.existsSync(getPaths().web.storybook) && "web/.storybook",
|
|
37
|
+
!pathString && fs.existsSync(getPaths().scripts) && "scripts",
|
|
38
|
+
!pathString && fs.existsSync(getPaths().api.src) && "api/src",
|
|
39
|
+
pathString
|
|
40
|
+
].filter(Boolean),
|
|
41
|
+
{
|
|
42
|
+
cwd: getPaths().base,
|
|
43
|
+
shell: true,
|
|
44
|
+
stdio: "inherit"
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
process.exitCode = result.exitCode;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
process.exitCode = error.exitCode ?? 1;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
builder,
|
|
54
|
+
command,
|
|
55
|
+
description,
|
|
56
|
+
handler
|
|
57
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const command = "prerender";
|
|
2
|
+
const aliases = ["render"];
|
|
3
|
+
const description = "Prerender pages of your Redwood app at build time";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.showHelpOnFail(false);
|
|
6
|
+
yargs.option("path", {
|
|
7
|
+
alias: ["p", "route"],
|
|
8
|
+
description: "Router path to prerender. Especially useful for debugging",
|
|
9
|
+
type: "string"
|
|
10
|
+
});
|
|
11
|
+
yargs.option("dry-run", {
|
|
12
|
+
alias: ["d", "dryrun"],
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Run prerender and output to console",
|
|
15
|
+
type: "boolean"
|
|
16
|
+
});
|
|
17
|
+
yargs.option("verbose", {
|
|
18
|
+
alias: "v",
|
|
19
|
+
default: false,
|
|
20
|
+
description: "Print more",
|
|
21
|
+
type: "boolean"
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const handler = async (options) => {
|
|
25
|
+
const { handler: handler2 } = await import("./prerenderHandler.js");
|
|
26
|
+
return handler2(options);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
aliases,
|
|
30
|
+
builder,
|
|
31
|
+
command,
|
|
32
|
+
description,
|
|
33
|
+
handler
|
|
34
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { Listr } from "listr2";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { runPrerender, writePrerenderedHtmlFile } from "@cedarjs/prerender";
|
|
6
|
+
import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
|
|
7
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
8
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
|
+
import c from "../lib/colors.js";
|
|
10
|
+
import { configureBabel, runScriptFunction } from "../lib/exec.js";
|
|
11
|
+
class PathParamError extends Error {
|
|
12
|
+
}
|
|
13
|
+
const mapRouterPathToHtml = (routerPath) => {
|
|
14
|
+
if (routerPath === "/") {
|
|
15
|
+
return "web/dist/index.html";
|
|
16
|
+
} else {
|
|
17
|
+
return `web/dist${routerPath}.html`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function getRouteHooksFilePath(routeFilePath) {
|
|
21
|
+
const routeHooksFilePathTs = routeFilePath.replace(
|
|
22
|
+
/\.[jt]sx?$/,
|
|
23
|
+
".routeHooks.ts"
|
|
24
|
+
);
|
|
25
|
+
if (fs.existsSync(routeHooksFilePathTs)) {
|
|
26
|
+
return routeHooksFilePathTs;
|
|
27
|
+
}
|
|
28
|
+
const routeHooksFilePathJs = routeFilePath.replace(
|
|
29
|
+
/\.[jt]sx?$/,
|
|
30
|
+
".routeHooks.js"
|
|
31
|
+
);
|
|
32
|
+
if (fs.existsSync(routeHooksFilePathJs)) {
|
|
33
|
+
return routeHooksFilePathJs;
|
|
34
|
+
}
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
async function expandRouteParameters(route) {
|
|
38
|
+
const routeHooksFilePath = getRouteHooksFilePath(route.filePath);
|
|
39
|
+
if (!routeHooksFilePath) {
|
|
40
|
+
return [route];
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const routeParameters = await runScriptFunction({
|
|
44
|
+
path: routeHooksFilePath,
|
|
45
|
+
functionName: "routeParameters",
|
|
46
|
+
args: {
|
|
47
|
+
name: route.name,
|
|
48
|
+
path: route.path,
|
|
49
|
+
routePath: route.routePath,
|
|
50
|
+
filePath: route.filePath
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (routeParameters) {
|
|
54
|
+
return routeParameters.map((pathParamValues) => {
|
|
55
|
+
let newPath = route.path;
|
|
56
|
+
Object.entries(pathParamValues).forEach(([paramName, paramValue]) => {
|
|
57
|
+
newPath = newPath.replace(
|
|
58
|
+
new RegExp(`{${paramName}:?[^}]*}`),
|
|
59
|
+
paramValue
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
return { ...route, path: newPath };
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error(c.error(e.stack));
|
|
67
|
+
return [route];
|
|
68
|
+
}
|
|
69
|
+
return [route];
|
|
70
|
+
}
|
|
71
|
+
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
72
|
+
const prerenderRoutes = detectPrerenderRoutes().filter((route) => route.path);
|
|
73
|
+
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
74
|
+
if (prerenderRoutes.length === 0) {
|
|
75
|
+
console.log("\nSkipping prerender...");
|
|
76
|
+
console.log(
|
|
77
|
+
c.warning(
|
|
78
|
+
"You have not marked any routes with a path as `prerender` in `Routes.{jsx,tsx}` \n"
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
if (!fs.existsSync(indexHtmlPath)) {
|
|
84
|
+
console.error(
|
|
85
|
+
"You must run `yarn rw build web` before trying to prerender."
|
|
86
|
+
);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
configureBabel();
|
|
90
|
+
const expandedRouteParameters = await Promise.all(
|
|
91
|
+
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
92
|
+
);
|
|
93
|
+
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
94
|
+
const queryCache = {};
|
|
95
|
+
const shouldFold = routesToPrerender.length > 16;
|
|
96
|
+
if (shouldFold) {
|
|
97
|
+
const displayIncrement = Math.max(
|
|
98
|
+
1,
|
|
99
|
+
Math.floor(routesToPrerender.length / 100)
|
|
100
|
+
);
|
|
101
|
+
const title = (i) => `Prerendering ${routesToPrerender[0].name} (${i.toLocaleString()} of ${routesToPrerender.length.toLocaleString()})`;
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
title: title(0),
|
|
105
|
+
task: async (_, task) => {
|
|
106
|
+
for (let i = 0; i < routesToPrerender.length; i++) {
|
|
107
|
+
const routeToPrerender = routesToPrerender[i];
|
|
108
|
+
if (routerPathFilter && routeToPrerender.path !== routerPathFilter) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
await prerenderRoute(
|
|
112
|
+
queryCache,
|
|
113
|
+
routeToPrerender,
|
|
114
|
+
dryrun,
|
|
115
|
+
mapRouterPathToHtml(routeToPrerender.path)
|
|
116
|
+
);
|
|
117
|
+
if (i % displayIncrement === 0) {
|
|
118
|
+
task.title = title(i);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
task.title = title(routesToPrerender.length);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
return routesToPrerender.map((routeToPrerender) => {
|
|
127
|
+
if (routerPathFilter && routeToPrerender.path !== routerPathFilter) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
const outputHtmlPath = mapRouterPathToHtml(routeToPrerender.path);
|
|
131
|
+
return {
|
|
132
|
+
title: `Prerendering ${routeToPrerender.path} -> ${outputHtmlPath}`,
|
|
133
|
+
task: async () => {
|
|
134
|
+
await prerenderRoute(
|
|
135
|
+
queryCache,
|
|
136
|
+
routeToPrerender,
|
|
137
|
+
dryrun,
|
|
138
|
+
outputHtmlPath
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return listrTasks;
|
|
145
|
+
};
|
|
146
|
+
const diagnosticCheck = () => {
|
|
147
|
+
const checks = [
|
|
148
|
+
{
|
|
149
|
+
message: "Duplicate React version found in web/node_modules",
|
|
150
|
+
failure: fs.existsSync(
|
|
151
|
+
path.join(getPaths().web.base, "node_modules/react")
|
|
152
|
+
)
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
message: "Duplicate react-dom version found in web/node_modules",
|
|
156
|
+
failure: fs.existsSync(
|
|
157
|
+
path.join(getPaths().web.base, "node_modules/react-dom")
|
|
158
|
+
)
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
message: "Duplicate core-js version found in web/node_modules",
|
|
162
|
+
failure: fs.existsSync(
|
|
163
|
+
path.join(getPaths().web.base, "node_modules/core-js")
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
message: "Duplicate @cedarjs/web version found in web/node_modules",
|
|
168
|
+
failure: fs.existsSync(
|
|
169
|
+
path.join(getPaths().web.base, "node_modules/@cedarjs/web")
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
console.log("Running diagnostic checks");
|
|
174
|
+
if (checks.some((checks2) => checks2.failure)) {
|
|
175
|
+
console.error(c.error("node_modules are being duplicated in `./web` \n"));
|
|
176
|
+
console.log("\u26A0\uFE0F Issues found: ");
|
|
177
|
+
console.log("-".repeat(50));
|
|
178
|
+
checks.filter((check) => check.failure).forEach((check, i) => {
|
|
179
|
+
console.log(`${i + 1}. ${check.message}`);
|
|
180
|
+
});
|
|
181
|
+
console.log("-".repeat(50));
|
|
182
|
+
console.log(
|
|
183
|
+
"Diagnostic check found issues. See the Redwood Forum link below for help:"
|
|
184
|
+
);
|
|
185
|
+
console.log(
|
|
186
|
+
c.underline(
|
|
187
|
+
"https://community.redwoodjs.com/search?q=duplicate%20package%20found"
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
console.log();
|
|
191
|
+
process.exit(1);
|
|
192
|
+
} else {
|
|
193
|
+
console.log("\u2714 Diagnostics checks passed \n");
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const prerenderRoute = async (queryCache, routeToPrerender, dryrun, outputHtmlPath) => {
|
|
197
|
+
if (/\{.*}/.test(routeToPrerender.path)) {
|
|
198
|
+
throw new PathParamError(
|
|
199
|
+
`Could not retrieve route parameters for ${routeToPrerender.path}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const prerenderedHtml = await runPrerender({
|
|
204
|
+
queryCache,
|
|
205
|
+
renderPath: routeToPrerender.path
|
|
206
|
+
});
|
|
207
|
+
if (!dryrun) {
|
|
208
|
+
writePrerenderedHtmlFile(outputHtmlPath, prerenderedHtml);
|
|
209
|
+
}
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.log();
|
|
212
|
+
console.log(c.warning("You can use `yarn rw prerender --dry-run` to debug"));
|
|
213
|
+
console.log();
|
|
214
|
+
console.log(
|
|
215
|
+
`${c.info("-".repeat(10))} Error rendering path "${routeToPrerender.path}" ${c.info("-".repeat(10))}`
|
|
216
|
+
);
|
|
217
|
+
errorTelemetry(process.argv, `Error prerendering: ${e.message}`);
|
|
218
|
+
console.error(c.error(e.stack));
|
|
219
|
+
console.log();
|
|
220
|
+
throw new Error(`Failed to render "${routeToPrerender.filePath}"`);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
224
|
+
if (getConfig().experimental?.streamingSsr?.enabled) {
|
|
225
|
+
console.log(
|
|
226
|
+
c.warning(
|
|
227
|
+
"Prerendering is not yet supported with Streaming SSR. Skipping prerender..."
|
|
228
|
+
)
|
|
229
|
+
);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
recordTelemetryAttributes({
|
|
233
|
+
command: "prerender",
|
|
234
|
+
dryRun,
|
|
235
|
+
verbose
|
|
236
|
+
});
|
|
237
|
+
const listrTasks = await getTasks(dryRun, routerPath);
|
|
238
|
+
const tasks = new Listr(listrTasks, {
|
|
239
|
+
renderer: verbose ? "verbose" : "default",
|
|
240
|
+
rendererOptions: { collapseSubtasks: false },
|
|
241
|
+
concurrent: false
|
|
242
|
+
});
|
|
243
|
+
try {
|
|
244
|
+
if (dryRun) {
|
|
245
|
+
console.log(c.info("::: Dry run, not writing changes :::"));
|
|
246
|
+
}
|
|
247
|
+
await tasks.run();
|
|
248
|
+
} catch (e) {
|
|
249
|
+
console.log();
|
|
250
|
+
await diagnosticCheck();
|
|
251
|
+
console.log(c.warning("Tips:"));
|
|
252
|
+
if (e instanceof PathParamError) {
|
|
253
|
+
console.log(
|
|
254
|
+
c.info(
|
|
255
|
+
"- You most likely need to add or update a *.routeHooks.{js,ts} file next to the Page you're trying to prerender"
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
} else {
|
|
259
|
+
console.log(
|
|
260
|
+
c.info(
|
|
261
|
+
`- This could mean that a library you're using does not support SSR.`
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
console.log(
|
|
265
|
+
c.info(
|
|
266
|
+
"- Avoid using `window` in the initial render path through your React components without checks. \n See https://redwoodjs.com/docs/prerender#prerender-utils"
|
|
267
|
+
)
|
|
268
|
+
);
|
|
269
|
+
console.log(
|
|
270
|
+
c.info(
|
|
271
|
+
"- Avoid prerendering Cells with authenticated queries, by conditionally rendering them.\n See https://redwoodjs.com/docs/prerender#common-warnings--errors"
|
|
272
|
+
)
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
console.log();
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
export {
|
|
280
|
+
getTasks,
|
|
281
|
+
handler
|
|
282
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const command = "prisma [commands..]";
|
|
2
|
+
const description = "Run Prisma CLI with experimental features";
|
|
3
|
+
const builder = (yargs) => {
|
|
4
|
+
yargs.strictOptions(false).strictCommands(false).strict(false).parserConfiguration({
|
|
5
|
+
"camel-case-expansion": false
|
|
6
|
+
}).help(false).version(false);
|
|
7
|
+
};
|
|
8
|
+
const handler = async (options) => {
|
|
9
|
+
const { handler: handler2 } = await import("./prismaHandler.js");
|
|
10
|
+
return handler2(options);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
builder,
|
|
14
|
+
command,
|
|
15
|
+
description,
|
|
16
|
+
handler
|
|
17
|
+
};
|