#!/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);