<commit_before>'use strict';

module.exports = function(grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('bower.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= pkg.licenses.map(function(l){return l.type;}).join(", ") %> */\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    frame: {
      options: {
        frame: 'src/frame.js',
      },
      dist: {
        src: ['src/xhr.js',
              'src/api.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
    },
    uglify: {
      options: {
        banner: '<%= banner %>',
        report: 'gzip'
      },
      dist: {
        src: ['dist/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.min.js'
      },
    },
    compress: {
      options: {
        mode: 'gzip'
      },
      dist: {
        src: ['dist/<%= pkg.name %>.min.js'],
        dest: 'dist/<%= pkg.name %>.min.js'
      },
    },
    qunit: {
      files: ['test/**/*.html']
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js',
              '!src/*frame.js']
      },
      dist: {
        options: {
          jshintrc: 'src/.jshintrc-dist'
        },
        src: ['dist/*.js']
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/**/*.js']
      },
    },
    nugetpack: {
        dist: {
            src: '<%= pkg.name %>.nuspec',
            dest: 'dist/',
            options: {
              version: '<%= pkg.version %>'
            }
        }
    },
    nugetpush: {
        dist: {
            src: 'dist/<%= pkg.name %>.<%= pkg.version %>.nupkg'
        }
    }
  });

  grunt.loadTasks('tasks');

  // Default task.
  grunt.registerTask('default', ['clean', 'frame', 'jshint', 'uglify', 'compress', 'qunit']);
  grunt.registerTask('nuget', ['nugetpack', 'nugetpush']);

};
<commit_msg>copy build to docs for demo code<commit_after>'use strict';

module.exports = function(grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('bower.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= pkg.licenses.map(function(l){return l.type;}).join(", ") %> */\n',
    // Task configuration.
    clean: {
      files: ['dist']
    },
    frame: {
      options: {
        frame: 'src/frame.js',
      },
      dist: {
        src: ['src/xhr.js',
              'src/api.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
    },
    copy: {
      docs: {
        src: 'dist/<%= pkg.name %>.js',
        dest: 'docs/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>',
        report: 'gzip'
      },
      dist: {
        src: ['dist/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.min.js'
      },
    },
    compress: {
      options: {
        mode: 'gzip'
      },
      dist: {
        src: ['dist/<%= pkg.name %>.min.js'],
        dest: 'dist/<%= pkg.name %>.min.js'
      },
    },
    qunit: {
      files: ['test/**/*.html']
    },
    jshint: {
      gruntfile: {
        options: {
          jshintrc: '.jshintrc'
        },
        src: 'Gruntfile.js'
      },
      src: {
        options: {
          jshintrc: 'src/.jshintrc'
        },
        src: ['src/**/*.js',
              '!src/*frame.js']
      },
      dist: {
        options: {
          jshintrc: 'src/.jshintrc-dist'
        },
        src: ['dist/*.js']
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/**/*.js']
      },
    },
    nugetpack: {
        dist: {
            src: '<%= pkg.name %>.nuspec',
            dest: 'dist/',
            options: {
              version: '<%= pkg.version %>'
            }
        }
    },
    nugetpush: {
        dist: {
            src: 'dist/<%= pkg.name %>.<%= pkg.version %>.nupkg'
        }
    }
  });

  grunt.loadTasks('tasks');

  // Default task.
  grunt.registerTask('default', ['clean', 'frame', 'jshint', 'uglify', 'compress', 'qunit', 'copy']);
  grunt.registerTask('nuget', ['nugetpack', 'nugetpush']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    config: {
      banner: '/*\n' +
        ' TechanJS v<%= pkg.version %>\n' +
        " (c) 2014 - <%= grunt.template.today('yyyy') %> Andre Dumas | https://github.com/andredumas/techan.js\n" +
        '*/',
      dist: 'techan-<%= pkg.version %>'
    },

    clean: {
      dist: ['dist'],
      build: ['build']
    },

    filegen: {
      version: {
        options: {
          content: "'use strict';module.exports='<%= pkg.version %>';"
        },
        dest: 'build/version.js'
      }
    },

    browserify: {
      dev: {
        options: {
          // Thanks https://github.com/amitayd/grunt-browserify-jasmine-node-example/blob/2488181e29b09226f2a87202a851f996820eafb6/Gruntfile.js#L51
          require: grunt.file.expand({filter: 'isFile'}, './src/**/*.js', './<%= filegen.version.dest %>'),
          bundleOptions: {
            debug: true
          }
        },
        src: 'src/techan.js',
        dest: 'build/techan-bundle.js'
      },
      test: {
        options: {
          external: ['src/**/*.js'],
          bundleOptions: {
            debug: true
          }
        },
        src: ['test/spec/bundle/**/*.js'],
        dest: 'build/specs-bundle.js'
      },
      dist: {
        options: {
          bundleOptions: {
            standalone: 'techan'
          }
        },
        src: 'src/techan.js',
        dest: 'dist/techan.js'
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= config.banner %>',
        linebreak: true
      },
      dist: {
        files: {
          src: '<%= browserify.dist.dest %>'
        }
      }
    },

    jsonlint: {
      bower: {
        src: ['bower.json']
      },
      dist: {
        src: ['package.json']
      }
    },

    jshint: {
      options: {
        jshintrc: ".jshintrc"
      },
      dev: {
        src: ['src/**/*.js', 'lib/**/*.js', 'Gruntfile.js', 'test/**/*.js', '<%= filegen.version.dest %>']
      }
    },

    jscs: {
      options: {
        config: '.jscs.json'
      },
      dev: ['src/**/*.js', 'Gruntfile.js', 'test/**/*.js', '<%= filegen.version.dest %>']
    },

    watch: {
      files: '<%= jshint.dev.src %>',
      tasks: ['dev', 'dist']
    },

    jasmine: {
      options: {
        vendor: ['bower_components/d3/d3.js', 'test/spec/common/**/*.js'],
        keepRunner: true
      },
      test: {
        options: {
          specs: '<%= browserify.test.dest %>',
          outfile: 'build/bundleSpecRunner.html'
        },
        src: '<%= browserify.dev.dest %>'
      },
      dist: {
        options: {
          specs: 'test/spec/standalone/**/*.js',
          outfile: 'build/standaloneSpecRunner.html'
        },
        src: '<%= browserify.dist.dest %>'
      },
      minify: {
        options: {
          specs: 'test/spec/standalone/**/*.js',
          outfile: 'build/standaloneMinSpecRunner.html'
        },
        src: '<%= uglify.dist.dest %>'
      }
    },

    uglify: {
      options: {
        banner: '<%= config.banner %>',
        sourceMap: true,
        report: 'min'
      },
      dist: {
        src: '<%= browserify.dist.dest %>',
        dest: 'dist/techan.min.js'
      }
    },

    compress: {
      dist: {
        options: {
          archive: 'dist/techan.zip'
        },
        expand: true,
        cwd: 'dist',
        src: ['*.js*'],
        dest: '<%= config.dist %>'
      }
    },

    bump: {
      options: {
        commit: true,
        commitMessage: 'Release %VERSION%',
        commitFiles: ['-a'],
        createTag: true,
        tagName: '%VERSION%',
        tagMessage: '%VERSION%',
        push: false
      }
    },

    connect: {
      server: {}
    }
  });

  require('load-grunt-tasks')(grunt);
  grunt.loadTasks('lib/grunt');

  grunt.registerTask('lint', ['jshint', 'jscs']);
  grunt.registerTask('dev', ['filegen:version', 'lint', 'browserify:dev', 'browserify:test', 'jasmine:test']);
  grunt.registerTask('dist', ['browserify:dist', 'usebanner', 'jasmine:dist']);
  grunt.registerTask('minify', ['uglify', 'jasmine:minify']);
  grunt.registerTask('serve', ['connect', 'watch']);
  grunt.registerTask('prerelease', ['bump-only:prerelease', 'default']);
  // Test on next release
//  grunt.registerTask('release:minor', ['bump-only:minor', 'default', 'bump-commit']);
//  grunt.registerTask('release:major', ['bump-only:major', 'default', 'bump-commit']);

  grunt.registerTask('default', ['jsonlint', 'bower', 'clean', 'dev', 'dist', 'minify', 'compress']);
};<commit_msg>Release task rename<commit_after>module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    config: {
      banner: '/*\n' +
        ' TechanJS v<%= pkg.version %>\n' +
        " (c) 2014 - <%= grunt.template.today('yyyy') %> Andre Dumas | https://github.com/andredumas/techan.js\n" +
        '*/',
      dist: 'techan-<%= pkg.version %>'
    },

    clean: {
      dist: ['dist'],
      build: ['build']
    },

    filegen: {
      version: {
        options: {
          content: "'use strict';module.exports='<%= pkg.version %>';"
        },
        dest: 'build/version.js'
      }
    },

    browserify: {
      dev: {
        options: {
          // Thanks https://github.com/amitayd/grunt-browserify-jasmine-node-example/blob/2488181e29b09226f2a87202a851f996820eafb6/Gruntfile.js#L51
          require: grunt.file.expand({filter: 'isFile'}, './src/**/*.js', './<%= filegen.version.dest %>'),
          bundleOptions: {
            debug: true
          }
        },
        src: 'src/techan.js',
        dest: 'build/techan-bundle.js'
      },
      test: {
        options: {
          external: ['src/**/*.js'],
          bundleOptions: {
            debug: true
          }
        },
        src: ['test/spec/bundle/**/*.js'],
        dest: 'build/specs-bundle.js'
      },
      dist: {
        options: {
          bundleOptions: {
            standalone: 'techan'
          }
        },
        src: 'src/techan.js',
        dest: 'dist/techan.js'
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= config.banner %>',
        linebreak: true
      },
      dist: {
        files: {
          src: '<%= browserify.dist.dest %>'
        }
      }
    },

    jsonlint: {
      bower: {
        src: ['bower.json']
      },
      dist: {
        src: ['package.json']
      }
    },

    jshint: {
      options: {
        jshintrc: ".jshintrc"
      },
      dev: {
        src: ['src/**/*.js', 'lib/**/*.js', 'Gruntfile.js', 'test/**/*.js', '<%= filegen.version.dest %>']
      }
    },

    jscs: {
      options: {
        config: '.jscs.json'
      },
      dev: ['src/**/*.js', 'Gruntfile.js', 'test/**/*.js', '<%= filegen.version.dest %>']
    },

    watch: {
      files: '<%= jshint.dev.src %>',
      tasks: ['dev', 'dist']
    },

    jasmine: {
      options: {
        vendor: ['bower_components/d3/d3.js', 'test/spec/common/**/*.js'],
        keepRunner: true
      },
      test: {
        options: {
          specs: '<%= browserify.test.dest %>',
          outfile: 'build/bundleSpecRunner.html'
        },
        src: '<%= browserify.dev.dest %>'
      },
      dist: {
        options: {
          specs: 'test/spec/standalone/**/*.js',
          outfile: 'build/standaloneSpecRunner.html'
        },
        src: '<%= browserify.dist.dest %>'
      },
      minify: {
        options: {
          specs: 'test/spec/standalone/**/*.js',
          outfile: 'build/standaloneMinSpecRunner.html'
        },
        src: '<%= uglify.dist.dest %>'
      }
    },

    uglify: {
      options: {
        banner: '<%= config.banner %>',
        sourceMap: true,
        report: 'min'
      },
      dist: {
        src: '<%= browserify.dist.dest %>',
        dest: 'dist/techan.min.js'
      }
    },

    compress: {
      dist: {
        options: {
          archive: 'dist/techan.zip'
        },
        expand: true,
        cwd: 'dist',
        src: ['*.js*'],
        dest: '<%= config.dist %>'
      }
    },

    bump: {
      options: {
        commit: true,
        commitMessage: 'Release %VERSION%',
        commitFiles: ['-a'],
        createTag: true,
        tagName: '%VERSION%',
        tagMessage: '%VERSION%',
        push: false
      }
    },

    connect: {
      server: {}
    }
  });

  require('load-grunt-tasks')(grunt);
  grunt.loadTasks('lib/grunt');

  grunt.registerTask('lint', ['jshint', 'jscs']);
  grunt.registerTask('dev', ['filegen:version', 'lint', 'browserify:dev', 'browserify:test', 'jasmine:test']);
  grunt.registerTask('dist', ['browserify:dist', 'usebanner', 'jasmine:dist']);
  grunt.registerTask('minify', ['uglify', 'jasmine:minify']);
  grunt.registerTask('serve', ['connect', 'watch']);
  grunt.registerTask('release:pre', ['bump-only:prerelease', 'default']);
  grunt.registerTask('release:minor', ['bump-only:minor', 'default', 'bump-commit']);
  grunt.registerTask('release:major', ['bump-only:major', 'default', 'bump-commit']);

  grunt.registerTask('default', ['jsonlint', 'bower', 'clean', 'dev', 'dist', 'minify', 'compress']);
};<|endoftext|>


