diff --git a/public/themes/custom/hdbt_subtheme/.husky/.gitignore b/public/themes/custom/hdbt_subtheme/.husky/.gitignore new file mode 100644 index 00000000..31354ec1 --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/public/themes/custom/hdbt_subtheme/.husky/commit-msg b/public/themes/custom/hdbt_subtheme/.husky/commit-msg new file mode 100644 index 00000000..503b8fdd --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/.husky/commit-msg @@ -0,0 +1,14 @@ +#!/bin/bash + +# Supported patterns: +# feature/PROJECT-1234-test-test +# PROJECT-1234-test-test +# PROJECT-1234_test_test +id=$(echo `git rev-parse --abbrev-ref HEAD` | sed -nE 's|([a-z]+/)?([A-Z]+-[0-9]+)(-.+)?(_.+)?|\2|p') + +# only prepare commit message if pattern matched and jiraId was found +if [[ ! -z $id ]]; then + # $1 is the name of the file containing the commit message + # Prepend "ABCD-123: " + sed -i.bak -E "1s/^/${id}: /" $1 +fi diff --git a/public/themes/custom/hdbt_subtheme/.husky/pre-commit b/public/themes/custom/hdbt_subtheme/.husky/pre-commit new file mode 100644 index 00000000..024a453e --- /dev/null +++ b/public/themes/custom/hdbt_subtheme/.husky/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +# Define the hdbt_subtheme path relative to the Git root +SUBTHEME_DIR="public/themes/custom/hdbt_subtheme/src" + +# Check if any staged file is inside the hdbt_subtheme +if git diff --cached --name-only | grep -q "^$SUBTHEME_DIR"; then + echo "Detected changes in hdbt_subtheme/src/, running lint..." + cd "$SUBTHEME_DIR" || exit 1 + npm run lint +fi diff --git a/public/themes/custom/hdbt_subtheme/package-lock.json b/public/themes/custom/hdbt_subtheme/package-lock.json index a73d6580..1ca50db1 100644 --- a/public/themes/custom/hdbt_subtheme/package-lock.json +++ b/public/themes/custom/hdbt_subtheme/package-lock.json @@ -3345,9 +3345,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001698", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001698.tgz", - "integrity": "sha512-xJ3km2oiG/MbNU8G6zIq6XRZ6HtAOVXsbOrP/blGazi52kc5Yy7b6sDA5O+FbROzRrV7BSTllLHuNvmawYUJjw==", + "version": "1.0.30001699", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001699.tgz", + "integrity": "sha512-b+uH5BakXZ9Do9iK+CkDmctUSEqZl+SP056vc5usa0PL+ev5OHw003rZXcnjNDv3L8P5j6rwT6C0BPKSikW08w==", "funding": [ { "type": "opencollective", @@ -3361,8 +3361,7 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ], - "license": "CC-BY-4.0" + ] }, "node_modules/chalk": { "version": "2.4.2", @@ -13055,9 +13054,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001698", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001698.tgz", - "integrity": "sha512-xJ3km2oiG/MbNU8G6zIq6XRZ6HtAOVXsbOrP/blGazi52kc5Yy7b6sDA5O+FbROzRrV7BSTllLHuNvmawYUJjw==" + "version": "1.0.30001699", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001699.tgz", + "integrity": "sha512-b+uH5BakXZ9Do9iK+CkDmctUSEqZl+SP056vc5usa0PL+ev5OHw003rZXcnjNDv3L8P5j6rwT6C0BPKSikW08w==" }, "chalk": { "version": "2.4.2", diff --git a/public/themes/custom/hdbt_subtheme/package.json b/public/themes/custom/hdbt_subtheme/package.json index c9ba1cd6..eeed4c4f 100644 --- a/public/themes/custom/hdbt_subtheme/package.json +++ b/public/themes/custom/hdbt_subtheme/package.json @@ -10,7 +10,8 @@ "build": "webpack --progress --mode=production --config webpack.config.js", "preinstall": "npx update-browserslist-db@latest", "lint": "lint-staged", - "lint:js": "eslint --fix src/" + "lint:js": "eslint --fix src/", + "prepare": "cd ../../../.. && husky install public/themes/custom/hdbt_subtheme/.husky || true" }, "dependencies": { "@babel/core": "^7.23.2",