11import { DepGraphBuilder } from '@snyk/dep-graph' ;
2- import { getTopLevelDeps } from '../util' ;
2+ import { createNodeInfo , getTopLevelDeps } from '../util' ;
33import type { Overrides , PnpmProjectParseOptions } from '../types' ;
44import type { PackageJsonBase } from '../types' ;
55import { getPnpmChildNode } from './utils' ;
@@ -28,11 +28,13 @@ export const buildDepGraphPnpm = async (
2828 includeOptionalDeps,
2929 includeDevDeps,
3030 pruneWithinTopLevelDeps,
31+ showNpmScope,
3132 } = options ;
3233
3334 const depGraphBuilder = new DepGraphBuilder (
3435 { name : 'pnpm' } ,
3536 { name : pkgJson . name , version : pkgJson . version || UNDEFINED_VERSION } ,
37+ createNodeInfo ( options ) ,
3638 ) ;
3739
3840 lockFileParser . extractedPackages = lockFileParser . extractPackages ( ) ;
@@ -84,6 +86,8 @@ export const buildDepGraphPnpm = async (
8486 pkgJson . pnpm ?. overrides || { } ,
8587 pruneWithinTopLevelDeps ,
8688 lockFileParser ,
89+ undefined ,
90+ showNpmScope ,
8791 ) ;
8892
8993 return depGraphBuilder . build ( ) ;
@@ -107,6 +111,7 @@ const dfsVisit = async (
107111 pruneWithinTopLevel : boolean ,
108112 lockFileParser : PnpmLockfileParser ,
109113 visited ?: Set < string > ,
114+ showNpmScope ?: boolean ,
110115) : Promise < void > => {
111116 for ( const [ name , depInfo ] of Object . entries ( node . dependencies || { } ) ) {
112117 if ( eventLoopSpinner . isStarving ( ) ) {
@@ -134,6 +139,9 @@ const dfsVisit = async (
134139 {
135140 labels : {
136141 scope : childNode . isDev ? 'dev' : 'prod' ,
142+ ...( showNpmScope && {
143+ 'npm:scope' : childNode . isDev ? 'dev' : 'prod' ,
144+ } ) ,
137145 pruned : 'true' ,
138146 ...( node . missingLockFileEntry && {
139147 missingLockFileEntry : 'true' ,
@@ -154,6 +162,9 @@ const dfsVisit = async (
154162 {
155163 labels : {
156164 scope : childNode . isDev ? 'dev' : 'prod' ,
165+ ...( showNpmScope && {
166+ 'npm:scope' : childNode . isDev ? 'dev' : 'prod' ,
167+ } ) ,
157168 ...( node . missingLockFileEntry && {
158169 missingLockFileEntry : 'true' ,
159170 } ) ,
@@ -174,6 +185,7 @@ const dfsVisit = async (
174185 pruneWithinTopLevel ,
175186 lockFileParser ,
176187 localVisited ,
188+ showNpmScope ,
177189 ) ;
178190 }
179191} ;
0 commit comments