From cbee1f6733acd2ce1f25bb29d26e7270de213e4a Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 16:19:53 -0430 Subject: [PATCH 01/12] Making create.js more extensible --- lib/create.js | 234 ++++++++++++++++++++++++++------------------------ 1 file changed, 123 insertions(+), 111 deletions(-) diff --git a/lib/create.js b/lib/create.js index cdfaa9d..a5d1465 100644 --- a/lib/create.js +++ b/lib/create.js @@ -1,11 +1,12 @@ var log = require('./log'), - cpr = require('cpr').cpr, - mkdirp = require('mkdirp'), - config = require('./config'), - path = require('path'), - timethat = require('timethat'), - fs = require('fs'), - util = require('./util'); + cpr = require('cpr').cpr, + mkdirp = require('mkdirp'), + config = require('./config'), + path = require('path'), + timethat = require('timethat'), + fs = require('fs'), + util = require('./util'), + mods; var _defaultDirs = [ @@ -15,55 +16,63 @@ var _defaultDirs = [ './meta', './css', './assets' -]; + ]; -var createJSON = function(options, callback) { +mods = { + + /** + Create a JSON + @method createJSON + @param {Object} options {options.name, options.location, options.defaultDirs} + **/ + createJSON : function (options, callback) { var name = options.name, - build = { - name: name, - builds: {} - }, - meta = {}, - codeFile = path.join(options.location, 'js', name + '.js'), - skinBase = path.join(options.location, 'assets', name, 'skins', 'sam'), - file = path.join(options.location, 'build.json'), - readme = path.join(options.location, 'README.md'), - history = path.join(options.location, 'HISTORY.md'), - metaFile = path.join(options.location, 'meta', name + '.json'); + build = { + name: name, + builds: {} + }, + meta = {}, + defaultDirs = options.defaultDirs || _defaultDirs, + codeFile = path.join(options.location, 'js', name + '.js'), + skinBase = path.join(options.location, 'assets', name, 'skins', 'sam'), + file = path.join(options.location, 'build.json'), + readme = path.join(options.location, 'README.md'), + history = path.join(options.location, 'HISTORY.md'), + metaFile = path.join(options.location, 'meta', name + '.json'); build.builds[name] = { }; + meta[name] = { }; switch (options.type) { - case 'js': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'yui-base' ]; - break; - case 'css': - codeFile = path.join(options.location, 'css', name + '.css'), - build.builds[name].cssfiles = [ - 'css/' + name + '.css' - ]; - meta[name].type = 'css'; - break; - case 'widget': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'widget' ]; - meta[name].skinnable = true; - - mkdirp.sync(skinBase); - log.info('creating skin templates'); - fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - break; + case 'js': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'yui-base' ]; + break; + case 'css': + codeFile = path.join(options.location, 'css', name + '.css'); + build.builds[name].cssfiles = [ + 'css/' + name + '.css' + ]; + meta[name].type = 'css'; + break; + case 'widget': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'widget' ]; + meta[name].skinnable = true; + mkdirp.sync(skinBase); + log.info('creating skin templates'); + fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + break; } log.debug('creating README file: ' + readme); @@ -72,7 +81,6 @@ var createJSON = function(options, callback) { log.debug('creating HISTORY file: ' + history); fs.writeFileSync(history, name + '\n========\n', 'utf8'); - log.debug('creating code file: ' + codeFile); fs.writeFileSync(codeFile, '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); @@ -82,86 +90,90 @@ var createJSON = function(options, callback) { log.debug('creating meta/' + name + '.json file: ' + metaFile); fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); callback(); -}; + }, - -var replaceTitle = function(options, items, callback) { + replaceTitle : function (options, items, callback) { var tags = '[ "gallery" ]', - title = options.name; - author = config.get('username'); - - items.forEach(function(file) { - var stat = fs.statSync(file), str; - if (!stat.isDirectory()) { - log.debug('updating title in ' + file); - str = fs.readFileSync(file, 'utf8'); - str = str.replace(/\{\{title\}\}/gi, title); - str = str.replace(/\{\{name\}\}/gi, title); - str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); - str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); - str = str.replace(/\{\{tags\}\}/gi, tags); - str = str.replace(/\{\{author\}\}/gi, author); - str = str.replace(/\{\{code\}\}/gi, '//Module example code'); - fs.writeFileSync(file, str, 'utf8'); - } + title = options.name, + author = config.get('username'); + + items.forEach(function (file) { + + var stat = fs.statSync(file), str; + if (!stat.isDirectory()) { + log.debug('updating title in ' + file); + str = fs.readFileSync(file, 'utf8'); + str = str.replace(/\{\{title\}\}/gi, title); + str = str.replace(/\{\{name\}\}/gi, title); + str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); + str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); + str = str.replace(/\{\{tags\}\}/gi, tags); + str = str.replace(/\{\{author\}\}/gi, author); + str = str.replace(/\{\{code\}\}/gi, '//Module example code'); + fs.writeFileSync(file, str, 'utf8'); + } }); - callback(); -}; -var createDirs = function(options, callback) { + callback(); + }, + createDirs : function (options, callback) { log.info('creating default directory structure'); var stack = new util.Stack(), - copied = []; - - _defaultDirs.forEach(function(dir) { - var d = path.join(__dirname, '../defaults/', dir), - toDir = path.join(options.location, dir); - - if (util.exists(toDir)) { - log.info('did not create default directory, it exists: ' + toDir); - return; - } - if (util.exists(d)) { - log.debug('copying dir from ' + d); - log.debug('to ' + toDir); - mkdirp(toDir, stack.add(function() { - cpr(d, toDir, stack.add(function(err, status) { - copied = [].concat(copied, status); - })); - })); - } else { - log.debug('making ' + toDir); - mkdirp(toDir, stack.add(function() { - })); - } + copied = [], + defaultDirs = options.defaultDirs || _defaultDirs; + + defaultDirs.forEach(function (dir) { + var d = path.join(__dirname, '../defaults/', dir), + toDir = path.join(options.location, dir); + + if (util.exists(toDir)) { + log.info('did not create default directory, it exists: ' + toDir); + return; + } + if (util.exists(d)) { + log.debug('copying dir from ' + d); + log.debug('to ' + toDir); + mkdirp(toDir, stack.add(function () { + cpr(d, toDir, stack.add(function (err, status) { + copied = [].concat(copied, status); + })); + })); + } else { + log.debug('making ' + toDir); + mkdirp(toDir, stack.add(function () { + })); + } }); - stack.done(function() { - log.info('directories created, processing files'); - replaceTitle(options, copied, function() { - createJSON(options, function() { - callback(); - }); + stack.done(function () { + log.info('directories created, processing files'); + mods.replaceTitle(options, copied, function () { + mods.createJSON(options, function () { + callback(); }); + }); }); -}; - -exports.init = function(options, callback) { + }, + init : function (options, callback) { var start = (new Date()).getTime(); log.info('creating module (' + options.name + ') in: ' + options.location); if (util.exists(options.location)) { - log.bail('destination already exists, you are on your own! bailing..'); + log.bail('destination already exists, you are on your own! bailing..'); } - createDirs(options, function() { - util.tree(options.location, options.root, function(tree) { - log.log(''); - log.info('module created, here\'s what yogi did for you:'); - log.log(''); - console.log(tree); - log.info('yogi took ' + timethat.calc(start, new Date().getTime()) + ' to create this module'); - callback(); - }); + this.createDirs(options, function () { + util.tree(options.location, options.root, function (tree) { + log.log(''); + log.info('module created, here\'s what yogi did for you:'); + log.log(''); + console.log(tree); + log.info('yogi took ' + timethat.calc(start, new Date().getTime()) + ' to create this module'); + callback(); + }); }); + } }; + +util.mix(exports, mods); + From 4fa2411e7104e853af081f1a950f73f66406a08d Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 16:41:03 -0430 Subject: [PATCH 02/12] Fixed Travis Problems --- lib/create.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/create.js b/lib/create.js index a5d1465..39e3e37 100644 --- a/lib/create.js +++ b/lib/create.js @@ -33,7 +33,6 @@ mods = { builds: {} }, meta = {}, - defaultDirs = options.defaultDirs || _defaultDirs, codeFile = path.join(options.location, 'js', name + '.js'), skinBase = path.join(options.location, 'assets', name, 'skins', 'sam'), file = path.join(options.location, 'build.json'), From 885911b3ecef39b84c435112e2eceac9298bb1b4 Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 17:13:44 -0430 Subject: [PATCH 03/12] some changes --- lib/create.js | 172 +++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/lib/create.js b/lib/create.js index 39e3e37..c95aa9c 100644 --- a/lib/create.js +++ b/lib/create.js @@ -1,12 +1,12 @@ var log = require('./log'), - cpr = require('cpr').cpr, - mkdirp = require('mkdirp'), - config = require('./config'), - path = require('path'), - timethat = require('timethat'), - fs = require('fs'), - util = require('./util'), - mods; + cpr = require('cpr').cpr, + mkdirp = require('mkdirp'), + config = require('./config'), + path = require('path'), + timethat = require('timethat'), + fs = require('fs'), + util = require('./util'), + mods; var _defaultDirs = [ @@ -27,93 +27,93 @@ mods = { **/ createJSON : function (options, callback) { - var name = options.name, - build = { - name: name, - builds: {} - }, - meta = {}, - codeFile = path.join(options.location, 'js', name + '.js'), - skinBase = path.join(options.location, 'assets', name, 'skins', 'sam'), - file = path.join(options.location, 'build.json'), - readme = path.join(options.location, 'README.md'), - history = path.join(options.location, 'HISTORY.md'), - metaFile = path.join(options.location, 'meta', name + '.json'); - - build.builds[name] = { - }; - - meta[name] = { - }; - - switch (options.type) { - - case 'js': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'yui-base' ]; - break; - case 'css': - codeFile = path.join(options.location, 'css', name + '.css'); - build.builds[name].cssfiles = [ - 'css/' + name + '.css' - ]; - meta[name].type = 'css'; - break; - case 'widget': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'widget' ]; - meta[name].skinnable = true; - mkdirp.sync(skinBase); - log.info('creating skin templates'); - fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - break; - } + var name = options.name, + build = { + name: name, + builds: {} + }, + meta = {}, + codeFile = path.join(options.location, 'js', name + '.js'), + skinBase = path.join(options.location, 'assets', name, 'skins', 'sam'), + file = path.join(options.location, 'build.json'), + readme = path.join(options.location, 'README.md'), + history = path.join(options.location, 'HISTORY.md'), + metaFile = path.join(options.location, 'meta', name + '.json'); + + build.builds[name] = { + }; + + meta[name] = { + }; + + switch (options.type) { + + case 'js': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'yui-base' ]; + break; + case 'css': + codeFile = path.join(options.location, 'css', name + '.css'); + build.builds[name].cssfiles = [ + 'css/' + name + '.css' + ]; + meta[name].type = 'css'; + break; + case 'widget': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'widget' ]; + meta[name].skinnable = true; + mkdirp.sync(skinBase); + log.info('creating skin templates'); + fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + break; + } - log.debug('creating README file: ' + readme); - fs.writeFileSync(readme, name + '\n========\n', 'utf8'); + log.debug('creating README file: ' + readme); + fs.writeFileSync(readme, name + '\n========\n', 'utf8'); - log.debug('creating HISTORY file: ' + history); - fs.writeFileSync(history, name + '\n========\n', 'utf8'); + log.debug('creating HISTORY file: ' + history); + fs.writeFileSync(history, name + '\n========\n', 'utf8'); - log.debug('creating code file: ' + codeFile); - fs.writeFileSync(codeFile, '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + log.debug('creating code file: ' + codeFile); + fs.writeFileSync(codeFile, '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - log.debug('creating build.json file: ' + file); - fs.writeFileSync(file, JSON.stringify(build, null, 4) + '\n', 'utf8'); + log.debug('creating build.json file: ' + file); + fs.writeFileSync(file, JSON.stringify(build, null, 4) + '\n', 'utf8'); - log.debug('creating meta/' + name + '.json file: ' + metaFile); - fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); - callback(); + log.debug('creating meta/' + name + '.json file: ' + metaFile); + fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); + callback(); }, replaceTitle : function (options, items, callback) { - var tags = '[ "gallery" ]', - title = options.name, - author = config.get('username'); - - items.forEach(function (file) { - - var stat = fs.statSync(file), str; - if (!stat.isDirectory()) { - log.debug('updating title in ' + file); - str = fs.readFileSync(file, 'utf8'); - str = str.replace(/\{\{title\}\}/gi, title); - str = str.replace(/\{\{name\}\}/gi, title); - str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); - str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); - str = str.replace(/\{\{tags\}\}/gi, tags); - str = str.replace(/\{\{author\}\}/gi, author); - str = str.replace(/\{\{code\}\}/gi, '//Module example code'); - fs.writeFileSync(file, str, 'utf8'); - } - }); + var tags = '[ "gallery" ]', + title = options.name, + author = config.get('username'); + + items.forEach(function (file) { + + var stat = fs.statSync(file), str; + if (!stat.isDirectory()) { + log.debug('updating title in ' + file); + str = fs.readFileSync(file, 'utf8'); + str = str.replace(/\{\{title\}\}/gi, title); + str = str.replace(/\{\{name\}\}/gi, title); + str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); + str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); + str = str.replace(/\{\{tags\}\}/gi, tags); + str = str.replace(/\{\{author\}\}/gi, author); + str = str.replace(/\{\{code\}\}/gi, '//Module example code'); + fs.writeFileSync(file, str, 'utf8'); + } + }); - callback(); + callback(); }, createDirs : function (options, callback) { From a9c3e66936ec82d2d006d31563c5805cdd0a5be9 Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 17:31:30 -0430 Subject: [PATCH 04/12] tabs set to 2 spaces --- lib/create.js | 228 +++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/lib/create.js b/lib/create.js index c95aa9c..d685e98 100644 --- a/lib/create.js +++ b/lib/create.js @@ -5,7 +5,7 @@ var log = require('./log'), path = require('path'), timethat = require('timethat'), fs = require('fs'), - util = require('./util'), + util = require('./util'); mods; @@ -16,7 +16,7 @@ var _defaultDirs = [ './meta', './css', './assets' - ]; +], mods = { @@ -27,10 +27,10 @@ mods = { **/ createJSON : function (options, callback) { - var name = options.name, + var name = options.name, build = { - name: name, - builds: {} + name: name, + builds: {} }, meta = {}, codeFile = path.join(options.location, 'js', name + '.js'), @@ -40,139 +40,139 @@ mods = { history = path.join(options.location, 'HISTORY.md'), metaFile = path.join(options.location, 'meta', name + '.json'); - build.builds[name] = { - }; - - meta[name] = { - }; - - switch (options.type) { - - case 'js': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'yui-base' ]; - break; - case 'css': - codeFile = path.join(options.location, 'css', name + '.css'); - build.builds[name].cssfiles = [ - 'css/' + name + '.css' - ]; - meta[name].type = 'css'; - break; - case 'widget': - build.builds[name].jsfiles = [ - 'js/' + name + '.js' - ]; - meta[name].requires = [ 'widget' ]; - meta[name].skinnable = true; - mkdirp.sync(skinBase); - log.info('creating skin templates'); - fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - break; - } - - log.debug('creating README file: ' + readme); - fs.writeFileSync(readme, name + '\n========\n', 'utf8'); - - log.debug('creating HISTORY file: ' + history); - fs.writeFileSync(history, name + '\n========\n', 'utf8'); - - log.debug('creating code file: ' + codeFile); - fs.writeFileSync(codeFile, '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); - - log.debug('creating build.json file: ' + file); - fs.writeFileSync(file, JSON.stringify(build, null, 4) + '\n', 'utf8'); - - log.debug('creating meta/' + name + '.json file: ' + metaFile); - fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); - callback(); - }, + build.builds[name] = { + }; + meta[name] = { + }; + + switch (options.type) { + case 'js': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'yui-base' ]; + break; + case 'css': + codeFile = path.join(options.location, 'css', name + '.css'), + build.builds[name].cssfiles = [ + 'css/' + name + '.css' + ]; + meta[name].type = 'css'; + break; + case 'widget': + build.builds[name].jsfiles = [ + 'js/' + name + '.js' + ]; + meta[name].requires = [ 'widget' ]; + meta[name].skinnable = true; + + mkdirp.sync(skinBase); + log.info('creating skin templates'); + fs.writeFileSync(path.join(skinBase, name + '-skin.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + fs.writeFileSync(path.join(skinBase, '../../', name + '-core.css'), '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + break; + + } + + log.debug('creating README file: ' + readme); + fs.writeFileSync(readme, name + '\n========\n', 'utf8'); + + log.debug('creating HISTORY file: ' + history); + fs.writeFileSync(history, name + '\n========\n', 'utf8'); + + + log.debug('creating code file: ' + codeFile); + fs.writeFileSync(codeFile, '\n/**\n Your Code Goes Here\n*/\n', 'utf8'); + + log.debug('creating build.json file: ' + file); + fs.writeFileSync(file, JSON.stringify(build, null, 4) + '\n', 'utf8'); + + log.debug('creating meta/' + name + '.json file: ' + metaFile); + fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); + callback(); +}, - replaceTitle : function (options, items, callback) { - var tags = '[ "gallery" ]', - title = options.name, - author = config.get('username'); - items.forEach(function (file) { +replaceTitle : function(options, items, callback) { + var tags = '[ "gallery" ]', + title = options.name; + author = config.get('username'); + items.forEach(function(file) { var stat = fs.statSync(file), str; if (!stat.isDirectory()) { - log.debug('updating title in ' + file); - str = fs.readFileSync(file, 'utf8'); - str = str.replace(/\{\{title\}\}/gi, title); - str = str.replace(/\{\{name\}\}/gi, title); - str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); - str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); - str = str.replace(/\{\{tags\}\}/gi, tags); - str = str.replace(/\{\{author\}\}/gi, author); - str = str.replace(/\{\{code\}\}/gi, '//Module example code'); - fs.writeFileSync(file, str, 'utf8'); + log.debug('updating title in ' + file); + str = fs.readFileSync(file, 'utf8'); + str = str.replace(/\{\{title\}\}/gi, title); + str = str.replace(/\{\{name\}\}/gi, title); + str = str.replace(/\{\{summary\}\}/gi, '*Summary Goes Here*'); + str = str.replace(/\{\{description\}\}/gi, '*Module Description Goes Here*'); + str = str.replace(/\{\{tags\}\}/gi, tags); + str = str.replace(/\{\{author\}\}/gi, author); + str = str.replace(/\{\{code\}\}/gi, '//Module example code'); + fs.writeFileSync(file, str, 'utf8'); } - }); + }); + callback(); +}, - callback(); - }, createDirs : function (options, callback) { log.info('creating default directory structure'); var stack = new util.Stack(), - copied = [], - defaultDirs = options.defaultDirs || _defaultDirs; - - defaultDirs.forEach(function (dir) { - var d = path.join(__dirname, '../defaults/', dir), - toDir = path.join(options.location, dir); - - if (util.exists(toDir)) { - log.info('did not create default directory, it exists: ' + toDir); - return; - } - if (util.exists(d)) { - log.debug('copying dir from ' + d); - log.debug('to ' + toDir); - mkdirp(toDir, stack.add(function () { - cpr(d, toDir, stack.add(function (err, status) { - copied = [].concat(copied, status); - })); - })); - } else { - log.debug('making ' + toDir); - mkdirp(toDir, stack.add(function () { - })); - } + copied = []; + defaultDirs = options.defaultDirs || _defaultDirs; + + defaultDirs.forEach(function (dir) { + var d = path.join(__dirname, '../defaults/', dir), + toDir = path.join(options.location, dir); + + if (util.exists(toDir)) { + log.info('did not create default directory, it exists: ' + toDir); + return; + } + if (util.exists(d)) { + log.debug('copying dir from ' + d); + log.debug('to ' + toDir); + mkdirp(toDir, stack.add(function() { + cpr(d, toDir, stack.add(function(err, status) { + copied = [].concat(copied, status); + })); + })); + } else { + log.debug('making ' + toDir); + mkdirp(toDir, stack.add(function() { + })); + } }); - stack.done(function () { - log.info('directories created, processing files'); - mods.replaceTitle(options, copied, function () { - mods.createJSON(options, function () { - callback(); + stack.done(function() { + log.info('directories created, processing files'); + mods.replaceTitle(options, copied, function() { + mods.createJSON(options, function() { + callback(); + }); }); - }); }); }, init : function (options, callback) { var start = (new Date()).getTime(); log.info('creating module (' + options.name + ') in: ' + options.location); if (util.exists(options.location)) { - log.bail('destination already exists, you are on your own! bailing..'); + log.bail('destination already exists, you are on your own! bailing..'); } this.createDirs(options, function () { - util.tree(options.location, options.root, function (tree) { - log.log(''); - log.info('module created, here\'s what yogi did for you:'); - log.log(''); - console.log(tree); - log.info('yogi took ' + timethat.calc(start, new Date().getTime()) + ' to create this module'); - callback(); - }); + util.tree(options.location, options.root, function(tree) { + log.log(''); + log.info('module created, here\'s what yogi did for you:'); + log.log(''); + console.log(tree); + log.info('yogi took ' + timethat.calc(start, new Date().getTime()) + ' to create this module'); + callback(); + }); }); } }; -util.mix(exports, mods); - +util.mix(exports, mods); \ No newline at end of file From 056a33577585d5774d7c18d8ade19db63399ddd0 Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 17:41:48 -0430 Subject: [PATCH 05/12] adding eof newline --- lib/create.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/create.js b/lib/create.js index d685e98..1500be8 100644 --- a/lib/create.js +++ b/lib/create.js @@ -173,6 +173,4 @@ replaceTitle : function(options, items, callback) { }); } }; - - util.mix(exports, mods); \ No newline at end of file From ce02f1d6e92f4ec8cb5057bc34decfb5985ea3c3 Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 17:43:15 -0430 Subject: [PATCH 06/12] adding eof newline --- lib/create.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/create.js b/lib/create.js index 1500be8..6fc5915 100644 --- a/lib/create.js +++ b/lib/create.js @@ -173,4 +173,6 @@ replaceTitle : function(options, items, callback) { }); } }; -util.mix(exports, mods); \ No newline at end of file + +util.mix(exports, mods); + From 69b37368d06d5c6e2a475c5dc7604ad6ec5e4e83 Mon Sep 17 00:00:00 2001 From: dariel Date: Wed, 21 Aug 2013 17:55:50 -0430 Subject: [PATCH 07/12] more descriptive comment --- lib/create.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/create.js b/lib/create.js index 6fc5915..398fc44 100644 --- a/lib/create.js +++ b/lib/create.js @@ -21,7 +21,7 @@ var _defaultDirs = [ mods = { /** - Create a JSON + Creates the JSON assets for the new module @method createJSON @param {Object} options {options.name, options.location, options.defaultDirs} **/ @@ -176,3 +176,5 @@ replaceTitle : function(options, items, callback) { util.mix(exports, mods); + + From afb7e72050b8f205658bcf9a8701abea2dea6d22 Mon Sep 17 00:00:00 2001 From: dariel Date: Thu, 22 Aug 2013 12:48:39 -0430 Subject: [PATCH 08/12] fixed travis bugs --- lib/create.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/create.js b/lib/create.js index 398fc44..495e97a 100644 --- a/lib/create.js +++ b/lib/create.js @@ -5,18 +5,15 @@ var log = require('./log'), path = require('path'), timethat = require('timethat'), fs = require('fs'), - util = require('./util'); - mods; - - -var _defaultDirs = [ + util = require('./util'), + _defaultDirs = [ './docs/', './tests/', './js', './meta', './css', './assets' -], + ], mods = { From 22ccf853c6a594d2e940bacaed2cc2367f1c8774 Mon Sep 17 00:00:00 2001 From: dariel Date: Tue, 27 Aug 2013 22:52:00 -0430 Subject: [PATCH 09/12] refactoring --- lib/create.js | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/lib/create.js b/lib/create.js index 495e97a..9e149fa 100644 --- a/lib/create.js +++ b/lib/create.js @@ -5,24 +5,19 @@ var log = require('./log'), path = require('path'), timethat = require('timethat'), fs = require('fs'), - util = require('./util'), - _defaultDirs = [ + util = require('./util'); + + +var _defaultDirs = [ './docs/', './tests/', './js', './meta', './css', './assets' - ], - -mods = { +]; - /** - Creates the JSON assets for the new module - @method createJSON - @param {Object} options {options.name, options.location, options.defaultDirs} - **/ - createJSON : function (options, callback) { +var createJSON = function(options, callback) { var name = options.name, build = { @@ -87,10 +82,10 @@ mods = { log.debug('creating meta/' + name + '.json file: ' + metaFile); fs.writeFileSync(metaFile, JSON.stringify(meta, null, 4) + '\n', 'utf8'); callback(); -}, +}; -replaceTitle : function(options, items, callback) { +var replaceTitle = function(options, items, callback) { var tags = '[ "gallery" ]', title = options.name; author = config.get('username'); @@ -111,16 +106,15 @@ replaceTitle : function(options, items, callback) { } }); callback(); -}, +}; - createDirs : function (options, callback) { +var createDirs = function(options, callback) { log.info('creating default directory structure'); var stack = new util.Stack(), copied = []; - defaultDirs = options.defaultDirs || _defaultDirs; - defaultDirs.forEach(function (dir) { + _defaultDirs.forEach(function(dir) { var d = path.join(__dirname, '../defaults/', dir), toDir = path.join(options.location, dir); @@ -144,21 +138,22 @@ replaceTitle : function(options, items, callback) { }); stack.done(function() { log.info('directories created, processing files'); - mods.replaceTitle(options, copied, function() { - mods.createJSON(options, function() { + replaceTitle(options, copied, function() { + createJSON(options, function() { callback(); }); }); }); - }, - init : function (options, callback) { +}; + +var init = function(options, callback) { var start = (new Date()).getTime(); log.info('creating module (' + options.name + ') in: ' + options.location); if (util.exists(options.location)) { log.bail('destination already exists, you are on your own! bailing..'); } - - this.createDirs(options, function () { + + createDirs(options, function() { util.tree(options.location, options.root, function(tree) { log.log(''); log.info('module created, here\'s what yogi did for you:'); @@ -168,10 +163,10 @@ replaceTitle : function(options, items, callback) { callback(); }); }); - } }; -util.mix(exports, mods); - - - +module.exports = { + init: init, + createJSON: createJSON, + createDirs: createDirs +} \ No newline at end of file From 2960a5abd49068568b161df4552c4059a73d7f86 Mon Sep 17 00:00:00 2001 From: dariel Date: Tue, 27 Aug 2013 23:13:46 -0430 Subject: [PATCH 10/12] refactoring --- lib/create.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/create.js b/lib/create.js index 9e149fa..462afa5 100644 --- a/lib/create.js +++ b/lib/create.js @@ -164,9 +164,3 @@ var init = function(options, callback) { }); }); }; - -module.exports = { - init: init, - createJSON: createJSON, - createDirs: createDirs -} \ No newline at end of file From e9e31329f9410cf96c2195fbd64b7f58ae167b59 Mon Sep 17 00:00:00 2001 From: dariel Date: Tue, 27 Aug 2013 23:14:06 -0430 Subject: [PATCH 11/12] refactoring --- lib/create.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/create.js b/lib/create.js index 462afa5..0df7017 100644 --- a/lib/create.js +++ b/lib/create.js @@ -164,3 +164,9 @@ var init = function(options, callback) { }); }); }; + +module.exports = { + init: init, + createJSON: createJSON, + createDirs: createDirs +} From bc3f23846d0e649b0d7f12be75cafa9c579429db Mon Sep 17 00:00:00 2001 From: dariel Date: Tue, 27 Aug 2013 23:22:20 -0430 Subject: [PATCH 12/12] fixed travis problems --- lib/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/create.js b/lib/create.js index 0df7017..f8811b9 100644 --- a/lib/create.js +++ b/lib/create.js @@ -169,4 +169,4 @@ module.exports = { init: init, createJSON: createJSON, createDirs: createDirs -} +};