@commitlint/config-pnpm-scopes 19.8.0 → 19.9.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/package.json +11 -6
- package/index.js +0 -79
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/config-pnpm-scopes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "19.
|
|
4
|
+
"version": "19.9.0",
|
|
5
5
|
"description": "Shareable commitlint config enforcing pnpm workspaces names as scopes",
|
|
6
|
-
"main": "index.js",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
|
-
"
|
|
9
|
+
"dist"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "jest",
|
|
11
14
|
"deps": "dep-check",
|
|
12
15
|
"pkg": "pkg-check"
|
|
13
16
|
},
|
|
@@ -37,8 +40,10 @@
|
|
|
37
40
|
"read-yaml-file": "^2.1.0"
|
|
38
41
|
},
|
|
39
42
|
"devDependencies": {
|
|
40
|
-
"@commitlint/test": "^19.8.
|
|
41
|
-
"@commitlint/utils": "^19.8.
|
|
43
|
+
"@commitlint/test": "^19.8.1",
|
|
44
|
+
"@commitlint/utils": "^19.8.1",
|
|
45
|
+
"@types/node": "^18.19.17",
|
|
46
|
+
"typescript": "^5.2.2"
|
|
42
47
|
},
|
|
43
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a1d4dbd01b8ceaf00b1855b86885932ec8a1513d"
|
|
44
49
|
}
|
package/index.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
import fg from 'fast-glob';
|
|
4
|
-
import readYamlFile from 'read-yaml-file';
|
|
5
|
-
import {readExactProjectManifest} from '@pnpm/read-project-manifest';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
utils: {getProjects},
|
|
9
|
-
rules: {
|
|
10
|
-
'scope-enum': (ctx) =>
|
|
11
|
-
getProjects(ctx).then((packages) => [2, 'always', packages]),
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function requirePackagesManifest(dir) {
|
|
16
|
-
return readYamlFile(path.join(dir, 'pnpm-workspace.yaml')).catch((err) => {
|
|
17
|
-
if (err.code === 'ENOENT') {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
throw err;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function normalizePatterns(patterns) {
|
|
26
|
-
const normalizedPatterns = [];
|
|
27
|
-
for (const pattern of patterns) {
|
|
28
|
-
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.json'));
|
|
29
|
-
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.json5'));
|
|
30
|
-
normalizedPatterns.push(pattern.replace(/\/?$/, '/package.yaml'));
|
|
31
|
-
}
|
|
32
|
-
return normalizedPatterns;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function findWorkspacePackages(cwd) {
|
|
36
|
-
return requirePackagesManifest(cwd)
|
|
37
|
-
.then((manifest) => {
|
|
38
|
-
const patterns = normalizePatterns(
|
|
39
|
-
(manifest && manifest.packages) || ['**']
|
|
40
|
-
);
|
|
41
|
-
const opts = {
|
|
42
|
-
cwd,
|
|
43
|
-
ignore: ['**/node_modules/**', '**/bower_components/**'],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return fg(patterns, opts);
|
|
47
|
-
})
|
|
48
|
-
.then((entries) => {
|
|
49
|
-
const paths = Array.from(
|
|
50
|
-
new Set(entries.map((entry) => path.join(cwd, entry)))
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
return Promise.all(
|
|
54
|
-
paths.map((manifestPath) => readExactProjectManifest(manifestPath))
|
|
55
|
-
);
|
|
56
|
-
})
|
|
57
|
-
.then((manifests) => {
|
|
58
|
-
return manifests.map((manifest) => manifest.manifest);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getProjects(context) {
|
|
63
|
-
const ctx = context || {};
|
|
64
|
-
const cwd = ctx.cwd || process.cwd();
|
|
65
|
-
|
|
66
|
-
return findWorkspacePackages(cwd).then((projects) => {
|
|
67
|
-
return projects
|
|
68
|
-
.reduce((projects, project) => {
|
|
69
|
-
const name = project.name;
|
|
70
|
-
|
|
71
|
-
if (name) {
|
|
72
|
-
projects.push(name.charAt(0) === '@' ? name.split('/')[1] : name);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return projects;
|
|
76
|
-
}, [])
|
|
77
|
-
.sort();
|
|
78
|
-
});
|
|
79
|
-
}
|