@@ -65,41 +65,41 @@ async function generateQueryPack(
65
65
const cliSupportsMrvaPackCreate =
66
66
await cliServer . cliConstraints . supportsMrvaPackCreate ( ) ;
67
67
68
- let queryPackDir : string ;
68
+ let targetPackPath : string ;
69
69
let needsInstall : boolean ;
70
70
if ( mustSynthesizePack ) {
71
71
// This section applies whether or not the CLI supports MRVA pack creation directly.
72
72
73
- queryPackDir = tmpDir . queryPackDir ;
73
+ targetPackPath = tmpDir . queryPackDir ;
74
74
75
75
// Synthesize a query pack for the query.
76
76
// copy only the query file to the query pack directory
77
77
// and generate a synthetic query pack
78
- await createNewQueryPack ( qlPackDetails , queryPackDir ) ;
78
+ await createNewQueryPack ( qlPackDetails , targetPackPath ) ;
79
79
// Clear the cliServer cache so that the previous qlpack text is purged from the CLI.
80
80
await cliServer . clearCache ( ) ;
81
81
82
82
// Install packs, since we just synthesized a dependency on the language's standard library.
83
83
needsInstall = true ;
84
84
} else if ( ! cliSupportsMrvaPackCreate ) {
85
85
// We need to copy the query pack to a temporary directory and then fix it up to work with MRVA.
86
- queryPackDir = tmpDir . queryPackDir ;
87
- await copyExistingQueryPack ( cliServer , qlPackDetails , queryPackDir ) ;
86
+ targetPackPath = tmpDir . queryPackDir ;
87
+ await copyExistingQueryPack ( cliServer , qlPackDetails , targetPackPath ) ;
88
88
89
89
// We should already have all the dependencies available, but these older versions of the CLI
90
90
// have a bug where they will not search `--additional-packs` during validation in `codeql pack bundle`.
91
91
// Installing the packs will ensure that any extension packs get put in the right place.
92
92
needsInstall = true ;
93
93
} else {
94
94
// The CLI supports creating a MRVA query pack directly from the source pack.
95
- queryPackDir = qlPackDetails . qlPackRootPath ;
95
+ targetPackPath = qlPackDetails . qlPackRootPath ;
96
96
// We expect any dependencies to be available already.
97
97
needsInstall = false ;
98
98
}
99
99
100
100
if ( needsInstall ) {
101
101
// Install the dependencies of the synthesized query pack.
102
- await cliServer . packInstall ( queryPackDir , {
102
+ await cliServer . packInstall ( targetPackPath , {
103
103
workspaceFolders,
104
104
} ) ;
105
105
@@ -120,7 +120,7 @@ async function generateQueryPack(
120
120
121
121
const queryOpts = qlPackDetails . queryFiles . flatMap ( ( q ) => [
122
122
"--query" ,
123
- join ( queryPackDir , relative ( qlPackDetails . qlPackRootPath , q ) ) ,
123
+ join ( targetPackPath , relative ( qlPackDetails . qlPackRootPath , q ) ) ,
124
124
] ) ;
125
125
126
126
precompilationOpts = [
@@ -143,16 +143,16 @@ async function generateQueryPack(
143
143
}
144
144
145
145
if ( extensionPacks . length > 0 ) {
146
- await addExtensionPacksAsDependencies ( queryPackDir , extensionPacks ) ;
146
+ await addExtensionPacksAsDependencies ( targetPackPath , extensionPacks ) ;
147
147
}
148
148
}
149
149
150
150
const bundlePath = tmpDir . bundleFile ;
151
151
void extLogger . log (
152
- `Compiling and bundling query pack from ${ queryPackDir } to ${ bundlePath } . (This may take a while.)` ,
152
+ `Compiling and bundling query pack from ${ targetPackPath } to ${ bundlePath } . (This may take a while.)` ,
153
153
) ;
154
154
await cliServer . packBundle (
155
- queryPackDir ,
155
+ targetPackPath ,
156
156
workspaceFolders ,
157
157
bundlePath ,
158
158
tmpDir . compiledPackDir ,
@@ -164,12 +164,12 @@ async function generateQueryPack(
164
164
165
165
async function createNewQueryPack (
166
166
qlPackDetails : QlPackDetails ,
167
- queryPackDir : string ,
167
+ targetPackPath : string ,
168
168
) {
169
169
for ( const queryFile of qlPackDetails . queryFiles ) {
170
- void extLogger . log ( `Copying ${ queryFile } to ${ queryPackDir } ` ) ;
170
+ void extLogger . log ( `Copying ${ queryFile } to ${ targetPackPath } ` ) ;
171
171
const relativeQueryPath = relative ( qlPackDetails . qlPackRootPath , queryFile ) ;
172
- const targetQueryFileName = join ( queryPackDir , relativeQueryPath ) ;
172
+ const targetQueryFileName = join ( targetPackPath , relativeQueryPath ) ;
173
173
await copy ( queryFile , targetQueryFileName ) ;
174
174
}
175
175
@@ -184,15 +184,15 @@ async function createNewQueryPack(
184
184
} ;
185
185
186
186
await writeFile (
187
- join ( queryPackDir , FALLBACK_QLPACK_FILENAME ) ,
187
+ join ( targetPackPath , FALLBACK_QLPACK_FILENAME ) ,
188
188
dump ( syntheticQueryPack ) ,
189
189
) ;
190
190
}
191
191
192
192
async function copyExistingQueryPack (
193
193
cliServer : CodeQLCliServer ,
194
194
qlPackDetails : QlPackDetails ,
195
- queryPackDir : string ,
195
+ targetPackPath : string ,
196
196
) {
197
197
const toCopy = await cliServer . packPacklist (
198
198
qlPackDetails . qlPackRootPath ,
@@ -226,7 +226,7 @@ async function copyExistingQueryPack(
226
226
} ) ;
227
227
228
228
let copiedCount = 0 ;
229
- await copy ( qlPackDetails . qlPackRootPath , queryPackDir , {
229
+ await copy ( qlPackDetails . qlPackRootPath , targetPackPath , {
230
230
filter : ( file : string ) =>
231
231
// copy file if it is in the packlist, or it is a parent directory of a file in the packlist
232
232
! ! toCopy . find ( ( f ) => {
@@ -241,9 +241,9 @@ async function copyExistingQueryPack(
241
241
} ) ,
242
242
} ) ;
243
243
244
- void extLogger . log ( `Copied ${ copiedCount } files to ${ queryPackDir } ` ) ;
244
+ void extLogger . log ( `Copied ${ copiedCount } files to ${ targetPackPath } ` ) ;
245
245
246
- await fixPackFile ( queryPackDir , qlPackDetails ) ;
246
+ await fixPackFile ( targetPackPath , qlPackDetails ) ;
247
247
}
248
248
249
249
interface RemoteQueryTempDir {
@@ -378,21 +378,21 @@ export async function prepareRemoteQueryRun(
378
378
* - Removes any `${workspace}` version references from the qlpack.yml or codeql-pack.yml file. Converts them
379
379
* to `*` versions.
380
380
*
381
- * @param queryPackDir The directory containing the query pack
381
+ * @param targetPackPath The path to the directory containing the target pack
382
382
* @param qlPackDetails The details of the original QL pack
383
383
*/
384
384
async function fixPackFile (
385
- queryPackDir : string ,
385
+ targetPackPath : string ,
386
386
qlPackDetails : QlPackDetails ,
387
387
) : Promise < void > {
388
- const packPath = await getQlPackFilePath ( queryPackDir ) ;
388
+ const packPath = await getQlPackFilePath ( targetPackPath ) ;
389
389
390
390
// This should not happen since we create the pack ourselves.
391
391
if ( ! packPath ) {
392
392
throw new Error (
393
393
`Could not find ${ QLPACK_FILENAMES . join (
394
394
" or " ,
395
- ) } file in '${ queryPackDir } '`,
395
+ ) } file in '${ targetPackPath } '`,
396
396
) ;
397
397
}
398
398
const qlpack = load ( await readFile ( packPath , "utf8" ) ) as QlPackFile ;
0 commit comments