1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[deps] Vault: Update commander to v11 (#7329)

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* removed unused interfaces

* fix shell completions (#7756)

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gbubemismith <gsmithwalter@gmail.com>
Co-authored-by: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com>
Co-authored-by: SmithThe4th <gsmith@bitwarden.com>
This commit is contained in:
renovate[bot]
2024-01-31 17:17:04 -05:00
committed by GitHub
parent 01781848f3
commit 83812d471c
15 changed files with 152 additions and 212 deletions

View File

@@ -1,25 +1,12 @@
import * as program from "commander";
import { program, OptionValues, Command } from "commander";
import { Response } from "../models/response";
import { MessageResponse } from "../models/response/message.response";
interface IOption {
long?: string;
short?: string;
description: string;
}
interface ICommand {
commands?: ICommand[];
options?: IOption[];
_name: string;
_description: string;
}
const validShells = ["zsh"];
export class CompletionCommand {
async run(options: program.OptionValues) {
async run(options: OptionValues) {
const shell: (typeof validShells)[number] = options.shell;
if (!shell) {
@@ -33,14 +20,14 @@ export class CompletionCommand {
let content = "";
if (shell === "zsh") {
content = this.zshCompletion("bw", program as any as ICommand).render();
content = this.zshCompletion("bw", program).render();
}
const res = new MessageResponse(content, null);
return Response.success(res);
}
private zshCompletion(rootName: string, rootCommand: ICommand) {
private zshCompletion(rootName: string, rootCommand: Command) {
return {
render: () => {
return [
@@ -52,7 +39,7 @@ export class CompletionCommand {
};
}
private renderCommandBlock(name: string, command: ICommand): string {
private renderCommandBlock(name: string, command: Command): string {
const { commands = [], options = [] } = command;
const hasOptions = options.length > 0;
const hasCommands = commands.length > 0;
@@ -89,18 +76,19 @@ export class CompletionCommand {
cmnds)
commands=(
${commands
.map(({ _name, _description }) => `"${_name}:${_description}"`)
.map((command) => `"${command.name().split(" ")[0]}:${command.description()}"`)
.join("\n ")}
)
_describe "command" commands
;;
esac
;;\n esac
case "$words[1]" in
${commands
.map(({ _name }) => [`${_name})`, `_${name}_${_name}`, ";;"].join("\n "))
.join("\n ")}
esac`,
.map((command) => {
const commandName = command.name().split(" ")[0];
return [`${commandName})`, `_${name}_${commandName}`, ";;"].join("\n ");
})
.join("\n ")}\n esac`,
);
}
@@ -110,7 +98,7 @@ export class CompletionCommand {
if (hasCommands) {
commandBlocParts.push(
commands.map((c) => this.renderCommandBlock(`${name}_${c._name}`, c)).join("\n\n"),
commands.map((c) => this.renderCommandBlock(`${name}_${c.name()}`, c)).join("\n\n"),
);
}

View File

@@ -1,4 +1,4 @@
import * as program from "commander";
import { OptionValues } from "commander";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
@@ -9,7 +9,7 @@ import { StringResponse } from "../models/response/string.response";
export class ConfigCommand {
constructor(private environmentService: EnvironmentService) {}
async run(setting: string, value: string, options: program.OptionValues): Promise<Response> {
async run(setting: string, value: string, options: OptionValues): Promise<Response> {
setting = setting.toLowerCase();
switch (setting) {
case "server":
@@ -19,7 +19,7 @@ export class ConfigCommand {
}
}
private async getOrSetServer(url: string, options: program.OptionValues): Promise<Response> {
private async getOrSetServer(url: string, options: OptionValues): Promise<Response> {
if (
(url == null || url.trim() === "") &&
!options.webVault &&

View File

@@ -1,6 +1,6 @@
import * as koaMulter from "@koa/multer";
import * as koaRouter from "@koa/router";
import * as program from "commander";
import { OptionValues } from "commander";
import * as koa from "koa";
import * as koaBodyParser from "koa-bodyparser";
import * as koaJson from "koa-json";
@@ -164,7 +164,7 @@ export class ServeCommand {
);
}
async run(options: program.OptionValues) {
async run(options: OptionValues) {
const protectOrigin = !options.disableOriginProtection;
const port = options.port || 8087;
const hostname = options.hostname || "localhost";