Skip to content

Commit 81cce9f

Browse files
committed
Add codeQL.checkForUpdatesToCLI type for command
The `codeQL.checkForUpdatesToCLI` command is registered pre-activation, and we don't really want to create the command manager before activation, so this will just add the correct type without registering it using the command manager.
1 parent 297fa2e commit 81cce9f

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>;
@@ -237,7 +244,7 @@ export type MockGitHubApiServerCommands = {
237244
"codeQL.mockGitHubApiServer.unloadScenario": () => Promise<void>;
238245
};
239246

240-
// All commands where the implementation is provided by this extension.
247+
// All commands where the implementation is provided by this activated extension.
241248
export type AllExtensionCommands = BaseCommands &
242249
QueryEditorCommands &
243250
ResultsViewCommands &
@@ -253,7 +260,9 @@ export type AllExtensionCommands = BaseCommands &
253260
Partial<TestUICommands> &
254261
MockGitHubApiServerCommands;
255262

256-
export type AllCommands = AllExtensionCommands & BuiltInVsCodeCommands;
263+
export type AllCommands = AllExtensionCommands &
264+
PreActivationCommands &
265+
BuiltInVsCodeCommands;
257266

258267
export type AppCommandManager = CommandManager<AllCommands>;
259268

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";
@@ -204,6 +205,8 @@ function registerErrorStubs(
204205

205206
stubbedCommands.forEach((command) => {
206207
if (excludedCommands.indexOf(command) === -1) {
208+
// This is purposefully using `commandRunner` instead of the command manager because these
209+
// commands are untyped and registered pre-activation.
207210
errorStubs.push(commandRunner(command, stubGenerator(command)));
208211
}
209212
});
@@ -305,6 +308,8 @@ export async function activate(
305308
),
306309
);
307310
ctx.subscriptions.push(
311+
// This is purposefully using `commandRunner` directly instead of the command manager
312+
// because this command is registered pre-activation.
308313
commandRunner(checkForUpdatesCommand, () =>
309314
installOrUpdateThenTryActivate(
310315
ctx,
@@ -1096,7 +1101,8 @@ async function initializeLogging(ctx: ExtensionContext): Promise<void> {
10961101
ctx.subscriptions.push(ideServerLogger);
10971102
}
10981103

1099-
const checkForUpdatesCommand = "codeQL.checkForUpdatesToCLI";
1104+
const checkForUpdatesCommand: keyof PreActivationCommands =
1105+
"codeQL.checkForUpdatesToCLI" as const;
11001106

11011107
const avoidVersionCheck = "avoid-version-check-at-startup";
11021108
const lastVersionChecked = "last-version-checked";

0 commit comments

Comments
 (0)