index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.projectConfig = projectConfig;
  6. exports.dependencyConfig = void 0;
  7. function _path() {
  8. const data = _interopRequireDefault(require("path"));
  9. _path = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _lodash() {
  15. const data = require("lodash");
  16. _lodash = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. var _findProject = _interopRequireDefault(require("./findProject"));
  22. var _findPodfilePath = _interopRequireDefault(require("./findPodfilePath"));
  23. var _findPodspec = _interopRequireDefault(require("./findPodspec"));
  24. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25. /**
  26. * Copyright (c) Facebook, Inc. and its affiliates.
  27. *
  28. * This source code is licensed under the MIT license found in the
  29. * LICENSE file in the root directory of this source tree.
  30. *
  31. */
  32. const memoizedFindProject = (0, _lodash().memoize)(_findProject.default);
  33. /**
  34. * For libraries specified without an extension, add '.tbd' for those that
  35. * start with 'lib' and '.framework' to the rest.
  36. */
  37. const mapSharedLibaries = libraries => libraries.map(name => {
  38. if (_path().default.extname(name)) {
  39. return name;
  40. }
  41. return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework');
  42. });
  43. /**
  44. * Returns project config by analyzing given folder and applying some user defaults
  45. * when constructing final object
  46. */
  47. function projectConfig(folder, userConfig) {
  48. if (!userConfig) {
  49. return;
  50. }
  51. const project = userConfig.project || memoizedFindProject(folder);
  52. /**
  53. * No iOS config found here
  54. */
  55. if (!project) {
  56. return null;
  57. }
  58. const projectPath = _path().default.join(folder, project);
  59. const sourceDir = _path().default.dirname(projectPath);
  60. return {
  61. sourceDir,
  62. folder,
  63. pbxprojPath: _path().default.join(projectPath, 'project.pbxproj'),
  64. podfile: (0, _findPodfilePath.default)(projectPath),
  65. podspecPath: userConfig.podspecPath || // podspecs are usually placed in the root dir of the library or in the
  66. // iOS project path
  67. (0, _findPodspec.default)(folder) || (0, _findPodspec.default)(sourceDir),
  68. projectPath,
  69. projectName: _path().default.basename(projectPath),
  70. libraryFolder: userConfig.libraryFolder || 'Libraries',
  71. sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []),
  72. plist: userConfig.plist || [],
  73. scriptPhases: userConfig.scriptPhases || []
  74. };
  75. }
  76. const dependencyConfig = projectConfig;
  77. exports.dependencyConfig = dependencyConfig;
  78. //# sourceMappingURL=index.js.map