@tdk-landscape/tdk-cli-core 1.3.45 → 1.3.49
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/.github/workflows/release-binaries.yml +54 -0
- package/.pre-commit-config.yaml +57 -0
- package/Makefile +92 -0
- package/bun.lock +538 -0
- package/cli/AGENTS.md +390 -0
- package/cli/DESIGN.md +735 -0
- package/cli/biome.json +44 -0
- package/cli/dependency-graph.svg +1135 -0
- package/cli/knip.json +6 -0
- package/cli/package.json +77 -0
- package/cli/pnpm-lock.yaml +2305 -0
- package/cli/pnpm-workspace.yaml +2 -0
- package/cli/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +23 -0
- package/cli/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +464 -0
- package/cli/shared-platform-engineering/docker-templates/install-deps.sh +152 -0
- package/cli/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +12 -0
- package/cli/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +56 -0
- package/{dist/cli.js → cli/src/cli.ts} +21 -13
- package/cli/src/commands/__tests__/always-enabled-infra.test.ts +115 -0
- package/cli/src/commands/__tests__/config.test.ts +146 -0
- package/cli/src/commands/__tests__/doctor.test.ts +557 -0
- package/cli/src/commands/__tests__/error-handling.test.ts +78 -0
- package/cli/src/commands/__tests__/phases-model.test.ts +163 -0
- package/cli/src/commands/__tests__/project-resource-features-e2e.test.ts +207 -0
- package/cli/src/commands/__tests__/project.test.ts +68 -0
- package/cli/src/commands/__tests__/resource.test.ts +226 -0
- package/cli/src/commands/__tests__/saas-starter-integration.test.ts +196 -0
- package/cli/src/commands/__tests__/stack-features-e2e.test.ts +129 -0
- package/cli/src/commands/__tests__/upgrade.test.ts +101 -0
- package/{dist/commands/completion.js → cli/src/commands/completion.ts} +78 -72
- package/cli/src/commands/config.ts +299 -0
- package/cli/src/commands/doctor.ts +790 -0
- package/cli/src/commands/down.ts +37 -0
- package/cli/src/commands/help.ts +150 -0
- package/cli/src/commands/networks-design.md +80 -0
- package/cli/src/commands/networks.ts +332 -0
- package/cli/src/commands/project.ts +439 -0
- package/cli/src/commands/projects.ts +82 -0
- package/cli/src/commands/resource.ts +652 -0
- package/cli/src/commands/resources.ts +95 -0
- package/cli/src/commands/stack.ts +128 -0
- package/cli/src/commands/stacks.ts +52 -0
- package/cli/src/commands/status.ts +88 -0
- package/cli/src/commands/ui.tsx +843 -0
- package/cli/src/commands/up.ts +150 -0
- package/cli/src/commands/upgrade.ts +570 -0
- package/{dist/commands/version.js → cli/src/commands/version.ts} +5 -5
- package/cli/src/components/Accessible.tsx +21 -0
- package/cli/src/components/BaseTooltip.tsx +66 -0
- package/cli/src/components/DetailPanel.tsx +146 -0
- package/cli/src/components/FileTree.tsx +89 -0
- package/cli/src/components/ResourceSelectInput.tsx +30 -0
- package/cli/src/components/ResourceTable.tsx +78 -0
- package/cli/src/components/TabBar.tsx +53 -0
- package/cli/src/components/Tooltip.tsx +11 -0
- package/{dist/components/index.js → cli/src/components/index.ts} +0 -1
- package/cli/src/config/platform-standards.test.ts +11 -0
- package/cli/src/config/platform-standards.ts +196 -0
- package/cli/src/generator/__tests__/extension-fetch.test.ts +220 -0
- package/cli/src/generator/__tests__/template-engine.test.ts +70 -0
- package/cli/src/generator/extension-fetch.ts +279 -0
- package/cli/src/generator/template-engine.ts +754 -0
- package/cli/src/index.ts +86 -0
- package/cli/src/templates.d.ts +4 -0
- package/cli/src/types/index.ts +351 -0
- package/cli/src/utils/__tests__/cache.test.ts +98 -0
- package/cli/src/utils/__tests__/formatting.test.ts +170 -0
- package/cli/src/utils/__tests__/paths.test.ts +180 -0
- package/cli/src/utils/__tests__/port-assignment.test.ts +121 -0
- package/cli/src/utils/__tests__/service-urls.test.ts +174 -0
- package/cli/src/utils/__tests__/services.test.ts +531 -0
- package/cli/src/utils/__tests__/tilt.test.ts +143 -0
- package/cli/src/utils/__tests__/validation.test.ts +148 -0
- package/cli/src/utils/cache.ts +76 -0
- package/cli/src/utils/command-helpers.ts +54 -0
- package/cli/src/utils/constants.ts +126 -0
- package/cli/src/utils/discovery-context.ts +49 -0
- package/cli/src/utils/docker.ts +20 -0
- package/cli/src/utils/doctor-runtime.ts +604 -0
- package/cli/src/utils/env-validator.ts +139 -0
- package/cli/src/utils/errors.ts +168 -0
- package/cli/src/utils/file-helpers.ts +62 -0
- package/cli/src/utils/formatting.ts +215 -0
- package/cli/src/utils/paths.ts +53 -0
- package/cli/src/utils/port-assignment.ts +106 -0
- package/cli/src/utils/project-features.ts +118 -0
- package/cli/src/utils/project-templates.ts +28 -0
- package/cli/src/utils/prompt.ts +123 -0
- package/cli/src/utils/resource-features.ts +209 -0
- package/cli/src/utils/service-urls.ts +124 -0
- package/cli/src/utils/services.ts +363 -0
- package/cli/src/utils/stack-features.ts +30 -0
- package/cli/src/utils/tar.ts +24 -0
- package/cli/src/utils/tilt.ts +113 -0
- package/cli/src/utils/validation.ts +67 -0
- package/{templates → cli/templates}/Tiltfile.hbs +1 -1
- package/cli/tsconfig.json +25 -0
- package/cli/tsconfig.typecheck.json +8 -0
- package/docs/FEATURES.md +279 -0
- package/engine/topologies/platform/docker/dockerfile/dockerfile.star +3 -3
- package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +1 -1
- package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +0 -3
- package/engine/topologies/platform/docker/layers/l3_builder_layers.star +1 -1
- package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +1 -1
- package/engine/topologies/platform/docker/secrets/infisical.star +19 -47
- package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +1 -1
- package/install.sh +242 -0
- package/knip.json +10 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/.openspec.yaml +2 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/design.md +102 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/proposal.md +31 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/specs/vscode-tdk-notifications/spec.md +48 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/specs/vscode-tdk-orchestration/spec.md +63 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/specs/vscode-tdk-troubleshooting/spec.md +56 -0
- package/openspec/changes/add-vscode-tdk-troubleshooter-plugin/tasks.md +61 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/design.md +114 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/proposal.md +32 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/specs/manifest-field-migration/spec.md +20 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/specs/resource-terminology-standard/spec.md +20 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/specs/stack-terminology-standard/spec.md +20 -0
- package/openspec/changes/archive/2026-04-28-rename-domain-to-stack-service-to-resource/tasks.md +194 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/design.md +111 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/proposal.md +33 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/specs/function-naming-alignment/spec.md +12 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/specs/optional-parameter-patterns/spec.md +18 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/specs/parameter-documentation/spec.md +16 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/specs/parameter-naming-consistency/spec.md +12 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/specs/parameter-ordering-standard/spec.md +12 -0
- package/openspec/changes/archive/2026-04-28-star-files-parameter-fixes/tasks.md +194 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/codebase-audit-report.md +62 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/design.md +84 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/proposal.md +31 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/specs/codebase-audit/spec.md +27 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/specs/dead-code-cleanup/spec.md +27 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/specs/test-gap-fill/spec.md +23 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/specs/todo-resolution/spec.md +27 -0
- package/openspec/changes/archive/2026-04-29-scan-repo-gaps-fix/tasks.md +39 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/.openspec.yaml +5 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/design.md +94 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/proposal.md +46 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/ai-slop-cleanup/CLEANUP_REPORT_8.md +174 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/ai-slop-cleanup/CRITICAL_ASSESSMENT_8.md +160 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/circular-deps/CRITICAL_ASSESSMENT_4.md +381 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/dead-code/CRITICAL_ASSESSMENT_3.md +316 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/deduplication/CRITICAL_ASSESSMENT_1.md +290 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/deduplication/IMPLEMENTATION_SUMMARY_1.md +233 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/defensive-cleanup/CRITICAL_ASSESSMENT_6.md +835 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/legacy-cleanup/CRITICAL_ASSESSMENT_7.md +254 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/legacy-cleanup/IMPLEMENTATION_SUMMARY_7.md +187 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/strong-typing/CRITICAL_ASSESSMENT_5.md +269 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/type-consolidation/CRITICAL_ASSESSMENT_2.md +312 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/specs/type-consolidation/IMPLEMENTATION_SUMMARY.md +170 -0
- package/openspec/changes/archive/2026-05-04-comprehensive-cleanup-final/tasks.md +137 -0
- package/openspec/changes/archive/2026-06-25-landscape-consolidation/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-06-25-landscape-consolidation/design.md +80 -0
- package/openspec/changes/archive/2026-06-25-landscape-consolidation/proposal.md +40 -0
- package/openspec/changes/archive/2026-06-25-landscape-consolidation/spec.md +52 -0
- package/openspec/changes/archive/2026-06-25-landscape-consolidation/tasks.md +51 -0
- package/openspec/changes/archive/2026-09-17-fix-generated-stack-boot/.openspec.yaml +2 -0
- package/openspec/changes/archive/2026-09-17-fix-generated-stack-boot/design.md +43 -0
- package/openspec/changes/archive/2026-09-17-fix-generated-stack-boot/proposal.md +29 -0
- package/openspec/changes/archive/2026-09-17-fix-generated-stack-boot/specs/self-contained-generated-projects/spec.md +67 -0
- package/openspec/changes/archive/2026-09-17-fix-generated-stack-boot/tasks.md +27 -0
- package/openspec/specs/manifest-field-migration/spec.md +24 -0
- package/openspec/specs/resource-terminology-standard/spec.md +24 -0
- package/openspec/specs/self-contained-generated-projects/spec.md +67 -0
- package/openspec/specs/stack-terminology-standard/spec.md +24 -0
- package/package.json +27 -64
- package/platform/services/platform/proxy/service.yaml +14 -0
- package/scripts/audit-codebase.sh +213 -0
- package/scripts/install-git-hooks.sh +14 -0
- package/scripts/release-binaries.sh +94 -0
- package/scripts/setup-pre-commit.sh +33 -0
- package/scripts/stage-npm-engine.sh +36 -0
- package/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +23 -0
- package/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +464 -0
- package/shared-platform-engineering/docker-templates/install-deps.sh +152 -0
- package/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +12 -0
- package/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +56 -0
- package/tests/tilt-engine/__init__.py +5 -0
- package/tests/tilt-engine/conftest.py +182 -0
- package/tests/tilt-engine/fixtures/appointment-frontend-service.json +11 -0
- package/tests/tilt-engine/fixtures/identity-backend-service.json +12 -0
- package/tests/tilt-engine/fixtures/invalid-service.json +4 -0
- package/tests/tilt-engine/test_agents_md_generator.py +341 -0
- package/tests/tilt-engine/test_agents_md_integration.py +378 -0
- package/tests/tilt-engine/test_cache_operations.py +181 -0
- package/tests/tilt-engine/test_cache_persistence.py +142 -0
- package/tests/tilt-engine/test_code_executor.py +152 -0
- package/tests/tilt-engine/test_code_viewer.py +127 -0
- package/tests/tilt-engine/test_compose_port_anchors.py +310 -0
- package/tests/tilt-engine/test_config_inspector.py +162 -0
- package/tests/tilt-engine/test_daemon_focus_mode.py +89 -0
- package/tests/tilt-engine/test_daemon_polling.py +122 -0
- package/tests/tilt-engine/test_daemon_registration.py +115 -0
- package/tests/tilt-engine/test_daemon_validation.py +107 -0
- package/tests/tilt-engine/test_docker_generator_bugs.py +493 -0
- package/tests/tilt-engine/test_docker_prune.py +119 -0
- package/tests/tilt-engine/test_dockerignore_path_bug.py +82 -0
- package/tests/tilt-engine/test_file_browser.py +193 -0
- package/tests/tilt-engine/test_frontend_basepath_manifest.py +27 -0
- package/tests/tilt-engine/test_health_dependencies.py +130 -0
- package/tests/tilt-engine/test_health_endpoints.py +118 -0
- package/tests/tilt-engine/test_health_tilt_ui.py +85 -0
- package/tests/tilt-engine/test_safety_aliases.py +84 -0
- package/tests/tilt-engine/test_snapshot_diff.py +136 -0
- package/tests/tilt-engine/test_snapshot_persistence.py +163 -0
- package/tests/tilt-engine/test_snapshot_scanning.py +123 -0
- package/tests/tilt-engine/test_standalone_project_boot.py +61 -0
- package/tests/tilt-engine/test_standalone_traefik.py +108 -0
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/completion.d.ts +0 -3
- package/dist/commands/completion.d.ts.map +0 -1
- package/dist/commands/completion.js.map +0 -1
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -231
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -7
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -597
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/down.d.ts +0 -3
- package/dist/commands/down.d.ts.map +0 -1
- package/dist/commands/down.js +0 -32
- package/dist/commands/down.js.map +0 -1
- package/dist/commands/help.d.ts +0 -2
- package/dist/commands/help.d.ts.map +0 -1
- package/dist/commands/help.js +0 -130
- package/dist/commands/help.js.map +0 -1
- package/dist/commands/networks.d.ts +0 -3
- package/dist/commands/networks.d.ts.map +0 -1
- package/dist/commands/networks.js +0 -260
- package/dist/commands/networks.js.map +0 -1
- package/dist/commands/project.d.ts +0 -3
- package/dist/commands/project.d.ts.map +0 -1
- package/dist/commands/project.js +0 -373
- package/dist/commands/project.js.map +0 -1
- package/dist/commands/projects.d.ts +0 -3
- package/dist/commands/projects.d.ts.map +0 -1
- package/dist/commands/projects.js +0 -71
- package/dist/commands/projects.js.map +0 -1
- package/dist/commands/resource.d.ts +0 -69
- package/dist/commands/resource.d.ts.map +0 -1
- package/dist/commands/resource.js +0 -579
- package/dist/commands/resource.js.map +0 -1
- package/dist/commands/resources.d.ts +0 -3
- package/dist/commands/resources.d.ts.map +0 -1
- package/dist/commands/resources.js +0 -73
- package/dist/commands/resources.js.map +0 -1
- package/dist/commands/stack.d.ts +0 -3
- package/dist/commands/stack.d.ts.map +0 -1
- package/dist/commands/stack.js +0 -97
- package/dist/commands/stack.js.map +0 -1
- package/dist/commands/stacks.d.ts +0 -3
- package/dist/commands/stacks.d.ts.map +0 -1
- package/dist/commands/stacks.js +0 -43
- package/dist/commands/stacks.js.map +0 -1
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -71
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/ui.d.ts +0 -3
- package/dist/commands/ui.d.ts.map +0 -1
- package/dist/commands/ui.js +0 -445
- package/dist/commands/ui.js.map +0 -1
- package/dist/commands/up.d.ts +0 -3
- package/dist/commands/up.d.ts.map +0 -1
- package/dist/commands/up.js +0 -110
- package/dist/commands/up.js.map +0 -1
- package/dist/commands/upgrade.d.ts +0 -11
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -496
- package/dist/commands/upgrade.js.map +0 -1
- package/dist/commands/version.d.ts +0 -3
- package/dist/commands/version.d.ts.map +0 -1
- package/dist/commands/version.js.map +0 -1
- package/dist/components/Accessible.d.ts +0 -8
- package/dist/components/Accessible.d.ts.map +0 -1
- package/dist/components/Accessible.js +0 -10
- package/dist/components/Accessible.js.map +0 -1
- package/dist/components/BaseTooltip.d.ts +0 -4
- package/dist/components/BaseTooltip.d.ts.map +0 -1
- package/dist/components/BaseTooltip.js +0 -28
- package/dist/components/BaseTooltip.js.map +0 -1
- package/dist/components/DetailPanel.d.ts +0 -4
- package/dist/components/DetailPanel.d.ts.map +0 -1
- package/dist/components/DetailPanel.js +0 -18
- package/dist/components/DetailPanel.js.map +0 -1
- package/dist/components/FileTree.d.ts +0 -4
- package/dist/components/FileTree.d.ts.map +0 -1
- package/dist/components/FileTree.js +0 -47
- package/dist/components/FileTree.js.map +0 -1
- package/dist/components/ResourceSelectInput.d.ts +0 -4
- package/dist/components/ResourceSelectInput.d.ts.map +0 -1
- package/dist/components/ResourceSelectInput.js +0 -7
- package/dist/components/ResourceSelectInput.js.map +0 -1
- package/dist/components/ResourceTable.d.ts +0 -4
- package/dist/components/ResourceTable.d.ts.map +0 -1
- package/dist/components/ResourceTable.js +0 -18
- package/dist/components/ResourceTable.js.map +0 -1
- package/dist/components/TabBar.d.ts +0 -4
- package/dist/components/TabBar.d.ts.map +0 -1
- package/dist/components/TabBar.js +0 -17
- package/dist/components/TabBar.js.map +0 -1
- package/dist/components/Tooltip.d.ts +0 -12
- package/dist/components/Tooltip.d.ts.map +0 -1
- package/dist/components/Tooltip.js +0 -12
- package/dist/components/Tooltip.js.map +0 -1
- package/dist/components/index.d.ts +0 -8
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/config/platform-standards.d.ts +0 -159
- package/dist/config/platform-standards.d.ts.map +0 -1
- package/dist/config/platform-standards.js +0 -181
- package/dist/config/platform-standards.js.map +0 -1
- package/dist/generator/extension-fetch.d.ts +0 -25
- package/dist/generator/extension-fetch.d.ts.map +0 -1
- package/dist/generator/extension-fetch.js +0 -252
- package/dist/generator/extension-fetch.js.map +0 -1
- package/dist/generator/template-engine.d.ts +0 -61
- package/dist/generator/template-engine.d.ts.map +0 -1
- package/dist/generator/template-engine.js +0 -557
- package/dist/generator/template-engine.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -255
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -17
- package/dist/types/index.js.map +0 -1
- package/dist/utils/cache.d.ts +0 -19
- package/dist/utils/cache.d.ts.map +0 -1
- package/dist/utils/cache.js +0 -64
- package/dist/utils/cache.js.map +0 -1
- package/dist/utils/command-helpers.d.ts +0 -17
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/command-helpers.js +0 -41
- package/dist/utils/command-helpers.js.map +0 -1
- package/dist/utils/constants.d.ts +0 -52
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js +0 -112
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/discovery-context.d.ts +0 -4
- package/dist/utils/discovery-context.d.ts.map +0 -1
- package/dist/utils/discovery-context.js +0 -39
- package/dist/utils/discovery-context.js.map +0 -1
- package/dist/utils/docker.d.ts +0 -4
- package/dist/utils/docker.d.ts.map +0 -1
- package/dist/utils/docker.js +0 -19
- package/dist/utils/docker.js.map +0 -1
- package/dist/utils/doctor-runtime.d.ts +0 -66
- package/dist/utils/doctor-runtime.d.ts.map +0 -1
- package/dist/utils/doctor-runtime.js +0 -469
- package/dist/utils/doctor-runtime.js.map +0 -1
- package/dist/utils/env-validator.d.ts +0 -15
- package/dist/utils/env-validator.d.ts.map +0 -1
- package/dist/utils/env-validator.js +0 -109
- package/dist/utils/env-validator.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -31
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -140
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/file-helpers.d.ts +0 -14
- package/dist/utils/file-helpers.d.ts.map +0 -1
- package/dist/utils/file-helpers.js +0 -45
- package/dist/utils/file-helpers.js.map +0 -1
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +0 -1
- package/dist/utils/formatting.js +0 -164
- package/dist/utils/formatting.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -3
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js +0 -41
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/port-assignment.d.ts +0 -6
- package/dist/utils/port-assignment.d.ts.map +0 -1
- package/dist/utils/port-assignment.js +0 -81
- package/dist/utils/port-assignment.js.map +0 -1
- package/dist/utils/project-features.d.ts +0 -23
- package/dist/utils/project-features.d.ts.map +0 -1
- package/dist/utils/project-features.js +0 -98
- package/dist/utils/project-features.js.map +0 -1
- package/dist/utils/project-templates.d.ts +0 -7
- package/dist/utils/project-templates.d.ts.map +0 -1
- package/dist/utils/project-templates.js +0 -24
- package/dist/utils/project-templates.js.map +0 -1
- package/dist/utils/prompt.d.ts +0 -28
- package/dist/utils/prompt.d.ts.map +0 -1
- package/dist/utils/prompt.js +0 -79
- package/dist/utils/prompt.js.map +0 -1
- package/dist/utils/resource-features.d.ts +0 -29
- package/dist/utils/resource-features.d.ts.map +0 -1
- package/dist/utils/resource-features.js +0 -171
- package/dist/utils/resource-features.js.map +0 -1
- package/dist/utils/service-urls.d.ts +0 -30
- package/dist/utils/service-urls.d.ts.map +0 -1
- package/dist/utils/service-urls.js +0 -93
- package/dist/utils/service-urls.js.map +0 -1
- package/dist/utils/services.d.ts +0 -18
- package/dist/utils/services.d.ts.map +0 -1
- package/dist/utils/services.js +0 -291
- package/dist/utils/services.js.map +0 -1
- package/dist/utils/stack-features.d.ts +0 -22
- package/dist/utils/stack-features.d.ts.map +0 -1
- package/dist/utils/stack-features.js +0 -13
- package/dist/utils/stack-features.js.map +0 -1
- package/dist/utils/tar.d.ts +0 -7
- package/dist/utils/tar.d.ts.map +0 -1
- package/dist/utils/tar.js +0 -21
- package/dist/utils/tar.js.map +0 -1
- package/dist/utils/tilt.d.ts +0 -19
- package/dist/utils/tilt.d.ts.map +0 -1
- package/dist/utils/tilt.js +0 -78
- package/dist/utils/tilt.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -16
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -58
- package/dist/utils/validation.js.map +0 -1
- /package/{README.md → cli/README.md} +0 -0
- /package/{bin → cli/bin}/tdk.js +0 -0
- /package/{templates → cli/templates}/.tiltignore.hbs +0 -0
- /package/{templates → cli/templates}/TILT_RESOURCE_DEFAULTS.star.hbs +0 -0
- /package/{templates → cli/templates}/TILT_TECH_STACK.star.hbs +0 -0
- /package/{templates → cli/templates}/spec.master.hbs +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# Fix Bun hoisted package symlinks that can break when copied across Docker stages.
|
|
5
|
+
for pkg in node_modules/.bun/*/node_modules/*; do
|
|
6
|
+
[ -d "$pkg" ] || continue
|
|
7
|
+
name=$(basename "$pkg")
|
|
8
|
+
case "$name" in
|
|
9
|
+
@*) continue ;;
|
|
10
|
+
esac
|
|
11
|
+
ln -sfn "$(pwd)/$pkg" "node_modules/$name"
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
for pkg in node_modules/.bun/*/node_modules/@*/*; do
|
|
15
|
+
[ -d "$pkg" ] || continue
|
|
16
|
+
scope=$(basename "$(dirname "$pkg")")
|
|
17
|
+
name=$(basename "$pkg")
|
|
18
|
+
if [ "$scope" = "@prisma" ] && [ "$name" = "engines" ]; then
|
|
19
|
+
continue
|
|
20
|
+
fi
|
|
21
|
+
mkdir -p "node_modules/$scope"
|
|
22
|
+
ln -sfn "$(pwd)/$pkg" "node_modules/$scope/$name"
|
|
23
|
+
done
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# 🔐 UNIVERSAL INFISICAL ENTRYPOINT - Zero-Code Secret Injection
|
|
4
|
+
# =============================================================================
|
|
5
|
+
#
|
|
6
|
+
# This entrypoint wrapper injects secrets from Infisical WITHOUT modifying
|
|
7
|
+
# any microservice code. The service thinks it's reading from process.env,
|
|
8
|
+
# but Infisical CLI has already populated those variables.
|
|
9
|
+
#
|
|
10
|
+
# How it works:
|
|
11
|
+
# 1. Detects SERVICE_NAME environment variable (set by Tiltfile)
|
|
12
|
+
# 2. Constructs Infisical secret path: /services/{SERVICE_NAME}
|
|
13
|
+
# 3. Authenticates using Machine Identity (Universal Auth)
|
|
14
|
+
# 4. Uses `infisical run` to fetch secrets and inject into process env
|
|
15
|
+
# 5. Executes the original command (bun, npm, node, etc.)
|
|
16
|
+
#
|
|
17
|
+
# Key Benefits:
|
|
18
|
+
# - Zero refactoring: No SDK imports in microservices
|
|
19
|
+
# - Dynamic pathing: Auto-discovers service-specific secrets
|
|
20
|
+
# - Fallback support: Works without Infisical (for local dev)
|
|
21
|
+
# - Prisma compatible: CLI commands also see injected secrets
|
|
22
|
+
#
|
|
23
|
+
# 🗃️ DATABASE VIRTUALIZATION (BigTech Pattern):
|
|
24
|
+
# - Single PostgreSQL container with logical databases
|
|
25
|
+
# - Entrypoint waits for database to be ready before starting app
|
|
26
|
+
# - Saves ~80% RAM compared to 120 separate PostgreSQL containers
|
|
27
|
+
#
|
|
28
|
+
# 🎯 INVERSION OF CONTROL (Tilt as Single Source of Truth):
|
|
29
|
+
# - TILT_DATABASE_URL: If set by Docker Compose/Tilt, ALWAYS wins over Infisical
|
|
30
|
+
# - This ensures Tilt-created databases match application connections
|
|
31
|
+
# - Solves the "hidden DB secret" paradox without modifying Infisical
|
|
32
|
+
# - Precedence: TILT_DATABASE_URL > Infisical DATABASE_URL > Fallback
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
set -e
|
|
36
|
+
|
|
37
|
+
# Colors for terminal output
|
|
38
|
+
RED='\033[0;31m'
|
|
39
|
+
GREEN='\033[0;32m'
|
|
40
|
+
YELLOW='\033[1;33m'
|
|
41
|
+
BLUE='\033[0;34m'
|
|
42
|
+
CYAN='\033[0;36m'
|
|
43
|
+
NC='\033[0m' # No Color
|
|
44
|
+
|
|
45
|
+
log_info() {
|
|
46
|
+
printf "${BLUE}[ENTRYPOINT]${NC} %s\n" "$1"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
log_success() {
|
|
50
|
+
printf "${GREEN}[ENTRYPOINT]${NC} %s\n" "$1"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
log_warn() {
|
|
54
|
+
printf "${YELLOW}[ENTRYPOINT]${NC} %s\n" "$1"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
log_error() {
|
|
58
|
+
printf "${RED}[ENTRYPOINT]${NC} %s\n" "$1"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
log_db() {
|
|
62
|
+
printf "${CYAN}[DATABASE]${NC} %s\n" "$1"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# =============================================================================
|
|
66
|
+
# CONFIGURATION
|
|
67
|
+
# =============================================================================
|
|
68
|
+
|
|
69
|
+
# Service name (auto-detected from container or fallback to env var)
|
|
70
|
+
SERVICE_NAME="${SERVICE_NAME:-unknown-service}"
|
|
71
|
+
|
|
72
|
+
# Infisical configuration
|
|
73
|
+
INFISICAL_SITE_URL="${INFISICAL_SITE_URL:-https://app.infisical.com}"
|
|
74
|
+
INFISICAL_ENV="${INFISICAL_ENV:-dev}"
|
|
75
|
+
INFISICAL_SECRET_PATH="${INFISICAL_SECRET_PATH:-/services/${SERVICE_NAME}}"
|
|
76
|
+
|
|
77
|
+
# Check if Infisical is enabled (can be disabled for local dev)
|
|
78
|
+
INFISICAL_ENABLED="${INFISICAL_ENABLED:-true}"
|
|
79
|
+
|
|
80
|
+
# Database connectivity settings
|
|
81
|
+
DB_WAIT_TIMEOUT="${DB_WAIT_TIMEOUT:-60}"
|
|
82
|
+
DB_WAIT_INTERVAL="${DB_WAIT_INTERVAL:-2}"
|
|
83
|
+
|
|
84
|
+
# =============================================================================
|
|
85
|
+
# 🎯 INVERSION OF CONTROL - Tilt as Single Source of Truth
|
|
86
|
+
# =============================================================================
|
|
87
|
+
#
|
|
88
|
+
# Problem: Tilt creates databases but doesn't know what Infisical contains.
|
|
89
|
+
# This causes DATABASE_URL mismatch (e.g., beauty_crm_staff vs staff_db_prod)
|
|
90
|
+
#
|
|
91
|
+
# Solution: TILT_* prefixed variables ALWAYS override Infisical secrets
|
|
92
|
+
# Tilt sets TILT_DATABASE_URL → we export it as DATABASE_URL BEFORE infisical run
|
|
93
|
+
#
|
|
94
|
+
# Variables that can be overridden by Tilt:
|
|
95
|
+
# - TILT_DATABASE_URL → DATABASE_URL
|
|
96
|
+
# - TILT_NATS_URL → NATS_URL
|
|
97
|
+
# - TILT_REDIS_URL → REDIS_URL
|
|
98
|
+
# - TILT_* → * (generic pattern)
|
|
99
|
+
# =============================================================================
|
|
100
|
+
|
|
101
|
+
# List of critical variables that Tilt can override
|
|
102
|
+
TILT_OVERRIDE_VARS="DATABASE_URL NATS_URL REDIS_URL DB_HOST DB_PORT DB_NAME DB_USER DB_PASSWORD"
|
|
103
|
+
|
|
104
|
+
# Track overrides for logging
|
|
105
|
+
TILT_OVERRIDES_APPLIED=0
|
|
106
|
+
|
|
107
|
+
apply_tilt_overrides() {
|
|
108
|
+
log_info "🎯 Checking for Tilt IoC overrides..."
|
|
109
|
+
local overrides_applied=0
|
|
110
|
+
|
|
111
|
+
for var_name in $TILT_OVERRIDE_VARS; do
|
|
112
|
+
tilt_var="TILT_${var_name}"
|
|
113
|
+
tilt_value=$(eval echo \$$tilt_var)
|
|
114
|
+
|
|
115
|
+
if [ -n "$tilt_value" ]; then
|
|
116
|
+
log_success " ✓ TILT_${var_name} overrides ${var_name}"
|
|
117
|
+
export "${var_name}=${tilt_value}"
|
|
118
|
+
overrides_applied=$((overrides_applied + 1))
|
|
119
|
+
TILT_OVERRIDES_APPLIED=$overrides_applied
|
|
120
|
+
fi
|
|
121
|
+
done
|
|
122
|
+
|
|
123
|
+
if [ $overrides_applied -eq 0 ]; then
|
|
124
|
+
log_info " No Tilt overrides found - using Infisical/defaults"
|
|
125
|
+
else
|
|
126
|
+
log_success " 🎯 Applied ${overrides_applied} Tilt override(s) - Tilt is SSOT!"
|
|
127
|
+
fi
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# =============================================================================
|
|
131
|
+
# DATABASE VIRTUALIZATION FUNCTIONS (BigTech Pattern)
|
|
132
|
+
# =============================================================================
|
|
133
|
+
# Single PostgreSQL container with logical databases per service
|
|
134
|
+
# Saves ~80% RAM on Mac M1/M2 compared to 120 separate containers
|
|
135
|
+
|
|
136
|
+
wait_for_postgres() {
|
|
137
|
+
local db_host="$1"
|
|
138
|
+
local db_port="$2"
|
|
139
|
+
local db_name="$3"
|
|
140
|
+
local timeout="${DB_WAIT_TIMEOUT}"
|
|
141
|
+
local interval="${DB_WAIT_INTERVAL}"
|
|
142
|
+
local elapsed=0
|
|
143
|
+
|
|
144
|
+
log_db "🗃️ Waiting for PostgreSQL: ${db_host}:${db_port}/${db_name}"
|
|
145
|
+
log_db "⏱️ Timeout: ${timeout}s, Check interval: ${interval}s"
|
|
146
|
+
|
|
147
|
+
while [ $elapsed -lt $timeout ]; do
|
|
148
|
+
# TCP check first (port availability)
|
|
149
|
+
if nc -z "${db_host}" "${db_port}" 2>/dev/null; then
|
|
150
|
+
log_db "✓ PostgreSQL port ${db_port} is open"
|
|
151
|
+
|
|
152
|
+
# If we have psql, do a deeper health check
|
|
153
|
+
if command -v psql >/dev/null 2>&1; then
|
|
154
|
+
if PGPASSWORD="${db_password:-}" psql -h "${db_host}" -p "${db_port}" -U "${db_user:-beauty_crm}" -d "${db_name}" -c "SELECT 1" >/dev/null 2>&1; then
|
|
155
|
+
log_success "✅ Database ${db_name} is ready!"
|
|
156
|
+
return 0
|
|
157
|
+
fi
|
|
158
|
+
else
|
|
159
|
+
# No psql available, trust TCP check
|
|
160
|
+
log_success "✅ PostgreSQL is reachable (TCP check passed)"
|
|
161
|
+
return 0
|
|
162
|
+
fi
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
log_db "⏳ Waiting... (${elapsed}/${timeout}s)"
|
|
166
|
+
sleep $interval
|
|
167
|
+
elapsed=$((elapsed + interval))
|
|
168
|
+
done
|
|
169
|
+
|
|
170
|
+
log_warn "⚠️ Database connection timeout after ${timeout}s - proceeding anyway"
|
|
171
|
+
return 1
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
parse_database_url() {
|
|
175
|
+
# Parse DATABASE_URL: postgresql://user:password@host:port/dbname?schema=public
|
|
176
|
+
local url="$1"
|
|
177
|
+
|
|
178
|
+
# Extract components using sed
|
|
179
|
+
db_user=$(echo "$url" | sed -n 's|.*://\([^:]*\):.*|\1|p')
|
|
180
|
+
db_password=$(echo "$url" | sed -n 's|.*://[^:]*:\([^@]*\)@.*|\1|p')
|
|
181
|
+
db_host=$(echo "$url" | sed -n 's|.*@\([^:]*\):.*|\1|p')
|
|
182
|
+
db_port=$(echo "$url" | sed -n 's|.*:\([0-9]*\)/.*|\1|p')
|
|
183
|
+
db_name=$(echo "$url" | sed -n 's|.*/\([^?]*\).*|\1|p')
|
|
184
|
+
|
|
185
|
+
# Export for use in other functions
|
|
186
|
+
export DB_USER="${db_user}"
|
|
187
|
+
export DB_PASSWORD="${db_password}"
|
|
188
|
+
export DB_HOST="${db_host}"
|
|
189
|
+
export DB_PORT="${db_port}"
|
|
190
|
+
export DB_NAME="${db_name}"
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# =============================================================================
|
|
194
|
+
# INFISICAL VALIDATION
|
|
195
|
+
# =============================================================================
|
|
196
|
+
|
|
197
|
+
validate_infisical_config() {
|
|
198
|
+
local missing=""
|
|
199
|
+
|
|
200
|
+
if [ -z "$INFISICAL_CLIENT_ID" ]; then
|
|
201
|
+
missing="${missing}INFISICAL_CLIENT_ID "
|
|
202
|
+
fi
|
|
203
|
+
|
|
204
|
+
if [ -z "$INFISICAL_CLIENT_SECRET" ]; then
|
|
205
|
+
missing="${missing}INFISICAL_CLIENT_SECRET "
|
|
206
|
+
fi
|
|
207
|
+
|
|
208
|
+
if [ -z "$INFISICAL_PROJECT_ID" ]; then
|
|
209
|
+
missing="${missing}INFISICAL_PROJECT_ID "
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
if [ -n "$missing" ]; then
|
|
213
|
+
log_warn "Missing Infisical config: ${missing}"
|
|
214
|
+
return 1
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
return 0
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
# =============================================================================
|
|
221
|
+
# DATABASE CONNECTIVITY VALIDATION (Unified for Database Virtualization)
|
|
222
|
+
# =============================================================================
|
|
223
|
+
|
|
224
|
+
validate_database_connectivity() {
|
|
225
|
+
# Extract database info from DATABASE_URL if available
|
|
226
|
+
if [ -n "$DATABASE_URL" ]; then
|
|
227
|
+
parse_database_url "$DATABASE_URL"
|
|
228
|
+
|
|
229
|
+
log_info "🗃️ Database Virtualization Check:"
|
|
230
|
+
log_info " Host: ${DB_HOST:-unknown}"
|
|
231
|
+
log_info " Port: ${DB_PORT:-5432}"
|
|
232
|
+
log_info " Database: ${DB_NAME:-unknown}"
|
|
233
|
+
log_info " Service: ${SERVICE_NAME}"
|
|
234
|
+
|
|
235
|
+
# Wait for PostgreSQL to be ready
|
|
236
|
+
wait_for_postgres "${DB_HOST}" "${DB_PORT:-5432}" "${DB_NAME}"
|
|
237
|
+
else
|
|
238
|
+
log_warn "DATABASE_URL not set - skipping database connectivity check"
|
|
239
|
+
fi
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# =============================================================================
|
|
243
|
+
# 📦 PRISMA AUTO-MIGRATION (Architect Level - Uber Pattern)
|
|
244
|
+
# =============================================================================
|
|
245
|
+
#
|
|
246
|
+
# Detects Prisma schema and runs migrations DIRECTLY without relying on
|
|
247
|
+
# package.json scripts. This removes human error dependency and ensures
|
|
248
|
+
# migrations always run regardless of script configuration.
|
|
249
|
+
#
|
|
250
|
+
# Benefits:
|
|
251
|
+
# - No dependency on package.json "db:migrate" script existing
|
|
252
|
+
# - Consistent migration behavior across all services
|
|
253
|
+
# - Self-healing: works even if package.json is misconfigured
|
|
254
|
+
# =============================================================================
|
|
255
|
+
|
|
256
|
+
AUTO_MIGRATE="${AUTO_MIGRATE:-true}"
|
|
257
|
+
|
|
258
|
+
run_prisma_migrations() {
|
|
259
|
+
# Skip if auto-migrate is disabled
|
|
260
|
+
if [ "$AUTO_MIGRATE" = "false" ] || [ "$AUTO_MIGRATE" = "0" ]; then
|
|
261
|
+
log_info "📦 Auto-migration disabled (AUTO_MIGRATE=false)"
|
|
262
|
+
return 0
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
# Check for Prisma schema in common locations
|
|
266
|
+
local prisma_schema=""
|
|
267
|
+
if [ -f "./prisma/schema.prisma" ]; then
|
|
268
|
+
prisma_schema="./prisma/schema.prisma"
|
|
269
|
+
elif [ -f "./prisma/schema/schema.prisma" ]; then
|
|
270
|
+
prisma_schema="./prisma/schema/schema.prisma"
|
|
271
|
+
elif [ -f "./schema.prisma" ]; then
|
|
272
|
+
prisma_schema="./schema.prisma"
|
|
273
|
+
fi
|
|
274
|
+
|
|
275
|
+
if [ -n "$prisma_schema" ]; then
|
|
276
|
+
log_info "📦 Prisma schema found: ${prisma_schema}"
|
|
277
|
+
|
|
278
|
+
# Auto-resolve failed migrations (P3009) before deploying new ones.
|
|
279
|
+
# In dev/local environments, stale failed records in _prisma_migrations
|
|
280
|
+
# block all subsequent deploys. Resolve them automatically.
|
|
281
|
+
if [ -n "$DATABASE_URL" ]; then
|
|
282
|
+
local deploy_output
|
|
283
|
+
deploy_output=$(bunx prisma migrate deploy 2>&1) || true
|
|
284
|
+
if echo "$deploy_output" | grep -q "P3009"; then
|
|
285
|
+
log_warn "🔧 P3009: Found failed migration(s) — auto-resolving..."
|
|
286
|
+
# Extract migration name(s) from "The `<name>` migration ... failed" lines
|
|
287
|
+
echo "$deploy_output" | sed -n 's/.*The `\([^`]*\)` migration .* failed.*/\1/p' | while IFS= read -r migration_name; do
|
|
288
|
+
log_info " Rolling back: ${migration_name}"
|
|
289
|
+
bunx prisma migrate resolve --rolled-back "$migration_name" 2>&1 || true
|
|
290
|
+
done
|
|
291
|
+
# Retry deploy after resolving failed migrations
|
|
292
|
+
log_info "📦 Retrying database migrations..."
|
|
293
|
+
if bunx prisma migrate deploy 2>&1; then
|
|
294
|
+
log_success "✅ Database migrations completed successfully (after auto-resolve)"
|
|
295
|
+
else
|
|
296
|
+
log_warn "⚠️ Migration still failed after auto-resolve"
|
|
297
|
+
fi
|
|
298
|
+
elif echo "$deploy_output" | grep -q "applied successfully"; then
|
|
299
|
+
log_success "✅ Database migrations completed successfully"
|
|
300
|
+
else
|
|
301
|
+
# No P3009 and no success — could be "already in sync" or other info
|
|
302
|
+
echo "$deploy_output"
|
|
303
|
+
log_info "📦 Migration deploy completed (check output above)"
|
|
304
|
+
fi
|
|
305
|
+
else
|
|
306
|
+
log_warn "📦 DATABASE_URL not set — skipping migration deploy"
|
|
307
|
+
fi
|
|
308
|
+
else
|
|
309
|
+
log_info "📦 No Prisma schema found - skipping auto-migration"
|
|
310
|
+
fi
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
# =============================================================================
|
|
314
|
+
# MAIN EXECUTION
|
|
315
|
+
# =============================================================================
|
|
316
|
+
|
|
317
|
+
main() {
|
|
318
|
+
log_info "═══════════════════════════════════════════════════"
|
|
319
|
+
log_info "🚀 Starting service: ${SERVICE_NAME}"
|
|
320
|
+
log_info "🌍 Environment: ${INFISICAL_ENV}"
|
|
321
|
+
log_info "🔐 Secret path: ${INFISICAL_SECRET_PATH}"
|
|
322
|
+
log_info "🗃️ Database Virtualization: ENABLED (BigTech Pattern)"
|
|
323
|
+
log_info "🎯 Tilt IoC: ENABLED (Single Source of Truth)"
|
|
324
|
+
log_info "═══════════════════════════════════════════════════"
|
|
325
|
+
|
|
326
|
+
# 🎯 CRITICAL: Apply Tilt overrides FIRST (before anything else)
|
|
327
|
+
# This ensures TILT_DATABASE_URL becomes DATABASE_URL BEFORE:
|
|
328
|
+
# 1. validate_database_connectivity() uses it
|
|
329
|
+
# 2. infisical run potentially overwrites it
|
|
330
|
+
apply_tilt_overrides
|
|
331
|
+
|
|
332
|
+
# Check if Infisical is disabled
|
|
333
|
+
if [ "$INFISICAL_ENABLED" = "false" ] || [ "$INFISICAL_ENABLED" = "0" ]; then
|
|
334
|
+
log_warn "Infisical disabled - using direct environment variables"
|
|
335
|
+
validate_database_connectivity
|
|
336
|
+
run_prisma_migrations
|
|
337
|
+
exec "$@"
|
|
338
|
+
fi
|
|
339
|
+
|
|
340
|
+
# Check if infisical CLI is available
|
|
341
|
+
if ! command -v infisical >/dev/null 2>&1; then
|
|
342
|
+
log_warn "Infisical CLI not found - using direct environment variables"
|
|
343
|
+
validate_database_connectivity
|
|
344
|
+
run_prisma_migrations
|
|
345
|
+
exec "$@"
|
|
346
|
+
fi
|
|
347
|
+
|
|
348
|
+
# Validate Infisical configuration
|
|
349
|
+
if ! validate_infisical_config; then
|
|
350
|
+
log_warn "Infisical not configured - falling back to environment variables"
|
|
351
|
+
validate_database_connectivity
|
|
352
|
+
run_prisma_migrations
|
|
353
|
+
exec "$@"
|
|
354
|
+
fi
|
|
355
|
+
|
|
356
|
+
log_success "Infisical configured ✓"
|
|
357
|
+
|
|
358
|
+
# Authenticate with Machine Identity (Universal Auth)
|
|
359
|
+
# This is NON-INTERACTIVE - uses client ID/secret from env vars
|
|
360
|
+
log_info "Authenticating with Machine Identity..."
|
|
361
|
+
|
|
362
|
+
if ! infisical login --method=universal-auth \
|
|
363
|
+
--client-id="$INFISICAL_CLIENT_ID" \
|
|
364
|
+
--client-secret="$INFISICAL_CLIENT_SECRET" \
|
|
365
|
+
--domain="$INFISICAL_SITE_URL" \
|
|
366
|
+
--silent 2>/dev/null; then
|
|
367
|
+
log_warn "Machine Identity auth failed - falling back to environment variables"
|
|
368
|
+
validate_database_connectivity
|
|
369
|
+
run_prisma_migrations
|
|
370
|
+
exec "$@"
|
|
371
|
+
fi
|
|
372
|
+
|
|
373
|
+
log_success "Authenticated ✓"
|
|
374
|
+
|
|
375
|
+
# Validate database connectivity BEFORE starting the app
|
|
376
|
+
# This ensures the shared PostgreSQL is ready (Database Virtualization pattern)
|
|
377
|
+
validate_database_connectivity
|
|
378
|
+
|
|
379
|
+
# 📦 PRISMA AUTO-MIGRATION with Infisical context
|
|
380
|
+
# Run migrations INSIDE infisical run so DATABASE_URL from secrets is available
|
|
381
|
+
# Includes P3009 auto-resolve: marks stale failed migrations as rolled-back
|
|
382
|
+
log_info "📦 Running Prisma migrations with Infisical secrets..."
|
|
383
|
+
infisical run \
|
|
384
|
+
--domain="$INFISICAL_SITE_URL" \
|
|
385
|
+
--projectId="$INFISICAL_PROJECT_ID" \
|
|
386
|
+
--env="$INFISICAL_ENV" \
|
|
387
|
+
--path="$INFISICAL_SECRET_PATH" \
|
|
388
|
+
--expand=false \
|
|
389
|
+
--silent \
|
|
390
|
+
-- sh -c '
|
|
391
|
+
if [ -f "./prisma/schema.prisma" ] || [ -f "./prisma/schema/schema.prisma" ]; then
|
|
392
|
+
output=$(bunx prisma migrate deploy 2>&1) || true
|
|
393
|
+
if echo "$output" | grep -q "P3009"; then
|
|
394
|
+
echo "[ENTRYPOINT] 🔧 P3009: Auto-resolving failed migration(s)..."
|
|
395
|
+
echo "$output" | sed -n "s/.*The \`\([^\`]*\)\` migration .* failed.*/\1/p" | while IFS= read -r mig; do
|
|
396
|
+
echo "[ENTRYPOINT] Rolling back: $mig"
|
|
397
|
+
bunx prisma migrate resolve --rolled-back "$mig" 2>&1 || true
|
|
398
|
+
done
|
|
399
|
+
echo "[ENTRYPOINT] 📦 Retrying migrations..."
|
|
400
|
+
bunx prisma migrate deploy 2>&1 || echo "[ENTRYPOINT] ⚠️ Migration still failed after auto-resolve"
|
|
401
|
+
else
|
|
402
|
+
echo "$output"
|
|
403
|
+
fi
|
|
404
|
+
fi
|
|
405
|
+
' || true
|
|
406
|
+
|
|
407
|
+
# Execute with Infisical secret injection
|
|
408
|
+
# 🎯 CRITICAL FIX: Instead of using `infisical run` (which always overwrites existing env vars),
|
|
409
|
+
# we fetch secrets and only export vars that aren't already set. This preserves TILT_* overrides.
|
|
410
|
+
# Precedence: TILT_* > Infisical > Defaults
|
|
411
|
+
|
|
412
|
+
log_info "Fetching secrets from Infisical..."
|
|
413
|
+
|
|
414
|
+
# Fetch secrets in plain format (KEY=VALUE per line)
|
|
415
|
+
# Use a temporary file to capture output safely
|
|
416
|
+
temp_secrets=$(mktemp)
|
|
417
|
+
trap "rm -f $temp_secrets" EXIT
|
|
418
|
+
|
|
419
|
+
infisical secrets \
|
|
420
|
+
--domain="$INFISICAL_SITE_URL" \
|
|
421
|
+
--projectId="$INFISICAL_PROJECT_ID" \
|
|
422
|
+
--env="$INFISICAL_ENV" \
|
|
423
|
+
--path="$INFISICAL_SECRET_PATH" \
|
|
424
|
+
--expand=false \
|
|
425
|
+
--plain \
|
|
426
|
+
--silent > "$temp_secrets" 2>/dev/null || true
|
|
427
|
+
|
|
428
|
+
# Only export secrets that aren't already set in the environment
|
|
429
|
+
# This preserves TILT_DATABASE_URL -> DATABASE_URL override
|
|
430
|
+
secrets_exported=0
|
|
431
|
+
if [ -s "$temp_secrets" ]; then
|
|
432
|
+
while IFS= read -r line; do
|
|
433
|
+
# Skip empty lines
|
|
434
|
+
[ -z "$line" ] && continue
|
|
435
|
+
|
|
436
|
+
# Split on first = only (in case value contains =)
|
|
437
|
+
key="${line%%=*}"
|
|
438
|
+
value="${line#*=}"
|
|
439
|
+
|
|
440
|
+
# Only export if not already set in environment
|
|
441
|
+
eval "current_val=\$$key"
|
|
442
|
+
if [ -z "$current_val" ]; then
|
|
443
|
+
export "${key}=${value}"
|
|
444
|
+
secrets_exported=$((secrets_exported + 1))
|
|
445
|
+
fi
|
|
446
|
+
done < "$temp_secrets"
|
|
447
|
+
fi
|
|
448
|
+
|
|
449
|
+
log_success "Injected ${secrets_exported} secret(s) from Infisical (preserving ${TILT_OVERRIDES_APPLIED} TILT override(s))"
|
|
450
|
+
log_info "🎯 Final DATABASE_URL: ${DATABASE_URL:-not-set}"
|
|
451
|
+
log_success "🎉 Service ${SERVICE_NAME} starting with Database Virtualization!"
|
|
452
|
+
|
|
453
|
+
exec "$@"
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
# Handle the case where no command is provided
|
|
457
|
+
if [ $# -eq 0 ]; then
|
|
458
|
+
log_error "No command provided"
|
|
459
|
+
log_info "Usage: /entrypoint.sh <command> [args...]"
|
|
460
|
+
log_info "Example: /entrypoint.sh bun run src/index.ts"
|
|
461
|
+
exit 1
|
|
462
|
+
fi
|
|
463
|
+
|
|
464
|
+
main "$@"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# CRITICAL FIX: Bun concurrency and DNS settings for Docker/Colima
|
|
6
|
+
# These prevent "Resolving dependencies" hang
|
|
7
|
+
# =============================================================================
|
|
8
|
+
export BUN_INSTALL_CONCURRENCY=4 # Default is 16+, reduce for Docker
|
|
9
|
+
export UV_THREADPOOL_SIZE=4 # Limit threads (default is 128)
|
|
10
|
+
export BUN_NETWORK_TIMEOUT=30000 # 30s timeout per request
|
|
11
|
+
export BUN_RESOLVE_TIMEOUT=60000 # 60s for resolution phase
|
|
12
|
+
|
|
13
|
+
# DNS fixes for Colima/Docker
|
|
14
|
+
export NODE_OPTIONS="--dns-result-order=ipv4first"
|
|
15
|
+
|
|
16
|
+
start_ts=$(date +%s)
|
|
17
|
+
echo "⏱️ install-deps start: $(date '+%Y-%m-%d %H:%M:%S %z')"
|
|
18
|
+
echo "🔧 Bun concurrency: $BUN_INSTALL_CONCURRENCY, Threadpool: $UV_THREADPOOL_SIZE"
|
|
19
|
+
|
|
20
|
+
finish_install_timer() {
|
|
21
|
+
end_ts=$(date +%s)
|
|
22
|
+
echo "install-deps duration: $((end_ts-start_ts))s"
|
|
23
|
+
}
|
|
24
|
+
trap 'finish_install_timer' EXIT INT TERM
|
|
25
|
+
|
|
26
|
+
export NODE_ENV=development
|
|
27
|
+
|
|
28
|
+
# Use persistent cache directory (Docker layer, not mount)
|
|
29
|
+
export BUN_INSTALL_CACHE_DIR=/cache/bun
|
|
30
|
+
mkdir -p $BUN_INSTALL_CACHE_DIR
|
|
31
|
+
|
|
32
|
+
# =============================================================================
|
|
33
|
+
# Check Verdaccio registry (premium feature — only required when VERDACCIO_LICENSE_KEY is set)
|
|
34
|
+
# Without a license key, skip Verdaccio and fall back to public npm registry.
|
|
35
|
+
# =============================================================================
|
|
36
|
+
if [ -z "${TDK_LICENSE_KEY:-}" ]; then
|
|
37
|
+
echo "ℹ️ TDK_LICENSE_KEY not set — skipping private registry (public npm only)"
|
|
38
|
+
VERDACCIO_URL=""
|
|
39
|
+
else
|
|
40
|
+
VERDACCIO_URL="http://localhost:4873"
|
|
41
|
+
echo "🔍 Checking Verdaccio registry at $VERDACCIO_URL..."
|
|
42
|
+
if ! wget -q --spider --timeout=3 "$VERDACCIO_URL" 2>/dev/null; then
|
|
43
|
+
VERDACCIO_URL="http://host.docker.internal:4873"
|
|
44
|
+
echo " localhost unreachable, trying $VERDACCIO_URL..."
|
|
45
|
+
if ! wget -q --spider --timeout=3 "$VERDACCIO_URL" 2>/dev/null; then
|
|
46
|
+
echo "❌ Verdaccio not reachable at localhost:4873 or host.docker.internal:4873. Build will fail."
|
|
47
|
+
echo " Ensure Verdaccio is running: docker ps | grep verdaccio"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
fi
|
|
51
|
+
echo "✅ Verdaccio available at $VERDACCIO_URL"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# =============================================================================
|
|
55
|
+
# CRITICAL FIX: Reduced timeout for faster failure detection (was 900s)
|
|
56
|
+
# Using 60s to fail fast and retry, rather than hanging for 15 minutes
|
|
57
|
+
# =============================================================================
|
|
58
|
+
# CRITICAL FIX: Extended timeout for full dependency resolution
|
|
59
|
+
# 60s was too short - packages resolve but need time for transitive deps
|
|
60
|
+
INSTALL_TIMEOUT_SECONDS="${BUN_INSTALL_TIMEOUT_SECONDS:-300}"
|
|
61
|
+
echo "📦 Dependency install timeout: ${INSTALL_TIMEOUT_SECONDS}s (Verdaccio packages available)"
|
|
62
|
+
|
|
63
|
+
INSTALL_DEPS_VERBOSE="${INSTALL_DEPS_VERBOSE:-0}"
|
|
64
|
+
if [ "$INSTALL_DEPS_VERBOSE" = "1" ]; then
|
|
65
|
+
echo "🚀 Installing dependencies (verbose)..."
|
|
66
|
+
BUN_VERBOSE_FLAG="--verbose"
|
|
67
|
+
FAIL_TAIL_LINES=200
|
|
68
|
+
else
|
|
69
|
+
echo "📦 Installing dependencies..."
|
|
70
|
+
BUN_VERBOSE_FLAG=""
|
|
71
|
+
FAIL_TAIL_LINES=50
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
BUN_INSTALL_LOG=/tmp/bun-install.log
|
|
75
|
+
|
|
76
|
+
# Start tail in background for live logging
|
|
77
|
+
touch "$BUN_INSTALL_LOG"
|
|
78
|
+
tail -n 20 -f "$BUN_INSTALL_LOG" 2>/dev/null &
|
|
79
|
+
TAIL_PID=$!
|
|
80
|
+
cleanup_tail() {
|
|
81
|
+
kill "$TAIL_PID" 2>/dev/null || true
|
|
82
|
+
}
|
|
83
|
+
trap 'cleanup_tail; finish_install_timer' EXIT INT TERM
|
|
84
|
+
|
|
85
|
+
# =============================================================================
|
|
86
|
+
# Cache configuration: Use persistent Docker layer path
|
|
87
|
+
# =============================================================================
|
|
88
|
+
# Uses /cache/bun (persistent Docker layer path, not a mount).
|
|
89
|
+
# This avoids the "FileNotFound when create temporary directory" bug
|
|
90
|
+
# that occurs with Docker --mount=type=cache, while still persisting
|
|
91
|
+
# cache across rebuilds via Docker layer caching.
|
|
92
|
+
echo "🔧 Using /cache/bun for Bun cache (persistent Docker layer)..."
|
|
93
|
+
export BUN_CACHE_DIR="/cache/bun"
|
|
94
|
+
mkdir -p "$BUN_CACHE_DIR"
|
|
95
|
+
BUN_CACHE_FLAG="--cache-dir=/cache/bun"
|
|
96
|
+
echo "📁 Cache location: /cache/bun"
|
|
97
|
+
|
|
98
|
+
# =============================================================================
|
|
99
|
+
# Install function with timeout and logging
|
|
100
|
+
# Uses constrained concurrency to prevent "Resolving dependencies" hang
|
|
101
|
+
# =============================================================================
|
|
102
|
+
run_install() {
|
|
103
|
+
local args="$1"
|
|
104
|
+
local attempt="$2"
|
|
105
|
+
|
|
106
|
+
echo "📌 Attempt $attempt: bun install $args (concurrency: $BUN_INSTALL_CONCURRENCY)"
|
|
107
|
+
set +e
|
|
108
|
+
# Use timeout with explicit concurrency limit
|
|
109
|
+
timeout "$INSTALL_TIMEOUT_SECONDS" \
|
|
110
|
+
bun install $args \
|
|
111
|
+
--concurrent-tasks "$BUN_INSTALL_CONCURRENCY" \
|
|
112
|
+
--concurrent-scripts "$BUN_INSTALL_CONCURRENCY" \
|
|
113
|
+
$BUN_CACHE_FLAG $BUN_VERBOSE_FLAG >"$BUN_INSTALL_LOG" 2>&1
|
|
114
|
+
local code=$?
|
|
115
|
+
set -e
|
|
116
|
+
return $code
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# =============================================================================
|
|
120
|
+
# Install with lockfile but allow updates within resolved ranges
|
|
121
|
+
# =============================================================================
|
|
122
|
+
ATTEMPT=1
|
|
123
|
+
INSTALL_CODE=0
|
|
124
|
+
|
|
125
|
+
run_install "--force" $ATTEMPT
|
|
126
|
+
INSTALL_CODE=$?
|
|
127
|
+
ATTEMPT=$((ATTEMPT + 1))
|
|
128
|
+
|
|
129
|
+
cleanup_tail
|
|
130
|
+
|
|
131
|
+
# =============================================================================
|
|
132
|
+
# Final status check
|
|
133
|
+
# =============================================================================
|
|
134
|
+
if [ "$INSTALL_CODE" -ne 0 ]; then
|
|
135
|
+
echo "❌ Dependency installation failed after $((ATTEMPT - 1)) attempts (exit $INSTALL_CODE). Last ${FAIL_TAIL_LINES} lines:"
|
|
136
|
+
tail -n "$FAIL_TAIL_LINES" "$BUN_INSTALL_LOG"
|
|
137
|
+
exit 1
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
if [ ! -d "node_modules" ] || [ -z "$(ls -A node_modules 2>/dev/null)" ]; then
|
|
141
|
+
echo "❌ Dependency installation produced empty node_modules. Last ${FAIL_TAIL_LINES} lines:"
|
|
142
|
+
tail -n "$FAIL_TAIL_LINES" "$BUN_INSTALL_LOG"
|
|
143
|
+
exit 1
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
echo "✅ Dependency installation complete"
|
|
147
|
+
if [ "$INSTALL_DEPS_VERBOSE" = "1" ]; then
|
|
148
|
+
echo "📊 Total packages: $(ls node_modules 2>/dev/null | wc -l)"
|
|
149
|
+
du -sh node_modules 2>/dev/null || true
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
# No cache cleanup needed (--no-cache flag used)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# Fix Bun module resolution: .prisma/client must be reachable from .bun linker paths.
|
|
5
|
+
for dir in node_modules/.bun/@prisma+client*/node_modules; do
|
|
6
|
+
[ -d "$dir" ] && ln -sf "$(pwd)/node_modules/.prisma" "$dir/.prisma" || true
|
|
7
|
+
done
|
|
8
|
+
|
|
9
|
+
# Also fix malformed @prisma/client package.json in Bun cache if present.
|
|
10
|
+
for pkg in node_modules/.bun/@prisma+client*/node_modules/@prisma/client/package.json; do
|
|
11
|
+
[ -f "$pkg" ] && echo '{"name":"@prisma/client","main":"index.js","types":"index.d.ts"}' > "$pkg" || true
|
|
12
|
+
done
|