Permalink
Browse files

using new grunt-contrib and init tasks

  • Loading branch information...
1 parent 6dea17e commit 6afbef01e105fba07eea3211c55f7dc74bfdff5f @tkellen tkellen committed with tbranyen May 17, 2012
Showing with 7 additions and 369 deletions.
  1. +3 −3 .gitmodules
  2. +1 −1 bin/bbb
  3. +2 −5 package.json
  4. +0 −33 tasks/clean.js
  5. +0 −51 tasks/handlebars.js
  6. +1 −0 tasks/init
  7. +0 −30 tasks/init/bbb.js
  8. +0 −3 tasks/init/bbb/rename.json
  9. +0 −1 tasks/init/bbb/root
  10. +0 −93 tasks/jst.js
  11. +0 −62 tasks/less.js
  12. +0 −29 tasks/mincss.js
  13. +0 −58 tasks/templatize.js
View
@@ -1,3 +1,3 @@
-[submodule "tasks/init/bbb/root"]
- path = tasks/init/bbb/root
- url = git://github.com/tbranyen/backbone-boilerplate.git
+[submodule "tasks/init"]
+ path = tasks/init
+ url = git://github.com/backbone-boilerplate/init.git
View
@@ -1,3 +1,3 @@
#!/usr/bin/env node
-require("grunt").npmTasks("bbb").cli();
+require("grunt").npmTasks(["grunt-contrib", "bbb"]).cli();
View
@@ -17,12 +17,9 @@
},
"dependencies": {
"grunt": "0.3.9",
-
- "rimraf": "1.0.9",
- "less": "1.3.0",
- "clean-css": "0.3.2",
+ "grunt-contrib": "0.0.4",
"requirejs": "2.0.0",
- "express": "2.5.4"
+ "express": "2.5.9"
},
"devDependencies": {
"grunt": "~0.3.0"
View
@@ -1,33 +0,0 @@
-/*
- * Grunt Task File
- * ---------------
- *
- * Task: Clean
- * Description: Remove the contents of a given folder
- * Dependencies: rimraf
- *
- */
-
-module.exports = function(grunt) {
-
- var rimraf = require("rimraf");
- var log = grunt.log;
-
- grunt.registerTask("clean",
- "Deletes out all contents in a directory", function() {
-
- var files = grunt.config("clean");
-
- files.forEach(function(file) {
- grunt.helper("clean", file);
- });
-
- return grunt.errors ? false : true;
- });
-
- grunt.registerHelper("clean", function(path) {
- log.writeln("Removing: " + path);
- rimraf.sync(path);
- });
-
-};
View
@@ -1,51 +0,0 @@
-/*
- * Grunt Task File
- * ---------------
- *
- * Task: Handlebars
- * Description: Compile handlebars templates to JST file
- * Dependencies: None
- *
- */
-
-module.exports = function(grunt) {
-
- var config = grunt.config;
- var file = grunt.file;
- var log = grunt.log;
-
- grunt.registerMultiTask("handlebars",
- "Compile underscore templates to JST file", function() {
-
- // If namespace is specified use that, otherwise fallback
- var namespace = config("meta.handlebars.namespace") || "JST";
-
- // Create JST file.
- var files = file.expand(this.data);
- file.write(this.target, grunt.helper("handlebars", files, namespace));
-
- // Fail task if errors were logged.
- if (grunt.errors) { return false; }
-
- // Otherwise, print a success message.
- log.writeln("File \"" + this.target + "\" created.");
- });
-
- grunt.registerHelper("handlebars", function(files, namespace) {
- namespace = "this['" + namespace + "']";
-
- // Comes out looking like this["JST"] = this["JST"] || {};
- var contents = namespace + " = " + namespace + " || {};\n\n";
-
- // Compile the template and get the function source
- contents += files ? files.map(function(filepath) {
- var templateFunction =
- require("handlebars").precompile(file.read(filepath));
-
- return namespace + "['" + filepath + "'] = " + templateFunction + ";";
- }).join("\n\n") : "";
-
- return contents;
- });
-
-};
Submodule init added at ffdd60
View
@@ -1,30 +0,0 @@
-exports.description = "Backbone Boilerplate framework";
-exports.notes = "This tool will help you install, configure, build, and "
- + "maintain your Backbone Boilerplate project.";
-
-exports.template = function(grunt, init, done) {
-
- // Grunt utilities.
- var task = grunt.task;
- var file = grunt.file;
- var utils = grunt.utils;
- var log = grunt.log;
- var verbose = grunt.verbose;
- var fail = grunt.fail;
- var option = grunt.option;
- var config = grunt.config;
- var template = grunt.template;
- var _ = grunt.utils._;
-
- // Files to copy (and process).
- var files = init.filesToCopy({});
-
- // Actually copy (and process). files.
- init.copyAndProcess(files, {}, {
- noProcess: [ "assets/**", "test/**", "favicon.ico" ]
- });
-
- // All done!
- done();
-
-};
@@ -1,3 +0,0 @@
-{
- ".git": false
-}
Submodule root deleted from 10a6cd
View
@@ -1,93 +0,0 @@
-/*
- * Grunt Task File
- * ---------------
- *
- * Task: JST
- * Description: Compile underscore templates to JST file.
- * Dependencies: underscore
- *
- */
-
-module.exports = function(grunt) {
-
- var file = grunt.file;
- var log = grunt.log;
- var config = grunt.config;
-
- var _ = grunt.utils._;
-
- grunt.registerMultiTask("jst",
- "Compile underscore templates to JST file", function() {
-
- // If namespace is specified use that, otherwise fallback
- var namespace = config("options.jst.namespace") || "JST";
- // If template settings are available use those
- var templateSettings = config("options.jst.templateSettings") || null;
- // Expand files to full paths
- var files = file.expand(this.data);
-
- // Create JST file.
- file.write(this.target, grunt.helper("jst", files, namespace,
- templateSettings));
-
- // Fail task if errors were logged.
- if (grunt.errors) { return false; }
-
- // Otherwise, print a success message.
- log.writeln("File \"" + this.target + "\" created.");
- });
-
- grunt.registerHelper("jst", function(files, namespace, templateSettings) {
- // Pulled from underscore 1.2.4
- function underscoreTemplating(str) {
- // Merge in the templateSettings that may be passed
- var c = _.extend({}, _.templateSettings, templateSettings) ||
- _.templateSettings;
-
- var tmpl = '' +
- 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
- 'with(obj||{}){__p.push(\'' +
- str.replace(/\\/g, '\\\\')
- .replace(/'/g, "\\'")
- .replace(c.escape || noMatch, function(match, code) {
- return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
- })
- .replace(c.interpolate || noMatch, function(match, code) {
- return "'," + code.replace(/\\'/g, "'") + ",'";
- })
- .replace(c.evaluate || noMatch, function(match, code) {
- return "');" + code.replace(/\\'/g, "'")
- .replace(/[\r\n\t]/g, ' ')
- .replace(/\\\\/g, '\\') + ";__p.push('";
- })
- .replace(/\r/g, '\\r')
- .replace(/\n/g, '\\n')
- .replace(/\t/g, '\\t')
- + "');}return __p.join('');";
-
- return new Function('obj', '_', tmpl).toString();
- };
-
- namespace = "this['" + namespace + "']";
-
- // Comes out looking like this["JST"] = this["JST"] || {};
- var contents = namespace + " = " + namespace + " || {};\n\n";
-
- // Compile the template and get the function source
- contents += files ? files.map(function(filepath) {
- var templateFunction = [
- "function(data) { ",
-
- "return ",
- underscoreTemplating(file.read(filepath)).replace("anonymous", ""),
- "(data, _)",
-
- "};"].join("");
-
- return namespace + "['" + filepath + "'] = " + templateFunction;
- }).join("\n\n") : "";
-
- return contents;
- });
-
-};
View
@@ -1,62 +0,0 @@
-/*
- * Grunt Task File
- * ---------------
- *
- * Task: less
- * Description: Compile LESS files to CSS and minify.
- * Dependencies: less
- *
- */
-
-module.exports = function(grunt) {
-
- var file = grunt.file;
- var log = grunt.log;
-
- grunt.registerMultiTask("less",
- "Compile LESS files to CSS.", function() {
-
- // load libraries
- var less = require("less");
- var data = this.data;
-
- // initialize LESS parser
- var parser = new less.Parser();
-
- // make sure task runs until parser is completely finished (imports are processed asynchronously)
- var done = this.async();
-
- // iterate over files to compile/compress
- Object.keys(data.files).forEach(function(dest) {
-
- // grab src file to compile dest to
- var src = data.files[dest];
-
- // run less compiler
- parser.parse(file.read(src), function (err, tree) {
-
- // record error (if any)
- if(err) {
- log.error(err);
- }
-
- // compile less to css
- var css = tree.toCSS(data.options);
-
- // write contents
- grunt.file.write(dest,css);
-
- // flag task as complete
- done();
- });
-
- });
-
- // Fail task if errors were logged.
- if (grunt.errors) { return false; }
-
- // Otherwise, print a success message.
- log.writeln("LESS compilation complete.");
- });
-
-};
View
@@ -1,29 +0,0 @@
-module.exports = function(grunt) {
-
- var log = grunt.log;
- var file = grunt.file;
-
- grunt.registerMultiTask("mincss",
- "Compress down CSS files cleanly.", function() {
-
- // Minify CSS.
- var files = file.expand(this.data);
- file.write(this.target, grunt.helper('mincss', files));
-
- // Fail task if errors were logged.
- if (grunt.errors) { return false; }
-
- // Otherwise, print a success message.
- log.writeln("File \"" + this.target + "\" created.");
- });
-
- grunt.registerHelper("mincss", function(files) {
- var cleanCSS = require("clean-css");
-
- // Minify and combine all CSS
- return files ? files.map(function(filepath) {
- return cleanCSS.process(file.read(filepath));
- }).join("") : "";
- });
-
-};
View
@@ -1,58 +0,0 @@
-/*
- * Grunt Task File
- * ---------------
- *
- * Task: templatize
- * Description: Compile javascript templates with any templating enginej
- * Dependencies: None
- *
- */
-
-module.exports = function(grunt) {
-
- var log = grunt.log;
- var file = grunt.file;
-
- grunt.registerMultiTask("templatize",
- "Compile javascript templates with any templating enginej", function() {
-
- var data = this.data;
- var compiler = data.method;
- var params = data.params||[];
- var namespace = data.namespace || "JST";
- var wrapper = data.wrapper||function(text) { return text; };
-
- // iterate over files to compile
- Object.keys(data.files).forEach(function(dest) {
-
- // initialize template namespace
- var output = ["this['"+namespace+"'] = this['"+namespace+"'] || {};"];
-
- // add supporting library (if required)
- if(data.library) output.push(file.read(data.library));
-
- // grab src file to compile
- var files = file.expand(data.files[dest]);
-
- // iterate templates
- files.forEach(function(filepath) {
- // prepare arguments to pass to compiler
- var args = params.slice();
- args.unshift(file.read(filepath));
- // call compiler function and save to string
- output.push("this['"+namespace+"']['"+filepath+"'] = "+wrapper(compiler.apply(null,args))+";");
- });
-
- // write output to destination
- file.write(dest,output.join("\n"));
- });
-
- // fail task if errors were logged.
- if (grunt.errors) { return false; }
-
- // otherwise, print a success message.
- log.writeln("Javascript templatizing complete.");
-
- });
-
-};

0 comments on commit 6afbef0

Please sign in to comment.