spec-up-t-healthcheck 1.0.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.
@@ -0,0 +1,145 @@
1
+ /**
2
+ * @fileoverview Health checker module for spec-up-t-healthcheck
3
+ *
4
+ * This module provides a unified interface for health checking functionality.
5
+ * It acts as a facade for the modular health check system, providing access
6
+ * to individual checks and the orchestrator.
7
+ *
8
+ * @author spec-up-t-healthcheck
9
+ */
10
+
11
+ // Import the modular components
12
+ import {
13
+ createHealthCheckResult as utilsCreateHealthCheckResult,
14
+ calculateSummary,
15
+ isValidHealthCheckResult,
16
+ createErrorResult,
17
+ HEALTH_CHECK_STATUSES
18
+ } from './health-check-utils.js';
19
+
20
+ import {
21
+ globalRegistry,
22
+ HealthCheckRegistry,
23
+ registerHealthCheck,
24
+ getHealthCheck,
25
+ autoDiscoverHealthChecks
26
+ } from './health-check-registry.js';
27
+
28
+ import {
29
+ HealthCheckOrchestrator,
30
+ globalOrchestrator,
31
+ runHealthChecks as orchestratorRunHealthChecks
32
+ } from './health-check-orchestrator.js';
33
+
34
+ // Import individual check functions directly
35
+ import { checkPackageJson } from './checks/package-json.js';
36
+ import { checkSpecFiles } from './checks/spec-files.js';
37
+ import { checkSpecsJson } from './checks/specsjson.js';
38
+ import { checkExternalSpecsUrls } from './checks/external-specs-urls.js';
39
+ import { checkGitignore } from './checks/gitignore.js';
40
+
41
+ // Re-export types for backward compatibility
42
+ /**
43
+ * @typedef {import('./health-check-utils.js').HealthCheckResult} HealthCheckResult
44
+ */
45
+
46
+ /**
47
+ * @typedef {import('./health-check-utils.js').HealthCheckSummary} HealthCheckSummary
48
+ */
49
+
50
+ /**
51
+ * @typedef {import('./health-check-utils.js').HealthCheckReport} HealthCheckReport
52
+ */
53
+
54
+ /**
55
+ * Creates a standardized health check result object.
56
+ *
57
+ * @param {string} check - The identifier/name of the health check being performed
58
+ * @param {'pass'|'fail'|'warn'|'skip'} status - The status of the health check
59
+ * @param {string} message - A human-readable message describing the result
60
+ * @param {Object} [details={}] - Optional additional details about the check
61
+ * @returns {HealthCheckResult} A standardized health check result object
62
+ *
63
+ * @example
64
+ * ```javascript
65
+ * const result = createHealthCheckResult(
66
+ * 'package-json',
67
+ * 'pass',
68
+ * 'package.json is valid',
69
+ * { packageData: { name: 'my-spec', version: '1.0.0' } }
70
+ * );
71
+ * ```
72
+ */
73
+ export function createHealthCheckResult(check, status, message, details = {}) {
74
+ return utilsCreateHealthCheckResult(check, status, message, details);
75
+ }
76
+
77
+ // Re-export the actual check functions directly
78
+ export { checkPackageJson, checkSpecFiles, checkSpecsJson, checkExternalSpecsUrls, checkGitignore };
79
+
80
+ /**
81
+ * Runs a comprehensive health check suite on a specification repository.
82
+ *
83
+ * This is the main entry point for performing health checks using the
84
+ * modular orchestrator system.
85
+ *
86
+ * @param {import('./providers.js').Provider} provider - The provider instance for repository access
87
+ * @param {Object} [options={}] - Configuration options for the health check run
88
+ * @param {string[]} [options.checks] - Array of check names to run (defaults to all registered checks)
89
+ * @param {boolean} [options.continueOnError=true] - Whether to continue on failures
90
+ * @param {number} [options.timeout=30000] - Timeout for individual checks
91
+ * @param {boolean} [options.parallel=false] - Whether to run checks in parallel
92
+ * @returns {Promise<HealthCheckReport>} Complete health check report with results and summary
93
+ *
94
+ * @example
95
+ * ```javascript
96
+ * const provider = createLocalProvider('/path/to/repo');
97
+ *
98
+ * // Run all registered checks (default)
99
+ * const report = await runHealthChecks(provider);
100
+ *
101
+ * // Run specific checks only
102
+ * const customReport = await runHealthChecks(provider, {
103
+ * checks: ['package-json']
104
+ * });
105
+ *
106
+ * // Use advanced features
107
+ * const advancedReport = await runHealthChecks(provider, {
108
+ * parallel: true,
109
+ * timeout: 10000,
110
+ * categories: ['configuration']
111
+ * });
112
+ *
113
+ * console.log(`Health score: ${report.summary.score}%`);
114
+ * console.log(`${report.summary.passed}/${report.summary.total} checks passed`);
115
+ * ```
116
+ */
117
+ export async function runHealthChecks(provider, options = {}) {
118
+ // If no specific checks are requested, the orchestrator will automatically
119
+ // run all registered checks via registry.getExecutionOrder()
120
+ // No need to specify defaults here - they come from the registry
121
+ return await orchestratorRunHealthChecks(provider, options);
122
+ }
123
+
124
+ // Re-export modular components for advanced usage
125
+ export {
126
+ // Utils
127
+ calculateSummary,
128
+ isValidHealthCheckResult,
129
+ createErrorResult,
130
+ HEALTH_CHECK_STATUSES,
131
+
132
+ // Registry
133
+ HealthCheckRegistry,
134
+ globalRegistry,
135
+ registerHealthCheck,
136
+ getHealthCheck,
137
+ autoDiscoverHealthChecks,
138
+
139
+ // Orchestrator
140
+ HealthCheckOrchestrator,
141
+ globalOrchestrator
142
+ };
143
+
144
+ // Export default function for convenience
145
+ export default runHealthChecks;