Skip to main content
Glama
version-check.js•4.47 kB
#!/usr/bin/env node /** * Version Consistency Check Script * Ensures package.json, README, git tags, and server.js versions are synchronized */ import { readFileSync, existsSync } from 'fs'; import { execSync } from 'child_process'; import { join } from 'path'; const projectRoot = process.cwd(); function checkVersionConsistency() { console.log('šŸ” Checking version consistency...\n'); const results = { packageJson: null, readme: null, serverJs: null, gitTag: null, consistent: false, issues: [], }; try { // 1. Check package.json const packageJsonPath = join(projectRoot, 'package.json'); if (existsSync(packageJsonPath)) { const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')); results.packageJson = packageJson.version; console.log(`šŸ“¦ package.json: ${results.packageJson}`); } else { results.issues.push('āŒ package.json not found'); } // 2. Check README.md const readmePath = join(projectRoot, 'README.md'); if (existsSync(readmePath)) { const readmeContent = readFileSync(readmePath, 'utf8'); const versionMatch = readmeContent.match(/version-([^-]+)-/); results.readme = versionMatch ? versionMatch[1] : null; console.log(`šŸ“– README.md: ${results.readme || 'Not found'}`); } else { results.issues.push('āŒ README.md not found'); } // 3. Check server.js const serverJsPath = join(projectRoot, 'server.js'); if (existsSync(serverJsPath)) { const serverContent = readFileSync(serverJsPath, 'utf8'); const versionMatch = serverContent.match(/version:\s*['"]([^'"]+)['"]/); results.serverJs = versionMatch ? versionMatch[1] : null; console.log(`šŸ–„ļø server.js: ${results.serverJs || 'Not found'}`); } else { results.issues.push('āŒ server.js not found'); } // 4. Check git tags try { const gitOutput = execSync('git tag --sort=-version:refname', { encoding: 'utf8', stdio: 'pipe', }); const tags = gitOutput .trim() .split('\n') .filter((tag) => tag); results.gitTag = tags[0] || null; console.log(`šŸ·ļø Latest git tag: ${results.gitTag || 'None'}`); } catch (error) { results.issues.push('āŒ Failed to read git tags'); } console.log('\n' + '─'.repeat(50)); // 5. Check consistency const versions = [results.packageJson, results.readme, results.serverJs].filter( (v) => v !== null, ); const gitTagVersion = results.gitTag ? results.gitTag.replace(/^v/, '') : null; if (versions.length === 0) { results.issues.push('āŒ No versions found'); } else { const uniqueVersions = [...new Set(versions)]; if (uniqueVersions.length === 1) { console.log(`āœ… All file versions are consistent: ${uniqueVersions[0]}`); if (gitTagVersion && gitTagVersion !== uniqueVersions[0]) { results.issues.push( `āš ļø Git tag (${results.gitTag}) doesn't match file versions (${uniqueVersions[0]})`, ); } else if (gitTagVersion) { console.log('āœ… Git tag matches file versions'); results.consistent = true; } else { results.issues.push(`āš ļø No git tag found for version ${uniqueVersions[0]}`); } } else { results.issues.push('āŒ Version mismatch found:'); if (results.packageJson) results.issues.push(` package.json: ${results.packageJson}`); if (results.readme) results.issues.push(` README.md: ${results.readme}`); if (results.serverJs) results.issues.push(` server.js: ${results.serverJs}`); } } // 6. Report results console.log('\nšŸ“‹ Summary:'); if (results.consistent) { console.log('šŸŽ‰ All versions are consistent and properly tagged!'); process.exit(0); } else { console.log('šŸ”§ Issues found:'); results.issues.forEach((issue) => console.log(` ${issue}`)); console.log('\nšŸ’” To fix version consistency:'); console.log(' 1. Update all files to the same version'); console.log(' 2. Create a git tag: git tag v<version>'); console.log(' 3. Push the tag: git push origin v<version>'); process.exit(1); } } catch (error) { console.error('āŒ Version check failed:', error.message); process.exit(1); } } // Run the check checkVersionConsistency();

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/moikas-code/moidvk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server