Skip to content

Commit fbc5a89

Browse files
author
Thomas G.
committed
feat: ✨ improve config behavior
1 parent ab4c1fc commit fbc5a89

18 files changed

+307
-232
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- @format -->
2+
3+
# Changelog
4+
5+
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
6+
7+
## 1.1.0 (2024-06-22)
8+
9+
### Features
10+
11+
- ✨ add githook ([ab4c1fc](https://github.com/tomgrv/devcontainer-features/commit/ab4c1fc5eb4f712ed2009baf9a3cadb11097c7b5))
12+
- add features ([4b26d9d](https://github.com/tomgrv/devcontainer-features/commit/4b26d9d876caffb15078a6baaabf76d1a2707e6f))

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 126 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,132 @@
11
{
2-
"commit-and-tag-version": {
3-
"bumpFiles": [
4-
{
5-
"filename": "composer.json",
6-
"type": "json"
7-
},
8-
{
9-
"filename": "package.json",
10-
"type": "json"
11-
},
12-
{
13-
"filename": "VERSION",
14-
"type": "plain-text"
15-
}
16-
],
17-
"types": [
18-
{
19-
"type": "feat",
20-
"section": "Features"
21-
},
22-
{
23-
"type": "fix",
24-
"section": "Bug Fixes"
25-
},
26-
{
27-
"type": "chore",
28-
"hidden": true
29-
},
30-
{
31-
"type": "docs",
32-
"hidden": true
33-
},
34-
{
35-
"type": "style",
36-
"hidden": true
37-
},
38-
{
39-
"type": "refactor",
40-
"hidden": true
41-
},
42-
{
43-
"type": "perf",
44-
"hidden": true
45-
},
46-
{
47-
"type": "test",
48-
"hidden": true
49-
}
50-
],
2+
"commit-and-tag-version": {
3+
"bumpFiles": [
4+
{
5+
"filename": "src/githooks/devcontainer-feature.json",
6+
"type": "json"
7+
},
8+
{
9+
"filename": "src/gitutils/devcontainer-feature.json",
10+
"type": "json"
11+
},
12+
{
13+
"filename": "src/gitversion/devcontainer-feature.json",
14+
"type": "json"
15+
},
16+
{
17+
"filename": "src/pecl/devcontainer-feature.json",
18+
"type": "json"
19+
}
20+
],
21+
"types": [
22+
{
23+
"type": "feat",
24+
"section": "Features"
25+
},
26+
{
27+
"type": "fix",
28+
"section": "Bug Fixes"
29+
},
30+
{
31+
"type": "chore",
32+
"hidden": true
33+
},
34+
{
35+
"type": "docs",
36+
"hidden": true
37+
},
38+
{
39+
"type": "style",
40+
"hidden": true
41+
},
42+
{
43+
"type": "refactor",
44+
"hidden": true
45+
},
46+
{
47+
"type": "perf",
48+
"hidden": true
49+
},
50+
{
51+
"type": "test",
52+
"hidden": true
53+
}
54+
]
55+
},
5156
"scripts": {
52-
"prebump": "gitversion -config .gitversion -showvariable MajorMinorPatch"
53-
}
54-
},
55-
"scripts": {
56-
"release": "commit-and-tag-version --no-verify --",
57-
"lint": "lint-staged",
58-
"update": "npm-check-updates -i -u",
59-
"update-all": "npm run update -ws --root",
60-
"test": "echo \"Warning: no test specified\""
61-
},
62-
"commitlint": {
63-
"extends": [
64-
"@commitlint/config-conventional"
65-
],
66-
"rules": {
67-
"subject-case": [
68-
2,
69-
"never",
70-
[
71-
"start-case",
72-
"pascal-case",
73-
"upper-case"
57+
"release": "npx commit-and-tag-version --no-verify --",
58+
"lint": "npx lint-staged",
59+
"update": "npx npm-check-updates -i -u",
60+
"update-all": "npx npm run update -ws --root",
61+
"test": "echo \"Warning: no test specified\""
62+
},
63+
"commitlint": {
64+
"extends": [
65+
"@commitlint/config-conventional"
66+
],
67+
"rules": {
68+
"subject-case": [
69+
2,
70+
"never",
71+
[
72+
"start-case",
73+
"pascal-case",
74+
"upper-case"
75+
]
76+
],
77+
"scope-enum": [
78+
2,
79+
"always",
80+
[
81+
"deps",
82+
"release",
83+
"security",
84+
"i18n",
85+
"config",
86+
"add",
87+
"remove",
88+
"breaking",
89+
"modules",
90+
"packages",
91+
"ui-ux",
92+
"api",
93+
"model"
94+
]
95+
]
96+
}
97+
},
98+
"config": {
99+
"commitizen": {
100+
"path": "@commitlint/cz-commitlint"
101+
}
102+
},
103+
"git-precommit-checks": {
104+
"rules": [
105+
{
106+
"message": "You've got leftover conflict markers",
107+
"regex": "/^[<>|=]{4,}/m"
108+
},
109+
{
110+
"filter": "(^package\\.json|\\.git-precommit-checks.json)$",
111+
"message": "You have unfinished devs",
112+
"nonBlocking": "true",
113+
"regex": "(?:FIXME|TODO)"
114+
}
74115
]
75-
],
76-
"scope-enum": [
77-
2,
78-
"always",
79-
[
80-
"deps",
81-
"release",
82-
"security",
83-
"i18n",
84-
"config",
85-
"add",
86-
"remove",
87-
"breaking",
88-
"modules",
89-
"packages",
90-
"ui-ux",
91-
"api",
92-
"model"
116+
},
117+
"lint-staged": {
118+
"*.{js,jsx,ts,tsx,md,html,css,json,vue, yaml, yml}": [
119+
"npx prettier --write"
120+
],
121+
"*.php": [
122+
"composer lint"
93123
]
94-
]
95-
}
96-
},
97-
"config": {
98-
"commitizen": {
99-
"path": "@commitlint/cz-commitlint"
124+
},
125+
"prettier": {
126+
"trailingComma": "es5",
127+
"tabWidth": 4,
128+
"semi": false,
129+
"singleQuote": true,
130+
"insertPragma": true
100131
}
101-
},
102-
"git-precommit-checks": {
103-
"rules": [
104-
{
105-
"message": "You've got leftover conflict markers",
106-
"regex": "/^[<>|=]{4,}/m"
107-
},
108-
{
109-
"filter": "(^package\\.json|\\.git-precommit-checks.json)$",
110-
"message": "You have unfinished devs",
111-
"nonBlocking": "true",
112-
"regex": "(?:FIXME|TODO)"
113-
}
114-
]
115-
},
116-
"lint-staged": {
117-
"*.{js,jsx,ts,tsx,md,html,css,json,vue, yaml, yml}": [
118-
"prettier --write"
119-
],
120-
"*.php": [
121-
"composer lint"
122-
]
123-
},
124-
"prettier": {
125-
"trailingComma": "es5",
126-
"tabWidth": 4,
127-
"semi": false,
128-
"singleQuote": true,
129-
"insertPragma": true
130-
}
131132
}

src/githooks/README.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
1+
<!-- @format -->
12

2-
# Git Utils
3+
# Git Hooks
34

4-
This feature provides a set of utilities for working with Git repositories.
5+
This feature provides a set of hooks for working with Git repositories.
56

6-
The following aliases are included: [./alias.json](./src/gitutils/alias.json)
7+
The following hooks are included:
8+
9+
- `pre-commit` - Runs `git-pre-commit` to validate the code before committing and `lint-staged` to lint and format staged files
10+
- `prepare-commit-msg` - Runs `commitizen` to prepare commit messages
11+
- `commit-msg` - Runs `commitlint` to validate commit messages
12+
- `post-merge` - Handle changes in package.json and composer.json after a merge
13+
- `post-checkout` - Runs `git update` to update the current branch with the latest changes from the remote
14+
- `pre-push` - Runs `validate-branch-name` to validate the branch name before pushing
715

816
## Example Usage
917

1018
```json
1119
"features": {
12-
"ghcr.io/tomgrv/devcontainer-features/gitutils:1": {
13-
"version": "latest"
14-
}
20+
"ghcr.io/tomgrv/devcontainer-features/githooks:1": {}
1521
}
1622
```
1723

18-
## Options
19-
20-
| Options Id | Description | Type | Default Value |
21-
|-----|-----|-----|-----|
22-
| version | The version of GitUtils to install. | string | latest |
23-
24-
## GitFlow
25-
26-
Additionnaly, the feature installs the [git-flow](https:://github.com/nvie/gitflow) extension and sets up the Git configuration to use it.
27-
28-
Shortcuts are also added to the `git` command to make it easier to use the `git-flow` commands:
29-
30-
- `git beta` is a shortcut for `git flow release start`
31-
- `git hfix` is a shortcut for `git flow hotfix start`
32-
- `git prod` is a shortcut for `git flow release finish` and `git flow hotfix finish`
33-
34-
Those shortcuts work in cunjunction with the `gitversion` utility to automatically update the version number of the application.
24+
## Configuration
3525

36-
## Interactive Utilities
26+
All hooks utilities are installed globally and can be configured in the `package.json` file.
3727

38-
- `git fixup` - Amend the specified commit with current changes and rebase
28+
A default configuration is provided for each utility, but you can override it by modifying the `package.json` file.
3929

4030
## Contributing
4131

src/githooks/_commit-and-tag-version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@
5050
]
5151
},
5252
"scripts": {
53-
"release": "commit-and-tag-version --no-verify --"
53+
"release": "npx commit-and-tag-version --no-verify --"
5454
}
5555
}

src/githooks/_commitlint.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"config": {
3+
"commitizen": {
4+
"path": "@commitlint/cz-commitlint"
5+
}
6+
},
27
"commitlint": {
38
"extends": ["@commitlint/config-conventional"],
49
"rules": {

src/githooks/_config.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/githooks/_lint-staged.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
22
"scripts": {
3-
"lint": "lint-staged"
3+
"lint": "npx lint-staged"
44
},
55
"lint-staged": {
66
"*.{js,jsx,ts,tsx,md,html,css,json,vue, yaml, yml}": [
7-
"prettier --write"
7+
"npx prettier --write"
88
],
9-
"*.php": [
10-
"composer lint"
11-
]
9+
"*.php": ["composer lint"]
1210
}
13-
}
11+
}

src/githooks/configure-hooks.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -e
3+
4+
### Define current script directory as hook directory
5+
git config hooks.hookDir $(dirname $(readlink -f $0))

0 commit comments

Comments
 (0)