GSI - Employe Self Service Mobile
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.

68 lines
3.1 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
  5. const command_1 = require("../command");
  6. const planner = require("../deploy/extensions/planner");
  7. const etags_1 = require("../extensions/etags");
  8. const export_1 = require("../extensions/export");
  9. const extensionsHelper_1 = require("../extensions/extensionsHelper");
  10. const manifest = require("../extensions/manifest");
  11. const paramHelper_1 = require("../extensions/paramHelper");
  12. const functional_1 = require("../functional");
  13. const getProjectNumber_1 = require("../getProjectNumber");
  14. const logger_1 = require("../logger");
  15. const projectUtils_1 = require("../projectUtils");
  16. const prompt_1 = require("../prompt");
  17. const requirePermissions_1 = require("../requirePermissions");
  18. exports.command = new command_1.Command("ext:export")
  19. .description("export all Extension instances installed on a project to a local Firebase directory")
  20. .before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.list"])
  21. .before(extensionsHelper_1.ensureExtensionsApiEnabled)
  22. .before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
  23. .withForce()
  24. .action(async (options) => {
  25. const projectId = (0, projectUtils_1.needProjectId)(options);
  26. const projectNumber = await (0, getProjectNumber_1.getProjectNumber)(options);
  27. const have = await Promise.all(await planner.have(projectId));
  28. if (have.length === 0) {
  29. logger_1.logger.info(`No extension instances installed on ${projectId}, so there is nothing to export.`);
  30. return;
  31. }
  32. const [withRef, withoutRef] = (0, functional_1.partition)(have, (s) => !!s.ref);
  33. const withRefSubbed = await Promise.all(withRef.map(async (i) => {
  34. const subbed = await (0, export_1.setSecretParamsToLatest)(i);
  35. return (0, export_1.parameterizeProject)(projectId, projectNumber, subbed);
  36. }));
  37. (0, export_1.displayExportInfo)(withRefSubbed, withoutRef);
  38. if (!options.nonInteractive &&
  39. !options.force &&
  40. !(await (0, prompt_1.promptOnce)({
  41. message: "Do you wish to add these Extension instances to firebase.json?",
  42. type: "confirm",
  43. default: true,
  44. }))) {
  45. logger_1.logger.info("Exiting. No changes made.");
  46. return;
  47. }
  48. const manifestSpecs = withRefSubbed.map((spec) => {
  49. const paramCopy = Object.assign({}, spec.params);
  50. if (spec.eventarcChannel) {
  51. paramCopy.EVENTARC_CHANNEL = spec.eventarcChannel;
  52. }
  53. if (spec.allowedEventTypes) {
  54. paramCopy.ALLOWED_EVENT_TYPES = spec.allowedEventTypes.join(",");
  55. }
  56. return {
  57. instanceId: spec.instanceId,
  58. ref: spec.ref,
  59. params: (0, paramHelper_1.buildBindingOptionsWithBaseValue)(paramCopy),
  60. };
  61. });
  62. const existingConfig = manifest.loadConfig(options);
  63. await manifest.writeToManifest(manifestSpecs, existingConfig, {
  64. nonInteractive: options.nonInteractive,
  65. force: options.force,
  66. }, true);
  67. (0, etags_1.saveEtags)(options.rc, projectId, have);
  68. });