1
1
import path from "node:path" ;
2
2
3
3
import fg from "fast-glob" ;
4
- import readYamlFile from "read-yaml-file" ;
4
+ import readYamlFileModule from "read-yaml-file" ;
5
5
import { readExactProjectManifest } from "@pnpm/read-project-manifest" ;
6
+ const readYamlFile = readYamlFileModule . default ;
6
7
7
8
export default {
8
9
utils : { getProjects } ,
9
10
rules : {
10
- "scope-enum" : ( ctx ) =>
11
- getProjects ( ctx ) . then ( ( packages ) => [ 2 , "always" , packages ] ) ,
11
+ "scope-enum" : ( ctx = { } ) =>
12
+ getProjects ( ctx ) . then ( ( packages : any ) => [ 2 , "always" , packages ] ) ,
12
13
} ,
13
14
} ;
14
15
15
- function requirePackagesManifest ( dir ) {
16
- return readYamlFile ( path . join ( dir , "pnpm-workspace.yaml" ) ) . catch ( ( err ) => {
17
- if ( err . code === "ENOENT" ) {
18
- return null ;
19
- }
16
+ function requirePackagesManifest ( dir : any ) {
17
+ return readYamlFile ( path . join ( dir , "pnpm-workspace.yaml" ) ) . catch (
18
+ ( err : any ) => {
19
+ if ( err . code === "ENOENT" ) {
20
+ return null ;
21
+ }
20
22
21
- throw err ;
22
- } ) ;
23
+ throw err ;
24
+ } ,
25
+ ) ;
23
26
}
24
27
25
- function normalizePatterns ( patterns ) {
28
+ function normalizePatterns ( patterns : any ) {
26
29
const normalizedPatterns = [ ] ;
27
30
for ( const pattern of patterns ) {
28
31
normalizedPatterns . push ( pattern . replace ( / \/ ? $ / , "/package.json" ) ) ;
@@ -32,9 +35,9 @@ function normalizePatterns(patterns) {
32
35
return normalizedPatterns ;
33
36
}
34
37
35
- function findWorkspacePackages ( cwd ) {
38
+ function findWorkspacePackages ( cwd : any ) {
36
39
return requirePackagesManifest ( cwd )
37
- . then ( ( manifest ) => {
40
+ . then ( ( manifest : any ) => {
38
41
const patterns = normalizePatterns (
39
42
( manifest && manifest . packages ) || [ "**" ] ,
40
43
) ;
@@ -45,27 +48,29 @@ function findWorkspacePackages(cwd) {
45
48
46
49
return fg ( patterns , opts ) ;
47
50
} )
48
- . then ( ( entries ) => {
51
+ . then ( ( entries : any ) => {
49
52
const paths = Array . from (
50
- new Set ( entries . map ( ( entry ) => path . join ( cwd , entry ) ) ) ,
53
+ new Set ( entries . map ( ( entry : any ) => path . join ( cwd , entry ) ) ) ,
51
54
) ;
52
55
53
56
return Promise . all (
54
- paths . map ( ( manifestPath ) => readExactProjectManifest ( manifestPath ) ) ,
57
+ paths . map ( ( manifestPath : any ) =>
58
+ readExactProjectManifest ( manifestPath ) ,
59
+ ) ,
55
60
) ;
56
61
} )
57
- . then ( ( manifests ) => {
58
- return manifests . map ( ( manifest ) => manifest . manifest ) ;
62
+ . then ( ( manifests : any ) => {
63
+ return manifests . map ( ( manifest : any ) => manifest . manifest ) ;
59
64
} ) ;
60
65
}
61
66
62
- function getProjects ( context ) {
67
+ function getProjects ( context : any ) {
63
68
const ctx = context || { } ;
64
69
const cwd = ctx . cwd || process . cwd ( ) ;
65
70
66
- return findWorkspacePackages ( cwd ) . then ( ( projects ) => {
71
+ return findWorkspacePackages ( cwd ) . then ( ( projects : any ) => {
67
72
return projects
68
- . reduce ( ( projects , project ) => {
73
+ . reduce ( ( projects : any , project : any ) => {
69
74
const name = project . name ;
70
75
71
76
if ( name ) {
0 commit comments