Add in CodeQL CLI version check for the "resolve extensions" command
This commit is contained in:
@@ -1274,6 +1274,12 @@ export class CodeQLCliServer implements Disposable {
|
||||
suite: string,
|
||||
additionalPacks: string[],
|
||||
): Promise<ResolveExtensionsResult> {
|
||||
if (!(await this.cliConstraints.supportsResolveExtensions())) {
|
||||
throw new Error(
|
||||
"Resolving extensions is only supported for CodeQL CLI v2.10.2 or later",
|
||||
);
|
||||
}
|
||||
|
||||
const args = this.getAdditionalPacksArg(additionalPacks);
|
||||
args.push(suite);
|
||||
|
||||
@@ -1806,6 +1812,11 @@ export class CliVersionConstraint {
|
||||
"2.10.0",
|
||||
);
|
||||
|
||||
/**
|
||||
* CLI version where the `resolve extensions` subcommand exists.
|
||||
*/
|
||||
public static CLI_VERSION_WITH_RESOLVE_EXTENSIONS = new SemVer("2.10.2");
|
||||
|
||||
/**
|
||||
* CLI version where the `--evaluator-log` and related options to the query server were introduced,
|
||||
* on a per-query server basis.
|
||||
@@ -1882,6 +1893,12 @@ export class CliVersionConstraint {
|
||||
);
|
||||
}
|
||||
|
||||
async supportsResolveExtensions() {
|
||||
return this.isVersionAtLeast(
|
||||
CliVersionConstraint.CLI_VERSION_WITH_RESOLVE_EXTENSIONS,
|
||||
);
|
||||
}
|
||||
|
||||
async supportsStructuredEvalLog() {
|
||||
return this.isVersionAtLeast(
|
||||
CliVersionConstraint.CLI_VERSION_WITH_STRUCTURED_EVAL_LOG,
|
||||
|
||||
@@ -54,6 +54,16 @@ export class DataExtensionsEditorModule {
|
||||
public getCommands(): DataExtensionsEditorCommands {
|
||||
return {
|
||||
"codeQL.openDataExtensionsEditor": async () => {
|
||||
if (
|
||||
!(await this.cliServer.cliConstraints.supportsResolveExtensions())
|
||||
) {
|
||||
void showAndLogErrorMessage(
|
||||
this.app.logger,
|
||||
"CodeQL CLI version v2.10.2 or later is required to use the data extensions editor.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const db = this.databaseManager.currentDatabaseItem;
|
||||
if (!db) {
|
||||
void showAndLogErrorMessage(this.app.logger, "No database selected");
|
||||
|
||||
@@ -93,6 +93,10 @@ describe("listModelFiles", () => {
|
||||
}
|
||||
|
||||
it("should return the empty set when the extension pack is empty", async () => {
|
||||
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionPackPath = makeExtensionPack("extension-pack", []);
|
||||
|
||||
const modelFiles = await listModelFiles(extensionPackPath, cli);
|
||||
@@ -100,6 +104,10 @@ describe("listModelFiles", () => {
|
||||
});
|
||||
|
||||
it("should find all model files", async () => {
|
||||
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionPackPath = makeExtensionPack("extension-pack", [
|
||||
"library1.model.yml",
|
||||
"library2.model.yml",
|
||||
@@ -115,6 +123,10 @@ describe("listModelFiles", () => {
|
||||
});
|
||||
|
||||
it("should ignore model files from other extension packs", async () => {
|
||||
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionPackPath = makeExtensionPack("extension-pack", [
|
||||
"library1.model.yml",
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user