2 Commits

Author SHA1 Message Date
8c06faee31 Bump version to 1.1.1 2026-01-21 21:06:41 +01:00
86687cb6a3 Improve version management system
- Fix version-check.js to use git tag version for releases
- Add new-version.js script for proper version/tag synchronization
- Update package.json to correct version 1.1.0

The new-version.js script ensures package.json and git tags are always synchronized by:
1. Updating package.json with new version
2. Committing the change
3. Tagging the commit

This prevents version mismatches and git dirty states.
2026-01-21 21:06:35 +01:00
3 changed files with 97 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "jmespath-playground", "name": "jmespath-playground",
"version": "1.0.4", "version": "1.1.1",
"description": "A React-based web application for testing JMESPath expressions against JSON data", "description": "A React-based web application for testing JMESPath expressions against JSON data",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

92
scripts/new-version.js Executable file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/env node
const fs = require('fs');
const { execSync } = require('child_process');
function showUsage() {
console.log('Usage: node scripts/new-version.js <version>');
console.log('');
console.log('Creates a new version by updating package.json, committing, and tagging.');
console.log('');
console.log('Example:');
console.log(' node scripts/new-version.js 1.2.0');
console.log(' node scripts/new-version.js 2.0.0-beta.1');
}
function main() {
// Parse command line arguments
const args = process.argv.slice(2);
if (args.length === 0 || args[0] === '-h' || args[0] === '--help') {
showUsage();
process.exit(args.length === 0 ? 1 : 0);
}
if (args.length !== 1) {
console.error('Error: Exactly one version argument required');
showUsage();
process.exit(1);
}
const newVersion = args[0];
const tagName = `v${newVersion}`;
console.log(`🏷️ Creating new version: ${newVersion}`);
try {
// Check if tag already exists
try {
const existingTags = execSync('git tag -l', { encoding: 'utf8' });
if (existingTags.split('\n').includes(tagName)) {
console.error(`❌ Error: Tag '${tagName}' already exists`);
process.exit(1);
}
} catch (error) {
console.error('❌ Error: Failed to check existing tags');
process.exit(1);
}
// Check if working directory is clean
try {
const status = execSync('git status --porcelain', { encoding: 'utf8' });
if (status.trim()) {
console.error('❌ Error: Working directory has uncommitted changes');
console.error('Please commit or stash your changes first');
process.exit(1);
}
} catch (error) {
console.error('❌ Error: Failed to check git status');
process.exit(1);
}
// Read and update package.json
const packagePath = './package.json';
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
const oldVersion = pkg.version;
pkg.version = newVersion;
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n');
console.log(`📦 Updated package.json: ${oldVersion}${newVersion}`);
// Commit the package.json change
execSync('git add package.json', { stdio: 'inherit' });
execSync(`git commit -m "Bump version to ${newVersion}"`, { stdio: 'inherit' });
console.log(`✅ Committed version change`);
// Tag the commit
execSync(`git tag ${tagName}`, { stdio: 'inherit' });
console.log(`🏷️ Created tag: ${tagName}`);
console.log('');
console.log('🎉 Version created successfully!');
console.log('');
console.log('Next steps:');
console.log(` git push origin main --tags # Push the commit and tag`);
} catch (error) {
console.error('❌ Error during version creation:', error.message);
process.exit(1);
}
}
main();

View File

@@ -16,7 +16,9 @@ try {
const gitTag = execSync('git tag --points-at HEAD', { encoding: 'utf8' }).trim(); const gitTag = execSync('git tag --points-at HEAD', { encoding: 'utf8' }).trim();
if (gitTag) { if (gitTag) {
// We're at a tagged commit - use clean version // We're at a tagged commit - extract version from tag
const tagVersion = gitTag.replace(/^v/, ''); // Remove 'v' prefix if present
version = tagVersion;
console.log(`✅ Building release version ${version} (tagged: ${gitTag})`); console.log(`✅ Building release version ${version} (tagged: ${gitTag})`);
isRelease = true; isRelease = true;
} else { } else {
@@ -43,4 +45,4 @@ export const BUILD_TIME = '${new Date().toISOString()}';
`; `;
fs.writeFileSync(versionFile, versionContent); fs.writeFileSync(versionFile, versionContent);
console.log(`📝 Generated ${versionFile} with version ${version}`); console.log(`📝 Generated ${versionFile} with version ${version}`);