<commit_before>/*
 * Generated on 2014-04-16
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: require('./package'),
        bower: require('./bower'),
        deploy: {
            'build_branch': 'gh-pages',
            dist: '<%= directories.build.base %>'
        }
        directories: {
            base: 'src',
            assets: {
                base: 'src/assets',
                js: 'src/assets/scripts',
                styles: 'src/assets/styles',
                fonts: 'src/assets/fonts'
            },
            build: {
                base: 'dist',
                assets: 'dist/assets'
            },
            bower: 'src/bower_components'
        },
        files: {
            js: [
                'Gruntfile.js',
                'grunt/{,*/}*.js',
                '<%= directories.assets.js %>/**/*.js',
                '!<%= directories.assets.js %>/vendor/*',

            ],
            json: [
                '*.json',
                '<%= directories.base %>/data/{,*/}*.json'
            ]
        }
    });

    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load grunt tasks "just in time"
    require('jit-grunt')(grunt);

    grunt.loadTasks('grunt/tasks');

    grunt.registerTask('default', [
        'lint',
        'clean:html',
        'build'
    ]);
};
<commit_msg>And this is why I need a pre-commit task<commit_after>/*
 * Generated on 2014-04-16
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: require('./package'),
        bower: require('./bower'),
        deploy: {
            'build_branch': 'gh-pages',
            dist: '<%= directories.build.base %>'
        },
        directories: {
            base: 'src',
            assets: {
                base: 'src/assets',
                js: 'src/assets/scripts',
                styles: 'src/assets/styles',
                fonts: 'src/assets/fonts'
            },
            build: {
                base: 'dist',
                assets: 'dist/assets'
            },
            bower: 'src/bower_components'
        },
        files: {
            js: [
                'Gruntfile.js',
                'grunt/{,*/}*.js',
                '<%= directories.assets.js %>/**/*.js',
                '!<%= directories.assets.js %>/vendor/*',

            ],
            json: [
                '*.json',
                '<%= directories.base %>/data/{,*/}*.json'
            ]
        }
    });

    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load grunt tasks "just in time"
    require('jit-grunt')(grunt);

    grunt.loadTasks('grunt/tasks');

    grunt.registerTask('default', [
        'lint',
        'clean:html',
        'build'
    ]);
};
<|endoftext|>


<commit_before>/*!
 *
 * Grunt Task configuration for MY BIG project
 *
 * Assumptions:
 * - Using Sass
 * - Enabled CSS source maps in Chrome
 */

'use strict';

/**
 * Livereload and connect variables
 */
var LIVERELOAD_PORT = 35729,
	lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT}),
	mountFolder = function(connect, dir) {
		return connect.static(require('path').resolve(dir));
	};

/**
 * Grunt module
 */
module.exports = function(grunt) {

	/**
	 * Dynamically load npm tasks
	 */
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	/**
	 * Grunt config
	 */
	grunt.initConfig({

		//
		// Meta
		//

		pkg: grunt.file.readJSON('package.json'),

		/**
		 * Set project info
		 */
		project: {
			src: 'src/',
			assets: '<%= project.src %>',
			cssDir: '<%= project.assets %>css/',
			scss: '<%= project.cssDir %>sass/style.scss',
			jsDir: ['<%= project.assets %>js/'],
			build: 'build'
		},

		/**
		 * Project banner
		 * Dynamically appended to styles/JS files
		 * Inherits text from package.json
		 */
		banner: '/*!\n' +
		' * <%= pkg.name %>\n' +
		' * <%= pkg.title %>\n' +
		' * <%= pkg.url %>\n' +
		' * @author <%= pkg.author %>\n' +
		' * @version <%= pkg.version %>\n' +
		' * Copyright (c) <%= grunt.template.today("yyyy") %>\n' +
		' */\n',

		//
		// Server Related Tasks
		//

		/**
		 * Connect port/livereload
		 * https://github.com/gruntjs/grunt-contrib-connect
		 * Starts a local webserver and injects
		 * livereload snippet
		 */
		connect: {
			options: {
				port: 9000,
				hostname: '*'
			},
			livereload: {
				options: {
					middleware: function(connect) {
						return [
							lrSnippet,
							mountFolder(connect, 'src')
						];
					}
				}
			}
		},

		/**
		 * Opens the web server in the browser
		 * https://github.com/jsoverson/grunt-open
		 */
		open: {
			server: {
				path: 'http://localhost:<%= connect.options.port %>',
				app: 'Google Chrome'
			}
		},

		//
		// JS Tasks
		//

		/**
		 * JSHint
		 * https://github.com/gruntjs/grunt-contrib-jshint
		 * Manage the options inside .jshintrc file
		 */
		jshint: {
			files: ['<%= project.jsDir %>script.js', 'Gruntfile.js'],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		/**
		 * Concatenate JavaScript files
		 * https://github.com/gruntjs/grunt-contrib-concat
		 * Imports all .js files and appends project banner
		 */
		concat: {
			dev: {
				files: {
					'<%= project.jsDir %>scripts.min.js': [
						'<%= project.jsDir %>script.js'
						// more files added to array as needed
					]
				}
			},
			options: {
				stripBanners: true,
				nonull: true,
				banner: '<%= banner %>'
			}
		},

		/**
		 * Uglify (minify) JavaScript files
		 * https://github.com/gruntjs/grunt-contrib-uglify
		 * Compresses and minifies all JavaScript files into one
		 */
		uglify: {
			options: {
				preserveComments: false,
				banner: '<%= banner %>'
			},
			build: {
				files: {
				'<%= project.build %>/js/scripts.min.js': '<%= project.jsDir %>scripts.min.js'
				}
			}
		},

		//
		// CSS Tasks
		//

		/**
		 * Compile Sass/SCSS files
		 * https://github.com/gruntjs/grunt-contrib-sass
		 * Compiles all Sass/SCSS files and appends project banner
		 */
		sass: {
			dev: {
				options: {
					style: 'expanded',
					banner: '<%= banner %>',
					lineNumbers: true,
					sourcemap: true
				},
				files: {
					'<%= project.cssDir %>style.unprefixed.css': '<%= project.scss %>'
				}
			}
		},

		/**
		 * Autoprefixer
		 * Adds vendor prefixes automatically
		 * https://github.com/nDmitry/grunt-autoprefixer
		 */
		autoprefixer: {
			options: {
				browsers: ['last 2 version', 'safari 6', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'],
				map: true
			},
			dev: {
				files: {
					'<%= project.cssDir %>style.min.css': ['<%= project.cssDir %>style.unprefixed.css']
				}
			}
		},

		/**
		 * CSSMin
		 * CSS minification
		 * https://github.com/gruntjs/grunt-contrib-cssmin
		 */
		cssmin: {
			build: {
				options: {
					banner: '<%= banner %>'
				},
				files: {
					'<%= project.build %>style.min.css': ['<%= project.cssDir %>style.min.css']
				}
			}
		},

		//
		// Housekeeping
		//

		/**
		 * Copies files to the build dir
		 * https://github.com/gruntjs/grunt-contrib-copy
		 */
		copy: {
			build: {
				files: [
					{
						expand: true,
						cwd: '<%= project.assets %>',
						src: ['*', 'images/*'],
						dest: '<%= project.build %>/'
					}
				]
			}
		},

		/**
		 * Clean files and folders
		 * https://github.com/gruntjs/grunt-contrib-clean
		 * Remove generated files for clean deploy
		 */
		clean: {
			build: ['<%= project.cssDir %>style.unprefixed.css', '<%= project.cssDir %>style.prefixed.css']
		},

		/**
		 * Runs tasks against changed watched files
		 * https://github.com/gruntjs/grunt-contrib-watch
		 * Watching development files and run concat/compile tasks
		 * Livereload the browser once complete
		 */
		watch: {
			concat: {
				files: ['<%= project.src %>/js/{,*/}*.js'],
				tasks: ['concat:dev']
				options: {
					spawn: false,
					livereload: true
				}
			},
			sass: {
				files: ['<%= project.src %>/styles/sass/{,*/}*.{scss,sass}'],
				tasks: ['sass:dev', 'autoprefixer:dev']
				options: {
					spawn: false,
					livereload: true
				}
			},
			livereload: {
				files: [
					'<%= project.src %>{,*/}*.html',
					'<%= project.assets %>{,*/}*.{min.css, min.js}',
					'<%= project.assets %>{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
				],
				options: {
					livereload: LIVERELOAD_PORT
				}
			}
		}
	});

	//
	// Tasks Registry
	//

	/**
	 * Default task
	 * Run `grunt` on the command line
	 */
	grunt.registerTask('default', ['sass:dev', 'autoprefixer:dev', 'concat:dev', 'connect:livereload', 'open', 'watch']);

	/**
	 * Build task
	 * Run `grunt build` on the command line
	 * Then compress all JS/CSS files
	 */
	grunt.registerTask('build', ['sass:dev', 'autoprefixer:dev', 'cssmin:build', 'concat:dev', 'jshint', 'uglify', 'copy:build']);
};
<commit_msg>Refining Gruntfile.js with src, build, dist directory structure; adding build and deploy tasks<commit_after>/*!
 *
 * Grunt Task configuration for MY BIG project
 *
 * Assumptions:
 * - Using Sass
 * - Enabled CSS source maps in Chrome
 */

'use strict';

/**
 * Livereload and connect variables
 */
var LIVERELOAD_PORT = 35729,
	lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT}),
	mountFolder = function(connect, dir) {
		return connect.static(require('path').resolve(dir));
	};

