diff --git a/.gitignore b/.gitignore index 57872d0..ff87634 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/vendor/ +vendor/ +node_modules/ \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..4b69191 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +KN='\033[0m' +BBlue='\033[1;34m' +BRed='\033[1;31m' + +REGEX_ISSUE_ID="[a-zA-Z0-9,._-]+-[0-9]+" + +BRANCH_NAME=$(git symbolic-ref --short HEAD) +ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID") +COMMIT_MESSAGE=$(cat "$1") + +if [ -z "$ISSUE_ID" ]; then + echo "${BRed}Branch name does not follow the expected pattern...${KN}" + exit 1 +fi + +case "$COMMIT_MESSAGE" in + "$ISSUE_ID"*) + exit 0 + ;; +esac + +echo "$ISSUE_ID: $COMMIT_MESSAGE" > "$1" diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..68000ca --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "payhub", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "husky": "^9.1.7" + } + }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6b87ff3 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "husky": "^9.1.7" + }, + "scripts": { + "prepare": "husky" + } +}