Skip to content

Commit

Permalink
Updates permissions and command listing for 'firebase ext' command. (#…
Browse files Browse the repository at this point in the history
…1816)

* starts on fixing ext

* uses correct permissions for ext, and corrects usage of cmd

* refactors ext to use typescriptified commands

* formats

* pr fixes

* Update CHANGELOG.md

Co-Authored-By: Bryan Kendall <bkend@google.com>
  • Loading branch information
joehan and bkendall committed Nov 20, 2019
1 parent 76acde3 commit 38c5aea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Improved error handling when exporting users.
* Fixes an issue where repeated invoations cause an `EADDRINUSE` error (#1815)
* Fixes Firebase `ext` command and enables it to run without a project.
* Fixes an issue where repeated invoations cause an `EADDRINUSE` error (#1815).
52 changes: 27 additions & 25 deletions src/commands/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,43 @@ import * as clc from "cli-color";

import { Command } from "../command";
import * as getProjectId from "../getProjectId";
import { logPrefix } from "../extensions/extensionsHelper";
import { listExtensions } from "../extensions/listExtensions";
import { requirePermissions } from "../requirePermissions";
import * as logger from "../logger";
import * as utils from "../utils";
import { CommanderStatic } from "commander";

module.exports = new Command("ext")
.description(
"display information on how to use ext commands and extensions installed to your project"
)
.before(requirePermissions, ["deploymentmanager.deployments.get"])
.action((options: any) => {
const projectId = getProjectId(options);
const commands = [
"ext-configure",
"ext-info",
"ext-install",
"ext-list",
"ext-uninstall",
"ext-update",
.action(async (options: any) => {
// Print out help info for all extensions commands.
utils.logLabeledBullet(logPrefix, "list of extensions commands:");
const firebaseTools = require("../"); // eslint-disable-line @typescript-eslint/no-var-requires
const commandNames = [
"ext:install",
"ext:info",
"ext:list",
"ext:configure",
"ext:update",
"ext:uninstall",
];

_.forEach(commands, (command) => {
let cmd = require("./" + command);
if (cmd.default) {
cmd = cmd.default;
}
logger.info();
logger.info(`${clc.bold(cmd._cmd)} - ${cmd._description}`);
if (cmd._options.length > 0) {
logger.info("Option(s):");
_.forEach(cmd._options, (option) => {
logger.info(" ", option[0], " ", option[1]);
});
}
logger.info();
_.forEach(commandNames, (commandName) => {
const command: CommanderStatic = firebaseTools.getCommand(commandName);
logger.info(clc.bold("\n" + command.name()));
command.outputHelp();
});
logger.info();

return listExtensions(projectId);
// Print out a list of all extension instances on project, if called with a project.
try {
await requirePermissions(options, ["firebasemods.instances.list"]);
const projectId = getProjectId(options);
return listExtensions(projectId);
} catch (err) {
return;
}
});

0 comments on commit 38c5aea

Please sign in to comment.