Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Restore husky (#444)

Krystle Salazarae327e0705fc
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100755
index 000000000..01170b47a
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,15 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+# Generate a new openverse.pot file if en.json has changes
+TRANSFILE=src/locales/en.json
+POTFILE=src/locales/po-files/openverse.pot
+CHANGED=$(git diff --staged --name-only HEAD)
+
+if [[ "$CHANGED" == *"$TRANSFILE"* ]] && [[ "$CHANGED" != *"$POTFILE"* ]]; then
+ npm run i18n:generate-pot
+ git add $POTFILE
+fi
+
+# Lint staged files
+npx lint-staged
diff --git a/.husky/pre-push b/.husky/pre-push
new file mode 100755
index 000000000..449fcdee1
--- /dev/null
+++ b/.husky/pre-push
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npm test
diff --git a/package-lock.json b/package-lock.json
index 33cc4d60b..805ed6cb2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -67,6 +67,7 @@
"eslint-plugin-vue": "^7.8.0",
"eslint-plugin-vuejs-accessibility": "^0.6.1",
"glob": "^7.1.6",
+ "husky": "^7.0.1",
"jest": "^26.6.3",
"jest-transform-stub": "^2.0.0",
"lint-staged": "^11.1.1",
@@ -18947,6 +18948,21 @@
"node": ">=8.12.0"
}
},
+ "node_modules/husky": {
+ "version": "7.0.4",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz",
+ "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==",
+ "dev": true,
+ "bin": {
+ "husky": "lib/bin.js"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/iconv-lite": {
"version": "0.4.24",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
@@ -53713,6 +53729,12 @@
"integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==",
"dev": true
},
+ "husky": {
+ "version": "7.0.4",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz",
+ "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==",
+ "dev": true
+ },
"iconv-lite": {
"version": "0.4.24",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
diff --git a/package.json b/package.json
index 3f242b111..e9f471388 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
"format:test": "prettier --check .",
"vue-i18n-extract": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/locales/*.?(json)'",
"postinstall": "patch-package",
+ "prepare": "husky install",
"i18n:get-valid-locales": "node src/locales/scripts/get-validated-locales",
"i18n:get-translations": "node src/locales/scripts/get-translations && npm run i18n:get-valid-locales",
"i18n:generate-pot": "node src/locales/scripts/json-to-pot",
@@ -95,6 +96,7 @@
"eslint-plugin-vue": "^7.8.0",
"eslint-plugin-vuejs-accessibility": "^0.6.1",
"glob": "^7.1.6",
+ "husky": "^7.0.1",
"jest": "^26.6.3",
"jest-transform-stub": "^2.0.0",
"lint-staged": "^11.1.1",