Move packaging command registration to separate file

This commit is contained in:
Koen Vlaswinkel
2023-03-21 16:22:08 +01:00
parent 168af11e00
commit ef267f87bb
2 changed files with 41 additions and 27 deletions

View File

@@ -103,10 +103,7 @@ import {
withProgress,
} from "./commandRunner";
import { CodeQlStatusBarHandler } from "./status-bar";
import {
handleDownloadPacks,
handleInstallPackDependencies,
} from "./packaging";
import { registerPackagingCommands } from "./packaging";
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
import { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
import { EvalLogViewer } from "./eval-log-viewer";
@@ -1295,27 +1292,9 @@ async function activateWithInstalledDistribution(
}),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.installPackDependencies",
async (progress: ProgressCallback) =>
await handleInstallPackDependencies(cliServer, progress),
{
title: "Installing pack dependencies",
},
),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.downloadPacks",
async (progress: ProgressCallback) =>
await handleDownloadPacks(cliServer, progress),
{
title: "Downloading packs",
},
),
);
registerPackagingCommands(ctx, {
cliServer,
});
ctx.subscriptions.push(
commandRunner("codeQL.showLogs", async () => {

View File

@@ -4,13 +4,48 @@ import {
showAndLogExceptionWithTelemetry,
showAndLogInformationMessage,
} from "./helpers";
import { QuickPickItem, window } from "vscode";
import { ProgressCallback, UserCancellationException } from "./commandRunner";
import { ExtensionContext, QuickPickItem, window } from "vscode";
import {
commandRunnerWithProgress,
ProgressCallback,
UserCancellationException,
} from "./commandRunner";
import { extLogger } from "./common";
import { asError, getErrorStack } from "./pure/helpers-pure";
import { redactableError } from "./pure/errors";
import { PACKS_BY_QUERY_LANGUAGE } from "./common/query-language";
type PackagingOptions = {
cliServer: CodeQLCliServer;
};
export function registerPackagingCommands(
ctx: ExtensionContext,
{ cliServer }: PackagingOptions,
) {
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.installPackDependencies",
async (progress: ProgressCallback) =>
await handleInstallPackDependencies(cliServer, progress),
{
title: "Installing pack dependencies",
},
),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.downloadPacks",
async (progress: ProgressCallback) =>
await handleDownloadPacks(cliServer, progress),
{
title: "Downloading packs",
},
),
);
}
/**
* Prompts user to choose packs to download, and downloads them.
*