chore(expansion): bump bmad-creator-tools version (patch)
This commit is contained in:
parent
4b23b994c8
commit
1042ece371
|
|
@ -1,60 +1,65 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// Load required modules
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
|
||||||
|
// Parse CLI arguments
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
|
const packId = args[0];
|
||||||
|
const bumpType = args[1] || 'minor';
|
||||||
|
|
||||||
if (args.length < 1 || args.length > 2) {
|
// Validate arguments
|
||||||
|
if (!packId || args.length > 2) {
|
||||||
console.log('Usage: node bump-expansion-version.js <expansion-pack-id> [major|minor|patch]');
|
console.log('Usage: node bump-expansion-version.js <expansion-pack-id> [major|minor|patch]');
|
||||||
console.log('Default: minor');
|
console.log('Default: minor');
|
||||||
console.log('Example: node bump-expansion-version.js bmad-creator-tools patch');
|
console.log('Example: node bump-expansion-version.js bmad-creator-tools patch');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const packId = args[0];
|
|
||||||
const bumpType = args[1] || 'minor'; // default to minor
|
|
||||||
|
|
||||||
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
||||||
console.error('Error: Bump type must be major, minor, or patch');
|
console.error('Error: Bump type must be major, minor, or patch');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version bump logic
|
||||||
function bumpVersion(currentVersion, type) {
|
function bumpVersion(currentVersion, type) {
|
||||||
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'major':
|
case 'major': return `${major + 1}.0.0`;
|
||||||
return `${major + 1}.0.0`;
|
case 'minor': return `${major}.${minor + 1}.0`;
|
||||||
case 'minor':
|
case 'patch': return `${major}.${minor}.${patch + 1}`;
|
||||||
return `${major}.${minor + 1}.0`;
|
default: return currentVersion;
|
||||||
case 'patch':
|
|
||||||
return `${major}.${minor}.${patch + 1}`;
|
|
||||||
default:
|
|
||||||
return currentVersion;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main function to bump version
|
||||||
async function updateVersion() {
|
async function updateVersion() {
|
||||||
try {
|
|
||||||
const configPath = path.join(__dirname, '..', 'expansion-packs', packId, 'config.yaml');
|
const configPath = path.join(__dirname, '..', 'expansion-packs', packId, 'config.yaml');
|
||||||
|
|
||||||
|
// Check if config exists
|
||||||
if (!fs.existsSync(configPath)) {
|
if (!fs.existsSync(configPath)) {
|
||||||
console.error(`Error: Expansion pack '${packId}' not found`);
|
console.error(`Error: Expansion pack '${packId}' not found`);
|
||||||
console.log('\nAvailable expansion packs:');
|
console.log('\nAvailable expansion packs:');
|
||||||
const expansionPacksDir = path.join(__dirname, '..', 'expansion-packs');
|
|
||||||
const entries = fs.readdirSync(expansionPacksDir, { withFileTypes: true });
|
const packsDir = path.join(__dirname, '..', 'expansion-packs');
|
||||||
|
const entries = fs.readdirSync(packsDir, { withFileTypes: true });
|
||||||
|
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
||||||
console.log(` - ${entry.name}`);
|
console.log(` - ${entry.name}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const configContent = fs.readFileSync(configPath, 'utf8');
|
const configContent = fs.readFileSync(configPath, 'utf8');
|
||||||
const config = yaml.load(configContent);
|
const config = yaml.load(configContent);
|
||||||
|
|
||||||
const oldVersion = config.version || '1.0.0';
|
const oldVersion = config.version || '1.0.0';
|
||||||
const newVersion = bumpVersion(oldVersion, bumpType);
|
const newVersion = bumpVersion(oldVersion, bumpType);
|
||||||
|
|
||||||
|
|
@ -66,8 +71,8 @@ async function updateVersion() {
|
||||||
console.log(`✓ ${packId}: ${oldVersion} → ${newVersion}`);
|
console.log(`✓ ${packId}: ${oldVersion} → ${newVersion}`);
|
||||||
console.log(`\n✓ Successfully bumped ${packId} with ${bumpType} version bump`);
|
console.log(`\n✓ Successfully bumped ${packId} with ${bumpType} version bump`);
|
||||||
console.log('\nNext steps:');
|
console.log('\nNext steps:');
|
||||||
console.log('1. Test the changes');
|
console.log(`1. Test the changes`);
|
||||||
console.log('2. Commit: git add -A && git commit -m "chore: bump ' + packId + ' version (' + bumpType + ')"');
|
console.log(`2. Commit: git add -A && git commit -m "chore: bump ${packId} version (${bumpType})"`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating version:', error.message);
|
console.error('Error updating version:', error.message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue