@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,79 @@
|
|
|
1
|
+
import type { Delete${singularPascalName}Mutation, Delete${singularPascalName}MutationVariables, Find${singularPascalName}By${pascalIdName} } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import { Link, routes, navigate } from '@cedarjs/router'
|
|
4
|
+
import { useMutation } from '@cedarjs/web'
|
|
5
|
+
import type { TypedDocumentNode } from '@cedarjs/web'
|
|
6
|
+
import { toast } from '@cedarjs/web/toast'
|
|
7
|
+
|
|
8
|
+
import { ${formattersImports} } from 'src/lib/formatters'
|
|
9
|
+
|
|
10
|
+
const DELETE_${singularConstantName}_MUTATION: TypedDocumentNode<Delete${singularPascalName}Mutation, Delete${singularPascalName}MutationVariables> = gql`
|
|
11
|
+
mutation Delete${singularPascalName}Mutation($${idName}: ${idType}!) {
|
|
12
|
+
delete${singularPascalName}(${idName}: $${idName}) {
|
|
13
|
+
${idName}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
${singularCamelName}: NonNullable<Find${singularPascalName}By${pascalIdName}['${singularCamelName}']>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ${singularPascalName} = ({ ${singularCamelName} }: Props) => {
|
|
23
|
+
const [delete${singularPascalName}] = useMutation(DELETE_${singularConstantName}_MUTATION, {
|
|
24
|
+
onCompleted: () => {
|
|
25
|
+
toast.success('${singularPascalName} deleted')
|
|
26
|
+
navigate(routes.${pluralRouteName}())
|
|
27
|
+
},
|
|
28
|
+
onError: (error) => {
|
|
29
|
+
toast.error(error.message)
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const onDeleteClick = (${idName}: Delete${singularPascalName}MutationVariables['${idName}']) => {
|
|
34
|
+
if (confirm('Are you sure you want to delete ${singularCamelName} ' + ${idName} + '?')) {
|
|
35
|
+
delete${singularPascalName}({ variables: { ${idName} } })
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<div className="rw-segment">
|
|
42
|
+
<header className="rw-segment-header">
|
|
43
|
+
<h2 className="rw-heading rw-heading-secondary">
|
|
44
|
+
${singularPascalName} {${singularCamelName}.${idName}} Detail
|
|
45
|
+
</h2>
|
|
46
|
+
</header>
|
|
47
|
+
<table className="rw-table">
|
|
48
|
+
<tbody>
|
|
49
|
+
<% columns.forEach(column => { %><tr>
|
|
50
|
+
<th><%= column.label %></th><%
|
|
51
|
+
if (column.displayFunction) { %>
|
|
52
|
+
<td>{${column.displayFunction}(${singularCamelName}.${column.name})}</td><%
|
|
53
|
+
} else { %>
|
|
54
|
+
<td>{${singularCamelName}.${column.name}}</td><%
|
|
55
|
+
} %>
|
|
56
|
+
</tr><% }) %>
|
|
57
|
+
</tbody>
|
|
58
|
+
</table>
|
|
59
|
+
</div>
|
|
60
|
+
<nav className="rw-button-group">
|
|
61
|
+
<Link
|
|
62
|
+
to={routes.${editRouteName}({ ${idName}: ${singularCamelName}.${idName} })}
|
|
63
|
+
className="rw-button rw-button-blue"
|
|
64
|
+
>
|
|
65
|
+
Edit
|
|
66
|
+
</Link>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className="rw-button rw-button-red"
|
|
70
|
+
onClick={() => onDeleteClick(${singularCamelName}.${idName})}
|
|
71
|
+
>
|
|
72
|
+
Delete
|
|
73
|
+
</button>
|
|
74
|
+
</nav>
|
|
75
|
+
</>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default ${singularPascalName}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
${useClientDirective}import type { Find${singularPascalName}By${pascalIdName}, Find${singularPascalName}By${pascalIdName}Variables } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CellSuccessProps,
|
|
5
|
+
CellFailureProps,
|
|
6
|
+
TypedDocumentNode,
|
|
7
|
+
} from '@cedarjs/web'
|
|
8
|
+
|
|
9
|
+
import ${singularPascalName} from '${importComponentName}'
|
|
10
|
+
|
|
11
|
+
export const QUERY: TypedDocumentNode<
|
|
12
|
+
Find${singularPascalName}By${pascalIdName},
|
|
13
|
+
Find${singularPascalName}By${pascalIdName}Variables
|
|
14
|
+
> = gql`
|
|
15
|
+
query Find${singularPascalName}By${pascalIdName}($${idName}: ${idType}!) {
|
|
16
|
+
${singularCamelName}: ${singularCamelName}(${idName}: $${idName}) {<% columns.forEach(column => { %>
|
|
17
|
+
<%= column.name %><% }) %>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
export const Loading = () => <div>Loading...</div>
|
|
23
|
+
|
|
24
|
+
export const Empty = () => <div>${singularPascalName} not found</div>
|
|
25
|
+
|
|
26
|
+
export const Failure = ({ error }: CellFailureProps<Find${singularPascalName}By${pascalIdName}Variables>) => (
|
|
27
|
+
<div className="rw-cell-error">{error?.message}</div>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export const Success = ({ ${singularCamelName} }: CellSuccessProps<Find${singularPascalName}By${pascalIdName}, Find${singularPascalName}By${pascalIdName}Variables>) => {
|
|
31
|
+
return <${singularPascalName} ${singularCamelName}={${singularCamelName}} />
|
|
32
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Edit${singularPascalName}By${pascalIdName}, Update${singularPascalName}Input } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import type { RWGqlError } from '@cedarjs/forms'
|
|
4
|
+
import {
|
|
5
|
+
Form,
|
|
6
|
+
FormError,
|
|
7
|
+
FieldError,
|
|
8
|
+
Label,
|
|
9
|
+
${fieldsToImport.join(',\n ')},
|
|
10
|
+
Submit,
|
|
11
|
+
} from '@cedarjs/forms'
|
|
12
|
+
|
|
13
|
+
<% if (fieldsToImport.includes('DatetimeLocalField')) { %>
|
|
14
|
+
const formatDatetime = (value) => {
|
|
15
|
+
if (value) {
|
|
16
|
+
return value.replace(/:\d{2}\.\d{3}\w/, '')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
<% } %>
|
|
20
|
+
|
|
21
|
+
type Form${singularPascalName} = NonNullable<Edit${singularPascalName}By${pascalIdName}['${singularCamelName}']>
|
|
22
|
+
|
|
23
|
+
interface ${singularPascalName}FormProps {
|
|
24
|
+
${singularCamelName}?: Edit${singularPascalName}By${pascalIdName}['${singularCamelName}']
|
|
25
|
+
onSave: (data: Update${singularPascalName}Input, ${idName}?: Form${singularPascalName}['${idName}']) => void
|
|
26
|
+
error: RWGqlError
|
|
27
|
+
loading: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ${singularPascalName}Form = (props: ${singularPascalName}FormProps) => {
|
|
31
|
+
const onSubmit = (data: Form${singularPascalName}) => {
|
|
32
|
+
<% editableColumns.forEach(column => { %>
|
|
33
|
+
<% if (column.isEnum && !column.isList && !column.isRequired) { %>
|
|
34
|
+
if (data.${column.name} === '') {
|
|
35
|
+
data.${column.name} = null
|
|
36
|
+
}
|
|
37
|
+
<% } %>
|
|
38
|
+
<% if (column.isEnum && column.isList) { %>
|
|
39
|
+
if (data.${column.name}) {
|
|
40
|
+
data.${column.name} = data.${column.name}.filter((value) => !!value)
|
|
41
|
+
}
|
|
42
|
+
<% } %>
|
|
43
|
+
<% }) %>
|
|
44
|
+
props.onSave(data, props?.${singularCamelName}?.${idName})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="rw-form-wrapper">
|
|
49
|
+
<Form<Form${singularPascalName}> onSubmit={onSubmit} error={props.error}>
|
|
50
|
+
<FormError
|
|
51
|
+
error={props.error}
|
|
52
|
+
wrapperClassName="rw-form-error-wrapper"
|
|
53
|
+
titleClassName="rw-form-error-title"
|
|
54
|
+
listClassName="rw-form-error-list"
|
|
55
|
+
/>
|
|
56
|
+
<% editableColumns.forEach(column => { %>
|
|
57
|
+
<Label
|
|
58
|
+
name="${column.name}"
|
|
59
|
+
className="rw-label"
|
|
60
|
+
errorClassName="rw-label rw-label-error"
|
|
61
|
+
>
|
|
62
|
+
${column.label}
|
|
63
|
+
</Label>
|
|
64
|
+
<% if (column.isEnum) { %>
|
|
65
|
+
<% if (!column.isRequired) { %>
|
|
66
|
+
<div className="rw-check-radio-items">
|
|
67
|
+
<${column.component}
|
|
68
|
+
${idName}="${singularCamelName}-${column.name}-none"
|
|
69
|
+
name="${column.name}"
|
|
70
|
+
defaultValue=""
|
|
71
|
+
${column.defaultProp}={!props.${singularCamelName}?.${column.name}}
|
|
72
|
+
className="rw-input"
|
|
73
|
+
errorClassName="rw-input rw-input-error"
|
|
74
|
+
/>
|
|
75
|
+
<div className="rw-check-radio-item-none">
|
|
76
|
+
None
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<% } %>
|
|
80
|
+
<% column.values?.forEach((value, i) => {
|
|
81
|
+
const columnComponentName = column.isList ? `${column.name}[${i}]` : column.name
|
|
82
|
+
%>
|
|
83
|
+
<div className="rw-check-radio-items">
|
|
84
|
+
<${column.component}
|
|
85
|
+
${idName}="${singularCamelName}-${column.name}-${i}"
|
|
86
|
+
name="${columnComponentName}"
|
|
87
|
+
defaultValue="${value.name}"
|
|
88
|
+
${column.defaultProp}={props.${singularCamelName}?.${column.name}?.includes('${value.name}')}
|
|
89
|
+
className="rw-input"
|
|
90
|
+
errorClassName="rw-input rw-input-error"
|
|
91
|
+
/>
|
|
92
|
+
<div>
|
|
93
|
+
${value.name.replace('_', ' ').toLowerCase().replace(/\b\w/g, l => l.toUpperCase())}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<% }) %>
|
|
97
|
+
<% } else { %>
|
|
98
|
+
<${column.component}
|
|
99
|
+
name="${column.name}"
|
|
100
|
+
${column.defaultProp}={${column.deserializeFunction && column.deserializeFunction + '('}props.${singularCamelName}?.<%= column.name %>${column.deserializeFunction && ')'}}
|
|
101
|
+
className="rw-input"
|
|
102
|
+
errorClassName="rw-input rw-input-error"
|
|
103
|
+
<%= !column.validation ? '' : `validation=${column.validation}` %>
|
|
104
|
+
<%= column.isRelationalField && !column.isRequired ? `emptyAs={'undefined'}` : '' %>
|
|
105
|
+
/>
|
|
106
|
+
<% } %>
|
|
107
|
+
|
|
108
|
+
<FieldError name="${column.name}" className="rw-field-error" />
|
|
109
|
+
<% }) %>
|
|
110
|
+
<div className="rw-button-group">
|
|
111
|
+
<Submit
|
|
112
|
+
disabled={props.loading}
|
|
113
|
+
className="rw-button rw-button-blue"
|
|
114
|
+
>
|
|
115
|
+
Save
|
|
116
|
+
</Submit>
|
|
117
|
+
</div>
|
|
118
|
+
</Form>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default ${singularPascalName}Form
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Delete${singularPascalName}Mutation, Delete${singularPascalName}MutationVariables, Find${pluralPascalName} } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import { Link, routes } from '@cedarjs/router'
|
|
4
|
+
import { useMutation } from '@cedarjs/web'
|
|
5
|
+
import type { TypedDocumentNode } from '@cedarjs/web'
|
|
6
|
+
import { toast } from '@cedarjs/web/toast'
|
|
7
|
+
|
|
8
|
+
import { QUERY } from '${importComponentNamesCell}'
|
|
9
|
+
import { ${listFormattersImports} } from 'src/lib/formatters'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const DELETE_${singularConstantName}_MUTATION: TypedDocumentNode<Delete${singularPascalName}Mutation, Delete${singularPascalName}MutationVariables> = gql`
|
|
13
|
+
mutation Delete${singularPascalName}Mutation($${idName}: ${idType}!) {
|
|
14
|
+
delete${singularPascalName}(${idName}: $${idName}) {
|
|
15
|
+
${idName}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
const ${pluralPascalName}List = ({ ${pluralCamelName} }: Find${pluralPascalName}) => {
|
|
21
|
+
const [delete${singularPascalName}] = useMutation(DELETE_${singularConstantName}_MUTATION, {
|
|
22
|
+
onCompleted: () => {
|
|
23
|
+
toast.success('${singularPascalName} deleted')
|
|
24
|
+
},
|
|
25
|
+
onError: (error) => {
|
|
26
|
+
toast.error(error.message)
|
|
27
|
+
},
|
|
28
|
+
// This refetches the query on the list page. Read more about other ways to
|
|
29
|
+
// update the cache over here:
|
|
30
|
+
// https://www.apollographql.com/docs/react/data/mutations/#making-all-other-cache-updates
|
|
31
|
+
refetchQueries: [{ query: QUERY }],
|
|
32
|
+
awaitRefetchQueries: true,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const onDeleteClick = (${idName}: Delete${singularPascalName}MutationVariables['${idName}']) => {
|
|
36
|
+
if (confirm('Are you sure you want to delete ${singularCamelName} ' + ${idName} + '?')) {
|
|
37
|
+
delete${singularPascalName}({ variables: { ${idName} } })
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="rw-segment rw-table-wrapper-responsive">
|
|
43
|
+
<table className="rw-table">
|
|
44
|
+
<thead>
|
|
45
|
+
<tr><% columns.forEach(column => { %>
|
|
46
|
+
<th>${column.label}</th><% }) %>
|
|
47
|
+
<th> </th>
|
|
48
|
+
</tr>
|
|
49
|
+
</thead>
|
|
50
|
+
<tbody>
|
|
51
|
+
{${pluralCamelName}.map((${singularCamelName}) => (
|
|
52
|
+
<tr key={${singularCamelName}.${idName}}><% columns.forEach(column => { %>
|
|
53
|
+
<td>{${column.listDisplayFunction}(${singularCamelName}.${column.name})}</td><% }) %>
|
|
54
|
+
<td>
|
|
55
|
+
<nav className="rw-table-actions">
|
|
56
|
+
<Link
|
|
57
|
+
to={routes.${singularRouteName}({ ${idName}: ${singularCamelName}.${idName} })}
|
|
58
|
+
title={'Show ${singularCamelName} ' + ${singularCamelName}.${idName} + ' detail'}
|
|
59
|
+
className="rw-button rw-button-small"
|
|
60
|
+
>
|
|
61
|
+
Show
|
|
62
|
+
</Link>
|
|
63
|
+
<Link
|
|
64
|
+
to={routes.${editRouteName}({ ${idName}: ${singularCamelName}.${idName} })}
|
|
65
|
+
title={'Edit ${singularCamelName} ' + ${singularCamelName}.${idName}}
|
|
66
|
+
className="rw-button rw-button-small rw-button-blue"
|
|
67
|
+
>
|
|
68
|
+
Edit
|
|
69
|
+
</Link>
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
title={'Delete ${singularCamelName} ' + ${singularCamelName}.${idName}}
|
|
73
|
+
className="rw-button rw-button-small rw-button-red"
|
|
74
|
+
onClick={() => onDeleteClick(${singularCamelName}.${idName})}
|
|
75
|
+
>
|
|
76
|
+
Delete
|
|
77
|
+
</button>
|
|
78
|
+
</nav>
|
|
79
|
+
</td>
|
|
80
|
+
</tr>
|
|
81
|
+
))}
|
|
82
|
+
</tbody>
|
|
83
|
+
</table>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default ${pluralPascalName}List
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
${useClientDirective}import type { Find${pluralPascalName}, Find${pluralPascalName}Variables } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import { Link, routes } from '@cedarjs/router'
|
|
4
|
+
import type {
|
|
5
|
+
CellSuccessProps,
|
|
6
|
+
CellFailureProps,
|
|
7
|
+
TypedDocumentNode,
|
|
8
|
+
} from '@cedarjs/web'
|
|
9
|
+
|
|
10
|
+
import ${pluralPascalName} from '${importComponentNames}'
|
|
11
|
+
|
|
12
|
+
export const QUERY: TypedDocumentNode<
|
|
13
|
+
Find${pluralPascalName},
|
|
14
|
+
Find${pluralPascalName}Variables
|
|
15
|
+
> = gql`
|
|
16
|
+
query Find${pluralPascalName} {
|
|
17
|
+
${pluralCamelName} {<% columns.forEach(column => { %>
|
|
18
|
+
<%= column.name %><% }) %>
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const Loading = () => <div>Loading...</div>
|
|
24
|
+
|
|
25
|
+
export const Empty = () => {
|
|
26
|
+
return (
|
|
27
|
+
<div className="rw-text-center">
|
|
28
|
+
No ${pluralCamelName} yet.{' '}
|
|
29
|
+
<Link
|
|
30
|
+
to={routes.${newRouteName}()}
|
|
31
|
+
className="rw-link"
|
|
32
|
+
>
|
|
33
|
+
Create one?
|
|
34
|
+
</Link>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Failure = ({ error }: CellFailureProps<Find${pluralPascalName}>) => (
|
|
40
|
+
<div className="rw-cell-error">{error?.message}</div>
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export const Success = ({ ${pluralCamelName} }: CellSuccessProps<Find${pluralPascalName}, Find${pluralPascalName}Variables>) => {
|
|
44
|
+
return <${pluralPascalName} ${pluralCamelName}={${pluralCamelName}} />
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
${useClientDirective}import type {
|
|
2
|
+
Create${singularPascalName}Mutation,
|
|
3
|
+
Create${singularPascalName}Input,
|
|
4
|
+
Create${singularPascalName}MutationVariables
|
|
5
|
+
} from 'types/graphql'
|
|
6
|
+
|
|
7
|
+
import { navigate, routes } from '@cedarjs/router'
|
|
8
|
+
import { useMutation } from '@cedarjs/web'
|
|
9
|
+
import type { TypedDocumentNode } from '@cedarjs/web'
|
|
10
|
+
import { toast } from '@cedarjs/web/toast'
|
|
11
|
+
|
|
12
|
+
import ${singularPascalName}Form from '${importComponentNameForm}'
|
|
13
|
+
|
|
14
|
+
const CREATE_${singularConstantName}_MUTATION: TypedDocumentNode<
|
|
15
|
+
Create${singularPascalName}Mutation,
|
|
16
|
+
Create${singularPascalName}MutationVariables
|
|
17
|
+
> = gql`
|
|
18
|
+
mutation Create${singularPascalName}Mutation($input: Create${singularPascalName}Input!) {
|
|
19
|
+
create${singularPascalName}(input: $input) {
|
|
20
|
+
${idName}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
const New${singularPascalName} = () => {
|
|
26
|
+
const [create${singularPascalName}, { loading, error }] = useMutation(
|
|
27
|
+
CREATE_${singularConstantName}_MUTATION,
|
|
28
|
+
{
|
|
29
|
+
onCompleted: () => {
|
|
30
|
+
toast.success('${singularPascalName} created')
|
|
31
|
+
navigate(routes.${pluralRouteName}())
|
|
32
|
+
},
|
|
33
|
+
onError: (error) => {
|
|
34
|
+
toast.error(error.message)
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const onSave = (input: Create${singularPascalName}Input) => {
|
|
40
|
+
create${singularPascalName}({ variables: { input } })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className="rw-segment">
|
|
45
|
+
<header className="rw-segment-header">
|
|
46
|
+
<h2 className="rw-heading rw-heading-secondary">New ${singularPascalName}</h2>
|
|
47
|
+
</header>
|
|
48
|
+
<div className="rw-segment-main">
|
|
49
|
+
<${singularPascalName}Form onSave={onSave} loading={loading} error={error} />
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default New${singularPascalName}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Link, routes } from '@cedarjs/router'
|
|
2
|
+
import { Toaster } from '@cedarjs/web/toast'
|
|
3
|
+
|
|
4
|
+
type LayoutProps = {
|
|
5
|
+
title: string
|
|
6
|
+
titleTo: keyof typeof routes
|
|
7
|
+
buttonLabel: string
|
|
8
|
+
buttonTo: keyof typeof routes
|
|
9
|
+
children: React.ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ScaffoldLayout = ({
|
|
13
|
+
title,
|
|
14
|
+
titleTo,
|
|
15
|
+
buttonLabel,
|
|
16
|
+
buttonTo,
|
|
17
|
+
children,
|
|
18
|
+
}: LayoutProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<div className="rw-scaffold">
|
|
21
|
+
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
|
|
22
|
+
<header className="rw-header">
|
|
23
|
+
<h1 className="rw-heading rw-heading-primary">
|
|
24
|
+
<Link to={routes[titleTo]()} className="rw-link">
|
|
25
|
+
{title}
|
|
26
|
+
</Link>
|
|
27
|
+
</h1>
|
|
28
|
+
<Link to={routes[buttonTo]()} className="rw-button rw-button-green">
|
|
29
|
+
<div className="rw-button-icon">+</div> {buttonLabel}
|
|
30
|
+
</Link>
|
|
31
|
+
</header>
|
|
32
|
+
<main className="rw-main">{children}</main>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default ScaffoldLayout
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { render, waitFor, screen } from '@cedarjs/testing/web'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
formatEnum,
|
|
5
|
+
jsonTruncate,
|
|
6
|
+
truncate,
|
|
7
|
+
timeTag,
|
|
8
|
+
jsonDisplay,
|
|
9
|
+
checkboxInputTag,
|
|
10
|
+
} from './formatters'
|
|
11
|
+
|
|
12
|
+
describe('formatEnum', () => {
|
|
13
|
+
it('handles nullish values', () => {
|
|
14
|
+
expect(formatEnum(null)).toEqual('')
|
|
15
|
+
expect(formatEnum('')).toEqual('')
|
|
16
|
+
expect(formatEnum(undefined)).toEqual('')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('formats a list of values', () => {
|
|
20
|
+
expect(
|
|
21
|
+
formatEnum(['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'VIOLET'])
|
|
22
|
+
).toEqual('Red, Orange, Yellow, Green, Blue, Violet')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('formats a single value', () => {
|
|
26
|
+
expect(formatEnum('DARK_BLUE')).toEqual('Dark blue')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('returns an empty string for values of the wrong type (for JS projects)', () => {
|
|
30
|
+
// @ts-expect-error - Testing JS scenario
|
|
31
|
+
expect(formatEnum(5)).toEqual('')
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('truncate', () => {
|
|
36
|
+
it('truncates really long strings', () => {
|
|
37
|
+
expect(truncate('na '.repeat(1000) + 'batman').length).toBeLessThan(1000)
|
|
38
|
+
expect(truncate('na '.repeat(1000) + 'batman')).not.toMatch(/batman/)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('does not modify short strings', () => {
|
|
42
|
+
expect(truncate('Short strinG')).toEqual('Short strinG')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('adds ... to the end of truncated strings', () => {
|
|
46
|
+
expect(truncate('repeat'.repeat(1000))).toMatch(/\w\.\.\.$/)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('accepts numbers', () => {
|
|
50
|
+
expect(truncate(123)).toEqual('123')
|
|
51
|
+
expect(truncate(0)).toEqual('0')
|
|
52
|
+
expect(truncate(0o000)).toEqual('0')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('handles arguments of invalid type', () => {
|
|
56
|
+
// @ts-expect-error - Testing JS scenario
|
|
57
|
+
expect(truncate(false)).toEqual('false')
|
|
58
|
+
|
|
59
|
+
expect(truncate(undefined)).toEqual('')
|
|
60
|
+
expect(truncate(null)).toEqual('')
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
describe('jsonTruncate', () => {
|
|
65
|
+
it('truncates large json structures', () => {
|
|
66
|
+
expect(
|
|
67
|
+
jsonTruncate({
|
|
68
|
+
foo: 'foo',
|
|
69
|
+
bar: 'bar',
|
|
70
|
+
baz: 'baz',
|
|
71
|
+
kittens: 'kittens meow',
|
|
72
|
+
bazinga: 'Sheldon',
|
|
73
|
+
nested: {
|
|
74
|
+
foobar: 'I have no imagination',
|
|
75
|
+
two: 'Second nested item',
|
|
76
|
+
},
|
|
77
|
+
five: 5,
|
|
78
|
+
bool: false,
|
|
79
|
+
})
|
|
80
|
+
).toMatch(/.+\n.+\w\.\.\.$/s)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('timeTag', () => {
|
|
85
|
+
it('renders a date', async () => {
|
|
86
|
+
render(<div>{timeTag(new Date('1970-08-20').toUTCString())}</div>)
|
|
87
|
+
|
|
88
|
+
await waitFor(() => screen.getByText(/1970.*00:00:00/))
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('can take an empty input string', async () => {
|
|
92
|
+
expect(timeTag('')).toEqual('')
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('jsonDisplay', () => {
|
|
97
|
+
it('produces the correct output', () => {
|
|
98
|
+
expect(
|
|
99
|
+
jsonDisplay({
|
|
100
|
+
title: 'TOML Example (but in JSON)',
|
|
101
|
+
database: {
|
|
102
|
+
data: [['delta', 'phi'], [3.14]],
|
|
103
|
+
enabled: true,
|
|
104
|
+
ports: [8000, 8001, 8002],
|
|
105
|
+
temp_targets: {
|
|
106
|
+
case: 72.0,
|
|
107
|
+
cpu: 79.5,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
owner: {
|
|
111
|
+
dob: '1979-05-27T07:32:00-08:00',
|
|
112
|
+
name: 'Tom Preston-Werner',
|
|
113
|
+
},
|
|
114
|
+
servers: {
|
|
115
|
+
alpha: {
|
|
116
|
+
ip: '10.0.0.1',
|
|
117
|
+
role: 'frontend',
|
|
118
|
+
},
|
|
119
|
+
beta: {
|
|
120
|
+
ip: '10.0.0.2',
|
|
121
|
+
role: 'backend',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
).toMatchInlineSnapshot(`
|
|
126
|
+
<pre>
|
|
127
|
+
<code>
|
|
128
|
+
{
|
|
129
|
+
"title": "TOML Example (but in JSON)",
|
|
130
|
+
"database": {
|
|
131
|
+
"data": [
|
|
132
|
+
[
|
|
133
|
+
"delta",
|
|
134
|
+
"phi"
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
3.14
|
|
138
|
+
]
|
|
139
|
+
],
|
|
140
|
+
"enabled": true,
|
|
141
|
+
"ports": [
|
|
142
|
+
8000,
|
|
143
|
+
8001,
|
|
144
|
+
8002
|
|
145
|
+
],
|
|
146
|
+
"temp_targets": {
|
|
147
|
+
"case": 72,
|
|
148
|
+
"cpu": 79.5
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"owner": {
|
|
152
|
+
"dob": "1979-05-27T07:32:00-08:00",
|
|
153
|
+
"name": "Tom Preston-Werner"
|
|
154
|
+
},
|
|
155
|
+
"servers": {
|
|
156
|
+
"alpha": {
|
|
157
|
+
"ip": "10.0.0.1",
|
|
158
|
+
"role": "frontend"
|
|
159
|
+
},
|
|
160
|
+
"beta": {
|
|
161
|
+
"ip": "10.0.0.2",
|
|
162
|
+
"role": "backend"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</code>
|
|
167
|
+
</pre>
|
|
168
|
+
`)
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('checkboxInputTag', () => {
|
|
173
|
+
it('can be checked', () => {
|
|
174
|
+
render(checkboxInputTag(true))
|
|
175
|
+
expect(screen.getByRole('checkbox')).toBeChecked()
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('can be unchecked', () => {
|
|
179
|
+
render(checkboxInputTag(false))
|
|
180
|
+
expect(screen.getByRole('checkbox')).not.toBeChecked()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('is disabled when checked', () => {
|
|
184
|
+
render(checkboxInputTag(true))
|
|
185
|
+
expect(screen.getByRole('checkbox')).toBeDisabled()
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('is disabled when unchecked', () => {
|
|
189
|
+
render(checkboxInputTag(false))
|
|
190
|
+
expect(screen.getByRole('checkbox')).toBeDisabled()
|
|
191
|
+
})
|
|
192
|
+
})
|