<commit_before>/*
 * grunt-notify-offenses
 * https://github.com/christian.monsegue/gruntplugins
 *
 * Copyright (c) 2013 Christian Monsegue
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      tests: ['tmp']
    },

    //Default configuration with save set to true to write output to file.
    notify_offenses: {
      default_with_save_options: {
        options: {
          save: true
        },
        files: {
          'tmp/no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/basic-inline-html': ['test/fixtures/basic-inline-1.html'],
          'tmp/basic-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/basic-inline-cbd': ['test/fixtures/basic-inline-1.cbd']
        }
      },
      /*Searches a user defined offense with global and case-insensitive flags and writes the output to a XML file.*/
      user_offense_to_xml: {
        options: {
          save: true,
          output: 'minimalxml',
          offenses : {
            "erroneous": {
              message: 'Erroneous attribute detected. Please remove.',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'global', 'i'],
              extensions: ['html']
            }
          }
        },
        files: {
          'tmp/user-xml-no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/user-xml-inline-html': ['test/fixtures/user-inline-1.html'],
          'tmp/user-xml-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/user-xml-inline-cfm': ['test/fixtures/user-inline-1.cfm']
        }
      },
      /*user - u, clean - c - all. override - o - true
      Searches a user defined offense with global and case-insensitive flags. Override is set to true, clean all lines of the outputs of all spaces and writes the output to a JSON file.*/
      uco_to_json: {
        options: {
          save: true,
          override: true,
          cleaner: 'all',
          output: 'json',
          offenses : {
            "style": {
              pattern: ['erroneous', 'i', 'g'],
              extensions: ['html', 'cbd']
            },
            "erroneous": {
              message: 'Erroneous attribute detected. Please remove.',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'g', 'i'],
              extensions: ['html']
            }
          }
        },
        files: {
          'tmp/uco-json-no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/uco-json-inline-html': ['test/fixtures/user-inline-1.html'],
          'tmp/uco-json-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/uco-json-inline-cbd': ['test/fixtures/user-inline-1.cbd']
        }
      },
      default_options: {
        options: {
          save: false,
          stout: 'plaintext',
          output: 'plaintext',
          override: false,
          offenses: {},
          force: true,
          tabwidth: 4,
          cleaner: 'none'
        },
        files: {
          'tmp/example-default-result': ['test/fixtures/inline-1.html']
        }
      },
      only_user_to_xml: {
        options: {
          save: true,
          output: 'minimalxml',
          override: true,
          offenses : {
            'Style': {
              message: 'Style is overriden and now looks for the "img src=\'\'" attribute with flags global and case-insentive in extension .html',
              pattern: ['img[\\s\\t]*src[\\s\\t]*\\=[\\s\\t]*(\'|\")', 'global', 'i'],
              extensions: ['html']
            },
            "erroneous": {
              message: 'Searches for the user-defined offense "erroneous" with flags global and case-insentive in extensions .html',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'g', 'i'],
              extensions: ['html']
            }
          },
          force: false
        },
        files: {
          'tmp/example-user-result': ['test/fixtures/inline-1.html']
        }
      },
      type_subset_to_json: {
        options: {
          stout: 'json',
          override: true,
          offenses : {
            'Style': [],
            'ALIGN': {
              message: 'New ALIGN Message showing that ALIGN is overriden.',
              pattern: ['align[\\s\\t]*=[\\s\\t]*(\'|\")', 'g', 'i']
            }
          },
          force: false
        },
        files: {
          'tmp/example-subset-result': ['test/fixtures/inline-1.html']
        }
      }
    },

    //Unit Tests
    nodeunit: {
      tests: ['test/*_test.js']
    }

  });

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

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

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  //['clean', 'notify_offenses', 'nodeunit']
  grunt.registerTask('test', 'Plugin Unit Tests', function () {
    grunt.task.run('clean');
    grunt.task.run('notify_offenses:default_with_save_options');
    grunt.task.run('notify_offenses:user_offense_to_xml');
    grunt.task.run('notify_offenses:uco_to_json');
    grunt.task.run('nodeunit');
  });

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

  grunt.registerTask('examples', 'README Examples', function () {
    grunt.task.run('clean');
    grunt.task.run('notify_offenses:default_options');
    grunt.task.run('notify_offenses:only_user_to_xml');
    grunt.task.run('notify_offenses:type_subset_to_json');
  });

};
<commit_msg>Document Gruntfile.js<commit_after>/*
 * grunt-notify-offenses
 * https://github.com/christian.monsegue/gruntplugins
 *
 * Copyright (c) 2013 Christian Monsegue
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      tests: ['tmp']
    },

    notify_offenses: {
      //Default configuration with save set to true to write output to file.
      default_with_save_options: {
        options: {
          save: true
        },
        files: {
          'tmp/no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/basic-inline-html': ['test/fixtures/basic-inline-1.html'],
          'tmp/basic-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/basic-inline-cbd': ['test/fixtures/basic-inline-1.cbd']
        }
      },
      /*Searches a user defined offense with global and case-insensitive flags and writes the output to a XML file.*/
      user_offense_to_xml: {
        options: {
          save: true,
          output: 'minimalxml',
          offenses : {
            "erroneous": {
              message: 'Erroneous attribute detected. Please remove.',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'global', 'i'],
              extensions: ['html']
            }
          }
        },
        files: {
          'tmp/user-xml-no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/user-xml-inline-html': ['test/fixtures/user-inline-1.html'],
          'tmp/user-xml-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/user-xml-inline-cfm': ['test/fixtures/user-inline-1.cfm']
        }
      },
      /*user - u, clean - c - all. override - o - true
      Searches a user defined offense with global and case-insensitive flags. Override is set to true, clean all lines of the outputs of all spaces and writes the output to a JSON file.*/
      uco_to_json: {
        options: {
          save: true,
          override: true,
          cleaner: 'all',
          output: 'json',
          offenses : {
            "style": {
              pattern: ['erroneous', 'i', 'g'],
              extensions: ['html', 'cbd']
            },
            "erroneous": {
              message: 'Erroneous attribute detected. Please remove.',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'g', 'i'],
              extensions: ['html']
            }
          }
        },
        files: {
          'tmp/uco-json-no-inline-html': ['test/fixtures/no-inline-1.html'],
          'tmp/uco-json-inline-html': ['test/fixtures/user-inline-1.html'],
          'tmp/uco-json-js-console-log': ['test/fixtures/basic-console-log-1.js'],
          'tmp/uco-json-inline-cbd': ['test/fixtures/user-inline-1.cbd']
        }
      },
      //README.md Usage Examples
      default_options: {
        options: {
          save: false,
          stout: 'plaintext',
          output: 'plaintext',
          override: false,
          offenses: {},
          force: true,
          tabwidth: 4,
          cleaner: 'none'
        },
        files: {
          'tmp/example-default-result': ['test/fixtures/inline-1.html']
        }
      },
      only_user_to_xml: {
        options: {
          save: true,
          output: 'minimalxml',
          override: true,
          offenses : {
            'Style': {
              message: 'Style is overriden and now looks for the "img src=\'\'" attribute with flags global and case-insentive in extension .html',
              pattern: ['img[\\s\\t]*src[\\s\\t]*\\=[\\s\\t]*(\'|\")', 'global', 'i'],
              extensions: ['html']
            },
            "erroneous": {
              message: 'Searches for the user-defined offense "erroneous" with flags global and case-insentive in extensions .html',
              pattern: ['erroneous[\\s\\t]*=[\\s\\t]*(\"|\')[\\s\\ta-z0-9\\-\\:\\;{}\\/\\(\\)\\+\\=\\&\\%\\#\\@\\!\\,\\$_\"\']*(\"|\')', 'g', 'i'],
              extensions: ['html']
            }
          },
          force: false
        },
        files: {
          'tmp/example-user-result': ['test/fixtures/inline-1.html']
        }
      },
      type_subset_to_json: {
        options: {
          stout: 'json',
          override: true,
          offenses : {
            'Style': [],
            'ALIGN': {
              message: 'New ALIGN Message showing that ALIGN is overriden.',
              pattern: ['align[\\s\\t]*=[\\s\\t]*(\'|\")', 'g', 'i']
            }
          },
          force: false
        },
        files: {
          'tmp/example-subset-result': ['test/fixtures/inline-1.html']
        }
      }
    },

    //Unit Tests
    nodeunit: {
      tests: ['test/*_test.js']
    }

  });

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

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

 /* 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', 'Plugin Unit Tests', function () {
    grunt.task.run('clean');
    grunt.task.run('notify_offenses:default_with_save_options');
    grunt.task.run('notify_offenses:user_offense_to_xml');
    grunt.task.run('notify_offenses:uco_to_json');
    grunt.task.run('nodeunit');
  });

  /*Whenever the "examples" task is run, first cean the "tmp" dir, then run the list of notify-offenses specific tasks.*/
  grunt.registerTask('doexamples', 'README Examples', function () {
    grunt.task.run('clean');
    grunt.task.run('notify_offenses:default_options');
    grunt.task.run('notify_offenses:only_user_to_xml');
    grunt.task.run('notify_offenses:type_subset_to_json');
  });

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

  /*When "example" task is run, first lint the files and then run the "doexample" task.*/
  grunt.registerTask('examples', ['jshint', 'doexamples']);

};
<|endoftext|>


<commit_before>var path = require('path');
var stylesheetsDir = 'www/less';

module.exports = function(grunt) {

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

    less: {
      compile: {
        options: {
          paths: [stylesheetsDir],
          compress: true,
          sourceMap: grunt.option('sourceMap') || false,
          sourceMapFilename: 'www/assets/css/compiled.min.css.map',
          outputSourceFiles: true,
          sourceMapURL: '/assets/css/compiled.min.css.map'
        },
        files: {
          'www/assets/css/compiled.css': stylesheetsDir + '/index.less'
        }
      }
    },

    // ------------------------------------------------------------------------
    // Handelbars
    //
    // Compile templates
    // ------------------------------------------------------------------------
    handlebars: {
      compile: {
        options: {
          partialsUseNamespace: true,
          namespace: "front",
          // commonjs: false,
          wrapped: true,
          amd: true,
          processName: function(filename) {
            return filename.replace('www/app/views/_templates/', '').replace('.hbs', '');
          }
        },
        src: "www/app/views/_templates/**/*.hbs",
        dest: "www/app/views/_templates/compiled.js",
        filter: function(filepath) {
          var filename = path.basename(filepath);
          // Exclude files that begin with '__' from being sent to the client,
          // i.e. __layout.hbs.
          return filename.slice(0, 2) !== '__';
        }
      }
    },

    // ------------------------------------------------------------------------
    // Require.js
    //
    // Compile the JS files
    // ------------------------------------------------------------------------
    requirejs: {
      compile: {
        options: {
          name : 'index',
          baseUrl: "www/app",
          generateSourceMaps: grunt.option('sourceMap') || false,
          optimize: "uglify2",
          preserveLicenseComments: false,
          mainConfigFile: "www/app/index.js",
          out: "www/assets/js/index.js"
        }
      }
    },

    // ------------------------------------------------------------------------
    // Watch these files for changes
    //
    // Do a task when the files change
    // ------------------------------------------------------------------------
    watch: {

      templates: {
        files: 'www/app/views/_templates/**/*.hbs',
        tasks: ['handlebars'],
        options: {
          interrupt: true
        }
      },
      stylesheets: {
        files: [stylesheetsDir + '/*.less', stylesheetsDir + '/**/*.less'],
        tasks: ['less'],
        options: {
          interrupt: true
        }
      },
      livereload: {
        // Here we watch the files the sass task will compile to
        // These files are sent to the live reload server after sass compiles to them
        options: { livereload: true },
        files: ['www/assets/css/*'],
      },
    }

  });

  // ------------------------------------------------------------------------
  // NPM Tasks
  // ------------------------------------------------------------------------
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-handlebars');
  grunt.loadNpmTasks('grunt-contrib-requirejs');

  // On compile
  grunt.registerTask('compile', ['requirejs', 'less', 'handlebars']);

  // Run the server and watch for file changes
  grunt.registerTask('server', ['watch']);

  // Default task(s).
  grunt.registerTask('default', ['server']);
};
<commit_msg>small change in gruntfile compile order<commit_after>var path = require('path');
var stylesheetsDir = 'www/less';