/**
 * Grunt module
 */
module.exports = function(grunt) {

	/**
	 * Dynamically load npm tasks
	 */
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	/**
	 * Grunt config
	 */
	grunt.initConfig({

		//
		// Meta
		//

		pkg: grunt.file.readJSON('package.json'),

		/**
		 * Set project info
		 */
		project: {
			src: 			'src/',
			build: 			'build/',
			dist: 			'dist/',

			srcHtmlDir: 	'<%= project.src %>html/',
			srcSassDir: 	'<%= project.src %>sass/',
			srcScss: 		'<%= project.srcSassDir %>style.scss',
			srcJsDir: 		'<%= project.src %>javascript/',

			buildAssets: 	'<%= project.build %>assets/',
			buildCssDir: 	'<%= project.buildAssets %>css/',
			buildJsDir: 	'<%= project.buildAssets %>js/',

			distAssets: 	'<%= project.dist %>assets/',
			distCssDir: 	'<%= project.distAssets %>css/',
			distJsDir: 		'<%= project.distAssets %>js/'
		},

		/**
		 * Project banner
		 * Dynamically appended to styles/JS files
		 * Inherits text from package.json
		 */
		banner: '/*!\n' +
		' * <%= pkg.name %>\n' +
		' * <%= pkg.title %>\n' +
		' * <%= pkg.url %>\n' +
		' * @author <%= pkg.author %>\n' +
		' * @version <%= pkg.version %>\n' +
		' * Copyright (c) <%= grunt.template.today("yyyy") %>\n' +
		' */\n',

		//
		// Server Related Tasks
		//

		/**
		 * Connect port/livereload
		 * https://github.com/gruntjs/grunt-contrib-connect
		 * Starts a local webserver and injects
		 * livereload snippet
		 */
		connect: {
			options: {
				port: 9000,
				hostname: '*'
			},
			livereload: {
				options: {
					middleware: function(connect) {
						return [
							lrSnippet,
							mountFolder(connect, 'build')
						];
					}
				}
			}
		},

		/**
		 * Opens the web server in the browser
		 * https://github.com/jsoverson/grunt-open
		 */
		open: {
			server: {
				path: 'http://localhost:<%= connect.options.port %>',
				app: 'Google Chrome'
			}
		},

		//
		// JS Tasks
		//

		/**
		 * JSHint
		 * https://github.com/gruntjs/grunt-contrib-jshint
		 * Manage the options inside .jshintrc file
		 */
		jshint: {
			files: ['<%= project.srcJsDir %>{,*/}*.js', 'Gruntfile.js'],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		/**
		 * Concatenate JavaScript files
		 * https://github.com/gruntjs/grunt-contrib-concat
		 * Imports and combines all JavaScript files into one and appends project banner
		 */
		concat: {
			dev: {
				files: {
					'<%= project.buildJsDir %>scripts.min.js': [ // appended with .min, but not minified for dev build
						'<%= project.srcJsDir %>{,*/}*.js'
						// more files added to array as needed
					]
				}
			},
			options: {
				stripBanners: true,
				nonull: true,
				banner: '<%= banner %>'
			}
		},

		/**
		 * Uglify (minify) JavaScript files
		 * https://github.com/gruntjs/grunt-contrib-uglify
		 * Compresses / minifies JavaScript build file, copies to dist JS dir
		 */
		uglify: {
			options: {
				preserveComments: false,
				banner: '<%= banner %>'
			},
			deploy: {
				files: {
				'<%= project.distJsDir %>scripts.min.js': '<%= project.buildJsDir %>scripts.min.js'
				}
			}
		},

		//
		// CSS Tasks
		//

		/**
		 * Compile Sass/SCSS files
		 * https://github.com/gruntjs/grunt-contrib-sass
		 * Compiles all Sass/SCSS files and appends project banner
		 */
		sass: {
			dev: {
				options: {
					style: 'expanded',
					banner: '<%= banner %>',
					lineNumbers: true,
					sourcemap: true
				},
				files: {
					'<%= project.buildCssDir %>style.unprefixed.css': '<%= project.srcScss %>'
				}
			}
		},

		/**
		 * Autoprefixer
		 * Adds vendor prefixes automatically
		 * https://github.com/nDmitry/grunt-autoprefixer
		 */
		autoprefixer: {
			options: {
				browsers: ['last 2 version', 'safari 6', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'],
				map: true
			},
			dev: {
				files: {
					'<%= project.buildCssDir %>style.css': ['<%= project.buildCssDir %>style.unprefixed.css']
				}
			}
		},

		/**
		 * CSSMin
		 * Minification of CSS build file, copies to dist CSS dir
		 * https://github.com/gruntjs/grunt-contrib-cssmin
		 */
		cssmin: {
			deploy: {
				options: {
					banner: '<%= banner %>'
				},
				files: {
					'<%= project.distCssDir %>style.css': ['<%= project.buildCssDir %>style.css']
				}
			}
		},

		//
		// Housekeeping
		//

		/**
		 * Copies files to the build & dist dirs
		 * https://github.com/gruntjs/grunt-contrib-copy
		 */
		copy: {
			// HTML from src dir to build dir
			toBuildHtml: {
				files: [
					{
						cwd: '<%= project.srcHtmlDir %>',
						expand: true,
						src: '**/*',
						dest: '<%= project.build %>'
					}
				]
			},

			// All HTML and image assets from build dir to dist dir
			toDist: {
				files: [
					// image assets
					{
						cwd: '<%= project.buildAssets %>images',
						expand: true,
						src: [
							'**/*'
							// more files added to array as needed
							],
						dest: '<%= project.distAssets %>images'
					},
					// html
					{
						cwd: '<%= project.build %>',
						expand: true,
						src: [
							'{,*/}*.html'
						],
						dest: '<%= project.dist %>'
					}
				]
			}

		},

		/**
		 * Clean files and folders
		 * https://github.com/gruntjs/grunt-contrib-clean
		 * Remove generated files for clean deploy
		 */
		clean: {
			//build: ['<%= project.cssDir %>style.unprefixed.css', '<%= project.cssDir %>style.prefixed.css']
		},

		/**
		 * Runs tasks against changed watched files
		 * https://github.com/gruntjs/grunt-contrib-watch
		 * Watching development files and run concat/compile tasks
		 * Livereload the browser once complete
		 */
		watch: {
			js: {
				files: ['<%= project.srcJsDir %>{,*/}*.js'],
				tasks: ['jshint', 'concat:dev'],
				options: {
					spawn: false,
					livereload: true
				}
			},
			sass: {
				files: ['<%= project.srcSassDir %>{,*/}*.{scss,sass}'],
				tasks: ['sass:dev', 'autoprefixer:dev'],
				options: {
					spawn: false,
					livereload: true
				}
			},
			html: {
				files: ['<%= project.srcHtmlDir %>{,*/}*.html'],
				tasks: ['copy:toBuildHtml'],
				options: {
					spawn: false,
					livereload: true
				}
			},
			livereload: {
				files: [
					'<%= project.build %>{,*/}*.html',
					'<%= project.buildAssets %>{,*/}*.{css, js}',
					'<%= project.buildAssets %>{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
				],
				options: {
					livereload: LIVERELOAD_PORT
				}
			}
		}
	});

	//
	// Tasks Registry
	//

	/**
	 * Default task
	 * Run `grunt` on the command line
	 */
	grunt.registerTask('default', ['copy:toBuildHtml', 'sass:dev', 'autoprefixer:dev', 'jshint', 'concat:dev', 'connect:livereload', 'open', 'watch']);

	/**
	 * Deploy task
	 * Run `grunt deploy` on the command line
	 * Then compress all JS/CSS files
	 */
	grunt.registerTask('deploy', ['sass:dev', 'autoprefixer:dev', 'cssmin:build', 'jshint', 'concat:dev', 'uglify', 'copy:toDist']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	var appConfig = grunt.file.readJSON('package.json');

	// Load grunt tasks automatically
	// see: https://github.com/sindresorhus/load-grunt-tasks
	require('load-grunt-tasks')(grunt);

	// Time how long tasks take. Can help when optimizing build times
	// see: https://npmjs.org/package/time-grunt
	require('time-grunt')(grunt);

	var pathsConfig = function (appName) {
		this.app = appName || appConfig.name;

		return {
			app: this.app,
			foundation: this.app + '/../../bower_components/foundation/scss',
			templates: this.app + '/templates',
			css: this.app + '/static/css',
			sass: this.app + '/static/scss',
			fonts: this.app + '/static/fonts',
			images: this.app + '/static/img',
			js: this.app + '/static/js',
			manageScript: this.app + '/manage.py',
			serverScript: this.app + '/server.py'
		};
	};

	grunt.initConfig({
		pkg: appConfig,
		paths: pathsConfig('src/keybar'),

		sass: {
			options: {
				includePaths: ['<%= paths.foundation %>'],
			},
			dist: {
				options: {
					outputStyle: 'expanded'
				},

				files: [{
					expand: true,
					cwd: '<%= paths.sass %>',
					src: ['app.scss'],
					dest: '<%= paths.css %>',
					ext: '.css'
				}]
			}
		},
		watch: {
			options: {
				livereload: {
					key: grunt.file.read('extras/certificates/server.key'),
					cert: grunt.file.read('extras/certificates/server.crt')
				},
			},
			src: {
				files: ['<%= paths.js %>**/*', '<%= paths.sass %>**/*'],
				tasks: ['default'],
			},
		},
		lintspaces: {
			all: {
				src: [
					'<%= paths.js %>',
					'<%= paths.sass %>'
				],
				options: {
					editorconfig: '.editorconfig'
				}
			},
			javascript: {
				src: ['<%= paths.js %>/src/*.js'],
				options: {
					editorconfig: '.editorconfig'
				}
			},
			external: {
				src: [
					'<%= paths.app %>/**/*',
					'!<%= paths.app %>/static/*.ico',
					'!<%= paths.images %>/*',
					'!<%= paths.fonts %>/*',
					'!<%= paths.js %>/src/libs/*',
					'!<%= paths.app %>/**/djangojs.js'
				],
				options: {
					editorconfig: '.editorconfig'
				}
			}
		},
		jshint: {
			all: ['Gruntfile.js', '<%= paths.js %>/*.js']
		},
		jscs: {
			all: {
				options: {
					'standard': 'Jquery'
				},
				files: {
					src: ['tasks']
				}
			}
		},
		clean: {
			build: {
				src: [
					'<%= paths.js %>/build/**/*',
					'<%= paths.css %>/**/*'
				]
			}
		}
	});

	grunt.registerTask(
		'default',
		'Run all tasks in a row.',
		['build']
	);

	grunt.registerTask(
		'validate',
		'Validate all files.',
		['jshint', 'jscs', 'lintspaces']
	);

	grunt.registerTask(
		'test',
		'Run JS tests.',
		[]
	);

	grunt.registerTask(
		'build',
		'Build all JS files for a deploy.',
		['validate', 'clean:build', 'sass']
	);
};
<commit_msg>Allow tornado server to be run via new 'grunt serve' task.<commit_after>module.exports = function(grunt) {
	var appConfig = grunt.file.readJSON('package.json');

	// Load grunt tasks automatically
	// see: https://github.com/sindresorhus/load-grunt-tasks
	require('load-grunt-tasks')(grunt);

	// Time how long tasks take. Can help when optimizing build times
	// see: https://npmjs.org/package/time-grunt
	require('time-grunt')(grunt);

	var pathsConfig = function (appName) {
		this.app = appName || appConfig.name;

		return {
			app: this.app,
			foundation: this.app + '/../../bower_components/foundation/scss',
			templates: this.app + '/templates',
			css: this.app + '/static/css',
			sass: this.app + '/static/scss',
			fonts: this.app + '/static/fonts',
			images: this.app + '/static/img',
			js: this.app + '/static/js',
			manageScript: this.app + '/../../manage.py',
			serverScript: this.app + '/server.py'
		};
	};

	grunt.initConfig({
		pkg: appConfig,
		paths: pathsConfig('src/keybar'),

		sass: {
			options: {
				includePaths: ['<%= paths.foundation %>'],
			},
			dist: {
				options: {
					outputStyle: 'expanded'
				},

				files: [{
					expand: true,
					cwd: '<%= paths.sass %>',
					src: ['app.scss'],
					dest: '<%= paths.css %>',
					ext: '.css'
				}]
			}
		},
		watch: {
			options: {
				livereload: {
					key: grunt.file.read('extras/certificates/server.key'),
					cert: grunt.file.read('extras/certificates/server.crt')
				},
			},
			src: {
				files: ['<%= paths.js %>**/*', '<%= paths.sass %>**/*'],
				tasks: ['default'],
			},
		},
		lintspaces: {
			all: {
				src: [
					'<%= paths.js %>',
					'<%= paths.sass %>'
				],
				options: {
					editorconfig: '.editorconfig'
				}
			},
			javascript: {
				src: ['<%= paths.js %>/src/*.js'],
				options: {
					editorconfig: '.editorconfig'
				}
			},
			external: {
				src: [
					'<%= paths.app %>/**/*',
					'!<%= paths.app %>/static/*.ico',
					'!<%= paths.images %>/*',
					'!<%= paths.fonts %>/*',
					'!<%= paths.js %>/src/libs/*',
					'!<%= paths.app %>/**/djangojs.js'
				],
				options: {
					editorconfig: '.editorconfig'
				}
			}
		},
		jshint: {
			all: ['Gruntfile.js', '<%= paths.js %>/*.js']
		},
		jscs: {
			all: {
				options: {
					'standard': 'Jquery'
				},
				files: {
					src: ['tasks']
				}
			}
		},
		clean: {
			build: {
				src: [
					'<%= paths.js %>/build/**/*',
					'<%= paths.css %>/**/*'
				]
			}
		},

		// see: https://npmjs.org/package/grunt-bg-shell
		bgShell: {
			_defaults: {
				bg: true
			},
			runDjango: {
				cmd: 'python <%= paths.manageScript %> runserver'
			},
			runTornado: {
				cmd: 'python <%= paths.serverScript %>'
			}
		}
	});

	grunt.registerTask(
		'default',
		'Run all tasks in a row.',
		['build']
	);

	grunt.registerTask(
		'validate',
		'Validate all files.',
		['jshint', 'jscs', 'lintspaces']
	);

	grunt.registerTask(
		'test',
		'Run JS tests.',
		[]
	);

	grunt.registerTask(
		'build',
		'Build all JS files for a deploy.',
		['validate', 'clean:build', 'sass']
	);

	grunt.registerTask('serve', [
		'bgShell:runTornado',
		'watch'
	]);
};
<|endoftext|>


<commit_before>
'use strict';

var request = require('request');

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    var _ = require('underscore')._;

    var reloadPort = 35729, files;

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        browserify: {
            options: {
                debug: true,
                extensions: ['.jsx'],
                transform: ['reactify']
            },

            devApp: {
                options: {
                    alias: ['react:']  // Make React available externally for dev tools
                },
                src: ['./public/js/app.js'],
                dest: './dist/app/bundle.js'
            },

            prodApp: {
                options: {
                    debug: false
                },
                src: '<%= browserify.devApp.src %>',
                dest: '<%= browserify.devApp.dest %>'
            }
        },

        build: {
            app: {
                options: {
                    developTasks: ['browserify:devApp', 'stylus:devApp', 'copy:app'],
                    productionTasks: ['browserify:prodApp', 'stylus:prodApp', 'copy:app']
                }
            }
        },

        copy: {
            app: {
                files: [
                    { expand: true, cwd: './public', src: 'index.html', dest: './dist/app' },
                    { expand: true, cwd: './public', src: 'css/**/*.css', dest: './dist/app/css', flatten: true },
                    { expand: true, cwd: './public', src: 'img/**/*.*', dest: './dist/app' }]
            }
        },

        express: {
            options: {
                script: 'app.js'
            },

            devApp: {
                node_env: 'develop'
            },

            prodApp: {
                node_env: 'production'
            }
        },

        run: {
            app: {
                options: {
                    developTasks: ['watchify:devApp', 'stylus:devApp', 'copy:app', 'express:devApp', 'watch'],
                    productionTasks: ['browserify:prodApp', 'stylus:prodApp', 'copy:app', 'express:prodApp', 'keepalive']
                }
            }
        },

        stylus: {
            devApp: {
                files: {
                    './dist/app/css/style.css': ['./public/css/**/*.styl'],
                }
            },

            prodApp: {
                options: {
                    compress: true
                },

                files: '<%= stylus.devApp.files %>'
            }
        },

        watch: {
            options: {
                nospawn: true,
                livereload: reloadPort
            },
            server: {
                files: [
                    'app.js',
                    'model/*.js',
                    'routes/*.js'
                ],
                tasks: ['express:devApp', 'delayed-livereload']
            },
            js: {
                files: ['public/js/*.js', 'dist/js/*.js'],
                options: {
                  livereload: reloadPort
                }
            },
            css: {
                files: ['public/css/*.css'],
                options: {
                  livereload: reloadPort
                }
            },
            jade: {
                files: ['views/*.jade'],
                options: {
                  livereload: reloadPort
                }
            }
        },

        watchify: {
            options: {
                debug: true,
                transform: ['reactify'],
                extensions: ['.jsx']
            },

            devApp: {
                options: {
                    alias: ['react:']  // Make React available externally for dev tools
                },
                src: ['./public/js/app.js'],
                dest: './dist/app/bundle.js'
            },

            prodApp: {
                options: {
                    debug: false
                },
                src: '<%= watchify.dev.src %>',
                dest: '<%= watchify.dev.dest %>'
            }
        }
    });

    grunt.config.requires('watch.server.files');
    files = grunt.config('watch.server.files');
    files = grunt.file.expand(files);

    grunt.registerTask('delayed-livereload', 'Live reload after the node server has restarted.', function () {
        var done = this.async();
        setTimeout(function () {
            request.get('http://localhost:' + reloadPort + '/changed?files=' + files.join(','),  function (err, res) {
                var reloaded = !err && res.statusCode === 200;
                if (reloaded) {
                    grunt.log.ok('Delayed live reload successful.');
                } else {
                    grunt.log.error('Unable to make a delayed live reload.');
                }
                done(reloaded);
            });
        }, 500);
    });

    grunt.registerMultiTask('build', 'Build and deploy application targets', function () {
        grunt.log.writeln('Building target "' + this.target + '"...');

        var options = this.options()
          , developMode = this.flags.develop
          , tasks = developMode
                ? options.developTasks
                : options.productionTasks;

        grunt.task.run(tasks);
    });

    grunt.registerMultiTask('run', 'Run application targets', function () {
        grunt.log.writeln('Running target "' + this.target + '"...');

        var options = this.options()
          , developMode = this.flags.develop
          , tasks = developMode
                ? options.developTasks
                : options.productionTasks;

        grunt.task.run(tasks);
    });

    grunt.registerTask('default', ['run:app:develop']);
};
<commit_msg>request is devDependency, so only require it when strictly needed<commit_after>
'use strict';

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    var _ = require('underscore')._;

    var reloadPort = 35729, files;

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        browserify: {
            options: {
                debug: true,
                extensions: ['.jsx'],
                transform: ['reactify']
            },

            devApp: {
                options: {
                    alias: ['react:']  // Make React available externally for dev tools
                },
                src: ['./public/js/app.js'],
                dest: './dist/app/bundle.js'
            },

            prodApp: {
                options: {
                    debug: false
                },
                src: '<%= browserify.devApp.src %>',
                dest: '<%= browserify.devApp.dest %>'
            }
        },

        build: {
            app: {
                options: {
                    developTasks: ['browserify:devApp', 'stylus:devApp', 'copy:app'],
                    productionTasks: ['browserify:prodApp', 'stylus:prodApp', 'copy:app']
                }
            }
        },

        copy: {
            app: {
                files: [
                    { expand: true, cwd: './public', src: 'index.html', dest: './dist/app' },
                    { expand: true, cwd: './public', src: 'css/**/*.css', dest: './dist/app/css', flatten: true },
                    { expand: true, cwd: './public', src: 'img/**/*.*', dest: './dist/app' }]
            }
        },

        express: {
            options: {
                script: 'app.js'
            },

            devApp: {
                node_env: 'develop'
            },

            prodApp: {
                node_env: 'production'
            }
        },

        run: {
            app: {
                options: {
                    developTasks: ['watchify:devApp', 'stylus:devApp', 'copy:app', 'express:devApp', 'watch'],
                    productionTasks: ['browserify:prodApp', 'stylus:prodApp', 'copy:app', 'express:prodApp', 'keepalive']
                }
            }
        },

        stylus: {
            devApp: {
                files: {
                    './dist/app/css/style.css': ['./public/css/**/*.styl'],
                }
            },

            prodApp: {
                options: {
                    compress: true
                },

                files: '<%= stylus.devApp.files %>'
            }
        },

        watch: {
            options: {
                nospawn: true,
                livereload: reloadPort
            },
            server: {
                files: [
                    'app.js',
                    'model/*.js',
                    'routes/*.js'
                ],
                tasks: ['express:devApp', 'delayed-livereload']
            },
            js: {
                files: ['public/js/*.js', 'dist/js/*.js'],
                options: {
                  livereload: reloadPort
                }
            },
            css: {
                files: ['public/css/*.css'],
                options: {
                  livereload: reloadPort
                }
            },
            jade: {
                files: ['views/*.jade'],
                options: {
                  livereload: reloadPort
                }
            }
        },

        watchify: {
            options: {
                debug: true,
                transform: ['reactify'],
                extensions: ['.jsx']
            },

            devApp: {
                options: {
                    alias: ['react:']  // Make React available externally for dev tools
                },
                src: ['./public/js/app.js'],
                dest: './dist/app/bundle.js'
            },

            prodApp: {
                options: {
                    debug: false
                },
                src: '<%= watchify.dev.src %>',
                dest: '<%= watchify.dev.dest %>'
            }
        }
    });

    grunt.config.requires('watch.server.files');
    files = grunt.config('watch.server.files');
    files = grunt.file.expand(files);

    grunt.registerTask('delayed-livereload', 'Live reload after the node server has restarted.', function () {
        var request = require('request')
          , done = this.async();

        setTimeout(function () {
            request.get('http://localhost:' + reloadPort + '/changed?files=' + files.join(','),  function (err, res) {
                var reloaded = !err && res.statusCode === 200;
                if (reloaded) {
                    grunt.log.ok('Delayed live reload successful.');
                } else {
                    grunt.log.error('Unable to make a delayed live reload.');
                }
                done(reloaded);
            });
        }, 500);
    });

    grunt.registerMultiTask('build', 'Build and deploy application targets', function () {
        grunt.log.writeln('Building target "' + this.target + '"...');

        var options = this.options()
          , developMode = this.flags.develop
          , tasks = developMode
                ? options.developTasks
                : options.productionTasks;

        grunt.task.run(tasks);
    });

    grunt.registerMultiTask('run', 'Run application targets', function () {
        grunt.log.writeln('Running target "' + this.target + '"...');

        var options = this.options()
          , developMode = this.flags.develop
          , tasks = developMode
                ? options.developTasks
                : options.productionTasks;

        grunt.task.run(tasks);
    });

    grunt.registerTask('default', ['run:app:develop']);
};
<|endoftext|>


