@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,69 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { Listr } from "listr2";
|
|
4
|
+
import { addEnvVarTask } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
|
+
import c from "../../../lib/colors.js";
|
|
7
|
+
import { addPackagesTask, getPaths, writeFile } from "../../../lib/index.js";
|
|
8
|
+
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
9
|
+
const CLIENT_PACKAGE_MAP = {
|
|
10
|
+
memcached: "memjs",
|
|
11
|
+
redis: "redis"
|
|
12
|
+
};
|
|
13
|
+
const CLIENT_HOST_MAP = {
|
|
14
|
+
memcached: "localhost:11211",
|
|
15
|
+
redis: "redis://localhost:6379"
|
|
16
|
+
};
|
|
17
|
+
const handler = async ({ client, force }) => {
|
|
18
|
+
const extension = isTypeScriptProject ? "ts" : "js";
|
|
19
|
+
const tasks = new Listr([
|
|
20
|
+
await addPackagesTask({
|
|
21
|
+
packages: [CLIENT_PACKAGE_MAP[client]],
|
|
22
|
+
side: "api"
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
title: `Writing api/src/lib/cache.js`,
|
|
26
|
+
task: () => {
|
|
27
|
+
const template = fs.readFileSync(
|
|
28
|
+
path.join(
|
|
29
|
+
import.meta.dirname,
|
|
30
|
+
"templates",
|
|
31
|
+
`${client}.ts.template`
|
|
32
|
+
)
|
|
33
|
+
).toString();
|
|
34
|
+
return writeFile(
|
|
35
|
+
path.join(getPaths().api.lib, `cache.${extension}`),
|
|
36
|
+
template,
|
|
37
|
+
{
|
|
38
|
+
overwriteExisting: force
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
addEnvVarTask(
|
|
44
|
+
"CACHE_HOST",
|
|
45
|
+
CLIENT_HOST_MAP[client],
|
|
46
|
+
`Where your ${client} server lives for service caching`
|
|
47
|
+
),
|
|
48
|
+
{
|
|
49
|
+
title: "One more thing...",
|
|
50
|
+
task: (_ctx, task) => {
|
|
51
|
+
task.title = `One more thing...
|
|
52
|
+
|
|
53
|
+
${c.tip("Check out the Service Cache docs for config and usage:")}
|
|
54
|
+
${c.link("https://redwoodjs.com/docs/services#caching")}
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
try {
|
|
60
|
+
await tasks.run();
|
|
61
|
+
} catch (e) {
|
|
62
|
+
errorTelemetry(process.argv, e.message);
|
|
63
|
+
console.error(c.error(e.message));
|
|
64
|
+
process.exit(e?.exitCode || 1);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
handler
|
|
69
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCache,
|
|
3
|
+
InMemoryClient,
|
|
4
|
+
MemcachedClient,
|
|
5
|
+
} from '@cedarjs/api/cache'
|
|
6
|
+
|
|
7
|
+
import { logger } from './logger'
|
|
8
|
+
|
|
9
|
+
const memJsFormattedLogger = {
|
|
10
|
+
log: (msg: string) => logger.error(msg),
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export let client: InMemoryClient | MemcachedClient
|
|
14
|
+
|
|
15
|
+
if (process.env.NODE_ENV === 'test') {
|
|
16
|
+
client = new InMemoryClient()
|
|
17
|
+
} else {
|
|
18
|
+
try {
|
|
19
|
+
client = new MemcachedClient(process.env.CACHE_HOST, {
|
|
20
|
+
logger: memJsFormattedLogger,
|
|
21
|
+
})
|
|
22
|
+
} catch (e) {
|
|
23
|
+
logger.error(`Could not connect to cache: ${e.message}`)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } = createCache(client, {
|
|
28
|
+
logger,
|
|
29
|
+
timeout: 500,
|
|
30
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCache,
|
|
3
|
+
InMemoryClient,
|
|
4
|
+
RedisClient,
|
|
5
|
+
} from '@cedarjs/api/cache'
|
|
6
|
+
|
|
7
|
+
import { logger } from './logger'
|
|
8
|
+
|
|
9
|
+
export let client: InMemoryClient | RedisClient
|
|
10
|
+
|
|
11
|
+
if (process.env.NODE_ENV === 'test') {
|
|
12
|
+
client = new InMemoryClient()
|
|
13
|
+
} else {
|
|
14
|
+
try {
|
|
15
|
+
client = new RedisClient({ url: process.env.CACHE_HOST, logger })
|
|
16
|
+
} catch (e) {
|
|
17
|
+
logger.error(`Could not connect to cache: ${e.message}`)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } = createCache(client, {
|
|
22
|
+
logger,
|
|
23
|
+
timeout: 500,
|
|
24
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const command = "deploy <target>";
|
|
2
|
+
const description = "Setup deployment to various targets";
|
|
3
|
+
import terminalLink from "terminal-link";
|
|
4
|
+
import * as setupDeployBaremetal from "./providers/baremetal.js";
|
|
5
|
+
import * as setupDeployCoherence from "./providers/coherence.js";
|
|
6
|
+
import * as setupDeployFlightcontrol from "./providers/flightcontrol.js";
|
|
7
|
+
import * as setupDeployNetlify from "./providers/netlify.js";
|
|
8
|
+
import * as setupDeployRender from "./providers/render.js";
|
|
9
|
+
import * as setupDeployServerless from "./providers/serverless.js";
|
|
10
|
+
import * as setupDeployVercel from "./providers/vercel.js";
|
|
11
|
+
const builder = (yargs) => yargs.command(setupDeployBaremetal).command(setupDeployCoherence).command(setupDeployFlightcontrol).command(setupDeployNetlify).command(setupDeployRender).command(setupDeployServerless).command(setupDeployVercel).demandCommand().option("force", {
|
|
12
|
+
alias: "f",
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Overwrite existing configuration",
|
|
15
|
+
type: "boolean"
|
|
16
|
+
}).epilogue(
|
|
17
|
+
`Also see the ${terminalLink(
|
|
18
|
+
"Redwood CLI Reference",
|
|
19
|
+
"https://redwoodjs.com/docs/cli-commands#setup-deploy-config"
|
|
20
|
+
)}`
|
|
21
|
+
);
|
|
22
|
+
export {
|
|
23
|
+
builder,
|
|
24
|
+
command,
|
|
25
|
+
description
|
|
26
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import execa from "execa";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import { getPaths, writeFilesTask } from "../../../../lib/index.js";
|
|
6
|
+
const REDWOOD_TOML_PATH = path.join(getPaths().base, "redwood.toml");
|
|
7
|
+
const updateApiURLTask = (apiUrl) => {
|
|
8
|
+
return {
|
|
9
|
+
title: "Updating API URL in redwood.toml...",
|
|
10
|
+
task: () => {
|
|
11
|
+
const redwoodToml = fs.readFileSync(REDWOOD_TOML_PATH).toString();
|
|
12
|
+
let newRedwoodToml = redwoodToml;
|
|
13
|
+
if (redwoodToml.match(/apiUrl/)) {
|
|
14
|
+
newRedwoodToml = newRedwoodToml.replace(
|
|
15
|
+
/apiUrl.*/g,
|
|
16
|
+
`apiUrl = "${apiUrl}"`
|
|
17
|
+
);
|
|
18
|
+
} else if (redwoodToml.match(/\[web\]/)) {
|
|
19
|
+
newRedwoodToml = newRedwoodToml.replace(
|
|
20
|
+
/\[web\]/,
|
|
21
|
+
`[web]
|
|
22
|
+
apiUrl = "${apiUrl}"`
|
|
23
|
+
);
|
|
24
|
+
} else {
|
|
25
|
+
newRedwoodToml += `[web]
|
|
26
|
+
apiUrl = "${apiUrl}"`;
|
|
27
|
+
}
|
|
28
|
+
fs.writeFileSync(REDWOOD_TOML_PATH, newRedwoodToml);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const preRequisiteCheckTask = (preRequisites) => {
|
|
33
|
+
return {
|
|
34
|
+
title: "Checking pre-requisites",
|
|
35
|
+
task: () => new Listr(
|
|
36
|
+
preRequisites.map((preReq) => {
|
|
37
|
+
return {
|
|
38
|
+
title: preReq.title,
|
|
39
|
+
task: async () => {
|
|
40
|
+
try {
|
|
41
|
+
await execa(...preReq.command);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
error.message = error.message + "\n" + preReq.errorMessage;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const addFilesTask = ({
|
|
53
|
+
files,
|
|
54
|
+
force = false,
|
|
55
|
+
title = "Adding config"
|
|
56
|
+
}) => {
|
|
57
|
+
return {
|
|
58
|
+
title: `${title}...`,
|
|
59
|
+
task: () => {
|
|
60
|
+
let fileNameToContentMap = {};
|
|
61
|
+
files.forEach((fileData) => {
|
|
62
|
+
fileNameToContentMap[fileData.path] = fileData.content;
|
|
63
|
+
});
|
|
64
|
+
return writeFilesTask(fileNameToContentMap, { overwriteExisting: force });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const addToGitIgnoreTask = ({ paths }) => {
|
|
69
|
+
return {
|
|
70
|
+
title: "Updating .gitignore...",
|
|
71
|
+
skip: () => {
|
|
72
|
+
if (!fs.existsSync(path.resolve(getPaths().base, ".gitignore"))) {
|
|
73
|
+
return "No gitignore present, skipping.";
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
task: async (_ctx, task) => {
|
|
77
|
+
const gitIgnore = path.resolve(getPaths().base, ".gitignore");
|
|
78
|
+
const content = fs.readFileSync(gitIgnore).toString();
|
|
79
|
+
if (paths.every((item) => content.includes(item))) {
|
|
80
|
+
task.skip(".gitignore already includes the additions.");
|
|
81
|
+
}
|
|
82
|
+
fs.appendFileSync(gitIgnore, ["\n", "# Deployment", ...paths].join("\n"));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const addToDotEnvTask = ({ lines }) => {
|
|
87
|
+
return {
|
|
88
|
+
title: "Updating .env...",
|
|
89
|
+
skip: () => {
|
|
90
|
+
if (!fs.existsSync(path.resolve(getPaths().base, ".env"))) {
|
|
91
|
+
return "No .env present, skipping.";
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
task: async (_ctx, task) => {
|
|
95
|
+
const env = path.resolve(getPaths().base, ".env");
|
|
96
|
+
const content = fs.readFileSync(env).toString();
|
|
97
|
+
if (lines.every((line) => content.includes(line.split("=")[0]))) {
|
|
98
|
+
task.skip(".env already includes the additions.");
|
|
99
|
+
}
|
|
100
|
+
fs.appendFileSync(env, lines.join("\n"));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
addFilesTask,
|
|
106
|
+
addToDotEnvTask,
|
|
107
|
+
addToGitIgnoreTask,
|
|
108
|
+
preRequisiteCheckTask,
|
|
109
|
+
updateApiURLTask
|
|
110
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { Listr } from "listr2";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
5
|
+
import c from "../../../../lib/colors.js";
|
|
6
|
+
import {
|
|
7
|
+
addPackagesTask,
|
|
8
|
+
getPaths,
|
|
9
|
+
printSetupNotes
|
|
10
|
+
} from "../../../../lib/index.js";
|
|
11
|
+
import { addFilesTask } from "../helpers/index.js";
|
|
12
|
+
import { DEPLOY, ECOSYSTEM, MAINTENANCE } from "../templates/baremetal.js";
|
|
13
|
+
const configFilename = "deploy.toml";
|
|
14
|
+
const files = [
|
|
15
|
+
{
|
|
16
|
+
path: path.join(getPaths().base, configFilename),
|
|
17
|
+
content: DEPLOY
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
path: path.join(getPaths().base, "ecosystem.config.js"),
|
|
21
|
+
content: ECOSYSTEM
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
path: path.join(getPaths().web.src, "maintenance.html"),
|
|
25
|
+
content: MAINTENANCE
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
const notes = [
|
|
29
|
+
"You are almost ready to go BAREMETAL!",
|
|
30
|
+
"",
|
|
31
|
+
"See https://redwoodjs.com/docs/deploy/baremetal for the remaining",
|
|
32
|
+
"config and setup required before you can perform your first deploy."
|
|
33
|
+
];
|
|
34
|
+
const handler = async ({ force }) => {
|
|
35
|
+
recordTelemetryAttributes({
|
|
36
|
+
command: "setup deploy baremetal",
|
|
37
|
+
force
|
|
38
|
+
});
|
|
39
|
+
const tasks = new Listr(
|
|
40
|
+
[
|
|
41
|
+
await addPackagesTask({
|
|
42
|
+
packages: ["node-ssh"],
|
|
43
|
+
devDependency: true
|
|
44
|
+
}),
|
|
45
|
+
addFilesTask({
|
|
46
|
+
files,
|
|
47
|
+
force
|
|
48
|
+
}),
|
|
49
|
+
printSetupNotes(notes)
|
|
50
|
+
],
|
|
51
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
52
|
+
);
|
|
53
|
+
try {
|
|
54
|
+
await tasks.run();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
errorTelemetry(process.argv, e.message);
|
|
57
|
+
console.error(c.error(e.message));
|
|
58
|
+
process.exit(e?.exitCode || 1);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
configFilename,
|
|
63
|
+
handler
|
|
64
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
const command = "coherence";
|
|
3
|
+
const description = "Setup Coherence deploy";
|
|
4
|
+
function builder(yargs) {
|
|
5
|
+
yargs.option("force", {
|
|
6
|
+
description: "Overwrite existing configuration",
|
|
7
|
+
type: "boolean",
|
|
8
|
+
default: false
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async function handler(options) {
|
|
12
|
+
recordTelemetryAttributes({
|
|
13
|
+
command: "setup deploy coherence",
|
|
14
|
+
force: options.force
|
|
15
|
+
});
|
|
16
|
+
const { handler: handler2 } = await import("./coherenceHandler.js");
|
|
17
|
+
return handler2(options);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
builder,
|
|
21
|
+
command,
|
|
22
|
+
description,
|
|
23
|
+
handler
|
|
24
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import prismaInternals from "@prisma/internals";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import * as toml from "smol-toml";
|
|
6
|
+
import {
|
|
7
|
+
colors as c,
|
|
8
|
+
getPaths,
|
|
9
|
+
isTypeScriptProject
|
|
10
|
+
} from "@cedarjs/cli-helpers";
|
|
11
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
12
|
+
import { printSetupNotes } from "../../../../lib/index.js";
|
|
13
|
+
import { serverFileExists } from "../../../../lib/project.js";
|
|
14
|
+
import { addFilesTask } from "../helpers/index.js";
|
|
15
|
+
const { getSchema, getConfig } = prismaInternals;
|
|
16
|
+
const redwoodProjectPaths = getPaths();
|
|
17
|
+
const EXTENSION = isTypeScriptProject ? "ts" : "js";
|
|
18
|
+
async function handler({ force }) {
|
|
19
|
+
try {
|
|
20
|
+
const addCoherenceFilesTask = await getAddCoherenceFilesTask(force);
|
|
21
|
+
const tasks = new Listr(
|
|
22
|
+
[
|
|
23
|
+
addCoherenceFilesTask,
|
|
24
|
+
updateRedwoodTOMLTask(),
|
|
25
|
+
printSetupNotes([
|
|
26
|
+
"You're ready to deploy to Coherence! \u2728\n",
|
|
27
|
+
"Go to https://app.withcoherence.com to create your account and setup your cloud or GitHub connections.",
|
|
28
|
+
"Check out the deployment docs at https://docs.withcoherence.com for detailed instructions and more information.\n",
|
|
29
|
+
"Reach out to redwood@withcoherence.com with any questions! We're here to support you."
|
|
30
|
+
])
|
|
31
|
+
],
|
|
32
|
+
{ rendererOptions: { collapse: false } }
|
|
33
|
+
);
|
|
34
|
+
await tasks.run();
|
|
35
|
+
} catch (e) {
|
|
36
|
+
errorTelemetry(process.argv, e.message);
|
|
37
|
+
console.error(c.error(e.message));
|
|
38
|
+
process.exit(e?.exitCode || 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function getAddCoherenceFilesTask(force) {
|
|
42
|
+
const files = [
|
|
43
|
+
{
|
|
44
|
+
path: path.join(redwoodProjectPaths.api.functions, `health.${EXTENSION}`),
|
|
45
|
+
content: coherenceFiles.healthCheck
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
const coherenceConfigFile = {
|
|
49
|
+
path: path.join(redwoodProjectPaths.base, "coherence.yml")
|
|
50
|
+
};
|
|
51
|
+
coherenceConfigFile.content = await getCoherenceConfigFileContent();
|
|
52
|
+
files.push(coherenceConfigFile);
|
|
53
|
+
return addFilesTask({
|
|
54
|
+
title: `Adding coherence.yml and health.${EXTENSION}`,
|
|
55
|
+
files,
|
|
56
|
+
force
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async function getCoherenceConfigFileContent() {
|
|
60
|
+
const prismaSchema = await getSchema(redwoodProjectPaths.api.dbSchema);
|
|
61
|
+
const prismaConfig = await getConfig({ datamodel: prismaSchema });
|
|
62
|
+
let db = prismaConfig.datasources[0].activeProvider;
|
|
63
|
+
if (!SUPPORTED_DATABASES.includes(db)) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
[
|
|
66
|
+
`Coherence doesn't support the "${db}" provider in your Prisma schema.`,
|
|
67
|
+
`To proceed, switch to one of the following: ${SUPPORTED_DATABASES.join(
|
|
68
|
+
", "
|
|
69
|
+
)}.`
|
|
70
|
+
].join("\n")
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (db === "postgresql") {
|
|
74
|
+
db = "postgres";
|
|
75
|
+
}
|
|
76
|
+
const apiProdCommand = ["yarn", "rw", "build", "api", "&&"];
|
|
77
|
+
if (serverFileExists()) {
|
|
78
|
+
apiProdCommand.push(
|
|
79
|
+
"yarn",
|
|
80
|
+
"node",
|
|
81
|
+
"api/dist/server.js",
|
|
82
|
+
"--apiRootPath=/api"
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
apiProdCommand.push("yarn", "rw", "serve", "api", "--apiRootPath=/api");
|
|
86
|
+
}
|
|
87
|
+
return coherenceFiles.yamlTemplate({
|
|
88
|
+
db,
|
|
89
|
+
apiProdCommand: `[${apiProdCommand.map((cmd) => `"${cmd}"`).join(", ")}]`
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const SUPPORTED_DATABASES = ["mysql", "postgresql"];
|
|
93
|
+
function updateRedwoodTOMLTask() {
|
|
94
|
+
return {
|
|
95
|
+
title: "Updating redwood.toml...",
|
|
96
|
+
task: () => {
|
|
97
|
+
const redwoodTOMLPath = path.join(
|
|
98
|
+
redwoodProjectPaths.base,
|
|
99
|
+
"redwood.toml"
|
|
100
|
+
);
|
|
101
|
+
let redwoodTOMLContent = fs.readFileSync(redwoodTOMLPath, "utf-8");
|
|
102
|
+
const redwoodTOMLObject = toml.parse(redwoodTOMLContent);
|
|
103
|
+
if (!redwoodTOMLObject.web.host) {
|
|
104
|
+
const [beforeWeb, afterWeb] = redwoodTOMLContent.split(/\[web\]\s/);
|
|
105
|
+
redwoodTOMLContent = [
|
|
106
|
+
beforeWeb,
|
|
107
|
+
'[web]\n host = "0.0.0.0"\n',
|
|
108
|
+
afterWeb
|
|
109
|
+
].join("");
|
|
110
|
+
}
|
|
111
|
+
if (!redwoodTOMLObject.api.host) {
|
|
112
|
+
const [beforeApi, afterApi] = redwoodTOMLContent.split(/\[api\]\s/);
|
|
113
|
+
redwoodTOMLContent = [
|
|
114
|
+
beforeApi,
|
|
115
|
+
'[api]\n host = "0.0.0.0"\n',
|
|
116
|
+
afterApi
|
|
117
|
+
].join("");
|
|
118
|
+
}
|
|
119
|
+
redwoodTOMLContent = redwoodTOMLContent.replaceAll(
|
|
120
|
+
HOST_REGEXP,
|
|
121
|
+
(match, spaceBeforeAssign, spaceAfterAssign) => ["host", spaceBeforeAssign, "=", spaceAfterAssign, '"0.0.0.0"'].join(
|
|
122
|
+
""
|
|
123
|
+
)
|
|
124
|
+
);
|
|
125
|
+
redwoodTOMLContent = redwoodTOMLContent.replace(
|
|
126
|
+
API_URL_REGEXP,
|
|
127
|
+
(match, spaceBeforeAssign, spaceAfterAssign) => ["apiUrl", spaceBeforeAssign, "=", spaceAfterAssign, '"/api"'].join(
|
|
128
|
+
""
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
redwoodTOMLContent = redwoodTOMLContent.replaceAll(
|
|
132
|
+
PORT_REGEXP,
|
|
133
|
+
(_match, spaceBeforeAssign, spaceAfterAssign, port) => [
|
|
134
|
+
"port",
|
|
135
|
+
spaceBeforeAssign,
|
|
136
|
+
"=",
|
|
137
|
+
spaceAfterAssign,
|
|
138
|
+
`"\${PORT:${port}}"`
|
|
139
|
+
].join("")
|
|
140
|
+
);
|
|
141
|
+
fs.writeFileSync(redwoodTOMLPath, redwoodTOMLContent);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const HOST_REGEXP = /host(\s*)=(\s*)\".+\"/g;
|
|
146
|
+
const API_URL_REGEXP = /apiUrl(\s*)=(\s*)\".+\"/;
|
|
147
|
+
const PORT_REGEXP = /port(\s*)=(\s*)(?<port>\d{4})/g;
|
|
148
|
+
const coherenceFiles = {
|
|
149
|
+
yamlTemplate({ db, apiProdCommand }) {
|
|
150
|
+
return `api:
|
|
151
|
+
type: backend
|
|
152
|
+
url_path: "/api"
|
|
153
|
+
prod:
|
|
154
|
+
command: ${apiProdCommand}
|
|
155
|
+
dev:
|
|
156
|
+
command: ["yarn", "rw", "build", "api", "&&", "yarn", "rw", "dev", "api", "--apiRootPath=/api"]
|
|
157
|
+
local_packages: ["node_modules"]
|
|
158
|
+
|
|
159
|
+
system:
|
|
160
|
+
cpu: 2
|
|
161
|
+
memory: 2G
|
|
162
|
+
health_check: "/api/health"
|
|
163
|
+
|
|
164
|
+
resources:
|
|
165
|
+
- name: ${path.basename(redwoodProjectPaths.base)}-db
|
|
166
|
+
engine: ${db}
|
|
167
|
+
version: 13
|
|
168
|
+
type: database
|
|
169
|
+
${db === "postgres" ? "adapter: postgresql" : ""}
|
|
170
|
+
|
|
171
|
+
# If you use data migrations, use the following instead:
|
|
172
|
+
# migration: ["yarn", "rw", "prisma", "migrate", "deploy", "&&", "yarn", "rw", "data-migrate", "up"]
|
|
173
|
+
migration: ["yarn", "rw", "prisma", "migrate", "deploy"]
|
|
174
|
+
|
|
175
|
+
web:
|
|
176
|
+
type: frontend
|
|
177
|
+
assets_path: "web/dist"
|
|
178
|
+
prod:
|
|
179
|
+
command: ["yarn", "rw", "serve", "web"]
|
|
180
|
+
dev:
|
|
181
|
+
command: ["yarn", "rw", "dev", "web", "--fwd=\\"--allowed-hosts all\\""]
|
|
182
|
+
|
|
183
|
+
# Heads up: Redwood's prerender doesn't work with Coherence yet.
|
|
184
|
+
# For current status and updates, see https://github.com/redwoodjs/redwood/issues/8333.
|
|
185
|
+
build: ["yarn", "rw", "build", "web", "--no-prerender"]
|
|
186
|
+
local_packages: ["node_modules"]
|
|
187
|
+
|
|
188
|
+
system:
|
|
189
|
+
cpu: 2
|
|
190
|
+
memory: 2G
|
|
191
|
+
`;
|
|
192
|
+
},
|
|
193
|
+
healthCheck: `// Coherence health check
|
|
194
|
+
export const handler = async () => {
|
|
195
|
+
return {
|
|
196
|
+
statusCode: 200,
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`
|
|
200
|
+
};
|
|
201
|
+
export {
|
|
202
|
+
handler
|
|
203
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createHandler } from "../helpers/helpers.js";
|
|
2
|
+
const command = "flightcontrol";
|
|
3
|
+
const alias = "fc";
|
|
4
|
+
const description = "Setup Flightcontrol deploy";
|
|
5
|
+
const builder = (yargs) => yargs.option("database", {
|
|
6
|
+
alias: "d",
|
|
7
|
+
choices: ["none", "postgresql", "mysql"],
|
|
8
|
+
description: "Database deployment for Flightcontrol only",
|
|
9
|
+
default: "postgresql",
|
|
10
|
+
type: "string"
|
|
11
|
+
});
|
|
12
|
+
const handler = createHandler("flightcontrol");
|
|
13
|
+
export {
|
|
14
|
+
alias,
|
|
15
|
+
builder,
|
|
16
|
+
command,
|
|
17
|
+
description,
|
|
18
|
+
handler
|
|
19
|
+
};
|