@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.
- package/bin/tetra-init-tests.js +185 -66
- package/bin/tetra-init.js +67 -3
- package/bin/tetra-setup.js +152 -30
- package/bin/tetra-setup.js.tmp +0 -0
- package/bin/tetra-test-audit.js +83 -0
- package/lib/audits/test-coverage-audit.js +646 -0
- package/lib/checks/health/index.js +2 -1
- package/lib/checks/health/rpc-param-mismatch.js +21 -0
- package/lib/checks/health/scanner.js +4 -2
- package/lib/checks/health/sentry-monitoring.js +167 -0
- package/lib/checks/health/types.js +1 -1
- package/lib/checks/stability/ci-pipeline.js +21 -6
- package/lib/templates/hooks/doppler-guard.sh +30 -0
- package/lib/templates/hooks/worktree-guard.sh +75 -0
- package/lib/templates/tests/02-crud-resources.test.ts.tmpl +135 -0
- package/lib/templates/tests/03-permissions.test.ts.tmpl +110 -0
- package/lib/templates/tests/04-business-flows.test.ts.tmpl +64 -0
- package/lib/templates/tests/05-security.test.ts.tmpl +82 -0
- package/lib/templates/tests/global-setup.ts.tmpl +73 -0
- package/package.json +3 -2
- package/lib/templates/tests/07-security.test.ts.tmpl +0 -93
|
@@ -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()
|