@vyuhlabs/dxkit 2.4.7 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/CHANGELOG.md +456 -30
  2. package/README.md +360 -439
  3. package/dist/analyzers/bom/gather.d.ts +3 -3
  4. package/dist/analyzers/bom/gather.js +3 -3
  5. package/dist/analyzers/bom/index.js +2 -2
  6. package/dist/analyzers/bom/index.js.map +1 -1
  7. package/dist/analyzers/dashboard/index.d.ts.map +1 -1
  8. package/dist/analyzers/dashboard/index.js +4 -3
  9. package/dist/analyzers/dashboard/index.js.map +1 -1
  10. package/dist/analyzers/developer/index.d.ts.map +1 -1
  11. package/dist/analyzers/developer/index.js +2 -1
  12. package/dist/analyzers/developer/index.js.map +1 -1
  13. package/dist/analyzers/dispatcher.d.ts +15 -0
  14. package/dist/analyzers/dispatcher.d.ts.map +1 -1
  15. package/dist/analyzers/dispatcher.js +42 -6
  16. package/dist/analyzers/dispatcher.js.map +1 -1
  17. package/dist/analyzers/health.d.ts.map +1 -1
  18. package/dist/analyzers/health.js +11 -1
  19. package/dist/analyzers/health.js.map +1 -1
  20. package/dist/analyzers/licenses/gather.d.ts +1 -1
  21. package/dist/analyzers/licenses/gather.d.ts.map +1 -1
  22. package/dist/analyzers/licenses/gather.js +18 -2
  23. package/dist/analyzers/licenses/gather.js.map +1 -1
  24. package/dist/analyzers/quality/index.d.ts.map +1 -1
  25. package/dist/analyzers/quality/index.js +10 -2
  26. package/dist/analyzers/quality/index.js.map +1 -1
  27. package/dist/analyzers/security/aggregator.d.ts.map +1 -1
  28. package/dist/analyzers/security/aggregator.js +8 -48
  29. package/dist/analyzers/security/aggregator.js.map +1 -1
  30. package/dist/analyzers/security/gather.d.ts +4 -3
  31. package/dist/analyzers/security/gather.d.ts.map +1 -1
  32. package/dist/analyzers/security/gather.js +23 -5
  33. package/dist/analyzers/security/gather.js.map +1 -1
  34. package/dist/analyzers/security/index.d.ts +1 -1
  35. package/dist/analyzers/security/index.js +2 -2
  36. package/dist/analyzers/security/index.js.map +1 -1
  37. package/dist/analyzers/tools/autogen-header.js +1 -1
  38. package/dist/analyzers/tools/cloc.js +3 -3
  39. package/dist/analyzers/tools/cloc.js.map +1 -1
  40. package/dist/analyzers/tools/deadline.d.ts +67 -0
  41. package/dist/analyzers/tools/deadline.d.ts.map +1 -0
  42. package/dist/analyzers/tools/deadline.js +81 -0
  43. package/dist/analyzers/tools/deadline.js.map +1 -0
  44. package/dist/analyzers/tools/exclusions.d.ts +6 -6
  45. package/dist/analyzers/tools/exclusions.js +6 -6
  46. package/dist/analyzers/tools/fingerprint.d.ts +91 -26
  47. package/dist/analyzers/tools/fingerprint.d.ts.map +1 -1
  48. package/dist/analyzers/tools/fingerprint.js +111 -22
  49. package/dist/analyzers/tools/fingerprint.js.map +1 -1
  50. package/dist/analyzers/tools/generic.d.ts.map +1 -1
  51. package/dist/analyzers/tools/generic.js +7 -2
  52. package/dist/analyzers/tools/generic.js.map +1 -1
  53. package/dist/analyzers/tools/gitleaks.d.ts +24 -1
  54. package/dist/analyzers/tools/gitleaks.d.ts.map +1 -1
  55. package/dist/analyzers/tools/gitleaks.js +21 -12
  56. package/dist/analyzers/tools/gitleaks.js.map +1 -1
  57. package/dist/analyzers/tools/graphify.js +1 -1
  58. package/dist/analyzers/tools/jscpd.js +1 -1
  59. package/dist/analyzers/tools/jscpd.js.map +1 -1
  60. package/dist/analyzers/tools/lint-label.d.ts +29 -0
  61. package/dist/analyzers/tools/lint-label.d.ts.map +1 -0
  62. package/dist/analyzers/tools/lint-label.js +23 -0
  63. package/dist/analyzers/tools/lint-label.js.map +1 -0
  64. package/dist/analyzers/tools/nuget-package-reference.d.ts +6 -4
  65. package/dist/analyzers/tools/nuget-package-reference.d.ts.map +1 -1
  66. package/dist/analyzers/tools/nuget-package-reference.js +7 -5
  67. package/dist/analyzers/tools/nuget-package-reference.js.map +1 -1
  68. package/dist/analyzers/tools/report-date.d.ts +17 -0
  69. package/dist/analyzers/tools/report-date.d.ts.map +1 -0
  70. package/dist/analyzers/tools/report-date.js +26 -0
  71. package/dist/analyzers/tools/report-date.js.map +1 -0
  72. package/dist/analyzers/tools/runner.js +3 -3
  73. package/dist/analyzers/tools/runner.js.map +1 -1
  74. package/dist/analyzers/tools/vendored-advisor.js +1 -1
  75. package/dist/analyzers/tools/walk-paths.d.ts +1 -1
  76. package/dist/analyzers/tools/walk-paths.js +1 -1
  77. package/dist/analyzers/tools/walk-source-files.js +1 -1
  78. package/dist/analyzers/types.d.ts +6 -4
  79. package/dist/analyzers/types.d.ts.map +1 -1
  80. package/dist/baseline/baseline-file.d.ts +104 -0
  81. package/dist/baseline/baseline-file.d.ts.map +1 -0
  82. package/dist/baseline/baseline-file.js +110 -0
  83. package/dist/baseline/baseline-file.js.map +1 -0
  84. package/dist/baseline/check-renderers.d.ts +108 -0
  85. package/dist/baseline/check-renderers.d.ts.map +1 -0
  86. package/dist/baseline/check-renderers.js +379 -0
  87. package/dist/baseline/check-renderers.js.map +1 -0
  88. package/dist/baseline/check.d.ts +127 -0
  89. package/dist/baseline/check.d.ts.map +1 -0
  90. package/dist/baseline/check.js +462 -0
  91. package/dist/baseline/check.js.map +1 -0
  92. package/dist/baseline/content-hash.d.ts +83 -0
  93. package/dist/baseline/content-hash.d.ts.map +1 -0
  94. package/dist/baseline/content-hash.js +131 -0
  95. package/dist/baseline/content-hash.js.map +1 -0
  96. package/dist/baseline/create.d.ts +96 -0
  97. package/dist/baseline/create.d.ts.map +1 -0
  98. package/dist/baseline/create.js +339 -0
  99. package/dist/baseline/create.js.map +1 -0
  100. package/dist/baseline/entry-to-located.d.ts +35 -0
  101. package/dist/baseline/entry-to-located.d.ts.map +1 -0
  102. package/dist/baseline/entry-to-located.js +72 -0
  103. package/dist/baseline/entry-to-located.js.map +1 -0
  104. package/dist/baseline/finding-identity.d.ts +47 -0
  105. package/dist/baseline/finding-identity.d.ts.map +1 -0
  106. package/dist/baseline/finding-identity.js +292 -0
  107. package/dist/baseline/finding-identity.js.map +1 -0
  108. package/dist/baseline/git-aware-match.d.ts +146 -0
  109. package/dist/baseline/git-aware-match.d.ts.map +1 -0
  110. package/dist/baseline/git-aware-match.js +439 -0
  111. package/dist/baseline/git-aware-match.js.map +1 -0
  112. package/dist/baseline/policy.d.ts +171 -0
  113. package/dist/baseline/policy.d.ts.map +1 -0
  114. package/dist/baseline/policy.js +206 -0
  115. package/dist/baseline/policy.js.map +1 -0
  116. package/dist/baseline/producers/health.d.ts +30 -0
  117. package/dist/baseline/producers/health.d.ts.map +1 -0
  118. package/dist/baseline/producers/health.js +42 -0
  119. package/dist/baseline/producers/health.js.map +1 -0
  120. package/dist/baseline/producers/index.d.ts +164 -0
  121. package/dist/baseline/producers/index.d.ts.map +1 -0
  122. package/dist/baseline/producers/index.js +200 -0
  123. package/dist/baseline/producers/index.js.map +1 -0
  124. package/dist/baseline/producers/licenses.d.ts +23 -0
  125. package/dist/baseline/producers/licenses.d.ts.map +1 -0
  126. package/dist/baseline/producers/licenses.js +46 -0
  127. package/dist/baseline/producers/licenses.js.map +1 -0
  128. package/dist/baseline/producers/quality.d.ts +39 -0
  129. package/dist/baseline/producers/quality.d.ts.map +1 -0
  130. package/dist/baseline/producers/quality.js +84 -0
  131. package/dist/baseline/producers/quality.js.map +1 -0
  132. package/dist/baseline/producers/secret-hmac.d.ts +45 -0
  133. package/dist/baseline/producers/secret-hmac.d.ts.map +1 -0
  134. package/dist/baseline/producers/secret-hmac.js +70 -0
  135. package/dist/baseline/producers/secret-hmac.js.map +1 -0
  136. package/dist/baseline/producers/security.d.ts +59 -0
  137. package/dist/baseline/producers/security.d.ts.map +1 -0
  138. package/dist/baseline/producers/security.js +135 -0
  139. package/dist/baseline/producers/security.js.map +1 -0
  140. package/dist/baseline/producers/tests.d.ts +36 -0
  141. package/dist/baseline/producers/tests.d.ts.map +1 -0
  142. package/dist/baseline/producers/tests.js +69 -0
  143. package/dist/baseline/producers/tests.js.map +1 -0
  144. package/dist/baseline/salt.d.ts +45 -0
  145. package/dist/baseline/salt.d.ts.map +1 -0
  146. package/dist/baseline/salt.js +113 -0
  147. package/dist/baseline/salt.js.map +1 -0
  148. package/dist/baseline/show.d.ts +79 -0
  149. package/dist/baseline/show.d.ts.map +1 -0
  150. package/dist/baseline/show.js +233 -0
  151. package/dist/baseline/show.js.map +1 -0
  152. package/dist/baseline/types.d.ts +482 -0
  153. package/dist/baseline/types.d.ts.map +1 -0
  154. package/dist/baseline/types.js +53 -0
  155. package/dist/baseline/types.js.map +1 -0
  156. package/dist/cli.d.ts.map +1 -1
  157. package/dist/cli.js +395 -92
  158. package/dist/cli.js.map +1 -1
  159. package/dist/codebase-scanner.d.ts.map +1 -1
  160. package/dist/codebase-scanner.js +0 -1
  161. package/dist/codebase-scanner.js.map +1 -1
  162. package/dist/constants.d.ts.map +1 -1
  163. package/dist/constants.js +0 -4
  164. package/dist/constants.js.map +1 -1
  165. package/dist/detect.js +3 -3
  166. package/dist/detect.js.map +1 -1
  167. package/dist/doctor.d.ts.map +1 -1
  168. package/dist/doctor.js +22 -25
  169. package/dist/doctor.js.map +1 -1
  170. package/dist/fail-on.d.ts +84 -0
  171. package/dist/fail-on.d.ts.map +1 -0
  172. package/dist/fail-on.js +128 -0
  173. package/dist/fail-on.js.map +1 -0
  174. package/dist/generator.d.ts.map +1 -1
  175. package/dist/generator.js +2 -141
  176. package/dist/generator.js.map +1 -1
  177. package/dist/languages/capabilities/provider.d.ts +4 -4
  178. package/dist/languages/capabilities/types.d.ts +1 -1
  179. package/dist/languages/csharp.d.ts.map +1 -1
  180. package/dist/languages/csharp.js +15 -24
  181. package/dist/languages/csharp.js.map +1 -1
  182. package/dist/languages/go.d.ts.map +1 -1
  183. package/dist/languages/go.js +0 -15
  184. package/dist/languages/go.js.map +1 -1
  185. package/dist/languages/index.d.ts +4 -3
  186. package/dist/languages/index.d.ts.map +1 -1
  187. package/dist/languages/index.js +3 -2
  188. package/dist/languages/index.js.map +1 -1
  189. package/dist/languages/java.d.ts.map +1 -1
  190. package/dist/languages/java.js +0 -6
  191. package/dist/languages/java.js.map +1 -1
  192. package/dist/languages/kotlin.d.ts.map +1 -1
  193. package/dist/languages/kotlin.js +0 -11
  194. package/dist/languages/kotlin.js.map +1 -1
  195. package/dist/languages/python.d.ts.map +1 -1
  196. package/dist/languages/python.js +0 -15
  197. package/dist/languages/python.js.map +1 -1
  198. package/dist/languages/ruby.d.ts.map +1 -1
  199. package/dist/languages/ruby.js +0 -6
  200. package/dist/languages/ruby.js.map +1 -1
  201. package/dist/languages/rust.d.ts.map +1 -1
  202. package/dist/languages/rust.js +0 -4
  203. package/dist/languages/rust.js.map +1 -1
  204. package/dist/languages/types.d.ts +9 -35
  205. package/dist/languages/types.d.ts.map +1 -1
  206. package/dist/languages/typescript.d.ts.map +1 -1
  207. package/dist/languages/typescript.js +26 -4
  208. package/dist/languages/typescript.js.map +1 -1
  209. package/dist/lib.d.ts +2 -3
  210. package/dist/lib.d.ts.map +1 -1
  211. package/dist/lib.js +3 -6
  212. package/dist/lib.js.map +1 -1
  213. package/dist/prompts.d.ts.map +1 -1
  214. package/dist/prompts.js +0 -10
  215. package/dist/prompts.js.map +1 -1
  216. package/dist/report-schema.d.ts +42 -0
  217. package/dist/report-schema.d.ts.map +1 -0
  218. package/dist/report-schema.js +54 -0
  219. package/dist/report-schema.js.map +1 -0
  220. package/dist/ship-installers.d.ts +106 -0
  221. package/dist/ship-installers.d.ts.map +1 -0
  222. package/dist/ship-installers.js +415 -0
  223. package/dist/ship-installers.js.map +1 -0
  224. package/dist/types.d.ts +0 -4
  225. package/dist/types.d.ts.map +1 -1
  226. package/dist/update.d.ts.map +1 -1
  227. package/dist/update.js +0 -4
  228. package/dist/update.js.map +1 -1
  229. package/package.json +17 -11
  230. package/templates/.claude/agents/onboarding.md +5 -4
  231. package/templates/.claude/agents-available/codebase-explorer.md +1 -1
  232. package/templates/.claude/agents-available/debugger.md +2 -2
  233. package/templates/.claude/agents-available/health-auditor.md +2 -2
  234. package/templates/.claude/commands/doctor.md +20 -12
  235. package/templates/.claude/skills/build/SKILL.md.template +22 -30
  236. package/templates/.claude/skills/deploy/SKILL.md.template +5 -25
  237. package/templates/.claude/skills/doctor/SKILL.md +24 -47
  238. package/templates/.claude/skills/gcloud/SKILL.md +5 -5
  239. package/templates/.claude/skills/learned/SKILL.md +1 -1
  240. package/templates/.claude/skills/pulumi/SKILL.md +2 -2
  241. package/templates/.claude/skills/quality/SKILL.md.template +4 -23
  242. package/templates/.claude/skills/review/SKILL.md.template +4 -3
  243. package/templates/.claude/skills/scaffold/SKILL.md.template +5 -15
  244. package/templates/.claude/skills/secrets/SKILL.md +20 -21
  245. package/templates/.claude/skills/session/SKILL.md +20 -31
  246. package/templates/.claude/skills/test/SKILL.md.template +1 -7
  247. package/templates/.devcontainer/devcontainer.json +81 -0
  248. package/templates/.devcontainer/install-agent-clis.sh +42 -0
  249. package/templates/.devcontainer/post-create.sh +67 -0
  250. package/templates/.githooks/pre-commit +55 -0
  251. package/templates/.githooks/pre-push +63 -0
  252. package/templates/.github/workflows/dxkit-baseline-refresh.yml +78 -0
  253. package/templates/.github/workflows/dxkit-guardrails.yml +98 -0
  254. package/templates/CLAUDE.md.template +62 -196
  255. package/dist/project-yaml.d.ts +0 -13
  256. package/dist/project-yaml.d.ts.map +0 -1
  257. package/dist/project-yaml.js +0 -188
  258. package/dist/project-yaml.js.map +0 -1
  259. package/templates/.ai/README.md +0 -117
  260. package/templates/.ai/prompts/execution-prompt.md +0 -9
  261. package/templates/.ai/prompts/planning-prompt.md +0 -18
  262. package/templates/.ai/prompts/session-end-template.md +0 -182
  263. package/templates/.ai/prompts/session-end.md +0 -132
  264. package/templates/.ai/prompts/session-start.md +0 -109
  265. package/templates/.ai/prompts/step-by-step.md +0 -113
  266. package/templates/.ai/sessions/.gitkeep +0 -0
  267. package/templates/.claude/commands/setup-pr-review.md +0 -72
  268. package/templates/.devcontainer/Dockerfile.dev.template +0 -89
  269. package/templates/.devcontainer/devcontainer.json.template +0 -184
  270. package/templates/.devcontainer/docker-compose.yml.template +0 -105
  271. package/templates/.devcontainer/init-scripts/01-init.sql.template +0 -12
  272. package/templates/.devcontainer/post-create.sh.template +0 -298
  273. package/templates/.github/workflows/ci.yml.template +0 -399
  274. package/templates/.github/workflows/quality.yml.template +0 -376
  275. package/templates/.pre-commit-config.yaml.template +0 -106
  276. package/templates/.project/config/edit_config.py +0 -275
  277. package/templates/.project/config/project_config.py +0 -894
  278. package/templates/.project/scripts/codegen/generate-all.sh +0 -20
  279. package/templates/.project/scripts/codegen/validate-all.sh +0 -17
  280. package/templates/.project/scripts/docs/generate-all.sh +0 -30
  281. package/templates/.project/scripts/docs/serve.sh +0 -20
  282. package/templates/.project/scripts/quality/fix-all.sh +0 -138
  283. package/templates/.project/scripts/quality/lint-go.sh +0 -34
  284. package/templates/.project/scripts/quality/lint-python.sh +0 -54
  285. package/templates/.project/scripts/quality/run-all.sh +0 -497
  286. package/templates/.project/scripts/session/commit.sh +0 -70
  287. package/templates/.project/scripts/session/create-pr.sh +0 -165
  288. package/templates/.project/scripts/session/end.sh +0 -207
  289. package/templates/.project/scripts/session/start.sh +0 -233
  290. package/templates/.project/scripts/setup/doctor.sh +0 -404
  291. package/templates/.project/scripts/setup/interactive-setup.sh +0 -585
  292. package/templates/.project/scripts/sync/sync-template.sh +0 -328
  293. package/templates/.project/scripts/test/run-all.sh +0 -179
  294. package/templates/.project/scripts/test/run-quick.sh +0 -25
  295. package/templates/Makefile +0 -514
  296. package/templates/config/versions.yaml +0 -57
  297. package/templates/configs/go/.golangci.yml.template +0 -172
  298. package/templates/configs/go/go.mod.template +0 -15
  299. package/templates/configs/java/README.md +0 -6
  300. package/templates/configs/kotlin/README.md +0 -6
  301. package/templates/configs/node/package.json.template +0 -67
  302. package/templates/configs/node/tsconfig.json.template +0 -53
  303. package/templates/configs/python/pyproject.toml.template +0 -92
  304. package/templates/configs/python/pytest.ini.template +0 -64
  305. package/templates/configs/python/ruff.toml.template +0 -79
  306. package/templates/configs/ruby/README.md +0 -6
  307. package/templates/configs/rust/Cargo.toml.template +0 -51
  308. package/templates/configs/shared/.editorconfig +0 -67
  309. package/templates/scripts/validate-templates.sh +0 -449
