Няма описание
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.

database-rules-list.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const logger_1 = require("../logger");
  6. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  7. const requirePermissions_1 = require("../requirePermissions");
  8. const metadata = require("../database/metadata");
  9. const types_1 = require("../emulator/types");
  10. const commandUtils_1 = require("../emulator/commandUtils");
  11. exports.command = new command_1.Command("database:rules:list")
  12. .description("list realtime database rulesets")
  13. .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, uses default database instance)")
  14. .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.get"])
  15. .before(requireDatabaseInstance_1.requireDatabaseInstance)
  16. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
  17. .action(async (options) => {
  18. const labeled = await metadata.getRulesetLabels(options.instance);
  19. const rulesets = await metadata.listAllRulesets(options.instance);
  20. for (const ruleset of rulesets) {
  21. const labels = [];
  22. if (ruleset.id === labeled.stable) {
  23. labels.push("stable");
  24. }
  25. if (ruleset.id === labeled.canary) {
  26. labels.push("canary");
  27. }
  28. logger_1.logger.info(`${ruleset.id} ${ruleset.createdAt} ${labels.join(",")}`);
  29. }
  30. logger_1.logger.info("Labels:");
  31. logger_1.logger.info(` stable: ${labeled.stable}`);
  32. if (labeled.canary) {
  33. logger_1.logger.info(` canary: ${labeled.canary}`);
  34. }
  35. return { rulesets, labeled };
  36. });