chore(tools): clean up and refactor bump scripts for clarity and consistency (#325)

* refactor: simplify installer package version sync script and add comments

* chore: bump core version based on provided semver type

* chore(expansion): bump bmad-creator-tools version (patch)
This commit is contained in:
MIPAN
2025-07-18 09:09:09 +08:00
committed by GitHub
parent d1bed26e5d
commit aa0e9f9bc4
3 changed files with 94 additions and 91 deletions

View File

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