Skip to content

Commit 0e2c03f

Browse files
authored
Rename queryPackDir -> targetPackPath (#3284)
1 parent 95b082d commit 0e2c03f

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

extensions/ql-vscode/src/variant-analysis/run-remote-query.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,41 @@ async function generateQueryPack(
6565
const cliSupportsMrvaPackCreate =
6666
await cliServer.cliConstraints.supportsMrvaPackCreate();
6767

68-
let queryPackDir: string;
68+
let targetPackPath: string;
6969
let needsInstall: boolean;
7070
if (mustSynthesizePack) {
7171
// This section applies whether or not the CLI supports MRVA pack creation directly.
7272

73-
queryPackDir = tmpDir.queryPackDir;
73+
targetPackPath = tmpDir.queryPackDir;
7474

7575
// Synthesize a query pack for the query.
7676
// copy only the query file to the query pack directory
7777
// and generate a synthetic query pack
78-
await createNewQueryPack(qlPackDetails, queryPackDir);
78+
await createNewQueryPack(qlPackDetails, targetPackPath);
7979
// Clear the cliServer cache so that the previous qlpack text is purged from the CLI.
8080
await cliServer.clearCache();
8181

8282
// Install packs, since we just synthesized a dependency on the language's standard library.
8383
needsInstall = true;
8484
} else if (!cliSupportsMrvaPackCreate) {
8585
// 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);
8888

8989
// We should already have all the dependencies available, but these older versions of the CLI
9090
// have a bug where they will not search `--additional-packs` during validation in `codeql pack bundle`.
9191
// Installing the packs will ensure that any extension packs get put in the right place.
9292
needsInstall = true;
9393
} else {
9494
// The CLI supports creating a MRVA query pack directly from the source pack.
95-
queryPackDir = qlPackDetails.qlPackRootPath;
95+
targetPackPath = qlPackDetails.qlPackRootPath;
9696
// We expect any dependencies to be available already.
9797
needsInstall = false;
9898
}
9999

100100
if (needsInstall) {
101101
// Install the dependencies of the synthesized query pack.
102-
await cliServer.packInstall(queryPackDir, {
102+
await cliServer.packInstall(targetPackPath, {
103103
workspaceFolders,
104104
});
105105

@@ -120,7 +120,7 @@ async function generateQueryPack(
120120

121121
const queryOpts = qlPackDetails.queryFiles.flatMap((q) => [
122122
"--query",
123-
join(queryPackDir, relative(qlPackDetails.qlPackRootPath, q)),
123+
join(targetPackPath, relative(qlPackDetails.qlPackRootPath, q)),
124124
]);
125125

126126
precompilationOpts = [
@@ -143,16 +143,16 @@ async function generateQueryPack(
143143
}
144144

145145
if (extensionPacks.length > 0) {
146-
await addExtensionPacksAsDependencies(queryPackDir, extensionPacks);
146+
await addExtensionPacksAsDependencies(targetPackPath, extensionPacks);
147147
}
148148
}
149149

150150
const bundlePath = tmpDir.bundleFile;
151151
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.)`,
153153
);
154154
await cliServer.packBundle(
155-
queryPackDir,
155+
targetPackPath,
156156
workspaceFolders,
157157
bundlePath,
158158
tmpDir.compiledPackDir,
@@ -164,12 +164,12 @@ async function generateQueryPack(
164164

165165
async function createNewQueryPack(
166166
qlPackDetails: QlPackDetails,
167-
queryPackDir: string,
167+
targetPackPath: string,
168168
) {
169169
for (const queryFile of qlPackDetails.queryFiles) {
170-
void extLogger.log(`Copying ${queryFile} to ${queryPackDir}`);
170+
void extLogger.log(`Copying ${queryFile} to ${targetPackPath}`);
171171
const relativeQueryPath = relative(qlPackDetails.qlPackRootPath, queryFile);
172-
const targetQueryFileName = join(queryPackDir, relativeQueryPath);
172+
const targetQueryFileName = join(targetPackPath, relativeQueryPath);
173173
await copy(queryFile, targetQueryFileName);
174174
}
175175

@@ -184,15 +184,15 @@ async function createNewQueryPack(
184184
};
185185

186186
await writeFile(
187-
join(queryPackDir, FALLBACK_QLPACK_FILENAME),
187+
join(targetPackPath, FALLBACK_QLPACK_FILENAME),
188188
dump(syntheticQueryPack),
189189
);
190190
}
191191

192192
async function copyExistingQueryPack(
193193
cliServer: CodeQLCliServer,
194194
qlPackDetails: QlPackDetails,
195-
queryPackDir: string,
195+
targetPackPath: string,
196196
) {
197197
const toCopy = await cliServer.packPacklist(
198198
qlPackDetails.qlPackRootPath,
@@ -226,7 +226,7 @@ async function copyExistingQueryPack(
226226
});
227227

228228
let copiedCount = 0;
229-
await copy(qlPackDetails.qlPackRootPath, queryPackDir, {
229+
await copy(qlPackDetails.qlPackRootPath, targetPackPath, {
230230
filter: (file: string) =>
231231
// copy file if it is in the packlist, or it is a parent directory of a file in the packlist
232232
!!toCopy.find((f) => {
@@ -241,9 +241,9 @@ async function copyExistingQueryPack(
241241
}),
242242
});
243243

244-
void extLogger.log(`Copied ${copiedCount} files to ${queryPackDir}`);
244+
void extLogger.log(`Copied ${copiedCount} files to ${targetPackPath}`);
245245

246-
await fixPackFile(queryPackDir, qlPackDetails);
246+
await fixPackFile(targetPackPath, qlPackDetails);
247247
}
248248

249249
interface RemoteQueryTempDir {
@@ -378,21 +378,21 @@ export async function prepareRemoteQueryRun(
378378
* - Removes any `${workspace}` version references from the qlpack.yml or codeql-pack.yml file. Converts them
379379
* to `*` versions.
380380
*
381-
* @param queryPackDir The directory containing the query pack
381+
* @param targetPackPath The path to the directory containing the target pack
382382
* @param qlPackDetails The details of the original QL pack
383383
*/
384384
async function fixPackFile(
385-
queryPackDir: string,
385+
targetPackPath: string,
386386
qlPackDetails: QlPackDetails,
387387
): Promise<void> {
388-
const packPath = await getQlPackFilePath(queryPackDir);
388+
const packPath = await getQlPackFilePath(targetPackPath);
389389

390390
// This should not happen since we create the pack ourselves.
391391
if (!packPath) {
392392
throw new Error(
393393
`Could not find ${QLPACK_FILENAMES.join(
394394
" or ",
395-
)} file in '${queryPackDir}'`,
395+
)} file in '${targetPackPath}'`,
396396
);
397397
}
398398
const qlpack = load(await readFile(packPath, "utf8")) as QlPackFile;

0 commit comments

Comments
 (0)