UNPKG

2.29 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.projectConfig = projectConfig;
7exports.dependencyConfig = dependencyConfig;
8exports.findPodfilePaths = void 0;
9
10function _path() {
11 const data = _interopRequireDefault(require("path"));
12
13 _path = function () {
14 return data;
15 };
16
17 return data;
18}
19
20function _fs() {
21 const data = _interopRequireDefault(require("fs"));
22
23 _fs = function () {
24 return data;
25 };
26
27 return data;
28}
29
30var _findPodfilePath = _interopRequireDefault(require("./findPodfilePath"));
31
32var _findXcodeProject = _interopRequireDefault(require("./findXcodeProject"));
33
34var _findPodspec = _interopRequireDefault(require("./findPodspec"));
35
36var _findAllPodfilePaths = _interopRequireDefault(require("./findAllPodfilePaths"));
37
38function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
40/**
41 * Copyright (c) Facebook, Inc. and its affiliates.
42 *
43 * This source code is licensed under the MIT license found in the
44 * LICENSE file in the root directory of this source tree.
45 *
46 */
47
48/**
49 * Returns project config by analyzing given folder and applying some user defaults
50 * when constructing final object
51 */
52function projectConfig(folder, userConfig) {
53 if (!userConfig) {
54 return null;
55 }
56
57 const src = _path().default.join(folder, userConfig.sourceDir ?? '');
58
59 const podfile = (0, _findPodfilePath.default)(src);
60 /**
61 * In certain repos, the Xcode project can be generated by a tool.
62 * The only file that we can assume to exist on disk is `Podfile`.
63 */
64
65 if (!podfile) {
66 return null;
67 }
68
69 const sourceDir = _path().default.dirname(podfile);
70
71 const xcodeProject = (0, _findXcodeProject.default)(_fs().default.readdirSync(sourceDir));
72 return {
73 sourceDir,
74 xcodeProject
75 };
76}
77
78function dependencyConfig(folder, userConfig = {}) {
79 if (userConfig === null) {
80 return null;
81 }
82
83 const podspecPath = (0, _findPodspec.default)(folder);
84
85 if (!podspecPath) {
86 return null;
87 }
88
89 return {
90 podspecPath,
91 configurations: userConfig.configurations || [],
92 scriptPhases: userConfig.scriptPhases || []
93 };
94}
95
96const findPodfilePaths = _findAllPodfilePaths.default;
97exports.findPodfilePaths = findPodfilePaths;
98
99//# sourceMappingURL=index.js.map
\No newline at end of file