Skip to content

Commit 1782239

Browse files
Add in CodeQL CLI version check for the "resolve extensions" command
1 parent 752cf8a commit 1782239

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,12 @@ export class CodeQLCliServer implements Disposable {
12741274
suite: string,
12751275
additionalPacks: string[],
12761276
): Promise<ResolveExtensionsResult> {
1277+
if (!(await this.cliConstraints.supportsResolveExtensions())) {
1278+
throw new Error(
1279+
"Resolving extensions is only supported for CodeQL CLI v2.10.2 or later",
1280+
);
1281+
}
1282+
12771283
const args = this.getAdditionalPacksArg(additionalPacks);
12781284
args.push(suite);
12791285

@@ -1806,6 +1812,11 @@ export class CliVersionConstraint {
18061812
"2.10.0",
18071813
);
18081814

1815+
/**
1816+
* CLI version where the `resolve extensions` subcommand exists.
1817+
*/
1818+
public static CLI_VERSION_WITH_RESOLVE_EXTENSIONS = new SemVer("2.10.2");
1819+
18091820
/**
18101821
* CLI version where the `--evaluator-log` and related options to the query server were introduced,
18111822
* on a per-query server basis.
@@ -1882,6 +1893,12 @@ export class CliVersionConstraint {
18821893
);
18831894
}
18841895

1896+
async supportsResolveExtensions() {
1897+
return this.isVersionAtLeast(
1898+
CliVersionConstraint.CLI_VERSION_WITH_RESOLVE_EXTENSIONS,
1899+
);
1900+
}
1901+
18851902
async supportsStructuredEvalLog() {
18861903
return this.isVersionAtLeast(
18871904
CliVersionConstraint.CLI_VERSION_WITH_STRUCTURED_EVAL_LOG,

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ export class DataExtensionsEditorModule {
5454
public getCommands(): DataExtensionsEditorCommands {
5555
return {
5656
"codeQL.openDataExtensionsEditor": async () => {
57+
if (
58+
!(await this.cliServer.cliConstraints.supportsResolveExtensions())
59+
) {
60+
void showAndLogErrorMessage(
61+
this.app.logger,
62+
"CodeQL CLI version v2.10.2 or later is required to use the data extensions editor.",
63+
);
64+
return;
65+
}
66+
5767
const db = this.databaseManager.currentDatabaseItem;
5868
if (!db) {
5969
void showAndLogErrorMessage(this.app.logger, "No database selected");

extensions/ql-vscode/test/vscode-tests/cli-integration/data-extensions-editor/modeled-method-fs.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,21 @@ describe("listModelFiles", () => {
9393
}
9494

9595
it("should return the empty set when the extension pack is empty", async () => {
96+
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
97+
return;
98+
}
99+
96100
const extensionPackPath = makeExtensionPack("extension-pack", []);
97101

98102
const modelFiles = await listModelFiles(extensionPackPath, cli);
99103
expect(modelFiles).toEqual(new Set());
100104
});
101105

102106
it("should find all model files", async () => {
107+
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
108+
return;
109+
}
110+
103111
const extensionPackPath = makeExtensionPack("extension-pack", [
104112
"library1.model.yml",
105113
"library2.model.yml",
@@ -115,6 +123,10 @@ describe("listModelFiles", () => {
115123
});
116124

117125
it("should ignore model files from other extension packs", async () => {
126+
if (!(await cli.cliConstraints.supportsResolveExtensions())) {
127+
return;
128+
}
129+
118130
const extensionPackPath = makeExtensionPack("extension-pack", [
119131
"library1.model.yml",
120132
]);

0 commit comments

Comments
 (0)