diff --git a/package.json b/package.json index 08e38ec..7ee4cbc 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "url": "https://github.com/varletjs/rattail/issues" }, "scripts": { + "git-hooks": "simple-git-hooks", "dev": "tsup src/index.ts --format esm --out-dir=lib --watch --dts", "build": "tsup src/index.ts --format esm,cjs --out-dir=lib --dts --clean", "lint": "eslint . --fix --ext .ts,.js", @@ -44,11 +45,23 @@ "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs" }, + "simple-git-hooks": { + "pre-commit": "pnpm exec nano-staged --allow-empty", + "commit-msg": "pnpm exec vr commit-lint -p $1" + }, + "nano-staged": { + "*.{ts}": [ + "pnpm format", + "pnpm lint" + ] + }, "devDependencies": { "@types/node": "^22.8.1", "@varlet/eslint-config": "latest", "@varlet/release": "^0.3.0", "@vitest/coverage-istanbul": "^2.1.3", + "nano-staged": "0.8.0", + "simple-git-hooks": "^2.11.1", "eslint": "^8.53.0", "jsdom": "^25.0.1", "prettier": "^3.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 46bf66f..fdde6ac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,12 +26,18 @@ importers: jsdom: specifier: ^25.0.1 version: 25.0.1 + nano-staged: + specifier: 0.8.0 + version: 0.8.0 prettier: specifier: ^3.1.0 version: 3.3.3 rimraf: specifier: ^6.0.1 version: 6.0.1 + simple-git-hooks: + specifier: ^2.11.1 + version: 2.11.1 tsup: specifier: 8.3.5 version: 8.3.5(postcss@8.4.47)(typescript@5.6.3) @@ -2074,6 +2080,11 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} + nano-staged@0.8.0: + resolution: {integrity: sha512-QSEqPGTCJbkHU2yLvfY6huqYPjdBrOaTMKatO1F8nCSrkQGXeKwtCiCnsdxnuMhbg3DTVywKaeWLGCE5oJpq0g==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -2404,6 +2415,10 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + simple-git-hooks@2.11.1: + resolution: {integrity: sha512-tgqwPUMDcNDhuf1Xf6KTUsyeqGdgKMhzaH4PAZZuzguOgTl5uuyeYe/8mWgAr6IBxB5V06uqEf6Dy37gIWDtDg==} + hasBin: true + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -5165,6 +5180,10 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 + nano-staged@0.8.0: + dependencies: + picocolors: 1.1.1 + nanoid@3.3.7: {} nanospinner@1.1.0: @@ -5491,6 +5510,8 @@ snapshots: signal-exit@4.1.0: {} + simple-git-hooks@2.11.1: {} + slash@3.0.0: {} source-map-js@1.2.1: {}