暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const open = require("open");
  6. const error_1 = require("../error");
  7. const api = require("../api");
  8. const command_1 = require("../command");
  9. const logger_1 = require("../logger");
  10. const prompt_1 = require("../prompt");
  11. const requirePermissions_1 = require("../requirePermissions");
  12. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  13. const utils = require("../utils");
  14. const requireHostingSite_1 = require("../requireHostingSite");
  15. const LINKS = [
  16. { name: "Analytics", arg: "analytics", consolePath: "/analytics" },
  17. { name: "Authentication: Providers", arg: "auth", consolePath: "/authentication/providers" },
  18. { name: "Authentication: Users", arg: "auth:users", consolePath: "/authentication/users" },
  19. { name: "Crash Reporting", arg: "crash", consolePath: "/monitoring" },
  20. { name: "Database: Data", arg: "database", consolePath: "/database/data" },
  21. { name: "Database: Rules", arg: "database:rules", consolePath: "/database/rules" },
  22. { name: "Docs", arg: "docs", url: "https://firebase.google.com/docs" },
  23. { name: "Dynamic Links", arg: "links", consolePath: "/durablelinks" },
  24. { name: "Firestore: Data", arg: "firestore", consolePath: "/firestore/data" },
  25. { name: "Firestore: Rules", arg: "firestore:rules", consolePath: "/firestore/rules" },
  26. { name: "Firestore: Indexes", arg: "firestore:indexes", consolePath: "/firestore/indexes" },
  27. { name: "Firestore: Usage", arg: "firestore:usage", consolePath: "/firestore/usage" },
  28. { name: "Functions", arg: "functions", consolePath: "/functions/list" },
  29. { name: "Functions Log", arg: "functions:log" },
  30. { name: "Hosting: Deployed Site", arg: "hosting:site" },
  31. { name: "Hosting", arg: "hosting", consolePath: "/hosting/main" },
  32. { name: "Notifications", arg: "notifications", consolePath: "/notification" },
  33. { name: "Project Dashboard", arg: "dashboard", consolePath: "/overview" },
  34. { name: "Project Settings", arg: "settings", consolePath: "/settings/general" },
  35. {
  36. name: "Remote Config: Conditions",
  37. arg: "config:conditions",
  38. consolePath: "/config/conditions",
  39. },
  40. { name: "Remote Config", arg: "config", consolePath: "/config" },
  41. { name: "Storage: Files", arg: "storage", consolePath: "/storage/files" },
  42. { name: "Storage: Rules", arg: "storage:rules", consolePath: "/storage/rules" },
  43. { name: "Test Lab", arg: "testlab", consolePath: "/testlab/histories/" },
  44. ];
  45. const CHOICES = LINKS.map((l) => l.name);
  46. exports.command = new command_1.Command("open [link]")
  47. .description("quickly open a browser to relevant project resources")
  48. .before(requirePermissions_1.requirePermissions)
  49. .before(requireDatabaseInstance_1.requireDatabaseInstance)
  50. .before(requireHostingSite_1.requireHostingSite)
  51. .action(async (linkName, options) => {
  52. let link = LINKS.find((l) => l.arg === linkName);
  53. if (linkName && !link) {
  54. throw new error_1.FirebaseError("Unrecognized link name. Valid links are:\n\n" + LINKS.map((l) => l.arg).join("\n"));
  55. }
  56. if (!link) {
  57. const name = await (0, prompt_1.promptOnce)({
  58. type: "list",
  59. message: "What link would you like to open?",
  60. choices: CHOICES,
  61. });
  62. link = LINKS.find((l) => l.name === name);
  63. }
  64. if (!link) {
  65. throw new error_1.FirebaseError("Unrecognized link name. Valid links are:\n\n" + LINKS.map((l) => l.arg).join("\n"));
  66. }
  67. let url;
  68. if (link.consolePath) {
  69. url = utils.consoleUrl(options.project, link.consolePath);
  70. }
  71. else if (link.url) {
  72. url = link.url;
  73. }
  74. else if (link.arg === "hosting:site") {
  75. url = utils.addSubdomain(api.hostingOrigin, options.site);
  76. }
  77. else if (link.arg === "functions:log") {
  78. url = `https://console.developers.google.com/logs/viewer?resource=cloudfunctions.googleapis.com&project=${options.project}`;
  79. }
  80. else {
  81. throw new error_1.FirebaseError(`Unable to determine URL for link: ${link}`);
  82. }
  83. if (link.arg !== linkName) {
  84. logger_1.logger.info(`${clc.bold(clc.cyan("Tip:"))} You can also run ${clc.bold(clc.underline(`firebase open ${link.arg}`))}`);
  85. logger_1.logger.info();
  86. }
  87. logger_1.logger.info(`Opening ${clc.bold(link.name)} link in your default browser:`);
  88. logger_1.logger.info(clc.bold(clc.underline(url)));
  89. open(url);
  90. });