Skip to content

Commit 34bdbd1

Browse files
committed
Move qlpack functions/constants to pure
1 parent 7d6461a commit 34bdbd1

5 files changed

Lines changed: 27 additions & 23 deletions

File tree

extensions/ql-vscode/src/contextual/queryResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
getOnDiskWorkspaceFolders,
1010
QlPacksForLanguage,
1111
showAndLogExceptionWithTelemetry,
12-
QLPACK_FILENAMES,
1312
} from "../helpers";
1413
import { KeyType, kindOfKeyType, nameOfKeyType, tagOfKeyType } from "./keyType";
1514
import { CodeQLCliServer } from "../cli";
@@ -20,6 +19,7 @@ import { CancellationToken, Uri } from "vscode";
2019
import { ProgressCallback } from "../commandRunner";
2120
import { QueryRunner } from "../queryRunner";
2221
import { redactableError } from "../pure/errors";
22+
import { QLPACK_FILENAMES } from "../pure/ql";
2323

2424
export async function qlpackOfDatabase(
2525
cli: CodeQLCliServer,

extensions/ql-vscode/src/helpers.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { extLogger, OutputChannelLogger } from "./common";
2323
import { QueryMetadata } from "./pure/interface-types";
2424
import { telemetryListener } from "./telemetry";
2525
import { RedactableError } from "./pure/errors";
26+
import { getQlPackPath } from "./pure/ql";
2627

2728
// Shared temporary folder for the extension.
2829
export const tmpDir = dirSync({
@@ -742,20 +743,3 @@ export async function* walkDirectory(
742743
}
743744
}
744745
}
745-
746-
export const QLPACK_FILENAMES = ["qlpack.yml", "codeql-pack.yml"];
747-
export const FALLBACK_QLPACK_FILENAME = QLPACK_FILENAMES[0];
748-
749-
export async function getQlPackPath(
750-
packRoot: string,
751-
): Promise<string | undefined> {
752-
for (const filename of QLPACK_FILENAMES) {
753-
const path = join(packRoot, filename);
754-
755-
if (await pathExists(path)) {
756-
return path;
757-
}
758-
}
759-
760-
return undefined;
761-
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { join } from "path";
2+
import { pathExists } from "fs-extra";
3+
4+
export const QLPACK_FILENAMES = ["qlpack.yml", "codeql-pack.yml"];
5+
export const FALLBACK_QLPACK_FILENAME = QLPACK_FILENAMES[0];
6+
7+
export async function getQlPackPath(
8+
packRoot: string,
9+
): Promise<string | undefined> {
10+
for (const filename of QLPACK_FILENAMES) {
11+
const path = join(packRoot, filename);
12+
13+
if (await pathExists(path)) {
14+
return path;
15+
}
16+
}
17+
18+
return undefined;
19+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ import { LSPErrorCodes, ResponseError } from "vscode-languageclient";
1212
import { CodeQLCliServer } from "./cli";
1313
import { DatabaseUI } from "./databases-ui";
1414
import {
15-
FALLBACK_QLPACK_FILENAME,
1615
getInitialQueryContents,
1716
getPrimaryDbscheme,
1817
getQlPackForDbscheme,
19-
getQlPackPath,
2018
showBinaryChoiceDialog,
2119
} from "./helpers";
2220
import { ProgressCallback, UserCancellationException } from "./commandRunner";
2321
import { getErrorMessage } from "./pure/helpers-pure";
22+
import { FALLBACK_QLPACK_FILENAME, getQlPackPath } from "./pure/ql";
2423

2524
const QUICK_QUERIES_DIR_NAME = "quick-queries";
2625
const QUICK_QUERY_QUERY_NAME = "quick-query.ql";

extensions/ql-vscode/src/remote-queries/run-remote-query.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import {
99
getOnDiskWorkspaceFolders,
1010
tryGetQueryMetadata,
1111
tmpDir,
12-
FALLBACK_QLPACK_FILENAME,
13-
getQlPackPath,
14-
QLPACK_FILENAMES,
1512
} from "../helpers";
1613
import { Credentials } from "../common/authentication";
1714
import * as cli from "../cli";
@@ -33,6 +30,11 @@ import {
3330
} from "./repository-selection";
3431
import { Repository } from "./shared/repository";
3532
import { DbManager } from "../databases/db-manager";
33+
import {
34+
getQlPackPath,
35+
FALLBACK_QLPACK_FILENAME,
36+
QLPACK_FILENAMES,
37+
} from "../pure/ql";
3638

3739
export interface QlPack {
3840
name: string;

0 commit comments

Comments
 (0)