mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-14 10:26:19 +01: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:
parent
01781848f3
commit
83812d471c
@ -53,7 +53,7 @@
|
||||
"big-integer": "1.6.51",
|
||||
"browser-hrtime": "1.1.8",
|
||||
"chalk": "4.1.2",
|
||||
"commander": "7.2.0",
|
||||
"commander": "11.1.0",
|
||||
"form-data": "4.0.0",
|
||||
"https-proxy-agent": "7.0.2",
|
||||
"inquirer": "8.2.6",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as http from "http";
|
||||
|
||||
import * as program from "commander";
|
||||
import { OptionValues } from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
import Separator from "inquirer/lib/objects/separator";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
@ -47,7 +47,7 @@ export class LoginCommand {
|
||||
protected email: string;
|
||||
|
||||
private ssoRedirectUri: string = null;
|
||||
private options: program.OptionValues;
|
||||
private options: OptionValues;
|
||||
|
||||
constructor(
|
||||
protected authService: AuthService,
|
||||
@ -68,7 +68,7 @@ export class LoginCommand {
|
||||
protected logoutCallback: () => Promise<void>,
|
||||
) {}
|
||||
|
||||
async run(email: string, password: string, options: program.OptionValues) {
|
||||
async run(email: string, password: string, options: OptionValues) {
|
||||
this.options = options;
|
||||
this.email = email;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as program from "commander";
|
||||
import { program } from "commander";
|
||||
import * as jsdom from "jsdom";
|
||||
|
||||
import { PinCryptoServiceAbstraction, PinCryptoService } from "@bitwarden/auth/common";
|
||||
|
@ -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"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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 &&
|
||||
|
@ -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";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as chalk from "chalk";
|
||||
import * as program from "commander";
|
||||
import { program, Command, OptionValues } from "commander";
|
||||
|
||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||
|
||||
@ -135,7 +135,7 @@ export class Program {
|
||||
writeLn(" bw login --sso");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (email: string, password: string, options: program.OptionValues) => {
|
||||
.action(async (email: string, password: string, options: OptionValues) => {
|
||||
if (!options.check) {
|
||||
await this.exitIfAuthed();
|
||||
const command = new LoginCommand(
|
||||
@ -427,7 +427,7 @@ export class Program {
|
||||
writeLn(" bw completion --shell zsh");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (options: program.OptionValues, cmd: program.Command) => {
|
||||
.action(async (options: OptionValues, cmd: Command) => {
|
||||
const command = new CompletionCommand();
|
||||
const response = await command.run(options);
|
||||
this.processResponse(response);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as program from "commander";
|
||||
import { OptionValues } from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
@ -22,7 +22,7 @@ export class ExportCommand {
|
||||
private eventCollectionService: EventCollectionService,
|
||||
) {}
|
||||
|
||||
async run(options: program.OptionValues): Promise<Response> {
|
||||
async run(options: OptionValues): Promise<Response> {
|
||||
if (
|
||||
options.organizationid == null &&
|
||||
(await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport))
|
||||
@ -79,7 +79,7 @@ export class ExportCommand {
|
||||
|
||||
private async saveFile(
|
||||
exportContent: string,
|
||||
options: program.OptionValues,
|
||||
options: OptionValues,
|
||||
format: ExportFormat,
|
||||
): Promise<Response> {
|
||||
try {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as program from "commander";
|
||||
import { OptionValues } from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
@ -16,11 +16,7 @@ export class ImportCommand {
|
||||
private syncService: SyncService,
|
||||
) {}
|
||||
|
||||
async run(
|
||||
format: ImportType,
|
||||
filepath: string,
|
||||
options: program.OptionValues,
|
||||
): Promise<Response> {
|
||||
async run(format: ImportType, filepath: string, options: OptionValues): Promise<Response> {
|
||||
const organizationId = options.organizationid;
|
||||
if (organizationId != null) {
|
||||
const organization = await this.organizationService.getFromState(organizationId);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as program from "commander";
|
||||
import { OptionValues } from "commander";
|
||||
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
@ -21,7 +21,7 @@ export class SendGetCommand extends DownloadCommand {
|
||||
super(cryptoService);
|
||||
}
|
||||
|
||||
async run(id: string, options: program.OptionValues) {
|
||||
async run(id: string, options: OptionValues) {
|
||||
const serveCommand = process.env.BW_SERVE === "true";
|
||||
if (serveCommand && !Utils.isGuid(id)) {
|
||||
return Response.badRequest("`" + id + "` is not a GUID.");
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as program from "commander";
|
||||
import { OptionValues } from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
@ -36,7 +36,7 @@ export class SendReceiveCommand extends DownloadCommand {
|
||||
super(cryptoService);
|
||||
}
|
||||
|
||||
async run(url: string, options: program.OptionValues): Promise<Response> {
|
||||
async run(url: string, options: OptionValues): Promise<Response> {
|
||||
this.canInteract = process.env.BW_NOINTERACTION !== "true";
|
||||
|
||||
let urlObject: URL;
|
||||
|
@ -2,7 +2,7 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as chalk from "chalk";
|
||||
import * as program from "commander";
|
||||
import { program, Command, OptionValues } from "commander";
|
||||
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
@ -39,14 +39,11 @@ export class SendProgram extends Program {
|
||||
program.addCommand(this.receiveCommand());
|
||||
}
|
||||
|
||||
private sendCommand(): program.Command {
|
||||
return new program.Command("send")
|
||||
.arguments("<data>")
|
||||
private sendCommand(): Command {
|
||||
return new Command("send")
|
||||
.argument("<data>", "The data to Send. Specify as a filepath with the --file option")
|
||||
.description(
|
||||
"Work with Bitwarden sends. A Send can be quickly created using this command or subcommands can be used to fine-tune the Send",
|
||||
{
|
||||
data: "The data to Send. Specify as a filepath with the --file option",
|
||||
},
|
||||
)
|
||||
.option("-f, --file", "Specifies that <data> is a filepath")
|
||||
.option(
|
||||
@ -73,7 +70,7 @@ export class SendProgram extends Program {
|
||||
.addCommand(this.editCommand())
|
||||
.addCommand(this.removePasswordCommand())
|
||||
.addCommand(this.deleteCommand())
|
||||
.action(async (data: string, options: program.OptionValues) => {
|
||||
.action(async (data: string, options: OptionValues) => {
|
||||
const encodedJson = this.makeSendJson(data, options);
|
||||
|
||||
let response: Response;
|
||||
@ -87,8 +84,8 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private receiveCommand(): program.Command {
|
||||
return new program.Command("receive")
|
||||
private receiveCommand(): Command {
|
||||
return new Command("receive")
|
||||
.arguments("<url>")
|
||||
.description("Access a Bitwarden Send from a url")
|
||||
.option("--password <password>", "Password needed to access the Send.")
|
||||
@ -106,7 +103,7 @@ export class SendProgram extends Program {
|
||||
);
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (url: string, options: program.OptionValues) => {
|
||||
.action(async (url: string, options: OptionValues) => {
|
||||
const cmd = new SendReceiveCommand(
|
||||
this.main.apiService,
|
||||
this.main.cryptoService,
|
||||
@ -120,14 +117,14 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private listCommand(): program.Command {
|
||||
return new program.Command("list")
|
||||
private listCommand(): Command {
|
||||
return new Command("list")
|
||||
|
||||
.description("List all the Sends owned by you")
|
||||
.on("--help", () => {
|
||||
writeLn(chalk("This is in the list command"));
|
||||
})
|
||||
.action(async (options: program.OptionValues) => {
|
||||
.action(async (options: OptionValues) => {
|
||||
await this.exitIfLocked();
|
||||
const cmd = new SendListCommand(
|
||||
this.main.sendService,
|
||||
@ -139,12 +136,10 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private templateCommand(): program.Command {
|
||||
return new program.Command("template")
|
||||
.arguments("<object>")
|
||||
.description("Get json templates for send objects", {
|
||||
object: "Valid objects are: send.text, send.file",
|
||||
})
|
||||
private templateCommand(): Command {
|
||||
return new Command("template")
|
||||
.argument("<object>", "Valid objects are: send.text, send.file")
|
||||
.description("Get json templates for send objects")
|
||||
.action(async (object) => {
|
||||
const cmd = new GetCommand(
|
||||
this.main.cipherService,
|
||||
@ -164,8 +159,8 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private getCommand(): program.Command {
|
||||
return new program.Command("get")
|
||||
private getCommand(): Command {
|
||||
return new Command("get")
|
||||
.arguments("<id>")
|
||||
.description("Get Sends owned by you.")
|
||||
.option("--output <output>", "Output directory or filename for attachment.")
|
||||
@ -189,7 +184,7 @@ export class SendProgram extends Program {
|
||||
writeLn(" bw send get searchText --file --raw");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (id: string, options: program.OptionValues) => {
|
||||
.action(async (id: string, options: OptionValues) => {
|
||||
await this.exitIfLocked();
|
||||
const cmd = new SendGetCommand(
|
||||
this.main.sendService,
|
||||
@ -202,12 +197,10 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private createCommand(): program.Command {
|
||||
return new program.Command("create")
|
||||
.arguments("[encodedJson]")
|
||||
.description("create a Send", {
|
||||
encodedJson: "JSON object to upload. Can also be piped in through stdin.",
|
||||
})
|
||||
private createCommand(): Command {
|
||||
return new Command("create")
|
||||
.argument("[encodedJson]", "JSON object to upload. Can also be piped in through stdin.")
|
||||
.description("create a Send")
|
||||
.option("--file <path>", "file to Send. Can also be specified in parent's JSON.")
|
||||
.option("--text <text>", "text to Send. Can also be specified in parent's JSON.")
|
||||
.option("--hidden", "text hidden flag. Valid only with the --text option.")
|
||||
@ -221,34 +214,28 @@ export class SendProgram extends Program {
|
||||
writeLn(" Options specified in JSON take precedence over command options");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(
|
||||
async (
|
||||
encodedJson: string,
|
||||
options: program.OptionValues,
|
||||
args: { parent: program.Command },
|
||||
) => {
|
||||
// Work-around to support `--fullObject` option for `send create --fullObject`
|
||||
// Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option
|
||||
// to be defind on both parent-command and sub-command
|
||||
const { fullObject = false } = args.parent.opts();
|
||||
const mergedOptions = {
|
||||
...options,
|
||||
fullObject: fullObject,
|
||||
};
|
||||
.action(async (encodedJson: string, options: OptionValues, args: { parent: Command }) => {
|
||||
// Work-around to support `--fullObject` option for `send create --fullObject`
|
||||
// Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option
|
||||
// to be defind on both parent-command and sub-command
|
||||
const { fullObject = false } = args.parent.opts();
|
||||
const mergedOptions = {
|
||||
...options,
|
||||
fullObject: fullObject,
|
||||
};
|
||||
|
||||
const response = await this.runCreate(encodedJson, mergedOptions);
|
||||
this.processResponse(response);
|
||||
},
|
||||
);
|
||||
const response = await this.runCreate(encodedJson, mergedOptions);
|
||||
this.processResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
private editCommand(): program.Command {
|
||||
return new program.Command("edit")
|
||||
.arguments("[encodedJson]")
|
||||
.description("edit a Send", {
|
||||
encodedJson:
|
||||
"Updated JSON object to save. If not provided, encodedJson is read from stdin.",
|
||||
})
|
||||
private editCommand(): Command {
|
||||
return new Command("edit")
|
||||
.argument(
|
||||
"[encodedJson]",
|
||||
"Updated JSON object to save. If not provided, encodedJson is read from stdin.",
|
||||
)
|
||||
.description("edit a Send")
|
||||
.option("--itemid <itemid>", "Overrides the itemId provided in [encodedJson]")
|
||||
.on("--help", () => {
|
||||
writeLn("");
|
||||
@ -256,7 +243,7 @@ export class SendProgram extends Program {
|
||||
writeLn(" You cannot update a File-type Send's file. Just delete and remake it");
|
||||
writeLn("", true);
|
||||
})
|
||||
.action(async (encodedJson: string, options: program.OptionValues) => {
|
||||
.action(async (encodedJson: string, options: OptionValues) => {
|
||||
await this.exitIfLocked();
|
||||
const getCmd = new SendGetCommand(
|
||||
this.main.sendService,
|
||||
@ -275,12 +262,10 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private deleteCommand(): program.Command {
|
||||
return new program.Command("delete")
|
||||
.arguments("<id>")
|
||||
.description("delete a Send", {
|
||||
id: "The id of the Send to delete.",
|
||||
})
|
||||
private deleteCommand(): Command {
|
||||
return new Command("delete")
|
||||
.argument("<id>", "The id of the Send to delete.")
|
||||
.description("delete a Send")
|
||||
.action(async (id: string) => {
|
||||
await this.exitIfLocked();
|
||||
const cmd = new SendDeleteCommand(this.main.sendService, this.main.sendApiService);
|
||||
@ -289,12 +274,10 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private removePasswordCommand(): program.Command {
|
||||
return new program.Command("remove-password")
|
||||
.arguments("<id>")
|
||||
.description("removes the saved password from a Send.", {
|
||||
id: "The id of the Send to alter.",
|
||||
})
|
||||
private removePasswordCommand(): Command {
|
||||
return new Command("remove-password")
|
||||
.argument("<id>", "The id of the Send to alter.")
|
||||
.description("removes the saved password from a Send.")
|
||||
.action(async (id: string) => {
|
||||
await this.exitIfLocked();
|
||||
const cmd = new SendRemovePasswordCommand(
|
||||
@ -307,7 +290,7 @@ export class SendProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private makeSendJson(data: string, options: program.OptionValues) {
|
||||
private makeSendJson(data: string, options: OptionValues) {
|
||||
let sendFile = null;
|
||||
let sendText = null;
|
||||
let name = Utils.newGuid();
|
||||
@ -336,7 +319,7 @@ export class SendProgram extends Program {
|
||||
return Buffer.from(JSON.stringify(template), "utf8").toString("base64");
|
||||
}
|
||||
|
||||
private async runCreate(encodedJson: string, options: program.OptionValues) {
|
||||
private async runCreate(encodedJson: string, options: OptionValues) {
|
||||
await this.exitIfLocked();
|
||||
const cmd = new SendCreateCommand(
|
||||
this.main.sendService,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as program from "commander";
|
||||
import { program, Command } from "commander";
|
||||
|
||||
import { ConfirmCommand } from "./admin-console/commands/confirm.command";
|
||||
import { ShareCommand } from "./admin-console/commands/share.command";
|
||||
@ -54,7 +54,7 @@ export class VaultProgram extends Program {
|
||||
return success;
|
||||
}
|
||||
|
||||
private listCommand(): program.Command {
|
||||
private listCommand(): Command {
|
||||
const listObjects = [
|
||||
"items",
|
||||
"folders",
|
||||
@ -64,11 +64,9 @@ export class VaultProgram extends Program {
|
||||
"organizations",
|
||||
];
|
||||
|
||||
return new program.Command("list")
|
||||
.arguments("<object>")
|
||||
.description("List an array of objects from the vault.", {
|
||||
object: "Valid objects are: " + listObjects.join(", "),
|
||||
})
|
||||
return new Command("list")
|
||||
.argument("<object>", "Valid objects are: " + listObjects.join(", "))
|
||||
.description("List an array of objects from the vault.")
|
||||
.option("--search <search>", "Perform a search on the listed objects.")
|
||||
.option("--url <url>", "Filter items of type login with a url-match search.")
|
||||
.option("--folderid <folderid>", "Filter items by folder id.")
|
||||
@ -125,7 +123,7 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private getCommand(): program.Command {
|
||||
private getCommand(): Command {
|
||||
const getObjects = [
|
||||
"item",
|
||||
"username",
|
||||
@ -143,12 +141,10 @@ export class VaultProgram extends Program {
|
||||
"fingerprint",
|
||||
"send",
|
||||
];
|
||||
return new program.Command("get")
|
||||
.arguments("<object> <id>")
|
||||
.description("Get an object from the vault.", {
|
||||
object: "Valid objects are: " + getObjects.join(", "),
|
||||
id: "Search term or object's globally unique `id`.",
|
||||
})
|
||||
return new Command("get")
|
||||
.argument("<object>", "Valid objects are: " + getObjects.join(", "))
|
||||
.argument("<id>", "Search term or object's globally unique `id`.")
|
||||
.description("Get an object from the vault.")
|
||||
.option("--itemid <itemid>", "Attachment's item id.")
|
||||
.option("--output <output>", "Output directory or filename for attachment.")
|
||||
.option("--organizationid <organizationid>", "Organization id for an organization object.")
|
||||
@ -200,12 +196,13 @@ export class VaultProgram extends Program {
|
||||
|
||||
private createCommand() {
|
||||
const createObjects = ["item", "attachment", "folder", "org-collection"];
|
||||
return new program.Command("create")
|
||||
.arguments("<object> [encodedJson]")
|
||||
.description("Create an object in the vault.", {
|
||||
object: "Valid objects are: " + createObjects.join(", "),
|
||||
encodedJson: "Encoded json of the object to create. Can also be piped into stdin.",
|
||||
})
|
||||
return new Command("create")
|
||||
.argument("<object>", "Valid objects are: " + createObjects.join(", "))
|
||||
.argument(
|
||||
"[encodedJson]",
|
||||
"Encoded json of the object to create. Can also be piped into stdin.",
|
||||
)
|
||||
.description("Create an object in the vault.")
|
||||
.option("--file <file>", "Path to file for attachment.")
|
||||
.option("--itemid <itemid>", "Attachment's item id.")
|
||||
.option("--organizationid <organizationid>", "Organization id for an organization object.")
|
||||
@ -239,15 +236,16 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private editCommand(): program.Command {
|
||||
private editCommand(): Command {
|
||||
const editObjects = ["item", "item-collections", "folder", "org-collection"];
|
||||
return new program.Command("edit")
|
||||
.arguments("<object> <id> [encodedJson]")
|
||||
.description("Edit an object from the vault.", {
|
||||
object: "Valid objects are: " + editObjects.join(", "),
|
||||
id: "Object's globally unique `id`.",
|
||||
encodedJson: "Encoded json of the object to create. Can also be piped into stdin.",
|
||||
})
|
||||
return new Command("edit")
|
||||
.argument("<object>", "Valid objects are: " + editObjects.join(", "))
|
||||
.argument("<id>", "Object's globally unique `id`.")
|
||||
.argument(
|
||||
"[encodedJson]",
|
||||
"Encoded json of the object to create. Can also be piped into stdin.",
|
||||
)
|
||||
.description("Edit an object from the vault.")
|
||||
.option("--organizationid <organizationid>", "Organization id for an organization object.")
|
||||
.on("--help", () => {
|
||||
writeLn("\n Examples:");
|
||||
@ -283,14 +281,12 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private deleteCommand(): program.Command {
|
||||
private deleteCommand(): Command {
|
||||
const deleteObjects = ["item", "attachment", "folder", "org-collection"];
|
||||
return new program.Command("delete")
|
||||
.arguments("<object> <id>")
|
||||
.description("Delete an object from the vault.", {
|
||||
object: "Valid objects are: " + deleteObjects.join(", "),
|
||||
id: "Object's globally unique `id`.",
|
||||
})
|
||||
return new Command("delete")
|
||||
.argument("<object>", "Valid objects are: " + deleteObjects.join(", "))
|
||||
.argument("<id>", "Object's globally unique `id`.")
|
||||
.description("Delete an object from the vault.")
|
||||
.option("--itemid <itemid>", "Attachment's item id.")
|
||||
.option("--organizationid <organizationid>", "Organization id for an organization object.")
|
||||
.option(
|
||||
@ -326,14 +322,12 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private restoreCommand(): program.Command {
|
||||
private restoreCommand(): Command {
|
||||
const restoreObjects = ["item"];
|
||||
return new program.Command("restore")
|
||||
.arguments("<object> <id>")
|
||||
.description("Restores an object from the trash.", {
|
||||
object: "Valid objects are: " + restoreObjects.join(", "),
|
||||
id: "Object's globally unique `id`.",
|
||||
})
|
||||
return new Command("restore")
|
||||
.argument("<object>", "Valid objects are: " + restoreObjects.join(", "))
|
||||
.argument("<id>", "Object's globally unique `id`.")
|
||||
.description("Restores an object from the trash.")
|
||||
.on("--help", () => {
|
||||
writeLn("\n Examples:");
|
||||
writeLn("");
|
||||
@ -352,14 +346,15 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private shareCommand(commandName: string, deprecated: boolean): program.Command {
|
||||
return new program.Command(commandName)
|
||||
.arguments("<id> <organizationId> [encodedJson]")
|
||||
.description((deprecated ? "--DEPRECATED-- " : "") + "Move an item to an organization.", {
|
||||
id: "Object's globally unique `id`.",
|
||||
organizationId: "Organization's globally unique `id`.",
|
||||
encodedJson: "Encoded json of an array of collection ids. Can also be piped into stdin.",
|
||||
})
|
||||
private shareCommand(commandName: string, deprecated: boolean): Command {
|
||||
return new Command(commandName)
|
||||
.argument("<id>", "Object's globally unique `id`.")
|
||||
.argument("<organizationId>", "Organization's globally unique `id`.")
|
||||
.argument(
|
||||
"[encodedJson]",
|
||||
"Encoded json of an array of collection ids. Can also be piped into stdin.",
|
||||
)
|
||||
.description((deprecated ? "--DEPRECATED-- " : "") + "Move an item to an organization.")
|
||||
.on("--help", () => {
|
||||
writeLn("\n Examples:");
|
||||
writeLn("");
|
||||
@ -389,14 +384,12 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private confirmCommand(): program.Command {
|
||||
private confirmCommand(): Command {
|
||||
const confirmObjects = ["org-member"];
|
||||
return new program.Command("confirm")
|
||||
.arguments("<object> <id>")
|
||||
.description("Confirm an object to the organization.", {
|
||||
object: "Valid objects are: " + confirmObjects.join(", "),
|
||||
id: "Object's globally unique `id`.",
|
||||
})
|
||||
return new Command("confirm")
|
||||
.argument("<object>", "Valid objects are: " + confirmObjects.join(", "))
|
||||
.argument("<id>", "Object's globally unique `id`.")
|
||||
.description("Confirm an object to the organization.")
|
||||
.option("--organizationid <organizationid>", "Organization id for an organization object.")
|
||||
.on("--help", () => {
|
||||
writeLn("\n Examples:");
|
||||
@ -423,13 +416,11 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private importCommand(): program.Command {
|
||||
return new program.Command("import")
|
||||
.arguments("[format] [input]")
|
||||
.description("Import vault data from a file.", {
|
||||
format: "The format of [input]",
|
||||
input: "Filepath to data to import",
|
||||
})
|
||||
private importCommand(): Command {
|
||||
return new Command("import")
|
||||
.argument("[format]", "The format of [input]")
|
||||
.argument("[input]", "Filepath to data to import")
|
||||
.description("Import vault data from a file.")
|
||||
.option("--formats", "List formats")
|
||||
.option("--organizationid <organizationid>", "ID of the organization to import to.")
|
||||
.on("--help", () => {
|
||||
@ -454,9 +445,9 @@ export class VaultProgram extends Program {
|
||||
});
|
||||
}
|
||||
|
||||
private exportCommand(): program.Command {
|
||||
return new program.Command("export")
|
||||
.description("Export vault data to a CSV or JSON file.", {})
|
||||
private exportCommand(): Command {
|
||||
return new Command("export")
|
||||
.description("Export vault data to a CSV or JSON file.")
|
||||
.option("--output <output>", "Output directory or filename.")
|
||||
.option("--format <format>", "Export file format.")
|
||||
.option(
|
||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -36,7 +36,7 @@
|
||||
"braintree-web-drop-in": "1.42.0",
|
||||
"bufferutil": "4.0.8",
|
||||
"chalk": "4.1.2",
|
||||
"commander": "7.2.0",
|
||||
"commander": "11.1.0",
|
||||
"core-js": "3.34.0",
|
||||
"duo_web_sdk": "github:duosecurity/duo_web_sdk",
|
||||
"form-data": "4.0.0",
|
||||
@ -207,7 +207,7 @@
|
||||
"big-integer": "1.6.51",
|
||||
"browser-hrtime": "1.1.8",
|
||||
"chalk": "4.1.2",
|
||||
"commander": "7.2.0",
|
||||
"commander": "11.1.0",
|
||||
"form-data": "4.0.0",
|
||||
"https-proxy-agent": "7.0.2",
|
||||
"inquirer": "8.2.6",
|
||||
@ -5075,15 +5075,6 @@
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@compodoc/compodoc/node_modules/commander": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/@compodoc/compodoc/node_modules/cosmiconfig": {
|
||||
"version": "8.3.6",
|
||||
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz",
|
||||
@ -17429,11 +17420,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
||||
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/common-tags": {
|
||||
@ -27342,15 +27333,6 @@
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/lint-staged/node_modules/commander": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
|
||||
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/lint-staged/node_modules/execa": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",
|
||||
|
@ -171,7 +171,7 @@
|
||||
"braintree-web-drop-in": "1.42.0",
|
||||
"bufferutil": "4.0.8",
|
||||
"chalk": "4.1.2",
|
||||
"commander": "7.2.0",
|
||||
"commander": "11.1.0",
|
||||
"core-js": "3.34.0",
|
||||
"duo_web_sdk": "github:duosecurity/duo_web_sdk",
|
||||
"form-data": "4.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user