config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CapacitorJSONConfig = exports.CAPACITOR_CONFIG_JSON_FILE = void 0;
  4. const tslib_1 = require("tslib");
  5. const cli_framework_1 = require("@ionic/cli-framework");
  6. const lodash = tslib_1.__importStar(require("lodash"));
  7. exports.CAPACITOR_CONFIG_JSON_FILE = 'capacitor.config.json';
  8. class CapacitorJSONConfig extends cli_framework_1.BaseConfig {
  9. constructor(p) {
  10. super(p, { spaces: '\t' });
  11. }
  12. provideDefaults(config) {
  13. return config;
  14. }
  15. setServerUrl(url) {
  16. const serverConfig = this.get('server') || {};
  17. if (typeof serverConfig.url === 'string') {
  18. serverConfig.originalUrl = serverConfig.url;
  19. }
  20. serverConfig.url = url;
  21. this.set('server', serverConfig);
  22. }
  23. resetServerUrl() {
  24. const serverConfig = this.get('server') || {};
  25. delete serverConfig.url;
  26. if (serverConfig.originalUrl) {
  27. serverConfig.url = serverConfig.originalUrl;
  28. delete serverConfig.originalUrl;
  29. }
  30. if (lodash.isEmpty(serverConfig)) {
  31. this.unset('server');
  32. }
  33. else {
  34. this.set('server', serverConfig);
  35. }
  36. }
  37. }
  38. exports.CapacitorJSONConfig = CapacitorJSONConfig;