@tdk-landscape/tdk-cli-core 1.3.15 → 1.3.26

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.
Files changed (274) hide show
  1. package/Tiltfile +144 -0
  2. package/discovery/AGENTS.md +362 -0
  3. package/discovery/TILT_DISCOVERY.star +424 -0
  4. package/discovery/Tiltfile +58 -0
  5. package/discovery/config.star +258 -0
  6. package/discovery/constants.star +127 -0
  7. package/discovery/deterministic.star +211 -0
  8. package/discovery/discovery_daemon.star +191 -0
  9. package/discovery/discovery_orchestrator.star +460 -0
  10. package/discovery/filtering.star +5 -0
  11. package/discovery/identity-management-backend/service.yaml +26 -0
  12. package/discovery/identity-management-frontend/service.yaml +29 -0
  13. package/discovery/identity-sdk/service.yaml +9 -0
  14. package/discovery/incremental_discovery.star +213 -0
  15. package/discovery/indexing.star +7 -0
  16. package/discovery/json_manifest_scanner.star +51 -0
  17. package/discovery/libraries.star +46 -0
  18. package/discovery/loading.star +23 -0
  19. package/discovery/manifest/constants.star +104 -0
  20. package/discovery/manifest/loading.star +386 -0
  21. package/discovery/manifest/normalize.star +281 -0
  22. package/discovery/manifest/validation.star +108 -0
  23. package/discovery/normalization.star +11 -0
  24. package/discovery/registry.star +544 -0
  25. package/discovery/resource_snapshot.py +382 -0
  26. package/discovery/resource_snapshot.star +143 -0
  27. package/discovery/schemas.star +1 -0
  28. package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
  29. package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
  30. package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
  31. package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
  32. package/discovery/test_resource_snapshot.py +251 -0
  33. package/discovery/validation.star +78 -0
  34. package/discovery/versioning.star +1 -0
  35. package/dist/commands/config.d.ts.map +1 -1
  36. package/dist/commands/config.js +11 -0
  37. package/dist/commands/config.js.map +1 -1
  38. package/dist/commands/doctor.d.ts.map +1 -1
  39. package/dist/commands/doctor.js +1 -2
  40. package/dist/commands/doctor.js.map +1 -1
  41. package/dist/commands/project.d.ts.map +1 -1
  42. package/dist/commands/project.js +36 -41
  43. package/dist/commands/project.js.map +1 -1
  44. package/dist/commands/resource.d.ts.map +1 -1
  45. package/dist/commands/resource.js +51 -55
  46. package/dist/commands/resource.js.map +1 -1
  47. package/dist/commands/stack.d.ts.map +1 -1
  48. package/dist/commands/stack.js +22 -24
  49. package/dist/commands/stack.js.map +1 -1
  50. package/dist/commands/ui.d.ts.map +1 -1
  51. package/dist/commands/ui.js +1 -2
  52. package/dist/commands/ui.js.map +1 -1
  53. package/dist/commands/up.d.ts.map +1 -1
  54. package/dist/commands/up.js +1 -2
  55. package/dist/commands/up.js.map +1 -1
  56. package/dist/commands/upgrade.d.ts +8 -0
  57. package/dist/commands/upgrade.d.ts.map +1 -1
  58. package/dist/commands/upgrade.js +59 -18
  59. package/dist/commands/upgrade.js.map +1 -1
  60. package/dist/generator/extension-fetch.d.ts +19 -0
  61. package/dist/generator/extension-fetch.d.ts.map +1 -1
  62. package/dist/generator/extension-fetch.js +71 -5
  63. package/dist/generator/extension-fetch.js.map +1 -1
  64. package/dist/generator/template-engine.d.ts +1 -0
  65. package/dist/generator/template-engine.d.ts.map +1 -1
  66. package/dist/generator/template-engine.js +50 -6
  67. package/dist/generator/template-engine.js.map +1 -1
  68. package/dist/utils/command-helpers.d.ts.map +1 -1
  69. package/dist/utils/command-helpers.js +7 -9
  70. package/dist/utils/command-helpers.js.map +1 -1
  71. package/dist/utils/constants.d.ts +1 -0
  72. package/dist/utils/constants.d.ts.map +1 -1
  73. package/dist/utils/constants.js +1 -0
  74. package/dist/utils/constants.js.map +1 -1
  75. package/dist/utils/errors.d.ts +2 -0
  76. package/dist/utils/errors.d.ts.map +1 -1
  77. package/dist/utils/errors.js +6 -1
  78. package/dist/utils/errors.js.map +1 -1
  79. package/dist/utils/project-features.d.ts.map +1 -1
  80. package/dist/utils/project-features.js +1 -1
  81. package/dist/utils/project-features.js.map +1 -1
  82. package/dist/utils/resource-features.d.ts.map +1 -1
  83. package/dist/utils/resource-features.js +2 -2
  84. package/dist/utils/resource-features.js.map +1 -1
  85. package/dist/utils/tar.js +4 -4
  86. package/dist/utils/tar.js.map +1 -1
  87. package/dist/utils/validation.d.ts +7 -0
  88. package/dist/utils/validation.d.ts.map +1 -1
  89. package/dist/utils/validation.js +9 -0
  90. package/dist/utils/validation.js.map +1 -1
  91. package/engine/AGENTS.md +705 -0
  92. package/engine/README.md +29 -0
  93. package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
  94. package/engine/Tiltfile +80 -0
  95. package/engine/assets/docker/golden-layers.Dockerfile +221 -0
  96. package/engine/assets/scripts/cleanup-completed-migrator-images.sh +37 -0
  97. package/engine/assets/scripts/cleanup-tilt-images.sh +120 -0
  98. package/engine/assets/scripts/mac-m1-resource-monitor.sh +121 -0
  99. package/engine/config.star +3 -0
  100. package/engine/docs/AUTODISCOVERY_TEST.md +182 -0
  101. package/engine/docs/C4-ARCHITECTURE-operations.md +396 -0
  102. package/engine/docs/C4-ARCHITECTURE-overview.md +284 -0
  103. package/engine/docs/C4-ARCHITECTURE.md +17 -0
  104. package/engine/docs/GOLDEN_IMAGE_INTEGRATION.md +349 -0
  105. package/engine/docs/MANIFEST_DRIVEN_ARCHITECTURE.md +357 -0
  106. package/engine/docs/README.md +284 -0
  107. package/engine/entrypoint.star +97 -0
  108. package/engine/lifecycle/orchestrator.star +260 -0
  109. package/engine/paths.star +717 -0
  110. package/engine/schemas/manifest-schema.json +301 -0
  111. package/engine/schemas/service-schema.json +301 -0
  112. package/engine/scripts/README.md +89 -0
  113. package/engine/scripts/build-and-publish-lib.sh +205 -0
  114. package/engine/scripts/check-lib-publish.sh +85 -0
  115. package/engine/scripts/debug-container.sh +258 -0
  116. package/engine/scripts/generate-manifest.sh +197 -0
  117. package/engine/spec.master +702 -0
  118. package/engine/spec.master.example +341 -0
  119. package/engine/topologies/README.md +34 -0
  120. package/engine/topologies/platform/docker/AGENTS.md +59 -0
  121. package/engine/topologies/platform/docker/auth/auth.star +167 -0
  122. package/engine/topologies/platform/docker/build/golden_image.star +37 -0
  123. package/engine/topologies/platform/docker/build/golden_image_build.star +82 -0
  124. package/engine/topologies/platform/docker/build/golden_image_constants.star +93 -0
  125. package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +291 -0
  126. package/engine/topologies/platform/docker/compose/compose.star +636 -0
  127. package/engine/topologies/platform/docker/compose/compose_helpers.star +52 -0
  128. package/engine/topologies/platform/docker/compose/traefik_standalone.star +53 -0
  129. package/engine/topologies/platform/docker/config/bunignore.star +142 -0
  130. package/engine/topologies/platform/docker/config/dockerignore.star +150 -0
  131. package/engine/topologies/platform/docker/constants.star +170 -0
  132. package/engine/topologies/platform/docker/dockerfile/dockerfile.star +54 -0
  133. package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +73 -0
  134. package/engine/topologies/platform/docker/index.star +27 -0
  135. package/engine/topologies/platform/docker/layers/bun_helpers.star +23 -0
  136. package/engine/topologies/platform/docker/layers/infisical/index.star +40 -0
  137. package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +262 -0
  138. package/engine/topologies/platform/docker/layers/l1_base_layers.star +87 -0
  139. package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +125 -0
  140. package/engine/topologies/platform/docker/layers/l3_builder_layers.star +209 -0
  141. package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +214 -0
  142. package/engine/topologies/platform/docker/layers/prisma/constants.star +135 -0
  143. package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +96 -0
  144. package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +109 -0
  145. package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +98 -0
  146. package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +126 -0
  147. package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +161 -0
  148. package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +119 -0
  149. package/engine/topologies/platform/docker/networking/api_path_constants.star +230 -0
  150. package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +27 -0
  151. package/engine/topologies/platform/docker/networking/traefik.star +232 -0
  152. package/engine/topologies/platform/docker/networking/traefik_constants.star +146 -0
  153. package/engine/topologies/platform/docker/networking/traefik_helpers.star +160 -0
  154. package/engine/topologies/platform/docker/secrets/infisical.star +135 -0
  155. package/engine/topologies/platform/net/proxy.star +4 -0
  156. package/engine/topologies/platform/registries/local.star +4 -0
  157. package/engine/topologies/platform/security/secrets.star +239 -0
  158. package/engine/topologies/platform/state/relational.star +4 -0
  159. package/engine/topologies/tilt/common/AGENTS.md +59 -0
  160. package/engine/topologies/tilt/common/utils.star +364 -0
  161. package/engine/topologies/tilt/common/utils_debug.star +69 -0
  162. package/engine/topologies/tilt/common/utils_deterministic.star +168 -0
  163. package/engine/topologies/tilt/common/utils_docker_networks.star +46 -0
  164. package/engine/topologies/tilt/common/utils_env.star +43 -0
  165. package/engine/topologies/tilt/common/utils_output.star +97 -0
  166. package/engine/topologies/tilt/config/AGENTS.md +68 -0
  167. package/engine/topologies/tilt/config/defaults.star +3 -0
  168. package/engine/topologies/tilt/config/feature_flags.star +10 -0
  169. package/engine/topologies/tilt/config/global.star +55 -0
  170. package/engine/topologies/tilt/config/profiles.star +382 -0
  171. package/engine/topologies/tilt/generators/agents_md.star +62 -0
  172. package/engine/topologies/tilt/generators/api_gateway.star +145 -0
  173. package/engine/topologies/tilt/generators/index.star +124 -0
  174. package/engine/topologies/tilt/generators/infisical/README.md +424 -0
  175. package/engine/topologies/tilt/generators/infisical/examples.star +312 -0
  176. package/engine/topologies/tilt/generators/infisical/index.star +57 -0
  177. package/engine/topologies/tilt/generators/infisical/machine_identity.star +420 -0
  178. package/engine/topologies/tilt/generators/infisical/organization.star +534 -0
  179. package/engine/topologies/tilt/generators/infisical/path_manager.star +476 -0
  180. package/engine/topologies/tilt/generators/infisical/secrets_generator.star +420 -0
  181. package/engine/topologies/tilt/generators/nginx_conf.star +143 -0
  182. package/engine/topologies/tilt/generators/npmrc.star +111 -0
  183. package/engine/topologies/tilt/generators/tsconfig.star +23 -0
  184. package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +71 -0
  185. package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +124 -0
  186. package/engine/topologies/tilt/generators/typescript/common.star +7 -0
  187. package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +76 -0
  188. package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +110 -0
  189. package/engine/topologies/tilt/generators/typescript/include.star +23 -0
  190. package/engine/topologies/tilt/generators/typescript/playwright_config.star +40 -0
  191. package/engine/topologies/tilt/generators/typescript/prisma_config.star +49 -0
  192. package/engine/topologies/tilt/generators/validators.star +853 -0
  193. package/engine/topologies/tilt/generators/vite/backend.star +78 -0
  194. package/engine/topologies/tilt/generators/vite/frontend.star +98 -0
  195. package/engine/topologies/tilt/generators/vite/generators.star +43 -0
  196. package/engine/topologies/tilt/generators/vite/helpers.star +244 -0
  197. package/engine/topologies/tilt/generators/vite/library.star +65 -0
  198. package/engine/topologies/tilt/generators/vite/sdk.star +73 -0
  199. package/engine/topologies/tilt/generators/vite/templates.star +737 -0
  200. package/engine/topologies/tilt/generators/vite_config.star +22 -0
  201. package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
  202. package/engine/topologies/tilt/manifest/README.md +693 -0
  203. package/engine/topologies/tilt/manifest/__init__.star +218 -0
  204. package/engine/topologies/tilt/manifest/constants.star +252 -0
  205. package/engine/topologies/tilt/manifest/errors.star +266 -0
  206. package/engine/topologies/tilt/manifest/integration.star +339 -0
  207. package/engine/topologies/tilt/manifest/json_to_yaml.py +54 -0
  208. package/engine/topologies/tilt/manifest/loader.star +214 -0
  209. package/engine/topologies/tilt/manifest/mapper.star +227 -0
  210. package/engine/topologies/tilt/manifest/parser.star +400 -0
  211. package/engine/topologies/tilt/manifest/schema.star +462 -0
  212. package/engine/topologies/tilt/manifest/tests/test_integration.star +276 -0
  213. package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +397 -0
  214. package/engine/topologies/tilt/manifest/tests/test_manifest.star +316 -0
  215. package/engine/topologies/tilt/manifest/tests/test_validator.star +470 -0
  216. package/engine/topologies/tilt/manifest/validator.star +717 -0
  217. package/engine/topologies/tilt/manifest/yaml_to_json.py +18 -0
  218. package/engine/topologies/tilt/resources/AGENTS.md +71 -0
  219. package/engine/topologies/tilt/resources/conditions.star +3 -0
  220. package/engine/topologies/tilt/resources/databases.star +244 -0
  221. package/engine/topologies/tilt/resources/declaration.star +3 -0
  222. package/engine/topologies/tilt/resources/deps.star +3 -0
  223. package/engine/topologies/tilt/resources/infra-loader.star +437 -0
  224. package/engine/topologies/tilt/resources/libs.star +30 -0
  225. package/engine/topologies/tilt/resources/libs_discovery.star +102 -0
  226. package/engine/topologies/tilt/resources/libs_paths.star +79 -0
  227. package/engine/topologies/tilt/resources/libs_resource_definition.star +151 -0
  228. package/engine/topologies/tilt/resources/libs_setup.star +164 -0
  229. package/engine/topologies/tilt/resources/libs_tsconfig.star +37 -0
  230. package/engine/topologies/tilt/resources/orchestrator/apply.star +77 -0
  231. package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +431 -0
  232. package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +81 -0
  233. package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +148 -0
  234. package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +36 -0
  235. package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +44 -0
  236. package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +164 -0
  237. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
  238. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +21 -0
  239. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +134 -0
  240. package/engine/topologies/tilt/resources/orchestrator/generators/env.star +258 -0
  241. package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +169 -0
  242. package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +524 -0
  243. package/engine/topologies/tilt/resources/orchestrator/helpers.star +33 -0
  244. package/engine/topologies/tilt/resources/orchestrator.star +54 -0
  245. package/engine/topologies/tilt/resources/ordering.star +3 -0
  246. package/engine/topologies/tilt/resources/triggers.star +3 -0
  247. package/engine/topologies/tilt/resources/watchers.star +299 -0
  248. package/engine/where-things-live.star +717 -0
  249. package/ext/Tiltfile +66 -0
  250. package/ext/ide-components/README.md +219 -0
  251. package/ext/ide-components/code_executor/server.py +268 -0
  252. package/ext/ide-components/code_viewer/server.py +206 -0
  253. package/ext/ide-components/config_inspector/server.py +1050 -0
  254. package/ext/ide-components/file_browser/server.py +285 -0
  255. package/ext/ide-components/shared/config_service.py +469 -0
  256. package/ext/ide-components/shared/file_utils.py +298 -0
  257. package/ext/ide-components/shared/http_utils.py +232 -0
  258. package/ext/ide-components/shared/static/styles.css +1334 -0
  259. package/ext/ide-components/shared/syntax_highlighter.py +140 -0
  260. package/ext/ide-components/shared/template_engine.py +123 -0
  261. package/ext/ide-components/shared/templates/base.html +121 -0
  262. package/ext/ide-components/shared/test_config_service.py +326 -0
  263. package/ext/ide-components/shared/tilt_integration.py +158 -0
  264. package/ext/ui-enhancements/cron-status-server.sh +49 -0
  265. package/ext/ui-enhancements/cron-status-tracker.sh +146 -0
  266. package/ext/ui-enhancements/extension.yaml +36 -0
  267. package/ext/ui-enhancements/tiltfile.py +99 -0
  268. package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
  269. package/ext/ui-enhancements/ui/help-panel.css +279 -0
  270. package/ext/ui-enhancements/ui/icons.css +125 -0
  271. package/ext/ui-enhancements/ui/tooltips.css +114 -0
  272. package/package.json +13 -9
  273. package/specs/specs/TILT_SERVICE_DEFAULTS.star +205 -0
  274. package/specs/specs/TILT_TECH_STACK.star +159 -0
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # Library Build & Publish with Caching
4
+ # =============================================================================
5
+ # Intelligently builds and publishes libraries only when needed
6
+ # =============================================================================
7
+
8
+ set -euo pipefail
9
+
10
+ LIB_PATH="${1:?Library path required}"
11
+ REGISTRY="${2:-http://localhost:4873}"
12
+ PACKAGE_NAME="${3:?Package name required}"
13
+ CONSUMER_PATHS="${4:-}" # Optional: comma-separated list of consumer paths
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ WORKSPACE_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
17
+
18
+ if [[ "${LIB_PATH}" = /* ]]; then
19
+ LIB_ABS_PATH="${LIB_PATH}"
20
+ else
21
+ LIB_ABS_PATH="${WORKSPACE_ROOT}/${LIB_PATH}"
22
+ fi
23
+
24
+ CACHE_DIR="${LIB_ABS_PATH}/.tilt-cache"
25
+
26
+ # Check if rebuild/republish is needed
27
+ if ! "${SCRIPT_DIR}/check-lib-publish.sh" "${LIB_ABS_PATH}" "${REGISTRY}"; then
28
+ # Script exited with 1 (skip rebuild)
29
+ exit 0
30
+ fi
31
+
32
+ # Rebuild needed - run full pipeline
33
+ cd "${LIB_ABS_PATH}"
34
+
35
+ EFFECTIVE_REGISTRY="${REGISTRY%/}"
36
+ if ! curl -sf --max-time 3 "${EFFECTIVE_REGISTRY}/-/ping" >/dev/null 2>&1; then
37
+ for fallback_registry in "http://localhost:4873" "http://verdaccio.localhost:4873"; do
38
+ if curl -sf --max-time 3 "${fallback_registry}/-/ping" >/dev/null 2>&1; then
39
+ echo "⚠️ Registry ${EFFECTIVE_REGISTRY} is unreachable, falling back to ${fallback_registry}"
40
+ EFFECTIVE_REGISTRY="${fallback_registry}"
41
+ break
42
+ fi
43
+ done
44
+ fi
45
+
46
+ echo "📦 Installing dependencies..."
47
+ NPMRC_FOR_INSTALL=""
48
+ if [[ "${EFFECTIVE_REGISTRY}" == *"host.docker.internal"* ]]; then
49
+ if [[ -f "${LIB_ABS_PATH}/autogenerated/.npmrc.docker.autogenerated" ]]; then
50
+ NPMRC_FOR_INSTALL="${LIB_ABS_PATH}/autogenerated/.npmrc.docker.autogenerated"
51
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc.docker" ]]; then
52
+ NPMRC_FOR_INSTALL="${LIB_ABS_PATH}/.npmrc.docker"
53
+ fi
54
+ fi
55
+
56
+ if [[ -z "${NPMRC_FOR_INSTALL}" ]]; then
57
+ if [[ -f "${LIB_ABS_PATH}/autogenerated/.npmrc.autogenerated" ]]; then
58
+ NPMRC_FOR_INSTALL="${LIB_ABS_PATH}/autogenerated/.npmrc.autogenerated"
59
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc" ]]; then
60
+ NPMRC_FOR_INSTALL="${LIB_ABS_PATH}/.npmrc"
61
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc.docker" ]]; then
62
+ NPMRC_FOR_INSTALL="${LIB_ABS_PATH}/.npmrc.docker"
63
+ fi
64
+ fi
65
+
66
+ run_bun_install_with_retry() {
67
+ local npmrc_path="${1:-}"
68
+ local registry="${2:-}"
69
+ local attempt=1
70
+ local max_attempts=3
71
+ local exit_code=1
72
+ local install_env=()
73
+
74
+ if [[ -n "${registry}" ]]; then
75
+ install_env+=("npm_config_registry=${registry}")
76
+ if [[ "${PACKAGE_NAME}" == @*/* ]]; then
77
+ local package_scope="${PACKAGE_NAME%%/*}"
78
+ install_env+=("npm_config_${package_scope}:registry=${registry}")
79
+ fi
80
+ fi
81
+
82
+ while [[ ${attempt} -le ${max_attempts} ]]; do
83
+ set +e
84
+ if [[ -n "${npmrc_path}" ]]; then
85
+ env "${install_env[@]}" NPM_CONFIG_USERCONFIG="${npmrc_path}" bun install
86
+ exit_code=$?
87
+ else
88
+ env "${install_env[@]}" bun install
89
+ exit_code=$?
90
+ fi
91
+ set -e
92
+
93
+ if [[ ${exit_code} -eq 0 ]]; then
94
+ return 0
95
+ fi
96
+
97
+ if [[ ${attempt} -lt ${max_attempts} ]]; then
98
+ echo "⚠️ bun install failed (attempt ${attempt}/${max_attempts}), retrying..."
99
+ sleep $((attempt * 2))
100
+ fi
101
+
102
+ attempt=$((attempt + 1))
103
+ done
104
+
105
+ return ${exit_code}
106
+ }
107
+
108
+ set +e
109
+ run_bun_install_with_retry "${NPMRC_FOR_INSTALL}" "${EFFECTIVE_REGISTRY}"
110
+ INSTALL_EXIT_CODE=$?
111
+ set -e
112
+
113
+ if [[ ${INSTALL_EXIT_CODE} -ne 0 ]]; then
114
+ RETRY_REGISTRY=""
115
+ RETRY_NPMRC=""
116
+ for fallback_registry in "http://localhost:4873" "http://verdaccio.localhost:4873" "https://registry.npmjs.org"; do
117
+ if [[ "${fallback_registry}" != "${EFFECTIVE_REGISTRY}" ]] && curl -sf --max-time 3 "${fallback_registry}/-/ping" >/dev/null 2>&1; then
118
+ RETRY_REGISTRY="${fallback_registry}"
119
+ break
120
+ fi
121
+ done
122
+
123
+ if [[ -n "${RETRY_REGISTRY}" ]]; then
124
+ if [[ "${RETRY_REGISTRY}" == *"host.docker.internal"* ]]; then
125
+ if [[ -f "${LIB_ABS_PATH}/autogenerated/.npmrc.docker.autogenerated" ]]; then
126
+ RETRY_NPMRC="${LIB_ABS_PATH}/autogenerated/.npmrc.docker.autogenerated"
127
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc.docker" ]]; then
128
+ RETRY_NPMRC="${LIB_ABS_PATH}/.npmrc.docker"
129
+ fi
130
+ fi
131
+ if [[ -z "${RETRY_NPMRC}" ]]; then
132
+ if [[ -f "${LIB_ABS_PATH}/autogenerated/.npmrc.autogenerated" ]]; then
133
+ RETRY_NPMRC="${LIB_ABS_PATH}/autogenerated/.npmrc.autogenerated"
134
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc" ]]; then
135
+ RETRY_NPMRC="${LIB_ABS_PATH}/.npmrc"
136
+ elif [[ -f "${LIB_ABS_PATH}/.npmrc.docker" ]]; then
137
+ RETRY_NPMRC="${LIB_ABS_PATH}/.npmrc.docker"
138
+ fi
139
+ fi
140
+
141
+ echo "⚠️ bun install failed, retrying with fallback registry ${RETRY_REGISTRY}"
142
+ run_bun_install_with_retry "${RETRY_NPMRC}" "${RETRY_REGISTRY}"
143
+ EFFECTIVE_REGISTRY="${RETRY_REGISTRY}"
144
+ else
145
+ exit ${INSTALL_EXIT_CODE}
146
+ fi
147
+ fi
148
+
149
+ echo "🔨 Building package..."
150
+ if grep -q '"build":' package.json; then
151
+ bun run build
152
+ else
153
+ if [ -f ".autogenerated/tsconfig.autogenerated.json" ]; then
154
+ bunx tsc -p .autogenerated/tsconfig.autogenerated.json --declaration --declarationMap --rootDir src --outDir dist
155
+ else
156
+ bunx tsc -p tsconfig.json --declaration --declarationMap --rootDir src --outDir dist
157
+ fi
158
+ fi
159
+
160
+ echo "🔗 Linking package..."
161
+ bun link
162
+
163
+ echo "📤 Publishing to registry..."
164
+ # npm may prefer scoped registry config over --registry, so force both default
165
+ # and scope-specific registry to avoid publishing to a different host.
166
+ NPM_CONFIG_OVERRIDES=("npm_config_registry=${EFFECTIVE_REGISTRY}")
167
+ if [[ "${PACKAGE_NAME}" == @*/* ]]; then
168
+ PACKAGE_SCOPE="${PACKAGE_NAME%%/*}"
169
+ NPM_CONFIG_OVERRIDES+=("npm_config_${PACKAGE_SCOPE}:registry=${EFFECTIVE_REGISTRY}")
170
+ fi
171
+
172
+ # Try to unpublish first (ignore errors)
173
+ env "${NPM_CONFIG_OVERRIDES[@]}" npm unpublish --force --registry "${EFFECTIVE_REGISTRY}" >/dev/null 2>&1 || true
174
+ env "${NPM_CONFIG_OVERRIDES[@]}" npm publish --registry "${EFFECTIVE_REGISTRY}" --fetch-retries=1 --fetch-timeout=10000 --fetch-retry-mintimeout=1000 --fetch-retry-maxtimeout=5000
175
+
176
+ # Save source hash to mark successful build
177
+ mkdir -p "${CACHE_DIR}"
178
+ PACKAGE_JSON="${LIB_ABS_PATH}/package.json"
179
+ TSCONFIG_PATH="${LIB_ABS_PATH}/.autogenerated/tsconfig.autogenerated.json"
180
+ if [ -f "${TSCONFIG_PATH}" ]; then
181
+ find "${LIB_ABS_PATH}/src" "${PACKAGE_JSON}" "${TSCONFIG_PATH}" -type f 2>/dev/null | \
182
+ sort | \
183
+ xargs cat 2>/dev/null | \
184
+ shasum -a 256 | \
185
+ awk '{print $1}' > "${CACHE_DIR}/source-hash.txt"
186
+ else
187
+ find "${LIB_ABS_PATH}/src" "${PACKAGE_JSON}" "${LIB_ABS_PATH}/tsconfig.json" -type f 2>/dev/null | \
188
+ sort | \
189
+ xargs cat 2>/dev/null | \
190
+ shasum -a 256 | \
191
+ awk '{print $1}' > "${CACHE_DIR}/source-hash.txt"
192
+ fi
193
+
194
+ # Link to consumers if specified
195
+ if [[ -n "${CONSUMER_PATHS}" ]]; then
196
+ IFS=',' read -ra CONSUMERS <<< "${CONSUMER_PATHS}"
197
+ for consumer in "${CONSUMERS[@]}"; do
198
+ if [[ -n "${consumer}" ]]; then
199
+ echo "🔗 Linking to consumer: ${consumer}"
200
+ (cd "${WORKSPACE_ROOT}/${consumer}" && bun link "${PACKAGE_NAME}") || true
201
+ fi
202
+ done
203
+ fi
204
+
205
+ echo "✅ ${PACKAGE_NAME} build and publish complete"
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # Library Build/Publish Cache Checker
4
+ # =============================================================================
5
+ # Checks if a library needs to be rebuilt and republished to Verdaccio.
6
+ # The SOURCE HASH is the primary gate — if sources haven't changed since the
7
+ # last successful build+publish, skip entirely (regardless of registry state).
8
+ # Returns: 0 if rebuild needed, 1 if can skip
9
+ # =============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ LIB_PATH="${1:?Library path required}"
14
+ REGISTRY="${2:-http://localhost:4873}"
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ WORKSPACE_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
17
+
18
+ if [[ "${LIB_PATH}" = /* ]]; then
19
+ LIB_ABS_PATH="${LIB_PATH}"
20
+ else
21
+ LIB_ABS_PATH="${WORKSPACE_ROOT}/${LIB_PATH}"
22
+ fi
23
+
24
+ CACHE_DIR="${LIB_ABS_PATH}/.tilt-cache"
25
+
26
+ # Colors for output
27
+ GREEN='\033[0;32m'
28
+ YELLOW='\033[1;33m'
29
+ NC='\033[0m' # No Color
30
+
31
+ # Ensure cache directory exists
32
+ mkdir -p "${CACHE_DIR}"
33
+
34
+ # Read package.json to get name and version
35
+ PACKAGE_JSON="${LIB_ABS_PATH}/package.json"
36
+ if [[ ! -f "${PACKAGE_JSON}" ]]; then
37
+ echo -e "${YELLOW}⚠️ package.json not found at ${PACKAGE_JSON}${NC}"
38
+ exit 0 # Needs rebuild
39
+ fi
40
+
41
+ PACKAGE_NAME=$(grep -o '"name"[[:space:]]*:[[:space:]]*"[^"]*"' "${PACKAGE_JSON}" | sed 's/"name"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/')
42
+ PACKAGE_VERSION=$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "${PACKAGE_JSON}" | sed 's/"version"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/')
43
+
44
+ # ---------------------------------------------------------------------------
45
+ # PRIMARY CHECK: Source hash comparison (works offline, no registry needed)
46
+ # ---------------------------------------------------------------------------
47
+ SOURCE_HASH_FILE="${CACHE_DIR}/source-hash.txt"
48
+
49
+ # Calculate hash of source files (src/, package.json, tsconfig.json)
50
+ TSCONFIG_PATH="${LIB_ABS_PATH}/.autogenerated/tsconfig.autogenerated.json"
51
+ if [ -f "${TSCONFIG_PATH}" ]; then
52
+ CURRENT_HASH=$(find "${LIB_ABS_PATH}/src" "${PACKAGE_JSON}" "${TSCONFIG_PATH}" -type f 2>/dev/null | \
53
+ sort | \
54
+ xargs cat 2>/dev/null | \
55
+ shasum -a 256 | \
56
+ awk '{print $1}')
57
+ else
58
+ CURRENT_HASH=$(find "${LIB_ABS_PATH}/src" "${PACKAGE_JSON}" "${LIB_ABS_PATH}/tsconfig.json" -type f 2>/dev/null | \
59
+ sort | \
60
+ xargs cat 2>/dev/null | \
61
+ shasum -a 256 | \
62
+ awk '{print $1}')
63
+ fi
64
+
65
+ if [[ -f "${SOURCE_HASH_FILE}" ]]; then
66
+ CACHED_HASH=$(cat "${SOURCE_HASH_FILE}")
67
+
68
+ if [[ "${CURRENT_HASH}" == "${CACHED_HASH}" ]]; then
69
+ # Source unchanged since last successful build+publish — skip
70
+ echo -e "${GREEN}✓ ${PACKAGE_NAME}@${PACKAGE_VERSION} sources unchanged (hash match) - skipping build${NC}"
71
+ exit 1 # Skip rebuild
72
+ fi
73
+ fi
74
+
75
+ # ---------------------------------------------------------------------------
76
+ # Hash mismatch or no cached hash — rebuild needed
77
+ # ---------------------------------------------------------------------------
78
+ if [[ -f "${SOURCE_HASH_FILE}" ]]; then
79
+ echo -e "${YELLOW}⚠️ ${PACKAGE_NAME}@${PACKAGE_VERSION} sources changed — rebuilding${NC}"
80
+ else
81
+ echo -e "${YELLOW}⚠️ ${PACKAGE_NAME}@${PACKAGE_VERSION} no cached hash found — initial build${NC}"
82
+ fi
83
+
84
+ echo "🔨 Building ${PACKAGE_NAME}@${PACKAGE_VERSION}..."
85
+ exit 0 # Needs rebuild
@@ -0,0 +1,258 @@
1
+ #!/usr/bin/env bash
2
+ # ====================================================================
3
+ # Container Debug Helper Script
4
+ # Provides easy access to debugging running or failed Docker containers
5
+ # ====================================================================
6
+
7
+ set -euo pipefail
8
+
9
+ # Colors for output
10
+ RED='\033[0;31m'
11
+ GREEN='\033[0;32m'
12
+ YELLOW='\033[1;33m'
13
+ BLUE='\033[0;34m'
14
+ NC='\033[0m' # No Color
15
+
16
+ # Help text
17
+ show_help() {
18
+ cat << EOF
19
+ ${GREEN}Container Debug Helper${NC}
20
+
21
+ ${BLUE}Usage:${NC}
22
+ $0 [OPTIONS] [RESOURCE_NAME]
23
+
24
+ ${BLUE}Options:${NC}
25
+ -l, --list List all running containers with their status
26
+ -s, --shell SERVICE Start an interactive shell in SERVICE
27
+ -f, --failed Show failed build containers
28
+ -c, --command CMD Run a specific command in the container
29
+ -v, --verbose Show verbose output
30
+ -h, --help Show this help message
31
+
32
+ ${BLUE}Examples:${NC}
33
+ # List all running containers
34
+ $0 --list
35
+
36
+ # Open shell in identity service
37
+ $0 --shell identity-db-migrator
38
+
39
+ # Run a diagnostic command
40
+ $0 -s identity-db-migrator -c "bun install --verbose"
41
+
42
+ # Check network connectivity
43
+ $0 -s identity-db-migrator -c "nc -zv registry.npmjs.org 443"
44
+
45
+ # View package.json
46
+ $0 -s identity-db-migrator -c "cat package.json"
47
+
48
+ ${BLUE}Common Debug Commands:${NC}
49
+ # Network diagnostics
50
+ nc -zv registry.npmjs.org 443
51
+ nslookup registry.npmjs.org
52
+ curl -I https://registry.npmjs.org
53
+
54
+ # Bun diagnostics
55
+ bun --version
56
+ bun install --verbose --dry-run
57
+ cat .npmrc
58
+ cat bunfig.toml
59
+
60
+ # File system
61
+ ls -la node_modules
62
+ du -sh node_modules
63
+ df -h
64
+
65
+ EOF
66
+ }
67
+
68
+ # List containers
69
+ list_containers() {
70
+ echo -e "${GREEN}=== Running Containers ===${NC}"
71
+ docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" | grep -i "beauty"
72
+
73
+ echo ""
74
+ echo -e "${YELLOW}=== Recently Exited Containers ===${NC}"
75
+ docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" | grep -i "beauty" | grep -i "exited"
76
+ }
77
+
78
+ # Get container ID from service name
79
+ get_container_id() {
80
+ local resource_name="$1"
81
+ local container_id=$(docker ps -aq --filter "name=${resource_name}" | head -n1)
82
+
83
+ if [ -z "$container_id" ]; then
84
+ echo -e "${RED}Error: No container found for service '${resource_name}'${NC}" >&2
85
+ echo -e "${YELLOW}Tip: Run '$0 --list' to see available containers${NC}" >&2
86
+ return 1
87
+ fi
88
+
89
+ echo "$container_id"
90
+ }
91
+
92
+ # Start interactive shell
93
+ start_shell() {
94
+ local resource_name="$1"
95
+ local container_id=$(get_container_id "$resource_name") || return 1
96
+
97
+ echo -e "${GREEN}Starting interactive shell in ${resource_name}...${NC}"
98
+ echo -e "${BLUE}Container ID: ${container_id}${NC}"
99
+ echo ""
100
+
101
+ # Try sh first (alpine), then bash
102
+ if docker exec -it "$container_id" sh -c "command -v bash" >/dev/null 2>&1; then
103
+ docker exec -it "$container_id" bash
104
+ else
105
+ docker exec -it "$container_id" sh
106
+ fi
107
+ }
108
+
109
+ # Run specific command
110
+ run_command() {
111
+ local resource_name="$1"
112
+ local command="$2"
113
+ local container_id=$(get_container_id "$resource_name") || return 1
114
+
115
+ echo -e "${GREEN}Running command in ${resource_name}:${NC} ${command}"
116
+ echo -e "${BLUE}Container ID: ${container_id}${NC}"
117
+ echo ""
118
+
119
+ docker exec -it "$container_id" sh -c "$command"
120
+ }
121
+
122
+ # Show failed containers
123
+ show_failed() {
124
+ echo -e "${RED}=== Failed/Exited Containers ===${NC}"
125
+ docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" | grep -i "beauty" | grep -iE "(exited|error)"
126
+
127
+ echo ""
128
+ echo -e "${YELLOW}To inspect logs of a failed container:${NC}"
129
+ echo " docker logs <container_name>"
130
+ echo ""
131
+ echo -e "${YELLOW}To restart a failed container:${NC}"
132
+ echo " docker start -ai <container_name>"
133
+ }
134
+
135
+ # Quick diagnostics menu
136
+ diagnostics_menu() {
137
+ local resource_name="$1"
138
+
139
+ echo -e "${GREEN}=== Quick Diagnostics Menu ===${NC}"
140
+ echo "1) Check network connectivity"
141
+ echo "2) View package.json and config files"
142
+ echo "3) Test bun installation (dry-run)"
143
+ echo "4) Check disk space and cache"
144
+ echo "5) View environment variables"
145
+ echo "6) Interactive shell"
146
+ echo "q) Quit"
147
+ echo ""
148
+ read -p "Select option: " choice
149
+
150
+ case $choice in
151
+ 1)
152
+ echo -e "${BLUE}Testing network connectivity...${NC}"
153
+ run_command "$resource_name" "nc -zv registry.npmjs.org 443 && nc -zv TDK Landscape-verdaccio 4873"
154
+ ;;
155
+ 2)
156
+ echo -e "${BLUE}Viewing configuration files...${NC}"
157
+ run_command "$resource_name" "echo '=== package.json ===' && cat package.json && echo '' && echo '=== .npmrc ===' && cat .npmrc && echo '' && echo '=== bunfig.toml ===' && cat bunfig.toml"
158
+ ;;
159
+ 3)
160
+ echo -e "${BLUE}Testing bun installation (dry-run)...${NC}"
161
+ run_command "$resource_name" "bun install --verbose --dry-run"
162
+ ;;
163
+ 4)
164
+ echo -e "${BLUE}Checking disk space and cache...${NC}"
165
+ run_command "$resource_name" "df -h && echo '' && echo '=== Cache ===' && ls -lh /cache/bun && echo '' && echo '=== node_modules ===' && ls -lh node_modules | head -20"
166
+ ;;
167
+ 5)
168
+ echo -e "${BLUE}Environment variables:${NC}"
169
+ run_command "$resource_name" "env | sort"
170
+ ;;
171
+ 6)
172
+ start_shell "$resource_name"
173
+ ;;
174
+ q|Q)
175
+ exit 0
176
+ ;;
177
+ *)
178
+ echo -e "${RED}Invalid option${NC}"
179
+ ;;
180
+ esac
181
+ }
182
+
183
+ # Main script logic
184
+ main() {
185
+ local action=""
186
+ local resource_name=""
187
+ local command=""
188
+ local verbose=false
189
+
190
+ # Parse arguments
191
+ while [[ $# -gt 0 ]]; do
192
+ case $1 in
193
+ -l|--list)
194
+ action="list"
195
+ shift
196
+ ;;
197
+ -s|--shell)
198
+ action="shell"
199
+ resource_name="$2"
200
+ shift 2
201
+ ;;
202
+ -f|--failed)
203
+ action="failed"
204
+ shift
205
+ ;;
206
+ -c|--command)
207
+ command="$2"
208
+ shift 2
209
+ ;;
210
+ -v|--verbose)
211
+ verbose=true
212
+ shift
213
+ ;;
214
+ -h|--help)
215
+ show_help
216
+ exit 0
217
+ ;;
218
+ *)
219
+ if [ -z "$resource_name" ]; then
220
+ resource_name="$1"
221
+ action="menu"
222
+ fi
223
+ shift
224
+ ;;
225
+ esac
226
+ done
227
+
228
+ # Execute action
229
+ case $action in
230
+ list)
231
+ list_containers
232
+ ;;
233
+ shell)
234
+ if [ -n "$command" ]; then
235
+ run_command "$resource_name" "$command"
236
+ else
237
+ start_shell "$resource_name"
238
+ fi
239
+ ;;
240
+ failed)
241
+ show_failed
242
+ ;;
243
+ menu)
244
+ diagnostics_menu "$resource_name"
245
+ ;;
246
+ "")
247
+ echo -e "${YELLOW}No action specified. Use --help for usage information.${NC}"
248
+ list_containers
249
+ ;;
250
+ *)
251
+ echo -e "${RED}Unknown action: $action${NC}"
252
+ show_help
253
+ exit 1
254
+ ;;
255
+ esac
256
+ }
257
+
258
+ main "$@"