#!/usr/bin/env node
import { promisify } from "util";
import { exec } from "child_process";
import fs from "fs/promises";
import path from "path";
const execAsync = promisify(exec);
class ProjectMonitor {
constructor() {
this.repoUrl = this.getRepoUrl();
}
getRepoUrl() {
// This will be extracted from package.json or git config
return "https://github.com/yourusername/linux-bash-mcp-server";
}
async checkHealth() {
console.log("π Linux Bash MCP Server - Project Health Check\n");
try {
// Check if tests pass
console.log("π§ͺ Running test suite...");
await execAsync("npm test");
console.log("β
All tests passing\n");
// Check for common issues
console.log("π§ Checking for common issues...");
await execAsync("npm run debug");
console.log("β
Diagnostics completed\n");
// Check dependencies
console.log("π¦ Checking dependencies...");
const { stdout } = await execAsync("npm audit --audit-level=high");
if (stdout.trim()) {
console.log("β οΈ Security audit found issues:");
console.log(stdout);
} else {
console.log("β
No high-severity security issues found");
}
console.log("\nπ Project health check completed successfully!");
console.log("\nπ Project Status:");
console.log(` Repository: ${this.repoUrl}`);
console.log(" Status: β
Healthy");
console.log(" Tests: β
Passing");
console.log(" Security: β
No high-risk issues");
} catch (error) {
console.log(`\nβ Health check failed: ${error.message}`);
console.log("\nπ§ Recommended actions:");
console.log("1. Fix failing tests");
console.log("2. Run 'npm run debug' for detailed diagnostics");
console.log("3. Update dependencies if needed");
}
}
async generateProjectStats() {
console.log("π Project Statistics\n");
try {
// Count lines of code
const { stdout: lines } = await execAsync("find . -name '*.js' -not -path './node_modules/*' | xargs wc -l | tail -1");
console.log(`π Lines of code: ${lines.trim().split(/\s+/)[0]}`);
// Count files
const { stdout: files } = await execAsync("find . -name '*.js' -not -path './node_modules/*' | wc -l");
console.log(`π JavaScript files: ${files.trim()}`);
// Check documentation
const { stdout: docs } = await execAsync("find . -name '*.md' | wc -l");
console.log(`π Documentation files: ${docs.trim()}`);
// Check test coverage (approximate)
const { stdout: tests } = await execAsync("find . -name '*test*.js' -not -path './node_modules/*' | wc -l");
console.log(`π§ͺ Test files: ${tests.trim()}`);
} catch (error) {
console.log("β Could not generate statistics:", error.message);
}
}
async suggestImprovements() {
console.log("\nπ‘ Suggested Improvements:\n");
const suggestions = [
"π Set up GitHub Actions for automated testing",
"π Add code coverage reporting",
"π― Create issue templates for bugs and features",
"π Add examples for advanced use cases",
"π Consider creating a project website/docs",
"π± Add support for more Linux distributions",
"π§ Implement configuration validation",
"π Add performance monitoring",
"π¨ Create a project logo/branding",
"π€ Add contribution guidelines and code of conduct"
];
suggestions.forEach((suggestion, index) => {
console.log(`${index + 1}. ${suggestion}`);
});
}
async run() {
await this.checkHealth();
console.log("\n" + "=".repeat(50));
await this.generateProjectStats();
console.log("\n" + "=".repeat(50));
await this.suggestImprovements();
}
}
// Run monitor
const monitor = new ProjectMonitor();
monitor.run().catch(console.error);