Skip to content

Commit 7c7a64c

Browse files
committed
Convert packaging commands to typed commands
1 parent dfff7ae commit 7c7a64c

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

extensions/ql-vscode/src/common/commands.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,16 @@ export type DatabasePanelCommands = {
108108
"codeQLVariantAnalysisRepositories.removeItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
109109
};
110110

111+
export type PackagingCommands = {
112+
"codeQL.installPackDependencies": () => Promise<void>;
113+
"codeQL.downloadPacks": () => Promise<void>;
114+
};
115+
111116
export type AllCommands = BaseCommands &
112117
QueryHistoryCommands &
113118
LocalDatabasesCommands &
114119
VariantAnalysisCommands &
115-
DatabasePanelCommands;
120+
DatabasePanelCommands &
121+
PackagingCommands;
116122

117123
export type AppCommandManager = CommandManager<AllCommands>;

extensions/ql-vscode/src/extension.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ import {
103103
withProgress,
104104
} from "./commandRunner";
105105
import { CodeQlStatusBarHandler } from "./status-bar";
106-
import { registerPackagingCommands } from "./packaging";
106+
import { getPackagingCommands } from "./packaging";
107107
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
108108
import { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
109109
import { EvalLogViewer } from "./eval-log-viewer";
@@ -1090,6 +1090,9 @@ async function activateWithInstalledDistribution(
10901090
...variantAnalysisManager.getCommands(),
10911091
...databaseUI.getCommands(),
10921092
...dbModule.getCommands(),
1093+
...getPackagingCommands({
1094+
cliServer,
1095+
}),
10931096
};
10941097

10951098
for (const [commandName, command] of Object.entries(allCommands)) {
@@ -1292,10 +1295,6 @@ async function activateWithInstalledDistribution(
12921295
}),
12931296
);
12941297

1295-
registerPackagingCommands(ctx, {
1296-
cliServer,
1297-
});
1298-
12991298
ctx.subscriptions.push(
13001299
commandRunner("codeQL.showLogs", async () => {
13011300
extLogger.show();

extensions/ql-vscode/src/packaging.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import {
44
showAndLogExceptionWithTelemetry,
55
showAndLogInformationMessage,
66
} from "./helpers";
7-
import { ExtensionContext, QuickPickItem, window } from "vscode";
7+
import { QuickPickItem, window } from "vscode";
88
import {
9-
commandRunner,
109
ProgressCallback,
1110
UserCancellationException,
1211
withProgress,
@@ -15,38 +14,33 @@ import { extLogger } from "./common";
1514
import { asError, getErrorStack } from "./pure/helpers-pure";
1615
import { redactableError } from "./pure/errors";
1716
import { PACKS_BY_QUERY_LANGUAGE } from "./common/query-language";
17+
import { PackagingCommands } from "./common/commands";
1818

1919
type PackagingOptions = {
2020
cliServer: CodeQLCliServer;
2121
};
2222

23-
export function registerPackagingCommands(
24-
ctx: ExtensionContext,
25-
{ cliServer }: PackagingOptions,
26-
) {
27-
ctx.subscriptions.push(
28-
commandRunner("codeQL.installPackDependencies", async () =>
23+
export function getPackagingCommands({
24+
cliServer,
25+
}: PackagingOptions): PackagingCommands {
26+
return {
27+
"codeQL.installPackDependencies": async () =>
2928
withProgress(
3029
async (progress: ProgressCallback) =>
3130
await handleInstallPackDependencies(cliServer, progress),
3231
{
3332
title: "Installing pack dependencies",
3433
},
3534
),
36-
),
37-
);
38-
39-
ctx.subscriptions.push(
40-
commandRunner("codeQL.downloadPacks", async () =>
35+
"codeQL.downloadPacks": async () =>
4136
withProgress(
4237
async (progress: ProgressCallback) =>
4338
await handleDownloadPacks(cliServer, progress),
4439
{
4540
title: "Downloading packs",
4641
},
4742
),
48-
),
49-
);
43+
};
5044
}
5145

5246
/**

0 commit comments

Comments
 (0)