Skip to content

Commit c853baf

Browse files
committed
Merge remote-tracking branch 'origin/main' into koesie10/commands-with-progress
2 parents c3b023c + c632c38 commit c853baf

22 files changed

Lines changed: 985 additions & 598 deletions

File tree

extensions/ql-vscode/package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@
15351535
"ts-node": "^10.7.0",
15361536
"ts-protoc-gen": "^0.9.0",
15371537
"typescript": "^4.5.5",
1538-
"webpack": "^5.62.2",
1538+
"webpack": "^5.76.0",
15391539
"webpack-cli": "^4.6.0"
15401540
},
15411541
"lint-staged": {

extensions/ql-vscode/src/cli.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,11 +1284,25 @@ export class CodeQLCliServer implements Disposable {
12841284
);
12851285
}
12861286

1287-
async packInstall(dir: string, forceUpdate = false) {
1287+
async packInstall(
1288+
dir: string,
1289+
{ forceUpdate = false, workspaceFolders = [] as string[] } = {},
1290+
) {
12881291
const args = [dir];
12891292
if (forceUpdate) {
12901293
args.push("--mode", "update");
12911294
}
1295+
if (workspaceFolders?.length > 0) {
1296+
if (await this.cliConstraints.supportsAdditionalPacksInstall()) {
1297+
args.push(
1298+
// Allow prerelease packs from the ql submodule.
1299+
"--allow-prerelease",
1300+
// Allow the use of --additional-packs argument without issueing a warning
1301+
"--no-strict-mode",
1302+
...this.getAdditionalPacksArg(workspaceFolders),
1303+
);
1304+
}
1305+
}
12921306
return this.runJsonCodeQlCliCommandWithAuthentication(
12931307
["pack", "install"],
12941308
args,
@@ -1692,6 +1706,13 @@ export class CliVersionConstraint {
16921706
*/
16931707
public static CLI_VERSION_WITH_QLPACKS_KIND = new SemVer("2.12.3");
16941708

1709+
/**
1710+
* CLI version that supports the `--additional-packs` option for the `pack install` command.
1711+
*/
1712+
public static CLI_VERSION_WITH_ADDITIONAL_PACKS_INSTALL = new SemVer(
1713+
"2.12.4",
1714+
);
1715+
16951716
constructor(private readonly cli: CodeQLCliServer) {
16961717
/**/
16971718
}
@@ -1755,4 +1776,10 @@ export class CliVersionConstraint {
17551776
CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND,
17561777
);
17571778
}
1779+
1780+
async supportsAdditionalPacksInstall() {
1781+
return this.isVersionAtLeast(
1782+
CliVersionConstraint.CLI_VERSION_WITH_ADDITIONAL_PACKS_INSTALL,
1783+
);
1784+
}
17581785
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Disposable } from "../pure/disposable-object";
33
import { AppEventEmitter } from "./events";
44
import { Logger } from "./logging";
55
import { Memento } from "./memento";
6-
import { ExtensionCommandManager } from "./commands";
6+
import { AppCommandManager } from "./commands";
77

88
export interface App {
99
createEventEmitter<T>(): AppEventEmitter<T>;
@@ -16,7 +16,7 @@ export interface App {
1616
readonly workspaceStoragePath?: string;
1717
readonly workspaceState: Memento;
1818
readonly credentials: Credentials;
19-
readonly commandManager: ExtensionCommandManager;
19+
readonly commands: AppCommandManager;
2020
}
2121

2222
export enum AppMode {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import type { Uri } from "vscode";
88
* the implementation in the corresponding `getCommands` function.
99
*/
1010

11-
// Commands directly in the extension
12-
export type ExtensionCommands = {
11+
// Base commands not tied directly to a module like e.g. variant analysis.
12+
export type BaseCommands = {
1313
"codeQL.openDocumentation": () => Promise<void>;
1414
};
1515

@@ -22,6 +22,6 @@ export type VariantAnalysisCommands = {
2222
"codeQL.runVariantAnalysisContextEditor": (uri?: Uri) => Promise<void>;
2323
};
2424

25-
export type AllCommands = ExtensionCommands & VariantAnalysisCommands;
25+
export type AllCommands = BaseCommands & VariantAnalysisCommands;
2626

27-
export type ExtensionCommandManager = CommandManager<AllCommands>;
27+
export type AppCommandManager = CommandManager<AllCommands>;

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ import { commandRunner } from "../../commandRunner";
33
import { CommandFunction, CommandManager } from "../../packages/commands";
44

55
/**
6-
* Intializes a command manager for VSCode, wrapping the commandRunner
6+
* Create a command manager for VSCode, wrapping the commandRunner
77
* and vscode.executeCommand.
88
*/
9-
export function initializeVSCodeCommandManager<
9+
export function createVSCodeCommandManager<
1010
Commands extends Record<string, CommandFunction>,
1111
>(): CommandManager<Commands> {
12-
return new CommandManager(commandRunner, wrappedExecuteCommand);
12+
return new CommandManager(commandRunner, wrapExecuteCommand);
1313
}
1414

15-
async function wrappedExecuteCommand<
15+
/**
16+
* wrapExecuteCommand wraps commands.executeCommand to satisfy that the
17+
* type is a Promise. Type script does not seem to be smart enough
18+
* to figure out that `ReturnType<Commands[CommandName]>` is actually
19+
* a Promise, so we need to add a second layer of wrapping and unwrapping
20+
* (The `Promise<Awaited<` part) to get the right types.
21+
*/
22+
async function wrapExecuteCommand<
1623
Commands extends Record<string, CommandFunction>,
1724
CommandName extends keyof Commands & string = keyof Commands & string,
1825
>(

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import { AppEventEmitter } from "../events";
66
import { extLogger, Logger } from "../logging";
77
import { Memento } from "../memento";
88
import { VSCodeAppEventEmitter } from "./events";
9-
import { ExtensionCommandManager } from "../commands";
10-
import { initializeVSCodeCommandManager } from "./commands";
9+
import { AppCommandManager } from "../commands";
10+
import { createVSCodeCommandManager } from "./commands";
1111

1212
export class ExtensionApp implements App {
1313
public readonly credentials: VSCodeCredentials;
14-
public readonly commandManager: ExtensionCommandManager;
14+
public readonly commands: AppCommandManager;
1515

1616
public constructor(
1717
public readonly extensionContext: vscode.ExtensionContext,
1818
) {
1919
this.credentials = new VSCodeCredentials();
20-
this.commandManager = initializeVSCodeCommandManager();
21-
extensionContext.subscriptions.push(this.commandManager);
20+
this.commands = createVSCodeCommandManager();
21+
extensionContext.subscriptions.push(this.commands);
2222
}
2323

2424
public get extensionPath(): string {

0 commit comments

Comments
 (0)