chore: bump core version based on provided semver type
This commit is contained in:
parent
b632a4d288
commit
4b23b994c8
|
|
@ -4,8 +4,9 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
|
||||||
|
// --- Argument parsing ---
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const bumpType = args[0] || 'minor'; // default to minor
|
const bumpType = args[0] || 'minor';
|
||||||
|
|
||||||
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
||||||
console.log('Usage: node bump-core-version.js [major|minor|patch]');
|
console.log('Usage: node bump-core-version.js [major|minor|patch]');
|
||||||
|
|
@ -13,45 +14,43 @@ if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bumpVersion(currentVersion, type) {
|
// --- Function to bump semantic version ---
|
||||||
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
function bumpVersion(version, type) {
|
||||||
|
const [major, minor, patch] = version.split('.').map(Number);
|
||||||
|
|
||||||
switch (type) {
|
return {
|
||||||
case 'major':
|
major: `${major + 1}.0.0`,
|
||||||
return `${major + 1}.0.0`;
|
minor: `${major}.${minor + 1}.0`,
|
||||||
case 'minor':
|
patch: `${major}.${minor}.${patch + 1}`,
|
||||||
return `${major}.${minor + 1}.0`;
|
}[type] || version;
|
||||||
case 'patch':
|
|
||||||
return `${major}.${minor}.${patch + 1}`;
|
|
||||||
default:
|
|
||||||
return currentVersion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bumpCoreVersion() {
|
// --- Main function ---
|
||||||
|
function bumpCoreVersion() {
|
||||||
|
const configPath = path.join(__dirname, '..', 'bmad-core', 'core-config.yaml');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const coreConfigPath = path.join(__dirname, '..', 'bmad-core', 'core-config.yaml');
|
const content = fs.readFileSync(configPath, 'utf8');
|
||||||
|
const config = yaml.load(content);
|
||||||
|
|
||||||
const coreConfigContent = fs.readFileSync(coreConfigPath, 'utf8');
|
const oldVersion = config.version || '1.0.0';
|
||||||
const coreConfig = yaml.load(coreConfigContent);
|
|
||||||
const oldVersion = coreConfig.version || '1.0.0';
|
|
||||||
const newVersion = bumpVersion(oldVersion, bumpType);
|
const newVersion = bumpVersion(oldVersion, bumpType);
|
||||||
|
|
||||||
coreConfig.version = newVersion;
|
config.version = newVersion;
|
||||||
|
const updatedYaml = yaml.dump(config, { indent: 2 });
|
||||||
|
|
||||||
const updatedYaml = yaml.dump(coreConfig, { indent: 2 });
|
fs.writeFileSync(configPath, updatedYaml);
|
||||||
fs.writeFileSync(coreConfigPath, updatedYaml);
|
|
||||||
|
|
||||||
console.log(`✓ BMad Core: ${oldVersion} → ${newVersion}`);
|
console.log(`✓ BMad Core version bumped: ${oldVersion} → ${newVersion}\n`);
|
||||||
console.log(`\n✓ Successfully bumped BMad Core with ${bumpType} version bump`);
|
console.log('Next steps:');
|
||||||
console.log('\nNext steps:');
|
console.log(`1. Test your changes`);
|
||||||
console.log('1. Test the changes');
|
console.log(`2. Commit:\n git add -A && git commit -m "chore: bump core version (${bumpType})"`);
|
||||||
console.log('2. Commit: git add -A && git commit -m "chore: bump core version (' + bumpType + ')"');
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error('Error updating core version:', error.message);
|
console.error(`✗ Failed to bump version: ${err.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Run ---
|
||||||
bumpCoreVersion();
|
bumpCoreVersion();
|
||||||
Loading…
Reference in New Issue