--- /dev/null
+#!/bin/bash
+
+echo "Running husky pre-commit hook..."
+
+cd src/pybind/mgr/dashboard/frontend || exit 1
+
+HTML_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB -- "*.html" | wc -l)
+SCSS_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB -- "*.scss" | wc -l)
+TS_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB -- "*.ts" | wc -l)
+GHERKIN_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB -- "*.feature" | wc -l)
+
+if [[ "$HTML_FILES" -gt 0 && "$SCSS_FILES" -eq 0 && "$TS_FILES" -eq 0 ]]; then
+ echo 'Running "npm lint:html"...'
+ npm run lint:html
+fi
+
+if [[ "$SCSS_FILES" -gt 0 || "$TS_FILES" -gt 0 || "$GHERKIN_FILES" -gt 0 ]]; then
+ echo 'Running "npm fix"...'
+ npm run fix
+
+ # Add fixes to staging:
+ git add .
+
+ echo 'Running "npm lint"...'
+ npm run lint
+fi
+
+echo 'Pre-commit hook finished.'
"gherkin-lint": "4.2.4",
"html-linter": "1.1.1",
"htmllint-cli": "0.0.7",
+ "husky": "9.1.7",
"identity-obj-proxy": "3.0.0",
"isomorphic-form-data": "2.0.0",
"jest": "29.7.0",
"node": ">=8.12.0"
}
},
+ "node_modules/husky": {
+ "version": "9.1.7",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
+ "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "husky": "bin.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/hyperdyperid": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/hyperdyperid/-/hyperdyperid-1.2.0.tgz",
"build:localize": "node cd --env --pre && nx build --localize",
"postbuild:localize": "node cd --res",
"env_build": "node cd --env",
- "i18n": "npm run i18n:extract && npm run i18n:push && npm run i18n:pull && npm run i18n:merge",
+ "i18n": "npm run i18n:extract",
"i18n:extract": "nx extract-i18n --output-path src/locale --progress=false",
- "i18n:push": "npx i18ntool push -c i18n.config.json",
- "i18n:pull": "npx i18ntool pull -c i18n.config.json",
- "i18n:merge": "npx i18ntool merge -c i18n.config.json",
- "i18n:token": "npx i18ntool config token",
"test": "jest --watch",
"test:ci": "jest --clearCache && JEST_SILENT_REPORTER_DOTS=true jest --detectOpenHandles --coverage --reporters jest-silent-reporter",
"pree2e": "rm -f cypress/reports/results-*.xml || true",
"fix": "run-p -csl --aggregate-output fix:*",
"compodoc": "compodoc",
"doc-build": "compodoc -p tsconfig.app.json",
- "doc-serve": "compodoc --port 8444 -s tsconfig.app.json"
+ "doc-serve": "compodoc --port 8444 -s tsconfig.app.json",
+ "prepare-husky": "cd ../../../../../ && husky src/pybind/mgr/dashboard/frontend/.husky"
},
"private": true,
"dependencies": {
"gherkin-lint": "4.2.4",
"html-linter": "1.1.1",
"htmllint-cli": "0.0.7",
+ "husky": "9.1.7",
"identity-obj-proxy": "3.0.0",
"isomorphic-form-data": "2.0.0",
"jest": "29.7.0",