Move qlpack functions/constants to pure

This commit is contained in:
Koen Vlaswinkel
2023-02-08 17:12:22 +00:00
parent 7d6461a10a
commit 34bdbd158d
5 changed files with 27 additions and 23 deletions

View File

@@ -9,7 +9,6 @@ import {
getOnDiskWorkspaceFolders,
QlPacksForLanguage,
showAndLogExceptionWithTelemetry,
QLPACK_FILENAMES,
} from "../helpers";
import { KeyType, kindOfKeyType, nameOfKeyType, tagOfKeyType } from "./keyType";
import { CodeQLCliServer } from "../cli";
@@ -20,6 +19,7 @@ import { CancellationToken, Uri } from "vscode";
import { ProgressCallback } from "../commandRunner";
import { QueryRunner } from "../queryRunner";
import { redactableError } from "../pure/errors";
import { QLPACK_FILENAMES } from "../pure/ql";
export async function qlpackOfDatabase(
cli: CodeQLCliServer,

View File

@@ -23,6 +23,7 @@ import { extLogger, OutputChannelLogger } from "./common";
import { QueryMetadata } from "./pure/interface-types";
import { telemetryListener } from "./telemetry";
import { RedactableError } from "./pure/errors";
import { getQlPackPath } from "./pure/ql";
// Shared temporary folder for the extension.
export const tmpDir = dirSync({
@@ -742,20 +743,3 @@ export async function* walkDirectory(
}
}
}
export const QLPACK_FILENAMES = ["qlpack.yml", "codeql-pack.yml"];
export const FALLBACK_QLPACK_FILENAME = QLPACK_FILENAMES[0];
export async function getQlPackPath(
packRoot: string,
): Promise<string | undefined> {
for (const filename of QLPACK_FILENAMES) {
const path = join(packRoot, filename);
if (await pathExists(path)) {
return path;
}
}
return undefined;
}

View File

@@ -0,0 +1,19 @@
import { join } from "path";
import { pathExists } from "fs-extra";
export const QLPACK_FILENAMES = ["qlpack.yml", "codeql-pack.yml"];
export const FALLBACK_QLPACK_FILENAME = QLPACK_FILENAMES[0];
export async function getQlPackPath(
packRoot: string,
): Promise<string | undefined> {
for (const filename of QLPACK_FILENAMES) {
const path = join(packRoot, filename);
if (await pathExists(path)) {
return path;
}
}
return undefined;
}

View File

@@ -12,15 +12,14 @@ import { LSPErrorCodes, ResponseError } from "vscode-languageclient";
import { CodeQLCliServer } from "./cli";
import { DatabaseUI } from "./databases-ui";
import {
FALLBACK_QLPACK_FILENAME,
getInitialQueryContents,
getPrimaryDbscheme,
getQlPackForDbscheme,
getQlPackPath,
showBinaryChoiceDialog,
} from "./helpers";
import { ProgressCallback, UserCancellationException } from "./commandRunner";
import { getErrorMessage } from "./pure/helpers-pure";
import { FALLBACK_QLPACK_FILENAME, getQlPackPath } from "./pure/ql";
const QUICK_QUERIES_DIR_NAME = "quick-queries";
const QUICK_QUERY_QUERY_NAME = "quick-query.ql";

View File

@@ -9,9 +9,6 @@ import {
getOnDiskWorkspaceFolders,
tryGetQueryMetadata,
tmpDir,
FALLBACK_QLPACK_FILENAME,
getQlPackPath,
QLPACK_FILENAMES,
} from "../helpers";
import { Credentials } from "../common/authentication";
import * as cli from "../cli";
@@ -33,6 +30,11 @@ import {
} from "./repository-selection";
import { Repository } from "./shared/repository";
import { DbManager } from "../databases/db-manager";
import {
getQlPackPath,
FALLBACK_QLPACK_FILENAME,
QLPACK_FILENAMES,
} from "../pure/ql";
export interface QlPack {
name: string;