module.exports = function(grunt) {

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

    less: {
      compile: {
        options: {
          paths: [stylesheetsDir],
          compress: true,
          sourceMap: grunt.option('sourceMap') || false,
          sourceMapFilename: 'www/assets/css/compiled.min.css.map',
          outputSourceFiles: true,
          sourceMapURL: '/assets/css/compiled.min.css.map'
        },
        files: {
          'www/assets/css/compiled.css': stylesheetsDir + '/index.less'
        }
      }
    },

    // ------------------------------------------------------------------------
    // Handelbars
    //
    // Compile templates
    // ------------------------------------------------------------------------
    handlebars: {
      compile: {
        options: {
          partialsUseNamespace: true,
          namespace: "front",
          // commonjs: false,
          wrapped: true,
          amd: true,
          processName: function(filename) {
            return filename.replace('www/app/views/_templates/', '').replace('.hbs', '');
          }
        },
        src: "www/app/views/_templates/**/*.hbs",
        dest: "www/app/views/_templates/compiled.js",
        filter: function(filepath) {
          var filename = path.basename(filepath);
          // Exclude files that begin with '__' from being sent to the client,
          // i.e. __layout.hbs.
          return filename.slice(0, 2) !== '__';
        }
      }
    },

    // ------------------------------------------------------------------------
    // Require.js
    //
    // Compile the JS files
    // ------------------------------------------------------------------------
    requirejs: {
      compile: {
        options: {
          name : 'index',
          baseUrl: "www/app",
          generateSourceMaps: grunt.option('sourceMap') || false,
          optimize: "uglify2",
          preserveLicenseComments: false,
          mainConfigFile: "www/app/index.js",
          out: "www/assets/js/index.js"
        }
      }
    },

    // ------------------------------------------------------------------------
    // Watch these files for changes
    //
    // Do a task when the files change
    // ------------------------------------------------------------------------
    watch: {

      templates: {
        files: 'www/app/views/_templates/**/*.hbs',
        tasks: ['handlebars'],
        options: {
          interrupt: true
        }
      },
      stylesheets: {
        files: [stylesheetsDir + '/*.less', stylesheetsDir + '/**/*.less'],
        tasks: ['less'],
        options: {
          interrupt: true
        }
      },
      livereload: {
        // Here we watch the files the sass task will compile to
        // These files are sent to the live reload server after sass compiles to them
        options: { livereload: true },
        files: ['www/assets/css/*'],
      },
    }

  });

  // ------------------------------------------------------------------------
  // NPM Tasks
  // ------------------------------------------------------------------------
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-handlebars');
  grunt.loadNpmTasks('grunt-contrib-requirejs');

  // On compile
  grunt.registerTask('compile', ['less', 'handlebars', 'requirejs']);

  // Run the server and watch for file changes
  grunt.registerTask('server', ['watch']);

  // Default task(s).
  grunt.registerTask('default', ['server']);
};
<|endoftext|>


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

	'use strict'

	var gzip = require( 'gzip-js' ),
			srcHintOptions = readOptionalJSON( '/.jshintrc' )

	function readOptionalJSON( filepath ) {
		var data = {}

		try {
			data = grunt.file.readJSON( filepath )
		} catch ( e ) {}
		return data
	}

	// The concatenated file won't pass onevar
	// But our modules can
	delete srcHintOptions.onevar

	grunt.initConfig({
		pkg: grunt.file.readJSON( 'package.json' ),
		build: {
			all: {
				dest: './han.js'
			}
		},
		uglify: {
			all: {
				files: {
					'han.min.js': [ 'han.js' ]
				},
				options: {
					preserveComments: false,
					report: 'min',
					beautify: {
						ascii_only: true
					},
					banner: '/*!\n' +
						' * 漢字標準格式 v<%= pkg.version %> | MIT License | css.hanzi.co\n' +
						' * Han: CSS typography framework optimised for Hanzi\n' +
						' */\n',
					compress: {
						hoist_funs: false,
						loops: false,
						unused: false
					}
				}
			}
		}
	})

	// Load grunt tasks from NPM packages
	require( 'load-grunt-tasks' )( grunt )

	// Integrate jQuery specific tasks
	grunt.loadTasks( 'build' )

	grunt.registerTask( 'lint', [ 'jshint' ] )

	// Short list as a high frequency watch task
	grunt.registerTask( 'dev', [ 'build:*:*' ] )

	// Default grunt
	grunt.registerTask( 'default', [ 'dev', 'uglify' ] )
}
<commit_msg>Indent with 2 spaces instead<commit_after>
module.exports = function( grunt ) {

  'use strict'

  var gzip = require( 'gzip-js' ),
      srcHintOptions = readOptionalJSON( '/.jshintrc' )

  function readOptionalJSON( filepath ) {
    var data = {}

    try {
      data = grunt.file.readJSON( filepath )
    } catch ( e ) {}
    return data
  }

  // The concatenated file won't pass onevar
  // But our modules can
  delete srcHintOptions.onevar

  grunt.initConfig({
    pkg: grunt.file.readJSON( 'package.json' ),
    build: {
      all: {
        dest: './han.js'
      }
    },
    uglify: {
      all: {
        files: {
          'han.min.js': [ 'han.js' ]
        },
        options: {
          preserveComments: false,
          report: 'min',
          beautify: {
            ascii_only: true
          },
          banner: '/*!\n' +
            ' * 漢字標準格式 v<%= pkg.version %> | MIT License | css.hanzi.co\n' +
            ' * Han: CSS typography framework optimised for Hanzi\n' +
            ' */\n',
          compress: {
            hoist_funs: false,
            loops: false,
            unused: false
          }
        }
      }
    }
  })

  // Load grunt tasks from NPM packages
  require( 'load-grunt-tasks' )( grunt )

  // Integrate jQuery specific tasks
  grunt.loadTasks( 'build' )

  grunt.registerTask( 'lint', [ 'jshint' ] )

  // Short list as a high frequency watch task
  grunt.registerTask( 'dev', [ 'build:*:*' ] )

  // Default grunt
  grunt.registerTask( 'default', [ 'dev', 'uglify' ] )
}
<|endoftext|>


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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    connect: {
      server: {
        options: {
          hostname: '*',
          port: process.env.PORT || 3000,
          base: [ 'site' ]
        }
      }
    },
    copy: {
      images: {
        files: {
          'site/': [ 'images/**' ]
        }
      },
      js: {
        expand: true,
        cwd: 'assets/js/vendor/',
        src: 'html5shiv.js',
        dest: 'site/js/'
      },
      statics: {
        expand: true,
        cwd: 'static/',
        src: '**',
        dest: 'site/',
        dot: true
      }
    },
    clean: {
      site: [ 'site' ],
      tmp: [ 'assets/js/tmp' ]
    },
    less: {
      options: {
        cleancss: true,
        stripBanners: true,
        banner: '/*! Generated on <%= grunt.template.today("dddd, mmmm dS, ' +
          'yyyy, h:MM:ss TT") %> */\n'
      },
      simpleCinema: {
        files: {
          'site/css/simple-cinema.css': [ 'assets/css/application.less' ]
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      js: {
        files: [ 'assets/js/**/*' ],
        tasks: [ 'uglify', 'concat' ]
      },
      css: {
        files: [ 'assets/css/**/*' ],
        tasks: [ 'less' ]
      },
      grunt: {
        files: [ 'Gruntfile.js' ]
      },
      index: {
        files: [ 'layouts/*', 'helpers/*', 'pages/*', 'posts/**/*' ],
        tasks: [ 'assemble' ]
      }
    },
    uglify: {
      javascripts: {
        files: [{
          expand: true,
          cwd: 'assets/js',
          src: [ '*.js', 'vendor/*.js', '!vendor/*.min.js', '!vendor/html5shiv.js' ],
          dest: 'assets/js/tmp/'
        }]
      }
    },
    concat: {
      options: {
        banner: '/*! Generated on <%= grunt.template.today("dddd, mmmm dS, ' +
          'yyyy, h:MM:ss TT") %> */\n'
      },
      js: {
        files: {
          'site/js/application.js': [
            'assets/js/tmp/vendor/fastclick.js',
            'assets/js/vendor/jquery-*.min.js',
            'assets/js/vendor/*.min.js',
            'assets/js/tmp/**/*.js'
          ]
        }
      }
    },
    assemble: {
      options: {
        pkg: '<%= pkg %>',
        plugins: [ 'assemble-permalink', 'helpers/all-pages.js', 'helpers/trim.js' ],
        helpers: [ 'handlebars-helper-prettify', 'helpers/helpers.js' ],
        layoutdir: 'layouts',
        layout: 'default.hbs',
        production: false,
        prettify: {
          unformatted: [ 'a', 'sub', 'sup', 'b', 'i', 'u', 'textarea', 'pre' ]
        },
        posts: {
          work: grunt.file.readYAML('posts/work.yml'),
          work2: grunt.file.readYAML('posts/work2.yml')
        }
      },
      blog: {
        options: {
          layout: 'blogpost.hbs',
          permalink: '/blog/{{ basename }}/'
        },
        files: {
          'site/': [ 'pages/~blog*.hbs', 'posts/blog/**/*.md' ]
        }
      },
      work: {
        options: {
          layout: 'work.hbs',
          pages: '<%= assemble.options.posts.work %>'
        },
        files: {
          'site/' : []
        }
      },
      work2: {
        options: {
          layout: 'work.hbs',
          pages: '<%= assemble.options.posts.work2 %>'
        },
        files: {
          'site/' : []
        }
      },
      site: {
        files: {
          'site/': [ 'pages/*.hbs', '!pages/~*.hbs' ]
        }
      },
      sitemap: {
        files: {
          'site/': [ 'pages/~sitemap.hbs' ]
        }
      }
    }
  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('assemble-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('common', [
    'clean',
    'less',
    'uglify',
    'concat',
    'copy',
    'make-blog-index',
    'clean:tmp'
  ]);

  grunt.registerTask('default', [
    'common',
    'assemble',
    'connect',
    'watch'
  ]);

  grunt.registerTask('make', [
    'common',
    'hash',
    'assemble_in_production',
    'assemble'
  ]);

  grunt.registerTask('assemble_in_production', 'Enter production mode.',
    function() {
    grunt.config('assemble.options.production', true);
    grunt.log.ok('Entered production mode.');
  });

  grunt.registerTask('make-blog-index', '', function() {
    var blogposts = grunt.config('assemble.options.all_blog') || [];
    blogposts = blogposts.reverse();
    grunt.file.write('site/blog/index.json', JSON.stringify(blogposts));
    grunt.log.ok('Generated blog index.')
  });

  grunt.registerTask('hash', 'Generate asset hash filenames', function() {
    var path = require('path');
    var crypto = require('crypto');
    var fs = require('fs');
    var sitedir = 'site';
    var assets = grunt.file.expand({
      cwd: sitedir
    }, 'js/*.js', 'css/*.css');
    var compiled_assets = grunt.config('assemble.options.compiled_assets') || {};
    for (var i = 0; i < assets.length; i++) {
      var old_filename = path.join(sitedir, assets[i]);
      var js = fs.readFileSync(old_filename);
      shasum = crypto.createHash('sha1');
      shasum.update(js);
      var hash = shasum.digest('hex');
      var dot = old_filename.lastIndexOf('.');
      if (dot === -1) dot = undefined;
      var new_filename = old_filename.slice(0, dot);
      new_filename += '-' + hash + old_filename.slice(dot);
      fs.renameSync(old_filename, new_filename);
      grunt.log.ok('File ' + old_filename + ' renamed to ' + new_filename);
      var site = sitedir.length;
      compiled_assets[old_filename.slice(site)] = new_filename.slice(site);
    }
    grunt.config('assemble.options.compiled_assets', compiled_assets);
  });

};
<commit_msg>move grunt task;<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    connect: {
      server: {
        options: {
          hostname: '*',
          port: process.env.PORT || 3000,
          base: [ 'site' ]
        }
      }
    },
    copy: {
      images: {
        files: {
          'site/': [ 'images/**' ]
        }
      },
      js: {
        expand: true,
        cwd: 'assets/js/vendor/',
        src: 'html5shiv.js',
        dest: 'site/js/'
      },
      statics: {
        expand: true,
        cwd: 'static/',
        src: '**',
        dest: 'site/',
        dot: true
      }
    },
    clean: {
      site: [ 'site' ],
      tmp: [ 'assets/js/tmp' ]
    },
    less: {
      options: {
        cleancss: true,
        stripBanners: true,
        banner: '/*! Generated on <%= grunt.template.today("dddd, mmmm dS, ' +
          'yyyy, h:MM:ss TT") %> */\n'
      },
      simpleCinema: {
        files: {
          'site/css/simple-cinema.css': [ 'assets/css/application.less' ]
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      js: {
        files: [ 'assets/js/**/*' ],
        tasks: [ 'uglify', 'concat' ]
      },
      css: {
        files: [ 'assets/css/**/*' ],
        tasks: [ 'less' ]
      },
      grunt: {
        files: [ 'Gruntfile.js' ]
      },
      index: {
        files: [ 'layouts/*', 'helpers/*', 'pages/*', 'posts/**/*' ],
        tasks: [ 'assemble' ]
      }
    },
    uglify: {
      javascripts: {
        files: [{
          expand: true,
          cwd: 'assets/js',
          src: [ '*.js', 'vendor/*.js', '!vendor/*.min.js', '!vendor/html5shiv.js' ],
          dest: 'assets/js/tmp/'
        }]
      }
    },
    concat: {
      options: {
        banner: '/*! Generated on <%= grunt.template.today("dddd, mmmm dS, ' +
          'yyyy, h:MM:ss TT") %> */\n'
      },
      js: {
        files: {
          'site/js/application.js': [
            'assets/js/tmp/vendor/fastclick.js',
            'assets/js/vendor/jquery-*.min.js',
            'assets/js/vendor/*.min.js',
            'assets/js/tmp/**/*.js'
          ]
        }
      }
    },
    assemble: {
      options: {
        pkg: '<%= pkg %>',
        plugins: [ 'assemble-permalink', 'helpers/all-pages.js', 'helpers/trim.js' ],
        helpers: [ 'handlebars-helper-prettify', 'helpers/helpers.js' ],
        layoutdir: 'layouts',
        layout: 'default.hbs',
        production: false,
        prettify: {
          unformatted: [ 'a', 'sub', 'sup', 'b', 'i', 'u', 'textarea', 'pre' ]
        },
        posts: {
          work: grunt.file.readYAML('posts/work.yml'),
          work2: grunt.file.readYAML('posts/work2.yml')
        }
      },
      blog: {
        options: {
          layout: 'blogpost.hbs',
          permalink: '/blog/{{ basename }}/'
        },
        files: {
          'site/': [ 'pages/~blog*.hbs', 'posts/blog/**/*.md' ]
        }
      },
      work: {
        options: {
          layout: 'work.hbs',
          pages: '<%= assemble.options.posts.work %>'
        },
        files: {
          'site/' : []
        }
      },
      work2: {
        options: {
          layout: 'work.hbs',
          pages: '<%= assemble.options.posts.work2 %>'
        },
        files: {
          'site/' : []
        }
      },
      site: {
        files: {
          'site/': [ 'pages/*.hbs', '!pages/~*.hbs' ]
        }
      },
      sitemap: {
        files: {
          'site/': [ 'pages/~sitemap.hbs' ]
        }
      }
    }
  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('assemble-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('common', [
    'clean',
    'less',
    'uglify',
    'concat',
    'copy',
    'clean:tmp'
  ]);

  grunt.registerTask('default', [
    'common',
    'assemble',
    'make-blog-index',
    'connect',
    'watch'
  ]);

  grunt.registerTask('make', [
    'common',
    'hash',
    'assemble_in_production',
    'assemble',
    'make-blog-index'
  ]);

  grunt.registerTask('assemble_in_production', 'Enter production mode.',
    function() {
    grunt.config('assemble.options.production', true);
    grunt.log.ok('Entered production mode.');
  });

  grunt.registerTask('make-blog-index', '', function() {
    var blogposts = grunt.config('assemble.options.all_blog') || [];
    blogposts = blogposts.reverse();
    grunt.file.write('site/blog/index.json', JSON.stringify(blogposts));
    grunt.log.ok('Generated blog index.')
  });

  grunt.registerTask('hash', 'Generate asset hash filenames', function() {
    var path = require('path');
    var crypto = require('crypto');
    var fs = require('fs');
    var sitedir = 'site';
    var assets = grunt.file.expand({
      cwd: sitedir
    }, 'js/*.js', 'css/*.css');
    var compiled_assets = grunt.config('assemble.options.compiled_assets') || {};
    for (var i = 0; i < assets.length; i++) {
      var old_filename = path.join(sitedir, assets[i]);
      var js = fs.readFileSync(old_filename);
      shasum = crypto.createHash('sha1');
      shasum.update(js);
      var hash = shasum.digest('hex');
      var dot = old_filename.lastIndexOf('.');
      if (dot === -1) dot = undefined;
      var new_filename = old_filename.slice(0, dot);
      new_filename += '-' + hash + old_filename.slice(dot);
      fs.renameSync(old_filename, new_filename);
      grunt.log.ok('File ' + old_filename + ' renamed to ' + new_filename);
      var site = sitedir.length;
      compiled_assets[old_filename.slice(site)] = new_filename.slice(site);
    }
    grunt.config('assemble.options.compiled_assets', compiled_assets);
  });

};
<|endoftext|>


