diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..602d089 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +node scripts/incrementVersion.ts diff --git a/incrementVersion.ts b/incrementVersion.ts new file mode 100644 index 0000000..04233a6 --- /dev/null +++ b/incrementVersion.ts @@ -0,0 +1,24 @@ +// /incrementVersion.ts +import fs from "fs"; +import path from "path"; + +const filePath = path.join(__dirname, "../config/webVersion.ts"); +const fileContent = fs.readFileSync(filePath, "utf8"); + +const versionRegex = /const webVersion = "(\d+)\.(\d+)\.(\d+)\.(\d+)";/; +const match = fileContent.match(versionRegex); + +if (!match) { + console.error("Version format not found!"); + process.exit(1); +} + +const [_, major, minor, build, patch] = match; +const newVersion = `${major}.${minor}.${build}.${parseInt(patch, 10) + 1}`; +const updatedContent = fileContent.replace( + versionRegex, + `const webVersion = "${newVersion}";` +); + +fs.writeFileSync(filePath, updatedContent, "utf8"); +console.log(`Version updated to ${newVersion}`); diff --git a/package-lock.json b/package-lock.json index 82017df..7b57721 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "@types/redux-mock-store": "^1.5.0", "@types/testing-library__react": "^10.2.0", "cypress": "^14.0.0", - "husky": "^9.1.7", + "husky": "^8.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -4201,15 +4201,15 @@ } }, "node_modules/husky": { - "version": "9.1.7", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", - "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", "dev": true, "bin": { - "husky": "bin.js" + "husky": "lib/bin.js" }, "engines": { - "node": ">=18" + "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/typicode" diff --git a/package.json b/package.json index 87e0a1d..05e8f79 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "postbuild": "copy LICENSE_ICONIFY.txt out\\LICENSE_ICONIFY.txt", "start": "next start", "lint": "next lint", - "test": "jest" + "test": "jest", + "prepare": "husky install" }, "dependencies": { "@fontsource/roboto": "^5.1.0", @@ -50,7 +51,7 @@ "@types/redux-mock-store": "^1.5.0", "@types/testing-library__react": "^10.2.0", "cypress": "^14.0.0", - "husky": "^9.1.7", + "husky": "^8.0.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0",