@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,153 @@
|
|
|
1
|
+
import pascalcase from "pascalcase";
|
|
2
|
+
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
3
|
+
import { nameVariants, transformTSToJS } from "../../../lib/index.js";
|
|
4
|
+
import { isWordPluralizable } from "../../../lib/pluralHelpers.js";
|
|
5
|
+
import { addFunctionToRollback } from "../../../lib/rollback.js";
|
|
6
|
+
import { isPlural, singularize } from "../../../lib/rwPluralize.js";
|
|
7
|
+
import { getSchema } from "../../../lib/schemaHelpers.js";
|
|
8
|
+
import { forcePluralizeWord, removeGeneratorName } from "../helpers.js";
|
|
9
|
+
import {
|
|
10
|
+
createHandler,
|
|
11
|
+
templateForComponentFile
|
|
12
|
+
} from "../yargsHandlerHelpers.js";
|
|
13
|
+
import {
|
|
14
|
+
checkProjectForQueryField,
|
|
15
|
+
getIdName,
|
|
16
|
+
getIdType,
|
|
17
|
+
operationNameIsUnique,
|
|
18
|
+
uniqueOperationName
|
|
19
|
+
} from "./utils/utils.js";
|
|
20
|
+
const COMPONENT_SUFFIX = "Cell";
|
|
21
|
+
const REDWOOD_WEB_PATH_NAME = "components";
|
|
22
|
+
const files = async ({ name, typescript, ...argv }) => {
|
|
23
|
+
let cellName = removeGeneratorName(name, "cell");
|
|
24
|
+
let idName = "id";
|
|
25
|
+
let idType, mockIdValues = [42, 43, 44], model = null;
|
|
26
|
+
let templateNameSuffix = "";
|
|
27
|
+
let typeName = cellName;
|
|
28
|
+
const shouldGenerateList = (isWordPluralizable(cellName) ? isPlural(cellName) : argv.list) || argv.list;
|
|
29
|
+
try {
|
|
30
|
+
model = await getSchema(pascalcase(singularize(cellName)));
|
|
31
|
+
idName = getIdName(model);
|
|
32
|
+
idType = getIdType(model);
|
|
33
|
+
typeName = model.name;
|
|
34
|
+
mockIdValues = idType === "String" ? mockIdValues.map((value) => `'${value}'`) : mockIdValues;
|
|
35
|
+
} catch {
|
|
36
|
+
idType = "Int";
|
|
37
|
+
}
|
|
38
|
+
if (shouldGenerateList) {
|
|
39
|
+
cellName = forcePluralizeWord(cellName);
|
|
40
|
+
templateNameSuffix = "List";
|
|
41
|
+
}
|
|
42
|
+
let operationName = argv.query;
|
|
43
|
+
if (operationName) {
|
|
44
|
+
const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(operationName);
|
|
45
|
+
if (!userSpecifiedOperationNameIsUnique) {
|
|
46
|
+
throw new Error(`Specified query name: "${operationName}" is not unique!`);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
operationName = await uniqueOperationName(cellName, {
|
|
50
|
+
list: shouldGenerateList
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const extension = typescript ? ".tsx" : ".jsx";
|
|
54
|
+
const cellFile = await templateForComponentFile({
|
|
55
|
+
name: cellName,
|
|
56
|
+
suffix: COMPONENT_SUFFIX,
|
|
57
|
+
extension,
|
|
58
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
59
|
+
generator: "cell",
|
|
60
|
+
templatePath: `cell${templateNameSuffix}.tsx.template`,
|
|
61
|
+
templateVars: {
|
|
62
|
+
operationName,
|
|
63
|
+
idName,
|
|
64
|
+
idType
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const testFile = await templateForComponentFile({
|
|
68
|
+
name: cellName,
|
|
69
|
+
suffix: COMPONENT_SUFFIX,
|
|
70
|
+
extension: `.test${extension}`,
|
|
71
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
72
|
+
generator: "cell",
|
|
73
|
+
templatePath: "test.js.template",
|
|
74
|
+
templateVars: {
|
|
75
|
+
idName: shouldGenerateList ? void 0 : idName,
|
|
76
|
+
mockIdValues: shouldGenerateList ? void 0 : mockIdValues
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const storiesFile = await templateForComponentFile({
|
|
80
|
+
name: cellName,
|
|
81
|
+
suffix: COMPONENT_SUFFIX,
|
|
82
|
+
extension: `.stories${extension}`,
|
|
83
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
84
|
+
generator: "cell",
|
|
85
|
+
templatePath: "stories.tsx.template"
|
|
86
|
+
});
|
|
87
|
+
const mockFile = await templateForComponentFile({
|
|
88
|
+
name: cellName,
|
|
89
|
+
suffix: COMPONENT_SUFFIX,
|
|
90
|
+
extension: typescript ? ".mock.ts" : ".mock.js",
|
|
91
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
92
|
+
generator: "cell",
|
|
93
|
+
templatePath: `mock${templateNameSuffix}.ts.template`,
|
|
94
|
+
templateVars: {
|
|
95
|
+
idName,
|
|
96
|
+
mockIdValues,
|
|
97
|
+
typeName
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const files2 = [cellFile];
|
|
101
|
+
if (argv.stories) {
|
|
102
|
+
files2.push(storiesFile);
|
|
103
|
+
}
|
|
104
|
+
if (argv.tests) {
|
|
105
|
+
files2.push(testFile);
|
|
106
|
+
}
|
|
107
|
+
if (argv.stories || argv.tests) {
|
|
108
|
+
files2.push(mockFile);
|
|
109
|
+
}
|
|
110
|
+
return files2.reduce(async (accP, [outputPath, content]) => {
|
|
111
|
+
const acc = await accP;
|
|
112
|
+
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
113
|
+
return {
|
|
114
|
+
[outputPath]: template,
|
|
115
|
+
...acc
|
|
116
|
+
};
|
|
117
|
+
}, Promise.resolve({}));
|
|
118
|
+
};
|
|
119
|
+
const handler = createHandler({
|
|
120
|
+
componentName: "cell",
|
|
121
|
+
filesFn: files,
|
|
122
|
+
includeAdditionalTasks: ({ name: cellName }) => {
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
title: `Generating types ...`,
|
|
126
|
+
task: async (_ctx, task) => {
|
|
127
|
+
const queryFieldName = nameVariants(
|
|
128
|
+
removeGeneratorName(cellName, "cell")
|
|
129
|
+
).camelName;
|
|
130
|
+
const projectHasSdl = await checkProjectForQueryField(queryFieldName);
|
|
131
|
+
if (projectHasSdl) {
|
|
132
|
+
const { errors } = await generateTypes();
|
|
133
|
+
for (const { message, error } of errors) {
|
|
134
|
+
console.error(message);
|
|
135
|
+
console.log();
|
|
136
|
+
console.error(error);
|
|
137
|
+
console.log();
|
|
138
|
+
}
|
|
139
|
+
addFunctionToRollback(generateTypes, true);
|
|
140
|
+
} else {
|
|
141
|
+
task.skip(
|
|
142
|
+
`Skipping type generation: no SDL defined for "${queryFieldName}". To generate types, run 'yarn rw g sdl ${queryFieldName}'.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
export {
|
|
151
|
+
files,
|
|
152
|
+
handler
|
|
153
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ${operationName}, ${operationName}Variables } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CellSuccessProps,
|
|
5
|
+
CellFailureProps,
|
|
6
|
+
TypedDocumentNode,
|
|
7
|
+
} from '@cedarjs/web'
|
|
8
|
+
|
|
9
|
+
export const QUERY: TypedDocumentNode<
|
|
10
|
+
${operationName},
|
|
11
|
+
${operationName}Variables
|
|
12
|
+
> = gql`
|
|
13
|
+
query ${operationName}($id: ${idType}!) {
|
|
14
|
+
${camelName}: ${camelName}(${idName}: $id) {
|
|
15
|
+
${idName}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const Loading = () => <div>Loading...</div>
|
|
21
|
+
|
|
22
|
+
export const Empty = () => <div>Empty</div>
|
|
23
|
+
|
|
24
|
+
export const Failure = ({
|
|
25
|
+
error,
|
|
26
|
+
}: CellFailureProps<${operationName}Variables>) => (
|
|
27
|
+
<div style={{ color: 'red' }}>Error: {error?.message}</div>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export const Success = ({
|
|
31
|
+
${camelName},
|
|
32
|
+
}: CellSuccessProps<${operationName}, ${operationName}Variables>) => {
|
|
33
|
+
return <div>{JSON.stringify(${camelName})}</div>
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ${operationName}, ${operationName}Variables } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CellSuccessProps,
|
|
5
|
+
CellFailureProps,
|
|
6
|
+
TypedDocumentNode,
|
|
7
|
+
} from '@cedarjs/web'
|
|
8
|
+
|
|
9
|
+
export const QUERY: TypedDocumentNode<
|
|
10
|
+
${operationName},
|
|
11
|
+
${operationName}Variables
|
|
12
|
+
> = gql`
|
|
13
|
+
query ${operationName} {
|
|
14
|
+
${camelName} {
|
|
15
|
+
${idName}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const Loading = () => <div>Loading...</div>
|
|
21
|
+
|
|
22
|
+
export const Empty = () => <div>Empty</div>
|
|
23
|
+
|
|
24
|
+
export const Failure = ({
|
|
25
|
+
error,
|
|
26
|
+
}: CellFailureProps<${operationName}Variables>) => (
|
|
27
|
+
<div style={{ color: 'red' }}>Error: {error?.message}</div>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export const Success = ({
|
|
31
|
+
${camelName},
|
|
32
|
+
}: CellSuccessProps<${operationName}, ${operationName}Variables>) => {
|
|
33
|
+
return (
|
|
34
|
+
<ul>
|
|
35
|
+
{${camelName}.map((item) => {
|
|
36
|
+
return <li key={item.${idName}}>{JSON.stringify(item)}</li>
|
|
37
|
+
})}
|
|
38
|
+
</ul>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Define your own mock data here:
|
|
2
|
+
export const standard = (/* vars, { ctx, req } */) => ({
|
|
3
|
+
${camelName}: [
|
|
4
|
+
{
|
|
5
|
+
__typename: "${typeName}" as const,
|
|
6
|
+
${idName}: ${mockIdValues[0]} },
|
|
7
|
+
{
|
|
8
|
+
__typename: "${typeName}" as const,
|
|
9
|
+
${idName}: ${mockIdValues[1]} },
|
|
10
|
+
{
|
|
11
|
+
__typename: "${typeName}" as const,
|
|
12
|
+
${idName}: ${mockIdValues[2]} }
|
|
13
|
+
]
|
|
14
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import { Loading, Empty, Failure, Success } from './${pascalName}Cell'
|
|
4
|
+
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
+
|
|
6
|
+
const meta: Meta = {
|
|
7
|
+
title: 'Cells/${pascalName}Cell',
|
|
8
|
+
tags: ['autodocs']
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
|
|
13
|
+
export const loading: StoryObj<typeof Loading> = {
|
|
14
|
+
render: () => {
|
|
15
|
+
return Loading ? <Loading /> : <></>
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const empty: StoryObj<typeof Empty> = {
|
|
20
|
+
render: () => {
|
|
21
|
+
return Empty ? <Empty /> : <></>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const failure: StoryObj<typeof Failure> = {
|
|
26
|
+
render: (args) => {
|
|
27
|
+
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></>
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const success: StoryObj<typeof Success> = {
|
|
32
|
+
render: (args) => {
|
|
33
|
+
return Success ? <Success {...standard()} {...args} /> : <></>
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { render } from '@cedarjs/testing/web'
|
|
2
|
+
|
|
3
|
+
import { Loading, Empty, Failure, Success } from './${pascalName}Cell'
|
|
4
|
+
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
+
|
|
6
|
+
// Generated boilerplate tests do not account for all circumstances
|
|
7
|
+
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
|
+
// Please refer to the RedwoodJS Testing Docs:
|
|
9
|
+
// https://redwoodjs.com/docs/testing#testing-cells
|
|
10
|
+
// https://redwoodjs.com/docs/testing#jest-expect-type-considerations
|
|
11
|
+
|
|
12
|
+
describe('${pascalName}Cell', () => {
|
|
13
|
+
it('renders Loading successfully', () => {
|
|
14
|
+
expect(() => {
|
|
15
|
+
render(<Loading />)
|
|
16
|
+
}).not.toThrow()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('renders Empty successfully', async () => {
|
|
20
|
+
expect(() => {
|
|
21
|
+
render(<Empty />)
|
|
22
|
+
}).not.toThrow()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('renders Failure successfully', async () => {
|
|
26
|
+
expect(() => {
|
|
27
|
+
render(<Failure <% if (idName) { %>${idName}={${mockIdValues[0]}} <% } %>error={new Error('Oh no')} />)
|
|
28
|
+
}).not.toThrow()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// When you're ready to test the actual output of your component render
|
|
32
|
+
// you could test that, for example, certain text is present:
|
|
33
|
+
//
|
|
34
|
+
// 1. import { screen } from '@cedarjs/testing/web'
|
|
35
|
+
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument()
|
|
36
|
+
|
|
37
|
+
it('renders Success successfully', async () => {
|
|
38
|
+
expect(() => {
|
|
39
|
+
render(<Success <% if (idName) { %>${idName}={${mockIdValues[0]}} <% } %>${camelName}={standard().${camelName}} />)
|
|
40
|
+
}).not.toThrow()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import pascalcase from "pascalcase";
|
|
2
|
+
import { listQueryTypeFieldsInProject } from "@cedarjs/internal/dist/gql";
|
|
3
|
+
const getCellOperationNames = async () => {
|
|
4
|
+
const { getProject } = await import("@cedarjs/structure");
|
|
5
|
+
return getProject().cells.map((x) => {
|
|
6
|
+
return x.queryOperationName;
|
|
7
|
+
}).filter(Boolean);
|
|
8
|
+
};
|
|
9
|
+
const uniqueOperationName = async (name, { index = 1, list = false }) => {
|
|
10
|
+
let operationName = pascalcase(
|
|
11
|
+
index <= 1 ? `find_${name}_query` : `find_${name}_query_${index}`
|
|
12
|
+
);
|
|
13
|
+
if (list) {
|
|
14
|
+
operationName = index <= 1 ? `${pascalcase(name)}Query` : `${pascalcase(name)}Query_${index}`;
|
|
15
|
+
}
|
|
16
|
+
const cellOperationNames = await getCellOperationNames();
|
|
17
|
+
if (!cellOperationNames.includes(operationName)) {
|
|
18
|
+
return operationName;
|
|
19
|
+
}
|
|
20
|
+
return uniqueOperationName(name, { index: index + 1 });
|
|
21
|
+
};
|
|
22
|
+
const operationNameIsUnique = async (operationName) => {
|
|
23
|
+
const cellOperationNames = await getCellOperationNames();
|
|
24
|
+
return !cellOperationNames.includes(operationName);
|
|
25
|
+
};
|
|
26
|
+
const getIdType = (model) => {
|
|
27
|
+
return model.fields.find((field) => field.isId)?.type;
|
|
28
|
+
};
|
|
29
|
+
const getIdName = (model) => {
|
|
30
|
+
return model.fields.find((field) => field.isId)?.name;
|
|
31
|
+
};
|
|
32
|
+
const checkProjectForQueryField = async (queryFieldName) => {
|
|
33
|
+
const queryFields = await listQueryTypeFieldsInProject();
|
|
34
|
+
return queryFields.includes(queryFieldName);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
checkProjectForQueryField,
|
|
38
|
+
getCellOperationNames,
|
|
39
|
+
getIdName,
|
|
40
|
+
getIdType,
|
|
41
|
+
operationNameIsUnique,
|
|
42
|
+
uniqueOperationName
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCommand,
|
|
3
|
+
createBuilder,
|
|
4
|
+
createHandler
|
|
5
|
+
} from "../yargsCommandHelpers.js";
|
|
6
|
+
const command = createCommand("component");
|
|
7
|
+
const description = "Generate a component";
|
|
8
|
+
const builder = createBuilder({ componentName: "component" });
|
|
9
|
+
const handler = createHandler("component");
|
|
10
|
+
export {
|
|
11
|
+
builder,
|
|
12
|
+
command,
|
|
13
|
+
description,
|
|
14
|
+
handler
|
|
15
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { transformTSToJS } from "../../../lib/index.js";
|
|
2
|
+
import {
|
|
3
|
+
createHandler,
|
|
4
|
+
templateForComponentFile
|
|
5
|
+
} from "../yargsHandlerHelpers.js";
|
|
6
|
+
const REDWOOD_WEB_PATH_NAME = "components";
|
|
7
|
+
const files = async ({ name, typescript = false, ...argv }) => {
|
|
8
|
+
const extension = typescript ? ".tsx" : ".jsx";
|
|
9
|
+
const componentFile = await templateForComponentFile({
|
|
10
|
+
name,
|
|
11
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
12
|
+
extension,
|
|
13
|
+
generator: "component",
|
|
14
|
+
templatePath: "component.tsx.template"
|
|
15
|
+
});
|
|
16
|
+
const testFile = await templateForComponentFile({
|
|
17
|
+
name,
|
|
18
|
+
extension: `.test${extension}`,
|
|
19
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
20
|
+
generator: "component",
|
|
21
|
+
templatePath: "test.tsx.template"
|
|
22
|
+
});
|
|
23
|
+
const storiesFile = await templateForComponentFile({
|
|
24
|
+
name,
|
|
25
|
+
extension: `.stories${extension}`,
|
|
26
|
+
webPathSection: REDWOOD_WEB_PATH_NAME,
|
|
27
|
+
generator: "component",
|
|
28
|
+
// Using two different template files here because we have a TS-specific
|
|
29
|
+
// information in a comment in the .tsx template
|
|
30
|
+
templatePath: typescript ? "stories.tsx.template" : "stories.jsx.template"
|
|
31
|
+
});
|
|
32
|
+
const files2 = [componentFile];
|
|
33
|
+
if (argv.stories) {
|
|
34
|
+
files2.push(storiesFile);
|
|
35
|
+
}
|
|
36
|
+
if (argv.tests) {
|
|
37
|
+
files2.push(testFile);
|
|
38
|
+
}
|
|
39
|
+
return files2.reduce(async (accP, [outputPath, content]) => {
|
|
40
|
+
const acc = await accP;
|
|
41
|
+
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
42
|
+
return {
|
|
43
|
+
[outputPath]: template,
|
|
44
|
+
...acc
|
|
45
|
+
};
|
|
46
|
+
}, Promise.resolve({}));
|
|
47
|
+
};
|
|
48
|
+
const handler = createHandler({
|
|
49
|
+
componentName: "component",
|
|
50
|
+
filesFn: files
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
files,
|
|
54
|
+
handler
|
|
55
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Pass props to your component by passing an `args` object to your story
|
|
2
|
+
//
|
|
3
|
+
// ```jsx
|
|
4
|
+
// export const Primary = {
|
|
5
|
+
// args: {
|
|
6
|
+
// propName: propValue
|
|
7
|
+
// }
|
|
8
|
+
// }
|
|
9
|
+
// ```
|
|
10
|
+
//
|
|
11
|
+
// See https://storybook.js.org/docs/7/writing-stories/args
|
|
12
|
+
|
|
13
|
+
import ${pascalName} from './${pascalName}'
|
|
14
|
+
|
|
15
|
+
export default { component: ${pascalName} }
|
|
16
|
+
|
|
17
|
+
export const Primary = {}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Pass props to your component by passing an `args` object to your story
|
|
2
|
+
//
|
|
3
|
+
// ```tsx
|
|
4
|
+
// export const Primary: Story = {
|
|
5
|
+
// args: {
|
|
6
|
+
// propName: propValue
|
|
7
|
+
// }
|
|
8
|
+
// }
|
|
9
|
+
// ```
|
|
10
|
+
//
|
|
11
|
+
// See https://storybook.js.org/docs/7/writing-stories/args
|
|
12
|
+
|
|
13
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
14
|
+
|
|
15
|
+
import ${pascalName} from './${pascalName}'
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof ${pascalName}> = {
|
|
18
|
+
component: ${pascalName},
|
|
19
|
+
tags: ['autodocs']
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default meta
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof ${pascalName}>
|
|
25
|
+
|
|
26
|
+
export const Primary: Story = {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@cedarjs/testing/web'
|
|
2
|
+
|
|
3
|
+
import ${pascalName} from './${pascalName}'
|
|
4
|
+
|
|
5
|
+
// Improve this test with help from the Redwood Testing Doc:
|
|
6
|
+
// https://redwoodjs.com/docs/testing#testing-components
|
|
7
|
+
|
|
8
|
+
describe('${pascalName}', () => {
|
|
9
|
+
it('renders successfully', () => {
|
|
10
|
+
expect(() => {
|
|
11
|
+
render(<${pascalName} />)
|
|
12
|
+
}).not.toThrow()
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { paramCase } from "change-case";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import terminalLink from "terminal-link";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
7
|
+
import c from "../../../lib/colors.js";
|
|
8
|
+
import { getPaths, writeFilesTask } from "../../../lib/index.js";
|
|
9
|
+
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
10
|
+
import { validateName } from "../helpers.js";
|
|
11
|
+
import { getYargsDefaults } from "../yargsCommandHelpers.js";
|
|
12
|
+
const POST_RUN_INSTRUCTIONS = `Next steps...
|
|
13
|
+
|
|
14
|
+
${c.warning(
|
|
15
|
+
"After writing your migration, you can run it with:"
|
|
16
|
+
)}
|
|
17
|
+
|
|
18
|
+
yarn rw dataMigrate up
|
|
19
|
+
`;
|
|
20
|
+
const TEMPLATE_PATHS = {
|
|
21
|
+
js: path.resolve(
|
|
22
|
+
import.meta.dirname,
|
|
23
|
+
"templates",
|
|
24
|
+
"dataMigration.js.template"
|
|
25
|
+
),
|
|
26
|
+
ts: path.resolve(
|
|
27
|
+
import.meta.dirname,
|
|
28
|
+
"templates",
|
|
29
|
+
"dataMigration.ts.template"
|
|
30
|
+
)
|
|
31
|
+
};
|
|
32
|
+
const files = ({ name, typescript }) => {
|
|
33
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
34
|
+
const timestamp = now.split(".")[0].replace(/\D/g, "");
|
|
35
|
+
const basename = `${timestamp}-${paramCase(name)}`;
|
|
36
|
+
const extension = typescript ? "ts" : "js";
|
|
37
|
+
const outputFilename = basename + "." + extension;
|
|
38
|
+
const outputPath = path.join(getPaths().api.dataMigrations, outputFilename);
|
|
39
|
+
return {
|
|
40
|
+
[outputPath]: fs.readFileSync(TEMPLATE_PATHS[extension]).toString()
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const command = "data-migration <name>";
|
|
44
|
+
const aliases = ["dataMigration", "dm"];
|
|
45
|
+
const description = "Generate a data migration";
|
|
46
|
+
const builder = (yargs) => {
|
|
47
|
+
yargs.positional("name", {
|
|
48
|
+
description: "A descriptor of what this data migration does",
|
|
49
|
+
type: "string"
|
|
50
|
+
}).option("rollback", {
|
|
51
|
+
description: "Revert all generator actions if an error occurs",
|
|
52
|
+
type: "boolean",
|
|
53
|
+
default: true
|
|
54
|
+
}).epilogue(
|
|
55
|
+
`Also see the ${terminalLink(
|
|
56
|
+
"Redwood CLI Reference",
|
|
57
|
+
"https://redwoodjs.com/docs/cli-commands#generate-datamigration"
|
|
58
|
+
)}`
|
|
59
|
+
);
|
|
60
|
+
Object.entries(getYargsDefaults()).forEach(([option, config]) => {
|
|
61
|
+
yargs.option(option, config);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const handler = async (args) => {
|
|
65
|
+
recordTelemetryAttributes({
|
|
66
|
+
command: "generate data-migration",
|
|
67
|
+
force: args.force,
|
|
68
|
+
rollback: args.rollback
|
|
69
|
+
});
|
|
70
|
+
validateName(args.name);
|
|
71
|
+
const tasks = new Listr(
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
title: "Generating data migration file...",
|
|
75
|
+
task: () => {
|
|
76
|
+
return writeFilesTask(files(args));
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
title: "Next steps...",
|
|
81
|
+
task: (_ctx, task) => {
|
|
82
|
+
task.title = POST_RUN_INSTRUCTIONS;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
].filter(Boolean),
|
|
86
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
87
|
+
);
|
|
88
|
+
try {
|
|
89
|
+
if (args.rollback && !args.force) {
|
|
90
|
+
prepareForRollback(tasks);
|
|
91
|
+
}
|
|
92
|
+
await tasks.run();
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.log(c.error(e.message));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
aliases,
|
|
100
|
+
builder,
|
|
101
|
+
command,
|
|
102
|
+
description,
|
|
103
|
+
files,
|
|
104
|
+
handler
|
|
105
|
+
};
|