<commit_before>'use strict';

var titleize = require('titleize');
var chalk = require('chalk');
var Registry = require('npm-registry');
var npm = new Registry({ retries: 4 });

var NPM_CARTRIDGE_TASK_KEYWORD = 'cartridge-task';
var CARTRIDGE_TASK_MODULES;

var _promptOptions = [];

var promptOptionsApi = {};

promptOptionsApi.getNewCommandPromptOptions = function() {
	return getCartridgeTaskModulesFromNpm()
		.then(setPromptOptionsData);
}

function getCartridgeTaskModulesFromNpm() {

	return new Promise(function(resolve, reject) {

		npm.packages.keyword(NPM_CARTRIDGE_TASK_KEYWORD, function(err, data) {
			if(err) return console.error(err);

			CARTRIDGE_TASK_MODULES = data;

			resolve();
		});

	})

}

function setPromptOptionsData() {
	_promptOptions.push(getProjectTypePromptOptions());
	_promptOptions.push(getProjectNamePromptOptions());
	_promptOptions.push(getProjectAuthorPromptOptions());
	_promptOptions.push(getProjectDescriptionPromptOptions());
	_promptOptions.push(getCartridgeModulesPromptOptions());
	_promptOptions.push(getUserConfirmCopyPromptOptions());

	return Promise.resolve(_promptOptions);
}

function getCartridgeModulesPromptOptions() {
	return {
		type: 'checkbox',
		name: 'cartridgeModules',
		message: 'What modules would you like included?',
		choices: CARTRIDGE_TASK_MODULES
	}
}

function getProjectTypePromptOptions() {
	return {
		type: 'list',
		name: 'projectType',
		message: 'What is the project type?',<commit_msg>feat: format date from npm registry to combine module name and description<commit_after>'use strict';

var titleize = require('titleize');
var chalk = require('chalk');
var Registry = require('npm-registry');
var npm = new Registry({ retries: 4 });

var NPM_CARTRIDGE_TASK_KEYWORD = 'cartridge-task';
var CARTRIDGE_TASK_MODULES;

var _promptOptions = [];

var promptOptionsApi = {};

promptOptionsApi.getNewCommandPromptOptions = function() {
	return getCartridgeTaskModulesFromNpm()
		.then(setPromptOptionsData);
}

function getCartridgeTaskModulesFromNpm() {

	return new Promise(function(resolve, reject) {

		npm.packages.keyword(NPM_CARTRIDGE_TASK_KEYWORD, function(err, data) {
			if(err) return console.error(err);

			CARTRIDGE_TASK_MODULES = formatModuleData(data);

			resolve();
		});

	})

}

function formatModuleData(moduleData) {
	return moduleData.map(function(module) {
	   var formattedModule = {};
	   formattedModule.name = ' ' + chalk.underline(module.name) + ' => ' + module.description;
	   return formattedModule;
	})
}

function setPromptOptionsData() {
	_promptOptions.push(getProjectTypePromptOptions());
	_promptOptions.push(getProjectNamePromptOptions());
	_promptOptions.push(getProjectAuthorPromptOptions());
	_promptOptions.push(getProjectDescriptionPromptOptions());
	_promptOptions.push(getCartridgeModulesPromptOptions());
	_promptOptions.push(getUserConfirmCopyPromptOptions());

	return Promise.resolve(_promptOptions);
}

function getCartridgeModulesPromptOptions() {
	return {
		type: 'checkbox',
		name: 'cartridgeModules',
		message: 'What modules would you like included?',
		choices: CARTRIDGE_TASK_MODULES
	}
}

function getProjectTypePromptOptions() {
	return {
		type: 'list',
		name: 'projectType',
		message: 'What is the project type?',
{'fraction_non_alphanumeric': 0.1168152474638795, 'fraction_numerical': 0.0006148170919151552, 'mean_word_length': 6.63849765258216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5731572', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1028, 'n_words': 191}