Convert run variant analysis command to new commands package
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { CommandManager } from "../packages/commands";
|
||||
import type { Uri } from "vscode";
|
||||
|
||||
/**
|
||||
* Contains type definitions for all commands used by the extension.
|
||||
@@ -17,6 +18,8 @@ export type VariantAnalysisCommands = {
|
||||
"codeQL.openVariantAnalysisLogs": (
|
||||
variantAnalysisId: number,
|
||||
) => Promise<void>;
|
||||
"codeQL.runVariantAnalysis": (uri?: Uri) => Promise<void>;
|
||||
"codeQL.runVariantAnalysisContextEditor": (uri?: Uri) => Promise<void>;
|
||||
};
|
||||
|
||||
export type AllCommands = ExtensionCommands & VariantAnalysisCommands;
|
||||
|
||||
@@ -1151,55 +1151,6 @@ async function activateWithInstalledDistribution(
|
||||
),
|
||||
);
|
||||
|
||||
async function runVariantAnalysis(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
uri: Uri | undefined,
|
||||
): Promise<void> {
|
||||
progress({
|
||||
maxStep: 5,
|
||||
step: 0,
|
||||
message: "Getting credentials",
|
||||
});
|
||||
|
||||
await variantAnalysisManager.runVariantAnalysis(
|
||||
uri || window.activeTextEditor?.document.uri,
|
||||
progress,
|
||||
token,
|
||||
);
|
||||
}
|
||||
|
||||
ctx.subscriptions.push(
|
||||
commandRunnerWithProgress(
|
||||
"codeQL.runVariantAnalysis",
|
||||
async (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
uri: Uri | undefined,
|
||||
) => await runVariantAnalysis(progress, token, uri),
|
||||
{
|
||||
title: "Run Variant Analysis",
|
||||
cancellable: true,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
|
||||
ctx.subscriptions.push(
|
||||
commandRunnerWithProgress(
|
||||
"codeQL.runVariantAnalysisContextEditor",
|
||||
async (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
uri: Uri | undefined,
|
||||
) => await runVariantAnalysis(progress, token, uri),
|
||||
{
|
||||
title: "Run Variant Analysis",
|
||||
cancellable: true,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const allCommands: AllCommands = {
|
||||
...getCommands(),
|
||||
...variantAnalysisManager.getCommands(),
|
||||
|
||||
@@ -51,7 +51,11 @@ import {
|
||||
import { readFile, readJson, remove, pathExists, outputJson } from "fs-extra";
|
||||
import { EOL } from "os";
|
||||
import { cancelVariantAnalysis } from "./gh-api/gh-actions-api-client";
|
||||
import { ProgressCallback, UserCancellationException } from "../commandRunner";
|
||||
import {
|
||||
ProgressCallback,
|
||||
UserCancellationException,
|
||||
withProgress,
|
||||
} from "../commandRunner";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import {
|
||||
defaultFilterSortState,
|
||||
@@ -132,6 +136,11 @@ export class VariantAnalysisManager
|
||||
"codeQL.openVariantAnalysisLogs": async (variantAnalysisId: number) => {
|
||||
await this.openVariantAnalysisLogs(variantAnalysisId);
|
||||
},
|
||||
"codeQL.runVariantAnalysis": async (uri?: Uri) =>
|
||||
this.runVariantAnalysisFromCommand(uri),
|
||||
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
|
||||
"codeQL.runVariantAnalysisContextEditor": async (uri?: Uri) =>
|
||||
this.runVariantAnalysisFromCommand(uri),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,11 +148,32 @@ export class VariantAnalysisManager
|
||||
return this.app.commandManager;
|
||||
}
|
||||
|
||||
private async runVariantAnalysisFromCommand(uri?: Uri) {
|
||||
return withProgress(
|
||||
async (progress, token) =>
|
||||
this.runVariantAnalysis(
|
||||
uri || Window.activeTextEditor?.document.uri,
|
||||
progress,
|
||||
token,
|
||||
),
|
||||
{
|
||||
title: "Run Variant Analysis",
|
||||
cancellable: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public async runVariantAnalysis(
|
||||
uri: Uri | undefined,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
progress({
|
||||
maxStep: 5,
|
||||
step: 0,
|
||||
message: "Getting credentials",
|
||||
});
|
||||
|
||||
const {
|
||||
actionBranch,
|
||||
base64Pack,
|
||||
|
||||
Reference in New Issue
Block a user