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.
- package/README.md +216 -0
- package/bin/cli.js +193 -0
- package/bin/demo-html.js +186 -0
- package/bin/simple-test.js +79 -0
- package/lib/checks/external-specs-urls.js +484 -0
- package/lib/checks/gitignore.js +350 -0
- package/lib/checks/package-json.js +518 -0
- package/lib/checks/spec-files.js +263 -0
- package/lib/checks/specsjson.js +361 -0
- package/lib/file-opener.js +127 -0
- package/lib/formatters.js +176 -0
- package/lib/health-check-orchestrator.js +413 -0
- package/lib/health-check-registry.js +396 -0
- package/lib/health-check-utils.js +234 -0
- package/lib/health-checker.js +145 -0
- package/lib/html-formatter.js +626 -0
- package/lib/index.js +123 -0
- package/lib/providers.js +184 -0
- package/lib/web.js +70 -0
- package/package.json +91 -0
package/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Spec-Up-T Health Check Tool
|
|
2
|
+
|
|
3
|
+
A modular npm tool for performing comprehensive health checks on spec-up-t repositories. Works across multiple environments: Node.js, browsers, and CLI with beautiful HTML reports.
|
|
4
|
+
|
|
5
|
+
## š Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install globally
|
|
9
|
+
npm install -g spec-up-t-healthcheck
|
|
10
|
+
|
|
11
|
+
# Basic health check
|
|
12
|
+
npx spec-up-t-healthcheck check ./my-spec-repo
|
|
13
|
+
|
|
14
|
+
# Generate HTML report (opens in browser)
|
|
15
|
+
npx spec-up-t-healthcheck check ./my-spec-repo --format html
|
|
16
|
+
|
|
17
|
+
# Save to specific file
|
|
18
|
+
npx spec-up-t-healthcheck check . --format html --output my-report.html
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## š¦ Installation & Usage
|
|
22
|
+
|
|
23
|
+
### CLI Usage
|
|
24
|
+
```bash
|
|
25
|
+
# Text output (default)
|
|
26
|
+
spec-up-t-healthcheck check .
|
|
27
|
+
|
|
28
|
+
# JSON output
|
|
29
|
+
spec-up-t-healthcheck check . --format json
|
|
30
|
+
|
|
31
|
+
# HTML report with Bootstrap styling
|
|
32
|
+
spec-up-t-healthcheck check . --format html
|
|
33
|
+
|
|
34
|
+
# Specific checks only
|
|
35
|
+
spec-up-t-healthcheck check . --checks package-json,spec-files
|
|
36
|
+
|
|
37
|
+
# List available checks
|
|
38
|
+
spec-up-t-healthcheck list-checks
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Direct API Usage (Recommended)
|
|
42
|
+
|
|
43
|
+
For maximum control and integration into your own tools:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// Basic usage with runHealthChecks
|
|
47
|
+
(async () => {
|
|
48
|
+
const { createProvider, runHealthChecks } = await import('spec-up-t-healthcheck');
|
|
49
|
+
const provider = createProvider('.');
|
|
50
|
+
const results = await runHealthChecks(provider, {});
|
|
51
|
+
console.log("š ~ Healthcheck results:", results);
|
|
52
|
+
})().catch(console.error);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// Advanced usage with specific checks and formatting
|
|
57
|
+
(async () => {
|
|
58
|
+
const {
|
|
59
|
+
createProvider,
|
|
60
|
+
runHealthChecks,
|
|
61
|
+
formatResultsAsHtml,
|
|
62
|
+
formatResultsAsText
|
|
63
|
+
} = await import('spec-up-t-healthcheck');
|
|
64
|
+
|
|
65
|
+
const provider = createProvider('./my-project');
|
|
66
|
+
const results = await runHealthChecks(provider, {
|
|
67
|
+
checks: ['package-json', 'spec-files']
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Check results
|
|
71
|
+
console.log(`Health Score: ${results.summary.score}%`);
|
|
72
|
+
console.log(`Passed: ${results.summary.passed}/${results.summary.total}`);
|
|
73
|
+
|
|
74
|
+
if (results.summary.hasErrors) {
|
|
75
|
+
console.error('ā Some checks failed');
|
|
76
|
+
console.log(formatResultsAsText(results));
|
|
77
|
+
} else {
|
|
78
|
+
console.log('ā
All checks passed!');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Generate HTML report
|
|
82
|
+
const htmlReport = formatResultsAsHtml(results, {
|
|
83
|
+
title: 'My Project Health Check',
|
|
84
|
+
repositoryUrl: 'https://github.com/user/repo'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Save HTML report
|
|
88
|
+
await import('fs/promises').then(fs =>
|
|
89
|
+
fs.writeFile('health-report.html', htmlReport)
|
|
90
|
+
);
|
|
91
|
+
})().catch(console.error);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Convenient High-Level API
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Simplified convenience function
|
|
98
|
+
import { healthCheck, formatResultsAsHtml } from 'spec-up-t-healthcheck';
|
|
99
|
+
|
|
100
|
+
const report = await healthCheck('.', {
|
|
101
|
+
checks: ['package-json', 'spec-files']
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(`Health score: ${report.summary.score}%`);
|
|
105
|
+
if (report.summary.hasErrors) {
|
|
106
|
+
console.error('Some health checks failed');
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### npm Scripts Integration
|
|
111
|
+
|
|
112
|
+
Add to your `package.json`:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"scripts": {
|
|
117
|
+
"healthcheck": "spec-up-t-healthcheck check .",
|
|
118
|
+
"healthcheck:html": "spec-up-t-healthcheck check . --format html",
|
|
119
|
+
"healthcheck:ci": "spec-up-t-healthcheck check . --format json"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## šØ HTML Reports
|
|
125
|
+
|
|
126
|
+
The HTML format generates beautiful, interactive reports with:
|
|
127
|
+
|
|
128
|
+
- **Bootstrap 5.3 responsive design**
|
|
129
|
+
- **Interactive filtering** (show/hide passing checks)
|
|
130
|
+
- **Color-coded status indicators**
|
|
131
|
+
- **Health score visualization**
|
|
132
|
+
- **Professional card-based layout**
|
|
133
|
+
- **Repository information integration**
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
## š Available Health Checks
|
|
138
|
+
|
|
139
|
+
- **package-json** - Validates package.json structure and required fields
|
|
140
|
+
- **spec-files** - Finds and validates specification markdown files
|
|
141
|
+
|
|
142
|
+
Use `spec-up-t-healthcheck list-checks` for the complete list.
|
|
143
|
+
|
|
144
|
+
## š Output Formats
|
|
145
|
+
|
|
146
|
+
| Format | Description | Use Case |
|
|
147
|
+
|--------|-------------|----------|
|
|
148
|
+
| `text` | Human-readable console output | Development, debugging |
|
|
149
|
+
| `json` | Structured data | CI/CD, automation, APIs |
|
|
150
|
+
| `html` | Interactive web report | Presentations, documentation |
|
|
151
|
+
|
|
152
|
+
## š§ Options Reference
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
spec-up-t-healthcheck check <target> [options]
|
|
156
|
+
|
|
157
|
+
Options:
|
|
158
|
+
-c, --checks <checks> Comma-separated list of checks to run
|
|
159
|
+
-f, --format <format> Output format: text|json|html (default: text)
|
|
160
|
+
-o, --output <file> Output file path
|
|
161
|
+
--no-open Don't auto-open HTML reports in browser
|
|
162
|
+
-h, --help Show help
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## šļø API Reference
|
|
166
|
+
|
|
167
|
+
### Core Functions
|
|
168
|
+
|
|
169
|
+
- `createProvider(path)` - Create a filesystem provider
|
|
170
|
+
- `runHealthChecks(provider, options)` - Execute health checks
|
|
171
|
+
- `formatResultsAsText(results)` - Format as console text
|
|
172
|
+
- `formatResultsAsJson(results)` - Format as JSON
|
|
173
|
+
- `formatResultsAsHtml(results, options)` - Format as HTML
|
|
174
|
+
|
|
175
|
+
### Result Structure
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
{
|
|
179
|
+
results: [
|
|
180
|
+
{
|
|
181
|
+
check: 'package-json',
|
|
182
|
+
status: 'pass|fail|warn|skip',
|
|
183
|
+
message: 'Human-readable message',
|
|
184
|
+
timestamp: '2025-09-18T...',
|
|
185
|
+
details: { /* additional data */ }
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
summary: {
|
|
189
|
+
total: 2,
|
|
190
|
+
passed: 2,
|
|
191
|
+
failed: 0,
|
|
192
|
+
warnings: 0,
|
|
193
|
+
skipped: 0,
|
|
194
|
+
score: 100,
|
|
195
|
+
hasErrors: false,
|
|
196
|
+
hasWarnings: false
|
|
197
|
+
},
|
|
198
|
+
timestamp: '2025-09-18T...',
|
|
199
|
+
provider: { type: 'local', repoPath: '.' }
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## š Documentation
|
|
204
|
+
|
|
205
|
+
- [API Documentation](docs/API.md)
|
|
206
|
+
- [Health Checks Reference](docs/CHECKS.md)
|
|
207
|
+
- [Integration Guide](docs/INTEGRATION.md)
|
|
208
|
+
- [Full Analysis](HEALTH_CHECK_TOOL_ANALYSIS.md)
|
|
209
|
+
|
|
210
|
+
## š¤ Contributing
|
|
211
|
+
|
|
212
|
+
This project follows the spec-up-t ecosystem standards. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
213
|
+
|
|
214
|
+
## š License
|
|
215
|
+
|
|
216
|
+
Apache-2.0 - see [LICENSE](LICENSE) file for details.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Command Line Interface for spec-up-t-healthcheck
|
|
5
|
+
*
|
|
6
|
+
* This CLI tool provides a convenient command-line interface for running health checks
|
|
7
|
+
* on specification repositories. It supports various output formats, check selection,
|
|
8
|
+
* and file output options. The CLI is built using Commander.js and provides a user-friendly
|
|
9
|
+
* interface for all health checking functionality.
|
|
10
|
+
*
|
|
11
|
+
* @author spec-up-t-healthcheck
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Command } from 'commander';
|
|
16
|
+
import { createProvider, runHealthChecks, formatResultsAsText, formatResultsAsJson, formatResultsAsHtml } from '../lib/index.js';
|
|
17
|
+
import { openHtmlFile } from '../lib/file-opener.js';
|
|
18
|
+
import { mkdirSync, existsSync } from 'fs';
|
|
19
|
+
import { join, dirname } from 'path';
|
|
20
|
+
|
|
21
|
+
const program = new Command();
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.name('spec-up-t-healthcheck')
|
|
25
|
+
.description('Health check tool for spec-up-t repositories')
|
|
26
|
+
.version('1.0.2');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Main 'check' command that performs health checks on a repository.
|
|
30
|
+
*
|
|
31
|
+
* This command creates a provider for the target repository, runs the specified
|
|
32
|
+
* health checks, and outputs the results in the requested format. It supports
|
|
33
|
+
* both local and remote repositories (when implemented) and provides flexible
|
|
34
|
+
* output options.
|
|
35
|
+
*
|
|
36
|
+
* Exit codes:
|
|
37
|
+
* - 0: All checks passed
|
|
38
|
+
* - 1: One or more checks failed or command error
|
|
39
|
+
* - 2: Checks passed but with warnings
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```bash
|
|
43
|
+
* # Basic usage
|
|
44
|
+
* spec-up-t-healthcheck check ./my-repo
|
|
45
|
+
*
|
|
46
|
+
* # Specific checks only
|
|
47
|
+
* spec-up-t-healthcheck check ./my-repo --checks package-json
|
|
48
|
+
*
|
|
49
|
+
* # JSON output to file
|
|
50
|
+
* spec-up-t-healthcheck check ./my-repo --format json --output report.json
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
program
|
|
54
|
+
.command('check')
|
|
55
|
+
.description('Run health checks on a repository')
|
|
56
|
+
.argument('<target>', 'Repository path (local) or URL (remote)')
|
|
57
|
+
.option('-c, --checks <checks>', 'Comma-separated list of checks to run (package-json,spec-files)')
|
|
58
|
+
.option('-f, --format <format>', 'Output format (text|json|html)', 'text')
|
|
59
|
+
.option('-o, --output <file>', 'Output file path')
|
|
60
|
+
.option('--no-open', 'Don\'t automatically open HTML reports in browser')
|
|
61
|
+
.action(async (target, options) => {
|
|
62
|
+
try {
|
|
63
|
+
console.log(`\nš Checking: ${target}\n`);
|
|
64
|
+
|
|
65
|
+
// Parse checks option
|
|
66
|
+
const checks = options.checks ? options.checks.split(',').map(c => c.trim()) : undefined;
|
|
67
|
+
|
|
68
|
+
// Create provider and run checks
|
|
69
|
+
const provider = createProvider(target);
|
|
70
|
+
const results = await runHealthChecks(provider, { checks });
|
|
71
|
+
|
|
72
|
+
// Format output based on requested format
|
|
73
|
+
let output;
|
|
74
|
+
let defaultOutputFile;
|
|
75
|
+
|
|
76
|
+
if (options.format === 'json') {
|
|
77
|
+
output = formatResultsAsJson(results, 2);
|
|
78
|
+
defaultOutputFile = `health-check-${Date.now()}.json`;
|
|
79
|
+
} else if (options.format === 'html') {
|
|
80
|
+
// For HTML, determine repository URL if possible
|
|
81
|
+
let repositoryUrl;
|
|
82
|
+
if (provider.repoPath && !provider.repoPath.startsWith('/')) {
|
|
83
|
+
repositoryUrl = provider.repoPath; // Assume it's a URL
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
output = formatResultsAsHtml(results, {
|
|
87
|
+
title: `Health Check Report - ${target}`,
|
|
88
|
+
repositoryUrl
|
|
89
|
+
});
|
|
90
|
+
defaultOutputFile = `health-check-${Date.now()}.html`;
|
|
91
|
+
} else {
|
|
92
|
+
output = formatResultsAsText(results);
|
|
93
|
+
defaultOutputFile = `health-check-${Date.now()}.txt`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Determine output file path
|
|
97
|
+
let outputFile = options.output;
|
|
98
|
+
if (options.format === 'html' && !outputFile) {
|
|
99
|
+
// For HTML format, create a default output file in .cache directory
|
|
100
|
+
const cacheDir = join(process.cwd(), '.cache');
|
|
101
|
+
if (!existsSync(cacheDir)) {
|
|
102
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
103
|
+
}
|
|
104
|
+
outputFile = join(cacheDir, defaultOutputFile);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Output results
|
|
108
|
+
if (outputFile) {
|
|
109
|
+
const fs = await import('fs/promises');
|
|
110
|
+
|
|
111
|
+
// Ensure output directory exists
|
|
112
|
+
const outputDir = dirname(outputFile);
|
|
113
|
+
if (!existsSync(outputDir)) {
|
|
114
|
+
mkdirSync(outputDir, { recursive: true });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
await fs.writeFile(outputFile, output);
|
|
118
|
+
console.log(`ā
Results written to ${outputFile}`);
|
|
119
|
+
|
|
120
|
+
// Automatically open HTML files in browser (unless disabled)
|
|
121
|
+
if (options.format === 'html' && options.open !== false) {
|
|
122
|
+
console.log('š Opening report in browser...');
|
|
123
|
+
const opened = await openHtmlFile(outputFile);
|
|
124
|
+
if (!opened) {
|
|
125
|
+
console.log('š” Could not automatically open browser. Please open the file manually:');
|
|
126
|
+
console.log(` ${outputFile}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
console.log(output);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Exit with appropriate code
|
|
134
|
+
if (results.summary.hasErrors) {
|
|
135
|
+
process.exit(1);
|
|
136
|
+
} else if (results.summary.hasWarnings) {
|
|
137
|
+
process.exit(2);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(`ā Error: ${error.message}`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 'list-checks' command that displays available health checks.
|
|
148
|
+
*
|
|
149
|
+
* This informational command helps users discover what health checks are available
|
|
150
|
+
* and understand what each check validates. It provides descriptions of each check
|
|
151
|
+
* and examples of how to use them.
|
|
152
|
+
*/
|
|
153
|
+
program
|
|
154
|
+
.command('list-checks')
|
|
155
|
+
.description('List available health checks')
|
|
156
|
+
.action(() => {
|
|
157
|
+
console.log('š Available Health Checks:\n');
|
|
158
|
+
console.log('1. package-json - Validates package.json structure and required fields');
|
|
159
|
+
console.log('2. spec-files - Finds and validates specification markdown files');
|
|
160
|
+
console.log('\nUsage: spec-up-t-healthcheck check <target> --checks package-json,spec-files');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 'example' command that demonstrates CLI usage patterns.
|
|
165
|
+
*
|
|
166
|
+
* This command provides practical examples of how to use the CLI tool
|
|
167
|
+
* with different options and scenarios. It helps users understand the
|
|
168
|
+
* available command-line options and common usage patterns.
|
|
169
|
+
*/
|
|
170
|
+
program
|
|
171
|
+
.command('example')
|
|
172
|
+
.description('Show usage examples')
|
|
173
|
+
.action(() => {
|
|
174
|
+
console.log('š Usage Examples:\n');
|
|
175
|
+
console.log('Local repository:');
|
|
176
|
+
console.log(' spec-up-t-healthcheck check ./my-spec-repo\n');
|
|
177
|
+
console.log('Specific checks only:');
|
|
178
|
+
console.log(' spec-up-t-healthcheck check ./repo --checks package-json\n');
|
|
179
|
+
console.log('JSON output:');
|
|
180
|
+
console.log(' spec-up-t-healthcheck check ./repo --format json\n');
|
|
181
|
+
console.log('HTML report (auto-opens in browser):');
|
|
182
|
+
console.log(' spec-up-t-healthcheck check ./repo --format html\n');
|
|
183
|
+
console.log('Save to specific file:');
|
|
184
|
+
console.log(' spec-up-t-healthcheck check ./repo --output report.html --format html\n');
|
|
185
|
+
console.log('HTML report without auto-opening:');
|
|
186
|
+
console.log(' spec-up-t-healthcheck check ./repo --format html --no-open');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Parse and execute the command line arguments.
|
|
191
|
+
* This must be called at the end to process user input.
|
|
192
|
+
*/
|
|
193
|
+
program.parse();
|
package/bin/demo-html.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Demonstration script for HTML health check reports
|
|
5
|
+
*
|
|
6
|
+
* This script creates sample health check data with various statuses and
|
|
7
|
+
* generates an HTML report to showcase the Bootstrap styling and interactive
|
|
8
|
+
* features. It's useful for testing the HTML formatter and demonstrating
|
|
9
|
+
* the visual appearance of health check reports.
|
|
10
|
+
*
|
|
11
|
+
* @author spec-up-t-healthcheck
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { formatResultsAsHtml } from '../lib/formatters.js';
|
|
16
|
+
import { openHtmlFile } from '../lib/file-opener.js';
|
|
17
|
+
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
18
|
+
import { join } from 'path';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates sample health check data for demonstration purposes.
|
|
22
|
+
*
|
|
23
|
+
* This function generates realistic health check results with various
|
|
24
|
+
* statuses to showcase how the HTML formatter handles different scenarios.
|
|
25
|
+
*
|
|
26
|
+
* @returns {import('../lib/health-checker.js').HealthCheckReport} Mock health check report
|
|
27
|
+
*/
|
|
28
|
+
function createSampleHealthCheckData() {
|
|
29
|
+
const timestamp = new Date().toISOString();
|
|
30
|
+
|
|
31
|
+
const results = [
|
|
32
|
+
{
|
|
33
|
+
check: 'package-json-exists',
|
|
34
|
+
status: 'pass',
|
|
35
|
+
message: 'package.json file found and valid',
|
|
36
|
+
timestamp,
|
|
37
|
+
details: {
|
|
38
|
+
packageData: {
|
|
39
|
+
name: 'spec-up-t-healthcheck',
|
|
40
|
+
version: '1.0.2'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
check: 'package-json-required-fields',
|
|
46
|
+
status: 'pass',
|
|
47
|
+
message: 'All required fields are present',
|
|
48
|
+
timestamp,
|
|
49
|
+
details: {}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
check: 'spec-files-present',
|
|
53
|
+
status: 'pass',
|
|
54
|
+
message: 'Specification files found',
|
|
55
|
+
timestamp,
|
|
56
|
+
details: {
|
|
57
|
+
count: 3
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
check: 'readme-exists',
|
|
62
|
+
status: 'pass',
|
|
63
|
+
message: 'README.md file is present',
|
|
64
|
+
timestamp,
|
|
65
|
+
details: {}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
check: 'license-check',
|
|
69
|
+
status: 'warn',
|
|
70
|
+
message: 'License file not found - consider adding a LICENSE file',
|
|
71
|
+
timestamp,
|
|
72
|
+
details: {}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
check: 'git-ignore-validation',
|
|
76
|
+
status: 'fail',
|
|
77
|
+
message: '.gitignore file is missing or incomplete',
|
|
78
|
+
timestamp,
|
|
79
|
+
details: {
|
|
80
|
+
missingFields: ['node_modules', '.cache', '*.log']
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
check: 'dependency-security',
|
|
85
|
+
status: 'warn',
|
|
86
|
+
message: 'Some dependencies have known vulnerabilities',
|
|
87
|
+
timestamp,
|
|
88
|
+
details: {}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
check: 'typescript-config',
|
|
92
|
+
status: 'skip',
|
|
93
|
+
message: 'TypeScript not detected, skipping config validation',
|
|
94
|
+
timestamp,
|
|
95
|
+
details: {}
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
// Calculate summary
|
|
100
|
+
const passed = results.filter(r => r.status === 'pass').length;
|
|
101
|
+
const failed = results.filter(r => r.status === 'fail').length;
|
|
102
|
+
const warnings = results.filter(r => r.status === 'warn').length;
|
|
103
|
+
const skipped = results.filter(r => r.status === 'skip').length;
|
|
104
|
+
|
|
105
|
+
const summary = {
|
|
106
|
+
total: results.length,
|
|
107
|
+
passed,
|
|
108
|
+
failed,
|
|
109
|
+
warnings,
|
|
110
|
+
skipped,
|
|
111
|
+
score: Math.round((passed / results.length) * 100),
|
|
112
|
+
hasErrors: failed > 0,
|
|
113
|
+
hasWarnings: warnings > 0
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
results,
|
|
118
|
+
summary,
|
|
119
|
+
timestamp,
|
|
120
|
+
provider: {
|
|
121
|
+
type: 'local',
|
|
122
|
+
repoPath: '/Users/demo/my-spec-project'
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Main function that generates and opens the sample HTML report.
|
|
129
|
+
*/
|
|
130
|
+
async function generateSampleReport() {
|
|
131
|
+
console.log('šØ Generating sample HTML health check report...\n');
|
|
132
|
+
|
|
133
|
+
// Create sample data
|
|
134
|
+
const sampleData = createSampleHealthCheckData();
|
|
135
|
+
|
|
136
|
+
// Generate HTML report with custom options
|
|
137
|
+
const htmlContent = formatResultsAsHtml(sampleData, {
|
|
138
|
+
title: 'Sample Spec-Up-T Health Check Report',
|
|
139
|
+
repositoryUrl: 'https://github.com/blockchain-bird/spec-up-t-sample',
|
|
140
|
+
showPassingByDefault: true
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Ensure output directory exists
|
|
144
|
+
const outputDir = join(process.cwd(), '.cache');
|
|
145
|
+
if (!existsSync(outputDir)) {
|
|
146
|
+
mkdirSync(outputDir, { recursive: true });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Write HTML file
|
|
150
|
+
const outputFile = join(outputDir, `sample-health-report-${Date.now()}.html`);
|
|
151
|
+
writeFileSync(outputFile, htmlContent);
|
|
152
|
+
|
|
153
|
+
console.log(`ā
Sample report generated: ${outputFile}`);
|
|
154
|
+
console.log('\nš Sample Report Contents:');
|
|
155
|
+
console.log(` Total checks: ${sampleData.summary.total}`);
|
|
156
|
+
console.log(` ā Passed: ${sampleData.summary.passed}`);
|
|
157
|
+
console.log(` ā Failed: ${sampleData.summary.failed}`);
|
|
158
|
+
console.log(` ā Warnings: ${sampleData.summary.warnings}`);
|
|
159
|
+
console.log(` ā Skipped: ${sampleData.summary.skipped}`);
|
|
160
|
+
console.log(` Score: ${sampleData.summary.score}%`);
|
|
161
|
+
|
|
162
|
+
console.log('\nš Opening sample report in browser...');
|
|
163
|
+
const opened = await openHtmlFile(outputFile);
|
|
164
|
+
|
|
165
|
+
if (opened) {
|
|
166
|
+
console.log('ā
Sample report opened successfully!');
|
|
167
|
+
} else {
|
|
168
|
+
console.log('ā ļø Could not automatically open browser. Please open manually:');
|
|
169
|
+
console.log(` ${outputFile}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log('\nšÆ Features demonstrated in the sample report:');
|
|
173
|
+
console.log(' ⢠Bootstrap responsive design');
|
|
174
|
+
console.log(' ⢠Interactive passing/failing filter toggle');
|
|
175
|
+
console.log(' ⢠Color-coded status indicators');
|
|
176
|
+
console.log(' ⢠Detailed health score calculation');
|
|
177
|
+
console.log(' ⢠Professional card-based layout');
|
|
178
|
+
console.log(' ⢠Repository information display');
|
|
179
|
+
console.log(' ⢠Various check result types (pass/fail/warn/skip)');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Run the sample generator
|
|
183
|
+
generateSampleReport().catch(error => {
|
|
184
|
+
console.error('ā Error generating sample report:', error);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Simple test utility for basic functionality validation
|
|
5
|
+
*
|
|
6
|
+
* This standalone test script provides a lightweight way to validate basic
|
|
7
|
+
* functionality without complex imports or dependencies. It performs fundamental
|
|
8
|
+
* checks on the current environment and repository structure to ensure the
|
|
9
|
+
* health check tool can operate correctly.
|
|
10
|
+
*
|
|
11
|
+
* The script is designed to be self-contained and can run independently
|
|
12
|
+
* of the main library code, making it useful for troubleshooting and
|
|
13
|
+
* basic environment validation.
|
|
14
|
+
*
|
|
15
|
+
* @author spec-up-t-healthcheck
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Performs basic environment and repository validation checks.
|
|
20
|
+
*
|
|
21
|
+
* This function validates:
|
|
22
|
+
* - Current working directory access
|
|
23
|
+
* - package.json existence and content
|
|
24
|
+
* - Basic Node.js functionality
|
|
25
|
+
* - Repository identification
|
|
26
|
+
*
|
|
27
|
+
* The checks are designed to be independent of the main health check
|
|
28
|
+
* library and provide a foundation for more complex validation.
|
|
29
|
+
*/
|
|
30
|
+
async function runBasicHealthCheck() {
|
|
31
|
+
console.log('š Spec-Up-T Health Check Tool v1.0.0');
|
|
32
|
+
console.log('');
|
|
33
|
+
console.log('Available Health Check Categories:');
|
|
34
|
+
console.log(' ā
repository (Basic repository checks)');
|
|
35
|
+
console.log(' ā
configuration (3 checks)');
|
|
36
|
+
console.log(' ā
structure (Basic structure checks)');
|
|
37
|
+
console.log('');
|
|
38
|
+
console.log('š Basic functionality test:');
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Test basic Node.js functionality
|
|
42
|
+
const fs = await import('fs/promises');
|
|
43
|
+
const path = await import('path');
|
|
44
|
+
|
|
45
|
+
const currentDir = process.cwd();
|
|
46
|
+
console.log(` ā Working directory: ${path.basename(currentDir)}`);
|
|
47
|
+
|
|
48
|
+
// Check if package.json exists
|
|
49
|
+
try {
|
|
50
|
+
await fs.access('package.json');
|
|
51
|
+
console.log(' ā package.json found');
|
|
52
|
+
} catch {
|
|
53
|
+
console.log(' ā package.json not found');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Check if we're in a spec-up-t healthcheck repo
|
|
57
|
+
const packageContent = await fs.readFile('package.json', 'utf-8');
|
|
58
|
+
const pkg = JSON.parse(packageContent);
|
|
59
|
+
|
|
60
|
+
if (pkg.name === 'spec-up-t-healthcheck') {
|
|
61
|
+
console.log(' ā
Running in spec-up-t-healthcheck repository');
|
|
62
|
+
console.log(` ā Version: ${pkg.version}`);
|
|
63
|
+
} else {
|
|
64
|
+
console.log(` ā¹ļø Running in: ${pkg.name || 'unknown project'}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log('ā
Basic health check tool is working!');
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log('Next: Implement full health check logic');
|
|
71
|
+
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('ā Error:', error.message);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Execute the basic health check
|
|
79
|
+
runBasicHealthCheck();
|