#!/usr/bin/env node
/**
* GLINR Commit Tool
* Enhanced commit tool with semantic release integration
*/
const { execSync } = require('child_process');
const path = require('path');
// Import the version sync utility
const VersionSync = require('./sync-versions.js');
class GlinrCommit {
constructor() {
this.versionSync = new VersionSync();
}
/**
* Execute commitweave with glinr-commit preset
*/
async commit() {
try {
console.log('π― GLINR Commit Tool');
console.log('π Creating semantic commit with automatic release detection...\n');
// Run commitweave with glinr-commit preset
execSync('npx commitweave --preset glinr-commit', {
stdio: 'inherit',
cwd: path.resolve(__dirname, '..')
});
// After commit, check if it should trigger a release
console.log('\nπ Checking if commit should trigger release...');
const releaseInfo = this.versionSync.autoRelease();
if (releaseInfo) {
console.log(`β
Release triggered! New version: ${releaseInfo}`);
console.log('π Version synchronized across all packages');
// Show release summary
console.log('\nπ Release Summary:');
this.versionSync.status();
console.log('\nπ‘ Next steps:');
console.log(' 1. Push to main/release branch to trigger CI/CD');
console.log(' 2. GitHub Actions will publish to npm and PyPI');
console.log(' 3. GitHub release will be created automatically');
} else {
console.log('βΉοΈ No automatic release triggered');
console.log('π‘ Use conventional commit types (feat:, fix:) for auto-releases');
}
} catch (error) {
console.error('β Commit failed:', error.message);
process.exit(1);
}
}
/**
* Show semantic release rules
*/
showRules() {
console.log('π GLINR Semantic Release Rules:');
console.log('');
console.log('π― Release Types:');
console.log(' feat: β minor release (new features)');
console.log(' fix: β patch release (bug fixes)');
console.log(' perf: β patch release (performance improvements)');
console.log(' docs: β patch release (documentation)');
console.log(' style: β patch release (code style)');
console.log(' refactor: β patch release (code refactoring)');
console.log(' test: β patch release (tests)');
console.log(' chore: β patch release (maintenance)');
console.log(' BREAKING: β major release (breaking changes)');
console.log('');
console.log('π¨ Commit Format:');
console.log(' {emoji} {type}({scope}): {subject}');
console.log('');
console.log('π¦ Examples:');
console.log(' β¨ feat(core): add multi-language support');
console.log(' π fix(filters): resolve case sensitivity issue');
console.log(' β‘ perf(python): optimize dictionary loading');
console.log(' π docs: update API documentation');
console.log('');
console.log('π Manual Release Commands:');
console.log(' npm run release:patch β 2.1.0 β 2.1.1');
console.log(' npm run release:minor β 2.1.0 β 2.2.0');
console.log(' npm run release:major β 2.1.0 β 3.0.0');
console.log(' npm run release:beta β 2.1.0 β 2.2.0-beta.1');
console.log(' npm run release:alpha β 2.1.0 β 2.2.0-alpha.1');
}
}
// CLI Interface
if (require.main === module) {
const glinrCommit = new GlinrCommit();
const args = process.argv.slice(2);
const command = args[0];
switch (command) {
case 'rules':
case 'help':
case '--help':
case '-h':
glinrCommit.showRules();
break;
default:
glinrCommit.commit();
break;
}
}
module.exports = GlinrCommit;