feat: bump version to 0.4.3 and add bump-patch script for automated versioning
All checks were successful
build / build (push) Successful in 15s

This commit is contained in:
2026-03-07 10:13:47 +01:00
parent d39fdb3e33
commit 9c2aea491c
3 changed files with 54 additions and 4 deletions

48
scripts/bump-patch.mjs Executable file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import semver from 'semver';
function bump(fileName) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const filePath = path.resolve(__dirname, '..', fileName);
if (!bump.nextVersion) {
const packageJsonPath = path.resolve(__dirname, '../package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const version = packageJson.version;
if (typeof version !== 'string') {
throw new Error('package.json does not contain a string "version" field.');
}
const nextVersion = semver.inc(version, 'patch');
if (!nextVersion) {
throw new Error(`Unsupported semver format: "${version}"`);
}
bump.nextVersion = nextVersion;
}
if (!fs.existsSync(filePath)) {
throw new Error(`File not found: ${filePath}`);
}
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
json.version = bump.nextVersion;
if (path.basename(filePath) === 'package-lock.json' && json.packages?.['']) {
json.packages[''].version = bump.nextVersion;
}
fs.writeFileSync(filePath, `${JSON.stringify(json, null, 4)}\n`, 'utf8');
console.log(`Bumped version in ${fileName} to ${bump.nextVersion}`);
}
bump('package.json');
bump('package-lock.json');