Nessuna descrizione
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.

deploy.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const _ = require("lodash");
  4. const clc = require("colorette");
  5. const error_1 = require("../../error");
  6. const indexes_1 = require("../../firestore/indexes");
  7. const logger_1 = require("../../logger");
  8. const utils = require("../../utils");
  9. const rulesDeploy_1 = require("../../rulesDeploy");
  10. async function deployRules(context) {
  11. const rulesDeploy = _.get(context, "firestore.rulesDeploy");
  12. if (!context.firestoreRules || !rulesDeploy) {
  13. return;
  14. }
  15. await rulesDeploy.createRulesets(rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE);
  16. }
  17. async function deployIndexes(context, options) {
  18. if (!context.firestoreIndexes) {
  19. return;
  20. }
  21. const indexesFileName = _.get(context, "firestore.indexes.name");
  22. const indexesSrc = _.get(context, "firestore.indexes.content");
  23. if (!indexesSrc) {
  24. logger_1.logger.debug("No Firestore indexes present.");
  25. return;
  26. }
  27. const indexes = indexesSrc.indexes;
  28. if (!indexes) {
  29. throw new error_1.FirebaseError(`Index file must contain an "indexes" property.`);
  30. }
  31. const fieldOverrides = indexesSrc.fieldOverrides || [];
  32. await new indexes_1.FirestoreIndexes().deploy(options, indexes, fieldOverrides);
  33. utils.logSuccess(`${clc.bold(clc.green("firestore:"))} deployed indexes in ${clc.bold(indexesFileName)} successfully`);
  34. }
  35. async function default_1(context, options) {
  36. await Promise.all([deployRules(context), deployIndexes(context, options)]);
  37. }
  38. exports.default = default_1;