@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,558 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import boxen from "boxen";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import * as toml from "smol-toml";
|
|
6
|
+
import { env as envInterpolation } from "string-env-interpolation";
|
|
7
|
+
import { titleCase } from "title-case";
|
|
8
|
+
import { recordTelemetryAttributes } from "@redmix/cli-helpers";
|
|
9
|
+
import c from "../../../lib/colors.js";
|
|
10
|
+
import { getPaths } from "../../../lib/index.js";
|
|
11
|
+
import { SshExecutor } from "./SshExecutor.js";
|
|
12
|
+
const CONFIG_FILENAME = "deploy.toml";
|
|
13
|
+
const SYMLINK_FLAGS = "-nsf";
|
|
14
|
+
const CURRENT_RELEASE_SYMLINK_NAME = "current";
|
|
15
|
+
const LIFECYCLE_HOOKS = ["before", "after"];
|
|
16
|
+
const DEFAULT_SERVER_CONFIG = {
|
|
17
|
+
port: 22,
|
|
18
|
+
branch: "main",
|
|
19
|
+
packageManagerCommand: "yarn",
|
|
20
|
+
monitorCommand: "pm2",
|
|
21
|
+
sides: ["api", "web"],
|
|
22
|
+
keepReleases: 5
|
|
23
|
+
};
|
|
24
|
+
const pathJoin = path.posix.join;
|
|
25
|
+
const throwMissingConfig = (name) => {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`"${name}" config option not set. See https://redwoodjs.com/docs/deployment/baremetal#deploytoml`
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
const verifyConfig = (config, yargs) => {
|
|
31
|
+
if (!yargs.environment) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Must specify an environment to deploy to, ex: `yarn rw deploy baremetal production`"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!config[yargs.environment]) {
|
|
37
|
+
throw new Error(`No servers found for environment "${yargs.environment}"`);
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
const verifyServerConfig = (config) => {
|
|
42
|
+
if (!config.host) {
|
|
43
|
+
throwMissingConfig("host");
|
|
44
|
+
}
|
|
45
|
+
if (!config.path) {
|
|
46
|
+
throwMissingConfig("path");
|
|
47
|
+
}
|
|
48
|
+
if (!config.repo) {
|
|
49
|
+
throwMissingConfig("repo");
|
|
50
|
+
}
|
|
51
|
+
if (config.freeSpaceRequired && !/^\d+$/.test(config.freeSpaceRequired)) {
|
|
52
|
+
throw new Error('"freeSpaceRequired" must be an integer >= 0');
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
const symlinkCurrentCommand = async (dir, ssh, path2) => {
|
|
57
|
+
return await ssh.exec(path2, "ln", [
|
|
58
|
+
SYMLINK_FLAGS,
|
|
59
|
+
dir,
|
|
60
|
+
CURRENT_RELEASE_SYMLINK_NAME
|
|
61
|
+
]);
|
|
62
|
+
};
|
|
63
|
+
const restartProcessCommand = async (processName, ssh, serverConfig, path2) => {
|
|
64
|
+
return await ssh.exec(path2, serverConfig.monitorCommand, [
|
|
65
|
+
"restart",
|
|
66
|
+
processName
|
|
67
|
+
]);
|
|
68
|
+
};
|
|
69
|
+
const serverConfigWithDefaults = (serverConfig, yargs) => {
|
|
70
|
+
return {
|
|
71
|
+
...DEFAULT_SERVER_CONFIG,
|
|
72
|
+
...serverConfig,
|
|
73
|
+
branch: yargs.branch || serverConfig.branch || DEFAULT_SERVER_CONFIG.branch
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const maintenanceTasks = (status, ssh, serverConfig) => {
|
|
77
|
+
const deployPath = pathJoin(serverConfig.path, CURRENT_RELEASE_SYMLINK_NAME);
|
|
78
|
+
const tasks = [];
|
|
79
|
+
if (status === "up") {
|
|
80
|
+
tasks.push({
|
|
81
|
+
title: `Enabling maintenance page...`,
|
|
82
|
+
task: async () => {
|
|
83
|
+
await ssh.exec(deployPath, "cp", [
|
|
84
|
+
pathJoin("web", "dist", "200.html"),
|
|
85
|
+
pathJoin("web", "dist", "200.html.orig")
|
|
86
|
+
]);
|
|
87
|
+
await ssh.exec(deployPath, "ln", [
|
|
88
|
+
SYMLINK_FLAGS,
|
|
89
|
+
pathJoin("..", "src", "maintenance.html"),
|
|
90
|
+
pathJoin("web", "dist", "200.html")
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (serverConfig.processNames) {
|
|
95
|
+
tasks.push({
|
|
96
|
+
title: `Stopping ${serverConfig.processNames.join(", ")} processes...`,
|
|
97
|
+
task: async () => {
|
|
98
|
+
await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
|
|
99
|
+
"stop",
|
|
100
|
+
serverConfig.processNames.join(" ")
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else if (status === "down") {
|
|
106
|
+
tasks.push({
|
|
107
|
+
title: `Starting ${serverConfig.processNames.join(", ")} processes...`,
|
|
108
|
+
task: async () => {
|
|
109
|
+
await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
|
|
110
|
+
"start",
|
|
111
|
+
serverConfig.processNames.join(" ")
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (serverConfig.processNames) {
|
|
116
|
+
tasks.push({
|
|
117
|
+
title: `Disabling maintenance page...`,
|
|
118
|
+
task: async () => {
|
|
119
|
+
await ssh.exec(deployPath, "rm", [
|
|
120
|
+
pathJoin("web", "dist", "200.html")
|
|
121
|
+
]);
|
|
122
|
+
await ssh.exec(deployPath, "cp", [
|
|
123
|
+
pathJoin("web", "dist", "200.html.orig"),
|
|
124
|
+
pathJoin("web", "dist", "200.html")
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return tasks;
|
|
131
|
+
};
|
|
132
|
+
const rollbackTasks = (count, ssh, serverConfig) => {
|
|
133
|
+
let rollbackCount = 1;
|
|
134
|
+
if (parseInt(count) === count) {
|
|
135
|
+
rollbackCount = count;
|
|
136
|
+
}
|
|
137
|
+
const tasks = [
|
|
138
|
+
{
|
|
139
|
+
title: `Rolling back ${rollbackCount} release(s)...`,
|
|
140
|
+
task: async () => {
|
|
141
|
+
const currentLink = (await ssh.exec(serverConfig.path, "readlink", ["-f", "current"])).stdout.split("/").pop();
|
|
142
|
+
const dirs = (await ssh.exec(serverConfig.path, "ls", ["-t"])).stdout.split("\n").filter((dirs2) => !dirs2.match(/current/));
|
|
143
|
+
const deployedIndex = dirs.indexOf(currentLink);
|
|
144
|
+
const rollbackIndex = deployedIndex + rollbackCount;
|
|
145
|
+
if (dirs[rollbackIndex]) {
|
|
146
|
+
console.info("Setting symlink");
|
|
147
|
+
await symlinkCurrentCommand(
|
|
148
|
+
dirs[rollbackIndex],
|
|
149
|
+
ssh,
|
|
150
|
+
serverConfig.path
|
|
151
|
+
);
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Cannot rollback ${rollbackCount} release(s): ${dirs.length - dirs.indexOf(currentLink) - 1} previous release(s) available`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
if (serverConfig.processNames) {
|
|
161
|
+
for (const processName of serverConfig.processNames) {
|
|
162
|
+
tasks.push({
|
|
163
|
+
title: `Restarting ${processName} process...`,
|
|
164
|
+
task: async () => {
|
|
165
|
+
await restartProcessCommand(
|
|
166
|
+
processName,
|
|
167
|
+
ssh,
|
|
168
|
+
serverConfig,
|
|
169
|
+
serverConfig.path
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return tasks;
|
|
176
|
+
};
|
|
177
|
+
const lifecycleTask = (lifecycle, task, skip, { serverLifecycle, ssh, cmdPath }) => {
|
|
178
|
+
if (serverLifecycle[lifecycle]?.[task]) {
|
|
179
|
+
const tasks = [];
|
|
180
|
+
for (const command of serverLifecycle[lifecycle][task]) {
|
|
181
|
+
tasks.push({
|
|
182
|
+
title: `${titleCase(lifecycle)} ${task}: \`${command}\``,
|
|
183
|
+
task: async () => {
|
|
184
|
+
await ssh.exec(cmdPath, command);
|
|
185
|
+
},
|
|
186
|
+
skip: () => skip
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return tasks;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const commandWithLifecycleEvents = ({ name, config, skip, command }) => {
|
|
193
|
+
const tasks = [];
|
|
194
|
+
tasks.push(lifecycleTask("before", name, skip, config));
|
|
195
|
+
tasks.push({ ...command, skip: () => skip });
|
|
196
|
+
tasks.push(lifecycleTask("after", name, skip, config));
|
|
197
|
+
return tasks.flat().filter((t) => t);
|
|
198
|
+
};
|
|
199
|
+
const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
200
|
+
const cmdPath = pathJoin(serverConfig.path, yargs.releaseDir);
|
|
201
|
+
const config = { yargs, ssh, serverConfig, serverLifecycle, cmdPath };
|
|
202
|
+
const tasks = [];
|
|
203
|
+
tasks.push(
|
|
204
|
+
commandWithLifecycleEvents({
|
|
205
|
+
name: "df",
|
|
206
|
+
config: { ...config, cmdPath: serverConfig.path },
|
|
207
|
+
skip: !yargs.df || serverConfig.freeSpaceRequired === 0 || serverConfig.freeSpaceRequired === "0",
|
|
208
|
+
command: {
|
|
209
|
+
title: `Checking available disk space...`,
|
|
210
|
+
task: async (_ctx, task) => {
|
|
211
|
+
const { stdout } = await ssh.exec(serverConfig.path, "df", [
|
|
212
|
+
serverConfig.path,
|
|
213
|
+
"|",
|
|
214
|
+
"awk",
|
|
215
|
+
`'NR == 2 {print "df:"$4}'`
|
|
216
|
+
]);
|
|
217
|
+
const df = stdout.split("\n").find((line) => line.startsWith("df:"));
|
|
218
|
+
if (!df || !df.startsWith("df:") || df === "df:") {
|
|
219
|
+
return task.skip(
|
|
220
|
+
c.warning("Warning: Could not get disk space information")
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
const dfMb = parseInt(df.replace("df:", ""), 10) / 1024;
|
|
224
|
+
if (isNaN(dfMb)) {
|
|
225
|
+
return task.skip(
|
|
226
|
+
c.warning("Warning: Could not parse disk space information")
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
task.output = `Available disk space: ${dfMb}MB`;
|
|
230
|
+
const freeSpaceRequired = parseInt(
|
|
231
|
+
serverConfig.freeSpaceRequired ?? 2048,
|
|
232
|
+
10
|
|
233
|
+
);
|
|
234
|
+
if (dfMb < freeSpaceRequired) {
|
|
235
|
+
if (typeof serverConfig.freeSpaceRequired === "undefined") {
|
|
236
|
+
return task.skip(
|
|
237
|
+
c.warning(
|
|
238
|
+
`Warning: Your server is running low on disk space. (${Math.round(dfMb)}MB available)`
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Not enough disk space. You need at least ${freeSpaceRequired}MB free space to continue.`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
tasks.push(
|
|
251
|
+
commandWithLifecycleEvents({
|
|
252
|
+
name: "update",
|
|
253
|
+
config: { ...config, cmdPath: serverConfig.path },
|
|
254
|
+
skip: !yargs.update,
|
|
255
|
+
command: {
|
|
256
|
+
title: `Cloning \`${serverConfig.branch}\` branch...`,
|
|
257
|
+
task: async () => {
|
|
258
|
+
await ssh.exec(serverConfig.path, "git", [
|
|
259
|
+
"clone",
|
|
260
|
+
`--branch=${serverConfig.branch}`,
|
|
261
|
+
`--depth=1`,
|
|
262
|
+
serverConfig.repo,
|
|
263
|
+
yargs.releaseDir
|
|
264
|
+
]);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
);
|
|
269
|
+
tasks.push(
|
|
270
|
+
commandWithLifecycleEvents({
|
|
271
|
+
name: "symlinkEnv",
|
|
272
|
+
config,
|
|
273
|
+
skip: !yargs.update,
|
|
274
|
+
command: {
|
|
275
|
+
title: `Symlink .env...`,
|
|
276
|
+
task: async () => {
|
|
277
|
+
await ssh.exec(cmdPath, "ln", [SYMLINK_FLAGS, "../.env", ".env"]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
);
|
|
282
|
+
tasks.push(
|
|
283
|
+
commandWithLifecycleEvents({
|
|
284
|
+
name: "install",
|
|
285
|
+
config,
|
|
286
|
+
skip: !yargs.install,
|
|
287
|
+
command: {
|
|
288
|
+
title: `Installing dependencies...`,
|
|
289
|
+
task: async () => {
|
|
290
|
+
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
291
|
+
"install"
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
tasks.push(
|
|
298
|
+
commandWithLifecycleEvents({
|
|
299
|
+
name: "migrate",
|
|
300
|
+
config,
|
|
301
|
+
skip: !yargs.migrate || serverConfig?.migrate === false,
|
|
302
|
+
command: {
|
|
303
|
+
title: `DB Migrations...`,
|
|
304
|
+
task: async () => {
|
|
305
|
+
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
306
|
+
"rw",
|
|
307
|
+
"prisma",
|
|
308
|
+
"migrate",
|
|
309
|
+
"deploy"
|
|
310
|
+
]);
|
|
311
|
+
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
312
|
+
"rw",
|
|
313
|
+
"prisma",
|
|
314
|
+
"generate"
|
|
315
|
+
]);
|
|
316
|
+
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
317
|
+
"rw",
|
|
318
|
+
"dataMigrate",
|
|
319
|
+
"up"
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
);
|
|
325
|
+
for (const side of serverConfig.sides) {
|
|
326
|
+
tasks.push(
|
|
327
|
+
commandWithLifecycleEvents({
|
|
328
|
+
name: "build",
|
|
329
|
+
config,
|
|
330
|
+
skip: !yargs.build,
|
|
331
|
+
command: {
|
|
332
|
+
title: `Building ${side}...`,
|
|
333
|
+
task: async () => {
|
|
334
|
+
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
335
|
+
"rw",
|
|
336
|
+
"build",
|
|
337
|
+
side
|
|
338
|
+
]);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
tasks.push(
|
|
345
|
+
commandWithLifecycleEvents({
|
|
346
|
+
name: "symlinkCurrent",
|
|
347
|
+
config,
|
|
348
|
+
skip: !yargs.update,
|
|
349
|
+
command: {
|
|
350
|
+
title: `Symlinking current release...`,
|
|
351
|
+
task: async () => {
|
|
352
|
+
await symlinkCurrentCommand(yargs.releaseDir, ssh, serverConfig.path);
|
|
353
|
+
},
|
|
354
|
+
skip: () => !yargs.update
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
);
|
|
358
|
+
if (serverConfig.processNames) {
|
|
359
|
+
for (const processName of serverConfig.processNames) {
|
|
360
|
+
if (yargs.firstRun) {
|
|
361
|
+
tasks.push(
|
|
362
|
+
commandWithLifecycleEvents({
|
|
363
|
+
name: "restart",
|
|
364
|
+
config,
|
|
365
|
+
skip: !yargs.restart,
|
|
366
|
+
command: {
|
|
367
|
+
title: `Starting ${processName} process for the first time...`,
|
|
368
|
+
task: async () => {
|
|
369
|
+
await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
|
|
370
|
+
"start",
|
|
371
|
+
pathJoin(CURRENT_RELEASE_SYMLINK_NAME, "ecosystem.config.js"),
|
|
372
|
+
"--only",
|
|
373
|
+
processName
|
|
374
|
+
]);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
})
|
|
378
|
+
);
|
|
379
|
+
tasks.push({
|
|
380
|
+
title: `Saving ${processName} state for future startup...`,
|
|
381
|
+
task: async () => {
|
|
382
|
+
await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
|
|
383
|
+
"save"
|
|
384
|
+
]);
|
|
385
|
+
},
|
|
386
|
+
skip: () => !yargs.restart
|
|
387
|
+
});
|
|
388
|
+
} else {
|
|
389
|
+
tasks.push(
|
|
390
|
+
commandWithLifecycleEvents({
|
|
391
|
+
name: "restart",
|
|
392
|
+
config,
|
|
393
|
+
skip: !yargs.restart,
|
|
394
|
+
command: {
|
|
395
|
+
title: `Restarting ${processName} process...`,
|
|
396
|
+
task: async () => {
|
|
397
|
+
await restartProcessCommand(
|
|
398
|
+
processName,
|
|
399
|
+
ssh,
|
|
400
|
+
serverConfig,
|
|
401
|
+
serverConfig.path
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
tasks.push(
|
|
411
|
+
commandWithLifecycleEvents({
|
|
412
|
+
name: "cleanup",
|
|
413
|
+
config: { ...config, cmdPath: serverConfig.path },
|
|
414
|
+
skip: !yargs.cleanup,
|
|
415
|
+
command: {
|
|
416
|
+
title: `Cleaning up old deploys...`,
|
|
417
|
+
task: async () => {
|
|
418
|
+
const fileStartIndex = serverConfig.keepReleases + 2;
|
|
419
|
+
await ssh.exec(
|
|
420
|
+
serverConfig.path,
|
|
421
|
+
`ls -t | tail -n +${fileStartIndex} | xargs rm -rf`
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
})
|
|
426
|
+
);
|
|
427
|
+
return tasks.flat().filter((e) => e);
|
|
428
|
+
};
|
|
429
|
+
const mergeLifecycleEvents = (lifecycle, other) => {
|
|
430
|
+
let lifecycleCopy = JSON.parse(JSON.stringify(lifecycle));
|
|
431
|
+
for (const hook of LIFECYCLE_HOOKS) {
|
|
432
|
+
for (const key in other[hook]) {
|
|
433
|
+
lifecycleCopy[hook][key] = (lifecycleCopy[hook][key] || []).concat(
|
|
434
|
+
other[hook][key]
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return lifecycleCopy;
|
|
439
|
+
};
|
|
440
|
+
const parseConfig = (yargs, rawConfigToml) => {
|
|
441
|
+
const configToml = envInterpolation(rawConfigToml);
|
|
442
|
+
const config = toml.parse(configToml);
|
|
443
|
+
let envConfig;
|
|
444
|
+
const emptyLifecycle = {};
|
|
445
|
+
verifyConfig(config, yargs);
|
|
446
|
+
for (const hook of LIFECYCLE_HOOKS) {
|
|
447
|
+
emptyLifecycle[hook] = {};
|
|
448
|
+
}
|
|
449
|
+
let envLifecycle = mergeLifecycleEvents(emptyLifecycle, config);
|
|
450
|
+
envConfig = config[yargs.environment];
|
|
451
|
+
envLifecycle = mergeLifecycleEvents(envLifecycle, envConfig);
|
|
452
|
+
return { envConfig, envLifecycle };
|
|
453
|
+
};
|
|
454
|
+
const commands = (yargs, ssh) => {
|
|
455
|
+
const deployConfig = fs.readFileSync(pathJoin(getPaths().base, CONFIG_FILENAME)).toString();
|
|
456
|
+
let { envConfig, envLifecycle } = parseConfig(yargs, deployConfig);
|
|
457
|
+
let servers = [];
|
|
458
|
+
let tasks = [];
|
|
459
|
+
for (const config of envConfig.servers) {
|
|
460
|
+
const serverConfig = serverConfigWithDefaults(config, yargs);
|
|
461
|
+
verifyServerConfig(serverConfig);
|
|
462
|
+
const serverLifecycle = mergeLifecycleEvents(envLifecycle, serverConfig);
|
|
463
|
+
tasks.push({
|
|
464
|
+
title: "Connecting...",
|
|
465
|
+
task: () => ssh.connect({
|
|
466
|
+
host: serverConfig.host,
|
|
467
|
+
port: serverConfig.port,
|
|
468
|
+
username: serverConfig.username,
|
|
469
|
+
password: serverConfig.password,
|
|
470
|
+
privateKey: serverConfig.privateKey,
|
|
471
|
+
privateKeyPath: serverConfig.privateKeyPath,
|
|
472
|
+
passphrase: serverConfig.passphrase,
|
|
473
|
+
agent: serverConfig.agentForward && process.env.SSH_AUTH_SOCK,
|
|
474
|
+
agentForward: serverConfig.agentForward
|
|
475
|
+
})
|
|
476
|
+
});
|
|
477
|
+
if (yargs.maintenance) {
|
|
478
|
+
tasks = tasks.concat(
|
|
479
|
+
maintenanceTasks(yargs.maintenance, ssh, serverConfig)
|
|
480
|
+
);
|
|
481
|
+
} else if (yargs.rollback) {
|
|
482
|
+
tasks = tasks.concat(rollbackTasks(yargs.rollback, ssh, serverConfig));
|
|
483
|
+
} else {
|
|
484
|
+
tasks = tasks.concat(
|
|
485
|
+
deployTasks(yargs, ssh, serverConfig, serverLifecycle)
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
tasks.push({
|
|
489
|
+
title: "Disconnecting...",
|
|
490
|
+
task: () => ssh.dispose()
|
|
491
|
+
});
|
|
492
|
+
servers.push({
|
|
493
|
+
title: serverConfig.host,
|
|
494
|
+
task: () => {
|
|
495
|
+
return new Listr(tasks);
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return servers;
|
|
500
|
+
};
|
|
501
|
+
const handler = async (yargs) => {
|
|
502
|
+
recordTelemetryAttributes({
|
|
503
|
+
command: "deploy baremetal",
|
|
504
|
+
firstRun: yargs.firstRun,
|
|
505
|
+
df: yargs.df,
|
|
506
|
+
update: yargs.update,
|
|
507
|
+
install: yargs.install,
|
|
508
|
+
migrate: yargs.migrate,
|
|
509
|
+
build: yargs.build,
|
|
510
|
+
restart: yargs.restart,
|
|
511
|
+
cleanup: yargs.cleanup,
|
|
512
|
+
maintenance: yargs.maintenance,
|
|
513
|
+
rollback: yargs.rollback,
|
|
514
|
+
verbose: yargs.verbose
|
|
515
|
+
});
|
|
516
|
+
const tomlPath = path.join(getPaths().base, "deploy.toml");
|
|
517
|
+
const ecosystemPath = path.join(getPaths().base, "ecosystem.config.js");
|
|
518
|
+
if (!fs.existsSync(tomlPath) || !fs.existsSync(ecosystemPath)) {
|
|
519
|
+
console.error(
|
|
520
|
+
c.error("\nError: Baremetal deploy has not been properly setup.\n") + "Please run `yarn rw setup deploy baremetal` before deploying"
|
|
521
|
+
);
|
|
522
|
+
process.exit(1);
|
|
523
|
+
}
|
|
524
|
+
const ssh = new SshExecutor(yargs.verbose);
|
|
525
|
+
try {
|
|
526
|
+
const tasks = new Listr(commands(yargs, ssh), {
|
|
527
|
+
concurrent: true,
|
|
528
|
+
exitOnError: true,
|
|
529
|
+
renderer: yargs.verbose && "verbose"
|
|
530
|
+
});
|
|
531
|
+
await tasks.run();
|
|
532
|
+
} catch (e) {
|
|
533
|
+
console.error(c.error("\nDeploy failed:"));
|
|
534
|
+
console.error(
|
|
535
|
+
boxen(e.stderr || e.message, {
|
|
536
|
+
padding: { top: 0, bottom: 0, right: 1, left: 1 },
|
|
537
|
+
margin: 0,
|
|
538
|
+
borderColor: "red"
|
|
539
|
+
})
|
|
540
|
+
);
|
|
541
|
+
process.exit(e?.exitCode || 1);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
export {
|
|
545
|
+
DEFAULT_SERVER_CONFIG,
|
|
546
|
+
commandWithLifecycleEvents,
|
|
547
|
+
commands,
|
|
548
|
+
deployTasks,
|
|
549
|
+
handler,
|
|
550
|
+
lifecycleTask,
|
|
551
|
+
maintenanceTasks,
|
|
552
|
+
parseConfig,
|
|
553
|
+
rollbackTasks,
|
|
554
|
+
serverConfigWithDefaults,
|
|
555
|
+
throwMissingConfig,
|
|
556
|
+
verifyConfig,
|
|
557
|
+
verifyServerConfig
|
|
558
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
const command = "baremetal [environment]";
|
|
3
|
+
const description = "Deploy to baremetal server(s)";
|
|
4
|
+
const builder = (yargs) => {
|
|
5
|
+
yargs.positional("environment", {
|
|
6
|
+
describe: "The environment to deploy to",
|
|
7
|
+
type: "string"
|
|
8
|
+
});
|
|
9
|
+
yargs.option("first-run", {
|
|
10
|
+
describe: "Set this flag the first time you deploy: starts server processes from scratch",
|
|
11
|
+
default: false,
|
|
12
|
+
type: "boolean"
|
|
13
|
+
});
|
|
14
|
+
yargs.option("df", {
|
|
15
|
+
describe: "Check available disk space",
|
|
16
|
+
default: true,
|
|
17
|
+
type: "boolean"
|
|
18
|
+
});
|
|
19
|
+
yargs.option("update", {
|
|
20
|
+
describe: "Update code to latest revision",
|
|
21
|
+
default: true,
|
|
22
|
+
type: "boolean"
|
|
23
|
+
});
|
|
24
|
+
yargs.option("install", {
|
|
25
|
+
describe: "Run `yarn install`",
|
|
26
|
+
default: true,
|
|
27
|
+
type: "boolean"
|
|
28
|
+
});
|
|
29
|
+
yargs.option("migrate", {
|
|
30
|
+
describe: "Run database migration tasks",
|
|
31
|
+
default: true,
|
|
32
|
+
type: "boolean"
|
|
33
|
+
});
|
|
34
|
+
yargs.option("build", {
|
|
35
|
+
describe: "Run build process for the deployed `sides`",
|
|
36
|
+
default: true,
|
|
37
|
+
type: "boolean"
|
|
38
|
+
});
|
|
39
|
+
yargs.option("restart", {
|
|
40
|
+
describe: "Restart server processes",
|
|
41
|
+
default: true,
|
|
42
|
+
type: "boolean"
|
|
43
|
+
});
|
|
44
|
+
yargs.option("cleanup", {
|
|
45
|
+
describe: "Remove old deploy directories",
|
|
46
|
+
default: true,
|
|
47
|
+
type: "boolean"
|
|
48
|
+
});
|
|
49
|
+
yargs.option("releaseDir", {
|
|
50
|
+
describe: "Directory to create for the latest release, defaults to timestamp",
|
|
51
|
+
default: (/* @__PURE__ */ new Date()).toISOString().replace(/[:\-TZ]/g, "").replace(/\.\d+$/, ""),
|
|
52
|
+
type: "string"
|
|
53
|
+
});
|
|
54
|
+
yargs.option("branch", {
|
|
55
|
+
describe: "The branch to deploy",
|
|
56
|
+
type: "string"
|
|
57
|
+
});
|
|
58
|
+
yargs.option("maintenance", {
|
|
59
|
+
describe: "Add/remove the maintenance page",
|
|
60
|
+
choices: ["up", "down"],
|
|
61
|
+
help: "Put up a maintenance page by replacing the content of web/dist/index.html with the content of web/src/maintenance.html"
|
|
62
|
+
});
|
|
63
|
+
yargs.option("rollback", {
|
|
64
|
+
describe: "Add/remove the maintenance page",
|
|
65
|
+
help: "Rollback [count] number of releases"
|
|
66
|
+
});
|
|
67
|
+
yargs.option("verbose", {
|
|
68
|
+
describe: "Verbose mode, for debugging purposes",
|
|
69
|
+
default: false,
|
|
70
|
+
type: "boolean"
|
|
71
|
+
});
|
|
72
|
+
yargs.epilogue(
|
|
73
|
+
`Also see the ${terminalLink(
|
|
74
|
+
"Redwood Baremetal Deploy Reference",
|
|
75
|
+
"https://redwoodjs.com/docs/cli-commands#deploy"
|
|
76
|
+
)}
|
|
77
|
+
`
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
async function handler(yargs) {
|
|
81
|
+
const { handler: importedHandler } = await import("./baremetal/baremetalHandler.js");
|
|
82
|
+
return importedHandler(yargs);
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
builder,
|
|
86
|
+
command,
|
|
87
|
+
description,
|
|
88
|
+
handler
|
|
89
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import terminalLink from "terminal-link";
|
|
2
|
+
const command = "flightcontrol <side>";
|
|
3
|
+
const alias = "fc";
|
|
4
|
+
const description = "Build, Migrate, and Serve commands for Flightcontrol deploy";
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs.positional("side", {
|
|
7
|
+
choices: ["api", "web"],
|
|
8
|
+
description: "Side to deploy",
|
|
9
|
+
type: "string"
|
|
10
|
+
}).option("prisma", {
|
|
11
|
+
description: "Apply database migrations",
|
|
12
|
+
type: "boolean",
|
|
13
|
+
default: true
|
|
14
|
+
}).option("serve", {
|
|
15
|
+
description: "Run server for api in production",
|
|
16
|
+
type: "boolean",
|
|
17
|
+
default: false
|
|
18
|
+
}).option("data-migrate", {
|
|
19
|
+
description: "Apply data migrations",
|
|
20
|
+
type: "boolean",
|
|
21
|
+
default: true,
|
|
22
|
+
alias: "dm"
|
|
23
|
+
}).epilogue(
|
|
24
|
+
`For more commands, options, and examples, see ${terminalLink(
|
|
25
|
+
"Redwood CLI Reference",
|
|
26
|
+
"https://redwoodjs.com/docs/cli-commands#deploy"
|
|
27
|
+
)}`
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
async function handler(yargs) {
|
|
31
|
+
const { handler: importedHandler } = await import("./flightcontrolHandler.js");
|
|
32
|
+
return importedHandler(yargs);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
alias,
|
|
36
|
+
builder,
|
|
37
|
+
command,
|
|
38
|
+
description,
|
|
39
|
+
handler
|
|
40
|
+
};
|