@@ -127,6 +127,12 @@ export interface CodeQL {
127127 queries : string [ ] ,
128128 extraSearchPath : string | undefined ,
129129 ) : Promise < ResolveQueriesOutput > ;
130+
131+ /**
132+ * Run 'codeql resolve packs'
133+ */
134+ resolvePacks ( ) : Promise < ResolvePacksOutput > ;
135+
130136 /**
131137 * Run 'codeql resolve build-environment'
132138 */
@@ -261,6 +267,39 @@ export interface ResolveBuildEnvironmentOutput {
261267 } ;
262268}
263269
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+
264303export interface PackDownloadOutput {
265304 packs : PackDownloadItem [ ] ;
266305}
@@ -468,6 +507,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
468507 async ( ) => ( { aliases : { } , extractors : { } } ) ,
469508 ) ,
470509 resolveQueries : resolveFunction ( partialCodeql , "resolveQueries" ) ,
510+ resolvePacks : resolveFunction ( partialCodeql , "resolvePacks" ) ,
471511 resolveBuildEnvironment : resolveFunction (
472512 partialCodeql ,
473513 "resolveBuildEnvironment" ,
@@ -786,6 +826,25 @@ export async function getCodeQLForCmd(
786826 throw new Error ( `Unexpected output from codeql resolve queries: ${ e } ` ) ;
787827 }
788828 } ,
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+ } ,
789848 async resolveBuildEnvironment (
790849 workingDir : string | undefined ,
791850 language : string ,
0 commit comments