From 53bb20781dc35bfb720a5e0a4d5bc89266152d30 Mon Sep 17 00:00:00 2001 From: baldo Date: Fri, 26 Aug 2022 16:16:26 +0200 Subject: [PATCH] Add pre-commit hook that runs all the checks. --- frontend/package.json | 2 ++ git-hooks/pre-commit | 21 +++++++++++++++++++++ package.json | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 git-hooks/pre-commit diff --git a/frontend/package.json b/frontend/package.json index b615739..eca9139 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,9 +8,11 @@ "email": "andreas@baldeau.net" }, "scripts": { + "check": "yarn run typecheck && yarn run lint", "dev": "vite", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview --port 5050", + "test": "yarn run test:unit", "test:unit": "vitest --environment jsdom", "typecheck": "vue-tsc --noEmit", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit new file mode 100755 index 0000000..a2f4452 --- /dev/null +++ b/git-hooks/pre-commit @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "${BASH_SOURCE[0]}")/../.." + +export PATH="$PWD/nix:$PATH" + +for directory in . ./frontend; do + if [[ -d "$directory" ]]; then + echo + echo "===================================================" + echo "Checking: $PWD" + echo "===================================================" + echo + + pushd "$directory" + yarn run check + popd + fi +done diff --git a/package.json b/package.json index 348a5de..7f37a8c 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,12 @@ "ffffng": "server/main.js" }, "scripts": { + "check": "yarn run build && yarn run lint && yarn run test", "test": "yarn run server:test", + "lint": "yarn run server:lint", "build": "yarn run server:build && grunt build && rsync -avzL --exclude='*/__mocks__/' --exclude='*.test.*' server-build/ dist/server/", "clean": "rm -rf server-build/ dist/ && grunt clean", - "dist": "yarn run clean && yarn run build && yarn run server:lint && ./bin/dist-fix-symlinks.sh && yarn run test", + "dist": "yarn run clean && yarn run build && yarn run check && ./bin/dist-fix-symlinks.sh", "client:serve": "grunt serve", "server:test": "jest --config=jest.server.config.js", "server:build": "tsc -b server && ln -sfv ../../server/db/patches ./server-build/db/ && ln -sfv ../server/templates ./server-build/ && ln -sfv ../server/mailTemplates ./server-build/",