Skip to content

Commit ef267f8

Browse files
committed
Move packaging command registration to separate file
1 parent 168af11 commit ef267f8

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ import {
103103
withProgress,
104104
} from "./commandRunner";
105105
import { CodeQlStatusBarHandler } from "./status-bar";
106-
import {
107-
handleDownloadPacks,
108-
handleInstallPackDependencies,
109-
} from "./packaging";
106+
import { registerPackagingCommands } from "./packaging";
110107
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
111108
import { exportSelectedVariantAnalysisResults } from "./variant-analysis/export-results";
112109
import { EvalLogViewer } from "./eval-log-viewer";
@@ -1295,27 +1292,9 @@ async function activateWithInstalledDistribution(
12951292
}),
12961293
);
12971294

1298-
ctx.subscriptions.push(
1299-
commandRunnerWithProgress(
1300-
"codeQL.installPackDependencies",
1301-
async (progress: ProgressCallback) =>
1302-
await handleInstallPackDependencies(cliServer, progress),
1303-
{
1304-
title: "Installing pack dependencies",
1305-
},
1306-
),
1307-
);
1308-
1309-
ctx.subscriptions.push(
1310-
commandRunnerWithProgress(
1311-
"codeQL.downloadPacks",
1312-
async (progress: ProgressCallback) =>
1313-
await handleDownloadPacks(cliServer, progress),
1314-
{
1315-
title: "Downloading packs",
1316-
},
1317-
),
1318-
);
1295+
registerPackagingCommands(ctx, {
1296+
cliServer,
1297+
});
13191298

13201299
ctx.subscriptions.push(
13211300
commandRunner("codeQL.showLogs", async () => {

extensions/ql-vscode/src/packaging.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,48 @@ import {
44
showAndLogExceptionWithTelemetry,
55
showAndLogInformationMessage,
66
} from "./helpers";
7-
import { QuickPickItem, window } from "vscode";
8-
import { ProgressCallback, UserCancellationException } from "./commandRunner";
7+
import { ExtensionContext, QuickPickItem, window } from "vscode";
8+
import {
9+
commandRunnerWithProgress,
10+
ProgressCallback,
11+
UserCancellationException,
12+
} from "./commandRunner";
913
import { extLogger } from "./common";
1014
import { asError, getErrorStack } from "./pure/helpers-pure";
1115
import { redactableError } from "./pure/errors";
1216
import { PACKS_BY_QUERY_LANGUAGE } from "./common/query-language";
1317

18+
type PackagingOptions = {
19+
cliServer: CodeQLCliServer;
20+
};
21+
22+
export function registerPackagingCommands(
23+
ctx: ExtensionContext,
24+
{ cliServer }: PackagingOptions,
25+
) {
26+
ctx.subscriptions.push(
27+
commandRunnerWithProgress(
28+
"codeQL.installPackDependencies",
29+
async (progress: ProgressCallback) =>
30+
await handleInstallPackDependencies(cliServer, progress),
31+
{
32+
title: "Installing pack dependencies",
33+
},
34+
),
35+
);
36+
37+
ctx.subscriptions.push(
38+
commandRunnerWithProgress(
39+
"codeQL.downloadPacks",
40+
async (progress: ProgressCallback) =>
41+
await handleDownloadPacks(cliServer, progress),
42+
{
43+
title: "Downloading packs",
44+
},
45+
),
46+
);
47+
}
48+
1449
/**
1550
* Prompts user to choose packs to download, and downloads them.
1651
*

0 commit comments

Comments
 (0)