<commit_before>/*
 * grunt-partial-extract
 * https://github.com/tilman/partial-extract
 *
 * Copyright (c) 2014 Tilman Justen
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Configuration to be run (and then tested).
    'partial-extract': {
      test: {
        options: {

        },
        files: [{
          expand: true,
          cwd: './',
          src: '*.html'
        }]
      }
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['jshint', 'partial-extract:test']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint']);

};
<commit_msg>Fix URL and date in file doc block of Gruntfile.js<commit_after>/*
 * grunt-partial-extract
 * https://github.com/tilmanjusten/grunt-partial-extract
 *
 * Copyright (c) 2015 Tilman Justen
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Configuration to be run (and then tested).
    'partial-extract': {
      test: {
        options: {

        },
        files: [{
          expand: true,
          cwd: './',
          src: '*.html'
        }]
      }
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['jshint', 'partial-extract:test']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		uglify: {
			main : {
				files: {
					'dist/min/events.min.js': ['dist/events.js'],
					'dist/min/router.min.js': ['dist/router.js'],
					'dist/min/util.min.js': ['dist/util.js']
				}
			}
		},

		copy : {
			main : {
				expand : true,
				cwd : 'src/',
				src : '**',
				dest : 'dist/'
			},

			demo : {
				expand : true,
				cwd : 'src/',
				src : '**',
				dest : 'demo/js/lib/'
			}
		},

		jshint : {
			options : {
				browser : true
			},
			main : [
				'src/**/*.js',
				'!src/test/**/*.js',
				'!src/demo/**/*.js'
			]
		},

		jsdoc : {
			main : {
				src: [
					'src/*.js',
					'README.md'
				],
				jsdoc : './node_modules/.bin/jsdoc',
				dest : 'docs',
				options : {
					configure : 'jsdoc.json'
				}
			}
		},

		mocha : {
			test : {
				options : {
					//log : true,
					//'remote-debugger-port' : 9001,
					//'remote-debugger-autorun' : 'yes',
					run : true,
					reporter : process.env.MOCHA_REPORTER || (process.env.ENVIRONMENT==='ci' ? 'XUnit' : 'Spec')
				},
				src : ['test/**/*.html'],
				dest : (process.env.ENVIRONMENT==='ci' || process.env.OUTPUT_TESTS) && './test-reports/default.xml'
			}
		},

		watch : {
			options : {
				interrupt : true
			},
			src : {
				files : ['src/**/*.js'],
				tasks : ['default']
			},
			test : {
				files : ['test/**/*'],
				tasks : ['test']
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-jsdoc');
	grunt.loadNpmTasks('grunt-mocha');
	grunt.loadNpmTasks('grunt-contrib-watch');

	grunt.registerTask('default', [
		'jshint:main',
		'copy:main',
		'uglify:main',
		'copy:demo',
		'jsdoc:main'
	]);

	grunt.registerTask('test', ['mocha:test'])

	grunt.registerTask('build-watch', [
		'default',
		'watch'
	]);

};
<commit_msg>Copy logo into docs on generation<commit_after>module.exports = function(grunt) {

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		uglify: {
			main : {
				files: {
					'dist/min/events.min.js': ['dist/events.js'],
					'dist/min/router.min.js': ['dist/router.js'],
					'dist/min/util.min.js': ['dist/util.js']
				}
			}
		},

		copy : {
			main : {
				expand : true,
				cwd : 'src/',
				src : '**',
				dest : 'dist/'
			},

			demo : {
				expand : true,
				cwd : 'src/',
				src : '**',
				dest : 'demo/js/lib/'
			},

			docs : {
				src : 'logo.png',
				dest : 'docs/logo.png'
			}
		},

		jshint : {
			options : {
				browser : true
			},
			main : [
				'src/**/*.js',
				'!src/test/**/*.js',
				'!src/demo/**/*.js'
			]
		},

		jsdoc : {
			main : {
				src: [
					'src/*.js',
					'README.md'
				],
				jsdoc : './node_modules/.bin/jsdoc',
				dest : 'docs',
				options : {
					configure : 'jsdoc.json'
				}
			}
		},

		mocha : {
			test : {
				options : {
					//log : true,
					//'remote-debugger-port' : 9001,
					//'remote-debugger-autorun' : 'yes',
					run : true,
					reporter : process.env.MOCHA_REPORTER || (process.env.ENVIRONMENT==='ci' ? 'XUnit' : 'Spec')
				},
				src : ['test/**/*.html'],
				dest : (process.env.ENVIRONMENT==='ci' || process.env.OUTPUT_TESTS) && './test-reports/default.xml'
			}
		},

		watch : {
			options : {
				interrupt : true
			},
			src : {
				files : [
					'src/**/*.js',
					'Gruntfile.js',
					'README.md',
					'jsdoc-template/**/*'
				],
				tasks : ['default']
			},
			test : {
				files : ['test/**/*'],
				tasks : ['test']
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-jsdoc');
	grunt.loadNpmTasks('grunt-mocha');
	grunt.loadNpmTasks('grunt-contrib-watch');

	grunt.registerTask('default', [
		'jshint:main',
		'copy:main',
		'uglify:main',
		'copy:demo',
		'jsdoc:main',
		'copy:docs'
	]);

	grunt.registerTask('test', ['mocha:test'])

	grunt.registerTask('build-watch', [
		'default',
		'watch'
	]);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var browsers = grunt.option('browsers') && grunt.option('browsers').split(',');
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
      },
      build: {
        src: 'dist/flow.js',
        dest: 'dist/flow.min.js'
      }
    },
    concat: {
      build: {
        files: {
          'dist/flow.js': [
            'src/flow.js'
          ]
        }
      }
    },
    jst: {
      compile: {
        options: {

        },
        files: {
          "dist/flow.js": ["dist/flow.js"]
        }
      }
    },
    coveralls: {
      options: {
        coverage_dir: 'coverage/'
      }
    },
    karma: {
      options: {
        configFile: 'karma.conf.js',
        browsers: browsers || ['Chrome']
      },
      watch: {
        autoWatch: true,
        background: false
      },
      continuous: {
        singleRun: true
      },
      coverage: {
        singleRun: true,
        reporters: ['progress', 'coverage'],
        preprocessors: {
          'src/*.js': 'coverage'
        },
        coverageReporter: {
          type: "lcov",
          dir: "coverage/"
        }
      },
      travis: {
        singleRun: true,
        reporters: ['progress', 'coverage'],
        preprocessors: {
          'src/*.js': 'coverage'
        },
        coverageReporter: {
          type: "lcov",
          dir: "coverage/"
        },
        // Buggiest browser
        browsers: browsers || ['sl_chorme'],
        // global config for SauceLabs
        sauceLabs: {
          username: grunt.option('sauce-username') || process.env.SAUCE_USERNAME,
          accessKey: grunt.option('sauce-access-key') || process.env.SAUCE_ACCESS_KEY,
          startConnect: grunt.option('sauce-local') ? false : true ,
          testName: 'flow.js'
        }
      }
    },
    clean: {
      release: ["dist/"]
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['-a'], // '-a' for all files
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
      }
    },
    'template': {
      'release': {
        'options': {
          'data': {
            'version': '<%= pkg.version %>'
          }
        },
        'files': {
          'dist/flow.js': ['dist/flow.js']
        }
      }
    }
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  // Default task.
  grunt.registerTask('default', ['test']);
  // Release tasks
  grunt.registerTask('build', ['concat', 'template', 'uglify']);
  grunt.registerTask('release', function(type) {
    type = type ? type : 'patch';
    grunt.task.run('bump-only:' + type);
    grunt.task.run('clean', 'build');
    grunt.task.run('bump-commit');
  });
  // Development
  grunt.registerTask('test', ["karma:travis", "coveralls"]);
};<commit_msg>chore: remove coveralls<commit_after>module.exports = function(grunt) {
  var browsers = grunt.option('browsers') && grunt.option('browsers').split(',');
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
      },
      build: {
        src: 'dist/flow.js',
        dest: 'dist/flow.min.js'
      }
    },
    concat: {
      build: {
        files: {
          'dist/flow.js': [
            'src/flow.js'
          ]
        }
      }
    },
    jst: {
      compile: {
        options: {

        },
        files: {
          "dist/flow.js": ["dist/flow.js"]
        }
      }
    },
    coveralls: {
      options: {
        coverage_dir: 'coverage/'
      }
    },
    karma: {
      options: {
        configFile: 'karma.conf.js',
        browsers: browsers || ['Chrome']
      },
      watch: {
        autoWatch: true,
        background: false
      },
      continuous: {
        singleRun: true
      },
      coverage: {
        singleRun: true,
        reporters: ['progress', 'coverage'],
        preprocessors: {
          'src/*.js': 'coverage'
        },
        coverageReporter: {
          type: "lcov",
          dir: "coverage/"
        }
      },
      travis: {
        singleRun: true,
        reporters: ['progress', 'coverage'],
        preprocessors: {
          'src/*.js': 'coverage'
        },
        coverageReporter: {
          type: "lcov",
          dir: "coverage/"
        },
        // Buggiest browser
        browsers: browsers || ['sl_chorme'],
        // global config for SauceLabs
        sauceLabs: {
          username: grunt.option('sauce-username') || process.env.SAUCE_USERNAME,
          accessKey: grunt.option('sauce-access-key') || process.env.SAUCE_ACCESS_KEY,
          startConnect: grunt.option('sauce-local') ? false : true ,
          testName: 'flow.js'
        }
      }
    },
    clean: {
      release: ["dist/"]
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        commit: true,
        commitMessage: 'Release v%VERSION%',
        commitFiles: ['-a'], // '-a' for all files
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
      }
    },
    'template': {
      'release': {
        'options': {
          'data': {
            'version': '<%= pkg.version %>'
          }
        },
        'files': {
          'dist/flow.js': ['dist/flow.js']
        }
      }
    }
  });

  // Loading dependencies
  for (var key in grunt.file.readJSON("package.json").devDependencies) {
    if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
  }

  // Default task.
  grunt.registerTask('default', ['test']);
  // Release tasks
  grunt.registerTask('build', ['concat', 'template', 'uglify']);
  grunt.registerTask('release', function(type) {
    type = type ? type : 'patch';
    grunt.task.run('bump-only:' + type);
    grunt.task.run('clean', 'build');
    grunt.task.run('bump-commit');
  });
  // Development
  grunt.registerTask('test', ["karma:travis"]);
};<|endoftext|>


