Commits

John Wright committed 0bca5ea

Upgraded Grunt

Comments (0)

Files changed (5)

src/bin/actions/project/index.coffee

 		images    = path.join assetsDir, 'images'
 		stat      = path.resolve base, 'static'
 
-		async.forEach [coffee, less, js, css, images, stat], mkdirp, callback
+		async.forEach [coffee, less, js, css, images, stat], mkdirp, (err)->
+			if err
+				callback err
+			else
+				fs.writeFile path.join(assetsDir, 'less', 'main.less'), '', callback
 
 	create = (name, callback=->)->
 		pckge = new skeleton.Package
 			(stats, callback)->
 				if stats and stats.isDirectory()
 					program.confirm "\"#{name}\" already exists. Do you want to create the project inside of an existing directory?", (ok)->
-						process.stdin.destroy()
 						callback null, ok
+						process.stdin.destroy()
 				else
 					callback null, yes
 

src/bin/actions/project/skeleton/Config.coffee

 				},
 				"prepublish": {
 					"options": {
-						"paths": "<config:less.dev.options.paths>",
+						"paths": "<%= less.dev.options.paths %>",
 						"compress": true
 					},
-					"files": "<config:less.dev.files>"
+					"files": "<%= less.dev.files %>"
 				}
 			},
 			"coffee": {
-				"dev": {
-					"options": {
-						"base": true
-					},
-					"files": {
-						"assets/js/src/*.js": ["assets/coffee/**/*.coffee"]
-					}
+				"options": {
+					"base": true
+				},
+				"files": {
+					"expand": true,
+					"cwd": "assets/coffee",
+					"src": ["**/*.coffee"],
+					"dest": "assets/js/src/",
+					"ext": ".js"
 				}
 			},
 			"concat": {
-				"js": {
+				"files": {
 					"src": "assets/js/src/**/*.js",
 					"dest": "assets/js/main.js"
 				}
 			},
+			"uglify": {
+				"options": {
+					"mangle": true,
+					"compress": true
+				},
+				"prepublish": {
+					"files": {
+						"assets/js/main.js": "assets/js/main.js"
+					}
+				}
+			},
 			"watcher": {
 				"coffee": {
 					"files": ["assets/coffee/**/*.coffee"],
-					"tasks": ["coffee:dev"]
+					"tasks": ["coffee"]
 				},
 				"less": {
 					"files": ["assets/less/**/*.less"],
 					"tasks": ["less:dev"]
 				},
 				"js": {
-					"files": "<config:concat.js.src>",
-					"tasks": ["concat:js"]
+					"files": "<%= concat.files.src %>",
+					"tasks": ["concat"]
 				}
 			},
+			"load_npm_tasks": ["grunt-contrib-coffee", "grunt-contrib-concat", "grunt-contrib-less", "grunt-contrib-uglify", "grunt-contrib-watch"],
+			"register_tasks": {
+				"watcher:coffee": ["coffee", "watch:coffee"],
+				"watcher:js": ["concat", "watch:js"],
+				"watcher:less": ["less:dev", "watch:less"],
+				"prepublish": ["coffee", "less:prepublish", "uglify"]
+			},
 			"proxy": false
 		}
 		"""

src/bin/actions/project/skeleton/Grunt.coffee

 module.exports = class Grunt extends Base
 
 	filename: ->
-		'grunt.js'
+		'Gruntfile.js'
 
 	content: ->
 		"""
 		module.exports = function(grunt) {
 
 			var gruntConfig = {},
-				key;
+				i, key;
 
 			for(key in config){
 				if(config.hasOwnProperty(key) && key !== 'watch'){
 			}
 
 			grunt.initConfig(util._extend(gruntConfig, {
-				pkg   : '<json:package.json>',
+				pkg   : grunt.file.readJSON('package.json'),
 				watch : gruntConfig.watcher
 			}));
 
-			if(config.less){
-				grunt.loadNpmTasks('grunt-contrib-less');
-
-				if(config.less.dev && config.watcher && config.watcher.less){
-					grunt.registerTask('watcher:less:dev', ['less:dev', 'watch:less']);
-				}
-
-				if(config.less.prepublish){
-					grunt.registerTask('prepublish', ['less:prepublish']);
+			if(gruntConfig.load_npm_tasks){
+				for(i=0; i<gruntConfig.load_npm_tasks.length; i++){
+					grunt.loadNpmTasks(gruntConfig.load_npm_tasks[i]);
 				}
 			}
 
-			if(config.concat && config.watcher.js){
-				grunt.registerTask('watcher:js:dev', ['concat:js', 'watch:js']);
-			}
-
-			if(config.coffee){
-				grunt.loadNpmTasks('grunt-contrib-coffee');
-
-				if(config.coffee.dev && config.watcher && config.watcher.coffee){
-					grunt.registerTask('watcher:coffee:dev', ['coffee:dev', 'watch:coffee']);
+			if(gruntConfig.register_tasks){
+				for(key in gruntConfig.register_tasks){
+					if(gruntConfig.register_tasks.hasOwnProperty(key)){
+						grunt.registerTask(key, gruntConfig.register_tasks[key]);
+					}
 				}
 			}
 

src/bin/actions/project/skeleton/Package.coffee

 			"version": "0.0.0",
 			"description": "Another frontfax environment",
 			"scripts": {
-				"start": "nf start",
-				"prepublish": "grunter prepublish --force"
+				"start": "nf start"
 			},
 			"author": "#{@author}",
 			"dependencies": {
 				"frontfax": "#{pack.version}",
 				"config": "0.4.18",
 				"foreman": "0.0.23",
-				"grunter": "~0.0.1",
-				"grunt-contrib-less": "~0.3.2",
-				"grunt-contrib-coffee": "~0.3.2"
+				"grunt": "~0.4.0",
+				"grunt-cli": "~0.1.6",
+				"grunt-contrib-coffee": "~0.4.0",
+				"grunt-contrib-concat": "~0.1.2",
+				"grunt-contrib-less": "~0.5.0",
+				"grunt-contrib-uglify": "~0.1.1",
+				"grunt-contrib-watch": "~0.2.0"
 			}
 		}
 		"""

src/bin/actions/project/skeleton/Procfile.coffee

 	content: ->
 		"""
 		server: node server
-		coffee: grunter watcher:coffee:dev --force
-		less: grunter watcher:less:dev --force
-		js: grunter watcher:js:dev
+		coffee: grunt watcher:coffee --force
+		less: grunt watcher:less --force
+		js: grunt watcher:js --force
 		"""