No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions-list.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const error_1 = require("../error");
  6. const projectUtils_1 = require("../projectUtils");
  7. const requirePermissions_1 = require("../requirePermissions");
  8. const backend = require("../deploy/functions/backend");
  9. const logger_1 = require("../logger");
  10. const Table = require("cli-table");
  11. exports.command = new command_1.Command("functions:list")
  12. .description("list all deployed functions in your Firebase project")
  13. .before(requirePermissions_1.requirePermissions, ["cloudfunctions.functions.list"])
  14. .action(async (options) => {
  15. try {
  16. const context = {
  17. projectId: (0, projectUtils_1.needProjectId)(options),
  18. };
  19. const existing = await backend.existingBackend(context);
  20. const endpointsList = backend.allEndpoints(existing).sort(backend.compareFunctions);
  21. const table = new Table({
  22. head: ["Function", "Version", "Trigger", "Location", "Memory", "Runtime"],
  23. style: { head: ["yellow"] },
  24. });
  25. for (const endpoint of endpointsList) {
  26. const trigger = backend.endpointTriggerType(endpoint);
  27. const availableMemoryMb = endpoint.availableMemoryMb || "---";
  28. const entry = [
  29. endpoint.id,
  30. endpoint.platform === "gcfv2" ? "v2" : "v1",
  31. trigger,
  32. endpoint.region,
  33. availableMemoryMb,
  34. endpoint.runtime,
  35. ];
  36. table.push(entry);
  37. }
  38. logger_1.logger.info(table.toString());
  39. return endpointsList;
  40. }
  41. catch (err) {
  42. throw new error_1.FirebaseError("Failed to list functions", {
  43. exit: 1,
  44. original: err,
  45. });
  46. }
  47. });