From eb3098a2f9e768397a52e772cd4f7ef1d3736210 Mon Sep 17 00:00:00 2001 From: dbale-altoros Date: Thu, 19 Dec 2024 15:00:46 -0300 Subject: [PATCH 1/2] removed husky --- .husky/pre-commit | 4 ---- DEV-README.md | 8 ++++++++ README.md | 4 ++-- package-lock.json | 40 +++++++++---------------------------- package.json | 7 ++++--- scripts/check-changes.js | 26 ++++++++++++++++++++++++ scripts/generate-changed.sh | 11 ---------- 7 files changed, 49 insertions(+), 51 deletions(-) delete mode 100755 .husky/pre-commit create mode 100644 DEV-README.md create mode 100644 scripts/check-changes.js delete mode 100644 scripts/generate-changed.sh diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index e09f21fc..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -sh ./scripts/generate-changed.sh diff --git a/DEV-README.md b/DEV-README.md new file mode 100644 index 00000000..93d562a0 --- /dev/null +++ b/DEV-README.md @@ -0,0 +1,8 @@ +## Setting up Git Hooks + +After cloning the repository, set up the pre-commit hook by running the following commands: + +```sh +touch .git/hooks/pre-commit +chmod +x .git/hooks/pre-commit +echo '#!/bin/sh\nnode scripts/check-changes.js' > .git/hooks/pre-commit \ No newline at end of file diff --git a/README.md b/README.md index 91cdf52e..e6b341f0 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ Or disable all validations for a group of lines: ### Style Guide Rules [Full list with all supported Style Guide Rules](docs/rules.md#style-guide-rules) ### Best Practices Rules -[Full list with all supported Best Practices Rules](docs/rules.md#best-practise-rules) +[Full list with all supported Best Practices Rules](docs/rules.md#best-practices-rules) ## Docker ### Solhint has an official Docker Image @@ -269,7 +269,7 @@ Related documentation you may find [here](https://protofire.github.io/solhint/). The Solidity parser used is [`@solidity-parser/parser`](https://github.com/solidity-parser/parser). -## Licence +## License MIT diff --git a/package-lock.json b/package-lock.json index 3a57c215..fef8f0d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "solhint", - "version": "4.2.0", + "version": "5.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solhint", - "version": "4.2.0", + "version": "5.0.4", "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.18.0", + "@solidity-parser/parser": "^0.19.0", "ajv": "^6.12.6", "antlr4": "^4.13.1-patch-1", "ast-parents": "^0.0.1", @@ -39,7 +39,6 @@ "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.3", "markdown-table": "^2.0.0", "mocha": "^10.2.0", "mocha-lcov-reporter": "^1.3.0", @@ -852,9 +851,9 @@ } }, "node_modules/@solidity-parser/parser": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.18.0.tgz", - "integrity": "sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA==" + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.19.0.tgz", + "integrity": "sha512-RV16k/qIxW/wWc+mLzV3ARyKUaMUTBy9tOLMzFhtNSKYeTAanQ3a5MudJKf/8arIFnA2L27SNjarQKmFg0w/jA==" }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", @@ -2917,21 +2916,6 @@ "node": ">=10.19.0" } }, - "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -6524,9 +6508,9 @@ "integrity": "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==" }, "@solidity-parser/parser": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.18.0.tgz", - "integrity": "sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA==" + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.19.0.tgz", + "integrity": "sha512-RV16k/qIxW/wWc+mLzV3ARyKUaMUTBy9tOLMzFhtNSKYeTAanQ3a5MudJKf/8arIFnA2L27SNjarQKmFg0w/jA==" }, "@szmarczak/http-timer": { "version": "5.0.1", @@ -8044,12 +8028,6 @@ "resolve-alpn": "^1.2.0" } }, - "husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true - }, "ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", diff --git a/package.json b/package.json index 82e01688..506d4cc5 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,12 @@ "/solhint.js" ], "author": "Ilya Drabenia ", - "contributors": ["Diego Bale "], + "contributors": [ + "Diego Bale " + ], "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.18.0", + "@solidity-parser/parser": "^0.19.0", "ajv": "^6.12.6", "antlr4": "^4.13.1-patch-1", "ast-parents": "^0.0.1", @@ -64,7 +66,6 @@ "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.3", "markdown-table": "^2.0.0", "mocha": "^10.2.0", "mocha-lcov-reporter": "^1.3.0", diff --git a/scripts/check-changes.js b/scripts/check-changes.js new file mode 100644 index 00000000..a8716748 --- /dev/null +++ b/scripts/check-changes.js @@ -0,0 +1,26 @@ +const { execSync } = require('child_process'); + +function changed() { + try { + // Run Git commands to check for changes in the lib/rules directory + const diffIndex = execSync('git diff-index --name-only -B -R -M -C HEAD lib/rules').toString().trim(); + const lsFiles = execSync('git ls-files -t -o -m lib/rules').toString().trim(); + + // Return true if there are changes + return diffIndex !== '' || lsFiles !== ''; + } catch (error) { + console.error('Error checking for changes:', error); + return false; + } +} + +if (changed()) { + try { + // Run npm commands if there are changes + execSync('npm run generate-rulesets', { stdio: 'inherit' }); + execSync('npm run docs', { stdio: 'inherit' }); + } catch (error) { + console.error('Error running npm commands:', error); + process.exit(1); + } +} \ No newline at end of file diff --git a/scripts/generate-changed.sh b/scripts/generate-changed.sh deleted file mode 100644 index a5b92f58..00000000 --- a/scripts/generate-changed.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -changed() { - git diff-index --name-only -B -R -M -C HEAD lib/rules - git ls-files -t -o -m lib/rules -} - -if [ "$(changed)" != "" ]; then - npm run generate-rulesets - npm run docs -fi From 7a0084f25851c161567db14d59d143215081d6fd Mon Sep 17 00:00:00 2001 From: dbale-altoros Date: Thu, 19 Dec 2024 15:16:56 -0300 Subject: [PATCH 2/2] remove husky --- DEV-README.md | 3 +++ scripts/check-changes.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/DEV-README.md b/DEV-README.md index 93d562a0..2e13cd8e 100644 --- a/DEV-README.md +++ b/DEV-README.md @@ -2,6 +2,9 @@ After cloning the repository, set up the pre-commit hook by running the following commands: +`git config --unset core.hooksPath` +To reset the hooks config to git default + ```sh touch .git/hooks/pre-commit chmod +x .git/hooks/pre-commit diff --git a/scripts/check-changes.js b/scripts/check-changes.js index a8716748..1aea29e0 100644 --- a/scripts/check-changes.js +++ b/scripts/check-changes.js @@ -23,4 +23,6 @@ if (changed()) { console.error('Error running npm commands:', error); process.exit(1); } +} else { + console.log('No changes detected in lib/rules.'); } \ No newline at end of file