Skip to content

Commit 1304112

Browse files
authored
Added alias support and alias appdistribution:groups:* (#7962)
* Added alias support and alias appgistribution:groups:* * fix shrinkwrap * Make groups command accessible as a node module * remove repeated entry so help test is not repetitive * Swap primary and alias * rename files, better approach for module
1 parent 8e9af08 commit 1304112

File tree

10 files changed

+36
-16
lines changed

10 files changed

+36
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
- Moved firebase-tools-ui server.js logic to fireabse-tools to run it in-memory. (#7897)
33
- Updates `superstatic` to `9.1.0` (#7929).
44
- Added the appdistribution:group:list and appdistribution:testers:list commands.
5+
- Aliased `appdistribution:group:*` commands to `appdistribution:groups:*`.
56
- 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)

npm-shrinkwrap.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"cjson": "^0.3.1",
111111
"cli-table": "0.3.11",
112112
"colorette": "^2.0.19",
113-
"commander": "^4.0.1",
113+
"commander": "^5.1.0",
114114
"configstore": "^5.0.1",
115115
"cors": "^2.8.5",
116116
"cross-env": "^5.1.3",

src/bin/firebase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const updateNotifier = updateNotifierPkg({ pkg });
1818
import { marked } from "marked";
1919
marked.use(markedTerminal() as any);
2020

21-
import { Command } from "commander";
21+
import { CommanderStatic } from "commander";
2222
import { join } from "node:path";
2323
import { SPLAT } from "triple-beam";
2424
import { stripVTControlCharacters } from "node:util";
@@ -34,7 +34,7 @@ import * as utils from "../utils";
3434
import * as winston from "winston";
3535

3636
let args = process.argv.slice(2);
37-
let cmd: Command;
37+
let cmd: CommanderStatic;
3838

3939
function findAvailableLogFile(): string {
4040
const candidates = ["firebase-debug.log"];

src/command.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe("Command", () => {
2424
},
2525
["foo", "bar"],
2626
);
27+
command.alias("example2");
2728
command.help("here's how!");
2829
command.action(() => {
2930
// do nothing

src/command.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Command {
3737
private descriptionText = "";
3838
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3939
private options: any[][] = [];
40+
private aliases: string[] = [];
4041
private actionFn: ActionFunction = (): void => {
4142
// noop by default, unless overwritten by `.action(fn)`.
4243
};
@@ -62,6 +63,16 @@ export class Command {
6263
return this;
6364
}
6465

66+
/**
67+
* Sets an alias for a command.
68+
* @param aliases an alternativre name for the command. Users will be able to call the command via this name.
69+
* @return the command, for chaining.
70+
*/
71+
alias(alias: string): Command {
72+
this.aliases.push(alias);
73+
return this;
74+
}
75+
6576
/**
6677
* Sets any options for the command.
6778
*
@@ -138,6 +149,9 @@ export class Command {
138149
if (this.descriptionText) {
139150
cmd.description(this.descriptionText);
140151
}
152+
if (this.aliases) {
153+
cmd.aliases(this.aliases);
154+
}
141155
this.options.forEach((args) => {
142156
const flags = args.shift();
143157
cmd.option(flags, ...args);

src/commands/appdistribution-group-create.ts renamed to src/commands/appdistribution-groups-create.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { requireAuth } from "../requireAuth";
44
import { AppDistributionClient } from "../appdistribution/client";
55
import { getProjectName } from "../appdistribution/options-parser-util";
66

7-
export const command = new Command("appdistribution:group:create <displayName> [alias]")
7+
export const command = new Command("appdistribution:groups:create <displayName> [alias]")
88
.description("create group in project")
9+
.alias("appdistribution:group:create")
910
.before(requireAuth)
1011
.action(async (displayName: string, alias?: string, options?: any) => {
1112
const projectName = await getProjectName(options);

src/commands/appdistribution-group-delete.ts renamed to src/commands/appdistribution-groups-delete.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { FirebaseError } from "../error";
55
import { AppDistributionClient } from "../appdistribution/client";
66
import { getProjectName } from "../appdistribution/options-parser-util";
77

8-
export const command = new Command("appdistribution:group:delete <alias>")
8+
export const command = new Command("appdistribution:groups:delete <alias>")
99
.description("delete group from a project")
10+
.alias("appdistribution:group:delete")
1011
.before(requireAuth)
1112
.action(async (alias: string, options: any) => {
1213
const projectName = await getProjectName(options);

src/commands/appdistribution-group-list.ts renamed to src/commands/appdistribution-groups-list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import * as utils from "../utils";
1111

1212
const Table = require("cli-table");
1313

14-
export const command = new Command("appdistribution:group:list")
14+
export const command = new Command("appdistribution:groups:list")
1515
.description("list groups in project")
16+
.alias("appdistribution:group:list")
1617
.before(requireAuth)
1718
.action(async (options?: Options): Promise<ListGroupsResponse> => {
1819
const projectName = await getProjectName(options);

src/commands/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export function load(client: any): any {
2626
client.appdistribution.testers.add = loadCommand("appdistribution-testers-add");
2727
client.appdistribution.testers.delete = loadCommand("appdistribution-testers-remove");
2828
client.appdistribution.group = {};
29-
client.appdistribution.group.list = loadCommand("appdistribution-group-list");
30-
client.appdistribution.group.create = loadCommand("appdistribution-group-create");
31-
client.appdistribution.group.delete = loadCommand("appdistribution-group-delete");
29+
client.appdistribution.group.list = loadCommand("appdistribution-groups-list");
30+
client.appdistribution.group.create = loadCommand("appdistribution-groups-create");
31+
client.appdistribution.group.delete = loadCommand("appdistribution-groups-delete");
32+
client.appdistribution.groups = client.appdistribution.group;
3233
client.apps = {};
3334
client.apps.create = loadCommand("apps-create");
3435
client.apps.list = loadCommand("apps-list");

0 commit comments

Comments
 (0)