<commit_before>// ==========================================================================
// Grunt Build
// ==========================================================================

module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({

    sass: {
      dist: {
        options: {
          style: 'expanded',
          compass: true
        },
        files: {
          'public/css/core.css': 'public/css/core.scss'
        }
      }
    },

    jshint: {
      options: {
        '-W058': true,
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: false,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: false,
        boss: true,
        eqnull: false,
        browser: true,
        esnext: true,
        debug: true,
        globalstrict: true,
        globals: {
          '$': false,
          'module': true,
          'require': false,
          'console': false,
          'window': true,
          'debug': true,
          'log': true,
          'io': true,
          'process': false,
          '__dirname': false,
          'ZeroClipboard': false
        }
      },
      files: ['Gruntfile.js', 'app.js', 'models/*.js', 'public/js/*.js']
    },

    /*jasmine: {
      pivotal: {
        src: 'js/core.js',
        options: {
          helpers: ['js/traceur-runtime.js', 'js/jquery.js', 'js/jasmine-jquery.js'],
          keepRunner: true
        }
      }
    },*/

    watch: {
      sass: {
        files: ['public/css/**/*.scss'],
        tasks: ['sass:dist']
      },
      js: {
        files: ['Gruntfile.js', 'app.js', 'models/*.js', 'public/js/*.js'],
        tasks: ['jshint'/*, 'jasmine'*/]
      },
      html: {
        files: ['index.html']
      },
      options: {
        livereload: true
      }
    }

  });

  // Load Modules
  // ----------------------------------------------------------
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  //grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Register Tasks
  // ----------------------------------------------------------
  grunt.registerTask('default', ['sass:dist', 'jshint']);
  grunt.registerTask('dev', ['sass:dist', 'jshint', 'watch']);

  // Show Timer
  // ----------------------------------------------------------
  require('time-grunt')(grunt);
};
<commit_msg>add heroku grunt task for sass<commit_after>// ==========================================================================
// Grunt Build
// ==========================================================================

