Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/set up husky and pre-commit hook for linting and format check (#3867)
dw-0fd26253e7afc
diff --git a/.husky/pre-commit b/.husky/pre-commitnew file mode 100644index 0000000000..4bf77522a5--- /dev/null+++ b/.husky/pre-commit@@ -0,0 +1,6 @@+# Run linting and stop the commit process if any errors are found+# --quiet suppresses warnings (temporary until all warnings are fixed)+npm run lint --quiet || exit 1++# Check formatting on modified and uncommitted files, stop the commit if issues are found+npm run format:check --uncommitted || exit 1diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 00021fbfce..f2464c3509 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## Unreleased+### Added++- Set up a git-hook via `husky` to lint and format the changes before a commit+### Fixed- Handled an exception in the historical market data gathering of derived currenciesdiff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex 0c76a29244..b009679ac0 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -14,7 +14,6 @@1. Run `npm install`1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)1. Run `npm run database:setup` to initialize the database schema-1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks1. Start the [server](#start-server) and the [client](#start-client)1. Open https://localhost:4200/en in your browser1. Create a new user via _Get Started_ (this first user will get the role `ADMIN`)diff --git a/git-hooks/pre-commit b/git-hooks/pre-commitdeleted file mode 100755index b2b86eac12..0000000000--- a/git-hooks/pre-commit+++ /dev/null@@ -1,26 +0,0 @@-#!/bin/bash--# Will check if "npm run format" is run before executing.-# Called by "git commit" with no arguments. The hook should-# exit with non-zero status after issuing an appropriate message if-# it wants to stop the commit.--echo "Running npm run format"--# Run the command and loop over its output-FILES_TO_STAGE=""-i=0-while IFS= read -r line; do- # Process each line here- ((i++))- if [ $i -le 2 ]; then- continue- fi- if [[ $line == Done* ]]; then- break- fi- FILES_TO_STAGE="$FILES_TO_STAGE $line"--done < <(npm run format)-git add $FILES_TO_STAGE-echo "Files formatted. Committing..."diff --git a/package-lock.json b/package-lock.jsonindex b848e8188d..5edf7d5106 100644--- a/package-lock.json+++ b/package-lock.json@@ -143,6 +143,7 @@"eslint-plugin-cypress": "2.15.1","eslint-plugin-import": "2.29.1","eslint-plugin-storybook": "0.6.15",+ "husky": "9.1.6","jest": "29.7.0","jest-environment-jsdom": "29.7.0","jest-preset-angular": "14.1.0",@@ -20653,6 +20654,21 @@"node": ">=8.12.0"}},+ "node_modules/husky": {+ "version": "9.1.6",+ "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.6.tgz",+ "integrity": "sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==",+ "dev": true,+ "bin": {+ "husky": "bin.js"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/typicode"+ }+ },"node_modules/hyperdyperid": {"version": "1.2.0","resolved": "https://registry.npmjs.org/hyperdyperid/-/hyperdyperid-1.2.0.tgz",diff --git a/package.json b/package.jsonindex 584407f1d7..06fd92a8c8 100644--- a/package.json+++ b/package.json@@ -33,10 +33,11 @@"format:check": "nx format:check","format:write": "nx format:write","help": "nx help",- "lint": "nx lint",+ "lint": "nx run-many --target=lint --all","ng": "nx","nx": "nx","postinstall": "prisma generate",+ "prepare": "husky","prisma": "prisma","replace-placeholders-in-build": "node ./replace.build.js","start": "node dist/apps/api/main",@@ -188,6 +189,7 @@"eslint-plugin-cypress": "2.15.1","eslint-plugin-import": "2.29.1","eslint-plugin-storybook": "0.6.15",+ "husky": "9.1.6","jest": "29.7.0","jest-environment-jsdom": "29.7.0","jest-preset-angular": "14.1.0",