From fe1b8f0e1f9e26a602710c86a162bcfd65055bd7 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Sat, 7 Mar 2026 11:05:27 +0100 Subject: [PATCH] bump version to 0.1.2 and add bump-patch script for version management --- package-lock.json | 2 +- package.json | 2 +- scripts/bump-patch.mjs | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 scripts/bump-patch.mjs diff --git a/package-lock.json b/package-lock.json index 11dddbc..ca8d2ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@slawek/sk-tools", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 714bc96..0ec5326 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@slawek/sk-tools", - "version": "0.1.1", + "version": "0.1.2", "type": "module", "files": [ "dist", diff --git a/scripts/bump-patch.mjs b/scripts/bump-patch.mjs new file mode 100755 index 0000000..259dd83 --- /dev/null +++ b/scripts/bump-patch.mjs @@ -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);