@commitlint/config-nx-scopes 16.2.0 → 17.0.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 CHANGED
@@ -3,6 +3,43 @@
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
+ # [17.0.0](https://github.com/conventional-changelog/commitlint/compare/v16.3.0...v17.0.0) (2022-05-16)
7
+
8
+
9
+ * chore!: minimum node version v14 (#3128) ([ac5f9b4](https://github.com/conventional-changelog/commitlint/commit/ac5f9b47a9e3cd5c9d58b14da0feb426f06b1ef9)), closes [#3128](https://github.com/conventional-changelog/commitlint/issues/3128)
10
+
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * drop node v12 support
15
+
16
+ * chore: rename circleci windows job
17
+
18
+ node version is not defned by the name anyways (i think)
19
+
20
+
21
+
22
+
23
+
24
+ # [16.3.0](https://github.com/conventional-changelog/commitlint/compare/v16.2.4...v16.3.0) (2022-05-14)
25
+
26
+
27
+ ### Features
28
+
29
+ * 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)
30
+
31
+
32
+
33
+
34
+
35
+ ## [16.2.1](https://github.com/conventional-changelog/commitlint/compare/v16.2.0...v16.2.1) (2022-02-13)
36
+
37
+ **Note:** Version bump only for package @commitlint/config-nx-scopes
38
+
39
+
40
+
41
+
42
+
6
43
  # [16.2.0](https://github.com/conventional-changelog/commitlint/compare/v16.1.0...v16.2.0) (2022-01-25)
7
44
 
8
45
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const {Workspaces} = require('@nrwl/tao/src/shared/workspace');
1
+ const {Workspaces} = require('nx/src/config/workspaces');
2
2
 
3
3
  module.exports = {
4
4
  utils: {getProjects},
@@ -8,7 +8,10 @@ module.exports = {
8
8
  },
9
9
  };
10
10
 
11
- function getProjects(context) {
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.2.0",
3
+ "version": "17.0.0",
4
4
  "description": "Shareable commitlint config enforcing nx project and workspace names as scopes",
5
5
  "files": [
6
6
  "index.js"
@@ -27,20 +27,20 @@
27
27
  },
28
28
  "homepage": "https://commitlint.js.org/",
29
29
  "peerDependencies": {
30
- "@nrwl/tao": "^12.0.0 || ^13.0.0"
30
+ "nx": "^14.0.0"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
- "@nrwl/tao": {
33
+ "nx": {
34
34
  "optional": true
35
35
  }
36
36
  },
37
37
  "engines": {
38
- "node": ">=v12"
38
+ "node": ">=v14"
39
39
  },
40
40
  "devDependencies": {
41
- "@commitlint/test": "^16.0.0",
42
- "@commitlint/utils": "^16.0.0",
43
- "@nrwl/tao": "^13.0.0"
41
+ "@commitlint/test": "^17.0.0",
42
+ "@commitlint/utils": "^17.0.0",
43
+ "nx": "^14.0.0"
44
44
  },
45
- "gitHead": "66f722acb44482ac9e8409126215f2f42e930925"
45
+ "gitHead": "ed437d29464ab1b239deecb84ce4d1f2a5e471c6"
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
  ```