@soulbatical/tetra-dev-toolkit 1.20.11 → 1.20.13

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.
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Tetra Test Audit — Discover test coverage gaps across a Tetra project.
5
+ *
6
+ * Scans FeatureConfigs, routes, frontend pages, and test files to find:
7
+ * - Features without CRUD tests
8
+ * - API endpoints without auth wall tests
9
+ * - Frontend pages without e2e specs
10
+ * - CI pipeline gaps
11
+ *
12
+ * Usage:
13
+ * tetra-test-audit # Audit current project
14
+ * tetra-test-audit --path /path/to/project # Audit specific project
15
+ * tetra-test-audit --json # JSON output for CI
16
+ * tetra-test-audit --ci # GitHub Actions annotations
17
+ * tetra-test-audit --strict # Fail on any gap
18
+ *
19
+ * Exit codes:
20
+ * 0 = all critical checks pass (or no gaps in --strict mode)
21
+ * 1 = gaps found
22
+ */
23
+
24
+ import { program } from 'commander'
25
+ import chalk from 'chalk'
26
+ import {
27
+ runTestCoverageAudit,
28
+ formatReport,
29
+ formatReportJSON,
30
+ formatCIAnnotations,
31
+ } from '../lib/audits/test-coverage-audit.js'
32
+
33
+ program
34
+ .name('tetra-test-audit')
35
+ .description('Audit test coverage gaps across a Tetra project')
36
+ .version('1.0.0')
37
+ .option('--path <dir>', 'Project root directory (default: cwd)')
38
+ .option('--json', 'JSON output for CI')
39
+ .option('--ci', 'GitHub Actions annotations for failures')
40
+ .option('--strict', 'Fail on any gap (default: only fail on critical gaps like missing auth tests)')
41
+ .action(async (options) => {
42
+ try {
43
+ const projectRoot = options.path || process.cwd()
44
+
45
+ if (!options.json) {
46
+ console.log(chalk.gray('\n Scanning project...'))
47
+ }
48
+
49
+ const report = await runTestCoverageAudit(projectRoot)
50
+
51
+ // Output
52
+ if (options.json) {
53
+ console.log(formatReportJSON(report))
54
+ } else {
55
+ console.log(formatReport(report, chalk))
56
+
57
+ if (options.ci) {
58
+ const annotations = formatCIAnnotations(report)
59
+ if (annotations) {
60
+ console.log(annotations)
61
+ }
62
+ }
63
+ }
64
+
65
+ // Exit code
66
+ const { summary } = report
67
+ if (options.strict) {
68
+ // Strict: fail on any gap
69
+ process.exit(summary.totalGaps > 0 ? 1 : 0)
70
+ } else {
71
+ // Default: only fail on critical gaps (missing auth wall tests)
72
+ process.exit(summary.criticalGaps > 0 ? 1 : 0)
73
+ }
74
+ } catch (err) {
75
+ console.error(chalk.red(`\n ERROR: ${err.message}\n`))
76
+ if (!options.json) {
77
+ console.error(chalk.gray(` ${err.stack}`))
78
+ }
79
+ process.exit(1)
80
+ }
81
+ })
82
+
83
+ program.parse()