<commit_before>/* jshint node: true */

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

	var fs = require('fs')
		,_ = require('underscore')
		,path = require('path');

	var init_project = function(project_name){
		if (grunt.config.get('initialized') == true) return grunt.config.get('project');
		if (! project_name){
			grunt.log.error('Specify a project name like this... grunt <command>:project-name');
			return false;
		}
		var p = path.join('projects', project_name);
		var cfg_path = path.join(p, 'project.json');
		var project;
		if (fs.existsSync(cfg_path)){
			project = grunt.file.readJSON(cfg_path);
		} else {
			project = {
				name: project_name
				, description: 'New project. Put your description here.'
				, version: '0.0.0'
				, targets: []
			};
		}

		var version = project.version.split('.');
		var last = parseInt(version.pop());
		version.push(last + 1);
		project.version = version.join('.');

		var cfg = {
			initialized: true,
			pkg: grunt.file.readJSON('package.json'),
			project: project,
			project_path: p,
			date: new Date().toUTCString(),
			bootstrap_directory: path.resolve('bootstrap'),
			bootstrap_pkg: grunt.file.readJSON('bootstrap/package.json'),
			banner: '/*!\n' +
				' * <%= project.name %> v. <%= project.version %> Compiled by <%= pkg.english_name %> at <%= date %>.\n' +
				' * \n' +
				' * Bootstrap v<%= bootstrap_pkg.version %> by @fat and @mdo\n' +
				' * Copyright <%= grunt.template.today("yyyy") %> <%= bootstrap_pkg.author %>\n' +
				' * Licensed under <%= _.pluck(bootstrap_pkg.licenses, "url").join(", ") %>\n' +
				' *\n' +
				' * Designed and built with all the love in the world by @mdo and @fat.\n' +
				' */\n',
			jqueryCheck: 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }\n\n',
			recess: {
				options: {
					compile: true,
					banner: '<%= banner %>'
				},
				full: {
					src: ['projects/<%= project.name %>/less/style.less'],
					dest: 'projects/<%= project.name %>/assets/css/style.css'
				},
				min: {
					options: {
						compress: true
					},
					src: ['projects/<%= project.name %>/less/style.less'],
					dest: 'projects/<%= project.name %>/assets/css/style.min.css'
				}
			},
			uglify: {

				bootstrap: {
					options: {
						banner: '<%= banner %>',
						report: 'min'
					},
					src: ['<%= concat.bootstrap.dest %>'],
					dest: 'projects/<%= project.name %>/assets/js/<%= bootstrap_pkg.name %>.min.js'
				},
				user: {
					options:{
						banner: '/*!\n' +
							' * <%= project.name %> v. <%= project.version %> Compiled by <%= pkg.english_name %> at <%= date %>.\n' +
							' * \n',
						report: 'min',
						files: {}
					}
				}
			},
			concat: {

				bootstrap: {
					options: {
						banner: '<%= banner %><%= jqueryCheck %>',
						stripBanners: false
					},
					src: [
						'<%= bootstrap_directory %>/js/transition.js',
						'<%= bootstrap_directory %>/js/alert.js',
						'<%= bootstrap_directory %>/js/button.js',
						'<%= bootstrap_directory %>/js/carousel.js',
						'<%= bootstrap_directory %>/js/collapse.js',
						'<%= bootstrap_directory %>/js/dropdown.js',
						'<%= bootstrap_directory %>/js/modal.js',
						'<%= bootstrap_directory %>/js/tooltip.js',
						'<%= bootstrap_directory %>/js/popover.js',
						'<%= bootstrap_directory %>/js/scrollspy.js',
						'<%= bootstrap_directory %>/js/tab.js',
						'<%= bootstrap_directory %>/js/affix.js'
					],
					dest: 'projects/<%= project.name %>/assets/js/<%= bootstrap_pkg.name %>.js'
				}
			},

			clean: {
				options: {force: true},
				update_css: [],
				update_fonts: [],
				update_js: []
			},
			copy: {
				init_project: {
					files: [
						{
							expand: true,
							src: ['**'],
							dest: 'projects/<%= project.name %>',
							cwd: 'sample-project/'
						}
					]

				},
				update_fonts: {
					files: [
						{
							expand: true,
							src: ['**'],
							dest: 'projects/<%= project.name %>/assets/fonts',
							cwd: '<%= bootstrap_directory %>/fonts/'
						}
					]

				},

				update_js: {
					files: []
				},
				update_css: {
					files: []
				}
			},
			watch: {
				recess: {
					files: 'projects/<%= project.name %>/less/*.less',
					tasks: ['update-css', 'bump']
				}
			}
		};

		_.each(project.targets, function(target){
			cfg.clean.update_fonts.push(target + '/assets/fonts');
			cfg.clean.update_js.push(target + '/assets/js');
			cfg.clean.update_css.push(target + '/assets/css');
			cfg.copy.update_fonts.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/fonts',
				cwd: 'projects/<%= project.name %>/assets/fonts/'
			});
			cfg.copy.update_js.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/js',
				cwd: 'projects/<%= project.name %>/assets/js/'
			});
			cfg.copy.update_css.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/css',
				cwd: 'projects/<%= project.name %>/assets/css/'
			});
		});

		grunt.initConfig(cfg);

		return grunt.config.get('project');
	};

	// These plugins provide necessary tasks.
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-recess');

	grunt.registerTask('bump', 'Bump a project\'s version.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var p = path.join('projects', project.name);
		var cfg_p = path.join(p, 'project.json');
		grunt.file.write(cfg_p, JSON.stringify( project, null, '\t'));
		return true;
	});

	grunt.registerTask('update-fonts', 'Update a project\'s fonts.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = ['clean:update_fonts', 'copy:update_fonts'];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('update-bootstrap-js', 'Update a project\'s bootstrap js.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = ['concat:bootstrap','uglify:bootstrap', 'clean:update_js', 'copy:update_js'];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('update-css', 'Update a project\'s css.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = [
			'recess:full',
			'recess:min',
			'clean:update_css',
			'copy:update_css'
		];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	// Project initialization.
	grunt.registerTask('init', 'Initialize a project.', function(project_name){

		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var p = grunt.config.get('project_path');
		if (fs.existsSync(p)){
			grunt.log.error('A project at ' + p + ' already exists.');
			return false;
		}
		var q = [
			'copy:init_project',
			'update-fonts',
			'update-bootstrap-js',
			'update-css',
			'bump'
		];
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('watcher','Watch a project\'s less files and compile into css.',function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		grunt.task.run(
			'update-css',
			'bump',
			'watch'
		);
		return true;
	});

};
<commit_msg>changed the task name to watch-css<commit_after>/* jshint node: true */

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

	var fs = require('fs')
		,_ = require('underscore')
		,path = require('path');

	var init_project = function(project_name){
		if (grunt.config.get('initialized') == true) return grunt.config.get('project');
		if (! project_name){
			grunt.log.error('Specify a project name like this... grunt <command>:project-name');
			return false;
		}
		var p = path.join('projects', project_name);
		var cfg_path = path.join(p, 'project.json');
		var project;
		if (fs.existsSync(cfg_path)){
			project = grunt.file.readJSON(cfg_path);
		} else {
			project = {
				name: project_name
				, description: 'New project. Put your description here.'
				, version: '0.0.0'
				, targets: []
			};
		}

		var version = project.version.split('.');
		var last = parseInt(version.pop());
		version.push(last + 1);
		project.version = version.join('.');

		var cfg = {
			initialized: true,
			pkg: grunt.file.readJSON('package.json'),
			project: project,
			project_path: p,
			date: new Date().toUTCString(),
			bootstrap_directory: path.resolve('bootstrap'),
			bootstrap_pkg: grunt.file.readJSON('bootstrap/package.json'),
			banner: '/*!\n' +
				' * <%= project.name %> v. <%= project.version %> Compiled by <%= pkg.english_name %> at <%= date %>.\n' +
				' * \n' +
				' * Bootstrap v<%= bootstrap_pkg.version %> by @fat and @mdo\n' +
				' * Copyright <%= grunt.template.today("yyyy") %> <%= bootstrap_pkg.author %>\n' +
				' * Licensed under <%= _.pluck(bootstrap_pkg.licenses, "url").join(", ") %>\n' +
				' *\n' +
				' * Designed and built with all the love in the world by @mdo and @fat.\n' +
				' */\n',
			jqueryCheck: 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }\n\n',
			recess: {
				options: {
					compile: true,
					banner: '<%= banner %>'
				},
				full: {
					src: ['projects/<%= project.name %>/less/style.less'],
					dest: 'projects/<%= project.name %>/assets/css/style.css'
				},
				min: {
					options: {
						compress: true
					},
					src: ['projects/<%= project.name %>/less/style.less'],
					dest: 'projects/<%= project.name %>/assets/css/style.min.css'
				}
			},
			uglify: {

				bootstrap: {
					options: {
						banner: '<%= banner %>',
						report: 'min'
					},
					src: ['<%= concat.bootstrap.dest %>'],
					dest: 'projects/<%= project.name %>/assets/js/<%= bootstrap_pkg.name %>.min.js'
				},
				user: {
					options:{
						banner: '/*!\n' +
							' * <%= project.name %> v. <%= project.version %> Compiled by <%= pkg.english_name %> at <%= date %>.\n' +
							' * \n',
						report: 'min',
						files: {}
					}
				}
			},
			concat: {

				bootstrap: {
					options: {
						banner: '<%= banner %><%= jqueryCheck %>',
						stripBanners: false
					},
					src: [
						'<%= bootstrap_directory %>/js/transition.js',
						'<%= bootstrap_directory %>/js/alert.js',
						'<%= bootstrap_directory %>/js/button.js',
						'<%= bootstrap_directory %>/js/carousel.js',
						'<%= bootstrap_directory %>/js/collapse.js',
						'<%= bootstrap_directory %>/js/dropdown.js',
						'<%= bootstrap_directory %>/js/modal.js',
						'<%= bootstrap_directory %>/js/tooltip.js',
						'<%= bootstrap_directory %>/js/popover.js',
						'<%= bootstrap_directory %>/js/scrollspy.js',
						'<%= bootstrap_directory %>/js/tab.js',
						'<%= bootstrap_directory %>/js/affix.js'
					],
					dest: 'projects/<%= project.name %>/assets/js/<%= bootstrap_pkg.name %>.js'
				}
			},

			clean: {
				options: {force: true},
				update_css: [],
				update_fonts: [],
				update_js: []
			},
			copy: {
				init_project: {
					files: [
						{
							expand: true,
							src: ['**'],
							dest: 'projects/<%= project.name %>',
							cwd: 'sample-project/'
						}
					]

				},
				update_fonts: {
					files: [
						{
							expand: true,
							src: ['**'],
							dest: 'projects/<%= project.name %>/assets/fonts',
							cwd: '<%= bootstrap_directory %>/fonts/'
						}
					]

				},

				update_js: {
					files: []
				},
				update_css: {
					files: []
				}
			},
			watch: {
				recess: {
					files: 'projects/<%= project.name %>/less/*.less',
					tasks: ['update-css', 'bump']
				}
			}
		};

		_.each(project.targets, function(target){
			cfg.clean.update_fonts.push(target + '/assets/fonts');
			cfg.clean.update_js.push(target + '/assets/js');
			cfg.clean.update_css.push(target + '/assets/css');
			cfg.copy.update_fonts.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/fonts',
				cwd: 'projects/<%= project.name %>/assets/fonts/'
			});
			cfg.copy.update_js.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/js',
				cwd: 'projects/<%= project.name %>/assets/js/'
			});
			cfg.copy.update_css.files.push({
				expand: true,
				src: ['**'],
				dest: target + '/assets/css',
				cwd: 'projects/<%= project.name %>/assets/css/'
			});
		});

		grunt.initConfig(cfg);

		return grunt.config.get('project');
	};

	// These plugins provide necessary tasks.
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-recess');

	grunt.registerTask('bump', 'Bump a project\'s version.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var p = path.join('projects', project.name);
		var cfg_p = path.join(p, 'project.json');
		grunt.file.write(cfg_p, JSON.stringify( project, null, '\t'));
		return true;
	});

	grunt.registerTask('update-fonts', 'Update a project\'s fonts.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = ['clean:update_fonts', 'copy:update_fonts'];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('update-bootstrap-js', 'Update a project\'s bootstrap js.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = ['concat:bootstrap','uglify:bootstrap', 'clean:update_js', 'copy:update_js'];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('update-css', 'Update a project\'s css.', function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var q = [
			'recess:full',
			'recess:min',
			'clean:update_css',
			'copy:update_css'
		];
		if (project_name) q.push('bump');
		grunt.task.run(q);
		return true;
	});

	// Project initialization.
	grunt.registerTask('init', 'Initialize a project.', function(project_name){

		var project = init_project(project_name);
		if (! project){
			return false;
		}
		var p = grunt.config.get('project_path');
		if (fs.existsSync(p)){
			grunt.log.error('A project at ' + p + ' already exists.');
			return false;
		}
		var q = [
			'copy:init_project',
			'update-fonts',
			'update-bootstrap-js',
			'update-css',
			'bump'
		];
		grunt.task.run(q);
		return true;
	});

	grunt.registerTask('watch-css','Watch a project\'s less files and compile into css.',function(project_name){
		var project = init_project(project_name);
		if (! project){
			return false;
		}
		grunt.task.run(
			'update-css',
			'bump',
			'watch'
		);
		return true;
	});

};
<|endoftext|>


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

  grunt.initConfig({

    requirejs: {
      compile: {
        options: {
          // All paths will be relative to this baseUrl
          baseUrl: "src",
          // Tells r.js that you want everything in one file.
          out: "dist/mylib.js",
          // Usually, you would use the name parameter to specify your main module
          // but we’re using include here because we’re bundling almond.js loader as well
          include: ['../vendor/almond', 'mylib'],
          // Insert require([]) at the end of the built file to trigger module loading
          insertRequire: ['mylib'],
          // Wrap everything into IIFE: (function() { + content + }());
          wrap: true,

          optimize: 'none',
          preserveLicenseComments: false
        }
      }
    },

    uglify: {
      release: {
        files: {
          "dist/mylib.min.js": "dist/mylib.js"
        }
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.registerTask('default', ['requirejs', 'uglify']);
};
<commit_msg>added a few more comments<commit_after>module.exports = function(grunt) {
  grunt.initConfig({

    requirejs: {
      compile: {
        options: {
          // All paths will be relative to this baseUrl
          baseUrl: "src",
          // Tells r.js that you want everything in one file
          out: "dist/mylib.js",
          // Usually, you would use the name parameter to specify your main module
          // but we’re using include here because we’re bundling almond.js loader as well
          include: ['../vendor/almond', 'mylib'],
          // Insert require([]) at the end of the built file to trigger module loading
          insertRequire: ['mylib'],
          // Wrap everything into IIFE: (function() { + content + }());
          wrap: true,
          // No minification will be done
          optimize: 'none',
          // Remove license comments from the built file
          preserveLicenseComments: false
        }
      }
    },

    uglify: {
      release: {
        files: {
          "dist/mylib.min.js": "dist/mylib.js"
        }
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');

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


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    info: grunt.file.readJSON('bower.json'),
    meta: {
      banner: '/*!\n'+
              ' * <%= info.name %> - <%= info.description %>\n'+
              ' * v<%= info.version %>\n'+
              ' * <%= info.homepage %>\n'+
              ' * copyright <%= info.copyright %> <%= grunt.template.today("yyyy") %>\n'+
              ' * <%= info.license %> License\n'+
              '*/\n'
    },
    jshint: {
      main: [
        'Gruntfile.js',
        'bower.json',
        'lib/**/*.js',
        'test/*.js'
      ]
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: [
          'lib/fidel.js',
          'lib/jquery.js'
        ],
        dest: 'dist/fidel.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: 'dist/fidel.js',
        dest: 'dist/fidel.min.js'
      }
    },
    watch: {
      main: {
        files: '<%= jshint.main %>',
        tasks: 'scripts'
      },
      ci: {
        files: [
          'Gruntfile.js',
          'test/index.html'
        ],
        tasks: ['default']
      }
    },
    mocha: {
      all: {
        src: 'test/index.html',
        options: {
          run: true,
          growl: true
        }
      }
    },
    plato: {
      main: {
        files: {
          'reports': ['lib/*.js']
        }
      }
    },
    reloadr: {
      main: [
        'example/*',
        'dist/*'
      ]
    },
    connect: {
      server:{
        port: 8000,
        base: '.'
      },
      plato: {
        port: 8000,
        base: 'reports',
        options: {
          keepalive: true
        }
      },
    },
    bytesize: {
      scripts: {
        src: [
          'dist/*'
        ]
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-bytesize');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-reloadr');
  grunt.loadNpmTasks('grunt-plato');
  grunt.registerTask('scripts', ['jshint', 'concat', 'uglify', 'mocha', 'bytesize']);
  grunt.registerTask('default', ['scripts']);
  grunt.registerTask('dev', ['connect:server', 'reloadr', 'watch:main']);
  grunt.registerTask('reports', ['plato', 'connect:plato']);
};
<commit_msg>updated mocha reporter to spec<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    info: grunt.file.readJSON('bower.json'),
    meta: {
      banner: '/*!\n'+
              ' * <%= info.name %> - <%= info.description %>\n'+
              ' * v<%= info.version %>\n'+
              ' * <%= info.homepage %>\n'+
              ' * copyright <%= info.copyright %> <%= grunt.template.today("yyyy") %>\n'+
              ' * <%= info.license %> License\n'+
              '*/\n'
    },
    jshint: {
      main: [
        'Gruntfile.js',
        'bower.json',
        'lib/**/*.js',
        'test/*.js'
      ]
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: [
          'lib/fidel.js',
          'lib/jquery.js'
        ],
        dest: 'dist/fidel.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: 'dist/fidel.js',
        dest: 'dist/fidel.min.js'
      }
    },
    watch: {
      main: {
        files: '<%= jshint.main %>',
        tasks: 'scripts'
      },
      ci: {
        files: [
          'Gruntfile.js',
          'test/index.html'
        ],
        tasks: ['default']
      }
    },
    mocha: {
      all: {
        src: 'test/index.html',
        options: {
          run: true,
          growl: true,
          reporter: 'Spec'
        }
      }
    },
    plato: {
      main: {
        files: {
          'reports': ['lib/*.js']
        }
      }
    },
    reloadr: {
      main: [
        'example/*',
        'dist/*'
      ]
    },
    connect: {
      server:{
        port: 8000,
        base: '.'
      },
      plato: {
        port: 8000,
        base: 'reports',
        options: {
          keepalive: true
        }
      },
    },
    bytesize: {
      scripts: {
        src: [
          'dist/*'
        ]
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-bytesize');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-reloadr');
  grunt.loadNpmTasks('grunt-plato');
  grunt.registerTask('scripts', ['jshint', 'concat', 'uglify', 'mocha', 'bytesize']);
  grunt.registerTask('default', ['scripts']);
  grunt.registerTask('dev', ['connect:server', 'reloadr', 'watch:main']);
  grunt.registerTask('reports', ['plato', 'connect:plato']);
};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function (grunt) {
    'use strict';

    // Project configuration.
    grunt.initConfig({
        // Metadata.
        pkg: grunt.file.readJSON('package.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 <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',

        // Task configuration.
//        jshint: {
//            platform: 'webapp/js/platform/**/*.js',
//            tmf: 'webapp/js/tmf/**/*.js',
//
//            options: {
//                jshintrc: '.jshintrc'
//            }
//        },

        bower: {
            install: {
                options: {
                    copy: false,
                    install: true,
                    verbose: false,
                    cleanTargetDir: false,
                    cleanBowerDir: false,
                    bowerOptions: {}
                }
            }
        },

        react: {
            options: {
                extension: 'js'
            },
            app: {
                files: {
                    'js-built': 'js'
                }
            }
        },

        requirejs: {
            compile: {
                options: {

                    optimize: 'none',
                    inlineText: true,
                    useStrict: true,
                    skipPragmas: true,
                    preserveLicenseComments: true,

                    out: 'dist/wingspan-forms.js',
                    include: ['almond', 'wingspan-forms'],
                    exclude: ['jquery', 'underscore', 'react', 'moment', 'require',
                              'text', 'underscore-string', 'kendo'],
                    wrap: {
                        "startFile": "almond-begin.txt",
                        "endFile": "almond-end.txt"
                    },

                    baseUrl: 'js-built',

                    paths: {
                        textassets: '../textassets', // all assets loaded via `text!` must be rooted here so the JSX compiler works.
                        text: '../bower_components/requirejs-text/text',
                        underscore: '../bower_components/underscore/underscore',
                        'underscore-string': '../bower_components/underscore.string/lib/underscore.string',
                        jquery: '../bower_components/jquery/jquery',
                        kendo: '../bower_components/kendo-ui/src/js/kendo.web',
                        moment: '../bower_components/momentjs/moment',
                        react: '../bower_components/react/react',
                        stacktrace: '../bower_components/stacktrace/stacktrace',
                        almond: '../bower_components/almond/almond'
                    },

                    shim: {
                        'underscore': { deps: [], exports: '_' },
                        'underscore-string': { exports: ['_s'] },
                        'jquery': { deps: [], exports: '$' },
                        'kendo': { deps: [], exports: 'kendo' },
                        'moment': { deps: [], exports: 'moment' },
                        'react': { deps: [], exports: 'React'}
                    },

                    uglify: {
                        toplevel: true,
                        ascii_only: true,
                        beautify: true,
                        max_line_length: 1000,
                        defines: { DEBUG: ['name', 'false'] },
                        no_mangle: true
                    }
                }
            }
        },

        less: {
            development: {
                options: {
                    paths: [
                        'styles'
                    ],
                    ieCompat: true,
                    yuicompress: true,
                    report: 'min'
                },
                files: {
                    'dist/wingspan-forms.css': 'styles/app.less'
                }
            }
        },

        qunit: {
            files: ['test/**/*.html']
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-react');
    grunt.loadNpmTasks('grunt-bower-task');

    // Default task.
    grunt.registerTask('default', []);
};
<commit_msg>default grunt task<commit_after>/*global module:false*/
module.exports = function (grunt) {
    'use strict';

    // Project configuration.
    grunt.initConfig({
        // Metadata.
        pkg: grunt.file.readJSON('package.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 <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',

        // Task configuration.
//        jshint: {
//            platform: 'webapp/js/platform/**/*.js',
//            tmf: 'webapp/js/tmf/**/*.js',
//
//            options: {
//                jshintrc: '.jshintrc'
//            }
//        },

        bower: {
            install: {
                options: {
                    copy: false,
                    install: true,
                    verbose: false,
                    cleanTargetDir: false,
                    cleanBowerDir: false,
                    bowerOptions: {}
                }
            }
        },

        react: {
            options: {
                extension: 'js'
            },
            app: {
                files: {
                    'js-built': 'js'
                }
            }
        },

        requirejs: {
            compile: {
                options: {

                    optimize: 'none',
                    inlineText: true,
                    useStrict: true,
                    skipPragmas: true,
                    preserveLicenseComments: true,

                    out: 'dist/wingspan-forms.js',
                    include: ['almond', 'wingspan-forms'],
                    exclude: ['jquery', 'underscore', 'react', 'moment', 'require',
                              'text', 'underscore-string', 'kendo'],
                    wrap: {
                        "startFile": "almond-begin.txt",
                        "endFile": "almond-end.txt"
                    },

                    baseUrl: 'js-built',

                    paths: {
                        textassets: '../textassets', // all assets loaded via `text!` must be rooted here so the JSX compiler works.
                        text: '../bower_components/requirejs-text/text',
                        underscore: '../bower_components/underscore/underscore',
                        'underscore-string': '../bower_components/underscore.string/lib/underscore.string',
                        jquery: '../bower_components/jquery/jquery',
                        kendo: '../bower_components/kendo-ui/src/js/kendo.web',
                        moment: '../bower_components/momentjs/moment',
                        react: '../bower_components/react/react',
                        stacktrace: '../bower_components/stacktrace/stacktrace',
                        almond: '../bower_components/almond/almond'
                    },

                    shim: {
                        'underscore': { deps: [], exports: '_' },
                        'underscore-string': { exports: ['_s'] },
                        'jquery': { deps: [], exports: '$' },
                        'kendo': { deps: [], exports: 'kendo' },
                        'moment': { deps: [], exports: 'moment' },
                        'react': { deps: [], exports: 'React'}
                    },

                    uglify: {
                        toplevel: true,
                        ascii_only: true,
                        beautify: true,
                        max_line_length: 1000,
                        defines: { DEBUG: ['name', 'false'] },
                        no_mangle: true
                    }
                }
            }
        },

        less: {
            development: {
                options: {
                    paths: [
                        'styles'
                    ],
                    ieCompat: true,
                    yuicompress: true,
                    report: 'min'
                },
                files: {
                    'dist/wingspan-forms.css': 'styles/app.less'
                }
            }
        },

        qunit: {
            files: ['test/**/*.html']
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-react');
    grunt.loadNpmTasks('grunt-bower-task');

    grunt.registerTask('default', ['bower:install', 'react', 'less', 'requirejs']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            files: [
                'src/**/*.js'
            ],
            options: {
                ignores: [],
                curly: true,
                eqnull: true,
                browser: true,
                globals: {
                    jQuery: true,
                    console: true,
                    exports: true,
                    require: true
                },
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle: false
            },
            build: {
                files: {
                    'dist/blackjack-<%= pkg.version %>.min.js': ['src/**/*.js']
                }
            },
        },
        handlebars: {
            compile: {
                options: {
                    namespace: "dodgercms.templates"
                },
                files: {
                    "templates/compiled/entry.html": "templates/raw/entry.html",
                    "templates/compiled/menu.html": "templates/raw/nav.html",
                    "templates/compiled/nav.html": "templates/raw/menu.html"
                }
            }
        }
    });

    //grunt.loadNpmTasks('grunt-contrib-jshint');
    //grunt.loadNpmTasks('grunt-contrib-uglify');

    //grunt.registerTask('default', ['jshint', 'uglify']);

    grunt.loadNpmTasks('grunt-contrib-handlebars');
   // grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask('default', ['handlebars']);
};<commit_msg>Add a partials path regex<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            files: [
                'src/**/*.js'
            ],
            options: {
                ignores: [],
                curly: true,
                eqnull: true,
                browser: true,
                globals: {
                    jQuery: true,
                    console: true,
                    exports: true,
                    require: true
                },
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
                mangle: false
            },
            build: {
                files: {
                    'dist/blackjack-<%= pkg.version %>.min.js': ['src/**/*.js']
                }
            },
        },
        handlebars: {
            compile: {
                options: {
                    namespace: "dodgercms.templates",
                    partialsUseNamespace: false,
                    partialRegex: /.*/,
                    partialsPathRegex: /templates\/partials\//,
                    processPartialName: function(filePath) {
                        var pieces = filePath.split("/");
                        return pieces[pieces.length - 1];
                    },
                    processName: function(filePath) {
                        var pieces = filePath.split("/");
                        return pieces[pieces.length - 1];
                    }
                },
                files: {
                    "templates/compiled/entry.html.js": "templates/entry.html",
                    "templates/compiled/nav.html.js": "templates/nav.html",
                    "templates/compiled/menu.html.js": "templates/partials/menu.html"
                }
            }
        }
    });

    //grunt.loadNpmTasks('grunt-contrib-jshint');
    //grunt.loadNpmTasks('grunt-contrib-uglify');

    //grunt.registerTask('default', ['jshint', 'uglify']);

    grunt.loadNpmTasks('grunt-contrib-handlebars');
   // grunt.loadNpmTasks('grunt-contrib-uglify');

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


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

    browserify: {
      dist: {
        src: [
          'src/utils.js',
          'src/minefield.js',
          'src/fieldlocation.js',
          'src/mineplacer.js',
          'src/cursor.js',
          'src/exports.js'
        ],
        dest: 'dist/landmine.js'
      }
    },

    uglify: {
      options: {
        banner: '//landmine.js\n'
      },
      dist: {
        files: {
          'dist/landmine.min.js': ['<%= browserify.dist.dest %>']
        }
      }
    },

    jshint: {
      files: ['gruntfile.js', 'src/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          module: true,
          document: true
        },
        ignores: ['src/intro.js', 'src/outro.js']
      }
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec',
          growl : true
        },
        src: ['test/**/*.js']
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/*.js'],
      tasks: ['jshint', 'mochaTest', 'browserify', 'uglify']
      }
    });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-browserify');

  grunt.registerTask('default', ['jshint', 'browserify', 'mochaTest', 'uglify']);
  grunt.registerTask('test', ['jshint', 'browserify', 'mochaTest']);
};
<commit_msg>remove hardcoded list of src files for browserify<commit_after>module.exports = function(grunt){
  grunt.initConfig({

    browserify: {
      dist: {
        src: 'src/**/*.js',
        dest: 'dist/landmine.js'
      }
    },

    uglify: {
      options: {
        banner: '//landmine.js\n'
      },
      dist: {
        files: {
          'dist/landmine.min.js': ['<%= browserify.dist.dest %>']
        }
      }
    },

    jshint: {
      files: ['gruntfile.js', 'src/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          module: true,
          document: true
        },
        ignores: ['src/intro.js', 'src/outro.js']
      }
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec',
          growl : true
        },
        src: ['test/**/*.js']
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'test/*.js'],
      tasks: ['jshint', 'mochaTest', 'browserify', 'uglify']
      }
    });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-browserify');

  grunt.registerTask('default', ['jshint', 'browserify', 'mochaTest', 'uglify']);
  grunt.registerTask('test', ['jshint', 'browserify', 'mochaTest']);
};
<|endoftext|>