module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({

    sass: {
      dist: {
        options: {
          style: 'expanded',
          compass: true
        },
        files: {
          'public/css/core.css': 'public/css/core.scss'
        }
      }
    },

    jshint: {
      options: {
        '-W058': true,
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: false,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: false,
        boss: true,
        eqnull: false,
        browser: true,
        esnext: true,
        debug: true,
        globalstrict: true,
        globals: {
          '$': false,
          'module': true,
          'require': false,
          'console': false,
          'window': true,
          'debug': true,
          'log': true,
          'io': true,
          'process': false,
          '__dirname': false,
          'ZeroClipboard': false
        }
      },
      files: ['Gruntfile.js', 'app.js', 'models/*.js', 'public/js/*.js']
    },

    /*jasmine: {
      pivotal: {
        src: 'js/core.js',
        options: {
          helpers: ['js/traceur-runtime.js', 'js/jquery.js', 'js/jasmine-jquery.js'],
          keepRunner: true
        }
      }
    },*/

    watch: {
      sass: {
        files: ['public/css/**/*.scss'],
        tasks: ['sass:dist']
      },
      js: {
        files: ['Gruntfile.js', 'app.js', 'models/*.js', 'public/js/*.js'],
        tasks: ['jshint'/*, 'jasmine'*/]
      },
      html: {
        files: ['index.html']
      },
      options: {
        livereload: true
      }
    }

  });

  // Load Modules
  // ----------------------------------------------------------
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  //grunt.loadNpmTasks('grunt-contrib-jasmine');

  // Register Tasks
  // ----------------------------------------------------------
  grunt.registerTask('default', ['sass:dist', 'jshint']);
  grunt.registerTask('dev', ['sass:dist', 'jshint', 'watch']);
  grunt.registerTask('heroku', ['sass:dist']);

  // Show Timer
  // ----------------------------------------------------------
  require('time-grunt')(grunt);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.initConfig({
        settings: {
            src: 'src',
            dist: 'dist',
            libName: 'diagrammatica',
            angularModuleName: 'diagrammatica-angular-module'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            src: [
                '<%= settings.src %>/{,*/}*.js'
            ]
        },
        karma: {
            unit: {
                configFile: 'test/karma.conf.js'
            }
        },
        sass: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= settings.src %>/css',
                    src: ['**/*.scss'],
                    dest: '<%= settings.dist %>',
                    ext: '.css'
                }]
            }
        },
        watch: {
            src: {
                files: ['<%= settings.src %>/**/*.*'],
                tasks: [
                    'uglify:beautifyLibrary',
                    'uglify:minifyLibrary',
                    'uglify:beautifyAngularModule',
                    'uglify:minifyAngularModule',
                    'sass:dist'],
                options: {
                    spawn: false
                }
            }
        },
        uglify: {
            beautifyLibrary: {
                files: {
                    '<%= settings.dist %>/<%= settings.libName %>.js': ['<%= settings.src %>/css/*.js']
                },
                options: {
                    wrap: '<%= settings.libName %>',
                    exportAll: true,
                    compress: false,
                    mangle: false,
                    beautify: true
                }
            },
            minifyLibrary: {
                files: {
                    '<%= settings.dist %>/<%= settings.libName %>.min.js': ['<%= settings.src %>/js/*.js']
                },
                options: {
                    wrap: '<%= settings.libName %>',
                    exportAll: true,
                    sourceMap: true
                }
            },
            beautifyAngularModule: {
                files: {
                    '<%= settings.dist %>/<%= settings.angularModuleName %>.js': ['<%= settings.src %>/angular-module/*.js']
                },
                options: {
                    compress: false,
                    mangle: false,
                    beautify: true
                }
            },
            minifyAngularModule: {
                files: {
                    '<%= settings.dist %>/<%= settings.angularModuleName %>.min.js': ['<%= settings.src %>/angular-module/*.js']
                },
                options: {
                    sourceMap: true
                }
            }
        }
    });

    grunt.registerTask('dev', [
        'watch:src'
    ]);

    grunt.registerTask('build', [
        'sass:dist',
        'jshint:src',
        'uglify:beautifyLibrary',
        'uglify:minifyLibrary',
        'uglify:beautifyAngularModule',
        'uglify:minifyAngularModule'
    ]);

    grunt.registerTask('test', [
        'karma:unit'
    ]);

    grunt.registerTask('default', [
        'build'
    ]);
};
<commit_msg>Fix type in Grunt build task<commit_after>'use strict';

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.initConfig({
        settings: {
            src: 'src',
            dist: 'dist',
            libName: 'diagrammatica',
            angularModuleName: 'diagrammatica-angular-module'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            src: [
                '<%= settings.src %>/{,*/}*.js'
            ]
        },
        karma: {
            unit: {
                configFile: 'test/karma.conf.js'
            }
        },
        sass: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= settings.src %>/css',
                    src: ['**/*.scss'],
                    dest: '<%= settings.dist %>',
                    ext: '.css'
                }]
            }
        },
        watch: {
            src: {
                files: ['<%= settings.src %>/**/*.*'],
                tasks: [
                    'uglify:beautifyLibrary',
                    'uglify:minifyLibrary',
                    'uglify:beautifyAngularModule',
                    'uglify:minifyAngularModule',
                    'sass:dist'],
                options: {
                    spawn: false
                }
            }
        },
        uglify: {
            beautifyLibrary: {
                files: {
                    '<%= settings.dist %>/<%= settings.libName %>.js': ['<%= settings.src %>/js/*.js']
                },
                options: {
                    wrap: '<%= settings.libName %>',
                    exportAll: true,
                    compress: false,
                    mangle: false,
                    beautify: true
                }
            },
            minifyLibrary: {
                files: {
                    '<%= settings.dist %>/<%= settings.libName %>.min.js': ['<%= settings.src %>/js/*.js']
                },
                options: {
                    wrap: '<%= settings.libName %>',
                    exportAll: true,
                    sourceMap: true
                }
            },
            beautifyAngularModule: {
                files: {
                    '<%= settings.dist %>/<%= settings.angularModuleName %>.js': ['<%= settings.src %>/angular-module/*.js']
                },
                options: {
                    compress: false,
                    mangle: false,
                    beautify: true
                }
            },
            minifyAngularModule: {
                files: {
                    '<%= settings.dist %>/<%= settings.angularModuleName %>.min.js': ['<%= settings.src %>/angular-module/*.js']
                },
                options: {
                    sourceMap: true
                }
            }
        }
    });

    grunt.registerTask('dev', [
        'watch:src'
    ]);

    grunt.registerTask('build', [
        'sass:dist',
        'jshint:src',
        'uglify:beautifyLibrary',
        'uglify:minifyLibrary',
        'uglify:beautifyAngularModule',
        'uglify:minifyAngularModule'
    ]);

    grunt.registerTask('test', [
        'karma:unit'
    ]);

    grunt.registerTask('default', [
        'build'
    ]);
};
<|endoftext|>


