@@ -1163,24 +1163,32 @@ export class CodeQLCliServer implements Disposable {
11631163
11641164 /**
11651165 * Gets information about available qlpacks
1166- * @param additionalPacks A list of directories to search for qlpacks before searching in `searchPath` .
1167- * @param searchPath A list of directories to search for packs not found in `additionalPacks`. If undefined,
1168- * the default CLI search path is used .
1166+ * @param additionalPacks A list of directories to search for qlpacks.
1167+ * @param extensionPacksOnly Whether to only search for extension packs. If true, only extension packs will
1168+ * be returned. If false, all packs will be returned .
11691169 * @returns A dictionary mapping qlpack name to the directory it comes from
11701170 */
1171- resolveQlpacks (
1171+ async resolveQlpacks (
11721172 additionalPacks : string [ ] ,
1173- searchPath ?: string [ ] ,
1173+ extensionPacksOnly = false ,
11741174 ) : Promise < QlpacksInfo > {
11751175 const args = this . getAdditionalPacksArg ( additionalPacks ) ;
1176- if ( searchPath ?. length ) {
1177- args . push ( "--search-path" , join ( ...searchPath ) ) ;
1176+ if ( extensionPacksOnly ) {
1177+ if ( ! ( await this . cliConstraints . supportsQlpacksKind ( ) ) ) {
1178+ void this . logger . log (
1179+ "Warning: Running with extension packs is only supported by CodeQL CLI v2.12.3 or later." ,
1180+ ) ;
1181+ return { } ;
1182+ }
1183+ args . push ( "--kind" , "extension" , "--no-recursive" ) ;
11781184 }
11791185
11801186 return this . runJsonCodeQlCliCommand < QlpacksInfo > (
11811187 [ "resolve" , "qlpacks" ] ,
11821188 args ,
1183- "Resolving qlpack information" ,
1189+ `Resolving qlpack information${
1190+ extensionPacksOnly ? " (extension packs only)" : ""
1191+ } `,
11841192 ) ;
11851193 }
11861194
@@ -1380,6 +1388,17 @@ export class CodeQLCliServer implements Disposable {
13801388 private getAdditionalPacksArg ( paths : string [ ] ) : string [ ] {
13811389 return paths . length ? [ "--additional-packs" , paths . join ( delimiter ) ] : [ ] ;
13821390 }
1391+
1392+ public async useExtensionPacks ( ) : Promise < boolean > {
1393+ return (
1394+ this . cliConfig . useExtensionPacks &&
1395+ ( await this . cliConstraints . supportsQlpacksKind ( ) )
1396+ ) ;
1397+ }
1398+
1399+ public async setUseExtensionPacks ( useExtensionPacks : boolean ) {
1400+ await this . cliConfig . setUseExtensionPacks ( useExtensionPacks ) ;
1401+ }
13831402}
13841403
13851404/**
@@ -1668,6 +1687,11 @@ export class CliVersionConstraint {
16681687 */
16691688 public static CLI_VERSION_WITH_WORKSPACE_RFERENCES = new SemVer ( "2.11.3" ) ;
16701689
1690+ /**
1691+ * CLI version that supports the `--kind` option for the `resolve qlpacks` command.
1692+ */
1693+ public static CLI_VERSION_WITH_QLPACKS_KIND = new SemVer ( "2.12.3" ) ;
1694+
16711695 constructor ( private readonly cli : CodeQLCliServer ) {
16721696 /**/
16731697 }
@@ -1725,4 +1749,10 @@ export class CliVersionConstraint {
17251749 CliVersionConstraint . CLI_VERSION_WITH_WORKSPACE_RFERENCES ,
17261750 ) ;
17271751 }
1752+
1753+ async supportsQlpacksKind ( ) {
1754+ return this . isVersionAtLeast (
1755+ CliVersionConstraint . CLI_VERSION_WITH_QLPACKS_KIND ,
1756+ ) ;
1757+ }
17281758}
0 commit comments