@commitlint/config-nx-scopes 18.4.4 → 18.5.1

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.
Files changed (2) hide show
  1. package/index.js +25 -28
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,10 +1,14 @@
1
- const {Workspaces} = require('nx/src/config/workspaces');
1
+ const {RuleConfigSeverity} = require('@commitlint/types');
2
+ const {
3
+ getProjects: getNXProjects,
4
+ } = require('nx/src/generators/utils/project-configuration');
5
+ const {FsTree} = require('nx/src/generators/tree');
2
6
 
3
7
  module.exports = {
4
8
  utils: {getProjects},
5
9
  rules: {
6
10
  'scope-enum': (ctx) =>
7
- getProjects(ctx).then((packages) => [2, 'always', packages]),
11
+ Promise.resolve([RuleConfigSeverity.Error, 'always', getProjects(ctx)]),
8
12
  },
9
13
  };
10
14
 
@@ -12,30 +16,23 @@ module.exports = {
12
16
  * @param {(params: Pick<Nx.ProjectConfiguration, 'name' | 'projectType' | 'tags'>) => boolean} selector
13
17
  */
14
18
  function getProjects(context, selector = () => true) {
15
- return Promise.resolve()
16
- .then(() => {
17
- const ctx = context || {};
18
- const cwd = ctx.cwd || process.cwd();
19
- const ws = new Workspaces(cwd);
20
- const workspace = ws.readWorkspaceConfiguration();
21
- return Object.entries(workspace.projects || {}).map(
22
- ([name, project]) => ({
23
- name,
24
- ...project,
25
- })
26
- );
27
- })
28
- .then((projects) => {
29
- return projects
30
- .filter((project) =>
31
- selector({
32
- name: project.name,
33
- projectType: project.projectType,
34
- tags: project.tags,
35
- })
36
- )
37
- .filter((project) => project.targets)
38
- .map((project) => project.name)
39
- .map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
40
- });
19
+ const ctx = context || {};
20
+ const cwd = ctx.cwd || process.cwd();
21
+
22
+ const projects = getNXProjects(new FsTree(cwd, false));
23
+ return Array.from(projects.entries())
24
+ .map(([name, project]) => ({
25
+ name,
26
+ ...project,
27
+ }))
28
+ .filter((project) =>
29
+ selector({
30
+ name: project.name,
31
+ projectType: project.projectType,
32
+ tags: project.tags,
33
+ })
34
+ )
35
+ .filter((project) => project.targets)
36
+ .map((project) => project.name)
37
+ .map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
41
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commitlint/config-nx-scopes",
3
- "version": "18.4.4",
3
+ "version": "18.5.1",
4
4
  "description": "Shareable commitlint config enforcing nx project names as scopes",
5
5
  "files": [
6
6
  "index.js"
@@ -41,5 +41,5 @@
41
41
  "@commitlint/test": "^18.0.0",
42
42
  "@commitlint/utils": "^18.4.4"
43
43
  },
44
- "gitHead": "ad2637f3cf23c5579e600950594e4d8d47d79864"
44
+ "gitHead": "5706af23ef4901d13f8c751df19214098404f44b"
45
45
  }