/*
	Licensed Material - Property of IBM

	(C) Copyright 2015 IBM Corp.

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/


'use strict';

var detectPlatform = require('./detectPlatform');
var detectPlatforms = require('./detectPlatforms');
var parsePlatform = require('./parsePlatform');

var log = require('npmlog');

log.level = global.MDO_CLI_LOG_LEVEL ? global.MDO_CLI_LOG_LEVEL : log.level;

module.exports = {
    detectPlatform: detectPlatform,
    detectPlatforms: detectPlatforms,
    parsePlatform: parsePlatform
};

/* Three main entry points
 * detectPlatform: Singular version of detectPlatforms.
    @param -
        platformId - Platform to try and detect. Values (cordova-{android/ios/windows}, native-{android/ios/windows})
    @return -
        Reference detectPlatforms, except you will not receive the platfroms array.
 * detectPlatforms:
    @params - none
    @return -
        Promise, (*NOTE* Only success function is expected to return) returns an object if platform(s) detected. If no platform(s) is/are detected then return from promise is 'undefined'.
        If detected the object returned has the structure:
            {
                isCordova: is Cordova Project
                rootDir: root directory of project
                platforms: all of the platforms detected. 0-3 for Cordova, 0-1 for Native
            }
        Structure of platform object:
            {
                configXMLPath: only present in Cordova platforms
                platformPath: directory of platform in Cordova project. Is === to rootDir in native projects
                platformId: ID of the platform. Values are (cordova-{android/ios/windows}, native-{android/ios/windows})
        }
 * parsePlatform:
    @params -
        platformId: String, the platformId of the project type.  Valid values (android, ios, windows), these values match the 'id' value in the package.json extension point.
        isCordova: Boolean, true if project being parsed is a Cordova project. The object returned by detectPlatforms will contain this value.
        rootDir: The root directory of where the parsing file lives (Android -> AndroidManifest.xml, IOS -> Info.plist, Windows -> appxmanifest). The object returned by detectPlatforms will contain this value.
    @return -
        Promise, if successful it will contain an object that contains platform information of the platform.
            Cordova projects return:
                clientMetadata['app.version']
                clientMetadata['app.name']
                clientMetadata['app.description']
                clientMetadata['app.dotId']
                clientMetadata['author.name']
                clientMetadata['author.email']
                clientMetadata['author.href']
                clientMetadata['app.mainfile']
            Native projects return:
                clientMetadata['app.version'] = "";
                clientMetadata['app.name'] = "";
                clientMetadata['app.dotId'] = "";
*/