<commit_before>'use strict';

var fs          = require( 'fs' )
  , os          = require( 'os' )
  , path        = require( 'path' )
  , pkgJson     = require( path.resolve( path.join( __dirname, '..', '..', 'package.json') ) )
  , odmEnabled  = pkgJson.bundledDependencies.indexOf( 'clever-odm' ) !== -1
  , isWin       = /^win32/.test( os.platform() );

module.exports = function( grunt ) {
    // Arguments for individual module rebase/seed
    var dbTarget = grunt.option( 'module' ) || null;

    return [{
        prompt: {
            cleverstack: {
                options: {
                    questions: [
                        {
                            config: 'cleverstackorm.username',
                            type: 'input',
                            message: 'Database username',
                            default: '',
                        },
                        {
                            config: 'cleverstackorm.password',
                            type: 'password',
                            message: 'Database password',
                            default: ''
                        },
                        {
                            config: 'cleverstackorm.database',
                            type: 'input',
                            message: 'Database name',
                            default: ''
                        },
                        {
                            config: 'cleverstackorm.dialect',
                            type: 'list',
                            message: 'Database dialect',
                            choices: [
                                { name: 'mysql' },
                                { name: 'mariadb' },
                                { name: 'postgres' },
                                { name: 'sqlite' }
                            ]
                        },
                        {
                            config: 'cleverstackorm.host',
                            type: 'input',
                            message: 'Database host',
                            default: '127.0.0.1'
                        },
                        {
                            config: 'cleverstackorm.port',
                            type: 'input',
                            message: 'Database port',
                            default: '3306'
                        }
                    ]
                }
            }
        },
        exec: {
            ormRebase: {
                cmd: "node modules/clever-orm/bin/rebase.js " + dbTarget
            },
            ormSeed: {
                cmd: "node modules/clever-orm/bin/seedModels.js " + dbTarget
            }
        }
    }, function( grunt ) {
        grunt.loadNpmTasks('grunt-prompt');

        // Register each command
        grunt.registerTask( 'db:ormRebase', [ 'exec:ormRebase' ] );
        grunt.registerTask( 'db:ormSeed', [ 'exec:ormSeed' ] );

        // Register grouped command
        grunt.registerTask( 'db:orm', [ 'db:ormRebase', 'db:ormSeed' ] );

        if ( odmEnabled ) {
            grunt.registerTask( 'db:rebase', [ 'db:ormRebase', 'db:odmRebase' ] );
            grunt.registerTask( 'db:seed', [ 'db:ormSeed', 'db:odmSeed' ] );
            grunt.registerTask( 'db', [ 'db:rebase', 'db:seed' ] );
        } else {
            grunt.registerTask( 'db:rebase', [ 'db:ormRebase' ] );
            grunt.registerTask( 'db:seed', [ 'db:ormSeed' ] );
            grunt.registerTask( 'db', [ 'db:orm' ] );
        }

        grunt.registerTask( 'readme', 'Displays helpful information', function ( ) {
            console.log( 'Installation instructions:' );
            console.log( '1. In the config file for your desired environment (ie. backend/config/local.json), update the clever-orm object with the details for your database.' );
            console.log( '' );
            console.log( '2. From your project\'s `backend` folder, run `NODE_ENV=local grunt db`.' );
            console.log( 'The database tables for your modules should now be installed and seeded with data!' );
        } );

        grunt.registerTask( 'prompt:clever', [ 'prompt:cleverstack', 'createConfig' ] );
        grunt.registerTask( 'createConfig', 'Creates a .json config file for database credentials', function ( ) {
            var conf = grunt.config( 'cleverstackorm' )
              , obj  = {
                    'clever-orm': { db: { options: {} } }
                }
              , env  = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'local'
              , file = path.join( process.cwd( ), 'config', env + '.json' );

            if ( fs.existsSync( file ) ) {
                obj = require( file );
            }

            obj[ 'clever-orm' ] = obj[ 'clever-orm' ] || {};

            Object.keys( conf ).forEach( function ( key ) {
                if ([ 'host', 'dialect', 'port' ].indexOf( key ) > -1) {
                    obj[ 'clever-orm' ].db.options = obj[ 'clever-orm' ].db.options || {};
                    obj[ 'clever-orm' ].db.options[ key ] = conf[ key ];
                } else {
                    obj[ 'clever-orm' ].db[ key ] = conf[ key ];
                }
            } );

            fs.writeFileSync( file, JSON.stringify( obj, null, '  ' ) );
        } );
    }];
};<commit_msg>refactor(grunt): No longer use os module to detect isWin<commit_after>'use strict';

var fs          = require( 'fs' )
  , path        = require( 'path' )
  , pkgJson     = require( path.resolve( path.join( __dirname, '..', '..', 'package.json') ) )
  , odmEnabled  = pkgJson.bundledDependencies.indexOf( 'clever-odm' ) !== -1;

