Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,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>;
};
Expand All @@ -149,6 +154,7 @@ export type AllCommands = BaseCommands &
LocalDatabasesCommands &
VariantAnalysisCommands &
DatabasePanelCommands &
PackagingCommands &
EvalLogViewerCommands;

export type AppCommandManager = CommandManager<AllCommands>;
Expand Down
30 changes: 4 additions & 26 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
import { EvalLogViewer } from "./eval-log-viewer";
Expand Down Expand Up @@ -821,6 +818,9 @@ async function activateWithInstalledDistribution(
...variantAnalysisManager.getCommands(),
...databaseUI.getCommands(),
...dbModule.getCommands(),
...getPackagingCommands({
cliServer,
}),
...evalLogViewer.getCommands(),
};

Expand Down Expand Up @@ -984,28 +984,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();
Expand Down
34 changes: 33 additions & 1 deletion extensions/ql-vscode/src/packaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down