[chore] Added Husky for Automating Building and Linting Projects Before Push (#2032)

* chore: Added Husky as Root Dependency

* chore: Added Husky Prepush Script

* chore: Modified Husky Pre-Push Script to Conditionally Build Projects

* chore: added husky as dev dependency
This commit is contained in:
Henit Chobisa 2023-09-02 13:47:21 +05:30 committed by GitHub
parent abe8df4eca
commit 63d799310b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

23
.husky/pre-push Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"
changed_files=$(git diff --name-only HEAD~1)
app_changed=$(echo "$changed_files" | grep -E '^apps/app/' || true)
space_changed=$(echo "$changed_files" | grep -E '^apps/space/' || true)
echo $app_changed
echo $space_changed
if [ -n "$app_changed" ] && [ -n "$space_changed" ]; then
echo "Changes detected in both apps/app and apps/space. Building..."
yarn run lint
yarn run build
elif [ -n "$app_changed" ]; then
echo "Changes detected in apps/app. Building..."
yarn run lint --filter=app
yarn run build --filter=app
elif [ -n "$space_changed" ]; then
echo "Changes detected in apps/space. Building..."
yarn run lint --filter=space
yarn run build --filter=space
fi

View File

@ -7,16 +7,19 @@
"packages/*"
],
"scripts": {
"prepare": "husky install",
"build": "turbo run build",
"dev": "turbo run dev",
"start": "turbo run start",
"lint": "turbo run lint",
"clean": "turbo run clean"
},
"devDependencies": {
"eslint-config-custom": "*",
"prettier": "latest",
"turbo": "latest"
"turbo": "latest",
"husky": "^8.0.3"
},
"packageManager": "yarn@1.22.19"
}

View File

@ -4891,6 +4891,11 @@ https-proxy-agent@^5.0.0:
agent-base "6"
debug "4"
husky@^8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184"
integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==
idb@^7.0.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/idb/-/idb-7.1.1.tgz#d910ded866d32c7ced9befc5bfdf36f572ced72b"