@ministryofjustice/hmpps-precommit-hooks 0.0.1-alpha.2 → 0.0.1-alpha.4

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @ministryofjustice/precommit-hooks
1
+ # @ministryofjustice/hmpps-precommit-hooks
2
2
 
3
3
  This package aims to automatically install and configure husky with gitleaks to help catch potential secrets before committing them to github.
4
4
 
@@ -11,7 +11,7 @@ This library is in alpha. Teams are free to use this library but further breakin
11
11
  #### Automatically installing the library
12
12
 
13
13
  The package will self install and initialised by running via npx:
14
- `npx @ministryofjustice/precommit-hooks`
14
+ `npx @ministryofjustice/hmpps-precommit-hooks`
15
15
 
16
16
  Note: The project needs to be initialised before use - solely adding the library will make no difference.
17
17
  Once the project has been initialised, other developers should be able to develop against it without further configuration.
@@ -67,13 +67,13 @@ See the gitleaks documentation for how to create rules and [examples](https://gi
67
67
  Secret protection can be tested using the following command:
68
68
 
69
69
  ```bash
70
- npx -p @ministryofjustice/precommit-hooks -c test-secret-protection
70
+ npx -p @ministryofjustice/hmpps-precommit-hooks -c test-secret-protection
71
71
  ```
72
72
 
73
73
  This should fail similarly to:
74
74
 
75
75
  ```bash
76
- > npx -p @ministryofjustice/precommit-hooks -c test-secret-protection
76
+ > npx -p @ministryofjustice/hmpps-precommit-hooks -c test-secret-protection
77
77
  Creating test file containing dummy AWS_KEY=AKIA<SOME-VALUE>ASD
78
78
  Attempting to commit file containing secret
79
79
 
package/bin/init.sh CHANGED
@@ -26,7 +26,7 @@ if ! [ -f ./package.json ]; then
26
26
  fi
27
27
 
28
28
  startStage " * Setting prepare script"
29
- npm pkg set --silent scripts.prepare="hmpps-precommit-hooks"
29
+ npm pkg set --silent scripts.prepare="hmpps-precommit-hooks-prepare"
30
30
  endStage " ✅"
31
31
 
32
32
  if npm list husky > /dev/null 2>&1; then
@@ -35,12 +35,12 @@ if npm list husky > /dev/null 2>&1; then
35
35
  endStage " ✅"
36
36
  fi
37
37
 
38
- if ! npm list @ministryofjustice/precommit-hooks > /dev/null 2>&1; then
39
- startStage " * Installing @ministryofjustice/precommit-hooks"
40
- npm install --silent --save-dev @ministryofjustice/precommit-hooks
38
+ if ! npm list @ministryofjustice/hmpps-precommit-hooks > /dev/null 2>&1; then
39
+ startStage " * Installing @ministryofjustice/hmpps-precommit-hooks"
40
+ npm install --silent --save-dev @ministryofjustice/hmpps-precommit-hooks
41
41
  endStage " ✅"
42
42
  else
43
- endStage " * @ministryofjustice/precommit-hooks already installed ✅"
43
+ endStage " * @ministryofjustice/hmpps-precommit-hooks already installed ✅"
44
44
  # Run npm install to trigger prepare script
45
45
  npm --silent install
46
46
  fi
@@ -73,7 +73,7 @@ startStage " * Creating project gitleaks config"
73
73
  printf "%s\n" \
74
74
  "title = \"HMPPS Gitleaks configuration\"" \
75
75
  "[extend]" \
76
- "path = \"./node_modules/@ministryofjustice/precommit-hooks/config.toml\"" \
76
+ "path = \"./node_modules/@ministryofjustice/hmpps-precommit-hooks/config.toml\"" \
77
77
  > .gitleaks/config.toml
78
78
  endStage " ✅"
79
79
 
package/bin/prepare.sh CHANGED
@@ -3,7 +3,7 @@
3
3
  # This runs as part of any `npm install` via `prepare`
4
4
  #
5
5
 
6
- set -euo pipefail
6
+ set -eo pipefail
7
7
 
8
8
  startStage() {
9
9
  printf "\x1b[1;97m%s\x1b[0m" "$1"
@@ -17,6 +17,11 @@ 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ministryofjustice/hmpps-precommit-hooks",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "Precommit hooks for HMPPS typescript projects",
5
5
  "keywords": [
6
6
  "precommit"
@@ -14,7 +14,7 @@
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
20
  "files": [