Skip to content

Commit 1bf7192

Browse files
author
Thomas G.
committed
chore: 🔧 use zz_log in githooks
1 parent 5f34bd5 commit 1bf7192

9 files changed

Lines changed: 22 additions & 20 deletions

src/githooks/_commit-msg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ if [ -t 1 ]; then
77
fi
88

99
# Apply commitlint rules to the latest commit message
10-
npx --yes chalk-cli --no-stdin -t "{blue →} Applying commitlint rules to the latest commit..."
10+
zz_log i "Applying commitlint rules to the latest commit..."
1111
PLUGINS=$(cat package.json | npx --yes jqn '.commitlint.extends' | tr -d "'[]:")
1212
npm list $PLUGINS 2>/dev/null 1>&2 || npm install --no-save $PLUGINS 2>/dev/null 1>&2 && npx --yes commitlint --edit "$1" && npx --yes devmoji -e

src/githooks/_lint-staged.package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
"lint": "npx --yes lint-staged"
44
},
55
"lint-staged": {
6-
"*.php": ["composer lint"],
6+
"*.php": [
7+
"composer lint"
8+
],
79
"*.{js,jsx,ts,tsx,md,html,css,json,vue, yaml, yml, sh}": [
810
"npx --yes prettier --write"
911
],
10-
"*.json": ["normalize-json -s -a -i -t 4"]
12+
"*.json": [
13+
"normalize-json -s -a -i -t 4 -l true"
14+
]
1115
}
1216
}

src/githooks/_post-checkout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ isRebase() {
1818

1919
# Check if the current Git command is a rebase
2020
if test "$GIT_COMMAND" = "rebase"; then
21-
npx --yes chalk-cli --no-stdin -t "{green ✔} Skip post-checkout hook during rebase."
21+
zz_log s "Skip post-checkout hook during rebase."
2222
exit 0
2323
fi

src/githooks/_post-merge.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ isChanged() {
1414
# Checkout composer.lock or package-lock.json if changed
1515
if isChanged 'composer.lock' || isChanged 'package-lock.json'; then
1616
git checkout --theirs composer.lock package-lock.json && git add composer.lock package-lock.json
17-
npx --yes chalk-cli --no-stdin -t "{green.bold Files <package-lock.json> or <composer.lock> changed.}"
18-
npx --yes chalk-cli --no-stdin -t "{green.bold Run composer/npm install to bring your dependencies up to date.}"
17+
zz_log s "Files <package-lock.json> or <composer.lock> changed."
18+
zz_log s "Run composer/npm install to bring your dependencies up to date."
1919
fi

src/githooks/_pre-commit.sh

100755100644
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99

1010
# Check if the current Git command is a rebase
1111
if test "$GIT_COMMAND" = "rebase"; then
12-
npx --yes chalk-cli --no-stdin -t "{green ✔} Skip pre-commit hook during rebase"
12+
zz_log s "Skip pre-commit hook during rebase"
1313
exit 0
1414
fi
1515

@@ -19,7 +19,7 @@ echo $GIT_COMMAND
1919
if git diff ${@:---cached --name-only} | grep -q "package.json"; then
2020

2121
# ensure that the package.json is valid and package-lock.json is up-to-date
22-
npx --yes chalk-cli --no-stdin -t "{blue →} Ensure that the package.json is valid and package-lock.json is up-to-date..."
22+
zz_log i "Ensure that the package.json is valid and package-lock.json is up-to-date..."
2323

2424
ws=$(npm pkg get workspaces)
2525
if test "$ws" = "undefined" || test "$ws" = "{}"; then
@@ -30,17 +30,17 @@ if git diff ${@:---cached --name-only} | grep -q "package.json"; then
3030

3131
# commit the updated package-lock.json if file changed
3232
if git diff --quiet package-lock.json; then
33-
npx --yes chalk-cli --no-stdin -t "{green ✔} package-lock.json update not required"
33+
zz_log s "package-lock.json update not required"
3434
else
35-
git add package-lock.json && npx --yes chalk-cli --no-stdin -t "{yellow ⚠} Updated package-lock.json"
35+
git add package-lock.json && zz_log w "Updated package-lock.json"
3636
fi
3737
fi
3838

3939
# Check if the current commit contains composer.json changes
4040
if git diff ${@:---cached --name-only} | grep -q "composer.json"; then
4141

4242
# ensure that the composer.json is valid and composer.lock is up-to-date
43-
npx --yes chalk-cli --no-stdin -t "{blue →} Ensure that the composer.json is valid and composer.lock is up-to-date..."
43+
zz_log i "Ensure that the composer.json is valid and composer.lock is up-to-date..."
4444
composer validate --no-check-all --strict 2>&1 | grep -oP 'Required package "\K[^"]+' | while read -r package; do
4545
composer require --ignore-platform-reqs --with-all-dependencies --no-scripts --no-interaction --no-progress --no-install "$package"
4646
done
@@ -50,9 +50,9 @@ if git diff ${@:---cached --name-only} | grep -q "composer.json"; then
5050

5151
# commit the updated composer.lock if file changed
5252
if git diff --quiet composer.lock; then
53-
npx --yes chalk-cli --no-stdin -t "{green ✔} composer.lock update not required"
53+
zz_log s "composer.lock update not required"
5454
else
55-
git add composer.lock && npx --yes chalk-cli --no-stdin -t "{yellow ⚠} Updated composer.lock"
55+
git add composer.lock && zz_log w "Updated composer.lock"
5656
fi
5757
fi
5858

src/githooks/_prepare-commit-msg.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ npm install --no-save $(cat package.json | npx --yes jqn '.config.commitizen.pat
1212

1313
# Edit commit message
1414
if [ $(grep -cv -e '^#' -e '^$' .git/COMMIT_EDITMSG) -eq 0 ]; then
15-
(exec </dev/tty && npx --yes git-cz --hook || npx --yes chalk-cli --no-stdin -t "{red !} Unable to start commitizen.") || npx --yes chalk-cli --no-stdin -t "{red !} Commitizen failed."
15+
(exec </dev/tty && npx --yes git-cz --hook || zz_log e "Unable to start commitizen.") || zz_log e "Commitizen failed."
1616
else
17-
npx --yes chalk-cli --no-stdin -t "{blue →} Commitizen not relevant. Skipping..."
17+
zz_log i "Commitizen not relevant. Skipping..."
1818
fi

src/githooks/_prettier.package.json

100644100755
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"prettier": {
33
"insertPragma": true,
4-
"plugins": [
5-
"prettier-plugin-sh"
6-
],
4+
"plugins": ["prettier-plugin-sh"],
75
"semi": false,
86
"singleQuote": true,
97
"tabWidth": 4,

src/githooks/configure-hooks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ git config core.hooksPath .git/hooks
66
### Make a symbolic link to the hook directory for each hook starting with '_' and ending with '.sh'
77
find $source -name '_*.sh' | sort | while read file; do
88
hook=$(basename $file | sed 's/^_//;s/\.sh$//')
9-
echo "Link $file to .git/hooks/$hook"
9+
zz_log - "Link $file to .git/hooks/$hook"
1010
ln -sf $file .git/hooks/$hook
1111
done

src/githooks/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "githooks",
33
"name": "Git Hooks",
44
"description": "A feature to add useful Git hooks to your project",
5-
"version": "5.5.0",
5+
"version": "5.6.0",
66
"dependsOn": {
77
"ghcr.io/devcontainers/features/node": {},
88
"ghcr.io/tomgrv/devcontainer-features/common-utils:3": {},

0 commit comments

Comments
 (0)