@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,28 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { getEpilogue } from "./util.js";
|
|
3
|
+
const command = "setup-rsc";
|
|
4
|
+
const description = "Enable React Server Components (RSC)";
|
|
5
|
+
const EXPERIMENTAL_TOPIC_ID = 5081;
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.option("force", {
|
|
8
|
+
alias: "f",
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Overwrite existing configuration",
|
|
11
|
+
type: "boolean"
|
|
12
|
+
}).epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true));
|
|
13
|
+
};
|
|
14
|
+
const handler = async (options) => {
|
|
15
|
+
recordTelemetryAttributes({
|
|
16
|
+
command: ["experimental", command].join(" "),
|
|
17
|
+
force: options.force
|
|
18
|
+
});
|
|
19
|
+
const { handler: handler2 } = await import("./setupRscHandler.js");
|
|
20
|
+
return handler2(options);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
EXPERIMENTAL_TOPIC_ID,
|
|
24
|
+
builder,
|
|
25
|
+
command,
|
|
26
|
+
description,
|
|
27
|
+
handler
|
|
28
|
+
};
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import execa from "execa";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import { prettify } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../../lib/colors.js";
|
|
9
|
+
import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
|
|
10
|
+
import { isTypeScriptProject } from "../../lib/project.js";
|
|
11
|
+
import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupRsc.js";
|
|
12
|
+
import { printTaskEpilogue } from "./util.js";
|
|
13
|
+
const handler = async ({ force, verbose }) => {
|
|
14
|
+
const rwPaths = getPaths();
|
|
15
|
+
const redwoodTomlPath = getConfigPath();
|
|
16
|
+
const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
|
|
17
|
+
const ext = path.extname(rwPaths.web.entryClient || "");
|
|
18
|
+
const tasks = new Listr(
|
|
19
|
+
[
|
|
20
|
+
{
|
|
21
|
+
title: "Check prerequisites",
|
|
22
|
+
task: () => {
|
|
23
|
+
if (!rwPaths.web.entryClient || !rwPaths.web.viteConfig) {
|
|
24
|
+
throw new Error("Vite needs to be setup before you can enable RSCs");
|
|
25
|
+
}
|
|
26
|
+
if (!getConfig().experimental?.streamingSsr?.enabled) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"The Streaming SSR experimental feature must be enabled before you can enable RSCs"
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (!isTypeScriptProject()) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"RSCs are only supported in TypeScript projects at this time"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: "Adding config to redwood.toml...",
|
|
40
|
+
task: (_ctx, task) => {
|
|
41
|
+
if (!configContent.includes("[experimental.rsc]")) {
|
|
42
|
+
writeFile(
|
|
43
|
+
redwoodTomlPath,
|
|
44
|
+
configContent.concat("\n[experimental.rsc]\n enabled = true\n"),
|
|
45
|
+
{
|
|
46
|
+
overwriteExisting: true
|
|
47
|
+
// redwood.toml always exists
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
if (force) {
|
|
52
|
+
task.output = "Overwriting config in redwood.toml";
|
|
53
|
+
writeFile(
|
|
54
|
+
redwoodTomlPath,
|
|
55
|
+
configContent.replace(
|
|
56
|
+
// Enable if it's currently disabled
|
|
57
|
+
"\n[experimental.rsc]\n enabled = false\n",
|
|
58
|
+
"\n[experimental.rsc]\n enabled = true\n"
|
|
59
|
+
),
|
|
60
|
+
{
|
|
61
|
+
overwriteExisting: true
|
|
62
|
+
// redwood.toml always exists
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
} else {
|
|
66
|
+
task.skip(
|
|
67
|
+
"The [experimental.rsc] config block already exists in your `redwood.toml` file."
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
rendererOptions: { persistentOutput: true }
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: `Overwriting entry.client${ext}...`,
|
|
76
|
+
task: async () => {
|
|
77
|
+
const entryClientTemplate = fs.readFileSync(
|
|
78
|
+
path.resolve(
|
|
79
|
+
import.meta.dirname,
|
|
80
|
+
"templates",
|
|
81
|
+
"rsc",
|
|
82
|
+
"entry.client.tsx.template"
|
|
83
|
+
),
|
|
84
|
+
"utf-8"
|
|
85
|
+
);
|
|
86
|
+
const entryClientContent = isTypeScriptProject() ? entryClientTemplate : await transformTSToJS(
|
|
87
|
+
rwPaths.web.entryClient,
|
|
88
|
+
entryClientTemplate
|
|
89
|
+
);
|
|
90
|
+
writeFile(rwPaths.web.entryClient, entryClientContent, {
|
|
91
|
+
overwriteExisting: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
title: `Overwriting entry.server${ext}...`,
|
|
97
|
+
task: async () => {
|
|
98
|
+
const entryServerTemplate = fs.readFileSync(
|
|
99
|
+
path.resolve(
|
|
100
|
+
import.meta.dirname,
|
|
101
|
+
"templates",
|
|
102
|
+
"rsc",
|
|
103
|
+
"entry.server.tsx.template"
|
|
104
|
+
),
|
|
105
|
+
"utf-8"
|
|
106
|
+
);
|
|
107
|
+
const entryServerPath = path.join(
|
|
108
|
+
rwPaths.web.src,
|
|
109
|
+
`entry.server${ext}`
|
|
110
|
+
);
|
|
111
|
+
const entryServerContent = isTypeScriptProject() ? entryServerTemplate : await transformTSToJS(entryServerPath, entryServerTemplate);
|
|
112
|
+
writeFile(entryServerPath, entryServerContent, {
|
|
113
|
+
overwriteExisting: true
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
title: `Overwriting Document${ext}...`,
|
|
119
|
+
task: async () => {
|
|
120
|
+
const documentTemplate = fs.readFileSync(
|
|
121
|
+
path.resolve(
|
|
122
|
+
import.meta.dirname,
|
|
123
|
+
"templates",
|
|
124
|
+
"rsc",
|
|
125
|
+
"Document.tsx.template"
|
|
126
|
+
),
|
|
127
|
+
"utf-8"
|
|
128
|
+
);
|
|
129
|
+
const documentPath = path.join(rwPaths.web.src, `Document${ext}`);
|
|
130
|
+
const documentContent = isTypeScriptProject() ? documentTemplate : await transformTSToJS(documentPath, documentTemplate);
|
|
131
|
+
writeFile(documentPath, documentContent, {
|
|
132
|
+
overwriteExisting: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
title: "Adding Pages...",
|
|
138
|
+
task: async () => {
|
|
139
|
+
const homePageTemplate = fs.readFileSync(
|
|
140
|
+
path.resolve(
|
|
141
|
+
import.meta.dirname,
|
|
142
|
+
"templates",
|
|
143
|
+
"rsc",
|
|
144
|
+
"HomePage.tsx.template"
|
|
145
|
+
),
|
|
146
|
+
"utf-8"
|
|
147
|
+
);
|
|
148
|
+
const homePagePath = path.join(
|
|
149
|
+
rwPaths.web.pages,
|
|
150
|
+
"HomePage",
|
|
151
|
+
"HomePage.tsx"
|
|
152
|
+
);
|
|
153
|
+
writeFile(homePagePath, homePageTemplate, {
|
|
154
|
+
overwriteExisting: force
|
|
155
|
+
});
|
|
156
|
+
const aboutPageTemplate = fs.readFileSync(
|
|
157
|
+
path.resolve(
|
|
158
|
+
import.meta.dirname,
|
|
159
|
+
"templates",
|
|
160
|
+
"rsc",
|
|
161
|
+
"AboutPage.tsx.template"
|
|
162
|
+
),
|
|
163
|
+
"utf-8"
|
|
164
|
+
);
|
|
165
|
+
const aboutPagePath = path.join(
|
|
166
|
+
rwPaths.web.pages,
|
|
167
|
+
"AboutPage",
|
|
168
|
+
"AboutPage.tsx"
|
|
169
|
+
);
|
|
170
|
+
writeFile(aboutPagePath, aboutPageTemplate, {
|
|
171
|
+
overwriteExisting: force
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: "Adding Counter.tsx...",
|
|
177
|
+
task: async () => {
|
|
178
|
+
const counterTemplate = fs.readFileSync(
|
|
179
|
+
path.resolve(
|
|
180
|
+
import.meta.dirname,
|
|
181
|
+
"templates",
|
|
182
|
+
"rsc",
|
|
183
|
+
"Counter.tsx.template"
|
|
184
|
+
),
|
|
185
|
+
"utf-8"
|
|
186
|
+
);
|
|
187
|
+
const counterPath = path.join(
|
|
188
|
+
rwPaths.web.components,
|
|
189
|
+
"Counter",
|
|
190
|
+
"Counter.tsx"
|
|
191
|
+
);
|
|
192
|
+
writeFile(counterPath, counterTemplate, {
|
|
193
|
+
overwriteExisting: force
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
title: "Adding AboutCounter.tsx...",
|
|
199
|
+
task: async () => {
|
|
200
|
+
const counterTemplate = fs.readFileSync(
|
|
201
|
+
path.resolve(
|
|
202
|
+
import.meta.dirname,
|
|
203
|
+
"templates",
|
|
204
|
+
"rsc",
|
|
205
|
+
"AboutCounter.tsx.template"
|
|
206
|
+
),
|
|
207
|
+
"utf-8"
|
|
208
|
+
);
|
|
209
|
+
const counterPath = path.join(
|
|
210
|
+
rwPaths.web.components,
|
|
211
|
+
"Counter",
|
|
212
|
+
"AboutCounter.tsx"
|
|
213
|
+
);
|
|
214
|
+
writeFile(counterPath, counterTemplate, {
|
|
215
|
+
overwriteExisting: force
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
title: "Adding CSS files...",
|
|
221
|
+
task: async () => {
|
|
222
|
+
const files = [
|
|
223
|
+
{
|
|
224
|
+
template: "Counter.css.template",
|
|
225
|
+
path: ["components", "Counter", "Counter.css"]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
template: "Counter.module.css.template",
|
|
229
|
+
path: ["components", "Counter", "Counter.module.css"]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
template: "HomePage.css.template",
|
|
233
|
+
path: ["pages", "HomePage", "HomePage.css"]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
template: "HomePage.module.css.template",
|
|
237
|
+
path: ["pages", "HomePage", "HomePage.module.css"]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
template: "AboutPage.css.template",
|
|
241
|
+
path: ["pages", "AboutPage", "AboutPage.css"]
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
files.forEach((file) => {
|
|
245
|
+
const template = fs.readFileSync(
|
|
246
|
+
path.resolve(
|
|
247
|
+
import.meta.dirname,
|
|
248
|
+
"templates",
|
|
249
|
+
"rsc",
|
|
250
|
+
file.template
|
|
251
|
+
),
|
|
252
|
+
"utf-8"
|
|
253
|
+
);
|
|
254
|
+
const filePath = path.join(rwPaths.web.src, ...file.path);
|
|
255
|
+
writeFile(filePath, template, {
|
|
256
|
+
overwriteExisting: force
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
title: "Adding Layout...",
|
|
263
|
+
task: async () => {
|
|
264
|
+
const layoutTemplate = fs.readFileSync(
|
|
265
|
+
path.resolve(
|
|
266
|
+
import.meta.dirname,
|
|
267
|
+
"templates",
|
|
268
|
+
"rsc",
|
|
269
|
+
"NavigationLayout.tsx.template"
|
|
270
|
+
),
|
|
271
|
+
"utf-8"
|
|
272
|
+
);
|
|
273
|
+
const layoutPath = path.join(
|
|
274
|
+
rwPaths.web.layouts,
|
|
275
|
+
"NavigationLayout",
|
|
276
|
+
"NavigationLayout.tsx"
|
|
277
|
+
);
|
|
278
|
+
writeFile(layoutPath, layoutTemplate, { overwriteExisting: force });
|
|
279
|
+
const cssTemplate = fs.readFileSync(
|
|
280
|
+
path.resolve(
|
|
281
|
+
import.meta.dirname,
|
|
282
|
+
"templates",
|
|
283
|
+
"rsc",
|
|
284
|
+
"NavigationLayout.css.template"
|
|
285
|
+
),
|
|
286
|
+
"utf-8"
|
|
287
|
+
);
|
|
288
|
+
const cssPath = path.join(
|
|
289
|
+
rwPaths.web.layouts,
|
|
290
|
+
"NavigationLayout",
|
|
291
|
+
"NavigationLayout.css"
|
|
292
|
+
);
|
|
293
|
+
writeFile(cssPath, cssTemplate, { overwriteExisting: force });
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
title: "Overwriting index.css...",
|
|
298
|
+
task: async () => {
|
|
299
|
+
const template = fs.readFileSync(
|
|
300
|
+
path.resolve(
|
|
301
|
+
import.meta.dirname,
|
|
302
|
+
"templates",
|
|
303
|
+
"rsc",
|
|
304
|
+
"index.css.template"
|
|
305
|
+
),
|
|
306
|
+
"utf-8"
|
|
307
|
+
);
|
|
308
|
+
const filePath = path.join(rwPaths.web.src, "index.css");
|
|
309
|
+
writeFile(filePath, template, {
|
|
310
|
+
overwriteExisting: true
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
title: "Add React experimental types...",
|
|
316
|
+
task: async () => {
|
|
317
|
+
const tsconfigPath = path.join(rwPaths.web.base, "tsconfig.json");
|
|
318
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, "utf-8"));
|
|
319
|
+
if (tsconfig.compilerOptions.types.includes("react/experimental")) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
tsconfig.compilerOptions.types.push("react/experimental");
|
|
323
|
+
writeFile(
|
|
324
|
+
tsconfigPath,
|
|
325
|
+
await prettify("tsconfig.json", JSON.stringify(tsconfig, null, 2)),
|
|
326
|
+
{
|
|
327
|
+
overwriteExisting: true
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
title: "Overwriting routes...",
|
|
334
|
+
task: async () => {
|
|
335
|
+
const routesTemplate = fs.readFileSync(
|
|
336
|
+
path.resolve(
|
|
337
|
+
import.meta.dirname,
|
|
338
|
+
"templates",
|
|
339
|
+
"rsc",
|
|
340
|
+
"Routes.tsx.template"
|
|
341
|
+
),
|
|
342
|
+
"utf-8"
|
|
343
|
+
);
|
|
344
|
+
writeFile(rwPaths.web.routes, routesTemplate, {
|
|
345
|
+
overwriteExisting: true
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
title: "Updating React version...",
|
|
351
|
+
task: async () => {
|
|
352
|
+
const canaryWebPackageJsonUrl = "https://raw.githubusercontent.com/cedarjs/cedar/main/packages/create-cedar-app/templates/ts/web/package.json";
|
|
353
|
+
const response = await fetch(canaryWebPackageJsonUrl);
|
|
354
|
+
const canaryPackageJson = await response.json();
|
|
355
|
+
const currentRootPackageJsonPath = path.join(
|
|
356
|
+
rwPaths.base,
|
|
357
|
+
"package.json"
|
|
358
|
+
);
|
|
359
|
+
const currentRootPackageJson = JSON.parse(
|
|
360
|
+
fs.readFileSync(currentRootPackageJsonPath, "utf-8")
|
|
361
|
+
);
|
|
362
|
+
const currentWebPackageJsonPath = path.join(
|
|
363
|
+
rwPaths.web.base,
|
|
364
|
+
"package.json"
|
|
365
|
+
);
|
|
366
|
+
const currentWebPackageJson = JSON.parse(
|
|
367
|
+
fs.readFileSync(currentWebPackageJsonPath, "utf-8")
|
|
368
|
+
);
|
|
369
|
+
const packagesToUpdate = ["react", "react-dom"];
|
|
370
|
+
for (const packageName of packagesToUpdate) {
|
|
371
|
+
currentRootPackageJson.resolutions ||= {};
|
|
372
|
+
currentRootPackageJson.resolutions[packageName] = canaryPackageJson.dependencies[packageName];
|
|
373
|
+
currentWebPackageJson.dependencies[packageName] = canaryPackageJson.dependencies[packageName];
|
|
374
|
+
}
|
|
375
|
+
writeFile(
|
|
376
|
+
currentWebPackageJsonPath,
|
|
377
|
+
JSON.stringify(currentWebPackageJson, null, 2),
|
|
378
|
+
{
|
|
379
|
+
overwriteExisting: true
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
await execa("yarn", [], {
|
|
383
|
+
cwd: getPaths().web.base
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
task: () => {
|
|
389
|
+
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
{
|
|
394
|
+
rendererOptions: { collapseSubtasks: false, persistentOutput: true },
|
|
395
|
+
renderer: verbose ? "verbose" : "default"
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
try {
|
|
399
|
+
await tasks.run();
|
|
400
|
+
} catch (e) {
|
|
401
|
+
errorTelemetry(process.argv, e.message);
|
|
402
|
+
console.error(c.error(e.message));
|
|
403
|
+
process.exit(e?.exitCode || 1);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
export {
|
|
407
|
+
handler
|
|
408
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { getEpilogue } from "./util.js";
|
|
3
|
+
const command = "setup-streaming-ssr";
|
|
4
|
+
const description = "Enable React Streaming and Server Side Rendering (SSR)";
|
|
5
|
+
const EXPERIMENTAL_TOPIC_ID = 5052;
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.option("force", {
|
|
8
|
+
alias: "f",
|
|
9
|
+
default: false,
|
|
10
|
+
description: "Overwrite existing configuration",
|
|
11
|
+
type: "boolean"
|
|
12
|
+
}).epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true));
|
|
13
|
+
};
|
|
14
|
+
const handler = async (options) => {
|
|
15
|
+
recordTelemetryAttributes({
|
|
16
|
+
command: ["experimental", command].join(" "),
|
|
17
|
+
force: options.force
|
|
18
|
+
});
|
|
19
|
+
const { handler: handler2 } = await import("./setupStreamingSsrHandler.js");
|
|
20
|
+
return handler2(options);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
EXPERIMENTAL_TOPIC_ID,
|
|
24
|
+
builder,
|
|
25
|
+
command,
|
|
26
|
+
description,
|
|
27
|
+
handler
|
|
28
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import { addWebPackages } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { getConfigPath } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../../lib/colors.js";
|
|
9
|
+
import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
|
|
10
|
+
import { isTypeScriptProject } from "../../lib/project.js";
|
|
11
|
+
import {
|
|
12
|
+
command,
|
|
13
|
+
description,
|
|
14
|
+
EXPERIMENTAL_TOPIC_ID
|
|
15
|
+
} from "./setupStreamingSsr.js";
|
|
16
|
+
import { printTaskEpilogue } from "./util.js";
|
|
17
|
+
const handler = async ({ force, verbose }) => {
|
|
18
|
+
const rwPaths = getPaths();
|
|
19
|
+
const redwoodTomlPath = getConfigPath();
|
|
20
|
+
const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");
|
|
21
|
+
const ts = isTypeScriptProject();
|
|
22
|
+
const ext = path.extname(rwPaths.web.entryClient || "");
|
|
23
|
+
const tasks = new Listr(
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
title: "Check prerequisites",
|
|
27
|
+
task: () => {
|
|
28
|
+
if (!rwPaths.web.entryClient || !rwPaths.web.viteConfig) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Vite needs to be setup before you can enable Streaming SSR"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "Adding config to redwood.toml...",
|
|
37
|
+
task: (_ctx, task) => {
|
|
38
|
+
if (!configContent.includes("[experimental.streamingSsr]")) {
|
|
39
|
+
writeFile(
|
|
40
|
+
redwoodTomlPath,
|
|
41
|
+
configContent.concat(
|
|
42
|
+
`
|
|
43
|
+
[experimental.streamingSsr]
|
|
44
|
+
enabled = true
|
|
45
|
+
`
|
|
46
|
+
),
|
|
47
|
+
{
|
|
48
|
+
overwriteExisting: true
|
|
49
|
+
// redwood.toml always exists
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
if (force) {
|
|
54
|
+
task.output = "Overwriting config in redwood.toml";
|
|
55
|
+
writeFile(
|
|
56
|
+
redwoodTomlPath,
|
|
57
|
+
configContent.replace(
|
|
58
|
+
// Enable if it's currently disabled
|
|
59
|
+
`
|
|
60
|
+
[experimental.streamingSsr]
|
|
61
|
+
enabled = false
|
|
62
|
+
`,
|
|
63
|
+
`
|
|
64
|
+
[experimental.streamingSsr]
|
|
65
|
+
enabled = true
|
|
66
|
+
`
|
|
67
|
+
),
|
|
68
|
+
{
|
|
69
|
+
overwriteExisting: true
|
|
70
|
+
// redwood.toml always exists
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
} else {
|
|
74
|
+
task.skip(
|
|
75
|
+
`The [experimental.streamingSsr] config block already exists in your 'redwood.toml' file.`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
rendererOptions: { persistentOutput: true }
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: `Adding entry.client${ext}...`,
|
|
84
|
+
task: async (_ctx, task) => {
|
|
85
|
+
const entryClientTemplate = fs.readFileSync(
|
|
86
|
+
path.resolve(
|
|
87
|
+
import.meta.dirname,
|
|
88
|
+
"templates",
|
|
89
|
+
"streamingSsr",
|
|
90
|
+
"entry.client.tsx.template"
|
|
91
|
+
),
|
|
92
|
+
"utf-8"
|
|
93
|
+
);
|
|
94
|
+
let entryClientPath = rwPaths.web.entryClient;
|
|
95
|
+
const entryClientContent = ts ? entryClientTemplate : await transformTSToJS(entryClientPath, entryClientTemplate);
|
|
96
|
+
let overwriteExisting = force;
|
|
97
|
+
if (!force) {
|
|
98
|
+
const prompt = task.prompt(ListrEnquirerPromptAdapter);
|
|
99
|
+
overwriteExisting = await prompt.run({
|
|
100
|
+
type: "Confirm",
|
|
101
|
+
message: `Overwrite ${entryClientPath}?`
|
|
102
|
+
});
|
|
103
|
+
if (!overwriteExisting) {
|
|
104
|
+
entryClientPath = entryClientPath.replace(ext, `.new${ext}`);
|
|
105
|
+
task.output = `File will be written to ${entryClientPath}
|
|
106
|
+
You'll manually need to merge it with your existing entry.client${ext} file.`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
writeFile(entryClientPath, entryClientContent, { overwriteExisting });
|
|
110
|
+
},
|
|
111
|
+
rendererOptions: { persistentOutput: true }
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
title: `Adding entry.server${ext}...`,
|
|
115
|
+
task: async () => {
|
|
116
|
+
const entryServerTemplate = fs.readFileSync(
|
|
117
|
+
path.resolve(
|
|
118
|
+
import.meta.dirname,
|
|
119
|
+
"templates",
|
|
120
|
+
"streamingSsr",
|
|
121
|
+
"entry.server.tsx.template"
|
|
122
|
+
),
|
|
123
|
+
"utf-8"
|
|
124
|
+
);
|
|
125
|
+
const entryServerPath = path.join(
|
|
126
|
+
rwPaths.web.src,
|
|
127
|
+
`entry.server${ext}`
|
|
128
|
+
);
|
|
129
|
+
const entryServerContent = ts ? entryServerTemplate : await transformTSToJS(entryServerPath, entryServerTemplate);
|
|
130
|
+
writeFile(entryServerPath, entryServerContent, {
|
|
131
|
+
overwriteExisting: force
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
title: `Adding Document${ext}...`,
|
|
137
|
+
task: async () => {
|
|
138
|
+
const documentTemplate = fs.readFileSync(
|
|
139
|
+
path.resolve(
|
|
140
|
+
import.meta.dirname,
|
|
141
|
+
"templates",
|
|
142
|
+
"streamingSsr",
|
|
143
|
+
"Document.tsx.template"
|
|
144
|
+
),
|
|
145
|
+
"utf-8"
|
|
146
|
+
);
|
|
147
|
+
const documentPath = path.join(rwPaths.web.src, `Document${ext}`);
|
|
148
|
+
const documentContent = ts ? documentTemplate : await transformTSToJS(documentPath, documentTemplate);
|
|
149
|
+
writeFile(documentPath, documentContent, {
|
|
150
|
+
overwriteExisting: force
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
title: `Update web/{ts,js}config.json...`,
|
|
156
|
+
task: async () => {
|
|
157
|
+
const tsconfigTemplate = fs.readFileSync(
|
|
158
|
+
path.resolve(
|
|
159
|
+
import.meta.dirname,
|
|
160
|
+
"templates",
|
|
161
|
+
"streamingSsr",
|
|
162
|
+
"tsconfig.json.template"
|
|
163
|
+
),
|
|
164
|
+
"utf-8"
|
|
165
|
+
);
|
|
166
|
+
const tsconfigPath = path.join(
|
|
167
|
+
rwPaths.web.base,
|
|
168
|
+
ts ? "tsconfig.json" : "jsconfig.json"
|
|
169
|
+
);
|
|
170
|
+
writeFile(tsconfigPath, tsconfigTemplate, {
|
|
171
|
+
overwriteExisting: force
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: 'Adding resolution for "@apollo/client-react-streaming/superjson"',
|
|
177
|
+
task: () => {
|
|
178
|
+
const pkgJsonPath = path.join(rwPaths.base, "package.json");
|
|
179
|
+
const pkgJson = fs.readJsonSync(pkgJsonPath);
|
|
180
|
+
const resolutions = pkgJson.resolutions || {};
|
|
181
|
+
resolutions["@apollo/client-react-streaming/superjson"] = "^1.12.2";
|
|
182
|
+
pkgJson.resolutions = resolutions;
|
|
183
|
+
fs.writeJsonSync(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
addWebPackages(["@apollo/client-react-streaming@0.10.0"]),
|
|
187
|
+
{
|
|
188
|
+
task: () => {
|
|
189
|
+
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
{
|
|
194
|
+
rendererOptions: { collapseSubtasks: false, persistentOutput: true },
|
|
195
|
+
renderer: verbose ? "verbose" : "default"
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
try {
|
|
199
|
+
await tasks.run();
|
|
200
|
+
} catch (e) {
|
|
201
|
+
errorTelemetry(process.argv, e.message);
|
|
202
|
+
console.error(c.error(e.message));
|
|
203
|
+
process.exit(e?.exitCode || 1);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
handler
|
|
208
|
+
};
|