Merge pull request #2198 from github/koesie10/packaging-typed-commands

Convert packaging to typed commands
This commit is contained in:
Koen Vlaswinkel
2023-03-22 13:02:21 +01:00
committed by GitHub
3 changed files with 43 additions and 27 deletions

View File

@@ -167,6 +167,11 @@ export type DatabasePanelCommands = {
"codeQLVariantAnalysisRepositories.removeItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
};
export type PackagingCommands = {
"codeQL.installPackDependencies": () => Promise<void>;
"codeQL.downloadPacks": () => Promise<void>;
};
export type EvalLogViewerCommands = {
"codeQLEvalLogViewer.clear": () => Promise<void>;
};
@@ -176,6 +181,7 @@ export type AllCommands = BaseCommands &
LocalDatabasesCommands &
VariantAnalysisCommands &
DatabasePanelCommands &
PackagingCommands &
EvalLogViewerCommands;
export type AppCommandManager = CommandManager<AllCommands>;

View File

@@ -96,10 +96,7 @@ import {
withProgress,
} from "./commandRunner";
import { CodeQlStatusBarHandler } from "./status-bar";
import {
handleDownloadPacks,
handleInstallPackDependencies,
} from "./packaging";
import { getPackagingCommands } from "./packaging";
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
import { EvalLogViewer } from "./eval-log-viewer";
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
@@ -815,6 +812,9 @@ async function activateWithInstalledDistribution(
...variantAnalysisManager.getCommands(),
...databaseUI.getCommands(),
...dbModule.getCommands(),
...getPackagingCommands({
cliServer,
}),
...evalLogViewer.getCommands(),
};
@@ -906,28 +906,6 @@ 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",
},
),
);
ctx.subscriptions.push(
commandRunner("codeQL.showLogs", async () => {
extLogger.show();

View File

@@ -5,11 +5,43 @@ import {
showAndLogInformationMessage,
} from "./helpers";
import { QuickPickItem, window } from "vscode";
import { ProgressCallback, UserCancellationException } from "./commandRunner";
import {
ProgressCallback,
UserCancellationException,
withProgress,
} 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";
import { PackagingCommands } from "./common/commands";
type PackagingOptions = {
cliServer: CodeQLCliServer;
};
export function getPackagingCommands({
cliServer,
}: PackagingOptions): PackagingCommands {
return {
"codeQL.installPackDependencies": async () =>
withProgress(
async (progress: ProgressCallback) =>
await handleInstallPackDependencies(cliServer, progress),
{
title: "Installing pack dependencies",
},
),
"codeQL.downloadPacks": async () =>
withProgress(
async (progress: ProgressCallback) =>
await handleDownloadPacks(cliServer, progress),
{
title: "Downloading packs",
},
),
};
}
/**
* Prompts user to choose packs to download, and downloads them.