@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,163 @@
|
|
|
1
|
+
import { parse, traverse } from "@babel/core";
|
|
2
|
+
import generate from "@babel/generator";
|
|
3
|
+
import { VISITOR_KEYS } from "@babel/types";
|
|
4
|
+
import { partition, forEachRight } from "lodash";
|
|
5
|
+
import prettier from "prettier";
|
|
6
|
+
import { forEachFunctionOn, nodeIs } from "./algorithms.js";
|
|
7
|
+
import { semanticIdentity } from "./semanticIdentity.js";
|
|
8
|
+
import { isOpaque } from "./strategy.js";
|
|
9
|
+
function extractProperty(property, fromObject) {
|
|
10
|
+
if (property === void 0) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
const tmp = fromObject[property];
|
|
14
|
+
delete fromObject[property];
|
|
15
|
+
return tmp;
|
|
16
|
+
}
|
|
17
|
+
function getProgramPath(ast) {
|
|
18
|
+
let programPath;
|
|
19
|
+
traverse(ast, {
|
|
20
|
+
Program(path) {
|
|
21
|
+
programPath = path;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (programPath === void 0) {
|
|
26
|
+
throw new Error("Unable to find Program node in AST");
|
|
27
|
+
}
|
|
28
|
+
return programPath;
|
|
29
|
+
}
|
|
30
|
+
function skipChildren(path) {
|
|
31
|
+
for (const key of VISITOR_KEYS[path.type]) {
|
|
32
|
+
path.skipKey(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function makeProxy(path) {
|
|
36
|
+
return new Proxy(path, {
|
|
37
|
+
get(target, property) {
|
|
38
|
+
if (property === "path") {
|
|
39
|
+
return target;
|
|
40
|
+
} else {
|
|
41
|
+
return target.node[property];
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
set(target, property, value) {
|
|
45
|
+
if (property === "path") {
|
|
46
|
+
throw new Error("You can't set a path on a proxy!");
|
|
47
|
+
} else {
|
|
48
|
+
target.node[property] = value;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
has(target, property) {
|
|
53
|
+
return property in target.node;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function expressionUses(exp, ...ids) {
|
|
58
|
+
let result = false;
|
|
59
|
+
exp.traverse({
|
|
60
|
+
Identifier(path) {
|
|
61
|
+
if (!path.parentPath.isNodeType("VariableDeclarator") && ids.includes(path.node.name)) {
|
|
62
|
+
result = true;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
function insertBeforeFirstUsage(expression, program) {
|
|
70
|
+
const body = program.get("body");
|
|
71
|
+
const pos = body.findIndex(
|
|
72
|
+
(exp) => expressionUses(exp, ...Object.keys(expression.getBindingIdentifiers()))
|
|
73
|
+
);
|
|
74
|
+
return pos !== -1 ? body[pos].insertBefore(expression.node) : program.pushContainer("body", expression.node);
|
|
75
|
+
}
|
|
76
|
+
function insertAfterLastImport(expression, program) {
|
|
77
|
+
const body = program.get("body");
|
|
78
|
+
return body[body.findLastIndex((bodyExpr) => bodyExpr.isNodeType("ImportDeclaration"))].insertAfter(expression.node);
|
|
79
|
+
}
|
|
80
|
+
function prune(path) {
|
|
81
|
+
switch (path.parentPath.type) {
|
|
82
|
+
// If pruning 'path' would yield an ill-formed parent (e.g, '{foo:}' or 'const x;'), prune it.
|
|
83
|
+
case "ObjectProperty":
|
|
84
|
+
case "VariableDeclarator":
|
|
85
|
+
return path.parentPath.remove();
|
|
86
|
+
default:
|
|
87
|
+
console.log(`Warning: default prune strategy for ${path.parentPath.type}`);
|
|
88
|
+
// eslint-disable-next-line no-fallthrough
|
|
89
|
+
case "Program":
|
|
90
|
+
case "ArrayExpression":
|
|
91
|
+
return path.remove();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function stripTrailingCommentsStrategy() {
|
|
95
|
+
return {
|
|
96
|
+
enter(path) {
|
|
97
|
+
path.node.trailingComments = [];
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function mergeAST(baseAST, extAST, strategy = {}) {
|
|
102
|
+
const identity = extractProperty("identity", strategy) ?? semanticIdentity;
|
|
103
|
+
const identities = {};
|
|
104
|
+
const baseVisitor = { ...stripTrailingCommentsStrategy() };
|
|
105
|
+
const extVisitor = { ...stripTrailingCommentsStrategy() };
|
|
106
|
+
forEachFunctionOn(strategy, (typename, strat) => {
|
|
107
|
+
extVisitor[typename] = {
|
|
108
|
+
enter(path) {
|
|
109
|
+
const id = identity(path);
|
|
110
|
+
id && (identities[id] ||= []).push(path);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
baseVisitor[typename] = {
|
|
114
|
+
enter(path) {
|
|
115
|
+
if (isOpaque(strat)) {
|
|
116
|
+
skipChildren(path);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
exit(path) {
|
|
120
|
+
const exts = extractProperty(identity(path), identities);
|
|
121
|
+
if (exts) {
|
|
122
|
+
const proxyPath = makeProxy(path);
|
|
123
|
+
exts.map(makeProxy).forEach((ext) => {
|
|
124
|
+
strat(proxyPath, ext);
|
|
125
|
+
prune(ext.path);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
traverse(extAST, extVisitor);
|
|
132
|
+
traverse(baseAST, baseVisitor);
|
|
133
|
+
const baseProgram = getProgramPath(baseAST);
|
|
134
|
+
const [imports, others] = partition(
|
|
135
|
+
getProgramPath(extAST).get("body"),
|
|
136
|
+
nodeIs("ImportDeclaration")
|
|
137
|
+
);
|
|
138
|
+
imports.forEach((exp) => insertAfterLastImport(exp, baseProgram));
|
|
139
|
+
forEachRight(others, (exp) => insertBeforeFirstUsage(exp, baseProgram));
|
|
140
|
+
}
|
|
141
|
+
async function merge(base, extension, strategy) {
|
|
142
|
+
function parseReact(code2) {
|
|
143
|
+
return parse(code2, {
|
|
144
|
+
filename: "merged.tsx",
|
|
145
|
+
// required to prevent babel error. The .tsx is relevant
|
|
146
|
+
presets: ["@babel/preset-typescript"]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const baseAST = parseReact(base);
|
|
150
|
+
const extAST = parseReact(extension);
|
|
151
|
+
mergeAST(baseAST, extAST, strategy);
|
|
152
|
+
const { code } = generate(baseAST);
|
|
153
|
+
return process.env.VITEST_POOL_ID ? await prettier.format(code, {
|
|
154
|
+
parser: "babel-ts",
|
|
155
|
+
bracketSpacing: true,
|
|
156
|
+
tabWidth: 2,
|
|
157
|
+
semi: false,
|
|
158
|
+
singleQuote: true
|
|
159
|
+
}) : code;
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
merge
|
|
163
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function semanticIdentity(path) {
|
|
2
|
+
const identity = {
|
|
3
|
+
get(path2) {
|
|
4
|
+
return path2.type in this ? this[path2.type](path2) : [path2.type];
|
|
5
|
+
},
|
|
6
|
+
ObjectProperty: (path2) => [path2.node.key.name],
|
|
7
|
+
VariableDeclarator: (path2) => [path2.node.id.name],
|
|
8
|
+
ImportDeclaration: (path2) => [
|
|
9
|
+
"ImportDeclaration",
|
|
10
|
+
"source",
|
|
11
|
+
path2.node.source.value
|
|
12
|
+
]
|
|
13
|
+
};
|
|
14
|
+
return path.getAncestry().reduce((acc, i) => [...identity.get(i), ...acc], []).join(".");
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
semanticIdentity
|
|
18
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import { nodeIs, sieve } from "./algorithms.js";
|
|
4
|
+
const OPAQUE_UID_TAG = "RW_MERGE_OPAQUE_UID_Q2xldmVyIHlvdSEgSGF2ZSBhIGNvb2tpZS4=";
|
|
5
|
+
function requireSameType(base, ext) {
|
|
6
|
+
if (base.path.type !== ext.path.type) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"Attempting to merge nodes with different types. This is not yet supported."
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function requireStrategyExists(base, _ext, strategy, strategyName) {
|
|
13
|
+
if (!(base.path.type in strategy)) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Attempting to ${strategyName} nodes that do not have an ${strategyName} strategy.`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const strictEquality = (lhs, rhs) => lhs === rhs;
|
|
20
|
+
const byName = (lhs, rhs) => lhs.name === rhs.name;
|
|
21
|
+
const byKeyName = (lhs, rhs) => lhs.key.name === rhs.key.name;
|
|
22
|
+
const byValue = (lhs, rhs) => lhs.value === rhs.value;
|
|
23
|
+
function defaultEquality(baseContainer, extContainer) {
|
|
24
|
+
const sample = baseContainer.length && baseContainer[0] || extContainer.length && extContainer[0];
|
|
25
|
+
const defaults = {
|
|
26
|
+
BigIntLiteral: byValue,
|
|
27
|
+
BooleanLiteral: byValue,
|
|
28
|
+
Identifier: byName,
|
|
29
|
+
NumericLiteral: byValue,
|
|
30
|
+
ObjectProperty: byKeyName,
|
|
31
|
+
StringLiteral: byValue
|
|
32
|
+
};
|
|
33
|
+
return sample && sample.type in defaults ? defaults[sample.type] : strictEquality;
|
|
34
|
+
}
|
|
35
|
+
function opaquely(strategy) {
|
|
36
|
+
strategy[OPAQUE_UID_TAG] = true;
|
|
37
|
+
return strategy;
|
|
38
|
+
}
|
|
39
|
+
function isOpaque(strategy) {
|
|
40
|
+
return strategy[OPAQUE_UID_TAG] === true;
|
|
41
|
+
}
|
|
42
|
+
const keepBase = opaquely(() => {
|
|
43
|
+
});
|
|
44
|
+
const keepBoth = opaquely((base, ext) => {
|
|
45
|
+
base.path.insertAfter(ext.path.node);
|
|
46
|
+
});
|
|
47
|
+
const keepExtension = opaquely((base, ext) => {
|
|
48
|
+
base.path.replaceWith(ext.path);
|
|
49
|
+
});
|
|
50
|
+
const keepBothStatementParents = opaquely((base, ext) => {
|
|
51
|
+
base.path.getStatementParent().insertAfter(ext.path.getStatementParent().node);
|
|
52
|
+
});
|
|
53
|
+
const interleaveStrategy = {
|
|
54
|
+
ImportDeclaration(baseImport, extImport) {
|
|
55
|
+
const baseSpecs = baseImport.specifiers;
|
|
56
|
+
const extSpecs = extImport.specifiers;
|
|
57
|
+
const importSpecifierEquality = (lhs, rhs) => lhs.type === rhs.type && lhs.imported?.name === rhs.imported?.name && lhs.local?.name == rhs.local?.name;
|
|
58
|
+
const uniqueSpecifiersOfType = (type) => _.uniqWith(
|
|
59
|
+
[...baseSpecs, ...extSpecs].filter(nodeIs(type)),
|
|
60
|
+
importSpecifierEquality
|
|
61
|
+
);
|
|
62
|
+
if (!baseSpecs.length !== !extSpecs.length) {
|
|
63
|
+
return keepBothStatementParents(baseImport, extImport);
|
|
64
|
+
}
|
|
65
|
+
const defaultPosition = (specs) => specs.some(nodeIs("ImportDefaultSpecifier")) ? -1 : 0;
|
|
66
|
+
const namespacePosition = (specs) => specs.some(nodeIs("ImportNamespaceSpecifier")) || specs.some(nodeIs("ImportSpecifier")) ? -1 : specs.length;
|
|
67
|
+
const importPosition = (specs) => specs.some(nodeIs("ImportNamespaceIdentifier")) ? -1 : specs.length;
|
|
68
|
+
const [firstSpecifierList, ...rest] = sieve(
|
|
69
|
+
[uniqueSpecifiersOfType("ImportDefaultSpecifier"), defaultPosition],
|
|
70
|
+
[uniqueSpecifiersOfType("ImportNamespaceSpecifier"), namespacePosition],
|
|
71
|
+
[uniqueSpecifiersOfType("ImportSpecifier"), importPosition]
|
|
72
|
+
);
|
|
73
|
+
baseImport.specifiers = firstSpecifierList;
|
|
74
|
+
if (rest.length) {
|
|
75
|
+
baseImport.path.insertAfter(
|
|
76
|
+
rest.map((specs) => t.importDeclaration(specs, baseImport.source))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function interleave(base, ext) {
|
|
82
|
+
requireSameType(base, ext);
|
|
83
|
+
requireStrategyExists(base, ext, interleaveStrategy, "interleave");
|
|
84
|
+
return interleaveStrategy[base.path.type](base, ext);
|
|
85
|
+
}
|
|
86
|
+
const concatStrategy = {
|
|
87
|
+
ArrayExpression(base, ext) {
|
|
88
|
+
base.elements = [...base.elements, ...ext.elements];
|
|
89
|
+
},
|
|
90
|
+
ObjectExpression(base, ext) {
|
|
91
|
+
base.properties = [...base.properties, ...ext.properties];
|
|
92
|
+
},
|
|
93
|
+
StringLiteral(base, ext) {
|
|
94
|
+
base.value = base.value.concat(ext.value);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function concat(base, ext) {
|
|
98
|
+
requireSameType(base, ext);
|
|
99
|
+
requireStrategyExists(base, ext, concatStrategy, "concat");
|
|
100
|
+
return concatStrategy[base.path.type](base, ext);
|
|
101
|
+
}
|
|
102
|
+
const concatUniqueStrategy = {
|
|
103
|
+
ArrayExpression(base, ext, eq) {
|
|
104
|
+
eq ||= defaultEquality(base.elements, ext.elements);
|
|
105
|
+
base.elements = _.uniqWith([...base.elements, ...ext.elements], eq);
|
|
106
|
+
},
|
|
107
|
+
ObjectExpression(base, ext, eq) {
|
|
108
|
+
eq ||= defaultEquality(base.properties, ext.properties);
|
|
109
|
+
base.properties = _.uniqWith([...base.properties, ...ext.properties], eq);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function concatUnique(baseOrEq, ext) {
|
|
113
|
+
if (arguments.length === 1) {
|
|
114
|
+
return (base, ext2) => {
|
|
115
|
+
requireSameType(base, ext2);
|
|
116
|
+
requireStrategyExists(base, ext2, concatUniqueStrategy, "concatUnique");
|
|
117
|
+
return concatUniqueStrategy[base.path.type](base, ext2, baseOrEq);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (arguments.length === 2) {
|
|
121
|
+
requireSameType(baseOrEq, ext);
|
|
122
|
+
requireStrategyExists(baseOrEq, ext, concatUniqueStrategy, "concatUnique");
|
|
123
|
+
return concatUniqueStrategy[baseOrEq.path.type](baseOrEq, ext);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
concat,
|
|
128
|
+
concatUnique,
|
|
129
|
+
interleave,
|
|
130
|
+
isOpaque,
|
|
131
|
+
keepBase,
|
|
132
|
+
keepBoth,
|
|
133
|
+
keepBothStatementParents,
|
|
134
|
+
keepExtension,
|
|
135
|
+
opaquely
|
|
136
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import execa from "execa";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { getPaths } from "./index.js";
|
|
6
|
+
async function installModule(name, version = void 0) {
|
|
7
|
+
if (isModuleInstalled(name)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (version === void 0) {
|
|
11
|
+
return installRedwoodModule(name);
|
|
12
|
+
} else {
|
|
13
|
+
await execa.command(`yarn add -D ${name}@${version}`, {
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
cwd: getPaths().base
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
async function installRedwoodModule(module) {
|
|
21
|
+
const packageJson = await import("@cedarjs/cli/package.json", { with: { type: "json" } });
|
|
22
|
+
let version = packageJson.default.version;
|
|
23
|
+
if (!isModuleInstalled(module)) {
|
|
24
|
+
if (version.includes("+")) {
|
|
25
|
+
version = version.split("+")[0];
|
|
26
|
+
}
|
|
27
|
+
let packument;
|
|
28
|
+
try {
|
|
29
|
+
const packumentResponse = await fetch(
|
|
30
|
+
`https://registry.npmjs.org/${module}`
|
|
31
|
+
);
|
|
32
|
+
packument = await packumentResponse.json();
|
|
33
|
+
if (packument.error) {
|
|
34
|
+
throw new Error(packument.error);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Couldn't fetch packument for ${module}: ${error.message}`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const versionIsPublished = Object.keys(packument.versions).includes(version);
|
|
42
|
+
if (!versionIsPublished) {
|
|
43
|
+
version = "canary";
|
|
44
|
+
}
|
|
45
|
+
await execa.command(`yarn add -D ${module}@${version}`, {
|
|
46
|
+
stdio: "inherit",
|
|
47
|
+
cwd: getPaths().base
|
|
48
|
+
});
|
|
49
|
+
await execa.command(`yarn dedupe`, {
|
|
50
|
+
stdio: "inherit",
|
|
51
|
+
cwd: getPaths().base
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
function isModuleInstalled(module) {
|
|
58
|
+
const { dependencies, devDependencies } = fs.readJSONSync(
|
|
59
|
+
path.join(getPaths().base, "package.json")
|
|
60
|
+
);
|
|
61
|
+
const deps = {
|
|
62
|
+
...dependencies,
|
|
63
|
+
...devDependencies
|
|
64
|
+
};
|
|
65
|
+
if (deps[module]) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const createdRequire = createRequire(import.meta.url);
|
|
69
|
+
return createdRequire.resolve.paths(`${module}/package.json`).some((requireResolvePath) => {
|
|
70
|
+
return fs.existsSync(path.join(requireResolvePath, module));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
installModule,
|
|
75
|
+
installRedwoodModule,
|
|
76
|
+
isModuleInstalled
|
|
77
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import enquirer from "enquirer";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { installModule, isModuleInstalled } from "./packages.js";
|
|
7
|
+
import { getPaths } from "./index.js";
|
|
8
|
+
const { Select } = enquirer;
|
|
9
|
+
const PLUGIN_CACHE_FILENAME = "commandCache.json";
|
|
10
|
+
const PLUGIN_CACHE_DEFAULT = {
|
|
11
|
+
"@cedarjs/cli-storybook-vite": {
|
|
12
|
+
storybook: {
|
|
13
|
+
aliases: ["sb"],
|
|
14
|
+
description: "Launch Storybook: a tool for building UI components and pages in isolation"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"@cedarjs/cli-data-migrate": {
|
|
18
|
+
"data-migrate <command>": {
|
|
19
|
+
aliases: ["dataMigrate", "dm"],
|
|
20
|
+
description: "Migrate the data in your database"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const PLUGIN_CACHE_BUILTIN = [
|
|
25
|
+
"build",
|
|
26
|
+
"check",
|
|
27
|
+
"diagnostics",
|
|
28
|
+
"console",
|
|
29
|
+
"c",
|
|
30
|
+
"deploy",
|
|
31
|
+
"destroy",
|
|
32
|
+
"d",
|
|
33
|
+
"dev",
|
|
34
|
+
"exec",
|
|
35
|
+
"experimental",
|
|
36
|
+
"exp",
|
|
37
|
+
"generate",
|
|
38
|
+
"g",
|
|
39
|
+
"info",
|
|
40
|
+
"lint",
|
|
41
|
+
"prerender",
|
|
42
|
+
"render",
|
|
43
|
+
"prisma",
|
|
44
|
+
"record",
|
|
45
|
+
"serve",
|
|
46
|
+
"setup",
|
|
47
|
+
"test",
|
|
48
|
+
"ts-to-js",
|
|
49
|
+
"type-check",
|
|
50
|
+
"tsc",
|
|
51
|
+
"tc",
|
|
52
|
+
"upgrade"
|
|
53
|
+
];
|
|
54
|
+
function loadCommandCache() {
|
|
55
|
+
let pluginCommandCache = PLUGIN_CACHE_DEFAULT;
|
|
56
|
+
const commandCachePath = path.join(
|
|
57
|
+
getPaths().generated.base,
|
|
58
|
+
PLUGIN_CACHE_FILENAME
|
|
59
|
+
);
|
|
60
|
+
try {
|
|
61
|
+
const localCommandCache = JSON.parse(fs.readFileSync(commandCachePath));
|
|
62
|
+
let valid = true;
|
|
63
|
+
for (const [key, value] of Object.entries(localCommandCache)) {
|
|
64
|
+
if (key === "_builtin") {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
valid &&= !Array.isArray(value);
|
|
68
|
+
}
|
|
69
|
+
if (valid) {
|
|
70
|
+
pluginCommandCache = {
|
|
71
|
+
...localCommandCache,
|
|
72
|
+
...PLUGIN_CACHE_DEFAULT
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error.code !== "ENOENT") {
|
|
77
|
+
console.error(`Error loading plugin command cache at ${commandCachePath}`);
|
|
78
|
+
console.error(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
pluginCommandCache._builtin = PLUGIN_CACHE_BUILTIN;
|
|
82
|
+
return pluginCommandCache;
|
|
83
|
+
}
|
|
84
|
+
function saveCommandCache(pluginCommandCache) {
|
|
85
|
+
const commandCachePath = path.join(
|
|
86
|
+
getPaths().generated.base,
|
|
87
|
+
PLUGIN_CACHE_FILENAME
|
|
88
|
+
);
|
|
89
|
+
try {
|
|
90
|
+
fs.writeFileSync(
|
|
91
|
+
commandCachePath,
|
|
92
|
+
JSON.stringify(pluginCommandCache, void 0, 2)
|
|
93
|
+
);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(`Error saving plugin command cache at ${commandCachePath}`);
|
|
96
|
+
console.error(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function checkPluginListAndWarn(plugins) {
|
|
100
|
+
for (const plugin of plugins) {
|
|
101
|
+
if (!plugin.package) {
|
|
102
|
+
console.warn(
|
|
103
|
+
chalk.yellow(`\u26A0\uFE0F A plugin is missing a package, it cannot be loaded.`)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const pluginPackages = plugins.map((p) => p.package).filter((p) => p !== void 0);
|
|
108
|
+
if (pluginPackages.length !== new Set(pluginPackages).size) {
|
|
109
|
+
console.warn(
|
|
110
|
+
chalk.yellow(
|
|
111
|
+
"\u26A0\uFE0F Duplicate plugin packages found in redwood.toml, duplicates will be ignored."
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const namespaces = plugins.map((p) => p.package?.split("/")[0]);
|
|
116
|
+
namespaces.forEach((ns) => {
|
|
117
|
+
if (ns !== void 0 && !ns.startsWith("@")) {
|
|
118
|
+
console.warn(
|
|
119
|
+
chalk.yellow(
|
|
120
|
+
`\u26A0\uFE0F Plugin "${ns}" is missing a scope/namespace, it will not be loaded.`
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async function loadPluginPackage(packageName, packageVersion, autoInstall) {
|
|
127
|
+
if (isModuleInstalled(packageName)) {
|
|
128
|
+
return await import(packageName);
|
|
129
|
+
}
|
|
130
|
+
if (!autoInstall) {
|
|
131
|
+
console.warn(
|
|
132
|
+
chalk.yellow(
|
|
133
|
+
`\u26A0\uFE0F Plugin "${packageName}" cannot be loaded because it is not installed and "autoInstall" is disabled.`
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
console.log(chalk.green(`Installing plugin "${packageName}"...`));
|
|
139
|
+
const installed = await installPluginPackage(packageName, packageVersion);
|
|
140
|
+
if (installed) {
|
|
141
|
+
return await import(packageName);
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
async function installPluginPackage(packageName, packageVersion) {
|
|
146
|
+
let versionToInstall = packageVersion;
|
|
147
|
+
const isRedwoodPackage = packageName.startsWith("@cedarjs/");
|
|
148
|
+
if (!isRedwoodPackage && versionToInstall === void 0) {
|
|
149
|
+
versionToInstall = "latest";
|
|
150
|
+
try {
|
|
151
|
+
const compatibilityData = await getCompatibilityData(
|
|
152
|
+
packageName,
|
|
153
|
+
versionToInstall
|
|
154
|
+
);
|
|
155
|
+
versionToInstall = compatibilityData.compatible.version;
|
|
156
|
+
console.log(
|
|
157
|
+
chalk.green(
|
|
158
|
+
`Installing the latest compatible version: ${versionToInstall}`
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.log(
|
|
163
|
+
"The following error occurred while checking plugin compatibility for automatic installation:"
|
|
164
|
+
);
|
|
165
|
+
const errorMessage = error.message ?? error;
|
|
166
|
+
console.log(errorMessage);
|
|
167
|
+
if (errorMessage.includes("does not have a tag") || errorMessage.includes("does not have a version")) {
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
const prompt = new Select({
|
|
171
|
+
name: "versionDecision",
|
|
172
|
+
message: "What would you like to do?",
|
|
173
|
+
choices: [
|
|
174
|
+
{
|
|
175
|
+
name: "cancel",
|
|
176
|
+
message: "Cancel"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "continue",
|
|
180
|
+
message: "Continue and install the 'latest' version"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
const decision = await prompt.run();
|
|
185
|
+
if (decision === "cancel") {
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
await installModule(packageName, versionToInstall);
|
|
192
|
+
return true;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error(error);
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
PLUGIN_CACHE_BUILTIN,
|
|
200
|
+
PLUGIN_CACHE_DEFAULT,
|
|
201
|
+
PLUGIN_CACHE_FILENAME,
|
|
202
|
+
checkPluginListAndWarn,
|
|
203
|
+
loadCommandCache,
|
|
204
|
+
loadPluginPackage,
|
|
205
|
+
saveCommandCache
|
|
206
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import prompts from "prompts";
|
|
2
|
+
import { isSingular, isPlural, addSingularPlural } from "./rwPluralize.js";
|
|
3
|
+
const isWordPluralizable = (word) => {
|
|
4
|
+
return isPlural(word) !== isSingular(word);
|
|
5
|
+
};
|
|
6
|
+
const validatePlural = (plural, singular) => {
|
|
7
|
+
const trimmedPlural = plural.trim();
|
|
8
|
+
if (trimmedPlural === singular) {
|
|
9
|
+
return "Plural can not be same as singular.";
|
|
10
|
+
}
|
|
11
|
+
if (trimmedPlural.match(/[\n\r\s]+/)) {
|
|
12
|
+
return "Only one word please!";
|
|
13
|
+
}
|
|
14
|
+
if (trimmedPlural.match(/^[\n\r\s\u0017]*$/)) {
|
|
15
|
+
return "Plural can not be empty.";
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
const ensureUniquePlural = async ({
|
|
20
|
+
model,
|
|
21
|
+
isDestroyer = false,
|
|
22
|
+
forcePrompt = false
|
|
23
|
+
}) => {
|
|
24
|
+
if (!forcePrompt && isWordPluralizable(model)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const generateMessage = `Cannot determine the plural of "${model}".
|
|
28
|
+
To continue, the generator requires a unique plural form:`;
|
|
29
|
+
const destroyMessage = `Cannot determine the plural of "${model}" originally used to generate the files.
|
|
30
|
+
To continue, the destroy command requires the plural form:`;
|
|
31
|
+
const promptMessage = isDestroyer ? destroyMessage : generateMessage;
|
|
32
|
+
const initialPlural = model.slice(-1) === "s" ? `${model}es` : `${model}s`;
|
|
33
|
+
const promptResult = await prompts({
|
|
34
|
+
type: "text",
|
|
35
|
+
name: "plural",
|
|
36
|
+
message: promptMessage,
|
|
37
|
+
initial: initialPlural,
|
|
38
|
+
validate: (pluralInput) => validatePlural(pluralInput, model)
|
|
39
|
+
});
|
|
40
|
+
const pluralToUse = promptResult.plural?.trim().replace(/\u0017/g, "");
|
|
41
|
+
if (!pluralToUse) {
|
|
42
|
+
throw Error("Plural name must not be empty");
|
|
43
|
+
}
|
|
44
|
+
addSingularPlural(model, pluralToUse);
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
ensureUniquePlural,
|
|
48
|
+
isWordPluralizable,
|
|
49
|
+
validatePlural
|
|
50
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import portfinder from "portfinder";
|
|
2
|
+
async function getFreePort(requestedPort, excludePorts = []) {
|
|
3
|
+
try {
|
|
4
|
+
let freePort = await portfinder.getPortPromise({
|
|
5
|
+
port: requestedPort
|
|
6
|
+
});
|
|
7
|
+
if (excludePorts.includes(freePort)) {
|
|
8
|
+
freePort = await getFreePort(freePort + 1, excludePorts);
|
|
9
|
+
}
|
|
10
|
+
return freePort;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
return -1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
getFreePort
|
|
17
|
+
};
|