From 92c256b03dbd9257b62ee5f8ee444d6955ab19d7 Mon Sep 17 00:00:00 2001 From: nobkd <44443899+nobkd@users.noreply.github.com> Date: Fri, 14 Apr 2023 00:27:49 +0200 Subject: [PATCH] feat(hooks): add automatically adding version change --- .husky/post-commit | 6 ++++++ .husky/prepare-commit-msg | 18 ++++++++++++------ package-lock.json | 5 +++-- package.json | 2 +- public/manifest.json | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.husky/post-commit b/.husky/post-commit index cd11349..ec614bf 100755 --- a/.husky/post-commit +++ b/.husky/post-commit @@ -1,3 +1,9 @@ #!/bin/bash +flag_file_path='./.version-update' + +if [ -f $flag_file_path ]; then + git add package.json package-lock.json public/manifest.json + git commit --amend --no-edit +fi exit 0 \ No newline at end of file diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg index d9af847..fcde15c 100755 --- a/.husky/prepare-commit-msg +++ b/.husky/prepare-commit-msg @@ -1,5 +1,17 @@ #!/bin/bash +flag_file_path='./.version-update' +# If this file exists when entering the script, it means the version was already +# updated and we did a commit amend to update package.json and package-lock.json, +# so we must delete the file and exit the script. +if [ -f $flag_file_path ]; then + rm $flag_file_path + exit 0 +fi + +npm run format +touch $flag_file_path + # types commit_types='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)' minor_types='^(build|feat|revert)' @@ -11,12 +23,6 @@ msg=':\s.+' version_match='"version": *"[0-9.]\+"' version_str='"version": ' -# skip with env -if [ "$SKIP_PRE_COMMIT" = true ]; then - echo 'Skipping conventional-pre-commit hook...' - exit 0 -fi - # read message to var commit_msg=$(cat $1) diff --git a/package-lock.json b/package-lock.json index 48017bd..e6751b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,13 @@ { "name": "replace-maps", - "version": "1.0.1", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "replace-maps", - "version": "1.0.1", + "version": "1.1.0", + "hasInstallScript": true, "license": "Unlicense", "dependencies": { "leaflet": "^1.9.3" diff --git a/package.json b/package.json index 6e3e85b..b4b8cae 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Replace Maps iframes with OSM", "author": "nobkd", "license": "Unlicense", - "version": "1.0.1", + "version": "1.1.0", "type": "module", "homepage": "https://github.com/nobkd/replace-maps#readme", "bugs": { diff --git a/public/manifest.json b/public/manifest.json index f978879..19024f4 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -2,7 +2,7 @@ "description": "Replace Maps iframes with OSM", "manifest_version": 2, "name": "Replace Maps", - "version": "1.0.1", + "version": "1.1.0", "homepage_url": "https://github.com/nobkd/replace-maps", "icons": { "48": "icons/48.png",