bump version to 0.1.2 and add bump-patch script for version management
All checks were successful
build / build (push) Successful in 8s

This commit is contained in:
2026-03-07 11:05:27 +01:00
parent d74dafbe01
commit fe1b8f0e1f
3 changed files with 37 additions and 2 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "@slawek/sk-tools", "name": "@slawek/sk-tools",
"version": "0.1.0", "version": "0.1.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@slawek/sk-tools", "name": "@slawek/sk-tools",
"version": "0.1.1", "version": "0.1.2",
"type": "module", "type": "module",
"files": [ "files": [
"dist", "dist",

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

@@ -0,0 +1,35 @@
#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import semver from 'semver';
function bump(fileName, version) {
const filePath = path.resolve(process.cwd(), fileName);
if (!fs.existsSync(filePath)) {
throw new Error(`File not found: ${filePath}`);
}
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
const currentVersion = json.version;
if (typeof currentVersion !== 'string') {
throw new Error(`${fileName} does not contain a string "version" field.`);
}
const nextVersion = version ?? semver.inc(currentVersion, 'patch');
if (!nextVersion) {
throw new Error(`Unsupported semver format: "${currentVersion}"`);
}
json.version = nextVersion;
fs.writeFileSync(filePath, `${JSON.stringify(json, null, 4)}\n`, 'utf8');
console.log(`Bumped version in ${fileName} to ${nextVersion}`);
return nextVersion;
}
const bumpedVersion = bump('package.json');
bump('package-lock.json', bumpedVersion);