@@ -1,449 +0,0 @@
1
- #!/bin/bash
2
- # validate-templates.sh - Validate template files for syntax and processing
3
- #
4
- # This script:
5
- # 1. Processes templates with test values
6
- # 2. Validates YAML, TOML, and JSON syntax
7
- # 3. Checks for unprocessed template variables
8
-
9
- set -e
10
-
11
- CYAN='\033[36m'
12
- GREEN='\033[32m'
13
- YELLOW='\033[33m'
14
- RED='\033[31m'
15
- RESET='\033[0m'
16
-
17
- TEMPLATE_DIR=".template"
18
- TEST_OUTPUT_DIR="/tmp/template-validation-$$"
19
- ERRORS=0
20
- WARNINGS=0
21
-
22
- # Cleanup on exit
23
- cleanup() {
24
- rm -rf "$TEST_OUTPUT_DIR"
25
- }
26
- trap cleanup EXIT
27
-
28
- mkdir -p "$TEST_OUTPUT_DIR"
29
-
30
- echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
31
- echo -e "${CYAN} TEMPLATE VALIDATION${RESET}"
32
- echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
33
- echo ""
34
-
35
- # Check available validation tools
36
- echo -e "${CYAN}Checking validation tools...${RESET}"
37
- TOOLS_AVAILABLE=""
38
- command -v yq &> /dev/null && TOOLS_AVAILABLE="$TOOLS_AVAILABLE yq"
39
- command -v jq &> /dev/null && TOOLS_AVAILABLE="$TOOLS_AVAILABLE jq"
40
- command -v python3 &> /dev/null && TOOLS_AVAILABLE="$TOOLS_AVAILABLE python3"
41
- if [ -n "$TOOLS_AVAILABLE" ]; then
42
- echo -e " Available:${GREEN}$TOOLS_AVAILABLE${RESET}"
43
- else
44
- echo -e " ${YELLOW}Warning: No validation tools found. Install yq, jq, or python3 for best results.${RESET}"
45
- fi
46
- echo ""
47
-
48
- # ============================================================================
49
- # Test Configuration
50
- # ============================================================================
51
-
52
- # Set test values for all template variables
53
- export PROJECT_NAME="test-project"
54
- export PROJECT_NAME_SNAKE="test_project"
55
- export PROJECT_NAME_KEBAB="test-project"
56
- export PROJECT_DESCRIPTION="A test project for template validation"
57
- export GITHUB_ORG="testorg"
58
- export PYTHON_VERSION="3.12"
59
- export GO_VERSION="1.24.0"
60
- export NODE_VERSION="20"
61
- export RUST_VERSION="stable"
62
- export POSTGRES_VERSION="16"
63
- export REDIS_VERSION="7"
64
- export DB_NAME="test_db"
65
- export DB_USER="test_user"
66
- export DB_PASSWORD="test_pass"
67
-
68
- # Include all features for validation
69
- export INCLUDE_PYTHON="true"
70
- export INCLUDE_GO="true"
71
- export INCLUDE_NODE="true"
72
- export INCLUDE_NEXTJS="true"
73
- export INCLUDE_RUST="true"
74
- export INCLUDE_POSTGRES="true"
75
- export INCLUDE_REDIS="true"
76
- export INCLUDE_AI_SESSIONS="true"
77
- export INCLUDE_AI_PROMPTS="true"
78
- export INCLUDE_PRECOMMIT="true"
79
- export INCLUDE_DOCKER="true"
80
- export INCLUDE_PULUMI="false"
81
- export INCLUDE_GH_CLI="true"
82
- export INCLUDE_CLAUDE_CODE="true"
83
- export INCLUDE_INFISICAL="false"
84
- export INCLUDE_GCLOUD="true"
85
- export INCLUDE_QUALITY_CHECKS="true"
86
- export COVERAGE_THRESHOLD="80"
87
-
88
- # ============================================================================
89
- # Helper Functions
90
- # ============================================================================
91
-
92
- # Use the Python template engine for processing
93
- # This ensures validation uses the exact same logic as actual template processing
94
- TEMPLATE_ENGINE="scripts/bootstrap/template_engine.py"
95
-
96
- if [ ! -f "$TEMPLATE_ENGINE" ]; then
97
- echo -e "${RED}Error: Template engine not found at $TEMPLATE_ENGINE${RESET}"
98
- exit 1
99
- fi
100
-
101
- process_test_template() {
102
- local input_file="$1"
103
- local output_file="$2"
104
-
105
- mkdir -p "$(dirname "$output_file")"
106
-
107
- # Use Python template engine (same as apply-config.sh)
108
- if ! python3 "$TEMPLATE_ENGINE" "$input_file" "$output_file" 2>/dev/null; then
109
- return 1
110
- fi
111
- }
112
-
113
- check_unprocessed_variables() {
114
- local file="$1"
115
- # Match {{VAR}} but not ${{ }} (GitHub Actions expressions)
116
- # Our template vars are {{WORD}} or {{#IF_X}}/{{/IF_X}}
117
- local result=$(grep -oE '\{\{[A-Z_#/][A-Z_0-9]*\}\}' "$file" 2>/dev/null || true)
118
- if [ -n "$result" ]; then
119
- echo -e " ${RED}ERROR${RESET}: Unprocessed template variables found:"
120
- echo "$result" | while read -r var; do
121
- echo " - $var"
122
- done
123
- return 1
124
- fi
125
- return 0
126
- }
127
-
128
- validate_yaml() {
129
- local file="$1"
130
- local error_msg=""
131
-
132
- # Try yq first (fastest, most reliable)
133
- if command -v yq &> /dev/null; then
134
- error_msg=$(yq eval '.' "$file" 2>&1)
135
- if [ $? -eq 0 ]; then
136
- return 0
137
- fi
138
- echo ""
139
- echo -e " ${RED}YAML Error:${RESET} $error_msg"
140
- return 1
141
- fi
142
-
143
- # Try Python yaml module
144
- if command -v python3 &> /dev/null; then
145
- error_msg=$(python3 -c "
146
- import yaml
147
- import sys
148
- try:
149
- with open('$file') as f:
150
- yaml.safe_load(f)
151
- except yaml.YAMLError as e:
152
- print(str(e), file=sys.stderr)
153
- sys.exit(1)
154
- " 2>&1)
155
- if [ $? -eq 0 ]; then
156
- return 0
157
- fi
158
- echo ""
159
- echo -e " ${RED}YAML Error:${RESET} $error_msg"
160
- return 1
161
- fi
162
-
163
- # Fallback: basic syntax check (no detailed errors)
164
- if ! grep -qE '^\s*[a-zA-Z_-]+:\s*$|^\s*[a-zA-Z_-]+:\s+\S' "$file" 2>/dev/null; then
165
- return 1
166
- fi
167
- return 0
168
- }
169
-
170
- validate_toml() {
171
- local file="$1"
172
- local error_msg=""
173
-
174
- if command -v python3 &> /dev/null; then
175
- # Try tomllib (Python 3.11+) or tomli
176
- error_msg=$(python3 -c "
177
- import sys
178
- try:
179
- import tomllib
180
- with open('$file', 'rb') as f:
181
- tomllib.load(f)
182
- except ImportError:
183
- try:
184
- import tomli
185
- with open('$file', 'rb') as f:
186
- tomli.load(f)
187
- except ImportError:
188
- # No TOML parser available, skip validation
189
- sys.exit(0)
190
- except Exception as e:
191
- print(str(e), file=sys.stderr)
192
- sys.exit(1)
193
- " 2>&1)
194
- if [ $? -eq 0 ]; then
195
- return 0
196
- fi
197
- echo ""
198
- echo -e " ${RED}TOML Error:${RESET} $error_msg"
199
- return 1
200
- fi
201
- # Fallback: no validation available
202
- return 0
203
- }
204
-
205
- validate_json() {
206
- local file="$1"
207
- local error_msg=""
208
-
209
- # Try jq first for strict JSON
210
- if command -v jq &> /dev/null; then
211
- error_msg=$(jq '.' "$file" 2>&1)
212
- if [ $? -eq 0 ]; then
213
- return 0
214
- fi
215
- # If jq fails, it might be JSONC (JSON with comments), try Python
216
- fi
217
-
218
- if command -v python3 &> /dev/null; then
219
- # Handle JSONC (JSON with Comments) - strip comments before parsing
220
- error_msg=$(python3 -c "
221
- import json
222
- import re
223
- import sys
224
-
225
- with open('$file', 'r') as f:
226
- lines = f.readlines()
227
-
228
- # Process line by line to safely handle comments
229
- cleaned_lines = []
230
- for line in lines:
231
- stripped = line.strip()
232
- # Skip full-line block comments
233
- if stripped.startswith('/*') and stripped.endswith('*/'):
234
- continue
235
- # Skip line comments at start
236
- if re.match(r'^\s*//', stripped):
237
- continue
238
- cleaned_lines.append(line)
239
-
240
- content = ''.join(cleaned_lines)
241
- # Remove trailing commas before } or ]
242
- content = re.sub(r',\s*([}\]])', r'\1', content)
243
-
244
- try:
245
- json.loads(content)
246
- except json.JSONDecodeError as e:
247
- print(f'Line {e.lineno}, Column {e.colno}: {e.msg}', file=sys.stderr)
248
- sys.exit(1)
249
- " 2>&1)
250
- if [ $? -eq 0 ]; then
251
- return 0
252
- fi
253
- echo ""
254
- echo -e " ${RED}JSON Error:${RESET} $error_msg"
255
- return 1
256
- fi
257
-
258
- echo ""
259
- echo -e " ${YELLOW}Warning:${RESET} No JSON validator available (install jq or python3)"
260
- return 1
261
- }
262
-
263
- # ============================================================================
264
- # Validation Tests
265
- # ============================================================================
266
-
267
- echo -e "${CYAN}Processing and validating templates...${RESET}"
268
- echo ""
269
-
270
- # Test YAML templates
271
- yaml_templates=(
272
- ".template/.github/workflows/ci.yml.template"
273
- ".template/.github/workflows/quality.yml.template"
274
- ".template/.pre-commit-config.yaml.template"
275
- ".template/configs/go/.golangci.yml.template"
276
- )
277
-
278
- for template in "${yaml_templates[@]}"; do
279
- if [ -f "$template" ]; then
280
- output_file="$TEST_OUTPUT_DIR/$(basename "$template" .template)"
281
- process_test_template "$template" "$output_file"
282
-
283
- echo -n " Testing $(basename "$template")... "
284
-
285
- if ! check_unprocessed_variables "$output_file"; then
286
- ((ERRORS++))
287
- continue
288
- fi
289
-
290
- if validate_yaml "$output_file"; then
291
- echo -e "${GREEN}PASS${RESET}"
292
- else
293
- echo -e "${RED}FAIL${RESET} (YAML syntax error)"
294
- ((ERRORS++))
295
- fi
296
- else
297
- echo -e " ${YELLOW}SKIP${RESET}: $template (not found)"
298
- ((WARNINGS++))
299
- fi
300
- done
301
-
302
- echo ""
303
-
304
- # Test TOML templates
305
- toml_templates=(
306
- ".template/configs/python/pyproject.toml.template"
307
- ".template/configs/python/ruff.toml.template"
308
- ".template/configs/rust/Cargo.toml.template"
309
- )
310
-
311
- for template in "${toml_templates[@]}"; do
312
- if [ -f "$template" ]; then
313
- output_file="$TEST_OUTPUT_DIR/$(basename "$template" .template)"
314
- process_test_template "$template" "$output_file"
315
-
316
- echo -n " Testing $(basename "$template")... "
317
-
318
- if ! check_unprocessed_variables "$output_file"; then
319
- ((ERRORS++))
320
- continue
321
- fi
322
-
323
- if validate_toml "$output_file"; then
324
- echo -e "${GREEN}PASS${RESET}"
325
- else
326
- echo -e "${RED}FAIL${RESET} (TOML syntax error)"
327
- ((ERRORS++))
328
- fi
329
- else
330
- echo -e " ${YELLOW}SKIP${RESET}: $template (not found)"
331
- ((WARNINGS++))
332
- fi
333
- done
334
-
335
- echo ""
336
-
337
- # Test JSON templates
338
- json_templates=(
339
- ".template/configs/node/package.json.template"
340
- ".template/configs/node/tsconfig.json.template"
341
- )
342
-
343
- for template in "${json_templates[@]}"; do
344
- if [ -f "$template" ]; then
345
- output_file="$TEST_OUTPUT_DIR/$(basename "$template" .template)"
346
- process_test_template "$template" "$output_file"
347
-
348
- echo -n " Testing $(basename "$template")... "
349
-
350
- if ! check_unprocessed_variables "$output_file"; then
351
- ((ERRORS++))
352
- continue
353
- fi
354
-
355
- if validate_json "$output_file"; then
356
- echo -e "${GREEN}PASS${RESET}"
357
- else
358
- echo -e "${RED}FAIL${RESET} (JSON syntax error)"
359
- ((ERRORS++))
360
- fi
361
- else
362
- echo -e " ${YELLOW}SKIP${RESET}: $template (not found)"
363
- ((WARNINGS++))
364
- fi
365
- done
366
-
367
- echo ""
368
-
369
- # Test INI templates (basic validation)
370
- ini_templates=(
371
- ".template/configs/python/pytest.ini.template"
372
- )
373
-
374
- for template in "${ini_templates[@]}"; do
375
- if [ -f "$template" ]; then
376
- output_file="$TEST_OUTPUT_DIR/$(basename "$template" .template)"
377
- process_test_template "$template" "$output_file"
378
-
379
- echo -n " Testing $(basename "$template")... "
380
-
381
- if ! check_unprocessed_variables "$output_file"; then
382
- ((ERRORS++))
383
- continue
384
- fi
385
-
386
- # INI files don't have strict validation, just check for unprocessed vars
387
- echo -e "${GREEN}PASS${RESET}"
388
- else
389
- echo -e " ${YELLOW}SKIP${RESET}: $template (not found)"
390
- ((WARNINGS++))
391
- fi
392
- done
393
-
394
- echo ""
395
-
396
- # Test Go module template
397
- go_templates=(
398
- ".template/configs/go/go.mod.template"
399
- )
400
-
401
- for template in "${go_templates[@]}"; do
402
- if [ -f "$template" ]; then
403
- output_file="$TEST_OUTPUT_DIR/$(basename "$template" .template)"
404
- process_test_template "$template" "$output_file"
405
-
406
- echo -n " Testing $(basename "$template")... "
407
-
408
- if ! check_unprocessed_variables "$output_file"; then
409
- ((ERRORS++))
410
- continue
411
- fi
412
-
413
- # Check go.mod has valid go version format (X.Y not X.Y.Z)
414
- if grep -qE '^go [0-9]+\.[0-9]+$' "$output_file"; then
415
- echo -e "${GREEN}PASS${RESET}"
416
- else
417
- echo -e "${RED}FAIL${RESET} (Invalid go version format)"
418
- ((ERRORS++))
419
- fi
420
- else
421
- echo -e " ${YELLOW}SKIP${RESET}: $template (not found)"
422
- ((WARNINGS++))
423
- fi
424
- done
425
-
426
- echo ""
427
-
428
- # ============================================================================
429
- # Results
430
- # ============================================================================
431
-
432
- echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
433
- if [ $ERRORS -eq 0 ]; then
434
- echo -e "${GREEN} VALIDATION PASSED${RESET}"
435
- echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
436
- echo ""
437
- echo " All templates validated successfully!"
438
- [ $WARNINGS -gt 0 ] && echo " (${WARNINGS} warnings - some templates not found)"
439
- echo ""
440
- exit 0
441
- else
442
- echo -e "${RED} VALIDATION FAILED${RESET}"
443
- echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
444
- echo ""
445
- echo " ${ERRORS} error(s) found"
446
- [ $WARNINGS -gt 0 ] && echo " ${WARNINGS} warning(s)"
447
- echo ""
448
- exit 1
449
- fi