@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,12 @@
|
|
|
1
|
+
import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
|
|
2
|
+
import { createHandler } from "../handlerHelpers.js";
|
|
3
|
+
const description = "Destroy a directive";
|
|
4
|
+
const { builder, tasks } = createHandler({
|
|
5
|
+
componentName: "directive",
|
|
6
|
+
filesFn: (args) => directiveFiles({ ...args, type: "validator" })
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
builder,
|
|
10
|
+
description,
|
|
11
|
+
tasks
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { files as functionFiles } from "../../generate/function/functionHandler.js";
|
|
2
|
+
import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
|
|
3
|
+
const description = "Destroy a Function";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("name", {
|
|
6
|
+
description: "Name of the Function",
|
|
7
|
+
type: "string"
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const { command } = createYargsForComponentDestroy({
|
|
11
|
+
componentName: "function",
|
|
12
|
+
filesFn: functionFiles
|
|
13
|
+
});
|
|
14
|
+
const handler = createHandler("function");
|
|
15
|
+
export {
|
|
16
|
+
builder,
|
|
17
|
+
command,
|
|
18
|
+
description,
|
|
19
|
+
handler
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { files as functionFiles } from "../../generate/function/functionHandler.js";
|
|
2
|
+
import { createHandler } from "../handlerHelpers.js";
|
|
3
|
+
const { handler, tasks } = createHandler({
|
|
4
|
+
componentName: "function",
|
|
5
|
+
filesFn: functionFiles
|
|
6
|
+
});
|
|
7
|
+
export {
|
|
8
|
+
handler,
|
|
9
|
+
tasks
|
|
10
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Listr } from "listr2";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { deleteFilesTask } from "../../lib/index.js";
|
|
4
|
+
const tasks = ({ componentName, filesFn, name }) => new Listr(
|
|
5
|
+
[
|
|
6
|
+
{
|
|
7
|
+
title: `Destroying ${componentName} files...`,
|
|
8
|
+
task: async () => {
|
|
9
|
+
const f = await filesFn({ name, stories: true, tests: true });
|
|
10
|
+
return deleteFilesTask(f);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
15
|
+
);
|
|
16
|
+
function createHandler({
|
|
17
|
+
componentName,
|
|
18
|
+
preTasksFn = (options) => options,
|
|
19
|
+
filesFn
|
|
20
|
+
}) {
|
|
21
|
+
return {
|
|
22
|
+
handler: async (options) => {
|
|
23
|
+
recordTelemetryAttributes({
|
|
24
|
+
command: `destroy ${componentName}`
|
|
25
|
+
});
|
|
26
|
+
options = await preTasksFn({ ...options, isDestroyer: true });
|
|
27
|
+
await tasks({ componentName, filesFn, name: options.name }).run();
|
|
28
|
+
},
|
|
29
|
+
tasks
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
createHandler
|
|
34
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const createYargsForComponentDestroy = ({ componentName }) => {
|
|
2
|
+
return {
|
|
3
|
+
command: `${componentName} <name>`,
|
|
4
|
+
description: `Destroy a ${componentName} component`,
|
|
5
|
+
builder: (yargs) => {
|
|
6
|
+
yargs.positional("name", {
|
|
7
|
+
description: `Name of the ${componentName}`,
|
|
8
|
+
type: "string"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
function createHandler(componentName) {
|
|
14
|
+
return async (argv) => {
|
|
15
|
+
const importedHandler = await import(`./${componentName}Handler.js`);
|
|
16
|
+
return importedHandler(argv);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
createHandler,
|
|
21
|
+
createYargsForComponentDestroy
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { files as layoutFiles } from "../../generate/layout/layoutHandler.js";
|
|
2
|
+
import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
|
|
3
|
+
const { command, description, builder } = createYargsForComponentDestroy(
|
|
4
|
+
{ componentName: "layout", filesFn: layoutFiles }
|
|
5
|
+
);
|
|
6
|
+
const handler = createHandler("layout");
|
|
7
|
+
export {
|
|
8
|
+
builder,
|
|
9
|
+
command,
|
|
10
|
+
description,
|
|
11
|
+
handler
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { files as layoutFiles } from "../../generate/layout/layoutHandler.js";
|
|
2
|
+
import { createHandler } from "../handlerHelpers.js";
|
|
3
|
+
const { handler, tasks } = createHandler({
|
|
4
|
+
componentName: "layout",
|
|
5
|
+
filesFn: layoutFiles
|
|
6
|
+
});
|
|
7
|
+
export {
|
|
8
|
+
handler,
|
|
9
|
+
tasks
|
|
10
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createHandler } from "../helpers.js";
|
|
2
|
+
const command = "page <name> [path]";
|
|
3
|
+
const description = "Destroy a page and route component";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("name", {
|
|
6
|
+
description: "Name of the page",
|
|
7
|
+
type: "string"
|
|
8
|
+
});
|
|
9
|
+
yargs.positional("path", {
|
|
10
|
+
description: "URL path to the page. Defaults to name",
|
|
11
|
+
type: "string"
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const handler = createHandler("page");
|
|
15
|
+
export {
|
|
16
|
+
builder,
|
|
17
|
+
command,
|
|
18
|
+
description,
|
|
19
|
+
handler
|
|
20
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import camelcase from "camelcase";
|
|
2
|
+
import { Listr } from "listr2";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import c from "../../../lib/colors.js";
|
|
5
|
+
import {
|
|
6
|
+
deleteFilesTask,
|
|
7
|
+
removeRoutesFromRouterTask
|
|
8
|
+
} from "../../../lib/index.js";
|
|
9
|
+
import { pathName } from "../../generate/helpers.js";
|
|
10
|
+
import {
|
|
11
|
+
files as pageFiles,
|
|
12
|
+
paramVariants as templateVars
|
|
13
|
+
} from "../../generate/page/pageHandler.js";
|
|
14
|
+
const tasks = ({ name, path }) => new Listr(
|
|
15
|
+
[
|
|
16
|
+
{
|
|
17
|
+
title: "Destroying page files...",
|
|
18
|
+
task: async () => {
|
|
19
|
+
const p = pathName(path, name);
|
|
20
|
+
const f = pageFiles({
|
|
21
|
+
name,
|
|
22
|
+
path: p,
|
|
23
|
+
stories: true,
|
|
24
|
+
tests: true,
|
|
25
|
+
...templateVars(p)
|
|
26
|
+
});
|
|
27
|
+
return deleteFilesTask(f);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "Cleaning up routes file...",
|
|
32
|
+
task: async () => removeRoutesFromRouterTask([camelcase(name)])
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
36
|
+
);
|
|
37
|
+
const handler = async ({ name, path }) => {
|
|
38
|
+
recordTelemetryAttributes({
|
|
39
|
+
command: "destroy page"
|
|
40
|
+
});
|
|
41
|
+
const t = tasks({ name, path });
|
|
42
|
+
try {
|
|
43
|
+
await t.run();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.log(c.error(e.message));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
handler,
|
|
50
|
+
tasks
|
|
51
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHandler } from "../helpers.js";
|
|
2
|
+
const command = "scaffold <model>";
|
|
3
|
+
const description = "Destroy pages, SDL, and Services files based on a given DB schema Model";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("model", {
|
|
6
|
+
description: "Model to destroy the scaffold of",
|
|
7
|
+
type: "string"
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const handler = createHandler("scaffold");
|
|
11
|
+
export {
|
|
12
|
+
builder,
|
|
13
|
+
command,
|
|
14
|
+
description,
|
|
15
|
+
handler
|
|
16
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Listr } from "listr2";
|
|
2
|
+
import pascalcase from "pascalcase";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import c from "../../../lib/colors.js";
|
|
5
|
+
import {
|
|
6
|
+
deleteFilesTask,
|
|
7
|
+
getPaths,
|
|
8
|
+
readFile,
|
|
9
|
+
removeRoutesFromRouterTask,
|
|
10
|
+
writeFile
|
|
11
|
+
} from "../../../lib/index.js";
|
|
12
|
+
import { pluralize } from "../../../lib/rwPluralize.js";
|
|
13
|
+
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
14
|
+
import {
|
|
15
|
+
files,
|
|
16
|
+
routes as scaffoldRoutes,
|
|
17
|
+
splitPathAndModel
|
|
18
|
+
} from "../../generate/scaffold/scaffoldHandler.js";
|
|
19
|
+
const removeRoutesWithSet = async ({ model, path, nestScaffoldByModel }) => {
|
|
20
|
+
const routes = await scaffoldRoutes({ model, path, nestScaffoldByModel });
|
|
21
|
+
const routeNames = routes.map(extractRouteName);
|
|
22
|
+
const pluralPascalName = pascalcase(pluralize(model));
|
|
23
|
+
const layoutName = `${pluralPascalName}Layout`;
|
|
24
|
+
return removeRoutesFromRouterTask(routeNames, layoutName);
|
|
25
|
+
};
|
|
26
|
+
const removeSetImport = () => {
|
|
27
|
+
const routesPath = getPaths().web.routes;
|
|
28
|
+
const routesContent = readFile(routesPath).toString();
|
|
29
|
+
if (routesContent.match("<Set")) {
|
|
30
|
+
return "Skipping removal of Set import in Routes.{jsx,tsx}";
|
|
31
|
+
}
|
|
32
|
+
const [redwoodRouterImport] = routesContent.match(
|
|
33
|
+
/import {[^]*} from '@cedarjs\/router'/
|
|
34
|
+
);
|
|
35
|
+
const removedSetImport = redwoodRouterImport.replace(/,*\s*Set,*/, "");
|
|
36
|
+
const newRoutesContent = routesContent.replace(
|
|
37
|
+
redwoodRouterImport,
|
|
38
|
+
removedSetImport
|
|
39
|
+
);
|
|
40
|
+
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
41
|
+
return "Removed Set import in Routes.{jsx,tsx}";
|
|
42
|
+
};
|
|
43
|
+
const removeLayoutImport = ({ model: name, path: scaffoldPath = "" }) => {
|
|
44
|
+
const pluralPascalName = pascalcase(pluralize(name));
|
|
45
|
+
const pascalScaffoldPath = scaffoldPath === "" ? scaffoldPath : scaffoldPath.split("/").map(pascalcase).join("/") + "/";
|
|
46
|
+
const layoutName = `${pluralPascalName}Layout`;
|
|
47
|
+
const importLayout = `import ${pluralPascalName}Layout from 'src/layouts/${pascalScaffoldPath}${layoutName}'`;
|
|
48
|
+
const routesPath = getPaths().web.routes;
|
|
49
|
+
const routesContent = readFile(routesPath).toString();
|
|
50
|
+
const newRoutesContent = routesContent.replace(
|
|
51
|
+
new RegExp(`\\s*${importLayout}`),
|
|
52
|
+
""
|
|
53
|
+
);
|
|
54
|
+
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
55
|
+
return "Removed layout import from Routes.{jsx,tsx}";
|
|
56
|
+
};
|
|
57
|
+
const tasks = ({ model, path, tests, nestScaffoldByModel }) => new Listr(
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
title: "Destroying scaffold files...",
|
|
61
|
+
task: async () => {
|
|
62
|
+
const f = await files({
|
|
63
|
+
model,
|
|
64
|
+
path,
|
|
65
|
+
tests,
|
|
66
|
+
nestScaffoldByModel
|
|
67
|
+
});
|
|
68
|
+
return deleteFilesTask(f);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: "Cleaning up scaffold routes...",
|
|
73
|
+
task: async () => removeRoutesWithSet({ model, path, nestScaffoldByModel })
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: "Removing set import...",
|
|
77
|
+
task: () => removeSetImport()
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
title: "Removing layout import...",
|
|
81
|
+
task: () => removeLayoutImport({ model, path })
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
85
|
+
);
|
|
86
|
+
const handler = async ({ model: modelArg }) => {
|
|
87
|
+
recordTelemetryAttributes({
|
|
88
|
+
command: "destory scaffold"
|
|
89
|
+
});
|
|
90
|
+
const { model, path } = splitPathAndModel(modelArg);
|
|
91
|
+
try {
|
|
92
|
+
const { name } = await verifyModelName({ name: model, isDestroyer: true });
|
|
93
|
+
await tasks({ model: name, path }).run();
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.log(c.error(e.message));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const extractRouteName = (route) => {
|
|
99
|
+
const { groups } = route.match(/.*name="?(?<routeName>\w+)"?/);
|
|
100
|
+
return groups.routeName;
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
handler,
|
|
104
|
+
tasks
|
|
105
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHandler } from "../helpers.js";
|
|
2
|
+
const command = "sdl <model>";
|
|
3
|
+
const description = "Destroy a GraphQL schema and service component based on a given DB schema Model";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("model", {
|
|
6
|
+
description: "Model to destroy the sdl of",
|
|
7
|
+
type: "string"
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const handler = createHandler("sdl");
|
|
11
|
+
export {
|
|
12
|
+
builder,
|
|
13
|
+
command,
|
|
14
|
+
description,
|
|
15
|
+
handler
|
|
16
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Listr } from "listr2";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
import c from "../../../lib/colors.js";
|
|
4
|
+
import { deleteFilesTask } from "../../../lib/index.js";
|
|
5
|
+
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
6
|
+
import { files } from "../../generate/sdl/sdlHandler.js";
|
|
7
|
+
const tasks = ({ model }) => new Listr(
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
title: "Destroying GraphQL schema and service component files...",
|
|
11
|
+
task: async () => {
|
|
12
|
+
const f = await files({ name: model });
|
|
13
|
+
return deleteFilesTask(f);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
18
|
+
);
|
|
19
|
+
const handler = async ({ model }) => {
|
|
20
|
+
recordTelemetryAttributes({
|
|
21
|
+
command: "destroy sdl"
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
const { name } = await verifyModelName({ name: model, isDestroyer: true });
|
|
25
|
+
await tasks({ model: name }).run();
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.log(c.error(e.message));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
handler,
|
|
32
|
+
tasks
|
|
33
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createHandler, createYargsForComponentDestroy } from "../helpers.js";
|
|
2
|
+
const { command, description } = createYargsForComponentDestroy({
|
|
3
|
+
componentName: "service"
|
|
4
|
+
});
|
|
5
|
+
const handler = createHandler("service");
|
|
6
|
+
export {
|
|
7
|
+
command,
|
|
8
|
+
description,
|
|
9
|
+
handler
|
|
10
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getDefaultArgs } from "../../../lib/index.js";
|
|
2
|
+
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
3
|
+
import { builder } from "../../generate/service/service.js";
|
|
4
|
+
import { files } from "../../generate/service/serviceHandler.js";
|
|
5
|
+
import { createHandler } from "../handlerHelpers.js";
|
|
6
|
+
const filesWithTemplateVars = (templateVars) => {
|
|
7
|
+
return (args) => files({ ...args, ...templateVars });
|
|
8
|
+
};
|
|
9
|
+
const { handler, tasks } = createHandler({
|
|
10
|
+
componentName: "service",
|
|
11
|
+
preTasksFn: verifyModelName,
|
|
12
|
+
filesFn: filesWithTemplateVars({ ...getDefaultArgs(builder), crud: true })
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
handler,
|
|
16
|
+
tasks
|
|
17
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const command = "destroy <type>";
|
|
2
|
+
const aliases = ["d"];
|
|
3
|
+
const description = "Rollback changes made by the generate command";
|
|
4
|
+
import terminalLink from "terminal-link";
|
|
5
|
+
import * as destroyCell from "./destroy/cell/cell.js";
|
|
6
|
+
import * as destroyComponent from "./destroy/component/component.js";
|
|
7
|
+
import * as destroyDirective from "./destroy/directive/directive.js";
|
|
8
|
+
import * as destroyFunction from "./destroy/function/function.js";
|
|
9
|
+
import * as destroyLayout from "./destroy/layout/layout.js";
|
|
10
|
+
import * as destroyPage from "./destroy/page/page.js";
|
|
11
|
+
import * as destroyScaffold from "./destroy/scaffold/scaffold.js";
|
|
12
|
+
import * as destroySdl from "./destroy/sdl/sdl.js";
|
|
13
|
+
import * as destroyService from "./destroy/service/service.js";
|
|
14
|
+
const builder = (yargs) => yargs.command(destroyCell).command(destroyComponent).command(destroyDirective).command(destroyFunction).command(destroyLayout).command(destroyPage).command(destroyScaffold).command(destroySdl).command(destroyService).demandCommand().epilogue(
|
|
15
|
+
`Also see the ${terminalLink(
|
|
16
|
+
"Redwood CLI Reference",
|
|
17
|
+
"https://redwoodjs.com/docs/cli-commands#destroy-alias-d"
|
|
18
|
+
)}`
|
|
19
|
+
);
|
|
20
|
+
export {
|
|
21
|
+
aliases,
|
|
22
|
+
builder,
|
|
23
|
+
command,
|
|
24
|
+
description
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
import c from "../lib/colors.js";
|
|
3
|
+
import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
|
|
4
|
+
const command = "dev [side..]";
|
|
5
|
+
const description = "Start development servers for api, and web";
|
|
6
|
+
const builder = (yargs) => {
|
|
7
|
+
yargs.positional("side", {
|
|
8
|
+
choices: ["api", "web"],
|
|
9
|
+
default: ["api", "web"],
|
|
10
|
+
description: "Which dev server(s) to start",
|
|
11
|
+
type: "array"
|
|
12
|
+
}).option("forward", {
|
|
13
|
+
alias: "fwd",
|
|
14
|
+
description: 'String of one or more vite dev server config options, for example: `--fwd="--port=1234 --open=false"`',
|
|
15
|
+
type: "string",
|
|
16
|
+
hidden: true
|
|
17
|
+
}).option("generate", {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
default: true,
|
|
20
|
+
description: "Generate artifacts"
|
|
21
|
+
}).option("apiDebugPort", {
|
|
22
|
+
type: "number",
|
|
23
|
+
description: "Port on which to expose API server debugger. If you supply the flag with no value it defaults to 18911."
|
|
24
|
+
}).middleware(() => {
|
|
25
|
+
const check = checkNodeVersion();
|
|
26
|
+
if (check.ok) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.warn(`${c.warning("Warning")}: ${check.message}
|
|
30
|
+
`);
|
|
31
|
+
}).epilogue(
|
|
32
|
+
`Also see the ${terminalLink(
|
|
33
|
+
"Redwood CLI Reference",
|
|
34
|
+
"https://redwoodjs.com/docs/cli-commands#dev"
|
|
35
|
+
)}`
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
const handler = async (options) => {
|
|
39
|
+
const { handler: handler2 } = await import("./devHandler.js");
|
|
40
|
+
return handler2(options);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
builder,
|
|
44
|
+
command,
|
|
45
|
+
description,
|
|
46
|
+
handler
|
|
47
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { argv } from "process";
|
|
2
|
+
import concurrently from "concurrently";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
6
|
+
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
7
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
+
import c from "../lib/colors.js";
|
|
9
|
+
import { exitWithError } from "../lib/exit.js";
|
|
10
|
+
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
11
|
+
import { getPaths } from "../lib/index.js";
|
|
12
|
+
import { getFreePort } from "../lib/ports.js";
|
|
13
|
+
import { serverFileExists } from "../lib/project.js";
|
|
14
|
+
const defaultApiDebugPort = 18911;
|
|
15
|
+
const handler = async ({
|
|
16
|
+
side = ["api", "web"],
|
|
17
|
+
forward = "",
|
|
18
|
+
generate = true,
|
|
19
|
+
apiDebugPort
|
|
20
|
+
}) => {
|
|
21
|
+
recordTelemetryAttributes({
|
|
22
|
+
command: "dev",
|
|
23
|
+
side: JSON.stringify(side),
|
|
24
|
+
generate
|
|
25
|
+
});
|
|
26
|
+
const rwjsPaths = getPaths();
|
|
27
|
+
const serverFile = serverFileExists();
|
|
28
|
+
let apiPreferredPort = parseInt(getConfig().api.port);
|
|
29
|
+
let webPreferredPort = parseInt(getConfig().web.port);
|
|
30
|
+
let apiAvailablePort = apiPreferredPort;
|
|
31
|
+
let apiPortChangeNeeded = false;
|
|
32
|
+
let webAvailablePort = webPreferredPort;
|
|
33
|
+
let webPortChangeNeeded = false;
|
|
34
|
+
if (side.includes("api") && !serverFile) {
|
|
35
|
+
apiAvailablePort = await getFreePort(apiPreferredPort);
|
|
36
|
+
if (apiAvailablePort === -1) {
|
|
37
|
+
exitWithError(void 0, {
|
|
38
|
+
message: `Could not determine a free port for the api server`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
apiPortChangeNeeded = apiAvailablePort !== apiPreferredPort;
|
|
42
|
+
}
|
|
43
|
+
if (side.includes("web")) {
|
|
44
|
+
const forwardedPortMatches = [
|
|
45
|
+
...forward.matchAll(/\-\-port(\=|\s)(?<port>[^\s]*)/g)
|
|
46
|
+
];
|
|
47
|
+
if (forwardedPortMatches.length) {
|
|
48
|
+
webPreferredPort = parseInt(forwardedPortMatches.pop().groups.port);
|
|
49
|
+
}
|
|
50
|
+
webAvailablePort = await getFreePort(webPreferredPort, [
|
|
51
|
+
apiPreferredPort,
|
|
52
|
+
apiAvailablePort
|
|
53
|
+
]);
|
|
54
|
+
if (webAvailablePort === -1) {
|
|
55
|
+
exitWithError(void 0, {
|
|
56
|
+
message: `Could not determine a free port for the web server`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
webPortChangeNeeded = webAvailablePort !== webPreferredPort;
|
|
60
|
+
}
|
|
61
|
+
if (apiPortChangeNeeded || webPortChangeNeeded) {
|
|
62
|
+
const message = [
|
|
63
|
+
"The currently configured ports for the development server are",
|
|
64
|
+
"unavailable. Suggested changes to your ports, which can be changed in",
|
|
65
|
+
"redwood.toml, are:\n",
|
|
66
|
+
apiPortChangeNeeded && ` - API to use port ${apiAvailablePort} instead`,
|
|
67
|
+
apiPortChangeNeeded && "of your currently configured",
|
|
68
|
+
apiPortChangeNeeded && `${apiPreferredPort}
|
|
69
|
+
`,
|
|
70
|
+
webPortChangeNeeded && ` - Web to use port ${webAvailablePort} instead`,
|
|
71
|
+
webPortChangeNeeded && "of your currently configured",
|
|
72
|
+
webPortChangeNeeded && `${webPreferredPort}
|
|
73
|
+
`,
|
|
74
|
+
"\nCannot run the development server until your configured ports are",
|
|
75
|
+
"changed or become available."
|
|
76
|
+
].filter(Boolean).join(" ");
|
|
77
|
+
exitWithError(void 0, { message });
|
|
78
|
+
}
|
|
79
|
+
if (side.includes("api")) {
|
|
80
|
+
try {
|
|
81
|
+
await generatePrismaClient({
|
|
82
|
+
verbose: false,
|
|
83
|
+
force: false,
|
|
84
|
+
schema: rwjsPaths.api.dbSchema
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
errorTelemetry(
|
|
88
|
+
process.argv,
|
|
89
|
+
`Error generating prisma client: ${e.message}`
|
|
90
|
+
);
|
|
91
|
+
console.error(c.error(e.message));
|
|
92
|
+
}
|
|
93
|
+
if (!serverFile) {
|
|
94
|
+
try {
|
|
95
|
+
await shutdownPort(apiAvailablePort);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
errorTelemetry(process.argv, `Error shutting down "api": ${e.message}`);
|
|
98
|
+
console.error(
|
|
99
|
+
`Error whilst shutting down "api" port: ${c.error(e.message)}`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (side.includes("web")) {
|
|
105
|
+
try {
|
|
106
|
+
await shutdownPort(webAvailablePort);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
errorTelemetry(process.argv, `Error shutting down "web": ${e.message}`);
|
|
109
|
+
console.error(
|
|
110
|
+
`Error whilst shutting down "web" port: ${c.error(e.message)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const getApiDebugFlag = () => {
|
|
115
|
+
if (apiDebugPort) {
|
|
116
|
+
return `--debug-port ${apiDebugPort}`;
|
|
117
|
+
} else if (argv.includes("--apiDebugPort")) {
|
|
118
|
+
return `--debug-port ${defaultApiDebugPort}`;
|
|
119
|
+
}
|
|
120
|
+
const apiDebugPortInToml = getConfig().api.debugPort;
|
|
121
|
+
if (apiDebugPortInToml) {
|
|
122
|
+
return `--debug-port ${apiDebugPortInToml}`;
|
|
123
|
+
}
|
|
124
|
+
return "";
|
|
125
|
+
};
|
|
126
|
+
const redwoodConfigPath = getConfigPath();
|
|
127
|
+
const streamingSsrEnabled = getConfig().experimental.streamingSsr?.enabled;
|
|
128
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
129
|
+
let webCommand = `yarn cross-env NODE_ENV=development rw-vite-dev ${forward}`;
|
|
130
|
+
if (streamingSsrEnabled) {
|
|
131
|
+
webCommand = `yarn cross-env NODE_ENV=development rw-dev-fe ${forward}`;
|
|
132
|
+
}
|
|
133
|
+
const jobs = {
|
|
134
|
+
api: {
|
|
135
|
+
name: "api",
|
|
136
|
+
command: [
|
|
137
|
+
"yarn nodemon",
|
|
138
|
+
" --quiet",
|
|
139
|
+
` --watch "${redwoodConfigPath}"`,
|
|
140
|
+
' --exec "yarn rw-api-server-watch',
|
|
141
|
+
` --port ${apiAvailablePort}`,
|
|
142
|
+
` ${getApiDebugFlag()}`,
|
|
143
|
+
' | rw-log-formatter"'
|
|
144
|
+
].join(" ").replace(/\s+/g, " "),
|
|
145
|
+
env: {
|
|
146
|
+
NODE_ENV: "development",
|
|
147
|
+
NODE_OPTIONS: getDevNodeOptions()
|
|
148
|
+
},
|
|
149
|
+
prefixColor: "cyan",
|
|
150
|
+
runWhen: () => fs.existsSync(rwjsPaths.api.src)
|
|
151
|
+
},
|
|
152
|
+
web: {
|
|
153
|
+
name: "web",
|
|
154
|
+
command: webCommand,
|
|
155
|
+
prefixColor: "blue",
|
|
156
|
+
cwd: rwjsPaths.web.base,
|
|
157
|
+
runWhen: () => fs.existsSync(rwjsPaths.web.src)
|
|
158
|
+
},
|
|
159
|
+
gen: {
|
|
160
|
+
name: "gen",
|
|
161
|
+
command: "yarn rw-gen-watch",
|
|
162
|
+
prefixColor: "green",
|
|
163
|
+
runWhen: () => generate
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const { result } = concurrently(
|
|
167
|
+
Object.keys(jobs).map((job) => {
|
|
168
|
+
if (side.includes(job) || job === "gen") {
|
|
169
|
+
return jobs[job];
|
|
170
|
+
}
|
|
171
|
+
}).filter((job) => job && job.runWhen()),
|
|
172
|
+
{
|
|
173
|
+
prefix: "{name} |",
|
|
174
|
+
timestampFormat: "HH:mm:ss",
|
|
175
|
+
handleInput: true
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
result.catch((e) => {
|
|
179
|
+
if (typeof e?.message !== "undefined") {
|
|
180
|
+
errorTelemetry(
|
|
181
|
+
process.argv,
|
|
182
|
+
`Error concurrently starting sides: ${e.message}`
|
|
183
|
+
);
|
|
184
|
+
exitWithError(e);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
function getDevNodeOptions() {
|
|
189
|
+
const { NODE_OPTIONS } = process.env;
|
|
190
|
+
const enableSourceMapsOption = "--enable-source-maps";
|
|
191
|
+
if (!NODE_OPTIONS) {
|
|
192
|
+
return enableSourceMapsOption;
|
|
193
|
+
}
|
|
194
|
+
if (NODE_OPTIONS.includes(enableSourceMapsOption)) {
|
|
195
|
+
return NODE_OPTIONS;
|
|
196
|
+
}
|
|
197
|
+
return `${NODE_OPTIONS} ${enableSourceMapsOption}`;
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
getDevNodeOptions,
|
|
201
|
+
handler
|
|
202
|
+
};
|