Updated the grunt task for making addons to include an option to make assets folder for .less files
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c4a3fcab Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c4a3fcab Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c4a3fcab Branch: refs/heads/fauxton-rebase Commit: c4a3fcab5024cf61ebd5aa0e1ac06dace20138df Parents: 152786d Author: suelockwood <[email protected]> Authored: Fri Feb 15 12:48:11 2013 -0500 Committer: Russell Branca <[email protected]> Committed: Fri Mar 15 14:35:40 2013 -0700 ---------------------------------------------------------------------- src/fauxton/tasks/fauxton.js | 24 ++++++++++++++++++++++-- src/fauxton/writing_addons.md | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/c4a3fcab/src/fauxton/tasks/fauxton.js ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js index a08a561..78b50f3 100644 --- a/src/fauxton/tasks/fauxton.js +++ b/src/fauxton/tasks/fauxton.js @@ -25,6 +25,11 @@ module.exports = function(grunt) { name: "path", message: "Location of add ons", default: "app/addons" + }, + { + name: "assets", + message: "Do you need an assets folder? (for .less)", + default: 'y/N' } ]; @@ -51,14 +56,29 @@ module.exports = function(grunt) { var done = this.async() grunt.helper('prompt', {}, prompts, function (err, result) { if (err) { return onErr(err); } - var module = result.name + grunt.log.writeln(result.assets); + var module = result.name, + assets = result.assets; + if (assets == 'y') { + //if you need an assets folder + filepath = result.path + '/' + module.toLowerCase() + '/assets/less'; + grunt.file.mkdir(filepath); + lessfile = { + name: 'less', + filename: module.toLowerCase()+'.less', + template: '//<%= module %> styles' + } + lessfile.module = module.charAt(0).toUpperCase() + module.substr(1); + var content = grunt.template.process(lessfile.template, lessfile); + grunt.file.write(filepath + '/' + lessfile.filename, content); + } filepath = result.path + '/' + module.toLowerCase() + '/templates'; grunt.file.mkdir(filepath); filepath = result.path + '/' + module.toLowerCase(); _.each(addonTemplates, function(file){ file.module = module.charAt(0).toUpperCase() + module.substr(1); var content = grunt.template.process(file.template, file); - grunt.file.write(filepath + '/' + file.filename, content) + grunt.file.write(filepath + '/' + file.filename, content); }); grunt.log.writeln('Created addon ' + result.name + ' in ' + result.path); done(); http://git-wip-us.apache.org/repos/asf/couchdb/blob/c4a3fcab/src/fauxton/writing_addons.md ---------------------------------------------------------------------- diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md index a41af53..6d3f87b 100644 --- a/src/fauxton/writing_addons.md +++ b/src/fauxton/writing_addons.md @@ -9,6 +9,10 @@ have the following structure: * routes.js - _URL routing for the addon_ * views.js - _views that the model provides_ + [optional] + * assets/less + * my_addon.less + ## Generating an addon We have a grunt task that lets you create a skeleton addon, including all the boiler plate code. Run `bbb addon` and answer the questions it asks to create @@ -21,6 +25,7 @@ an addon: Please answer the following: [?] Add on Name (WickedCool) SuperAddon [?] Location of add ons (app/addons) + [?] Do you need an assets folder?(for .less) (y/N) [?] Do you need to make any changes to the above before continuing? (y/N) Created addon SuperAddon in app/addons
