@ministryofjustice/hmpps-precommit-hooks 0.0.1-alpha.3 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -1
- package/bin/init.sh +3 -6
- package/bin/prepare.sh +9 -4
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ This package aims to automatically install and configure husky with gitleaks to
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
6
6
|
|
|
7
|
-
This library is
|
|
7
|
+
**This library is currently: ready to adopt.**
|
|
8
|
+
Teams are welcome to use this library. Please provide feedback via slack to the `#typescript` channel.
|
|
8
9
|
|
|
9
10
|
## Migrating existing projects
|
|
10
11
|
|
package/bin/init.sh
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
8
8
|
startStage() {
|
|
9
|
-
printf "
|
|
9
|
+
printf "%s" "$1"
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
endStage() {
|
|
13
|
-
printf "
|
|
13
|
+
printf "%s\n" "$1"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
printError() {
|
|
@@ -18,7 +18,6 @@ printError() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
endStage "Setting up precommit hooks"
|
|
21
|
-
endStage "Checking prerequisites..."
|
|
22
21
|
|
|
23
22
|
if ! [ -f ./package.json ]; then
|
|
24
23
|
printError "Not a node project: $(pwd)! exiting!"
|
|
@@ -26,7 +25,7 @@ if ! [ -f ./package.json ]; then
|
|
|
26
25
|
fi
|
|
27
26
|
|
|
28
27
|
startStage " * Setting prepare script"
|
|
29
|
-
npm pkg set --silent scripts.prepare="hmpps-precommit-hooks"
|
|
28
|
+
npm pkg set --silent scripts.prepare="hmpps-precommit-hooks-prepare"
|
|
30
29
|
endStage " ✅"
|
|
31
30
|
|
|
32
31
|
if npm list husky > /dev/null 2>&1; then
|
|
@@ -45,8 +44,6 @@ else
|
|
|
45
44
|
npm --silent install
|
|
46
45
|
fi
|
|
47
46
|
|
|
48
|
-
endStage "Installing precommit hooks..."
|
|
49
|
-
|
|
50
47
|
startStage " * Adding npm scripts"
|
|
51
48
|
npm pkg --silent set scripts.precommit:secrets="gitleaks git --pre-commit --redact --staged --verbose --config .gitleaks/config.toml"
|
|
52
49
|
npm pkg --silent set scripts.precommit:lint="node_modules/.bin/lint-staged"
|
package/bin/prepare.sh
CHANGED
|
@@ -3,26 +3,31 @@
|
|
|
3
3
|
# This runs as part of any `npm install` via `prepare`
|
|
4
4
|
#
|
|
5
5
|
|
|
6
|
-
set -
|
|
6
|
+
set -eo pipefail
|
|
7
7
|
|
|
8
8
|
startStage() {
|
|
9
|
-
printf "
|
|
9
|
+
printf "%s" "$1"
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
endStage() {
|
|
13
|
-
printf "
|
|
13
|
+
printf "%s\n" "$1"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
printError() {
|
|
17
17
|
printf "\x1b[1;31m%s\x1b[0m\n" "$1"
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
if [ "$CI" = "true" ]; then
|
|
21
|
+
endStage "Not initialising precommit hooks in CI..."
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
20
25
|
# Initialise husky
|
|
21
26
|
node_modules/.bin/husky
|
|
22
27
|
|
|
23
28
|
# Check brew exists
|
|
24
29
|
if ! command -v brew &> /dev/null; then
|
|
25
|
-
printError "Brew is not installed
|
|
30
|
+
printError "Brew is not installed. You will need to install gitleaks separately and ensure it's on your PATH. exiting..."
|
|
26
31
|
exit 0
|
|
27
32
|
fi
|
|
28
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-precommit-hooks",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Precommit hooks for HMPPS typescript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"precommit"
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"@ministryofjustice/hmpps-precommit-hooks": "./bin/init.sh",
|
|
17
|
-
"hmpps-precommit-hooks": "./bin/prepare.sh",
|
|
17
|
+
"hmpps-precommit-hooks-prepare": "./bin/prepare.sh",
|
|
18
18
|
"test-secret-protection": "./bin/test.sh"
|
|
19
19
|
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"check-for-updates": "npx npm-check-updates -u"
|
|
22
|
+
},
|
|
20
23
|
"files": [
|
|
21
24
|
"*.md",
|
|
22
25
|
"bin/*.sh",
|