diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 52e805f86..c304d99c2 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -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 () => { diff --git a/extensions/ql-vscode/src/packaging.ts b/extensions/ql-vscode/src/packaging.ts index c17621c09..43d9a99ad 100644 --- a/extensions/ql-vscode/src/packaging.ts +++ b/extensions/ql-vscode/src/packaging.ts @@ -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. *