diff --git a/apps/cli/package.json b/apps/cli/package.json index f8cd858189..b5edecfe3c 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -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", diff --git a/apps/cli/src/auth/commands/login.command.ts b/apps/cli/src/auth/commands/login.command.ts index 480127f1ff..468d03b0e3 100644 --- a/apps/cli/src/auth/commands/login.command.ts +++ b/apps/cli/src/auth/commands/login.command.ts @@ -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, ) {} - async run(email: string, password: string, options: program.OptionValues) { + async run(email: string, password: string, options: OptionValues) { this.options = options; this.email = email; diff --git a/apps/cli/src/bw.ts b/apps/cli/src/bw.ts index 1264ab949b..250aa46169 100644 --- a/apps/cli/src/bw.ts +++ b/apps/cli/src/bw.ts @@ -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"; diff --git a/apps/cli/src/commands/completion.command.ts b/apps/cli/src/commands/completion.command.ts index b0d3481921..49dc3e9a13 100644 --- a/apps/cli/src/commands/completion.command.ts +++ b/apps/cli/src/commands/completion.command.ts @@ -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"), ); } diff --git a/apps/cli/src/commands/config.command.ts b/apps/cli/src/commands/config.command.ts index 1665bae148..209f75a836 100644 --- a/apps/cli/src/commands/config.command.ts +++ b/apps/cli/src/commands/config.command.ts @@ -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 { + async run(setting: string, value: string, options: OptionValues): Promise { setting = setting.toLowerCase(); switch (setting) { case "server": @@ -19,7 +19,7 @@ export class ConfigCommand { } } - private async getOrSetServer(url: string, options: program.OptionValues): Promise { + private async getOrSetServer(url: string, options: OptionValues): Promise { if ( (url == null || url.trim() === "") && !options.webVault && diff --git a/apps/cli/src/commands/serve.command.ts b/apps/cli/src/commands/serve.command.ts index 588ff202ec..51cb285c5f 100644 --- a/apps/cli/src/commands/serve.command.ts +++ b/apps/cli/src/commands/serve.command.ts @@ -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"; diff --git a/apps/cli/src/program.ts b/apps/cli/src/program.ts index 64fe209258..dec8edd311 100644 --- a/apps/cli/src/program.ts +++ b/apps/cli/src/program.ts @@ -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); diff --git a/apps/cli/src/tools/export.command.ts b/apps/cli/src/tools/export.command.ts index a2ee8dafac..e88449d238 100644 --- a/apps/cli/src/tools/export.command.ts +++ b/apps/cli/src/tools/export.command.ts @@ -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 { + async run(options: OptionValues): Promise { 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 { try { diff --git a/apps/cli/src/tools/import.command.ts b/apps/cli/src/tools/import.command.ts index bd5a72803b..b24274c720 100644 --- a/apps/cli/src/tools/import.command.ts +++ b/apps/cli/src/tools/import.command.ts @@ -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 { + async run(format: ImportType, filepath: string, options: OptionValues): Promise { const organizationId = options.organizationid; if (organizationId != null) { const organization = await this.organizationService.getFromState(organizationId); diff --git a/apps/cli/src/tools/send/commands/get.command.ts b/apps/cli/src/tools/send/commands/get.command.ts index f6e61bab7b..9e80c350b7 100644 --- a/apps/cli/src/tools/send/commands/get.command.ts +++ b/apps/cli/src/tools/send/commands/get.command.ts @@ -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."); diff --git a/apps/cli/src/tools/send/commands/receive.command.ts b/apps/cli/src/tools/send/commands/receive.command.ts index 9e7d9c7e3c..8dfbf01fa9 100644 --- a/apps/cli/src/tools/send/commands/receive.command.ts +++ b/apps/cli/src/tools/send/commands/receive.command.ts @@ -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 { + async run(url: string, options: OptionValues): Promise { this.canInteract = process.env.BW_NOINTERACTION !== "true"; let urlObject: URL; diff --git a/apps/cli/src/tools/send/send.program.ts b/apps/cli/src/tools/send/send.program.ts index 59f0b7ecdb..2bb3dc225b 100644 --- a/apps/cli/src/tools/send/send.program.ts +++ b/apps/cli/src/tools/send/send.program.ts @@ -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("") + private sendCommand(): Command { + return new Command("send") + .argument("", "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 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("") .description("Access a Bitwarden Send from a url") .option("--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("") - .description("Get json templates for send objects", { - object: "Valid objects are: send.text, send.file", - }) + private templateCommand(): Command { + return new Command("template") + .argument("", "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("") .description("Get Sends owned by you.") .option("--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 ", "file to Send. Can also be specified in parent's JSON.") .option("--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 ", "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("") - .description("delete a Send", { - id: "The id of the Send to delete.", - }) + private deleteCommand(): Command { + return new Command("delete") + .argument("", "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("") - .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("", "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, diff --git a/apps/cli/src/vault.program.ts b/apps/cli/src/vault.program.ts index d27aba8829..d1651f934a 100644 --- a/apps/cli/src/vault.program.ts +++ b/apps/cli/src/vault.program.ts @@ -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("") - .description("List an array of objects from the vault.", { - object: "Valid objects are: " + listObjects.join(", "), - }) + return new Command("list") + .argument("", "Valid objects are: " + listObjects.join(", ")) + .description("List an array of objects from the vault.") .option("--search ", "Perform a search on the listed objects.") .option("--url ", "Filter items of type login with a url-match search.") .option("--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(" ") - .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("", "Valid objects are: " + getObjects.join(", ")) + .argument("", "Search term or object's globally unique `id`.") + .description("Get an object from the vault.") .option("--itemid ", "Attachment's item id.") .option("--output ", "Output directory or filename for attachment.") .option("--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(" [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("", "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 ", "Path to file for attachment.") .option("--itemid ", "Attachment's item id.") .option("--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(" [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("", "Valid objects are: " + editObjects.join(", ")) + .argument("", "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 ", "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(" ") - .description("Delete an object from the vault.", { - object: "Valid objects are: " + deleteObjects.join(", "), - id: "Object's globally unique `id`.", - }) + return new Command("delete") + .argument("", "Valid objects are: " + deleteObjects.join(", ")) + .argument("", "Object's globally unique `id`.") + .description("Delete an object from the vault.") .option("--itemid ", "Attachment's item id.") .option("--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(" ") - .description("Restores an object from the trash.", { - object: "Valid objects are: " + restoreObjects.join(", "), - id: "Object's globally unique `id`.", - }) + return new Command("restore") + .argument("", "Valid objects are: " + restoreObjects.join(", ")) + .argument("", "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(" [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("", "Object's globally unique `id`.") + .argument("", "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(" ") - .description("Confirm an object to the organization.", { - object: "Valid objects are: " + confirmObjects.join(", "), - id: "Object's globally unique `id`.", - }) + return new Command("confirm") + .argument("", "Valid objects are: " + confirmObjects.join(", ")) + .argument("", "Object's globally unique `id`.") + .description("Confirm an object to the organization.") .option("--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 ", "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 directory or filename.") .option("--format ", "Export file format.") .option( diff --git a/package-lock.json b/package-lock.json index de362235af..36b08a0d02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 49237f03cc..b314c85838 100644 --- a/package.json +++ b/package.json @@ -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",