<commit_before>/*
 * info.js: Titanium CLI info command
 *
 * Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.
 * See the LICENSE file for more information.
 */

var appc = require('node-appc'),
	env = appc.environ,
	mix = appc.util.mix,
	async = require('async');

exports.config = function (logger, config, cli) {
	return {
		desc: __('display development environment information'),
		noAuth: true,
		skipBanner: true,
		options: {
			output: {
				abbr: 'o',
				default: 'report',
				desc: __('output format'),
				values: ['report', 'json']
			}
		}
	};
};

exports.run = function (logger, config, cli) {
	// important: we must duplicate every bit of info as to not accidentally
	// break the contract of the JSON formatted output.
	async.parallel([
		function (next) {
			env.getOSInfo(function (info) {
				next(null, {
					os: {
						name: info.os,
						version: info.osver,
						architecture: info.osarch,
						numcpus: info.oscpu,
						memory: info.memory
					},
					node: {
						version: info.node
					},
					npm: {
						version: info.npm
					}
				});
			});
		},
		
		function (next) {
			appc.ios.detect(function (info) {
				var result = { xcode: {} };
				Object.keys(info.xcode).forEach(function (ver) {
					if (ver != '__selected__') {
						result.xcode[ver] = {
							path: info.xcode[ver].path,
							xcodebuild: info.xcode[ver].xcodebuild,
							selected: info.xcode[ver].selected,
							version: info.xcode[ver].version,
							build: info.xcode[ver].build,
							sdks: [].concat(info.xcode[ver].sdks),
							sims: [].concat(info.xcode[ver].sims)
						};
					}
				});
				result.iosCerts = {
					dev: info.certs.dev,
					devNames: [].concat(info.certs.devNames),
					dist: info.certs.dist,
					distNames: [].concat(info.certs.distNames),
					wwdr: info.certs.wwdr
				};
				next(null, result);
			});
		},
		
		function (next) {
			var sdks = {};
			Object.keys(env.sdks).forEach(function (ver) {
				var n = env.sdks[ver];
				sdks[ver] = {
					path: n.path,
					platforms: Object.keys(n.platforms),
					githash: n.manifest ? n.manifest.githash : null,
					timestamp: n.manifest ? n.manifest.timestamp : null
				};
			});
			next(null, { titanium: sdks });
		}
	], function (err, results) {
		var data = mix.apply(null, results);
		
		if (cli.argv.output == 'json') {
			logger.log(JSON.stringify(data, null, '\t'));
		} else {
			var sections = {
				'Operating System': [
					['Name', data.os.name],
					['Version', data.os.version],
					['Architecture', data.os.architecture],
					['# CPUs', data.os.numcpus],<commit_msg>Started adding Android info to the info command.<commit_after>/*
 * info.js: Titanium CLI info command
 *
 * Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.
 * See the LICENSE file for more information.
 */

var appc = require('node-appc'),
	env = appc.environ,
	mix = appc.util.mix,
	async = require('async');

exports.config = function (logger, config, cli) {
	return {
		desc: __('display development environment information'),
		noAuth: true,
		skipBanner: true,
		options: {
			output: {
				abbr: 'o',
				default: 'report',
				desc: __('output format'),
				values: ['report', 'json']
			}
		}
	};
};

exports.run = function (logger, config, cli) {
	// important: we must duplicate every bit of info as to not accidentally
	// break the contract of the JSON formatted output.
	async.parallel([
		function (next) {
			env.getOSInfo(function (info) {
				next(null, {
					os: {
						name: info.os,
						version: info.osver,
						architecture: info.osarch,
						numcpus: info.oscpu,
						memory: info.memory
					},
					node: {
						version: info.node
					},
					npm: {
						version: info.npm
					}
				});
			});
		},
		
		function (next) {
			appc.ios.detect(function (info) {
				var result = { xcode: {} };
				Object.keys(info.xcode).forEach(function (ver) {
					if (ver != '__selected__') {
						result.xcode[ver] = {
							path: info.xcode[ver].path,
							xcodebuild: info.xcode[ver].xcodebuild,
							selected: info.xcode[ver].selected,
							version: info.xcode[ver].version,
							build: info.xcode[ver].build,
							sdks: [].concat(info.xcode[ver].sdks),
							sims: [].concat(info.xcode[ver].sims)
						};
					}
				});
				result.iosCerts = {
					dev: info.certs.dev,
					devNames: [].concat(info.certs.devNames),
					dist: info.certs.dist,
					distNames: [].concat(info.certs.distNames),
					wwdr: info.certs.wwdr
				};
				next(null, result);
			});
		},
		
		function (next) {
			appc.android.detect(function (info) {
				var result = {};
				
				next(null, { android: result });
			});
		},
		
		function (next) {
			var sdks = {};
			Object.keys(env.sdks).forEach(function (ver) {
				var n = env.sdks[ver];
				sdks[ver] = {
					path: n.path,
					platforms: Object.keys(n.platforms),
					githash: n.manifest ? n.manifest.githash : null,
					timestamp: n.manifest ? n.manifest.timestamp : null
				};
			});
			next(null, { titanium: sdks });
		}
	], function (err, results) {
		var data = mix.apply(null, results);
		
		if (cli.argv.output == 'json') {
			logger.log(JSON.stringify(data, null, '\t'));
		} else {
			var sections = {
				'Operating System': [
					['Name', data.os.name],
					['Version', data.os.version],
					['Architecture', data.os.architecture],
					['# CPUs', data.os.numcpus],
{'fraction_non_alphanumeric': 0.16306775874906926, 'fraction_numerical': 0.0014892032762472078, 'mean_word_length': 2.5677290836653386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4782862', 'n_tokens_mistral': 2445, 'n_tokens_neox': 1859, 'n_words': 407}