vibecarbon 0.1.0
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 +663 -0
- package/README.md +188 -0
- package/carbon/.claude/hooks/task-completed-gate.sh +19 -0
- package/carbon/.claude/hooks/teammate-idle-gate.sh +29 -0
- package/carbon/.claude/settings.json +29 -0
- package/carbon/.cursor/rules/vibecarbon.mdc +6 -0
- package/carbon/.dockerignore +57 -0
- package/carbon/.env.example +219 -0
- package/carbon/.github/copilot-instructions.md +3 -0
- package/carbon/.github/workflows/deploy.yml +346 -0
- package/carbon/.github/workflows/vibecarbon-build.yml +81 -0
- package/carbon/.windsurfrules +74 -0
- package/carbon/AGENTS.md +422 -0
- package/carbon/CLAUDE.md +3 -0
- package/carbon/DEVELOPMENT.md +187 -0
- package/carbon/Dockerfile +98 -0
- package/carbon/LICENSE +21 -0
- package/carbon/PRODUCTION.md +364 -0
- package/carbon/README.md +193 -0
- package/carbon/TESTING.md +138 -0
- package/carbon/backup/Dockerfile +75 -0
- package/carbon/backup/backup.sh +95 -0
- package/carbon/backup/compose-backup.sh +140 -0
- package/carbon/biome.json +83 -0
- package/carbon/cloud-init/docker-ce-setup.yaml +55 -0
- package/carbon/cloud-init/k3s/master-init.sh +215 -0
- package/carbon/cloud-init/k3s/supabase-init.sh +167 -0
- package/carbon/cloud-init/k3s/worker-init.sh +147 -0
- package/carbon/components.json +24 -0
- package/carbon/content/blog/authentication-guide.mdx +34 -0
- package/carbon/content/blog/getting-started.mdx +41 -0
- package/carbon/content/changelog/v0-1-0.mdx +40 -0
- package/carbon/content/docs/analytics.mdx +90 -0
- package/carbon/content/docs/authentication.mdx +231 -0
- package/carbon/content/docs/background-jobs.mdx +116 -0
- package/carbon/content/docs/cli.mdx +630 -0
- package/carbon/content/docs/database.mdx +236 -0
- package/carbon/content/docs/deployment.mdx +227 -0
- package/carbon/content/docs/development.mdx +238 -0
- package/carbon/content/docs/environments.mdx +84 -0
- package/carbon/content/docs/getting-started.mdx +112 -0
- package/carbon/content/docs/legal/privacy-policy.mdx +89 -0
- package/carbon/content/docs/legal/terms-of-service.mdx +99 -0
- package/carbon/content/docs/optional-services.mdx +160 -0
- package/carbon/db/Dockerfile +23 -0
- package/carbon/docker-compose.dev-init.yml +5 -0
- package/carbon/docker-compose.metabase.override.yml +14 -0
- package/carbon/docker-compose.metabase.prod.yml +28 -0
- package/carbon/docker-compose.metabase.yml +84 -0
- package/carbon/docker-compose.n8n.override.yml +14 -0
- package/carbon/docker-compose.n8n.prod.yml +31 -0
- package/carbon/docker-compose.n8n.yml +97 -0
- package/carbon/docker-compose.observability.override.yml +18 -0
- package/carbon/docker-compose.observability.prod.yml +28 -0
- package/carbon/docker-compose.observability.yml +125 -0
- package/carbon/docker-compose.override.yml +28 -0
- package/carbon/docker-compose.prod.yml +294 -0
- package/carbon/docker-compose.yml +508 -0
- package/carbon/docker-entrypoint.sh +12 -0
- package/carbon/ha/activate-standby.sh +52 -0
- package/carbon/ha/primary-init.sql +36 -0
- package/carbon/ha/standby-init.sh +74 -0
- package/carbon/k8s/LICENSE +99 -0
- package/carbon/k8s/README.md +272 -0
- package/carbon/k8s/base/app/deployment.yaml +130 -0
- package/carbon/k8s/base/app/hpa.yaml +44 -0
- package/carbon/k8s/base/app/kustomization.yaml +10 -0
- package/carbon/k8s/base/app/network-policy.yaml +124 -0
- package/carbon/k8s/base/app/pdb.yaml +14 -0
- package/carbon/k8s/base/app/rbac.yaml +36 -0
- package/carbon/k8s/base/app/service.yaml +16 -0
- package/carbon/k8s/base/backup/cronjob.yaml +120 -0
- package/carbon/k8s/base/backup/kustomization.yaml +7 -0
- package/carbon/k8s/base/backup/network-policy.yaml +31 -0
- package/carbon/k8s/base/backup/rbac.yaml +7 -0
- package/carbon/k8s/base/cluster-autoscaler/deployment.yaml +103 -0
- package/carbon/k8s/base/cluster-autoscaler/kustomization.yaml +17 -0
- package/carbon/k8s/base/cluster-autoscaler/rbac.yaml +109 -0
- package/carbon/k8s/base/config/configmap.yaml +48 -0
- package/carbon/k8s/base/config/kustomization.yaml +8 -0
- package/carbon/k8s/base/hetzner-ccm/kustomization.yaml +9 -0
- package/carbon/k8s/base/hetzner-csi/kustomization.yaml +9 -0
- package/carbon/k8s/base/kustomization.yaml +43 -0
- package/carbon/k8s/base/namespace.yaml +7 -0
- package/carbon/k8s/base/network-policies.yaml +95 -0
- package/carbon/k8s/base/registry/kustomization.yaml +5 -0
- package/carbon/k8s/base/registry/local-registry.yaml +193 -0
- package/carbon/k8s/base/traefik/certificate.yaml +21 -0
- package/carbon/k8s/base/traefik/configmap.yaml +13 -0
- package/carbon/k8s/base/traefik/deployment.yaml +165 -0
- package/carbon/k8s/base/traefik/ingressroute.yaml +141 -0
- package/carbon/k8s/base/traefik/kustomization.yaml +11 -0
- package/carbon/k8s/base/traefik/middleware.yaml +109 -0
- package/carbon/k8s/base/traefik/network-policy.yaml +92 -0
- package/carbon/k8s/base/traefik/service.yaml +38 -0
- package/carbon/k8s/flux/README.md +49 -0
- package/carbon/k8s/flux/clusters/primary/vibecarbon.yaml +128 -0
- package/carbon/k8s/flux/clusters/standby/vibecarbon.yaml +83 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/helm-release.yaml +38 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/helm-repository.yaml +16 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/kustomization.yaml +10 -0
- package/carbon/k8s/gitops/supabase/helm-release.yaml +66 -0
- package/carbon/k8s/gitops/supabase/helm-repository.yaml +18 -0
- package/carbon/k8s/gitops/supabase/kustomization.yaml +33 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-cloudflare.yaml +51 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-hetzner.yaml +59 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-manual.yaml +43 -0
- package/carbon/k8s/infra/cert-manager-resources/kustomization.yaml +15 -0
- package/carbon/k8s/infra/kustomization.yaml +21 -0
- package/carbon/k8s/infra/traefik-crds/kustomization.yaml +10 -0
- package/carbon/k8s/overlays/local/configmap.yaml +23 -0
- package/carbon/k8s/overlays/local/ingressroute-studio.yaml +104 -0
- package/carbon/k8s/overlays/local/kustomization.yaml +215 -0
- package/carbon/k8s/overlays/local/namespace.yaml +8 -0
- package/carbon/k8s/overlays/local/secrets.yaml +32 -0
- package/carbon/k8s/overlays/production/kustomization.yaml +34 -0
- package/carbon/k8s/test-local.sh +318 -0
- package/carbon/k8s/values/supabase.values.yaml +133 -0
- package/carbon/package.json +154 -0
- package/carbon/runtime.Dockerfile +17 -0
- package/carbon/scripts/_dev-jwt.mjs +45 -0
- package/carbon/scripts/check-rls.ts +53 -0
- package/carbon/scripts/dev-init.js +191 -0
- package/carbon/scripts/dev.js +191 -0
- package/carbon/scripts/docker-down.js +63 -0
- package/carbon/scripts/docker-logs.js +59 -0
- package/carbon/scripts/docker-up.js +222 -0
- package/carbon/scripts/generate-dev-configs.sh +131 -0
- package/carbon/scripts/generate-rss.ts +116 -0
- package/carbon/scripts/generate-sitemap.ts +102 -0
- package/carbon/scripts/k8s-apply.js +71 -0
- package/carbon/scripts/k8s-delete.js +75 -0
- package/carbon/scripts/lib/manifest.js +176 -0
- package/carbon/scripts/secret-scan.mjs +278 -0
- package/carbon/scripts/validate-dev-configs.sh +101 -0
- package/carbon/src/client/App.tsx +202 -0
- package/carbon/src/client/assets/hyperformant-dark.svg +29 -0
- package/carbon/src/client/assets/hyperformant-light.svg +29 -0
- package/carbon/src/client/assets/logos/aider.svg +1 -0
- package/carbon/src/client/assets/logos/antigravity.svg +1 -0
- package/carbon/src/client/assets/logos/bolt.svg +1 -0
- package/carbon/src/client/assets/logos/claude-code.svg +1 -0
- package/carbon/src/client/assets/logos/copilot.svg +1 -0
- package/carbon/src/client/assets/logos/cursor.svg +1 -0
- package/carbon/src/client/assets/logos/gemini-cli.svg +1 -0
- package/carbon/src/client/assets/logos/lovable.svg +1 -0
- package/carbon/src/client/assets/logos/openai-codex.svg +1 -0
- package/carbon/src/client/assets/logos/v0.svg +1 -0
- package/carbon/src/client/assets/logos/windsurf.svg +1 -0
- package/carbon/src/client/assets/vibecarbon-icon.svg +19 -0
- package/carbon/src/client/assets/vibecarbon-logo-dark.svg +29 -0
- package/carbon/src/client/assets/vibecarbon-logo-light.svg +29 -0
- package/carbon/src/client/components/AIIntegrationSection.tsx +120 -0
- package/carbon/src/client/components/AppSidebar.tsx +760 -0
- package/carbon/src/client/components/ArchitectureSection.tsx +46 -0
- package/carbon/src/client/components/CTAFooter.tsx +59 -0
- package/carbon/src/client/components/ComparisonSection.tsx +132 -0
- package/carbon/src/client/components/ContentPanel.tsx +66 -0
- package/carbon/src/client/components/ContentSkeleton.tsx +21 -0
- package/carbon/src/client/components/ErrorBoundary.tsx +46 -0
- package/carbon/src/client/components/FAQSection.tsx +76 -0
- package/carbon/src/client/components/FileUpload.tsx +210 -0
- package/carbon/src/client/components/HeaderActions.tsx +17 -0
- package/carbon/src/client/components/Hero.tsx +608 -0
- package/carbon/src/client/components/ImpersonationBanner.tsx +31 -0
- package/carbon/src/client/components/LanguageSwitcher.tsx +67 -0
- package/carbon/src/client/components/Logo.tsx +87 -0
- package/carbon/src/client/components/LogoStrip.tsx +76 -0
- package/carbon/src/client/components/MetricsStrip.tsx +48 -0
- package/carbon/src/client/components/Nav.tsx +195 -0
- package/carbon/src/client/components/NewsletterSignup.tsx +147 -0
- package/carbon/src/client/components/NotificationDrawer.tsx +171 -0
- package/carbon/src/client/components/PageHeader.tsx +24 -0
- package/carbon/src/client/components/PlanGate.tsx +36 -0
- package/carbon/src/client/components/PricingSection.tsx +371 -0
- package/carbon/src/client/components/SEO.tsx +34 -0
- package/carbon/src/client/components/SmoothScroll.tsx +45 -0
- package/carbon/src/client/components/TechStackSection.tsx +165 -0
- package/carbon/src/client/components/WorkflowSection.tsx +604 -0
- package/carbon/src/client/components/admin/DockerLogs.tsx +276 -0
- package/carbon/src/client/components/admin/PerformanceMetrics.tsx +230 -0
- package/carbon/src/client/components/admin/ServiceCard.tsx +45 -0
- package/carbon/src/client/components/admin/ServicesStatus.tsx +296 -0
- package/carbon/src/client/components/architecture/ArchitectureDiagram.tsx +413 -0
- package/carbon/src/client/components/auth/AuthProvider.tsx +466 -0
- package/carbon/src/client/components/effects/FilmGrainOverlay.tsx +35 -0
- package/carbon/src/client/components/effects/FresnelEdge.tsx +49 -0
- package/carbon/src/client/components/effects/GlowTracker.tsx +46 -0
- package/carbon/src/client/components/effects/SparkBurst.tsx +145 -0
- package/carbon/src/client/components/effects/VGlowEffect.tsx +83 -0
- package/carbon/src/client/components/effects/index.ts +2 -0
- package/carbon/src/client/components/layouts/SidebarLayout.tsx +20 -0
- package/carbon/src/client/components/scroll/ScrollSection.tsx +76 -0
- package/carbon/src/client/components/scroll/ScrollytellingProvider.tsx +81 -0
- package/carbon/src/client/components/scroll/index.ts +2 -0
- package/carbon/src/client/components/ui/accordion.tsx +71 -0
- package/carbon/src/client/components/ui/alert-dialog.tsx +162 -0
- package/carbon/src/client/components/ui/alert.tsx +73 -0
- package/carbon/src/client/components/ui/aspect-ratio.tsx +22 -0
- package/carbon/src/client/components/ui/avatar.tsx +91 -0
- package/carbon/src/client/components/ui/badge.tsx +50 -0
- package/carbon/src/client/components/ui/breadcrumb.tsx +100 -0
- package/carbon/src/client/components/ui/button-group.tsx +78 -0
- package/carbon/src/client/components/ui/button.tsx +120 -0
- package/carbon/src/client/components/ui/calendar.tsx +182 -0
- package/carbon/src/client/components/ui/card.tsx +85 -0
- package/carbon/src/client/components/ui/carousel.tsx +227 -0
- package/carbon/src/client/components/ui/chart.tsx +357 -0
- package/carbon/src/client/components/ui/checkbox.tsx +27 -0
- package/carbon/src/client/components/ui/collapsible.tsx +15 -0
- package/carbon/src/client/components/ui/command.tsx +178 -0
- package/carbon/src/client/components/ui/context-menu.tsx +233 -0
- package/carbon/src/client/components/ui/dialog.tsx +132 -0
- package/carbon/src/client/components/ui/drawer.tsx +118 -0
- package/carbon/src/client/components/ui/dropdown-menu.tsx +242 -0
- package/carbon/src/client/components/ui/empty.tsx +94 -0
- package/carbon/src/client/components/ui/field.tsx +226 -0
- package/carbon/src/client/components/ui/hover-card.tsx +44 -0
- package/carbon/src/client/components/ui/input-group.tsx +146 -0
- package/carbon/src/client/components/ui/input-otp.tsx +83 -0
- package/carbon/src/client/components/ui/input.tsx +20 -0
- package/carbon/src/client/components/ui/item.tsx +188 -0
- package/carbon/src/client/components/ui/kbd.tsx +26 -0
- package/carbon/src/client/components/ui/label.tsx +21 -0
- package/carbon/src/client/components/ui/menubar.tsx +250 -0
- package/carbon/src/client/components/ui/navigation-menu.tsx +155 -0
- package/carbon/src/client/components/ui/pagination.tsx +102 -0
- package/carbon/src/client/components/ui/popover.tsx +75 -0
- package/carbon/src/client/components/ui/progress.tsx +66 -0
- package/carbon/src/client/components/ui/radio-group.tsx +36 -0
- package/carbon/src/client/components/ui/resizable.tsx +46 -0
- package/carbon/src/client/components/ui/scroll-area.tsx +48 -0
- package/carbon/src/client/components/ui/select.tsx +186 -0
- package/carbon/src/client/components/ui/separator.tsx +21 -0
- package/carbon/src/client/components/ui/sheet.tsx +124 -0
- package/carbon/src/client/components/ui/sidebar.tsx +702 -0
- package/carbon/src/client/components/ui/skeleton.tsx +13 -0
- package/carbon/src/client/components/ui/slider.tsx +57 -0
- package/carbon/src/client/components/ui/sonner.tsx +45 -0
- package/carbon/src/client/components/ui/spinner.tsx +15 -0
- package/carbon/src/client/components/ui/switch.tsx +30 -0
- package/carbon/src/client/components/ui/table.tsx +89 -0
- package/carbon/src/client/components/ui/tabs.tsx +73 -0
- package/carbon/src/client/components/ui/textarea.tsx +18 -0
- package/carbon/src/client/components/ui/toggle-group.tsx +87 -0
- package/carbon/src/client/components/ui/toggle.tsx +44 -0
- package/carbon/src/client/components/ui/tooltip.tsx +56 -0
- package/carbon/src/client/hooks/api/index.ts +14 -0
- package/carbon/src/client/hooks/api/useAuthSettings.ts +80 -0
- package/carbon/src/client/hooks/api/useSubscription.ts +87 -0
- package/carbon/src/client/hooks/use-mobile.ts +21 -0
- package/carbon/src/client/hooks/useMousePosition.ts +91 -0
- package/carbon/src/client/hooks/useNotifications.tsx +124 -0
- package/carbon/src/client/hooks/useOrganizationMembers.ts +127 -0
- package/carbon/src/client/hooks/useOrganizations.tsx +230 -0
- package/carbon/src/client/hooks/usePackageManager.ts +69 -0
- package/carbon/src/client/hooks/useReducedMotion.ts +20 -0
- package/carbon/src/client/hooks/useRunningServices.ts +114 -0
- package/carbon/src/client/hooks/useScrollProgress.ts +56 -0
- package/carbon/src/client/index.css +467 -0
- package/carbon/src/client/index.html +56 -0
- package/carbon/src/client/lib/admin-services.ts +151 -0
- package/carbon/src/client/lib/api.ts +32 -0
- package/carbon/src/client/lib/blog.ts +35 -0
- package/carbon/src/client/lib/changelog.ts +33 -0
- package/carbon/src/client/lib/docs-search.ts +101 -0
- package/carbon/src/client/lib/docs.ts +37 -0
- package/carbon/src/client/lib/i18n.ts +32 -0
- package/carbon/src/client/lib/supabase.ts +72 -0
- package/carbon/src/client/lib/tailwind-colors.ts +357 -0
- package/carbon/src/client/lib/theme.ts +117 -0
- package/carbon/src/client/lib/utils.ts +22 -0
- package/carbon/src/client/locales/de.json +529 -0
- package/carbon/src/client/locales/en.json +461 -0
- package/carbon/src/client/locales/es.json +529 -0
- package/carbon/src/client/locales/fr.json +529 -0
- package/carbon/src/client/locales/pt.json +529 -0
- package/carbon/src/client/main.tsx +56 -0
- package/carbon/src/client/mdx.d.ts +13 -0
- package/carbon/src/client/pages/ApiDocs.tsx +76 -0
- package/carbon/src/client/pages/AuthCallback.tsx +34 -0
- package/carbon/src/client/pages/Blog.tsx +167 -0
- package/carbon/src/client/pages/Changelog.tsx +171 -0
- package/carbon/src/client/pages/Charts.tsx +388 -0
- package/carbon/src/client/pages/Checkout.tsx +227 -0
- package/carbon/src/client/pages/Contact.tsx +174 -0
- package/carbon/src/client/pages/Dashboard.tsx +368 -0
- package/carbon/src/client/pages/Docs.tsx +372 -0
- package/carbon/src/client/pages/ForgotPassword.tsx +111 -0
- package/carbon/src/client/pages/Home.tsx +187 -0
- package/carbon/src/client/pages/Legal.tsx +100 -0
- package/carbon/src/client/pages/Login.tsx +408 -0
- package/carbon/src/client/pages/MFAVerify.tsx +156 -0
- package/carbon/src/client/pages/NotFound.tsx +21 -0
- package/carbon/src/client/pages/Onboarding.tsx +246 -0
- package/carbon/src/client/pages/ResetPassword.tsx +200 -0
- package/carbon/src/client/pages/UIComponents.tsx +390 -0
- package/carbon/src/client/pages/admin/ContactSubmissions.tsx +220 -0
- package/carbon/src/client/pages/admin/Dashboard.tsx +24 -0
- package/carbon/src/client/pages/admin/Infrastructure.tsx +257 -0
- package/carbon/src/client/pages/admin/Jobs.tsx +225 -0
- package/carbon/src/client/pages/admin/Logs.tsx +18 -0
- package/carbon/src/client/pages/admin/Newsletter.tsx +300 -0
- package/carbon/src/client/pages/admin/Notifications.tsx +603 -0
- package/carbon/src/client/pages/admin/Organizations.tsx +306 -0
- package/carbon/src/client/pages/admin/Settings.tsx +314 -0
- package/carbon/src/client/pages/admin/Theme.tsx +465 -0
- package/carbon/src/client/pages/admin/Users.tsx +365 -0
- package/carbon/src/client/pages/api-docs.css +156 -0
- package/carbon/src/client/pages/organizations/Details.tsx +200 -0
- package/carbon/src/client/pages/organizations/Members.tsx +402 -0
- package/carbon/src/client/pages/settings/Billing.tsx +473 -0
- package/carbon/src/client/pages/settings/Profile.tsx +160 -0
- package/carbon/src/client/pages/settings/Security.tsx +341 -0
- package/carbon/src/client/public/favicon.svg +19 -0
- package/carbon/src/client/public/robots.txt +8 -0
- package/carbon/src/server/billing/index.ts +104 -0
- package/carbon/src/server/billing/provider.ts +81 -0
- package/carbon/src/server/billing/providers/paddle.ts +314 -0
- package/carbon/src/server/billing/providers/polar.ts +325 -0
- package/carbon/src/server/billing/providers/stripe.ts +233 -0
- package/carbon/src/server/emails/templates.ts +116 -0
- package/carbon/src/server/index.ts +554 -0
- package/carbon/src/server/lib/auth.ts +6 -0
- package/carbon/src/server/lib/email.ts +64 -0
- package/carbon/src/server/lib/env.ts +112 -0
- package/carbon/src/server/lib/errors.ts +21 -0
- package/carbon/src/server/lib/logger.ts +17 -0
- package/carbon/src/server/lib/rate-limiter.ts +288 -0
- package/carbon/src/server/lib/request.ts +34 -0
- package/carbon/src/server/lib/stripe.ts +42 -0
- package/carbon/src/server/lib/supabase.ts +65 -0
- package/carbon/src/server/middleware/requirePlan.ts +80 -0
- package/carbon/src/server/routes/_internal/services-status.ts +958 -0
- package/carbon/src/server/routes/_internal/verify-role.ts +185 -0
- package/carbon/src/server/routes/health.ts +48 -0
- package/carbon/src/server/routes/v1/admin/contact.ts +128 -0
- package/carbon/src/server/routes/v1/admin/jobs.ts +171 -0
- package/carbon/src/server/routes/v1/admin/newsletter.ts +237 -0
- package/carbon/src/server/routes/v1/auth.ts +390 -0
- package/carbon/src/server/routes/v1/billing.ts +718 -0
- package/carbon/src/server/routes/v1/contact.ts +93 -0
- package/carbon/src/server/routes/v1/index.ts +1333 -0
- package/carbon/src/server/routes/v1/newsletter.ts +181 -0
- package/carbon/src/server/routes/v1/performance.ts +157 -0
- package/carbon/src/server/routes/v1/stats.ts +170 -0
- package/carbon/src/server/routes/v1/theme.ts +106 -0
- package/carbon/src/server/routes/webhooks/billing.ts +376 -0
- package/carbon/src/server/routes/webhooks/stripe.ts +276 -0
- package/carbon/src/server/types.ts +11 -0
- package/carbon/src/shared/pricing.ts +155 -0
- package/carbon/src/shared/types.ts +338 -0
- package/carbon/supabase/migrations/00001_init.sql +717 -0
- package/carbon/supabase/migrations/00002_theme_settings.sql +13 -0
- package/carbon/supabase/migrations/00003_pg_cron.sql +121 -0
- package/carbon/supabase/migrations/00004_contact_newsletter.sql +81 -0
- package/carbon/supabase/migrations/00005_localization_languages.sql +22 -0
- package/carbon/supabase/seed.sql +16 -0
- package/carbon/tests/_helpers/app.ts +45 -0
- package/carbon/tests/_helpers/env.ts +37 -0
- package/carbon/tests/_helpers/factories.ts +69 -0
- package/carbon/tests/_helpers/jwt.ts +23 -0
- package/carbon/tests/_helpers/setup-integration.ts +20 -0
- package/carbon/tests/_helpers/setup-rtl.ts +12 -0
- package/carbon/tests/component/ErrorBoundary.test.tsx +53 -0
- package/carbon/tests/component/use-auth-settings.test.tsx +119 -0
- package/carbon/tests/integration/server/routes/contact.test.ts +162 -0
- package/carbon/tests/integration/server/routes/health.test.ts +61 -0
- package/carbon/tests/structural/i18n-parity.test.ts +42 -0
- package/carbon/tests/unit/client/utils.test.ts +49 -0
- package/carbon/tests/unit/shared/pricing.test.ts +93 -0
- package/carbon/tsconfig.json +27 -0
- package/carbon/tsconfig.server.json +27 -0
- package/carbon/tsconfig.test.json +9 -0
- package/carbon/vite.config.ts +110 -0
- package/carbon/vitest.config.ts +74 -0
- package/carbon/volumes/db/jwt.sql +57 -0
- package/carbon/volumes/db/metabase-init.sh +29 -0
- package/carbon/volumes/db/n8n-init.sh +25 -0
- package/carbon/volumes/db/realtime.sql +33 -0
- package/carbon/volumes/db/roles.sql +93 -0
- package/carbon/volumes/db/set-passwords.sh +12 -0
- package/carbon/volumes/db/super-admin.dev.sql +113 -0
- package/carbon/volumes/db/super-admin.generated.sql +113 -0
- package/carbon/volumes/db/super-admin.sql +114 -0
- package/carbon/volumes/grafana/dashboards/logs.json +179 -0
- package/carbon/volumes/grafana/dashboards/overview.json +523 -0
- package/carbon/volumes/grafana/dashboards/postgresql.json +337 -0
- package/carbon/volumes/grafana/dashboards.dev/logs.json +179 -0
- package/carbon/volumes/grafana/dashboards.dev/overview.json +156 -0
- package/carbon/volumes/grafana/dashboards.dev/postgresql.json +337 -0
- package/carbon/volumes/grafana/provisioning/dashboards/dashboards.dev.yml +16 -0
- package/carbon/volumes/grafana/provisioning/dashboards/dashboards.yml +16 -0
- package/carbon/volumes/grafana/provisioning/datasources/datasources.yml +43 -0
- package/carbon/volumes/kong/docker-entrypoint.sh +9 -0
- package/carbon/volumes/kong/kong.yml +208 -0
- package/carbon/volumes/loki/loki-config.yml +58 -0
- package/carbon/volumes/n8n/hooks.js +131 -0
- package/carbon/volumes/n8n/scripts/setup.sh +66 -0
- package/carbon/volumes/prometheus/prometheus.yml +43 -0
- package/carbon/volumes/promtail/promtail-config.yml +64 -0
- package/carbon/volumes/traefik/middlewares.dev.yml +83 -0
- package/carbon/volumes/traefik/middlewares.yml +95 -0
- package/carbon/volumes/traefik/vite-dev.yml +20 -0
- package/package.json +95 -0
- package/src/access.js +354 -0
- package/src/activate.js +187 -0
- package/src/add.js +718 -0
- package/src/backup.js +786 -0
- package/src/cli.js +350 -0
- package/src/configure.js +967 -0
- package/src/console.js +155 -0
- package/src/create.js +1499 -0
- package/src/deploy.js +311 -0
- package/src/destroy.js +2033 -0
- package/src/diagnose.js +735 -0
- package/src/down.js +80 -0
- package/src/failover.js +1032 -0
- package/src/lib/backup-s3.js +179 -0
- package/src/lib/build.js +33 -0
- package/src/lib/checksum.js +28 -0
- package/src/lib/ci-setup.js +666 -0
- package/src/lib/cli/help.js +129 -0
- package/src/lib/cli/parse-flags.js +160 -0
- package/src/lib/cli/select-action.js +65 -0
- package/src/lib/cli/select-environment.js +108 -0
- package/src/lib/cli/tty-guard.js +75 -0
- package/src/lib/cloudflare.js +447 -0
- package/src/lib/colors.js +52 -0
- package/src/lib/command.js +361 -0
- package/src/lib/config.js +359 -0
- package/src/lib/cost.js +103 -0
- package/src/lib/deploy/bundle.js +231 -0
- package/src/lib/deploy/compose/acme-verify.js +121 -0
- package/src/lib/deploy/compose/build-args.js +78 -0
- package/src/lib/deploy/compose/ha.js +1874 -0
- package/src/lib/deploy/compose/index.js +1294 -0
- package/src/lib/deploy/compose/reconcile.js +74 -0
- package/src/lib/deploy/github.js +382 -0
- package/src/lib/deploy/image.js +191 -0
- package/src/lib/deploy/index.js +119 -0
- package/src/lib/deploy/k8s/LICENSE +99 -0
- package/src/lib/deploy/k8s/gitops-deploy.js +298 -0
- package/src/lib/deploy/k8s/ha/index.js +1000 -0
- package/src/lib/deploy/k8s/index.js +62 -0
- package/src/lib/deploy/k8s/k3s.js +2515 -0
- package/src/lib/deploy/orchestrator.js +1401 -0
- package/src/lib/deploy/prompts.js +545 -0
- package/src/lib/deploy/remote-build.js +130 -0
- package/src/lib/deploy/state.js +120 -0
- package/src/lib/deploy/utils.js +328 -0
- package/src/lib/deploy-logger.js +93 -0
- package/src/lib/dns-propagation.js +48 -0
- package/src/lib/environment.js +58 -0
- package/src/lib/fetch-retry.js +103 -0
- package/src/lib/github-environments.js +335 -0
- package/src/lib/hetzner-dns.js +377 -0
- package/src/lib/hetzner-guided-setup.js +275 -0
- package/src/lib/host-keys.js +37 -0
- package/src/lib/iac/cloud-init.js +52 -0
- package/src/lib/iac/index.js +325 -0
- package/src/lib/iac/programs/hetzner-compose.js +130 -0
- package/src/lib/iac/programs/hetzner-k8s.js +320 -0
- package/src/lib/kubectl.js +81 -0
- package/src/lib/licensing/index.js +259 -0
- package/src/lib/licensing/tiers.js +181 -0
- package/src/lib/licensing/validator.js +171 -0
- package/src/lib/merge-package-json.js +90 -0
- package/src/lib/operator-ip.js +381 -0
- package/src/lib/package-manager.js +111 -0
- package/src/lib/perf.js +71 -0
- package/src/lib/project-guard.js +39 -0
- package/src/lib/project.js +334 -0
- package/src/lib/providers/base.js +276 -0
- package/src/lib/providers/hetzner-s3.js +656 -0
- package/src/lib/providers/hetzner.js +755 -0
- package/src/lib/providers/index.js +164 -0
- package/src/lib/s3.js +510 -0
- package/src/lib/secret-scan.js +583 -0
- package/src/lib/secrets.js +63 -0
- package/src/lib/server-types.js +195 -0
- package/src/lib/shell.js +91 -0
- package/src/lib/ssh.js +241 -0
- package/src/lib/tracker.js +242 -0
- package/src/lib/upgrade-policy.js +170 -0
- package/src/lib/validators.js +105 -0
- package/src/lib/version.js +5 -0
- package/src/remove.js +292 -0
- package/src/reset.js +97 -0
- package/src/restore.js +871 -0
- package/src/scale.js +1734 -0
- package/src/shell.js +222 -0
- package/src/status.js +981 -0
- package/src/up.js +264 -0
- package/src/upgrade.js +721 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment Module Registry
|
|
3
|
+
*
|
|
4
|
+
* Four deployment modes:
|
|
5
|
+
* - compose: Docker Compose on single VPS (Fast + Pro)
|
|
6
|
+
* - compose-ha: Docker Compose HA on 2 VPS with PostgreSQL replication (Fast + Pro)
|
|
7
|
+
* - standard: Kubernetes single-region (Pro only)
|
|
8
|
+
* - ha: Kubernetes multi-region HA (Pro only)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
deployComposeHA,
|
|
13
|
+
destroyComposeHA,
|
|
14
|
+
getComposeHAStatus,
|
|
15
|
+
} from './compose/ha.js';
|
|
16
|
+
export {
|
|
17
|
+
backupCompose,
|
|
18
|
+
deployCompose,
|
|
19
|
+
destroyCompose,
|
|
20
|
+
getComposeStatus,
|
|
21
|
+
redeployCompose,
|
|
22
|
+
restoreCompose,
|
|
23
|
+
setupServer,
|
|
24
|
+
setupServerFiles,
|
|
25
|
+
waitForSSH as waitForComposeSSH,
|
|
26
|
+
} from './compose/index.js';
|
|
27
|
+
export { deployK8sHA, destroyK8sHA, getK8sHAStatus, triggerFailover } from './k8s/ha/index.js';
|
|
28
|
+
export { destroyK8s, getK8sStatus } from './k8s/index.js';
|
|
29
|
+
export { deployK3s } from './k8s/k3s.js';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the appropriate deploy function based on mode
|
|
33
|
+
* @param {string} mode - 'compose', 'compose-ha', 'kubernetes', or 'ha'
|
|
34
|
+
* @returns {Promise<Function>} Deploy function
|
|
35
|
+
*/
|
|
36
|
+
export function getDeployFunction(mode = 'compose') {
|
|
37
|
+
if (mode === 'ha') {
|
|
38
|
+
return import('./k8s/ha/index.js').then((m) => m.deployK8sHA);
|
|
39
|
+
}
|
|
40
|
+
if (mode === 'compose-ha') {
|
|
41
|
+
return import('./compose/ha.js').then((m) => m.deployComposeHA);
|
|
42
|
+
}
|
|
43
|
+
if (mode === 'kubernetes') {
|
|
44
|
+
return import('./k8s/k3s.js').then((m) => m.deployK3s);
|
|
45
|
+
}
|
|
46
|
+
return import('./compose/index.js').then((m) => m.deployCompose);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the appropriate destroy function based on mode
|
|
51
|
+
* @param {string} mode - 'compose', 'compose-ha', 'kubernetes', or 'ha'
|
|
52
|
+
* @returns {Promise<Function>} Destroy function
|
|
53
|
+
*/
|
|
54
|
+
export function getDestroyFunction(mode = 'compose') {
|
|
55
|
+
if (mode === 'ha') {
|
|
56
|
+
return import('./k8s/ha/index.js').then((m) => m.destroyK8sHA);
|
|
57
|
+
}
|
|
58
|
+
if (mode === 'compose-ha') {
|
|
59
|
+
return import('./compose/ha.js').then((m) => m.destroyComposeHA);
|
|
60
|
+
}
|
|
61
|
+
if (mode === 'kubernetes') {
|
|
62
|
+
return import('./k8s/index.js').then((m) => m.destroyK8s);
|
|
63
|
+
}
|
|
64
|
+
return import('./compose/index.js').then((m) => m.destroyCompose);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Deployment mode information
|
|
69
|
+
*/
|
|
70
|
+
export const MODES = {
|
|
71
|
+
compose: {
|
|
72
|
+
name: 'Compose',
|
|
73
|
+
displayName: 'Docker Compose',
|
|
74
|
+
description: 'Single-server deployment with Docker Compose',
|
|
75
|
+
tier: 'diamond',
|
|
76
|
+
features: [
|
|
77
|
+
'Docker Compose on single VPS',
|
|
78
|
+
'Auto HTTPS via Traefik/Caddy',
|
|
79
|
+
'All add-ons supported',
|
|
80
|
+
'Direct image transfer (no registry needed)',
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
'compose-ha': {
|
|
84
|
+
name: 'Compose HA',
|
|
85
|
+
displayName: 'Docker Compose HA',
|
|
86
|
+
description: 'Multi-region Docker Compose with PostgreSQL replication',
|
|
87
|
+
tier: 'diamond',
|
|
88
|
+
features: [
|
|
89
|
+
'Docker Compose on 2 VPS',
|
|
90
|
+
'PostgreSQL streaming replication',
|
|
91
|
+
'Cloudflare health checks + failover',
|
|
92
|
+
'Auto HTTPS via Traefik',
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
standard: {
|
|
96
|
+
name: 'Standard',
|
|
97
|
+
displayName: 'Kubernetes',
|
|
98
|
+
description: 'Single-region Kubernetes cluster',
|
|
99
|
+
tier: 'fullerene',
|
|
100
|
+
features: [
|
|
101
|
+
'Kubernetes cluster (1 master + workers)',
|
|
102
|
+
'Horizontal Pod Autoscaling',
|
|
103
|
+
'Traefik ingress with auto-SSL',
|
|
104
|
+
'Local Docker build & push',
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
ha: {
|
|
108
|
+
name: 'HA',
|
|
109
|
+
displayName: 'Kubernetes HA',
|
|
110
|
+
description: 'Multi-region Kubernetes with high availability',
|
|
111
|
+
tier: 'fullerene',
|
|
112
|
+
features: [
|
|
113
|
+
'Multi-region clusters',
|
|
114
|
+
'PostgreSQL streaming replication',
|
|
115
|
+
'One-command failover',
|
|
116
|
+
'DNS health checks',
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
## Acceptance
|
|
4
|
+
|
|
5
|
+
By using the Software, you agree to all of the terms and conditions below.
|
|
6
|
+
|
|
7
|
+
## Copyright License
|
|
8
|
+
|
|
9
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
10
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
11
|
+
available, and prepare derivative works of the Software, in each case subject
|
|
12
|
+
to the limitations and conditions below.
|
|
13
|
+
|
|
14
|
+
## Limitations
|
|
15
|
+
|
|
16
|
+
You may not provide the Software to third parties as a hosted or managed
|
|
17
|
+
service, where the service provides users with access to any substantial set
|
|
18
|
+
of the features or functionality of the Software.
|
|
19
|
+
|
|
20
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
21
|
+
in the Software, and you may not remove or obscure any functionality in the
|
|
22
|
+
Software that is protected by the license key.
|
|
23
|
+
|
|
24
|
+
You may not alter, remove, or obscure any licensing, copyright, or other
|
|
25
|
+
notices of the licensor in the Software. Any use of the licensor's trademarks
|
|
26
|
+
is subject to applicable law.
|
|
27
|
+
|
|
28
|
+
## Patents
|
|
29
|
+
|
|
30
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
31
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
32
|
+
sale, import and have imported the Software, in each case subject to the
|
|
33
|
+
limitations and conditions in this license. This license does not cover any
|
|
34
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
35
|
+
the Software. If you or your company make any written claim that the Software
|
|
36
|
+
infringes or contributes to infringement of any patent, your patent license
|
|
37
|
+
for the Software granted under these terms ends immediately. If your company
|
|
38
|
+
makes such a claim, your patent license ends immediately for work on behalf of
|
|
39
|
+
your company.
|
|
40
|
+
|
|
41
|
+
## Notices
|
|
42
|
+
|
|
43
|
+
You must ensure that anyone who gets a copy of any part of the Software from
|
|
44
|
+
you also gets a copy of these terms.
|
|
45
|
+
|
|
46
|
+
If you modify the Software, you must include in any modified copies of the
|
|
47
|
+
Software prominent notices stating that you have modified the Software.
|
|
48
|
+
|
|
49
|
+
## No Other Rights
|
|
50
|
+
|
|
51
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
52
|
+
these terms.
|
|
53
|
+
|
|
54
|
+
## Termination
|
|
55
|
+
|
|
56
|
+
If you use the Software in violation of these terms, such use is not licensed,
|
|
57
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
58
|
+
with a notice of your violation, and you cease all violation of this license
|
|
59
|
+
no later than 30 days after you receive that notice, your licenses will be
|
|
60
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
61
|
+
reinstatement, any additional violation of these terms will cause your
|
|
62
|
+
licenses to terminate automatically and permanently.
|
|
63
|
+
|
|
64
|
+
## No Liability
|
|
65
|
+
|
|
66
|
+
As far as the law allows, the Software comes as is, without any warranty or
|
|
67
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
68
|
+
out of these terms or the use or nature of the Software, under any kind of
|
|
69
|
+
legal claim.
|
|
70
|
+
|
|
71
|
+
## Definitions
|
|
72
|
+
|
|
73
|
+
The "licensor" is the entity offering these terms, Vibecarbon.
|
|
74
|
+
|
|
75
|
+
The "Software" is the software the licensor makes available under these terms,
|
|
76
|
+
including any portion of it.
|
|
77
|
+
|
|
78
|
+
"You" refers to the individual or entity agreeing to these terms.
|
|
79
|
+
|
|
80
|
+
"Your company" is any legal entity, sole proprietorship, or other kind of
|
|
81
|
+
organization that you work for, plus all organizations that have control over,
|
|
82
|
+
are under the control of, or are under common control with that organization.
|
|
83
|
+
"Control" means ownership of substantially all the assets of an entity, or the
|
|
84
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
85
|
+
Control can be direct or indirect.
|
|
86
|
+
|
|
87
|
+
"Your licenses" are all the licenses granted to you for the Software under
|
|
88
|
+
these terms.
|
|
89
|
+
|
|
90
|
+
"Use" means anything you do with the Software requiring one of your licenses.
|
|
91
|
+
|
|
92
|
+
"Trademark" means trademarks, service marks, and similar rights.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
Copyright (c) 2026 Vibecarbon
|
|
97
|
+
|
|
98
|
+
For the full Elastic License 2.0 text, see:
|
|
99
|
+
https://www.elastic.co/licensing/elastic-license
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 4.3c of the GitOps refactor: the thin GitOps-driven deploy path.
|
|
3
|
+
*
|
|
4
|
+
* stale-deploy-ignore: historical context — describes what this file replaced.
|
|
5
|
+
* Replaces the ~2000 LOC imperative `applyKubernetesManifests` with:
|
|
6
|
+
* 1. Render deploy-time-varying manifests into the customer's k8s/ tree
|
|
7
|
+
* (image tag in app Deployment, rendered Supabase values.yaml).
|
|
8
|
+
* 2. git add k8s/ && git commit && git push.
|
|
9
|
+
* 3. Seed GitHub Environment secrets + vars + upload KUBECONFIG_B64.
|
|
10
|
+
* 4. Trigger .github/workflows/deploy.yml + wait for completion.
|
|
11
|
+
*
|
|
12
|
+
* The workflow (Phase 4.3b.C) installs Flux + root Kustomization + applies
|
|
13
|
+
* vibecarbon-secrets / hetzner-api-token / kube-system/hcloud Secrets.
|
|
14
|
+
* Flux reconciles the rest from the committed k8s/ tree.
|
|
15
|
+
*
|
|
16
|
+
* Callers: `vibecarbon configure cicd <env>` (PR 7) layers this onto an
|
|
17
|
+
* already-running local-first cluster. Pre-PR-5 it was the default for
|
|
18
|
+
* `vibecarbon deploy --k8s --gitops`; that flag was retired with PR 5.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { execFileSync } from 'node:child_process';
|
|
22
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import * as p from '@clack/prompts';
|
|
25
|
+
import {
|
|
26
|
+
seedEnvironmentSecrets,
|
|
27
|
+
seedOrgSecrets,
|
|
28
|
+
triggerDeployWorkflow,
|
|
29
|
+
uploadKubeconfig,
|
|
30
|
+
waitForLatestWorkflowRun,
|
|
31
|
+
} from '../../github-environments.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Render `{{PLACEHOLDER}}` tokens in a text file in-place. Used to bake
|
|
35
|
+
* the deploy-time image tag + domain into manifests before committing.
|
|
36
|
+
*/
|
|
37
|
+
function renderInPlace(path, vars) {
|
|
38
|
+
if (!existsSync(path)) return;
|
|
39
|
+
let content = readFileSync(path, 'utf-8');
|
|
40
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
41
|
+
content = content.replaceAll(`{{${key}}}`, String(value ?? ''));
|
|
42
|
+
}
|
|
43
|
+
writeFileSync(path, content);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the real `{owner, name}` of the deploy target repo.
|
|
48
|
+
*
|
|
49
|
+
* At `vibecarbon create` time both placeholders bake to `projectName`
|
|
50
|
+
* (see src/create.js:616), producing `ghcr.io/<project>/<project>` image
|
|
51
|
+
* refs and `github.com/<project>/<project>` Flux URLs. Those paths only
|
|
52
|
+
* match reality when the user later runs `vibecarbon configure` → CI/CD
|
|
53
|
+
* with project name == repo name (which calls updateImageReferences()).
|
|
54
|
+
* E2E tests (and any user whose repo slug differs) need the real
|
|
55
|
+
* owner/repo wired in at deploy time, which is what this helper handles.
|
|
56
|
+
*/
|
|
57
|
+
function resolveOwnerAndRepo(projectDir) {
|
|
58
|
+
try {
|
|
59
|
+
const out = execFileSync(
|
|
60
|
+
'gh',
|
|
61
|
+
['repo', 'view', '--json', 'nameWithOwner', '-q', '.nameWithOwner'],
|
|
62
|
+
{ cwd: projectDir, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] },
|
|
63
|
+
).trim();
|
|
64
|
+
const [owner, name] = out.split('/');
|
|
65
|
+
if (owner && name) return { owner, name };
|
|
66
|
+
} catch {}
|
|
67
|
+
try {
|
|
68
|
+
const url = execFileSync('git', ['remote', 'get-url', 'origin'], {
|
|
69
|
+
cwd: projectDir,
|
|
70
|
+
encoding: 'utf-8',
|
|
71
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
72
|
+
}).trim();
|
|
73
|
+
const m = url.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
74
|
+
if (m) return { owner: m[1], name: m[2] };
|
|
75
|
+
} catch {}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function escapeForRegex(s) {
|
|
80
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Rewrite stale `<project>/<project>` owner+repo pairs in ghcr.io image
|
|
85
|
+
* refs and github.com Flux URLs to the real `<owner>/<repoName>` pair.
|
|
86
|
+
* Idempotent: after one pass the paths no longer match the stale pattern
|
|
87
|
+
* so subsequent calls are no-ops.
|
|
88
|
+
*/
|
|
89
|
+
function rewriteOwnerAndRepo(projectDir, projectName, owner, repoName) {
|
|
90
|
+
const pn = escapeForRegex(projectName);
|
|
91
|
+
// ghcr.io/<stale>/<project>[-db|-backup] → ghcr.io/<owner>/<repoName>[-db|-backup]
|
|
92
|
+
const ghcrRe = new RegExp(`ghcr\\.io/[^/\\s:]+/${pn}(-db|-backup)?\\b`, 'g');
|
|
93
|
+
// github.com/<stale>/<project> → github.com/<owner>/<repoName>
|
|
94
|
+
// Match plain `github.com/a/b` plus optional `.git` suffix. Avoid
|
|
95
|
+
// devouring a trailing path segment (e.g. branch names) by anchoring
|
|
96
|
+
// on word-boundary / end.
|
|
97
|
+
const ghRe = new RegExp(`github\\.com/[^/\\s:]+/${pn}(?=\\.git\\b|[^\\w-]|$)`, 'g');
|
|
98
|
+
|
|
99
|
+
const files = [
|
|
100
|
+
'k8s/base/app/deployment.yaml',
|
|
101
|
+
'k8s/base/backup/cronjob.yaml',
|
|
102
|
+
'k8s/values/supabase.values.yaml',
|
|
103
|
+
'k8s/overlays/production/kustomization.yaml',
|
|
104
|
+
'k8s/flux/clusters/primary/vibecarbon.yaml',
|
|
105
|
+
'k8s/flux/clusters/standby/vibecarbon.yaml',
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
for (const rel of files) {
|
|
109
|
+
const path = join(projectDir, rel);
|
|
110
|
+
if (!existsSync(path)) continue;
|
|
111
|
+
const before = readFileSync(path, 'utf-8');
|
|
112
|
+
const after = before
|
|
113
|
+
.replace(ghcrRe, (_match, suffix) => `ghcr.io/${owner}/${repoName}${suffix ?? ''}`)
|
|
114
|
+
.replace(ghRe, `github.com/${owner}/${repoName}`);
|
|
115
|
+
if (after !== before) writeFileSync(path, after);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Commit the k8s/ tree + push to origin/main. Returns true if a commit was
|
|
121
|
+
* actually made, false if the tree was already clean.
|
|
122
|
+
*/
|
|
123
|
+
function commitAndPushManifests(cwd, message) {
|
|
124
|
+
// Stage only k8s/ — don't accidentally commit unrelated dirty files.
|
|
125
|
+
execFileSync('git', ['add', 'k8s/'], { cwd });
|
|
126
|
+
|
|
127
|
+
// `git diff --cached --quiet` exits 0 if nothing staged, 1 if changes.
|
|
128
|
+
const hasChanges = (() => {
|
|
129
|
+
try {
|
|
130
|
+
execFileSync('git', ['diff', '--cached', '--quiet'], { cwd });
|
|
131
|
+
return false;
|
|
132
|
+
} catch {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
|
|
137
|
+
if (hasChanges) {
|
|
138
|
+
execFileSync('git', ['commit', '-m', message], { cwd });
|
|
139
|
+
}
|
|
140
|
+
// Push unconditionally — the remote may have commits we need to fast-forward
|
|
141
|
+
// (e.g., previous deploy from a different workstation). If the commit above
|
|
142
|
+
// was a no-op, this is a cheap no-op too.
|
|
143
|
+
execFileSync('git', ['push', 'origin', 'HEAD:main'], { cwd });
|
|
144
|
+
return hasChanges;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Full GitOps deploy: render manifests, commit + push, seed GitHub
|
|
149
|
+
* Environment, trigger workflow, wait for Flux reconciliation.
|
|
150
|
+
*
|
|
151
|
+
* @param {object} args
|
|
152
|
+
* @param {string} args.projectDir - customer repo root
|
|
153
|
+
* @param {string} args.environment - "dev" | "staging" | "prod"
|
|
154
|
+
* @param {string} args.domain - deployed domain
|
|
155
|
+
* @param {string} args.projectName
|
|
156
|
+
* @param {string} args.kubeconfigPath - path to kubeconfig fetched from the cluster
|
|
157
|
+
* @param {string} args.networkId - Hetzner private network ID (Pulumi output)
|
|
158
|
+
* @param {string} args.dnsProvider - "cloudflare" | "hetzner" | "manual"
|
|
159
|
+
* @param {object} args.creds - ~/.vibecarbon/credentials.json contents
|
|
160
|
+
* @param {string} [args.imageTag] - specific image tag to bake into app Deployment (default "main")
|
|
161
|
+
* @param {number} [args.workflowTimeoutSec] - default 60 min. deploy.yml's
|
|
162
|
+
* internal Flux waits cap at 10m (vibecarbon-base) + 20m (vibecarbon-supabase)
|
|
163
|
+
* = 30m, on top of ~5m Flux install + ~5m CRD apply. A 30m outer budget
|
|
164
|
+
* ties with the internal ceiling — every timeout was racing the workflow
|
|
165
|
+
* to its own error. 3600s gives the workflow room to fail naturally and
|
|
166
|
+
* surface its own log.
|
|
167
|
+
*/
|
|
168
|
+
export async function deployK8sGitOps(args) {
|
|
169
|
+
const {
|
|
170
|
+
projectDir,
|
|
171
|
+
environment,
|
|
172
|
+
domain,
|
|
173
|
+
projectName,
|
|
174
|
+
kubeconfigPath,
|
|
175
|
+
networkId,
|
|
176
|
+
dnsProvider,
|
|
177
|
+
creds,
|
|
178
|
+
imageTag,
|
|
179
|
+
workflowTimeoutSec = 3600,
|
|
180
|
+
skipCi = false,
|
|
181
|
+
} = args;
|
|
182
|
+
|
|
183
|
+
const s = p.spinner();
|
|
184
|
+
const skipCiStr = skipCi ? ' [skip ci]' : '';
|
|
185
|
+
|
|
186
|
+
// 1. Render image tag + values.yaml into the repo. The Supabase values.yaml
|
|
187
|
+
// (Phase 4.3a) already renders here; repeat is idempotent. The app
|
|
188
|
+
// Deployment manifest uses {{GITHUB_OWNER}}/{{PROJECT_NAME}} from create
|
|
189
|
+
// time — we add {{IMAGE_TAG}} rendering so Flux pulls the exact tag the
|
|
190
|
+
// CI build just published.
|
|
191
|
+
s.start('Rendering manifests for GitOps deploy');
|
|
192
|
+
// Flux GitRepository URL + every ghcr.io image ref bakes in owner/repo at
|
|
193
|
+
// create time as <project>/<project>. Rewrite to the real pair before we
|
|
194
|
+
// commit, otherwise Flux source-controller 403s cloning the nonexistent
|
|
195
|
+
// github.com/<project>/<project> and Kustomizations never reconcile.
|
|
196
|
+
const resolvedRepo = resolveOwnerAndRepo(projectDir);
|
|
197
|
+
const repoOwner = args.githubOwner || resolvedRepo?.owner;
|
|
198
|
+
const repoName = resolvedRepo?.name || projectName;
|
|
199
|
+
if (!repoOwner) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
`GitOps deploy: could not resolve GitHub owner for ${projectDir}. ` +
|
|
202
|
+
`Run 'gh repo view' or 'git remote get-url origin' and ensure origin points at github.com.`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
rewriteOwnerAndRepo(projectDir, projectName, repoOwner, repoName);
|
|
206
|
+
const appDeployment = join(projectDir, 'k8s', 'base', 'app', 'deployment.yaml');
|
|
207
|
+
if (existsSync(appDeployment) && imageTag) {
|
|
208
|
+
// Only substitute — don't touch tags that are already concrete. The
|
|
209
|
+
// default template uses `:main`; callers passing a pinned imageTag can
|
|
210
|
+
// rewrite that via renderInPlace if the template exposes {{IMAGE_TAG}}
|
|
211
|
+
// (follow-up: switch template to use {{IMAGE_TAG}} so SHAs can pin).
|
|
212
|
+
renderInPlace(appDeployment, { IMAGE_TAG: imageTag });
|
|
213
|
+
}
|
|
214
|
+
const supabaseValues = join(projectDir, 'k8s', 'gitops', 'supabase', 'values.yaml');
|
|
215
|
+
if (existsSync(supabaseValues)) {
|
|
216
|
+
// values.yaml is already rendered by Phase 4.3a's ensureVibecarbonSecrets
|
|
217
|
+
// call chain, but re-render here with {{DOMAIN}}/{{PROJECT_NAME}} in
|
|
218
|
+
// case the caller landed us without that step (e.g., `vibecarbon
|
|
219
|
+
// configure cicd <env>` against a cluster whose initial deploy
|
|
220
|
+
// didn't run the imperative bundle path).
|
|
221
|
+
renderInPlace(supabaseValues, {
|
|
222
|
+
DOMAIN: domain,
|
|
223
|
+
PROJECT_NAME: projectName,
|
|
224
|
+
S3_BACKUP_BUCKET: args.s3BackupBucket || `${projectName}-backups`,
|
|
225
|
+
GITHUB_OWNER: repoOwner,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
s.stop('Manifests rendered');
|
|
229
|
+
|
|
230
|
+
// 2. git add/commit/push — this is the deploy.
|
|
231
|
+
s.start('Committing + pushing k8s/ tree to customer repo');
|
|
232
|
+
const commitMsg = `deploy(${environment}): ${imageTag || 'latest'} @ ${new Date().toISOString()}${skipCiStr}`;
|
|
233
|
+
const pushed = commitAndPushManifests(projectDir, commitMsg);
|
|
234
|
+
s.stop(pushed ? 'Pushed new deploy commit' : 'Tree already clean, no new commit');
|
|
235
|
+
|
|
236
|
+
// 3. Seed GitHub Environment secrets + upload kubeconfig. Repo-level
|
|
237
|
+
// secrets (Hetzner token, Cloudflare token, S3 creds) are idempotent; env
|
|
238
|
+
// secrets + KUBECONFIG_B64 get written fresh every deploy (rotation path).
|
|
239
|
+
s.start(`Seeding GitHub Environment '${environment}'`);
|
|
240
|
+
await seedOrgSecrets(creds);
|
|
241
|
+
|
|
242
|
+
const envLocal = parseEnvLocal(projectDir);
|
|
243
|
+
const perEnvSecrets = {
|
|
244
|
+
DB_PASSWORD: envLocal.DB_PASSWORD,
|
|
245
|
+
JWT_SECRET: envLocal.JWT_SECRET,
|
|
246
|
+
SUPABASE_ANON_KEY: envLocal.SUPABASE_ANON_KEY || envLocal.ANON_KEY,
|
|
247
|
+
SUPABASE_SERVICE_ROLE_KEY: envLocal.SUPABASE_SERVICE_ROLE_KEY || envLocal.SERVICE_ROLE_KEY,
|
|
248
|
+
REALTIME_SECRET: envLocal.REALTIME_SECRET,
|
|
249
|
+
DB_ENC_KEY: envLocal.DB_ENC_KEY,
|
|
250
|
+
VAULT_ENC_KEY: envLocal.VAULT_ENC_KEY,
|
|
251
|
+
PG_META_CRYPTO_KEY: envLocal.PG_META_CRYPTO_KEY,
|
|
252
|
+
LOGFLARE_API_KEY: envLocal.LOGFLARE_API_KEY,
|
|
253
|
+
ADMIN_EMAIL: envLocal.ADMIN_EMAIL,
|
|
254
|
+
ADMIN_PASSWORD: envLocal.ADMIN_PASSWORD,
|
|
255
|
+
SMTP_PASSWORD: envLocal.SMTP_PASS,
|
|
256
|
+
};
|
|
257
|
+
const perEnvVars = {
|
|
258
|
+
SITE_URL: domain ? `https://${domain}` : '',
|
|
259
|
+
DNS_PROVIDER: dnsProvider || '',
|
|
260
|
+
HCLOUD_NETWORK_ID: networkId || '',
|
|
261
|
+
};
|
|
262
|
+
await seedEnvironmentSecrets(environment, perEnvSecrets, perEnvVars);
|
|
263
|
+
await uploadKubeconfig(environment, kubeconfigPath);
|
|
264
|
+
s.stop(`GitHub Environment '${environment}' seeded`);
|
|
265
|
+
|
|
266
|
+
// 4. Trigger the deploy workflow on the just-pushed commit + wait for
|
|
267
|
+
// completion. The workflow_dispatch trigger takes environment as an
|
|
268
|
+
// input; the concurrency group ensures only one run per env at a time.
|
|
269
|
+
s.start(`Triggering deploy.yml workflow for '${environment}'`);
|
|
270
|
+
await triggerDeployWorkflow(environment);
|
|
271
|
+
s.stop('Workflow triggered');
|
|
272
|
+
|
|
273
|
+
s.start('Waiting for Flux reconciliation (via GitHub Actions)');
|
|
274
|
+
const result = await waitForLatestWorkflowRun(workflowTimeoutSec);
|
|
275
|
+
s.stop(`Workflow run ${result.runId} succeeded`);
|
|
276
|
+
|
|
277
|
+
return { runId: result.runId, pushed };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Minimal .env.local parser. Handles double-quoted, single-quoted, and
|
|
282
|
+
* bare values; ignores comments and blank lines. Mirrors the readDotenv
|
|
283
|
+
* helper in src/lib/deploy/k8s/index.js — kept as a small duplicate here
|
|
284
|
+
* to avoid a cross-module import dependency that forces bringing the
|
|
285
|
+
* full k8s deploy module into GitOps flow.
|
|
286
|
+
*/
|
|
287
|
+
function parseEnvLocal(projectDir) {
|
|
288
|
+
const path = join(projectDir, '.env.local');
|
|
289
|
+
if (!existsSync(path)) return {};
|
|
290
|
+
const out = {};
|
|
291
|
+
for (const line of readFileSync(path, 'utf-8').split(/\r?\n/)) {
|
|
292
|
+
const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|(.*))\s*$/);
|
|
293
|
+
if (!m) continue;
|
|
294
|
+
const [, key, dq, sq, raw] = m;
|
|
295
|
+
out[key] = dq ?? sq ?? raw ?? '';
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|