<commit_before>/*
 * Grunt Replacer
 * https://github.com/tomaszczechowski/grunt-replacer
 *
 * Copyright (c) 2013 Tomasz Czechowski
 * Licensed under the MIT license.
 *
 */

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

    // Project configuration.
    grunt.initConfig({
        replacer: {
            index: {
                options : {
                    replace: {
                        '<!-- to-replacec -->' : 'was replaced'
                    },
                    reportError: false
                },
                files : [
                    {src: ['test/index.html'], dest: 'test/dist/index.html'}
                ]
            }
        },

        jshint: {
            options: {
                jshintrc : '.jshintrc'
            },
            files: [
                'Gruntfile.js',
                'tasks/*.js',
                'test/*.js'
            ]
        },

        nodeunit: {
            files: ['test/*.js']
        },

        clean: {
            dist: 'test/dist/*'
        }
    });

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

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

    // 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', ['clean', 'replacer', 'nodeunit']);

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

};
<commit_msg>Fixed 'to-replace'<commit_after>/*
 * Grunt Replacer
 * https://github.com/tomaszczechowski/grunt-replacer
 *
 * Copyright (c) 2013 Tomasz Czechowski
 * Licensed under the MIT license.
 *
 */

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

    // Project configuration.
    grunt.initConfig({
        replacer: {
            index: {
                options : {
                    replace: {
                        '<!-- to-replace -->' : 'was replaced'
                    },
                    reportError: false
                },
                files : [
                    {src: ['test/index.html'], dest: 'test/dist/index.html'}
                ]
            }
        },

        jshint: {
            options: {
                jshintrc : '.jshintrc'
            },
            files: [
                'Gruntfile.js',
                'tasks/*.js',
                'test/*.js'
            ]
        },

        nodeunit: {
            files: ['test/*.js']
        },

        clean: {
            dist: 'test/dist/*'
        }
    });

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

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

    // 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', ['clean', 'replacer', 'nodeunit']);

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

};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            version: '<%= pkg.version %>',
            banner:
                '// Backbone.Minionette\n' +
                '// -------------------\n' +
                '// v<%= pkg.version %>\n' +
                '//\n' +
                '// Copyright (c)<%= grunt.template.today("yyyy") %> Justin Ridgewell\n' +
                '// Distributed under MIT license\n' +
                '//\n' +
                '// https://github.com/jridgewell/minionette\n' +
                '\n'
        },

        preprocess: {
            build: {
                files: {
                    'dist/minionette.js' : 'src/build/minionette.js'
                }
            },
            amd: {
                files: {
                    'dist/amd/minionette.js' : 'src/build/amd.js'
                }
            },
        },

        uglify : {
            options: {
                banner: "<%= meta.banner %>"
            },
            amd : {
                src : 'dist/amd/minionette.js',
                dest : 'dist/amd/minionette.min.js',
            },
            core : {
                src : 'dist/minionette.js',
                dest : 'dist/minionette.min.js',
                options : {
                    sourceMap : 'dist/minionette.map',
                    sourceMapPrefix : 1,
                }
            }
        },

        jshint: {
            options: {
                jshintrc : '.jshintrc'
            },
            minionette : [ 'src/*.js' ]
        },

        plato: {
            minionette : {
                src : 'src/*.js',
                dest : 'reports',
                options : {
                    jshint : grunt.file.readJSON('.jshintrc')
                }
            }
        },

        docco: {
            src: ['src/*.js'],
            options: {
                output: 'docs/'
            }
        },

        mocha: {
            browser: ['spec/spec.html'],
            options: {
                run: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-preprocess');
    grunt.loadNpmTasks('grunt-plato');
    grunt.loadNpmTasks('grunt-docco2');
    grunt.loadNpmTasks('grunt-mocha');

    // Default task.
    grunt.registerTask('test', ['mocha']);
    grunt.registerTask('default', ['jshint', 'preprocess', 'uglify']);

};
<commit_msg>Don't run mocha automatically. I'll run it myself.<commit_after>/*global module:false*/
module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            version: '<%= pkg.version %>',
            banner:
                '// Backbone.Minionette\n' +
                '// -------------------\n' +
                '// v<%= pkg.version %>\n' +
                '//\n' +
                '// Copyright (c)<%= grunt.template.today("yyyy") %> Justin Ridgewell\n' +
                '// Distributed under MIT license\n' +
                '//\n' +
                '// https://github.com/jridgewell/minionette\n' +
                '\n'
        },

        preprocess: {
            build: {
                files: {
                    'dist/minionette.js' : 'src/build/minionette.js'
                }
            },
            amd: {
                files: {
                    'dist/amd/minionette.js' : 'src/build/amd.js'
                }
            },
        },

        uglify : {
            options: {
                banner: "<%= meta.banner %>"
            },
            amd : {
                src : 'dist/amd/minionette.js',
                dest : 'dist/amd/minionette.min.js',
            },
            core : {
                src : 'dist/minionette.js',
                dest : 'dist/minionette.min.js',
                options : {
                    sourceMap : 'dist/minionette.map',
                    sourceMapPrefix : 1,
                }
            }
        },

        jshint: {
            options: {
                jshintrc : '.jshintrc'
            },
            minionette : [ 'src/*.js' ]
        },

        plato: {
            minionette : {
                src : 'src/*.js',
                dest : 'reports',
                options : {
                    jshint : grunt.file.readJSON('.jshintrc')
                }
            }
        },

        docco: {
            src: ['src/*.js'],
            options: {
                output: 'docs/'
            }
        },

        mocha: {
            browser: ['spec/spec.html'],
            options: {
                // run: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-preprocess');
    grunt.loadNpmTasks('grunt-plato');
    grunt.loadNpmTasks('grunt-docco2');
    grunt.loadNpmTasks('grunt-mocha');

    // Default task.
    grunt.registerTask('test', ['mocha']);
    grunt.registerTask('default', ['jshint', 'preprocess', 'uglify']);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var uikitConfig = {
    src: 'src',
    srcRelution: 'src-relution',
    dist: 'dist',
    fileName: 'mw-uikit',
    fileNameRelution: 'mw-uikit.relution',
    getVersion: function () {
      var packageJson = grunt.file.readJSON('package.json');
      return packageJson.version;
    },
    getGruntParam: function (paramName, defaultValue) {
      var gruntParam = grunt.option(paramName);
      // For any reasons the useminPrepare task calls all subtasks of copy and then it will crash because some copy tasks need a param name
      if (!gruntParam && !defaultValue) {
        throw new Error('The param "' + paramName + '" is required for the task ' + grunt.task.current.name + ' and was not passed as argument. Please pass the argument --' + paramName);
      } else {
        return gruntParam || defaultValue;
      }
    },
    getversionWithBuildNumber: function () {
      return uikitConfig.getVersion() + '-b' + uikitConfig.getGruntParam('buildNumber', 'LOCAL');
    },
    getReleaseNameWithBuildNum: function () {
      return uikitConfig.fileName +
        '-v' + uikitConfig.getversionWithBuildNumber() +
        '-sha.c' + uikitConfig.getGruntParam('commitHash', 'none').toString().substr(0,5);
    }
  };

  grunt.initConfig({
    uikit: uikitConfig,
    regarde: {
      all: {
        files: [
          'src/**/*.js',
          'src/**/*.json',
          'src/**/*.html'
        ],
        tasks: ['process']
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        'src/**/*.js'
      ]
    },
    preprocess: {
      js: {
        src: 'src/mw_ui.js',
        dest: '<%= uikit.dist %>/<%= uikit.fileName %>.js'
      }
    },
    concat: {
      dist: {
        src: [
          'src-relution/mwUI.js',
          'src-relution/**/*.js',
          '!src-relution/test/**/*.js',
          '.tmp/templates.js',
          '.tmp/templates-relution.js',
          'libs/angular-sanitize/angular-sanitize.js',
          'libs/showdown/dist/showdown.js',
          'libs/jquery-ui/ui/jquery.ui.widget.js',
          'libs/blueimp-file-upload/js/jquery.fileupload.js',
          'libs/blueimp-file-upload/js/jquery.iframe-transport.js',
          'libs/bootstrap-sass-datepicker/js/bootstrap-sass-datepicker.js',
          'libs/bootstrap-sass-datepicker/js/locales/bootstrap-datepicker.de.js'
        ],
        dest: '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js'
      }
    },
    copy: {
      distToSamplePortal: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.dist %>',
            dest: 'sample_portal/app/components/mw-ui',
            src: [
              '<%= uikit.fileName %>.js'
            ]
          }
        ]
      },
      relutionScssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.srcRelution %>/styles',
            dest: '<%= uikit.dist %>/styles/relution',
            src: [
              '**/*.scss'
            ]
          }
        ]
      },
      scssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.src %>',
            dest: '<%= uikit.dist %>/styles',
            src: [
              '_mw_uis.scss',
              '**/*.scss',
              '**/styles/*.scss'
            ]
          }
        ]
      }
    },
    uglify: {
      js: {
        files: {
          '<%= uikit.dist %>/<%= uikit.fileName %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
          '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
        }
      }
    },
    ngAnnotate: {
      options: {
        singleQuotes: true
      },
      dist: {
        files: [
          {
            '<%= uikit.dist %>/<%= uikit.fileName %>.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
            '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
          }
        ]
      }
    },
    ngtemplates: {
      old: {
        src: [
          'src-relution/templates/**/*.html'
        ],
        dest: '.tmp/templates-relution.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src-relution/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      },
      new: {
        src: [
          'src/**/templates/**/*.html',
          'src/**/i18n/**/*.json',
          'src/mw_ui_icons.json'
        ],
        dest: '.tmp/templates.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    replace: {
      setBuildNumber: {
        src: ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
        overwrite: true,
        replacements: [
          {
            from: /UIKITVERSIONNUMBER/,
            to: function () {
              return uikitConfig.getversionWithBuildNumber();
            }
          }
        ]
      }
    },
    shell: {
      zipUiKit: {
        options: {
          stdout: true,
          failOnError: true
        },
        command: function () {
          return [
            'mkdir -p zip',
            'cp -r dist zip/' + uikitConfig.getReleaseNameWithBuildNum(),
            'cd zip',
            'zip -r ' + uikitConfig.getReleaseNameWithBuildNum() + '.zip ' + uikitConfig.getReleaseNameWithBuildNum(),
            'rm -rf ' + uikitConfig.getReleaseNameWithBuildNum()
          ].join('&&');
        }
      },
      gitRelease: {
        options: {
          stdout: true
        },
        command: function(){
          return [
            'export VERSION_NUMBER='+uikitConfig.getversionWithBuildNumber(),
            './bin/git_release.sh'
          ].join('&&');
        }
      }
    },
    clean: ['dist', 'zip']
  });

  grunt.registerTask('test', ['build', 'karma']);
  grunt.registerTask('test:codequality', ['jshint', 'test']);
  grunt.registerTask('watch', ['process', 'regarde']);
  grunt.registerTask('process', ['ngtemplates:new', 'preprocess:js', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('process-old', ['ngtemplates:old', 'concat', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('build', ['jshint', 'process', 'process-old']);
  grunt.registerTask('release', ['clean', 'build', 'replace:setBuildNumber', 'uglify', 'copy:scssToDistfolder', 'copy:relutionScssToDistfolder', 'shell:zipUiKit', 'shell:gitRelease']);
};
<commit_msg>add fail on error<commit_after>'use strict';

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var uikitConfig = {
    src: 'src',
    srcRelution: 'src-relution',
    dist: 'dist',
    fileName: 'mw-uikit',
    fileNameRelution: 'mw-uikit.relution',
    getVersion: function () {
      var packageJson = grunt.file.readJSON('package.json');
      return packageJson.version;
    },
    getGruntParam: function (paramName, defaultValue) {
      var gruntParam = grunt.option(paramName);
      // For any reasons the useminPrepare task calls all subtasks of copy and then it will crash because some copy tasks need a param name
      if (!gruntParam && !defaultValue) {
        throw new Error('The param "' + paramName + '" is required for the task ' + grunt.task.current.name + ' and was not passed as argument. Please pass the argument --' + paramName);
      } else {
        return gruntParam || defaultValue;
      }
    },
    getversionWithBuildNumber: function () {
      return uikitConfig.getVersion() + '-b' + uikitConfig.getGruntParam('buildNumber', 'LOCAL');
    },
    getReleaseNameWithBuildNum: function () {
      return uikitConfig.fileName +
        '-v' + uikitConfig.getversionWithBuildNumber() +
        '-sha.c' + uikitConfig.getGruntParam('commitHash', 'none').toString().substr(0,5);
    }
  };

  grunt.initConfig({
    uikit: uikitConfig,
    regarde: {
      all: {
        files: [
          'src/**/*.js',
          'src/**/*.json',
          'src/**/*.html'
        ],
        tasks: ['process']
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        'src/**/*.js'
      ]
    },
    preprocess: {
      js: {
        src: 'src/mw_ui.js',
        dest: '<%= uikit.dist %>/<%= uikit.fileName %>.js'
      }
    },
    concat: {
      dist: {
        src: [
          'src-relution/mwUI.js',
          'src-relution/**/*.js',
          '!src-relution/test/**/*.js',
          '.tmp/templates.js',
          '.tmp/templates-relution.js',
          'libs/angular-sanitize/angular-sanitize.js',
          'libs/showdown/dist/showdown.js',
          'libs/jquery-ui/ui/jquery.ui.widget.js',
          'libs/blueimp-file-upload/js/jquery.fileupload.js',
          'libs/blueimp-file-upload/js/jquery.iframe-transport.js',
          'libs/bootstrap-sass-datepicker/js/bootstrap-sass-datepicker.js',
          'libs/bootstrap-sass-datepicker/js/locales/bootstrap-datepicker.de.js'
        ],
        dest: '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js'
      }
    },
    copy: {
      distToSamplePortal: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.dist %>',
            dest: 'sample_portal/app/components/mw-ui',
            src: [
              '<%= uikit.fileName %>.js'
            ]
          }
        ]
      },
      relutionScssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.srcRelution %>/styles',
            dest: '<%= uikit.dist %>/styles/relution',
            src: [
              '**/*.scss'
            ]
          }
        ]
      },
      scssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.src %>',
            dest: '<%= uikit.dist %>/styles',
            src: [
              '_mw_uis.scss',
              '**/*.scss',
              '**/styles/*.scss'
            ]
          }
        ]
      }
    },
    uglify: {
      js: {
        files: {
          '<%= uikit.dist %>/<%= uikit.fileName %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
          '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
        }
      }
    },
    ngAnnotate: {
      options: {
        singleQuotes: true
      },
      dist: {
        files: [
          {
            '<%= uikit.dist %>/<%= uikit.fileName %>.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
            '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
          }
        ]
      }
    },
    ngtemplates: {
      old: {
        src: [
          'src-relution/templates/**/*.html'
        ],
        dest: '.tmp/templates-relution.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src-relution/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      },
      new: {
        src: [
          'src/**/templates/**/*.html',
          'src/**/i18n/**/*.json',
          'src/mw_ui_icons.json'
        ],
        dest: '.tmp/templates.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    replace: {
      setBuildNumber: {
        src: ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
        overwrite: true,
        replacements: [
          {
            from: /UIKITVERSIONNUMBER/,
            to: function () {
              return uikitConfig.getversionWithBuildNumber();
            }
          }
        ]
      }
    },
    shell: {
      zipUiKit: {
        options: {
          stdout: true,
          failOnError: true
        },
        command: function () {
          return [
            'mkdir -p zip',
            'cp -r dist zip/' + uikitConfig.getReleaseNameWithBuildNum(),
            'cd zip',
            'zip -r ' + uikitConfig.getReleaseNameWithBuildNum() + '.zip ' + uikitConfig.getReleaseNameWithBuildNum(),
            'rm -rf ' + uikitConfig.getReleaseNameWithBuildNum()
          ].join('&&');
        }
      },
      gitRelease: {
        options: {
          stdout: true,
          failOnError: true
        },
        command: function(){
          return [
            'export VERSION_NUMBER='+uikitConfig.getversionWithBuildNumber(),
            './bin/git_release.sh'
          ].join('&&');
        }
      }
    },
    clean: ['dist', 'zip']
  });

  grunt.registerTask('test', ['build', 'karma']);
  grunt.registerTask('test:codequality', ['jshint', 'test']);
  grunt.registerTask('watch', ['process', 'regarde']);
  grunt.registerTask('process', ['ngtemplates:new', 'preprocess:js', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('process-old', ['ngtemplates:old', 'concat', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('build', ['jshint', 'process', 'process-old']);
  grunt.registerTask('release', ['clean', 'build', 'replace:setBuildNumber', 'uglify', 'copy:scssToDistfolder', 'copy:relutionScssToDistfolder', 'shell:zipUiKit', 'shell:gitRelease']);
};
<|endoftext|>