Skip to content

Commit 5bb724b

Browse files
authored
Rename getQlPackPath to getQlPackFilePath (#3265)
1 parent 5664844 commit 5bb724b

7 files changed

Lines changed: 27 additions & 21 deletions

File tree

extensions/ql-vscode/src/common/ql.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export const QLPACK_LOCK_FILENAMES = [
88
];
99
export const FALLBACK_QLPACK_FILENAME = QLPACK_FILENAMES[0];
1010

11-
export async function getQlPackPath(
11+
/**
12+
* Gets the path to the QL pack file (a qlpack.yml or
13+
* codeql-pack.yml).
14+
* @param packRoot The root of the pack.
15+
* @returns The path to the qlpack file, or undefined if it doesn't exist.
16+
*/
17+
export async function getQlPackFilePath(
1218
packRoot: string,
1319
): Promise<string | undefined> {
1420
for (const filename of QLPACK_FILENAMES) {

extensions/ql-vscode/src/databases/qlpack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { glob } from "glob";
33
import { basename } from "path";
44
import { load } from "js-yaml";
55
import { readFile } from "fs-extra";
6-
import { getQlPackPath } from "../common/ql";
6+
import { getQlPackFilePath } from "../common/ql";
77
import type { CodeQLCliServer, QlpacksInfo } from "../codeql-cli/cli";
88
import { extLogger } from "../common/logging/vscode";
99
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
@@ -31,7 +31,7 @@ async function findDbschemePack(
3131
): Promise<{ name: string; isLibraryPack: boolean }> {
3232
for (const { packDir, packName } of packs) {
3333
if (packDir !== undefined) {
34-
const qlpackPath = await getQlPackPath(packDir);
34+
const qlpackPath = await getQlPackFilePath(packDir);
3535

3636
if (qlpackPath !== undefined) {
3737
const qlpack = load(await readFile(qlpackPath, "utf8")) as {

extensions/ql-vscode/src/local-queries/quick-query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getPrimaryDbscheme, getQlPackForDbscheme } from "../databases/qlpack";
1111
import type { ProgressCallback } from "../common/vscode/progress";
1212
import { UserCancellationException } from "../common/vscode/progress";
1313
import { getErrorMessage } from "../common/helpers-pure";
14-
import { FALLBACK_QLPACK_FILENAME, getQlPackPath } from "../common/ql";
14+
import { FALLBACK_QLPACK_FILENAME, getQlPackFilePath } from "../common/ql";
1515
import type { App } from "../common/app";
1616
import type { ExtensionApp } from "../common/vscode/vscode-app";
1717

@@ -119,7 +119,7 @@ export async function displayQuickQuery(
119119
const dbscheme = await getPrimaryDbscheme(datasetFolder);
120120
const qlpack = (await getQlPackForDbscheme(cliServer, dbscheme))
121121
.dbschemePack;
122-
const qlPackFile = await getQlPackPath(queriesDir);
122+
const qlPackFile = await getQlPackFilePath(queriesDir);
123123
const qlFile = join(queriesDir, QUICK_QUERY_QUERY_NAME);
124124
const shouldRewrite = await checkShouldRewrite(qlPackFile, qlpack);
125125

extensions/ql-vscode/src/local-queries/skeleton-query-wizard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { redactableError } from "../common/errors";
3636
import type { App } from "../common/app";
3737
import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
3838
import { containsPath, pathsEqual } from "../common/files";
39-
import { getQlPackPath } from "../common/ql";
39+
import { getQlPackFilePath } from "../common/ql";
4040
import { getQlPackLanguage } from "../common/qlpack-language";
4141

4242
type QueryLanguagesToDatabaseMap = Record<string, string>;
@@ -111,7 +111,7 @@ export class SkeletonQueryWizard {
111111

112112
// Try to detect if there is already a qlpack in this location. We will assume that
113113
// the user hasn't changed the language of the qlpack.
114-
const qlPackPath = await getQlPackPath(this.qlPackStoragePath);
114+
const qlPackPath = await getQlPackFilePath(this.qlPackStoragePath);
115115

116116
// If we are creating or using a qlpack in the user's selected folder, we will also
117117
// create the query in that folder
@@ -248,7 +248,7 @@ export class SkeletonQueryWizard {
248248

249249
const matchingQueryPackPath = matchingQueryPacks[0];
250250

251-
const qlPackPath = await getQlPackPath(matchingQueryPackPath);
251+
const qlPackPath = await getQlPackFilePath(matchingQueryPackPath);
252252
if (!qlPackPath) {
253253
return undefined;
254254
}

extensions/ql-vscode/src/model-editor/extension-pack-picker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
99
import type { ProgressCallback } from "../common/vscode/progress";
1010
import { UserCancellationException } from "../common/vscode/progress";
1111
import type { DatabaseItem } from "../databases/local-databases";
12-
import { getQlPackPath, QLPACK_FILENAMES } from "../common/ql";
12+
import { getQlPackFilePath, QLPACK_FILENAMES } from "../common/ql";
1313
import { getErrorMessage } from "../common/helpers-pure";
1414
import type { ExtensionPack } from "./shared/extension-pack";
1515
import type { NotificationLogger } from "../common/logging";
@@ -208,7 +208,7 @@ async function readExtensionPack(
208208
path: string,
209209
language: string,
210210
): Promise<ExtensionPack> {
211-
const qlpackPath = await getQlPackPath(path);
211+
const qlpackPath = await getQlPackFilePath(path);
212212
if (!qlpackPath) {
213213
throw new Error(
214214
`Could not find any of ${QLPACK_FILENAMES.join(", ")} in ${path}`,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
import type { Repository } from "./shared/repository";
3030
import type { DbManager } from "../databases/db-manager";
3131
import {
32-
getQlPackPath,
32+
getQlPackFilePath,
3333
FALLBACK_QLPACK_FILENAME,
3434
QLPACK_FILENAMES,
3535
QLPACK_LOCK_FILENAMES,
@@ -74,7 +74,7 @@ async function generateQueryPack(
7474
);
7575

7676
const mustSynthesizePack =
77-
(await getQlPackPath(originalPackRoot)) === undefined;
77+
(await getQlPackFilePath(originalPackRoot)) === undefined;
7878
const cliSupportsMrvaPackCreate =
7979
await cliServer.cliConstraints.supportsMrvaPackCreate();
8080

@@ -265,7 +265,7 @@ async function copyExistingQueryPack(
265265
async function findPackRoot(queryFile: string): Promise<string> {
266266
// recursively find the directory containing qlpack.yml or codeql-pack.yml
267267
let dir = dirname(queryFile);
268-
while (!(await getQlPackPath(dir))) {
268+
while (!(await getQlPackFilePath(dir))) {
269269
dir = dirname(dir);
270270
if (isFileSystemRoot(dir)) {
271271
// there is no qlpack.yml or codeql-pack.yml in this directory or any parent directory.
@@ -440,7 +440,7 @@ async function fixPackFile(
440440
queryPackDir: string,
441441
packRelativePath: string,
442442
): Promise<void> {
443-
const packPath = await getQlPackPath(queryPackDir);
443+
const packPath = await getQlPackFilePath(queryPackDir);
444444

445445
// This should not happen since we create the pack ourselves.
446446
if (!packPath) {
@@ -490,7 +490,7 @@ async function addExtensionPacksAsDependencies(
490490
queryPackDir: string,
491491
extensionPacks: string[],
492492
): Promise<void> {
493-
const qlpackFile = await getQlPackPath(queryPackDir);
493+
const qlpackFile = await getQlPackFilePath(queryPackDir);
494494
if (!qlpackFile) {
495495
throw new Error(
496496
`Could not find ${QLPACK_FILENAMES.join(

extensions/ql-vscode/test/unit-tests/common/ql.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { join } from "path";
22
import { dirSync } from "tmp-promise";
33
import type { DirResult } from "tmp";
44
import { writeFile } from "fs-extra";
5-
import { getQlPackPath } from "../../../src/common/ql";
5+
import { getQlPackFilePath } from "../../../src/common/ql";
66

7-
describe("getQlPackPath", () => {
7+
describe("getQlPackFilePath", () => {
88
let tmpDir: DirResult;
99

1010
beforeEach(() => {
@@ -22,27 +22,27 @@ describe("getQlPackPath", () => {
2222
it("should find a qlpack.yml when it exists", async () => {
2323
await writeFile(join(tmpDir.name, "qlpack.yml"), "name: test");
2424

25-
const result = await getQlPackPath(tmpDir.name);
25+
const result = await getQlPackFilePath(tmpDir.name);
2626
expect(result).toEqual(join(tmpDir.name, "qlpack.yml"));
2727
});
2828

2929
it("should find a codeql-pack.yml when it exists", async () => {
3030
await writeFile(join(tmpDir.name, "codeql-pack.yml"), "name: test");
3131

32-
const result = await getQlPackPath(tmpDir.name);
32+
const result = await getQlPackFilePath(tmpDir.name);
3333
expect(result).toEqual(join(tmpDir.name, "codeql-pack.yml"));
3434
});
3535

3636
it("should find a qlpack.yml when both exist", async () => {
3737
await writeFile(join(tmpDir.name, "qlpack.yml"), "name: test");
3838
await writeFile(join(tmpDir.name, "codeql-pack.yml"), "name: test");
3939

40-
const result = await getQlPackPath(tmpDir.name);
40+
const result = await getQlPackFilePath(tmpDir.name);
4141
expect(result).toEqual(join(tmpDir.name, "qlpack.yml"));
4242
});
4343

4444
it("should find nothing when it doesn't exist", async () => {
45-
const result = await getQlPackPath(tmpDir.name);
45+
const result = await getQlPackFilePath(tmpDir.name);
4646
expect(result).toEqual(undefined);
4747
});
4848
});

0 commit comments

Comments
 (0)