diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 79bf55a..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -# Run lint and format before each commit -pnpm lint:fix && pnpm format - -# Add the changes to the staging area -git add . \ No newline at end of file diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 0000000..ae940f7 --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,42 @@ +#!/bin/sh + +if [ "$LEFTHOOK" = "0" ]; then + exit 0 +fi + +call_lefthook() +{ + dir="$(git rev-parse --show-toplevel)" + osArch=$(uname | tr '[:upper:]' '[:lower:]') + cpuArch=$(uname -m | sed 's/aarch64/arm64/') + + if lefthook -h >/dev/null 2>&1 + then + lefthook "$@" + elif test -f "$dir/node_modules/lefthook/bin/index.js" + then + "$dir/node_modules/lefthook/bin/index.js" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@" + elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" + then + "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@" + elif bundle exec lefthook -h >/dev/null 2>&1 + then + bundle exec lefthook "$@" + elif yarn lefthook -h >/dev/null 2>&1 + then + yarn lefthook "$@" + elif pnpm lefthook -h >/dev/null 2>&1 + then + pnpm lefthook "$@" + elif command -v npx >/dev/null 2>&1 + then + npx @evilmartians/lefthook "$@" + else + echo "Can't find lefthook in PATH" + fi +} + +call_lefthook run "prepare-commit-msg" "$@" diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..c10f9e6 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,14 @@ +# EXAMPLE USAGE: +# +# Refer for explanation to following link: +# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md +# + +pre-commit: + commands: + lint: + glob: "src/**/*.{ts,tsx,js,jsx}" + run: npx eslint {staged_files} --fix && git add {staged_files} + format: + glob: "src/**/*.{ts,tsx,js,jsx}" + run: npx prettier --write {staged_files} && git add {staged_files} \ No newline at end of file diff --git a/package.json b/package.json index 7925246..958cf7c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "lint": "next lint", "format": "prettier --write ./src/**/*.{ts,tsx,js,jsx}", "lint:fix": "eslint src/**/*.{js,jsx,ts,tsx} --fix", - "prepare": "husky install" + "postinstall": "lefthook install" }, "dependencies": { "@ducanh2912/next-pwa": "^9.2.1", @@ -62,7 +62,7 @@ "@typescript-eslint/parser": "^5.59.7", "eslint": "8.43.0", "eslint-config-next": "13.4.7", - "husky": "^8.0.3", + "lefthook": "^1.4.7", "prettier": "2.8.8", "prettier-plugin-tailwindcss": "^0.3.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 430e17d..fbe5cf2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -151,9 +151,9 @@ devDependencies: eslint-config-next: specifier: 13.4.7 version: 13.4.7(eslint@8.43.0)(typescript@5.1.3) - husky: - specifier: ^8.0.3 - version: 8.0.3 + lefthook: + specifier: ^1.4.7 + version: 1.4.7 prettier: specifier: 2.8.8 version: 2.8.8 @@ -6065,12 +6065,6 @@ packages: engines: {node: '>=14.18.0'} dev: true - /husky@8.0.3: - resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} - engines: {node: '>=14'} - hasBin: true - dev: true - /idb@7.1.1: resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==} dev: false @@ -6579,6 +6573,85 @@ packages: resolution: {integrity: sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==} dev: false + /lefthook-darwin-arm64@1.4.7: + resolution: {integrity: sha512-26zPoDw9gUXCroqf8OIb3qHjIq7XWrRQKdwFz2RgCfOphY22XNEucq0W+5on5s4LeqI9GieKeYQ+R0UBTjQ5LA==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /lefthook-darwin-x64@1.4.7: + resolution: {integrity: sha512-LSPiHTGEYqcABYuKqK+5+4SW6tmDXRUhSmZqcd7VSFsGa/9HU7imzqcbreiVPEO7ahKUDFYOB0riPV4g/Qys7w==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /lefthook-freebsd-arm64@1.4.7: + resolution: {integrity: sha512-b7LJdWwnrkh3uuWKqNfrlvau8/9N78IoxPz1z/xo468WcwroCYORRGpM+lKvgmKjrVFOJZQ6lFIYvVe8212wZg==} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-freebsd-x64@1.4.7: + resolution: {integrity: sha512-+sOYtxlyB9iwVHZLyoD0P7qg/8Guqjk5wmslXQrM89ilEQmDL+gnPRaqfEZrByjNEi/ltPTZ0YlOXeK/qxM0mg==} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-linux-arm64@1.4.7: + resolution: {integrity: sha512-Gli+cAqnBX0bCwv0mON8PM7SY/aIaM4H+nbqad5HlDHZ3ovoQBPxCmEvMxug7/Ssa3v3zdZ1cR2FkRrgzA1w+w==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /lefthook-linux-x64@1.4.7: + resolution: {integrity: sha512-XVN686RdGB8UB/zguDeY+Nx6ikN1I9g3QBGBOGPE3aj9waB86+FotPhat/c9wfb9T0gkhKnxMiQ9kO8nvDuQxw==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /lefthook-windows-arm64@1.4.7: + resolution: {integrity: sha512-CxZwmsIV9h1N2NPZ08a2V9jXzvaDMPwmyByDJZNOkWW1Z3Dx/Q76VK4X7aS3HhyLpudzwYEYScWhQ+SIOmx6IA==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /lefthook-windows-x64@1.4.7: + resolution: {integrity: sha512-Hu/GoPrJviM9gbys11ZJEIgTXyQ4btifUn6WBFW4M7NpA8rxx1bbLfXdDlcl6W28BGDb1aFIXVdnJIupK01hUw==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /lefthook@1.4.7: + resolution: {integrity: sha512-0fCJ1ekbGG+Pi+xK9bnBF4B5eXHf/FRSiuLRP0ofYYs8LO7p1f7qbYQTCj3qjGBs6mvv/wq4UIR8e+Gi+L06TA==} + hasBin: true + requiresBuild: true + optionalDependencies: + lefthook-darwin-arm64: 1.4.7 + lefthook-darwin-x64: 1.4.7 + lefthook-freebsd-arm64: 1.4.7 + lefthook-freebsd-x64: 1.4.7 + lefthook-linux-arm64: 1.4.7 + lefthook-linux-x64: 1.4.7 + lefthook-windows-arm64: 1.4.7 + lefthook-windows-x64: 1.4.7 + dev: true + /leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index bed93a3..aa5d84a 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,4 +1,4 @@ -import { type Metadata } from "next"; +import { Metadata } from "next"; export const metadata: Metadata = { title: "Overview",