@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,59 @@
|
|
|
1
|
+
import { transformTSToJS } from "../../../lib/index.js";
|
|
2
|
+
import { removeGeneratorName } from "../helpers.js";
|
|
3
|
+
import {
|
|
4
|
+
templateForComponentFile,
|
|
5
|
+
createHandler
|
|
6
|
+
} from "../yargsHandlerHelpers.js";
|
|
7
|
+
const COMPONENT_SUFFIX = "Layout";
|
|
8
|
+
const REDWOOD_WEB_PATH_NAME = "layouts";
|
|
9
|
+
const files = async ({ name, typescript = false, ...options }) => {
|
|
10
|
+
const layoutName = removeGeneratorName(name, "layout");
|
|
11
|
+
const extension = typescript ? ".tsx" : ".jsx";
|
|
12
|
+
const layoutFile = await templateForComponentFile({
|
|
13
|
+
name: layoutName,
|
|
14
|
+
suffix: COMPONENT_SUFFIX,
|
|
15
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
16
|
+
extension,
|
|
17
|
+
generator: "layout",
|
|
18
|
+
templatePath: options.skipLink ? "layout.tsx.a11y.template" : "layout.tsx.template"
|
|
19
|
+
});
|
|
20
|
+
const testFile = await templateForComponentFile({
|
|
21
|
+
name: layoutName,
|
|
22
|
+
suffix: COMPONENT_SUFFIX,
|
|
23
|
+
extension: `.test${extension}`,
|
|
24
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
25
|
+
generator: "layout",
|
|
26
|
+
templatePath: "test.tsx.template"
|
|
27
|
+
});
|
|
28
|
+
const storyFile = await templateForComponentFile({
|
|
29
|
+
name: layoutName,
|
|
30
|
+
suffix: COMPONENT_SUFFIX,
|
|
31
|
+
extension: `.stories${extension}`,
|
|
32
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
33
|
+
generator: "layout",
|
|
34
|
+
templatePath: "stories.tsx.template"
|
|
35
|
+
});
|
|
36
|
+
const files2 = [layoutFile];
|
|
37
|
+
if (options.stories) {
|
|
38
|
+
files2.push(storyFile);
|
|
39
|
+
}
|
|
40
|
+
if (options.tests) {
|
|
41
|
+
files2.push(testFile);
|
|
42
|
+
}
|
|
43
|
+
return files2.reduce(async (accP, [outputPath, content]) => {
|
|
44
|
+
const acc = await accP;
|
|
45
|
+
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
46
|
+
return {
|
|
47
|
+
[outputPath]: template,
|
|
48
|
+
...acc
|
|
49
|
+
};
|
|
50
|
+
}, Promise.resolve({}));
|
|
51
|
+
};
|
|
52
|
+
const handler = createHandler({
|
|
53
|
+
componentName: "layout",
|
|
54
|
+
filesFn: files
|
|
55
|
+
});
|
|
56
|
+
export {
|
|
57
|
+
files,
|
|
58
|
+
handler
|
|
59
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SkipNavLink, SkipNavContent } from '@cedarjs/router'
|
|
2
|
+
import '@cedarjs/router/skip-nav.css'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* since the main content isn't usually the first thing in the document,
|
|
6
|
+
* it's important to provide a shortcut for keyboard and screen-reader users to skip to the main content
|
|
7
|
+
* API docs: https://reach.tech/skip-nav/#reach-skip-nav
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type ${singularPascalName}LayoutProps = {
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ${singularPascalName}Layout = ({ children }: ${singularPascalName}LayoutProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{/* renders a link that remains hidden till focused; put it at the top of your layout */}
|
|
18
|
+
<SkipNavLink />
|
|
19
|
+
<nav></nav>
|
|
20
|
+
{/* renders a div as the target for the link; put it next to your main content */}
|
|
21
|
+
<SkipNavContent />
|
|
22
|
+
<main>{children}</main>
|
|
23
|
+
</>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default ${singularPascalName}Layout
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import ${singularPascalName}Layout from './${pascalName}Layout'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof ${singularPascalName}Layout> = {
|
|
6
|
+
component: ${singularPascalName}Layout,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default meta
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof ${singularPascalName}Layout>
|
|
12
|
+
|
|
13
|
+
export const Primary: Story = {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@cedarjs/testing/web'
|
|
2
|
+
|
|
3
|
+
import ${pascalName}Layout from './${pascalName}Layout'
|
|
4
|
+
|
|
5
|
+
// Improve this test with help from the Redwood Testing Doc:
|
|
6
|
+
// https://redwoodjs.com/docs/testing#testing-pages-layouts
|
|
7
|
+
|
|
8
|
+
describe('${pascalName}Layout', () => {
|
|
9
|
+
it('renders successfully', () => {
|
|
10
|
+
expect(() => {
|
|
11
|
+
render(<${pascalName}Layout />)
|
|
12
|
+
}).not.toThrow()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
import { createHandler, getYargsDefaults } from "../yargsCommandHelpers.js";
|
|
3
|
+
const command = "model <name>";
|
|
4
|
+
const description = "Generate a RedwoodRecord model";
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs.positional("name", {
|
|
7
|
+
description: "Name of the model to create",
|
|
8
|
+
type: "string"
|
|
9
|
+
}).option("rollback", {
|
|
10
|
+
description: "Revert all generator actions if an error occurs",
|
|
11
|
+
type: "boolean",
|
|
12
|
+
default: true
|
|
13
|
+
}).epilogue(
|
|
14
|
+
`Also see the ${terminalLink(
|
|
15
|
+
"RedwoodRecord Reference",
|
|
16
|
+
"https://redwoodjs.com/docs/redwoodrecord"
|
|
17
|
+
)}`
|
|
18
|
+
);
|
|
19
|
+
Object.entries(getYargsDefaults()).forEach(([option, config]) => {
|
|
20
|
+
yargs.option(option, config);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const handler = createHandler("model");
|
|
24
|
+
export {
|
|
25
|
+
builder,
|
|
26
|
+
command,
|
|
27
|
+
description,
|
|
28
|
+
handler
|
|
29
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { Listr } from "listr2";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import c from "../../../lib/colors.js";
|
|
5
|
+
import {
|
|
6
|
+
getPaths,
|
|
7
|
+
writeFilesTask,
|
|
8
|
+
generateTemplate
|
|
9
|
+
} from "../../../lib/index.js";
|
|
10
|
+
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
11
|
+
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
12
|
+
import { validateName } from "../helpers.js";
|
|
13
|
+
const TEMPLATE_PATH = path.resolve(
|
|
14
|
+
import.meta.dirname,
|
|
15
|
+
"templates",
|
|
16
|
+
"model.js.template"
|
|
17
|
+
);
|
|
18
|
+
const files = async ({ name, typescript = false }) => {
|
|
19
|
+
const outputFilename = `${name}.${typescript ? "ts" : "js"}`;
|
|
20
|
+
const outputPath = path.join(getPaths().api.models, outputFilename);
|
|
21
|
+
return {
|
|
22
|
+
[outputPath]: await generateTemplate(TEMPLATE_PATH, { name })
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const handler = async ({ force, ...args }) => {
|
|
26
|
+
recordTelemetryAttributes({
|
|
27
|
+
command: "generate model",
|
|
28
|
+
force,
|
|
29
|
+
rollback: args.rollback
|
|
30
|
+
});
|
|
31
|
+
validateName(args.name);
|
|
32
|
+
const tasks = new Listr(
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
title: "Generating model file...",
|
|
36
|
+
task: async () => {
|
|
37
|
+
return writeFilesTask(await files(args), { overwriteExisting: force });
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: "Parsing datamodel, generating api/src/models/index.js...",
|
|
42
|
+
task: async () => {
|
|
43
|
+
const redwoodRecordModule = await import("@cedarjs/record");
|
|
44
|
+
await redwoodRecordModule.default.parseDatamodel();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
49
|
+
);
|
|
50
|
+
try {
|
|
51
|
+
await verifyModelName({ name: args.name });
|
|
52
|
+
if (args.rollback && !force) {
|
|
53
|
+
prepareForRollback(tasks);
|
|
54
|
+
}
|
|
55
|
+
await tasks.run();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.log(c.error(e.message));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
handler
|
|
63
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
3
|
+
import { createHandler } from "../yargsCommandHelpers.js";
|
|
4
|
+
const description = "Generate an og:image component";
|
|
5
|
+
const command = "og-image <path>";
|
|
6
|
+
const aliases = ["ogImage", "ogimage"];
|
|
7
|
+
const builder = (yargs) => {
|
|
8
|
+
yargs.positional("path", {
|
|
9
|
+
description: `Path to the page to create the og:image component for (ex: \`Products/ProductPage\`)`,
|
|
10
|
+
type: "string"
|
|
11
|
+
}).epilogue(
|
|
12
|
+
`Also see the ${terminalLink(
|
|
13
|
+
"Redwood CLI Reference",
|
|
14
|
+
`https://redwoodjs.com/docs/cli-commands#generate-og-image`
|
|
15
|
+
)}`
|
|
16
|
+
).option("typescript", {
|
|
17
|
+
alias: "ts",
|
|
18
|
+
description: "Generate TypeScript files",
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: isTypeScriptProject()
|
|
21
|
+
}).option("force", {
|
|
22
|
+
alias: "f",
|
|
23
|
+
description: "Overwrite existing files",
|
|
24
|
+
type: "boolean",
|
|
25
|
+
default: false
|
|
26
|
+
}).option("verbose", {
|
|
27
|
+
description: "Print all logs",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
default: false
|
|
30
|
+
}).option("rollback", {
|
|
31
|
+
description: "Revert all generator actions if an error occurs",
|
|
32
|
+
type: "boolean",
|
|
33
|
+
default: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const handler = createHandler("ogImage");
|
|
37
|
+
export {
|
|
38
|
+
aliases,
|
|
39
|
+
builder,
|
|
40
|
+
command,
|
|
41
|
+
description,
|
|
42
|
+
handler
|
|
43
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../../../lib/colors.js";
|
|
9
|
+
import {
|
|
10
|
+
generateTemplate,
|
|
11
|
+
getPaths,
|
|
12
|
+
transformTSToJS,
|
|
13
|
+
writeFilesTask
|
|
14
|
+
} from "../../../lib/index.js";
|
|
15
|
+
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
16
|
+
import { customOrDefaultTemplatePath } from "../yargsHandlerHelpers.js";
|
|
17
|
+
const files = async ({ pagePath, typescript = false }) => {
|
|
18
|
+
const extension = typescript ? ".tsx" : ".jsx";
|
|
19
|
+
const componentOutputPath = path.join(
|
|
20
|
+
getPaths().web.pages,
|
|
21
|
+
pagePath + ".og" + extension
|
|
22
|
+
);
|
|
23
|
+
const fullTemplatePath = customOrDefaultTemplatePath({
|
|
24
|
+
generator: "ogImage",
|
|
25
|
+
templatePath: "ogImage.og.tsx.template",
|
|
26
|
+
side: "web"
|
|
27
|
+
});
|
|
28
|
+
const content = await generateTemplate(fullTemplatePath, {
|
|
29
|
+
name: "ogImage",
|
|
30
|
+
outputPath: ensurePosixPath(
|
|
31
|
+
`./${path.relative(getPaths().base, componentOutputPath)}`
|
|
32
|
+
),
|
|
33
|
+
pageName: pagePath.split("/").pop()
|
|
34
|
+
});
|
|
35
|
+
const template = typescript ? content : await transformTSToJS(componentOutputPath, content);
|
|
36
|
+
return {
|
|
37
|
+
[componentOutputPath]: template
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const normalizedPath = (pagePath) => {
|
|
41
|
+
const parts = pagePath.split("/");
|
|
42
|
+
if (parts[0] === "pages") {
|
|
43
|
+
parts.shift();
|
|
44
|
+
}
|
|
45
|
+
if (parts.length === 1) {
|
|
46
|
+
return [parts[0], parts[0]].join("/");
|
|
47
|
+
}
|
|
48
|
+
if (parts[parts.length - 1] === parts[parts.length - 2]) {
|
|
49
|
+
return parts.join("/");
|
|
50
|
+
} else {
|
|
51
|
+
const dir = parts.pop();
|
|
52
|
+
return [...parts, dir, dir].join("/");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const validatePath = async (pagePath, extension, options) => {
|
|
56
|
+
const finalPath = `${pagePath}.${extension}`;
|
|
57
|
+
const pages = await fg(finalPath, {
|
|
58
|
+
cwd: getPaths().web.pages,
|
|
59
|
+
fs: options?.fs || fs
|
|
60
|
+
});
|
|
61
|
+
if (!pages.length) {
|
|
62
|
+
throw Error(`The page ${path.join(pagePath)}.${extension} does not exist`);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
const handler = async (options) => {
|
|
67
|
+
recordTelemetryAttributes({
|
|
68
|
+
command: `generate og-image`,
|
|
69
|
+
verbose: options.verbose,
|
|
70
|
+
rollback: options.rollback,
|
|
71
|
+
force: options.force
|
|
72
|
+
});
|
|
73
|
+
const normalizedPagePath = normalizedPath(options.path);
|
|
74
|
+
const extension = options.typescript ? "tsx" : "jsx";
|
|
75
|
+
try {
|
|
76
|
+
await validatePath(normalizedPagePath, extension);
|
|
77
|
+
const tasks = new Listr(
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
title: `Generating og:image component...`,
|
|
81
|
+
task: async () => {
|
|
82
|
+
const f = await files({
|
|
83
|
+
pagePath: normalizedPagePath,
|
|
84
|
+
typescript: options.typescript
|
|
85
|
+
});
|
|
86
|
+
return writeFilesTask(f, { overwriteExisting: options.force });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
{
|
|
91
|
+
rendererOptions: { collapseSubtasks: false },
|
|
92
|
+
exitOnError: true,
|
|
93
|
+
renderer: options.verbose && "verbose"
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
if (options.rollback && !options.force) {
|
|
97
|
+
prepareForRollback(tasks);
|
|
98
|
+
}
|
|
99
|
+
await tasks.run();
|
|
100
|
+
} catch (e) {
|
|
101
|
+
errorTelemetry(process.argv, e.message);
|
|
102
|
+
console.error(c.error(e.message));
|
|
103
|
+
process.exit(e?.exitCode || 1);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
export {
|
|
107
|
+
files,
|
|
108
|
+
handler,
|
|
109
|
+
normalizedPath,
|
|
110
|
+
validatePath
|
|
111
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const data = async () => {
|
|
2
|
+
return new Date()
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const output = ({ data }) => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<h1>${pageName} og:image</h1>
|
|
9
|
+
<p>Find me in <code>${outputPath}</code></p>
|
|
10
|
+
<p>The time is now {data.toISOString()}</p>
|
|
11
|
+
</>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBuilder,
|
|
3
|
+
createCommand,
|
|
4
|
+
createDescription,
|
|
5
|
+
createHandler
|
|
6
|
+
} from "../yargsCommandHelpers.js";
|
|
7
|
+
const positionalsObj = {
|
|
8
|
+
path: {
|
|
9
|
+
description: "URL path to the page, or just {param}. Defaults to name",
|
|
10
|
+
type: "string"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const command = createCommand("page", positionalsObj);
|
|
14
|
+
const description = createDescription("page");
|
|
15
|
+
const builder = createBuilder({ componentName: "page", positionalsObj });
|
|
16
|
+
const handler = createHandler("page");
|
|
17
|
+
export {
|
|
18
|
+
builder,
|
|
19
|
+
command,
|
|
20
|
+
description,
|
|
21
|
+
handler
|
|
22
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import camelcase from "camelcase";
|
|
3
|
+
import { Listr } from "listr2";
|
|
4
|
+
import pascalcase from "pascalcase";
|
|
5
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
7
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
8
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
|
+
import c from "../../../lib/colors.js";
|
|
10
|
+
import {
|
|
11
|
+
addRoutesToRouterTask,
|
|
12
|
+
transformTSToJS,
|
|
13
|
+
writeFilesTask
|
|
14
|
+
} from "../../../lib/index.js";
|
|
15
|
+
import {
|
|
16
|
+
prepareForRollback,
|
|
17
|
+
addFunctionToRollback
|
|
18
|
+
} from "../../../lib/rollback.js";
|
|
19
|
+
import {
|
|
20
|
+
pathName,
|
|
21
|
+
mapRouteParamTypeToTsType,
|
|
22
|
+
removeGeneratorName,
|
|
23
|
+
validateName
|
|
24
|
+
} from "../helpers.js";
|
|
25
|
+
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
26
|
+
const COMPONENT_SUFFIX = "Page";
|
|
27
|
+
const REDWOOD_WEB_PATH_NAME = "pages";
|
|
28
|
+
const mapRouteParamTypeToDefaultValue = (paramType) => {
|
|
29
|
+
switch (paramType) {
|
|
30
|
+
case "Int":
|
|
31
|
+
return 42;
|
|
32
|
+
case "Float":
|
|
33
|
+
return 42.1;
|
|
34
|
+
case "Boolean":
|
|
35
|
+
return true;
|
|
36
|
+
default:
|
|
37
|
+
return "42";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const paramVariants = (path) => {
|
|
41
|
+
const param = path?.match(/(\{[\w:]+\})/)?.[1];
|
|
42
|
+
const paramName = param?.replace(/:[^}]+/, "").slice(1, -1);
|
|
43
|
+
if (param === void 0) {
|
|
44
|
+
return {
|
|
45
|
+
propParam: "",
|
|
46
|
+
propValueParam: "",
|
|
47
|
+
argumentParam: "",
|
|
48
|
+
paramName: "",
|
|
49
|
+
paramValue: "",
|
|
50
|
+
paramType: ""
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const routeParamType = param?.match(/:/) ? param?.replace(/[^:]+/, "").slice(1, -1) : "String";
|
|
54
|
+
const defaultValue = mapRouteParamTypeToDefaultValue(routeParamType);
|
|
55
|
+
const defaultValueAsProp = routeParamType === "String" ? `'${defaultValue}'` : defaultValue;
|
|
56
|
+
return {
|
|
57
|
+
propParam: `{ ${paramName} }`,
|
|
58
|
+
propValueParam: `${paramName}={${defaultValueAsProp}}`,
|
|
59
|
+
// used in story
|
|
60
|
+
argumentParam: `{ ${paramName}: ${defaultValueAsProp} }`,
|
|
61
|
+
paramName,
|
|
62
|
+
paramValue: defaultValue,
|
|
63
|
+
paramType: mapRouteParamTypeToTsType(routeParamType)
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const files = async ({ name, tests, stories, typescript, ...rest }) => {
|
|
67
|
+
const extension = typescript ? ".tsx" : ".jsx";
|
|
68
|
+
const pageFile = await templateForComponentFile({
|
|
69
|
+
name,
|
|
70
|
+
suffix: COMPONENT_SUFFIX,
|
|
71
|
+
extension,
|
|
72
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
73
|
+
generator: "page",
|
|
74
|
+
templatePath: "page.tsx.template",
|
|
75
|
+
templateVars: {
|
|
76
|
+
rscEnabled: getConfig().experimental?.rsc?.enabled,
|
|
77
|
+
...rest
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const testFile = await templateForComponentFile({
|
|
81
|
+
name,
|
|
82
|
+
suffix: COMPONENT_SUFFIX,
|
|
83
|
+
extension: `.test${extension}`,
|
|
84
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
85
|
+
generator: "page",
|
|
86
|
+
templatePath: "test.tsx.template",
|
|
87
|
+
templateVars: rest
|
|
88
|
+
});
|
|
89
|
+
const storiesFile = await templateForComponentFile({
|
|
90
|
+
name,
|
|
91
|
+
suffix: COMPONENT_SUFFIX,
|
|
92
|
+
extension: `.stories${extension}`,
|
|
93
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
94
|
+
generator: "page",
|
|
95
|
+
templatePath: rest.paramName !== "" ? "stories.tsx.parameters.template" : "stories.tsx.template",
|
|
96
|
+
templateVars: rest
|
|
97
|
+
});
|
|
98
|
+
const files2 = [pageFile];
|
|
99
|
+
if (tests) {
|
|
100
|
+
files2.push(testFile);
|
|
101
|
+
}
|
|
102
|
+
if (stories) {
|
|
103
|
+
files2.push(storiesFile);
|
|
104
|
+
}
|
|
105
|
+
return files2.reduce(async (accP, [outputPath, content]) => {
|
|
106
|
+
const acc = await accP;
|
|
107
|
+
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
108
|
+
return {
|
|
109
|
+
[outputPath]: template,
|
|
110
|
+
...acc
|
|
111
|
+
};
|
|
112
|
+
}, Promise.resolve({}));
|
|
113
|
+
};
|
|
114
|
+
const routes = ({ name, path }) => {
|
|
115
|
+
return [
|
|
116
|
+
`<Route path="${path}" page={${pascalcase(name)}Page} name="${camelcase(
|
|
117
|
+
name
|
|
118
|
+
)}" />`
|
|
119
|
+
];
|
|
120
|
+
};
|
|
121
|
+
const handler = async ({
|
|
122
|
+
name,
|
|
123
|
+
path,
|
|
124
|
+
force,
|
|
125
|
+
tests,
|
|
126
|
+
stories,
|
|
127
|
+
typescript = false,
|
|
128
|
+
rollback
|
|
129
|
+
}) => {
|
|
130
|
+
const pageName = removeGeneratorName(name, "page");
|
|
131
|
+
validateName(pageName);
|
|
132
|
+
if (tests === void 0) {
|
|
133
|
+
tests = getConfig().generate.tests;
|
|
134
|
+
}
|
|
135
|
+
if (stories === void 0) {
|
|
136
|
+
stories = getConfig().generate.stories;
|
|
137
|
+
}
|
|
138
|
+
recordTelemetryAttributes({
|
|
139
|
+
command: "generate page",
|
|
140
|
+
force,
|
|
141
|
+
tests,
|
|
142
|
+
stories,
|
|
143
|
+
typescript,
|
|
144
|
+
rollback
|
|
145
|
+
});
|
|
146
|
+
if (process.platform === "win32") {
|
|
147
|
+
try {
|
|
148
|
+
const slashPath = execSync("cygpath -m /", {
|
|
149
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
150
|
+
}).toString().trim();
|
|
151
|
+
path = path.replace(new RegExp(`^${slashPath}?`), "/");
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const tasks = new Listr(
|
|
156
|
+
[
|
|
157
|
+
{
|
|
158
|
+
title: "Generating page files...",
|
|
159
|
+
task: async () => {
|
|
160
|
+
path = pathName(path, pageName);
|
|
161
|
+
const f = await files({
|
|
162
|
+
name: pageName,
|
|
163
|
+
path,
|
|
164
|
+
tests,
|
|
165
|
+
stories,
|
|
166
|
+
typescript,
|
|
167
|
+
...paramVariants(path)
|
|
168
|
+
});
|
|
169
|
+
return writeFilesTask(f, { overwriteExisting: force });
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
title: "Updating routes file...",
|
|
174
|
+
task: async () => {
|
|
175
|
+
addRoutesToRouterTask(
|
|
176
|
+
routes({ name: pageName, path: pathName(path, pageName) })
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: `Generating types...`,
|
|
182
|
+
task: async () => {
|
|
183
|
+
const { errors } = await generateTypes();
|
|
184
|
+
for (const { message, error } of errors) {
|
|
185
|
+
console.error(message);
|
|
186
|
+
console.log();
|
|
187
|
+
console.error(error);
|
|
188
|
+
console.log();
|
|
189
|
+
}
|
|
190
|
+
addFunctionToRollback(generateTypes, true);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: "One more thing...",
|
|
195
|
+
task: (ctx, task) => {
|
|
196
|
+
task.title = `One more thing...
|
|
197
|
+
|
|
198
|
+
${c.warning("Page created! A note about <Metadata>:")}
|
|
199
|
+
|
|
200
|
+
At the top of your newly created page is a <Metadata> component,
|
|
201
|
+
which contains the title and description for your page, essential
|
|
202
|
+
to good SEO. Check out this page for best practices:
|
|
203
|
+
|
|
204
|
+
https://developers.google.com/search/docs/advanced/appearance/good-titles-snippets
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
].filter(Boolean),
|
|
209
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
210
|
+
);
|
|
211
|
+
try {
|
|
212
|
+
if (rollback && !force) {
|
|
213
|
+
prepareForRollback(tasks);
|
|
214
|
+
}
|
|
215
|
+
await tasks.run();
|
|
216
|
+
} catch (e) {
|
|
217
|
+
errorTelemetry(process.argv, e.message);
|
|
218
|
+
console.error(c.error(e.message));
|
|
219
|
+
process.exit(e?.exitCode || 1);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
export {
|
|
223
|
+
files,
|
|
224
|
+
handler,
|
|
225
|
+
paramVariants,
|
|
226
|
+
routes
|
|
227
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<% if (rscEnabled) { %>
|
|
2
|
+
import { Link } from '@cedarjs/router/Link'
|
|
3
|
+
import { namedRoutes as routes } from '@cedarjs/router/namedRoutes'
|
|
4
|
+
import { Metadata } from '@cedarjs/web/Metadata'
|
|
5
|
+
<% } else { %>
|
|
6
|
+
// import { Link, routes } from '@cedarjs/router'
|
|
7
|
+
import { Metadata } from '@cedarjs/web'
|
|
8
|
+
<% } %>
|
|
9
|
+
|
|
10
|
+
<% if (paramName !== '') { %>
|
|
11
|
+
type ${pascalName}PageProps = {
|
|
12
|
+
${paramName}: ${paramType}
|
|
13
|
+
}
|
|
14
|
+
<% } %>
|
|
15
|
+
const ${pascalName}Page = (<%- paramName === '' ? '' : `${propParam}: ${pascalName}PageProps` %>) => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<Metadata title="${pascalName}" description="${pascalName} page" />
|
|
19
|
+
|
|
20
|
+
<h1>${pascalName}Page</h1>
|
|
21
|
+
<p>
|
|
22
|
+
Find me in <code>${outputPath}</code>
|
|
23
|
+
</p><% if (paramName !== '') { %>
|
|
24
|
+
<p>
|
|
25
|
+
The parameter passed to me is <code>{${ paramName }}</code>
|
|
26
|
+
</p><% } %>
|
|
27
|
+
{/*
|
|
28
|
+
My default route is named `${camelName}`, link to me with:
|
|
29
|
+
`<Link to={routes.${camelName}(${ argumentParam })}>${pascalName}<%= argumentParam !== '' ? ' 42' : '' %></Link>`
|
|
30
|
+
*/}
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default ${pascalName}Page
|