@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,485 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import https from "https";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import * as babel from "@babel/core";
|
|
5
|
+
import boxen from "boxen";
|
|
6
|
+
import camelcase from "camelcase";
|
|
7
|
+
import { paramCase } from "change-case";
|
|
8
|
+
import decamelize from "decamelize";
|
|
9
|
+
import execa from "execa";
|
|
10
|
+
import fs from "fs-extra";
|
|
11
|
+
import { Listr } from "listr2";
|
|
12
|
+
import lodash from "lodash";
|
|
13
|
+
import pascalcase from "pascalcase";
|
|
14
|
+
import { format } from "prettier";
|
|
15
|
+
import {
|
|
16
|
+
getConfig as getRedwoodConfig,
|
|
17
|
+
getPaths as getRedwoodPaths,
|
|
18
|
+
resolveFile as internalResolveFile,
|
|
19
|
+
findUp
|
|
20
|
+
} from "@cedarjs/project-config";
|
|
21
|
+
import c from "./colors.js";
|
|
22
|
+
import { addFileToRollback } from "./rollback.js";
|
|
23
|
+
import { pluralize, singularize } from "./rwPluralize.js";
|
|
24
|
+
const { memoize, template } = lodash;
|
|
25
|
+
const nameVariants = (name) => {
|
|
26
|
+
const normalizedName = pascalcase(paramCase(singularize(name)));
|
|
27
|
+
return {
|
|
28
|
+
pascalName: pascalcase(paramCase(name)),
|
|
29
|
+
camelName: camelcase(name),
|
|
30
|
+
singularPascalName: normalizedName,
|
|
31
|
+
pluralPascalName: pluralize(normalizedName),
|
|
32
|
+
singularCamelName: camelcase(normalizedName),
|
|
33
|
+
pluralCamelName: camelcase(pluralize(normalizedName)),
|
|
34
|
+
singularParamName: paramCase(normalizedName),
|
|
35
|
+
pluralParamName: paramCase(pluralize(normalizedName)),
|
|
36
|
+
singularConstantName: decamelize(normalizedName).toUpperCase(),
|
|
37
|
+
pluralConstantName: decamelize(pluralize(normalizedName)).toUpperCase()
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const generateTemplate = async (templateFilename, { name, ...rest }) => {
|
|
41
|
+
try {
|
|
42
|
+
const templateFn = template(readFile(templateFilename).toString());
|
|
43
|
+
const renderedTemplate = templateFn({
|
|
44
|
+
name,
|
|
45
|
+
...nameVariants(name),
|
|
46
|
+
...rest
|
|
47
|
+
});
|
|
48
|
+
return prettify(templateFilename, renderedTemplate);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
error.message = `Error applying template at ${templateFilename} for ${name}: ${error.message}`;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const prettify = async (templateFilename, renderedTemplate) => {
|
|
55
|
+
const parser = {
|
|
56
|
+
".css": "css",
|
|
57
|
+
".js": "babel",
|
|
58
|
+
".jsx": "babel",
|
|
59
|
+
".ts": "babel-ts",
|
|
60
|
+
".tsx": "babel-ts"
|
|
61
|
+
}[path.extname(templateFilename.replace(".template", ""))];
|
|
62
|
+
if (typeof parser === "undefined") {
|
|
63
|
+
return renderedTemplate;
|
|
64
|
+
}
|
|
65
|
+
const prettierOptions = await getPrettierOptions();
|
|
66
|
+
return format(renderedTemplate, {
|
|
67
|
+
...prettierOptions,
|
|
68
|
+
parser
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const readFile = (target) => fs.readFileSync(target, { encoding: "utf8" });
|
|
72
|
+
const SUPPORTED_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
73
|
+
const deleteFile = (file) => {
|
|
74
|
+
const extension = path.extname(file);
|
|
75
|
+
if (SUPPORTED_EXTENSIONS.includes(extension)) {
|
|
76
|
+
const baseFile = getBaseFile(file);
|
|
77
|
+
SUPPORTED_EXTENSIONS.forEach((ext) => {
|
|
78
|
+
const f = baseFile + ext;
|
|
79
|
+
if (fs.existsSync(f)) {
|
|
80
|
+
fs.unlinkSync(f);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
fs.unlinkSync(file);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const getBaseFile = (file) => file.replace(/\.\w*$/, "");
|
|
88
|
+
const existsAnyExtensionSync = (file) => {
|
|
89
|
+
const extension = path.extname(file);
|
|
90
|
+
if (SUPPORTED_EXTENSIONS.includes(extension)) {
|
|
91
|
+
const baseFile = getBaseFile(file);
|
|
92
|
+
return SUPPORTED_EXTENSIONS.some((ext) => fs.existsSync(baseFile + ext));
|
|
93
|
+
}
|
|
94
|
+
return fs.existsSync(file);
|
|
95
|
+
};
|
|
96
|
+
const writeFile = (target, contents, { overwriteExisting = false } = {}, task = {}) => {
|
|
97
|
+
const { base } = getPaths();
|
|
98
|
+
task.title = `Writing \`./${path.relative(base, target)}\``;
|
|
99
|
+
if (!overwriteExisting && fs.existsSync(target)) {
|
|
100
|
+
throw new Error(`${target} already exists.`);
|
|
101
|
+
}
|
|
102
|
+
addFileToRollback(target);
|
|
103
|
+
const filename = path.basename(target);
|
|
104
|
+
const targetDir = target.replace(filename, "");
|
|
105
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
106
|
+
fs.writeFileSync(target, contents);
|
|
107
|
+
task.title = `Successfully wrote file \`./${path.relative(base, target)}\``;
|
|
108
|
+
};
|
|
109
|
+
const saveRemoteFileToDisk = (url, localPath, { overwriteExisting = false } = {}) => {
|
|
110
|
+
if (!overwriteExisting && fs.existsSync(localPath)) {
|
|
111
|
+
throw new Error(`${localPath} already exists.`);
|
|
112
|
+
}
|
|
113
|
+
const downloadPromise = new Promise(
|
|
114
|
+
(resolve, reject) => https.get(url, (response) => {
|
|
115
|
+
if (response.statusCode === 200) {
|
|
116
|
+
response.pipe(fs.createWriteStream(localPath));
|
|
117
|
+
resolve();
|
|
118
|
+
} else {
|
|
119
|
+
reject(
|
|
120
|
+
new Error(`${url} responded with status code ${response.statusCode}`)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
return downloadPromise;
|
|
126
|
+
};
|
|
127
|
+
async function getInstalledCedarVersion() {
|
|
128
|
+
try {
|
|
129
|
+
const packageJson = await import("../../package.json", { with: { type: "json" } });
|
|
130
|
+
return packageJson.default.version;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error(c.error("Could not find installed Cedar version"));
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const bytes = (contents) => Buffer.byteLength(contents, "utf8");
|
|
137
|
+
const _getPaths = () => {
|
|
138
|
+
try {
|
|
139
|
+
return getRedwoodPaths();
|
|
140
|
+
} catch (e) {
|
|
141
|
+
console.error(c.error(e.message));
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const getPaths = memoize(_getPaths);
|
|
146
|
+
const resolveFile = internalResolveFile;
|
|
147
|
+
const getGraphqlPath = () => resolveFile(path.join(getPaths().api.functions, "graphql"));
|
|
148
|
+
const graphFunctionDoesExist = () => {
|
|
149
|
+
return fs.existsSync(getGraphqlPath());
|
|
150
|
+
};
|
|
151
|
+
const getConfig = () => {
|
|
152
|
+
try {
|
|
153
|
+
return getRedwoodConfig();
|
|
154
|
+
} catch (e) {
|
|
155
|
+
console.error(c.error(e.message));
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const getPrettierOptions = async () => {
|
|
160
|
+
try {
|
|
161
|
+
const { default: prettierOptions } = await import(`file://${path.join(getPaths().base, "prettier.config.js")}`);
|
|
162
|
+
return prettierOptions;
|
|
163
|
+
} catch (e) {
|
|
164
|
+
if (process.env.VITEST_POOL_ID !== void 0) {
|
|
165
|
+
return {
|
|
166
|
+
trailingComma: "es5",
|
|
167
|
+
bracketSpacing: true,
|
|
168
|
+
tabWidth: 2,
|
|
169
|
+
semi: false,
|
|
170
|
+
singleQuote: true,
|
|
171
|
+
arrowParens: "always",
|
|
172
|
+
overrides: [
|
|
173
|
+
{
|
|
174
|
+
files: "Routes.*",
|
|
175
|
+
options: {
|
|
176
|
+
printWidth: 999
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const transformTSToJS = async (filename, content) => {
|
|
186
|
+
const { code } = babel.transform(content, {
|
|
187
|
+
filename,
|
|
188
|
+
// If you ran `yarn rw generate` in `./web` transformSync would import the `.babelrc.js` file,
|
|
189
|
+
// in `./web`? despite us setting `configFile: false`.
|
|
190
|
+
cwd: process.env.NODE_ENV === "test" ? void 0 : getPaths().base,
|
|
191
|
+
configFile: false,
|
|
192
|
+
plugins: [
|
|
193
|
+
[
|
|
194
|
+
"@babel/plugin-transform-typescript",
|
|
195
|
+
{
|
|
196
|
+
isTSX: true,
|
|
197
|
+
allExtensions: true
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
],
|
|
201
|
+
retainLines: true
|
|
202
|
+
});
|
|
203
|
+
return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), code);
|
|
204
|
+
};
|
|
205
|
+
const writeFilesTask = (files, options) => {
|
|
206
|
+
const { base } = getPaths();
|
|
207
|
+
return new Listr(
|
|
208
|
+
Object.keys(files).map((file) => {
|
|
209
|
+
const contents = files[file];
|
|
210
|
+
return {
|
|
211
|
+
title: `...waiting to write file \`./${path.relative(base, file)}\`...`,
|
|
212
|
+
task: (ctx, task) => writeFile(file, contents, options, task)
|
|
213
|
+
};
|
|
214
|
+
})
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
const deleteFilesTask = (files) => {
|
|
218
|
+
const { base } = getPaths();
|
|
219
|
+
return new Listr([
|
|
220
|
+
...Object.keys(files).map((file) => {
|
|
221
|
+
return {
|
|
222
|
+
title: `Destroying \`./${path.relative(base, getBaseFile(file))}\`...`,
|
|
223
|
+
skip: () => !existsAnyExtensionSync(file) && `File doesn't exist`,
|
|
224
|
+
task: () => deleteFile(file)
|
|
225
|
+
};
|
|
226
|
+
}),
|
|
227
|
+
{
|
|
228
|
+
title: "Cleaning up empty directories...",
|
|
229
|
+
task: () => cleanupEmptyDirsTask(files)
|
|
230
|
+
}
|
|
231
|
+
]);
|
|
232
|
+
};
|
|
233
|
+
const cleanupEmptyDirsTask = (files) => {
|
|
234
|
+
const { base } = getPaths();
|
|
235
|
+
const endDirs = Object.keys(files).map((file) => path.dirname(file));
|
|
236
|
+
const uniqueEndDirs = [...new Set(endDirs)];
|
|
237
|
+
const pathDirs = [];
|
|
238
|
+
uniqueEndDirs.forEach((dir) => {
|
|
239
|
+
const relDir = path.relative(base, dir);
|
|
240
|
+
const splitDir = relDir.split(path.sep);
|
|
241
|
+
splitDir.pop();
|
|
242
|
+
while (splitDir.length > 3) {
|
|
243
|
+
const subDir = path.join(base, splitDir.join("/"));
|
|
244
|
+
pathDirs.push(subDir);
|
|
245
|
+
splitDir.pop();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const uniqueDirs = uniqueEndDirs.concat([...new Set(pathDirs)]);
|
|
249
|
+
return new Listr(
|
|
250
|
+
uniqueDirs.map((dir) => {
|
|
251
|
+
return {
|
|
252
|
+
title: `Removing empty \`./${path.relative(base, dir)}\`...`,
|
|
253
|
+
task: () => fs.rmdirSync(dir),
|
|
254
|
+
skip: () => {
|
|
255
|
+
if (!fs.existsSync(dir)) {
|
|
256
|
+
return `Doesn't exist`;
|
|
257
|
+
}
|
|
258
|
+
if (fs.readdirSync(dir).length > 0) {
|
|
259
|
+
return "Not empty";
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
})
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
const wrapWithSet = (routesContent, layout, routes, newLineAndIndent, props = {}) => {
|
|
268
|
+
const [_, indentOne, indentTwo] = routesContent.match(
|
|
269
|
+
/([ \t]*)<Router.*?>[^<]*[\r\n]+([ \t]+)/
|
|
270
|
+
) || ["", 0, 2];
|
|
271
|
+
const oneLevelIndent = indentTwo.slice(0, indentTwo.length - indentOne.length);
|
|
272
|
+
const newRoutesWithExtraIndent = routes.map((route) => oneLevelIndent + route);
|
|
273
|
+
const propsString = Object.entries(props).map((values) => `${values[0]}="${values[1]}"`).join(" ");
|
|
274
|
+
return [
|
|
275
|
+
`<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
276
|
+
...newRoutesWithExtraIndent,
|
|
277
|
+
`</Set>`
|
|
278
|
+
].join(newLineAndIndent);
|
|
279
|
+
};
|
|
280
|
+
const addRoutesToRouterTask = (routes, layout, setProps = {}) => {
|
|
281
|
+
const redwoodPaths = getPaths();
|
|
282
|
+
const routesContent = readFile(redwoodPaths.web.routes).toString();
|
|
283
|
+
let newRoutes = routes.filter((route) => !routesContent.match(route));
|
|
284
|
+
if (newRoutes.length) {
|
|
285
|
+
const [routerStart, routerParams, newLineAndIndent] = routesContent.match(
|
|
286
|
+
/\s*<Router(.*?)>(\s*)/s
|
|
287
|
+
);
|
|
288
|
+
if (/trailingSlashes={?(["'])always\1}?/.test(routerParams)) {
|
|
289
|
+
newRoutes = newRoutes.map((route) => {
|
|
290
|
+
if (route.length > 2e3) {
|
|
291
|
+
throw new Error(`Route is too long to process:
|
|
292
|
+
${route}`);
|
|
293
|
+
}
|
|
294
|
+
return route.replace(/ path="(.+?)" /, ' path="$1/" ');
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const routesBatch = layout ? wrapWithSet(
|
|
298
|
+
routesContent,
|
|
299
|
+
layout,
|
|
300
|
+
newRoutes,
|
|
301
|
+
newLineAndIndent,
|
|
302
|
+
setProps
|
|
303
|
+
) : newRoutes.join(newLineAndIndent);
|
|
304
|
+
const newRoutesContent = routesContent.replace(
|
|
305
|
+
routerStart,
|
|
306
|
+
`${routerStart + routesBatch + newLineAndIndent}`
|
|
307
|
+
);
|
|
308
|
+
writeFile(redwoodPaths.web.routes, newRoutesContent, {
|
|
309
|
+
overwriteExisting: true
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const addScaffoldImport = () => {
|
|
314
|
+
const appJsPath = getPaths().web.app;
|
|
315
|
+
let appJsContents = readFile(appJsPath).toString();
|
|
316
|
+
if (appJsContents.match("./scaffold.css")) {
|
|
317
|
+
return "Skipping scaffold style include";
|
|
318
|
+
}
|
|
319
|
+
appJsContents = appJsContents.replace(
|
|
320
|
+
/import ['"]\.\/index\.css['"]/,
|
|
321
|
+
"import './index.css'\nimport './scaffold.css'\n"
|
|
322
|
+
);
|
|
323
|
+
writeFile(appJsPath, appJsContents, { overwriteExisting: true });
|
|
324
|
+
return "Added scaffold import to App.{jsx,tsx}";
|
|
325
|
+
};
|
|
326
|
+
const removeEmtpySet = (routesContent, layout) => {
|
|
327
|
+
const setWithLayoutReg = new RegExp(
|
|
328
|
+
`\\s*<Set[^>]*wrap={${layout}}[^<]*>([^<]*)</Set>`
|
|
329
|
+
);
|
|
330
|
+
const [matchedSet, childContent] = routesContent.match(setWithLayoutReg) || [];
|
|
331
|
+
if (!matchedSet) {
|
|
332
|
+
return routesContent;
|
|
333
|
+
}
|
|
334
|
+
const child = childContent.replace(/\s/g, "");
|
|
335
|
+
if (child.length > 0) {
|
|
336
|
+
return routesContent;
|
|
337
|
+
}
|
|
338
|
+
return routesContent.replace(setWithLayoutReg, "");
|
|
339
|
+
};
|
|
340
|
+
const removeRoutesFromRouterTask = (routes, layout) => {
|
|
341
|
+
const redwoodPaths = getPaths();
|
|
342
|
+
const routesContent = readFile(redwoodPaths.web.routes).toString();
|
|
343
|
+
const newRoutesContent = routes.reduce((content, route) => {
|
|
344
|
+
const matchRouteByName = new RegExp(`\\s*<Route[^>]*name="${route}"[^>]*/>`);
|
|
345
|
+
return content.replace(matchRouteByName, "");
|
|
346
|
+
}, routesContent);
|
|
347
|
+
const routesWithoutEmptySet = layout ? removeEmtpySet(newRoutesContent, layout) : newRoutesContent;
|
|
348
|
+
writeFile(redwoodPaths.web.routes, routesWithoutEmptySet, {
|
|
349
|
+
overwriteExisting: true
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
const addPackagesTask = async ({
|
|
353
|
+
packages,
|
|
354
|
+
side = "project",
|
|
355
|
+
devDependency = false
|
|
356
|
+
}) => {
|
|
357
|
+
const cedarVersion = await getInstalledCedarVersion();
|
|
358
|
+
const packagesWithSameRWVersion = packages.map((pkg) => {
|
|
359
|
+
if (pkg.includes("@cedarjs")) {
|
|
360
|
+
return `${pkg}@${cedarVersion}`;
|
|
361
|
+
} else {
|
|
362
|
+
return pkg;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
let installCommand;
|
|
366
|
+
if (side !== "project") {
|
|
367
|
+
installCommand = [
|
|
368
|
+
"yarn",
|
|
369
|
+
[
|
|
370
|
+
"workspace",
|
|
371
|
+
side,
|
|
372
|
+
"add",
|
|
373
|
+
devDependency && "--dev",
|
|
374
|
+
...packagesWithSameRWVersion
|
|
375
|
+
].filter(Boolean)
|
|
376
|
+
];
|
|
377
|
+
} else {
|
|
378
|
+
const stdout = execSync("yarn --version");
|
|
379
|
+
const yarnVersion = stdout.toString().trim();
|
|
380
|
+
installCommand = [
|
|
381
|
+
"yarn",
|
|
382
|
+
[
|
|
383
|
+
yarnVersion.startsWith("1") && "-W",
|
|
384
|
+
"add",
|
|
385
|
+
devDependency && "--dev",
|
|
386
|
+
...packagesWithSameRWVersion
|
|
387
|
+
].filter(Boolean)
|
|
388
|
+
];
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
title: `Adding dependencies to ${side}`,
|
|
392
|
+
task: async () => {
|
|
393
|
+
await execa(...installCommand);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
const runCommandTask = async (commands, { verbose, silent }) => {
|
|
398
|
+
const tasks = new Listr(
|
|
399
|
+
commands.map(({ title, cmd, args, opts = {}, cwd = getPaths().base }) => ({
|
|
400
|
+
title,
|
|
401
|
+
task: async () => {
|
|
402
|
+
return execa(cmd, args, {
|
|
403
|
+
shell: true,
|
|
404
|
+
cwd,
|
|
405
|
+
stdio: verbose && !silent ? "inherit" : "pipe",
|
|
406
|
+
extendEnv: true,
|
|
407
|
+
cleanup: true,
|
|
408
|
+
...opts
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
})),
|
|
412
|
+
{
|
|
413
|
+
renderer: silent ? "silent" : verbose ? "verbose" : "default",
|
|
414
|
+
rendererOptions: { collapseSubtasks: false, dateFormat: false }
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
try {
|
|
418
|
+
await tasks.run();
|
|
419
|
+
return true;
|
|
420
|
+
} catch (e) {
|
|
421
|
+
console.log(c.error(e.message));
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const getDefaultArgs = (builder) => {
|
|
426
|
+
return Object.entries(builder).reduce(
|
|
427
|
+
(options, [optionName, optionConfig]) => {
|
|
428
|
+
options[optionName] = optionConfig.default;
|
|
429
|
+
return options;
|
|
430
|
+
},
|
|
431
|
+
{}
|
|
432
|
+
);
|
|
433
|
+
};
|
|
434
|
+
const usingVSCode = () => {
|
|
435
|
+
const redwoodPaths = getPaths();
|
|
436
|
+
const VS_CODE_PATH = path.join(redwoodPaths.base, ".vscode");
|
|
437
|
+
return fs.existsSync(VS_CODE_PATH);
|
|
438
|
+
};
|
|
439
|
+
const printSetupNotes = (notes) => {
|
|
440
|
+
return {
|
|
441
|
+
title: "One more thing...",
|
|
442
|
+
task: (_ctx, task) => {
|
|
443
|
+
task.title = `One more thing...
|
|
444
|
+
|
|
445
|
+
${boxen(notes.join("\n"), {
|
|
446
|
+
padding: { top: 1, bottom: 1, right: 1, left: 1 },
|
|
447
|
+
margin: 1,
|
|
448
|
+
borderColour: "gray"
|
|
449
|
+
})}
|
|
450
|
+
`;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
export {
|
|
455
|
+
_getPaths,
|
|
456
|
+
addPackagesTask,
|
|
457
|
+
addRoutesToRouterTask,
|
|
458
|
+
addScaffoldImport,
|
|
459
|
+
bytes,
|
|
460
|
+
cleanupEmptyDirsTask,
|
|
461
|
+
deleteFile,
|
|
462
|
+
deleteFilesTask,
|
|
463
|
+
existsAnyExtensionSync,
|
|
464
|
+
findUp,
|
|
465
|
+
generateTemplate,
|
|
466
|
+
getConfig,
|
|
467
|
+
getDefaultArgs,
|
|
468
|
+
getGraphqlPath,
|
|
469
|
+
getInstalledCedarVersion,
|
|
470
|
+
getPaths,
|
|
471
|
+
getPrettierOptions,
|
|
472
|
+
graphFunctionDoesExist,
|
|
473
|
+
nameVariants,
|
|
474
|
+
prettify,
|
|
475
|
+
printSetupNotes,
|
|
476
|
+
readFile,
|
|
477
|
+
removeRoutesFromRouterTask,
|
|
478
|
+
resolveFile,
|
|
479
|
+
runCommandTask,
|
|
480
|
+
saveRemoteFileToDisk,
|
|
481
|
+
transformTSToJS,
|
|
482
|
+
usingVSCode,
|
|
483
|
+
writeFile,
|
|
484
|
+
writeFilesTask
|
|
485
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { getPaths } from "./index.js";
|
|
4
|
+
function ensureLockDirectoryExists() {
|
|
5
|
+
const locksPath = path.join(getPaths().generated.base, "locks");
|
|
6
|
+
if (!fs.existsSync(locksPath)) {
|
|
7
|
+
fs.mkdirSync(locksPath, { recursive: true });
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function setLock(identifier) {
|
|
11
|
+
ensureLockDirectoryExists();
|
|
12
|
+
if (isLockSet(identifier)) {
|
|
13
|
+
throw new Error(`Lock "${identifier}" is already set`);
|
|
14
|
+
}
|
|
15
|
+
fs.writeFileSync(
|
|
16
|
+
path.join(getPaths().generated.base, "locks", identifier),
|
|
17
|
+
""
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function unsetLock(identifier) {
|
|
21
|
+
try {
|
|
22
|
+
fs.rmSync(path.join(getPaths().generated.base, "locks", identifier));
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code !== "ENOENT") {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function isLockSet(identifier) {
|
|
30
|
+
const lockfilePath = path.join(getPaths().generated.base, "locks", identifier);
|
|
31
|
+
const exists = fs.existsSync(lockfilePath);
|
|
32
|
+
if (!exists) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const createdAt = fs.statSync(lockfilePath).birthtimeMs;
|
|
36
|
+
if (Date.now() - createdAt > 36e5) {
|
|
37
|
+
unsetLock(identifier);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
function clearLocks(identifiers = []) {
|
|
43
|
+
ensureLockDirectoryExists();
|
|
44
|
+
if (identifiers.length > 0) {
|
|
45
|
+
for (const id of identifiers) {
|
|
46
|
+
unsetLock(id);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
const locks = fs.readdirSync(path.join(getPaths().generated.base, "locks"));
|
|
50
|
+
for (const lock of locks) {
|
|
51
|
+
unsetLock(lock);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
clearLocks,
|
|
57
|
+
isLockSet,
|
|
58
|
+
setLock,
|
|
59
|
+
unsetLock
|
|
60
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { forOwn } from "lodash";
|
|
2
|
+
const nodeIs = (type) => (node) => node.type === type;
|
|
3
|
+
function sieve(...listRulePairs) {
|
|
4
|
+
const result = [[]];
|
|
5
|
+
for (const [list, rule] of listRulePairs) {
|
|
6
|
+
elementLoop: for (const element of list) {
|
|
7
|
+
for (const arr of result) {
|
|
8
|
+
const position = rule(arr);
|
|
9
|
+
if (position !== -1) {
|
|
10
|
+
arr.splice(position, 0, element);
|
|
11
|
+
continue elementLoop;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
result.push([element]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
function forEachFunctionOn(object, callback) {
|
|
20
|
+
forOwn(object, (value, key) => {
|
|
21
|
+
if (typeof value === "function") {
|
|
22
|
+
callback(key, value);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
forEachFunctionOn,
|
|
28
|
+
nodeIs,
|
|
29
|
+
sieve
|
|
30
|
+
};
|