@commitlint/config-nx-scopes 16.2.1 → 16.3.0
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 +11 -0
- package/index.js +11 -1
- package/package.json +2 -2
- package/readme.md +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [16.3.0](https://github.com/conventional-changelog/commitlint/compare/v16.2.4...v16.3.0) (2022-05-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add ability to filter Nx projects in @commitlint/config-nx-scopes ([#3155](https://github.com/conventional-changelog/commitlint/issues/3155)) ([e595693](https://github.com/conventional-changelog/commitlint/commit/e595693eb9be51a874cff01580b883982083ba0e)), closes [#3152](https://github.com/conventional-changelog/commitlint/issues/3152)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [16.2.1](https://github.com/conventional-changelog/commitlint/compare/v16.2.0...v16.2.1) (2022-02-13)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @commitlint/config-nx-scopes
|
package/index.js
CHANGED
|
@@ -8,7 +8,10 @@ module.exports = {
|
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param {(params: Pick<Nx.ProjectConfiguration, 'name' | 'projectType' | 'tags'>) => boolean} selector
|
|
13
|
+
*/
|
|
14
|
+
function getProjects(context, selector = () => true) {
|
|
12
15
|
return Promise.resolve()
|
|
13
16
|
.then(() => {
|
|
14
17
|
const ctx = context || {};
|
|
@@ -24,6 +27,13 @@ function getProjects(context) {
|
|
|
24
27
|
})
|
|
25
28
|
.then((projects) => {
|
|
26
29
|
return projects
|
|
30
|
+
.filter((project) =>
|
|
31
|
+
selector({
|
|
32
|
+
name: project.name,
|
|
33
|
+
projectType: project.projectType,
|
|
34
|
+
tags: project.tags,
|
|
35
|
+
})
|
|
36
|
+
)
|
|
27
37
|
.filter((project) => project.targets)
|
|
28
38
|
.map((project) => project.name)
|
|
29
39
|
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/config-nx-scopes",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0",
|
|
4
4
|
"description": "Shareable commitlint config enforcing nx project and workspace names as scopes",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.js"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@commitlint/utils": "^16.2.1",
|
|
43
43
|
"@nrwl/tao": "^13.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "211f5140ab20c0513478d04b83fbd78ff3f6da80"
|
|
46
46
|
}
|
package/readme.md
CHANGED
|
@@ -12,6 +12,63 @@ npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
|
|
|
12
12
|
echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Filtering projects
|
|
16
|
+
|
|
17
|
+
You can filter projects by providing a filter function as the second parameter to `getProjects()`. The function will be called with an object containing each projects' `name`, `projectType`, and `tags`. Simply return a boolean to indicate whether the project should be included or not.
|
|
18
|
+
|
|
19
|
+
As an example, the following code demonstrates how to select only applications that are not end-to-end tests.
|
|
20
|
+
|
|
21
|
+
In your .commitlintrc.js file:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
const {
|
|
25
|
+
utils: {getProjects},
|
|
26
|
+
} = require('@commitlint/config-nx-scopes');
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
rules: {
|
|
30
|
+
'scope-enum': async (ctx) => [
|
|
31
|
+
2,
|
|
32
|
+
'always',
|
|
33
|
+
[
|
|
34
|
+
...(await getProjects(
|
|
35
|
+
ctx,
|
|
36
|
+
({name, projectType}) =>
|
|
37
|
+
!name.includes('e2e') && projectType == 'application'
|
|
38
|
+
)),
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
// . . .
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Here is another example where projects tagged with 'stage:end-of-life' are not allowed to be used as the scope for a commit.
|
|
47
|
+
|
|
48
|
+
In your .commitlintrc.js file:
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
const {
|
|
52
|
+
utils: {getProjects},
|
|
53
|
+
} = require('@commitlint/config-nx-scopes');
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
rules: {
|
|
57
|
+
'scope-enum': async (ctx) => [
|
|
58
|
+
2,
|
|
59
|
+
'always',
|
|
60
|
+
[
|
|
61
|
+
...(await getProjects(
|
|
62
|
+
ctx,
|
|
63
|
+
({tags}) => !tags.includes('stage:end-of-life')
|
|
64
|
+
)),
|
|
65
|
+
],
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
// . . .
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
15
72
|
## Examples
|
|
16
73
|
|
|
17
74
|
```
|