@@ -16,7 +16,7 @@ import common = require('./common');
1616import { DepTree , TestOptions } from '../types' ;
1717import gemfileLockToDependencies = require( '../../lib/plugins/rubygems/gemfile-lock-to-dependencies' ) ;
1818import { convertTestDepGraphResultToLegacy , AnnotatedIssue , LegacyVulnApiResult , TestDepGraphResponse } from './legacy' ;
19- import { SingleDepRootResult , MultiDepRootsResult , isMultiResult , Options } from '../types' ;
19+ import { Options } from '../types' ;
2020import {
2121 NoSupportedManifestsFoundError ,
2222 InternalServerError ,
@@ -26,6 +26,7 @@ import {
2626import { maybePrintDeps } from '../print-deps' ;
2727import { SupportedPackageManagers } from '../package-managers' ;
2828import { countPathsToGraphRoot , pruneGraph } from '../prune' ;
29+ import { legacyPlugin as pluginApi } from '@snyk/cli-interface' ;
2930
3031// tslint:disable-next-line:no-var-requires
3132const debug = require ( 'debug' ) ( 'snyk' ) ;
@@ -207,23 +208,22 @@ function assemblePayloads(root: string, options: Options & TestOptions): Promise
207208 return assembleRemotePayloads ( root , options ) ;
208209}
209210
210- // Force getDepsFromPlugin to return depRoots for processing in assembleLocalPayload
211- async function getDepsFromPlugin ( root , options : Options ) : Promise < MultiDepRootsResult > {
211+ // Force getDepsFromPlugin to return scannedProjects for processing in assembleLocalPayload
212+ async function getDepsFromPlugin ( root , options : Options ) : Promise < pluginApi . MultiProjectResult > {
212213 options . file = options . file || detect . detectPackageFile ( root ) ;
213214 if ( ! options . docker && ! ( options . file || options . packageManager ) ) {
214215 throw NoSupportedManifestsFoundError ( [ ...root ] ) ;
215216 }
216217 const plugin = plugins . loadPlugin ( options . packageManager , options ) ;
217218 const moduleInfo = ModuleInfo ( plugin , options . policy ) ;
218- const pluginOptions = plugins . getPluginOptions ( options . packageManager , options ) ;
219- const inspectRes : SingleDepRootResult | MultiDepRootsResult =
220- await moduleInfo . inspect ( root , options . file , { ...options , ...pluginOptions } ) ;
219+ const inspectRes : pluginApi . InspectResult =
220+ await moduleInfo . inspect ( root , options . file , { ...options } ) ;
221221
222- if ( ! isMultiResult ( inspectRes ) ) {
222+ if ( ! pluginApi . isMultiResult ( inspectRes ) ) {
223223 if ( ! inspectRes . package ) {
224224 // something went wrong if both are not present...
225225 throw Error ( `error getting dependencies from ${ options . packageManager } ` +
226- 'plugin: neither \'package\' nor \'depRoots \' were found' ) ;
226+ 'plugin: neither \'package\' nor \'scannedProjects \' were found' ) ;
227227 }
228228 if ( ! inspectRes . package . targetFile && inspectRes . plugin ) {
229229 inspectRes . package . targetFile = inspectRes . plugin . targetFile ;
@@ -238,13 +238,13 @@ async function getDepsFromPlugin(root, options: Options): Promise<MultiDepRootsR
238238 }
239239 return {
240240 plugin : inspectRes . plugin ,
241- depRoots : [ { depTree : inspectRes . package } ] ,
241+ scannedProjects : [ { depTree : inspectRes . package } ] ,
242242 } ;
243243 } else {
244244 // We are using "options" to store some information returned from plugin that we need to use later,
245245 // but don't want to send to Registry in the Payload.
246246 // TODO(kyegupov): decouple inspect and payload so that we don't need this hack
247- options . subProjectNames = inspectRes . depRoots . map ( ( depRoot ) => depRoot . depTree . name ) ;
247+ ( options as any ) . subProjectNames = inspectRes . scannedProjects . map ( ( scannedProject ) => scannedProject . depTree . name ) ;
248248 return inspectRes ;
249249 }
250250}
@@ -263,14 +263,14 @@ async function assembleLocalPayloads(root, options: Options & TestOptions): Prom
263263 const deps = await getDepsFromPlugin ( root , options ) ;
264264 analytics . add ( 'pluginName' , deps . plugin . name ) ;
265265
266- for ( const depRoot of deps . depRoots ) {
267- const pkg = depRoot . depTree ;
266+ for ( const scannedProject of deps . scannedProjects ) {
267+ const pkg = scannedProject . depTree ;
268268 if ( options [ 'print-deps' ] ) {
269269 await spinner . clear < void > ( spinnerLbl ) ( ) ;
270270 maybePrintDeps ( options , pkg ) ;
271271 }
272272 if ( deps . plugin && deps . plugin . packageManager ) {
273- options . packageManager = deps . plugin . packageManager ;
273+ ( options as any ) . packageManager = deps . plugin . packageManager ;
274274 }
275275
276276 if ( pkg . docker ) {
@@ -332,7 +332,10 @@ async function assembleLocalPayloads(root, options: Options & TestOptions): Prom
332332 } else {
333333 // Graphs are more compact and robust representations.
334334 // Legacy parts of the code are still using trees, but will eventually be fully migrated.
335- debug ( 'converting dep-tree to dep-graph' , { name : pkg . name , targetFile : depRoot . targetFile || options . file } ) ;
335+ debug ( 'converting dep-tree to dep-graph' , {
336+ name : pkg . name ,
337+ targetFile : scannedProject . targetFile || options . file ,
338+ } ) ;
336339 let depGraph = await depGraphLib . legacy . depTreeToGraph (
337340 pkg , options . packageManager ) ;
338341
0 commit comments