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.

40 lines
1.6 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.init = void 0;
  4. const lodash_1 = require("lodash");
  5. const clc = require("colorette");
  6. const error_1 = require("../error");
  7. const logger_1 = require("../logger");
  8. const features = require("./features");
  9. const featureFns = new Map([
  10. ["account", features.account],
  11. ["database", features.database],
  12. ["firestore", features.firestore],
  13. ["functions", features.functions],
  14. ["hosting", features.hosting],
  15. ["storage", features.storage],
  16. ["emulators", features.emulators],
  17. ["project", features.project],
  18. ["remoteconfig", features.remoteconfig],
  19. ["hosting:github", features.hostingGithub],
  20. ]);
  21. async function init(setup, config, options) {
  22. var _a;
  23. const nextFeature = (_a = setup.features) === null || _a === void 0 ? void 0 : _a.shift();
  24. if (nextFeature) {
  25. if (!featureFns.has(nextFeature)) {
  26. const availableFeatures = Object.keys(features)
  27. .filter((f) => f !== "project")
  28. .join(", ");
  29. throw new error_1.FirebaseError(`${clc.bold(nextFeature)} is not a valid feature. Must be one of ${availableFeatures}`);
  30. }
  31. logger_1.logger.info(clc.bold(`\n${clc.white("===")} ${(0, lodash_1.capitalize)(nextFeature)} Setup`));
  32. const fn = featureFns.get(nextFeature);
  33. if (!fn) {
  34. throw new error_1.FirebaseError(`We've lost the function to init ${nextFeature}`, { exit: 2 });
  35. }
  36. await fn(setup, config, options);
  37. return init(setup, config, options);
  38. }
  39. }
  40. exports.init = init;