Merge pull request #2198 from github/koesie10/packaging-typed-commands
Convert packaging to typed commands
This commit is contained in:
@@ -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>;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user