2016-11-14 19:12:24 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const findProject = require('./findProject');
|
2017-10-18 04:19:53 +00:00
|
|
|
const findPodfilePath = require('./findPodfilePath');
|
|
|
|
const findPodspecName = require('./findPodspecName');
|
2016-11-14 19:12:24 +00:00
|
|
|
const path = require('path');
|
2016-05-20 11:52:08 +00:00
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
/**
|
|
|
|
* For libraries specified without an extension, add '.tbd' for those that
|
|
|
|
* start with 'lib' and '.framework' to the rest.
|
|
|
|
*/
|
|
|
|
const mapSharedLibaries = (libraries) => {
|
|
|
|
return libraries.map(name => {
|
|
|
|
if (path.extname(name)) {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
/**
|
|
|
|
* Returns project config by analyzing given folder and applying some user defaults
|
|
|
|
* when constructing final object
|
|
|
|
*/
|
|
|
|
exports.projectConfig = function projectConfigIOS(folder, userConfig) {
|
|
|
|
const project = userConfig.project || findProject(folder);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* No iOS config found here
|
|
|
|
*/
|
|
|
|
if (!project) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const projectPath = path.join(folder, project);
|
|
|
|
|
|
|
|
return {
|
|
|
|
sourceDir: path.dirname(projectPath),
|
|
|
|
folder: folder,
|
|
|
|
pbxprojPath: path.join(projectPath, 'project.pbxproj'),
|
2017-10-18 04:19:53 +00:00
|
|
|
podfile: findPodfilePath(projectPath),
|
|
|
|
podspec: findPodspecName(folder),
|
2016-05-20 11:52:08 +00:00
|
|
|
projectPath: projectPath,
|
|
|
|
projectName: path.basename(projectPath),
|
|
|
|
libraryFolder: userConfig.libraryFolder || 'Libraries',
|
2016-07-30 15:59:16 +00:00
|
|
|
sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []),
|
2016-05-20 11:52:08 +00:00
|
|
|
plist: userConfig.plist || [],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.dependencyConfig = exports.projectConfig;
|