diff --git a/.config/husky/pre-push b/.config/husky/pre-push new file mode 100755 index 0000000..2ded2d6 --- /dev/null +++ b/.config/husky/pre-push @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +set -e + +. "$(dirname -- "$0")/_/husky.sh" + +echo "************************************************************************" +echo "** Running sim-core's 'yarn fmt-check' **" +echo "** If this fails, run 'yarn fmt' and commit your fixes. **" +echo "** (Output is stored in .config/husky/husky.log) **" +echo "** This takes about 10 seconds... **" +echo "************************************************************************" + +cd apps/sim-core || exit 1 +yarn fmt-check > ../../.config/husky/husky.log 2>&1; + +echo "** Formatting check success. **" +echo "************************************************************************" diff --git a/.gitignore b/.gitignore index 341e591..ebf9c4e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ .next .old/ .vscode/ +.config/**/*.log dist/ node_modules/ target/ -test_artifacts/ \ No newline at end of file +test_artifacts/ diff --git a/apps/sim-core/package.json b/apps/sim-core/package.json index 9840a3a..bcbb328 100644 --- a/apps/sim-core/package.json +++ b/apps/sim-core/package.json @@ -8,6 +8,7 @@ "// 02": "", "preinstall": "node scripts/preinstall.js", "postinstall": "yarn build:utils && yarn build:engine-web", + "prepare": "cd ../.. && husky install .config/husky", "all": "npx npm-run-all", "fmt:scripts": "prettier \"scripts/**/*.{ts,tsx,js,json}\" --write", "fmt-check:scripts": "prettier \"scripts/**/*.{ts,tsx,js,json}\" --check", @@ -110,6 +111,7 @@ "file-loader": "6.2.0", "fork-ts-checker-webpack-plugin": "6.0.3", "html-webpack-plugin": "4.5.1", + "husky": "^8.0.0", "identity-obj-proxy": "3.0.0", "jest": "26.6.3", "jest-canvas-mock": "2.3.0", diff --git a/apps/sim-core/yarn.lock b/apps/sim-core/yarn.lock index 094e247..6b6df08 100644 --- a/apps/sim-core/yarn.lock +++ b/apps/sim-core/yarn.lock @@ -9506,6 +9506,11 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +husky@^8.0.0: + version "8.0.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" + integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== + hyphenate-style-name@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d"