module.exports = function( grunt ) {
    // Arguments for individual module rebase/seed
    var dbTarget = grunt.option( 'module' ) || null;

    return [{
        prompt: {
            cleverstack: {
                options: {
                    questions: [
                        {
                            config: 'cleverstackorm.username',
                            type: 'input',
                            message: 'Database username',
                            default: '',
                        },
                        {
                            config: 'cleverstackorm.password',
                            type: 'password',
                            message: 'Database password',
                            default: ''
                        },
                        {
                            config: 'cleverstackorm.database',
                            type: 'input',
                            message: 'Database name',
                            default: ''
                        },
                        {
                            config: 'cleverstackorm.dialect',
                            type: 'list',
                            message: 'Database dialect',
                            choices: [
                                { name: 'mysql' },
                                { name: 'mariadb' },
                                { name: 'postgres' },
                                { name: 'sqlite' }
                            ]
                        },
                        {
                            config: 'cleverstackorm.host',
                            type: 'input',
                            message: 'Database host',
                            default: '127.0.0.1'
                        },
                        {
                            config: 'cleverstackorm.port',
                            type: 'input',
                            message: 'Database port',
                            default: '3306'
                        }
                    ]
                }
            }
        },
        exec: {
            ormRebase: {
                cmd: "node modules/clever-orm/bin/rebase.js " + dbTarget
            },
            ormSeed: {
                cmd: "node modules/clever-orm/bin/seedModels.js " + dbTarget
            }
        }
    }, function( grunt ) {
        grunt.loadNpmTasks('grunt-prompt');

        // Register each command
        grunt.registerTask( 'db:ormRebase', [ 'exec:ormRebase' ] );
        grunt.registerTask( 'db:ormSeed', [ 'exec:ormSeed' ] );

        // Register grouped command
        grunt.registerTask( 'db:orm', [ 'db:ormRebase', 'db:ormSeed' ] );

        if ( odmEnabled ) {
            grunt.registerTask( 'db:rebase', [ 'db:ormRebase', 'db:odmRebase' ] );
            grunt.registerTask( 'db:seed', [ 'db:ormSeed', 'db:odmSeed' ] );
            grunt.registerTask( 'db', [ 'db:rebase', 'db:seed' ] );
        } else {
            grunt.registerTask( 'db:rebase', [ 'db:ormRebase' ] );
            grunt.registerTask( 'db:seed', [ 'db:ormSeed' ] );
            grunt.registerTask( 'db', [ 'db:orm' ] );
        }

        grunt.registerTask( 'readme', 'Displays helpful information', function ( ) {
            console.log( 'Installation instructions:' );
            console.log( '1. In the config file for your desired environment (ie. backend/config/local.json), update the clever-orm object with the details for your database.' );
            console.log( '' );
            console.log( '2. From your project\'s `backend` folder, run `NODE_ENV=local grunt db`.' );
            console.log( 'The database tables for your modules should now be installed and seeded with data!' );
        } );

        grunt.registerTask( 'prompt:clever', [ 'prompt:cleverstack', 'createConfig' ] );
        grunt.registerTask( 'createConfig', 'Creates a .json config file for database credentials', function ( ) {
            var conf = grunt.config( 'cleverstackorm' )
              , obj  = {
                    'clever-orm': { db: { options: {} } }
                }
              , env  = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'local'
              , file = path.join( process.cwd( ), 'config', env + '.json' );

            if ( fs.existsSync( file ) ) {
                obj = require( file );
            }

            obj[ 'clever-orm' ] = obj[ 'clever-orm' ] || {};

            Object.keys( conf ).forEach( function ( key ) {
                if ([ 'host', 'dialect', 'port' ].indexOf( key ) > -1) {
                    obj[ 'clever-orm' ].db.options = obj[ 'clever-orm' ].db.options || {};
                    obj[ 'clever-orm' ].db.options[ key ] = conf[ key ];
                } else {
                    obj[ 'clever-orm' ].db[ key ] = conf[ key ];
                }
            } );

            fs.writeFileSync( file, JSON.stringify( obj, null, '  ' ) );
        } );
    }];
};<|endoftext|>


<commit_before>'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
  port: LIVERELOAD_PORT
});
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
  // Let *load-grunt-tasks* require everything
  require('load-grunt-tasks')(grunt);
  // Read configuration from package.json
  var pkgConfig = grunt.file.readJSON('package.json');
  var jshintConfig = grunt.file.readJSON('.jshintrc');

  var loaders = [{
    test: /\.css$/,
    loader: 'style-loader!css-loader'
  }, {
    test: /\.s[ac]ss$/,
    loader: 'style!sass-loader'
  }, {
    test: /\.gif/,
    loader: 'url-loader?limit=10000&minetype=image/gif'
  }, {
    test: /\.jpg/,
    loader: 'url-loader?limit=10000&minetype=image/jpg'
  }, {
    test: /\.png/,
    loader: 'url-loader?limit=10000&minetype=image/png'
  }, {
    test: /\.js$/,
    loader: 'jsx-loader'
  }, {
    test: /\.woff$/,
    loader: "url-loader?limit=10000&minetype=application/font-woff"
  }, {
    test: /\.ttf$/,
    loader: "file-loader"
  }, {
    test: /\.eot$/,
    loader: "file-loader"
  }, {
    test: /\.svg$/,
    loader: "file-loader"
  }];

  grunt.initConfig({
    pkg: pkgConfig,
    webpack: {
      development: {
        entry: './<%= pkg.src %>/scripts/app.js',
        output: {
          path: '<%= pkg.src %>/build/',
          filename: '<%= pkg.mainOutput %>.js'
        },
        debug: true,
        cache: true,
        stats: {
          colors: true,
          reasons: true
        },
        jshint: grunt.util._.merge(jshintConfig, {
          emitErrors: false,
          failOnHint: false
        }),
        module: {
          preLoaders: [{
            test: '\\.js$',
            exclude: 'node_modules',
            loader: 'jshint'
          }],
          loaders: loaders
        }
      }
    },
    watch: {
      webpack: {
        files: ['<%= pkg.src %>/scripts/{,*/}*.js',
          '<%= pkg.src %>/styles/{,*/}*.css',
          '!<%= pkg.src %>/build/<%= pkg.mainOutput %>.js'
        ],
        tasks: ['webpack:development']
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: [
          '<%= pkg.src %>/{,*/}*.html',
          '<%= pkg.src %>/build/<%= pkg.mainOutput %>.js'
        ]
      }
    },
    connect: {
      options: {
        port: 8000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect, options) {
            return [
              lrSnippet,
              mountFolder(connect, "src/build"),
              mountFolder(connect, pkgConfig.src),
              function(req, res){
                for(var file, i = 0; i < pkgConfig.src.length; i++){
                  file = pkgConfig.src + "/index.html";
                  if (grunt.file.exists(file)){
                    require('fs').createReadStream(file).pipe(res);
                    return; // we're done
                  }
                }
                res.statusCode(404); // where's index.html?
                res.end();
              }
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, pkgConfig.dist)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'connect:livereload',
      'webpack:development',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('test', ['karma']);

  grunt.registerTask('build', []);

  grunt.registerTask('default', []);
};
<commit_msg>Fix webpack config to append /build/ to fonts<commit_after>'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
  port: LIVERELOAD_PORT
});
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
  // Let *load-grunt-tasks* require everything
  require('load-grunt-tasks')(grunt);
  // Read configuration from package.json
  var pkgConfig = grunt.file.readJSON('package.json');
  var jshintConfig = grunt.file.readJSON('.jshintrc');

  var loaders = [{
    test: /\.css$/,
    loader: 'style-loader!css-loader'
  }, {
    test: /\.s[ac]ss$/,
    loader: 'style!sass-loader'
  }, {
    test: /\.gif/,
    loader: 'url-loader?limit=10000&minetype=image/gif'
  }, {
    test: /\.jpg/,
    loader: 'url-loader?limit=10000&minetype=image/jpg'
  }, {
    test: /\.png/,
    loader: 'url-loader?limit=10000&minetype=image/png'
  }, {
    test: /\.js$/,
    loader: 'jsx-loader'
  }, {
    test: /\.woff$/,
    loader: "url-loader?limit=10000&minetype=application/font-woff"
  }, {
    test: /\.ttf$/,
    loader: "file-loader?prefix=/build/"
  }, {
    test: /\.eot$/,
    loader: "file-loader?prefix=/build/"
  }, {
    test: /\.svg$/,
    loader: "file-loader?prefix=/build/"
  }];

  grunt.initConfig({
    pkg: pkgConfig,
    webpack: {
      development: {
        entry: './<%= pkg.src %>/scripts/app.js',
        output: {
          path: '<%= pkg.src %>/build/',
          filename: '<%= pkg.mainOutput %>.js'
        },
        debug: true,
        cache: true,
        stats: {
          colors: true,
          reasons: true
        },
        jshint: grunt.util._.merge(jshintConfig, {
          emitErrors: false,
          failOnHint: false
        }),
        module: {
          preLoaders: [{
            test: '\\.js$',
            exclude: 'node_modules',
            loader: 'jshint'
          }],
          loaders: loaders
        }
      }
    },
    watch: {
      webpack: {
        files: ['<%= pkg.src %>/scripts/{,*/}*.js',
          '<%= pkg.src %>/styles/{,*/}*.css',
          '!<%= pkg.src %>/build/<%= pkg.mainOutput %>.js'
        ],
        tasks: ['webpack:development']
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: [
          '<%= pkg.src %>/{,*/}*.html',
          '<%= pkg.src %>/build/<%= pkg.mainOutput %>.js'
        ]
      }
    },
    connect: {
      options: {
        port: 8000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect, options) {
            return [
              lrSnippet,
              mountFolder(connect, "src/build"),
              mountFolder(connect, pkgConfig.src),
              function(req, res){
                for(var file, i = 0; i < pkgConfig.src.length; i++){
                  file = pkgConfig.src + "/index.html";
                  if (grunt.file.exists(file)){
                    require('fs').createReadStream(file).pipe(res);
                    return; // we're done
                  }
                }
                res.statusCode(404); // where's index.html?
                res.end();
              }
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, pkgConfig.dist)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'connect:livereload',
      'webpack:development',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('test', ['karma']);

  grunt.registerTask('build', []);

  grunt.registerTask('default', []);
};
<|endoftext|>