@@ -37,15 +37,7 @@ import {
3737import { QueryLanguage } from "../common/query-language" ;
3838import { tryGetQueryMetadata } from "../codeql-cli/query-metadata" ;
3939import { askForLanguage , findLanguage } from "../codeql-cli/query-language" ;
40-
41- interface QlPack {
42- name : string ;
43- version : string ;
44- library ?: boolean ;
45- dependencies : { [ key : string ] : string } ;
46- defaultSuite ?: Array < Record < string , unknown > > ;
47- defaultSuiteFile ?: string ;
48- }
40+ import { QlPackFile } from "../packaging/qlpack-file" ;
4941
5042/**
5143 * Well-known names for the query pack used by the server.
@@ -395,7 +387,7 @@ async function fixPackFile(
395387 ) } file in '${ queryPackDir } '`,
396388 ) ;
397389 }
398- const qlpack = load ( await readFile ( packPath , "utf8" ) ) as QlPack ;
390+ const qlpack = load ( await readFile ( packPath , "utf8" ) ) as QlPackFile ;
399391
400392 updateDefaultSuite ( qlpack , packRelativePath ) ;
401393 removeWorkspaceRefs ( qlpack ) ;
@@ -416,7 +408,11 @@ async function injectExtensionPacks(
416408 ) } file in '${ queryPackDir } '`,
417409 ) ;
418410 }
419- const syntheticQueryPack = load ( await readFile ( qlpackFile , "utf8" ) ) as QlPack ;
411+ const syntheticQueryPack = load (
412+ await readFile ( qlpackFile , "utf8" ) ,
413+ ) as QlPackFile ;
414+
415+ const dependencies = syntheticQueryPack . dependencies ?? { } ;
420416
421417 const extensionPacks = await cliServer . resolveQlpacks ( workspaceFolders , true ) ;
422418 Object . entries ( extensionPacks ) . forEach ( ( [ name , paths ] ) => {
@@ -433,13 +429,16 @@ async function injectExtensionPacks(
433429 // Add this extension pack as a dependency. It doesn't matter which
434430 // version we specify, since we are guaranteed that the extension pack
435431 // is resolved from source at the given path.
436- syntheticQueryPack . dependencies [ name ] = "*" ;
432+ dependencies [ name ] = "*" ;
437433 } ) ;
434+
435+ syntheticQueryPack . dependencies = dependencies ;
436+
438437 await writeFile ( qlpackFile , dump ( syntheticQueryPack ) ) ;
439438 await cliServer . clearCache ( ) ;
440439}
441440
442- function updateDefaultSuite ( qlpack : QlPack , packRelativePath : string ) {
441+ function updateDefaultSuite ( qlpack : QlPackFile , packRelativePath : string ) {
443442 delete qlpack . defaultSuiteFile ;
444443 qlpack . defaultSuite = generateDefaultSuite ( packRelativePath ) ;
445444}
@@ -541,10 +540,12 @@ async function getControllerRepoFromApi(
541540 }
542541}
543542
544- export function removeWorkspaceRefs ( qlpack : {
545- dependencies : Record < string , string > ;
546- } ) {
547- for ( const [ key , value ] of Object . entries ( qlpack . dependencies || { } ) ) {
543+ export function removeWorkspaceRefs ( qlpack : QlPackFile ) {
544+ if ( ! qlpack . dependencies ) {
545+ return ;
546+ }
547+
548+ for ( const [ key , value ] of Object . entries ( qlpack . dependencies ) ) {
548549 if ( value === "${workspace}" ) {
549550 qlpack . dependencies [ key ] = "*" ;
550551 }
0 commit comments