<commit_before>var path = require('path'),
	fs = require('fs'),
	wrench = require('wrench'),
	_ = require('../../lib/alloy/underscore')._,
	U = require('../../utils'),
	CONST = require('../../common/constants'),
	logger = require('../../common/logger');

var BASE_ERR = 'Project creation failed. ';

module.exports = function(args, program) {
	var appDirs = ['controllers','styles','views','models','assets'];
	var types = ['VIEW','STYLE','CONTROLLER'];
	var paths = getPaths(args[0] || '.');

	// only overwrite existing app path if given the force option
	if (path.existsSync(paths.app)) {
		if (!program.force) {
			U.die(BASE_ERR + '"app" directory already exists at "' + paths.app + '"');
		} else {
			wrench.rmdirSyncRecursive(paths.app);
		}
	}
	wrench.mkdirSyncRecursive(paths.app, 0777);

	// add alloy-specific folders
	_.each(appDirs, function(dir) {
		wrench.mkdirSyncRecursive(path.join(paths.app,dir), 0777);
	});

	// add alloy default project files
	_.each(types, function(type) {
		var filename = CONST.NAME_DEFAULT + '.' + CONST.FILE_EXT[type];
		fs.writeFileSync(
			path.join(paths.app,CONST.DIR[type],filename),
			fs.readFileSync(path.join(paths.default,filename),'utf8')
		);
	});
	fs.writeFileSync(path.join(paths.app,'README'), fs.readFileSync(paths.readme,'utf8'));

	// TODO: ti.physicalSizeCategory - https://jira.appcelerator.org/browse/ALOY-209
	// handle any necessary alloy native modules
	wrench.copyDirSyncRecursive(paths.modules, paths.project, {preserve:true});
	U.tiapp.installModule(paths.project, {
		id: 'ti.physicalSizeCategory',
		platform: 'android',
		version: '1.0'
	});

	// create default config files and install compiler plugin
	writeConfigFile('alloy.jmk', paths);
	writeConfigFile('config.json', paths);
	installPlugin(paths);

	// copy Resources android, iphone, and mobileweb directories to assets
	_.each(['android','iphone','mobileweb'], function(dir) {
		var rDir = path.join(paths.Resources,dir);
		if (!path.existsSync(rDir)) {
			return;
		}

		var p = path.join(paths.app,'assets',dir);
		wrench.mkdirSyncRecursive(p, 0777);
		wrench.copyDirSyncRecursive(rDir, p);
	});
	
	logger.info('Generated new project at: ' + paths.app);<commit_msg>add new .gitignore to new alloy projects<commit_after>var path = require('path'),
	fs = require('fs'),
	wrench = require('wrench'),
	_ = require('../../lib/alloy/underscore')._,
	U = require('../../utils'),
	CONST = require('../../common/constants'),
	logger = require('../../common/logger');

var BASE_ERR = 'Project creation failed. ';

module.exports = function(args, program) {
	var appDirs = ['controllers','styles','views','models','assets'];
	var types = ['VIEW','STYLE','CONTROLLER'];
	var paths = getPaths(args[0] || '.');

	// only overwrite existing app path if given the force option
	if (path.existsSync(paths.app)) {
		if (!program.force) {
			U.die(BASE_ERR + '"app" directory already exists at "' + paths.app + '"');
		} else {
			wrench.rmdirSyncRecursive(paths.app);
		}
	}
	wrench.mkdirSyncRecursive(paths.app, 0777);

	// add alloy-specific folders
	_.each(appDirs, function(dir) {
		wrench.mkdirSyncRecursive(path.join(paths.app,dir), 0777);
	});

	// add alloy default project files
	_.each(types, function(type) {
		var filename = CONST.NAME_DEFAULT + '.' + CONST.FILE_EXT[type];
		fs.writeFileSync(
			path.join(paths.app,CONST.DIR[type],filename),
			fs.readFileSync(path.join(paths.default,filename),'utf8')
		);
	});
	fs.writeFileSync(path.join(paths.app,'README'), fs.readFileSync(paths.readme,'utf8'));

	// TODO: ti.physicalSizeCategory - https://jira.appcelerator.org/browse/ALOY-209
	// handle any necessary alloy native modules
	wrench.copyDirSyncRecursive(paths.modules, paths.project, {preserve:true});
	U.tiapp.installModule(paths.project, {
		id: 'ti.physicalSizeCategory',
		platform: 'android',
		version: '1.0'
	});

	// create default config files and install compiler plugin
	writeConfigFile('alloy.jmk', paths);
	writeConfigFile('config.json', paths);
	installPlugin(paths);

	// copy Resources android, iphone, and mobileweb directories to assets
	U.copyFileSync(
		path.join(paths.template,'gitignore.txt'), 
		path.join(paths.project,'.gitignore')
	);
	_.each(['android','iphone','mobileweb'], function(dir) {
		var rDir = path.join(paths.Resources,dir);
		if (!path.existsSync(rDir)) {
			return;
		}

		var p = path.join(paths.app,'assets',dir);
		wrench.mkdirSyncRecursive(p, 0777);
		wrench.copyDirSyncRecursive(rDir, p);
	});
	
	logger.info('Generated new project at: ' + paths.app);
{'fraction_non_alphanumeric': 0.17865019850022057, 'fraction_numerical': 0.00882223202470225, 'mean_word_length': 4.626550868486352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7218849', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1530, 'n_words': 288}