Skip to content

Commit dae472c

Browse files
authored
Merge pull request #2213 from github/koesie10/check-for-updates-typed-command
Add `codeQL.checkForUpdatesToCLI` type for command
2 parents 20f85f2 + 81cce9f commit dae472c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export type BuiltInVsCodeCommands = {
3939
"workbench.action.reloadWindow": () => Promise<void>;
4040
};
4141

42+
// Commands that are available before the extension is fully activated.
43+
// These commands are *not* registered using the command manager, but can
44+
// be invoked using the command manager.
45+
export type PreActivationCommands = {
46+
"codeQL.checkForUpdatesToCLI": () => Promise<void>;
47+
};
48+
4249
// Base commands not tied directly to a module like e.g. variant analysis.
4350
export type BaseCommands = {
4451
"codeQL.openDocumentation": () => Promise<void>;
@@ -240,7 +247,7 @@ export type MockGitHubApiServerCommands = {
240247
"codeQL.mockGitHubApiServer.unloadScenario": () => Promise<void>;
241248
};
242249

243-
// All commands where the implementation is provided by this extension.
250+
// All commands where the implementation is provided by this activated extension.
244251
export type AllExtensionCommands = BaseCommands &
245252
QueryEditorCommands &
246253
ResultsViewCommands &
@@ -256,7 +263,9 @@ export type AllExtensionCommands = BaseCommands &
256263
Partial<TestUICommands> &
257264
MockGitHubApiServerCommands;
258265

259-
export type AllCommands = AllExtensionCommands & BuiltInVsCodeCommands;
266+
export type AllCommands = AllExtensionCommands &
267+
PreActivationCommands &
268+
BuiltInVsCodeCommands;
260269

261270
export type AppCommandManager = CommandManager<AllCommands>;
262271

extensions/ql-vscode/src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ import { QueryHistoryDirs } from "./query-history/query-history-dirs";
112112
import {
113113
AllExtensionCommands,
114114
BaseCommands,
115+
PreActivationCommands,
115116
QueryServerCommands,
116117
TestUICommands,
117118
} from "./common/commands";
@@ -235,6 +236,8 @@ function registerErrorStubs(
235236

236237
stubbedCommands.forEach((command) => {
237238
if (excludedCommands.indexOf(command) === -1) {
239+
// This is purposefully using `commandRunner` instead of the command manager because these
240+
// commands are untyped and registered pre-activation.
238241
errorStubs.push(commandRunner(command, stubGenerator(command)));
239242
}
240243
});
@@ -336,6 +339,8 @@ export async function activate(
336339
),
337340
);
338341
ctx.subscriptions.push(
342+
// This is purposefully using `commandRunner` directly instead of the command manager
343+
// because this command is registered pre-activation.
339344
commandRunner(checkForUpdatesCommand, () =>
340345
installOrUpdateThenTryActivate(
341346
ctx,
@@ -1089,7 +1094,8 @@ async function initializeLogging(ctx: ExtensionContext): Promise<void> {
10891094
ctx.subscriptions.push(ideServerLogger);
10901095
}
10911096

1092-
const checkForUpdatesCommand = "codeQL.checkForUpdatesToCLI";
1097+
const checkForUpdatesCommand: keyof PreActivationCommands =
1098+
"codeQL.checkForUpdatesToCLI" as const;
10931099

10941100
const avoidVersionCheck = "avoid-version-check-at-startup";
10951101
const lastVersionChecked = "last-version-checked";

0 commit comments

Comments
 (0)