]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard setup husky 64586/head
authorAfreen Misbah <afreen@ibm.com>
Sat, 19 Jul 2025 14:23:25 +0000 (19:53 +0530)
committerAfreen Misbah <afreen@ibm.com>
Fri, 1 Aug 2025 07:22:40 +0000 (12:52 +0530)
- setup pre-commit hook
- allows ease in catching errors and saves CI resources for nit-picks
- includes lint and fix commands
- removes dead commands for i18n

Signed-off-by: Afreen Misbah <afreen@ibm.com>
src/pybind/mgr/dashboard/frontend/.husky/pre-commit [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/package-lock.json
src/pybind/mgr/dashboard/frontend/package.json

diff --git a/src/pybind/mgr/dashboard/frontend/.husky/pre-commit b/src/pybind/mgr/dashboard/frontend/.husky/pre-commit
new file mode 100644 (file)
index 0000000..33b9f44
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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.'
index 7e4a72562abd979d74e86be62f2a60f3a7207a93..8f9ad3443678d0a9fe06105e3302f7be569095be 100644 (file)
@@ -97,6 +97,7 @@
         "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",
index 95ec0d35900372993a076cce49fb94d6fe5fe1ae..cc265518b34d8276e6c868e5a107db99f9a071b7 100644 (file)
     "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",
@@ -38,7 +34,8 @@
     "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",