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.

release.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.release = void 0;
  4. const queue_1 = require("../../throttler/queue");
  5. const tasks = require("./tasks");
  6. const planner = require("./planner");
  7. const error_1 = require("../../error");
  8. const errors_1 = require("./errors");
  9. const projectUtils_1 = require("../../projectUtils");
  10. const etags_1 = require("../../extensions/etags");
  11. async function release(context, options, payload) {
  12. var _a, _b, _c, _d;
  13. const projectId = (0, projectUtils_1.needProjectId)(options);
  14. const errorHandler = new errors_1.ErrorHandler();
  15. const deploymentQueue = new queue_1.default({
  16. retries: 5,
  17. concurrency: 5,
  18. handler: tasks.extensionsDeploymentHandler(errorHandler),
  19. });
  20. for (const creation of (_a = payload.instancesToCreate) !== null && _a !== void 0 ? _a : []) {
  21. const task = tasks.createExtensionInstanceTask(projectId, creation);
  22. void deploymentQueue.run(task);
  23. }
  24. for (const update of (_b = payload.instancesToUpdate) !== null && _b !== void 0 ? _b : []) {
  25. const task = tasks.updateExtensionInstanceTask(projectId, update);
  26. void deploymentQueue.run(task);
  27. }
  28. for (const update of (_c = payload.instancesToConfigure) !== null && _c !== void 0 ? _c : []) {
  29. const task = tasks.configureExtensionInstanceTask(projectId, update);
  30. void deploymentQueue.run(task);
  31. }
  32. for (const deletion of (_d = payload.instancesToDelete) !== null && _d !== void 0 ? _d : []) {
  33. const task = tasks.deleteExtensionInstanceTask(projectId, deletion);
  34. void deploymentQueue.run(task);
  35. }
  36. const deploymentPromise = deploymentQueue.wait();
  37. deploymentQueue.process();
  38. deploymentQueue.close();
  39. await deploymentPromise;
  40. const newHave = await planner.have(projectId);
  41. (0, etags_1.saveEtags)(options.rc, projectId, newHave);
  42. if (errorHandler.hasErrors()) {
  43. errorHandler.print();
  44. throw new error_1.FirebaseError(`Extensions deployment failed.`);
  45. }
  46. }
  47. exports.release = release;