@ministryofjustice/hmpps-precommit-hooks 2.0.0-beta.1 → 2.0.0-beta.3
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 +20 -0
- package/README.md +18 -5
- package/bin/prepare.sh +3 -11
- package/default-hooks.yaml +6 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- **Migrated from Husky to prek (pre-commit)** for managing git hooks
|
|
8
|
+
- Husky is automatically uninstalled during `npm install` if present
|
|
9
|
+
- Existing husky hooks are automatically removed
|
|
10
|
+
- prek is installed via Homebrew
|
|
11
|
+
|
|
12
|
+
### New Features
|
|
13
|
+
|
|
14
|
+
- Added `.pre-commit-config.yaml` configuration file with default hooks
|
|
15
|
+
- Configuration file is only created if it doesn't exist, preserving custom configurations
|
|
16
|
+
- Added automatic cleanup of legacy precommit scripts (`precommit:secrets`, `precommit:lint`, `precommit:verify`) from package.json
|
|
17
|
+
|
|
18
|
+
### Changes
|
|
19
|
+
|
|
20
|
+
- `prepare` script now installs prek instead of configuring husky
|
|
21
|
+
- Hooks are now managed through `.pre-commit-config.yaml` instead of husky scripts
|
|
22
|
+
|
|
3
23
|
## 1.0.2
|
|
4
24
|
|
|
5
25
|
Fix versions, accidentally mixed 1.0.0 and 0.1.0
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Teams are welcome to use this library. Please provide feedback via slack to the
|
|
|
9
9
|
|
|
10
10
|
## Migration from Husky
|
|
11
11
|
|
|
12
|
-
This package has migrated from using Husky to using [prek](https://github.com/pre-commit/pre-commit) (pre-commit) for managing git hooks. The migration will happen automatically during `npm install
|
|
12
|
+
This package has migrated from using Husky to using [prek](https://github.com/pre-commit/pre-commit) (pre-commit) for managing git hooks. The migration will happen automatically during `npm install` via a prepare hook:
|
|
13
13
|
|
|
14
14
|
- Husky will be uninstalled if present
|
|
15
15
|
- Existing husky hooks will be removed
|
|
@@ -45,10 +45,10 @@ HMPPS_HOOKS_VERSION: 1
|
|
|
45
45
|
repos:
|
|
46
46
|
- repo: local
|
|
47
47
|
hooks:
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
- repo: https://github.com/ministryofjustice/devsecops-hooks
|
|
49
|
+
rev: v1.x.x
|
|
50
|
+
hooks:
|
|
51
|
+
- id: baseline
|
|
52
52
|
- id: lint
|
|
53
53
|
name: linting code
|
|
54
54
|
language: system
|
|
@@ -109,6 +109,19 @@ Repo specific rules can be added by teams in `.gitleaks/config.toml` in their in
|
|
|
109
109
|
|
|
110
110
|
See the gitleaks documentation for how to create rules and [examples](https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml) or use the [online rule wizard](https://gitleaks.io/playground).
|
|
111
111
|
|
|
112
|
+
### Keeping up to date
|
|
113
|
+
|
|
114
|
+
`prek auto-update` can be used to pull in later versions of hooks including the devsecops-hooks.
|
|
115
|
+
|
|
116
|
+
Also, a manager can be added to your renovate.json config to allow renovate to raise PRs to keep hooks up to date:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"matchManagers": ["pre-commit"],
|
|
121
|
+
"groupName": "all pre-commit dependencies"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
112
125
|
### Running hooks manually
|
|
113
126
|
|
|
114
127
|
You can run all hooks manually using:
|
package/bin/prepare.sh
CHANGED
|
@@ -30,8 +30,8 @@ if [ -f "node_modules/.bin/husky" ]; then
|
|
|
30
30
|
endStage " ✅ "
|
|
31
31
|
|
|
32
32
|
if [ -f ".husky/pre-commit" ]; then
|
|
33
|
-
startStage "Deleting existing husky pre-commit
|
|
34
|
-
rm .husky
|
|
33
|
+
startStage "Deleting existing husky pre-commit hooks"
|
|
34
|
+
rm -Rf .husky
|
|
35
35
|
endStage " ✅ "
|
|
36
36
|
fi
|
|
37
37
|
fi
|
|
@@ -42,13 +42,6 @@ if ! command -v brew > /dev/null 2> /dev/null; then
|
|
|
42
42
|
exit 0
|
|
43
43
|
fi
|
|
44
44
|
|
|
45
|
-
# Install gitleaks if not present - this will be used by prek for secret scanning until we move over to devsecops hooks
|
|
46
|
-
if ! command -v gitleaks > /dev/null 2> /dev/null; then
|
|
47
|
-
startStage "Installing gitleaks"
|
|
48
|
-
brew install gitleaks
|
|
49
|
-
endStage " ✅ "
|
|
50
|
-
fi
|
|
51
|
-
|
|
52
45
|
# Install prek
|
|
53
46
|
if ! command -v prek > /dev/null 2> /dev/null; then
|
|
54
47
|
startStage "Installing prek"
|
|
@@ -56,11 +49,10 @@ if ! command -v prek > /dev/null 2> /dev/null; then
|
|
|
56
49
|
endStage " ✅ "
|
|
57
50
|
fi
|
|
58
51
|
|
|
59
|
-
# Copy default-hooks.yaml to target location
|
|
60
52
|
SOURCE_HOOKS="./node_modules/@ministryofjustice/hmpps-precommit-hooks/default-hooks.yaml"
|
|
61
53
|
TARGET_HOOKS=".pre-commit-config.yaml"
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
# Copy default-hooks.yaml to target location for first time initialisation only
|
|
64
56
|
if [ ! -f "$TARGET_HOOKS" ]; then
|
|
65
57
|
startStage "Creating .pre-commit-config.yaml"
|
|
66
58
|
cp "$SOURCE_HOOKS" "$TARGET_HOOKS"
|
package/default-hooks.yaml
CHANGED
|
@@ -5,24 +5,17 @@
|
|
|
5
5
|
# Other hooks maybe added or removed as needed to suit individual project requirements.
|
|
6
6
|
|
|
7
7
|
repos:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# - id: baseline
|
|
8
|
+
- repo: https://github.com/ministryofjustice/devsecops-hooks
|
|
9
|
+
rev: v1.3.0
|
|
10
|
+
hooks:
|
|
11
|
+
- id: baseline
|
|
13
12
|
- repo: local
|
|
14
13
|
hooks:
|
|
15
|
-
- id: gitleaks
|
|
16
|
-
name: Scan commit for secrets
|
|
17
|
-
language: system
|
|
18
|
-
entry: gitleaks git --pre-commit --redact --staged --verbose --config .gitleaks/config.toml --gitleaks-ignore-path .gitleaks/.gitleaksignore
|
|
19
|
-
require_serial: true
|
|
20
|
-
pass_filenames: false
|
|
21
14
|
- id: lint
|
|
22
15
|
name: linting code
|
|
23
16
|
language: system
|
|
24
|
-
entry:
|
|
25
|
-
|
|
17
|
+
entry: ./node_modules/.bin/lint-staged
|
|
18
|
+
types_or: [ts,javascript,css]
|
|
26
19
|
require_serial: true
|
|
27
20
|
pass_filenames: false
|
|
28
21
|
- id: typecheck
|