@commitlint/config-pnpm-scopes 17.4.0 → 17.5.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/index.js +60 -8
- package/package.json +9 -18
package/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const readYamlFile = require('read-yaml-file');
|
|
3
|
+
const fg = require('fast-glob');
|
|
4
|
+
const {readExactProjectManifest} = require('@pnpm/read-project-manifest');
|
|
2
5
|
|
|
3
6
|
module.exports = {
|
|
4
7
|
utils: {getProjects},
|
|
@@ -8,19 +11,68 @@ module.exports = {
|
|
|
8
11
|
},
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
function requirePackagesManifest(dir) {
|
|
15
|
+
return readYamlFile(path.join(dir, 'pnpm-workspace.yaml')).catch((err) => {
|
|
16
|
+
if (err.code === 'ENOENT') {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
throw err;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalizePatterns(patterns) {
|
|
25
|
+
const normalizedPatterns = [];
|
|
26
|
+
for (const pattern of patterns) {
|
|
27
|
+
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.json'));
|
|
28
|
+
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.json5'));
|
|
29
|
+
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.yaml'));
|
|
30
|
+
}
|
|
31
|
+
return normalizedPatterns;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function findWorkspacePackages(cwd) {
|
|
35
|
+
return requirePackagesManifest(cwd)
|
|
36
|
+
.then((manifest) => {
|
|
37
|
+
const patterns = normalizePatterns(
|
|
38
|
+
(manifest && manifest.packages) || ['**']
|
|
39
|
+
);
|
|
40
|
+
const opts = {
|
|
41
|
+
cwd,
|
|
42
|
+
ignore: ['**/node_modules/**', '**/bower_components/**'],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return fg(patterns, opts);
|
|
46
|
+
})
|
|
47
|
+
.then((entries) => {
|
|
48
|
+
const paths = Array.from(
|
|
49
|
+
new Set(entries.map((entry) => path.join(cwd, entry)))
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return Promise.all(
|
|
53
|
+
paths.map((manifestPath) => readExactProjectManifest(manifestPath))
|
|
54
|
+
);
|
|
55
|
+
})
|
|
56
|
+
.then((manifests) => {
|
|
57
|
+
return manifests.map((manifest) => manifest.manifest);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
11
61
|
function getProjects(context) {
|
|
12
62
|
const ctx = context || {};
|
|
13
63
|
const cwd = ctx.cwd || process.cwd();
|
|
14
64
|
|
|
15
65
|
return findWorkspacePackages(cwd).then((projects) => {
|
|
16
|
-
return projects
|
|
17
|
-
|
|
66
|
+
return projects
|
|
67
|
+
.reduce((projects, project) => {
|
|
68
|
+
const name = project.name;
|
|
18
69
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
70
|
+
if (name) {
|
|
71
|
+
projects.push(name.charAt(0) === '@' ? name.split('/')[1] : name);
|
|
72
|
+
}
|
|
22
73
|
|
|
23
|
-
|
|
24
|
-
|
|
74
|
+
return projects;
|
|
75
|
+
}, [])
|
|
76
|
+
.sort();
|
|
25
77
|
});
|
|
26
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/config-pnpm-scopes",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.5.0",
|
|
4
4
|
"description": "Shareable commitlint config enforcing pnpm workspaces names as scopes",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.js"
|
|
@@ -26,26 +26,17 @@
|
|
|
26
26
|
"url": "https://github.com/conventional-changelog/commitlint/issues"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://commitlint.js.org/",
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@pnpm/find-workspace-packages": "^5.0.0",
|
|
31
|
-
"@pnpm/logger": "^5.0.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"@pnpm/find-workspace-packages": {
|
|
35
|
-
"optional": true
|
|
36
|
-
},
|
|
37
|
-
"@pnpm/logger": {
|
|
38
|
-
"optional": true
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
29
|
"engines": {
|
|
42
30
|
"node": ">=v14"
|
|
43
31
|
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@pnpm/read-project-manifest": "^4.1.4",
|
|
34
|
+
"fast-glob": "^3.2.12",
|
|
35
|
+
"read-yaml-file": "^2.1.0"
|
|
36
|
+
},
|
|
44
37
|
"devDependencies": {
|
|
45
|
-
"@commitlint/test": "^17.4.
|
|
46
|
-
"@commitlint/utils": "^17.4.0"
|
|
47
|
-
"@pnpm/find-workspace-packages": "^5.0.0",
|
|
48
|
-
"@pnpm/logger": "^5.0.0"
|
|
38
|
+
"@commitlint/test": "^17.4.2",
|
|
39
|
+
"@commitlint/utils": "^17.4.0"
|
|
49
40
|
},
|
|
50
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "665fbe436b093939dfed8fc0256963ba1a32b426"
|
|
51
42
|
}
|