@@ -37,25 +37,31 @@ import {
3737import type { QlPackFile } from "../packaging/qlpack-file" ;
3838import { expandShortPaths } from "../common/short-paths" ;
3939import type { QlPackDetails } from "./ql-pack-details" ;
40+ import type { ModelPackDetails } from "../common/model-pack-details" ;
4041
4142/**
4243 * Well-known names for the query pack used by the server.
4344 */
4445const QUERY_PACK_NAME = "codeql-remote/query" ;
4546
47+ interface GeneratedQlPackDetails {
48+ base64Pack : string ;
49+ modelPacks : ModelPackDetails [ ] ;
50+ }
51+
4652/**
4753 * Two possibilities:
4854 * 1. There is no qlpack.yml (or codeql-pack.yml) in this directory. Assume this is a lone query and generate a synthetic qlpack for it.
4955 * 2. There is a qlpack.yml (or codeql-pack.yml) in this directory. Assume this is a query pack and use the yml to pack the query before uploading it.
5056 *
51- * @returns the entire qlpack as a base64 string .
57+ * @returns details about the generated QL pack .
5258 */
5359async function generateQueryPack (
5460 cliServer : CodeQLCliServer ,
5561 qlPackDetails : QlPackDetails ,
5662 tmpDir : RemoteQueryTempDir ,
5763 token : CancellationToken ,
58- ) : Promise < string > {
64+ ) : Promise < GeneratedQlPackDetails > {
5965 const workspaceFolders = getOnDiskWorkspaceFolders ( ) ;
6066 const extensionPacks = await getExtensionPacksToInject (
6167 cliServer ,
@@ -129,7 +135,7 @@ async function generateQueryPack(
129135 ...queryOpts ,
130136 // We need to specify the extension packs as dependencies so that they are included in the MRVA pack.
131137 // The version range doesn't matter, since they'll always be found by source lookup.
132- ...extensionPacks . map ( ( p ) => `--extension-pack=${ p } @*` ) ,
138+ ...extensionPacks . map ( ( p ) => `--extension-pack=${ p . name } @*` ) ,
133139 ] ;
134140 } else {
135141 precompilationOpts = [ "--qlx" ] ;
@@ -152,7 +158,10 @@ async function generateQueryPack(
152158 token ,
153159 ) ;
154160 const base64Pack = ( await readFile ( bundlePath ) ) . toString ( "base64" ) ;
155- return base64Pack ;
161+ return {
162+ base64Pack,
163+ modelPacks : extensionPacks ,
164+ } ;
156165}
157166
158167async function createNewQueryPack (
@@ -278,6 +287,7 @@ async function getPackedBundlePath(remoteQueryDir: string): Promise<string> {
278287interface PreparedRemoteQuery {
279288 actionBranch : string ;
280289 base64Pack : string ;
290+ modelPacks : ModelPackDetails [ ] ;
281291 repoSelection : RepositorySelection ;
282292 controllerRepo : Repository ;
283293 queryStartTime : number ;
@@ -330,10 +340,10 @@ export async function prepareRemoteQueryRun(
330340
331341 const tempDir = await createRemoteQueriesTempDirectory ( ) ;
332342
333- let base64Pack : string ;
343+ let generatedPack : GeneratedQlPackDetails ;
334344
335345 try {
336- base64Pack = await generateQueryPack (
346+ generatedPack = await generateQueryPack (
337347 cliServer ,
338348 qlPackDetails ,
339349 tempDir ,
@@ -358,7 +368,8 @@ export async function prepareRemoteQueryRun(
358368
359369 return {
360370 actionBranch,
361- base64Pack,
371+ base64Pack : generatedPack . base64Pack ,
372+ modelPacks : generatedPack . modelPacks ,
362373 repoSelection,
363374 controllerRepo,
364375 queryStartTime,
@@ -404,8 +415,8 @@ async function fixPackFile(
404415async function getExtensionPacksToInject (
405416 cliServer : CodeQLCliServer ,
406417 workspaceFolders : string [ ] ,
407- ) : Promise < string [ ] > {
408- const result : string [ ] = [ ] ;
418+ ) : Promise < ModelPackDetails [ ] > {
419+ const result : ModelPackDetails [ ] = [ ] ;
409420 if ( cliServer . useExtensionPacks ( ) ) {
410421 const extensionPacks = await cliServer . resolveQlpacks (
411422 workspaceFolders ,
@@ -422,7 +433,7 @@ async function getExtensionPacksToInject(
422433 ) } `,
423434 ) ;
424435 }
425- result . push ( name ) ;
436+ result . push ( { name, path : paths [ 0 ] } ) ;
426437 } ) ;
427438 }
428439
@@ -431,7 +442,7 @@ async function getExtensionPacksToInject(
431442
432443async function addExtensionPacksAsDependencies (
433444 queryPackDir : string ,
434- extensionPacks : string [ ] ,
445+ extensionPacks : ModelPackDetails [ ] ,
435446) : Promise < void > {
436447 const qlpackFile = await getQlPackFilePath ( queryPackDir ) ;
437448 if ( ! qlpackFile ) {
@@ -447,7 +458,7 @@ async function addExtensionPacksAsDependencies(
447458 ) as QlPackFile ;
448459
449460 const dependencies = syntheticQueryPack . dependencies ?? { } ;
450- extensionPacks . forEach ( ( name ) => {
461+ extensionPacks . forEach ( ( { name } ) => {
451462 // Add this extension pack as a dependency. It doesn't matter which
452463 // version we specify, since we are guaranteed that the extension pack
453464 // is resolved from source at the given path.
0 commit comments