diff --git a/CHANGELOG.md b/CHANGELOG.md index d3be85c1f4e..b1098d73ae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,5 @@ - Moved firebase-tools-ui server.js logic to fireabse-tools to run it in-memory. (#7897) - Updates `superstatic` to `9.1.0` (#7929). - Added the appdistribution:group:list and appdistribution:testers:list commands. +- Aliased `appdistribution:group:*` commands to `appdistribution:groups:*`. - Updated the Firebase Data Connect local toolkit to v1.7.2, which includes bug fixes for `@auth` expressions that reference the `auth` variable, `Optional` arrays in Swift codegen, and updates Kotlin codegen to use fully-qualified class names everywhere. (#7968) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 1dfe3a0f2f2..69eb36fa021 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -21,7 +21,7 @@ "cjson": "^0.3.1", "cli-table": "0.3.11", "colorette": "^2.0.19", - "commander": "^4.0.1", + "commander": "^5.1.0", "configstore": "^5.0.1", "cors": "^2.8.5", "cross-env": "^5.1.3", @@ -7190,9 +7190,9 @@ } }, "node_modules/commander": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.0.1.tgz", - "integrity": "sha512-IPF4ouhCP+qdlcmCedhxX4xiGBPyigb8v5NeUp+0LyhwLgxMqyp3S0vl7TAPfS/hiP7FC3caI/PB9lTmP8r1NA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "engines": { "node": ">= 6" } @@ -26420,9 +26420,9 @@ "dev": true }, "commander": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.0.1.tgz", - "integrity": "sha512-IPF4ouhCP+qdlcmCedhxX4xiGBPyigb8v5NeUp+0LyhwLgxMqyp3S0vl7TAPfS/hiP7FC3caI/PB9lTmP8r1NA==" + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" }, "comment-parser": { "version": "1.4.1", diff --git a/package.json b/package.json index e8844ccf3a1..022c9906e4d 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "cjson": "^0.3.1", "cli-table": "0.3.11", "colorette": "^2.0.19", - "commander": "^4.0.1", + "commander": "^5.1.0", "configstore": "^5.0.1", "cors": "^2.8.5", "cross-env": "^5.1.3", diff --git a/src/bin/firebase.ts b/src/bin/firebase.ts index 205341bb084..631eb54ee73 100755 --- a/src/bin/firebase.ts +++ b/src/bin/firebase.ts @@ -18,7 +18,7 @@ const updateNotifier = updateNotifierPkg({ pkg }); import { marked } from "marked"; marked.use(markedTerminal() as any); -import { Command } from "commander"; +import { CommanderStatic } from "commander"; import { join } from "node:path"; import { SPLAT } from "triple-beam"; import { stripVTControlCharacters } from "node:util"; @@ -34,7 +34,7 @@ import * as utils from "../utils"; import * as winston from "winston"; let args = process.argv.slice(2); -let cmd: Command; +let cmd: CommanderStatic; function findAvailableLogFile(): string { const candidates = ["firebase-debug.log"]; diff --git a/src/command.spec.ts b/src/command.spec.ts index 5cb2054c64e..8ba2d7b8d08 100644 --- a/src/command.spec.ts +++ b/src/command.spec.ts @@ -24,6 +24,7 @@ describe("Command", () => { }, ["foo", "bar"], ); + command.alias("example2"); command.help("here's how!"); command.action(() => { // do nothing diff --git a/src/command.ts b/src/command.ts index 918d9072401..68b045e5f3e 100644 --- a/src/command.ts +++ b/src/command.ts @@ -37,6 +37,7 @@ export class Command { private descriptionText = ""; // eslint-disable-next-line @typescript-eslint/no-explicit-any private options: any[][] = []; + private aliases: string[] = []; private actionFn: ActionFunction = (): void => { // noop by default, unless overwritten by `.action(fn)`. }; @@ -62,6 +63,16 @@ export class Command { return this; } + /** + * Sets an alias for a command. + * @param aliases an alternativre name for the command. Users will be able to call the command via this name. + * @return the command, for chaining. + */ + alias(alias: string): Command { + this.aliases.push(alias); + return this; + } + /** * Sets any options for the command. * @@ -138,6 +149,9 @@ export class Command { if (this.descriptionText) { cmd.description(this.descriptionText); } + if (this.aliases) { + cmd.aliases(this.aliases); + } this.options.forEach((args) => { const flags = args.shift(); cmd.option(flags, ...args); diff --git a/src/commands/appdistribution-group-create.ts b/src/commands/appdistribution-groups-create.ts similarity index 85% rename from src/commands/appdistribution-group-create.ts rename to src/commands/appdistribution-groups-create.ts index 493d32af836..a12c809dd3c 100644 --- a/src/commands/appdistribution-group-create.ts +++ b/src/commands/appdistribution-groups-create.ts @@ -4,8 +4,9 @@ import { requireAuth } from "../requireAuth"; import { AppDistributionClient } from "../appdistribution/client"; import { getProjectName } from "../appdistribution/options-parser-util"; -export const command = new Command("appdistribution:group:create [alias]") +export const command = new Command("appdistribution:groups:create [alias]") .description("create group in project") + .alias("appdistribution:group:create") .before(requireAuth) .action(async (displayName: string, alias?: string, options?: any) => { const projectName = await getProjectName(options); diff --git a/src/commands/appdistribution-group-delete.ts b/src/commands/appdistribution-groups-delete.ts similarity index 87% rename from src/commands/appdistribution-group-delete.ts rename to src/commands/appdistribution-groups-delete.ts index 16651d711f8..5ec20d4afd5 100644 --- a/src/commands/appdistribution-group-delete.ts +++ b/src/commands/appdistribution-groups-delete.ts @@ -5,8 +5,9 @@ import { FirebaseError } from "../error"; import { AppDistributionClient } from "../appdistribution/client"; import { getProjectName } from "../appdistribution/options-parser-util"; -export const command = new Command("appdistribution:group:delete ") +export const command = new Command("appdistribution:groups:delete ") .description("delete group from a project") + .alias("appdistribution:group:delete") .before(requireAuth) .action(async (alias: string, options: any) => { const projectName = await getProjectName(options); diff --git a/src/commands/appdistribution-group-list.ts b/src/commands/appdistribution-groups-list.ts similarity index 94% rename from src/commands/appdistribution-group-list.ts rename to src/commands/appdistribution-groups-list.ts index 864dd3e1248..3637cff986d 100644 --- a/src/commands/appdistribution-group-list.ts +++ b/src/commands/appdistribution-groups-list.ts @@ -11,8 +11,9 @@ import * as utils from "../utils"; const Table = require("cli-table"); -export const command = new Command("appdistribution:group:list") +export const command = new Command("appdistribution:groups:list") .description("list groups in project") + .alias("appdistribution:group:list") .before(requireAuth) .action(async (options?: Options): Promise => { const projectName = await getProjectName(options); diff --git a/src/commands/index.ts b/src/commands/index.ts index 3829ce3cd87..7ce27a3313e 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -26,9 +26,10 @@ export function load(client: any): any { client.appdistribution.testers.add = loadCommand("appdistribution-testers-add"); client.appdistribution.testers.delete = loadCommand("appdistribution-testers-remove"); client.appdistribution.group = {}; - client.appdistribution.group.list = loadCommand("appdistribution-group-list"); - client.appdistribution.group.create = loadCommand("appdistribution-group-create"); - client.appdistribution.group.delete = loadCommand("appdistribution-group-delete"); + client.appdistribution.group.list = loadCommand("appdistribution-groups-list"); + client.appdistribution.group.create = loadCommand("appdistribution-groups-create"); + client.appdistribution.group.delete = loadCommand("appdistribution-groups-delete"); + client.appdistribution.groups = client.appdistribution.group; client.apps = {}; client.apps.create = loadCommand("apps-create"); client.apps.list = loadCommand("apps-list");