Add CLI version constraint for packaging
This commit is contained in:
@@ -1199,6 +1199,11 @@ export class CliVersionConstraint {
|
||||
*/
|
||||
public static CLI_VERSION_WITH_OLD_EVAL_STATS = new SemVer('2.7.4');
|
||||
|
||||
/**
|
||||
* CLI version where packaging was introduced.
|
||||
*/
|
||||
public static CLI_VERSION_WITH_PACKAGING = new SemVer('2.6.0');
|
||||
|
||||
constructor(private readonly cli: CodeQLCliServer) {
|
||||
/**/
|
||||
}
|
||||
@@ -1250,4 +1255,8 @@ export class CliVersionConstraint {
|
||||
async supportsOldEvalStats() {
|
||||
return this.isVersionAtLeast(CliVersionConstraint.CLI_VERSION_WITH_OLD_EVAL_STATS);
|
||||
}
|
||||
|
||||
async supportsPackaging() {
|
||||
return this.isVersionAtLeast(CliVersionConstraint.CLI_VERSION_WITH_PACKAGING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CodeQLCliServer } from './cli';
|
||||
import { CliVersionConstraint, CodeQLCliServer } from './cli';
|
||||
import {
|
||||
getOnDiskWorkspaceFolders,
|
||||
showAndLogErrorMessage,
|
||||
@@ -30,6 +30,10 @@ export async function handleDownloadPacks(
|
||||
cliServer: CodeQLCliServer,
|
||||
progress: ProgressCallback,
|
||||
): Promise<void> {
|
||||
if (!(await cliServer.cliConstraints.supportsPackaging())) {
|
||||
throw new Error(`Packaging commands are not supported by this version of CodeQL. Please upgrade to v${CliVersionConstraint.CLI_VERSION_WITH_PACKAGING
|
||||
} or later.`);
|
||||
}
|
||||
progress({
|
||||
message: 'Choose packs to download',
|
||||
step: 1,
|
||||
@@ -87,6 +91,10 @@ export async function handleInstallPacks(
|
||||
cliServer: CodeQLCliServer,
|
||||
progress: ProgressCallback,
|
||||
): Promise<void> {
|
||||
if (!(await cliServer.cliConstraints.supportsPackaging())) {
|
||||
throw new Error(`Packaging commands are not supported by this version of CodeQL. Please upgrade to v${CliVersionConstraint.CLI_VERSION_WITH_PACKAGING
|
||||
} or later.`);
|
||||
}
|
||||
progress({
|
||||
message: 'Choose packs to install',
|
||||
step: 1,
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as path from 'path';
|
||||
|
||||
import * as pq from 'proxyquire';
|
||||
|
||||
import { CodeQLCliServer } from '../../cli';
|
||||
import { CliVersionConstraint, CodeQLCliServer } from '../../cli';
|
||||
import { CodeQLExtensionInterface } from '../../extension';
|
||||
import { expect } from 'chai';
|
||||
|
||||
@@ -40,7 +40,11 @@ describe('Packaging commands', function() {
|
||||
'Extension not initialized. Make sure cli is downloaded and installed properly.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!(await cli.cliConstraints.supportsPackaging())) {
|
||||
console.log(`Packaging commands are not supported on CodeQL CLI v${CliVersionConstraint.CLI_VERSION_WITH_PACKAGING
|
||||
}. Skipping this test.`);
|
||||
this.skip();
|
||||
}
|
||||
progress = sandbox.spy();
|
||||
quickPickSpy = sandbox.stub(window, 'showQuickPick');
|
||||
inputBoxSpy = sandbox.stub(window, 'showInputBox');
|
||||
|
||||
Reference in New Issue
Block a user