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

var VERSION_DEFAULT = '1.0';

module.exports = function(name, args, program) {
	var widgetId = args[0] || name;
	var types = ['VIEW','CONTROLLER','STYLE'];
	var paths = getPaths(program.outputPath, widgetId);

	// don't overwrite an existing widget unless force is specified
	if (path.existsSync(paths.widget) && !program.force) {
		U.die("Widget already exists: " + paths.widget);
	}

	// create default alloy widget folders and files
	_.each(types, function(type) {
		var typeFolder = path.join(paths.widget, CONST.DIR[type]);
		var typeTemplate = path.join(paths.template,'widget',type.toLowerCase() + '.' + CONST.FILE_EXT[type]);

		wrench.mkdirSyncRecursive(typeFolder, 0777);
		fs.writeFileSync(
			path.join(typeFolder,CONST.NAME_WIDGET_DEFAULT + '.' + CONST.FILE_EXT[type]),
			fs.readFileSync(typeTemplate,'utf8')
		);
	});
	wrench.mkdirSyncRecursive(path.join(paths.widget,CONST.DIR.ASSETS), 0777);

	// create widget.json manifest file
	fs.writeFileSync(
		path.join(paths.widget,'widget.json'), 
		_.template(fs.readFileSync(paths.widgetTemplate,'utf8'), {<commit_msg>better path management in widget generator<commit_after>var path = require('path'),
	fs = require('fs'),
	wrench = require('wrench'),
	jsonlint = require('jsonlint'),
	U = require('../../../utils'),
	_ = require("../../../lib/alloy/underscore")._,
	CONST = require('../../../common/constants'),
	logger = require('../../../common/logger');

var VERSION_DEFAULT = '1.0';

module.exports = function(name, args, program) {
	var widgetId = args[0] || name;
	var types = ['VIEW','CONTROLLER','STYLE'];
	var thePaths = U.getAndValidateProjectPaths(program.outputPath || program.projectDir);
	var paths = getPaths(thePaths.app, widgetId);

	// don't overwrite an existing widget unless force is specified
	if (path.existsSync(paths.widget) && !program.force) {
		U.die("Widget already exists: " + paths.widget);
	}

	// create default alloy widget folders and files
	_.each(types, function(type) {
		var typeFolder = path.join(paths.widget, CONST.DIR[type]);
		var typeTemplate = path.join(paths.template,'widget',type.toLowerCase() + '.' + CONST.FILE_EXT[type]);

		wrench.mkdirSyncRecursive(typeFolder, 0777);
		fs.writeFileSync(
			path.join(typeFolder,CONST.NAME_WIDGET_DEFAULT + '.' + CONST.FILE_EXT[type]),
			fs.readFileSync(typeTemplate,'utf8')
		);
	});
	wrench.mkdirSyncRecursive(path.join(paths.widget,CONST.DIR.ASSETS), 0777);

	// create widget.json manifest file
	fs.writeFileSync(
		path.join(paths.widget,'widget.json'), 
		_.template(fs.readFileSync(paths.widgetTemplate,'utf8'), {
{'fraction_non_alphanumeric': 0.18425635667014978, 'fraction_numerical': 0.009056078021595262, 'mean_word_length': 4.587548638132295, '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': '1355813', 'n_tokens_mistral': 995, 'n_tokens_neox': 940, 'n_words': 173}