From a89c3872627e5d2f94c8d38305c1180cc0882c29 Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Mon, 24 Oct 2022 14:58:25 -0700 Subject: [PATCH] Remove `FindModule.ts` since its long since been deprecated And the associated handlers in PSES do not exist. --- package.json | 3 +- src/features/FindModule.ts | 104 ------------------------------------- src/main.ts | 2 - 3 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 src/features/FindModule.ts diff --git a/package.json b/package.json index 460946267e..4faf1c14a8 100644 --- a/package.json +++ b/package.json @@ -229,7 +229,8 @@ { "command": "PowerShell.PowerShellFindModule", "title": "Find/Install PowerShell Modules from the Gallery", - "category": "PowerShell" + "category": "PowerShell", + "deprecationMessage": "This feature is no longer available, we're sorry!" }, { "command": "PowerShell.ShowAdditionalCommands", diff --git a/src/features/FindModule.ts b/src/features/FindModule.ts deleted file mode 100644 index 9819eae47f..0000000000 --- a/src/features/FindModule.ts +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// TODO: PSES does not currently support findModule...so this whole thing is broken! - -import vscode = require("vscode"); -import { RequestType } from "vscode-languageclient"; -import QuickPickItem = vscode.QuickPickItem; -import { LanguageClientConsumer } from "../languageClientConsumer"; - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -interface IFindModuleRequestArguments { -} - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -interface IModule { - name: string, - description: string -} - -export const FindModuleRequestType = - new RequestType("powerShell/findModule"); - -export const InstallModuleRequestType = - new RequestType("powerShell/installModule"); - -export class FindModuleFeature extends LanguageClientConsumer { - - private command: vscode.Disposable; - private cancelFindToken?: vscode.CancellationTokenSource; - - constructor() { - super(); - this.command = vscode.commands.registerCommand("PowerShell.PowerShellFindModule", async () => { - // It takes a while to get the list of PowerShell modules, display some UI to let user know - this.cancelFindToken = new vscode.CancellationTokenSource(); - const response = await vscode.window.showQuickPick( - ["Cancel"], - { placeHolder: "Please wait, retrieving list of PowerShell modules. This can take some time..." }, - this.cancelFindToken.token); - - if (response === "Cancel") { - this.clearCancelFindToken(); - } - - // Cancel the loading prompt after 60 seconds - setTimeout(() => { - if (this.cancelFindToken) { - this.clearCancelFindToken(); - - // eslint-disable-next-line @typescript-eslint/no-floating-promises - vscode.window.showErrorMessage( - "The online source for PowerShell modules is not responding. " + - "Cancelling Find/Install PowerShell command."); - } - }, 60000); - - const module = await this.pickPowerShellModule(); - if (module !== undefined) { - await this.languageClient?.sendRequest(InstallModuleRequestType, module); - } - }); - } - - public dispose() { - this.command.dispose(); - } - - private async pickPowerShellModule(): Promise { - const modules = await this.languageClient?.sendRequest(FindModuleRequestType, undefined); - const items: QuickPickItem[] = []; - - // We've got the modules info, let's cancel the timeout unless it's already been cancelled - if (this.cancelFindToken) { - this.clearCancelFindToken(); - } else { - // Already timed out, would be weird to display modules after we said it timed out. - return Promise.resolve(""); - } - - for (const module of modules ?? []) { - items.push({ label: module.name, description: module.description }); - } - - if (items.length === 0) { - return Promise.reject("No PowerShell modules were found."); - } - - const options: vscode.QuickPickOptions = { - placeHolder: "Select a PowerShell module to install", - matchOnDescription: true, - matchOnDetail: true, - }; - - return vscode.window.showQuickPick(items, options).then((item) => { - return item ? item.label : ""; - }); - } - - private clearCancelFindToken() { - this.cancelFindToken?.dispose(); - this.cancelFindToken = undefined; - } -} diff --git a/src/main.ts b/src/main.ts index 21fe2cc255..190348cb98 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,6 @@ import { ExamplesFeature } from "./features/Examples"; import { ExpandAliasFeature } from "./features/ExpandAlias"; import { ExtensionCommandsFeature } from "./features/ExtensionCommands"; import { ExternalApiFeature, IPowerShellExtensionClient } from "./features/ExternalApi"; -import { FindModuleFeature } from "./features/FindModule"; import { GenerateBugReportFeature } from "./features/GenerateBugReport"; import { GetCommandsFeature } from "./features/GetCommands"; import { HelpCompletionFeature } from "./features/HelpCompletion"; @@ -159,7 +158,6 @@ export async function activate(context: vscode.ExtensionContext): Promise