@@ -127,6 +127,12 @@ export interface CodeQL {
127
127
queries : string [ ] ,
128
128
extraSearchPath : string | undefined ,
129
129
) : Promise < ResolveQueriesOutput > ;
130
+
131
+ /**
132
+ * Run 'codeql resolve packs'
133
+ */
134
+ resolvePacks ( ) : Promise < ResolvePacksOutput > ;
135
+
130
136
/**
131
137
* Run 'codeql resolve build-environment'
132
138
*/
@@ -261,6 +267,39 @@ export interface ResolveBuildEnvironmentOutput {
261
267
} ;
262
268
}
263
269
270
+ export interface PackInfo {
271
+ kind : string ;
272
+ path : string ;
273
+ version ?: string ; // Present only under ByNameScan
274
+ }
275
+
276
+ export interface ByNameScan {
277
+ paths : string [ ] ;
278
+ found : {
279
+ [ packName : string ] : PackInfo ;
280
+ } ;
281
+ }
282
+
283
+ export interface StepByName {
284
+ type : "by-name" ;
285
+ scans : ByNameScan [ ] ;
286
+ }
287
+
288
+ export interface StepByNameAndVersion {
289
+ type : "by-name-and-version" ;
290
+ found : {
291
+ [ packName : string ] : {
292
+ [ version : string ] : PackInfo ;
293
+ } ;
294
+ } ;
295
+ }
296
+
297
+ export type ResolvePacksStep = StepByName | StepByNameAndVersion ;
298
+
299
+ export interface ResolvePacksOutput {
300
+ steps : ResolvePacksStep [ ] ;
301
+ }
302
+
264
303
export interface PackDownloadOutput {
265
304
packs : PackDownloadItem [ ] ;
266
305
}
@@ -468,6 +507,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
468
507
async ( ) => ( { aliases : { } , extractors : { } } ) ,
469
508
) ,
470
509
resolveQueries : resolveFunction ( partialCodeql , "resolveQueries" ) ,
510
+ resolvePacks : resolveFunction ( partialCodeql , "resolvePacks" ) ,
471
511
resolveBuildEnvironment : resolveFunction (
472
512
partialCodeql ,
473
513
"resolveBuildEnvironment" ,
@@ -786,6 +826,25 @@ export async function getCodeQLForCmd(
786
826
throw new Error ( `Unexpected output from codeql resolve queries: ${ e } ` ) ;
787
827
}
788
828
} ,
829
+ async resolvePacks ( ) : Promise < ResolvePacksOutput > {
830
+ const codeqlArgs = [
831
+ "resolve" ,
832
+ "packs" ,
833
+ "--format=json" ,
834
+ ...getExtraOptionsFromEnv ( [ "resolve" , "packs" ] ) ,
835
+ ] ;
836
+ // Resolve packs generate a lot of output, so we want to keep the output
837
+ // out of the Action logs.
838
+ const output = await runCli ( cmd , codeqlArgs , {
839
+ noStreamStdout : true ,
840
+ } ) ;
841
+
842
+ try {
843
+ return JSON . parse ( output ) as ResolvePacksOutput ;
844
+ } catch ( e ) {
845
+ throw new Error ( `Unexpected output from codeql resolve packs: ${ e } ` ) ;
846
+ }
847
+ } ,
789
848
async resolveBuildEnvironment (
790
849
workingDir : string | undefined ,
791
850
language : string ,
0 commit comments