<commit_before>/*
 * Grunt configuration.
 *
 * Note: this file is in ES5. The rest of this project is ES6.
 *
 * Note to contributors: Consider modifications to the npm publish mechanism,
 * including replacing the use of global variables and, potentially, utilizing a
 * promise-chain of tasks to improve readability of intent.
 */

//
// allPackages is the global array of npm-publishable packages in this monorepo
//
var allPackages = [
  'basic-arrow-selection',
  'basic-autosize-textarea',
  'basic-carousel',
  'basic-component-mixins',
  'basic-element-base',
  'basic-list-box',
  'basic-modes',
  'basic-page-dots',
  'basic-sliding-viewport',
  'basic-spread-items'
];

// Global array used for reporting successful npm publish tasks
var updatedPublishList = [];

//
// Build the global buildList object for use in browserify:components
//
function buildBuildList() {
  var obj = {
    'build/basic-web-components.js': ['packages/*/src/*.js'],
    'build/tests.js': ['packages/*/test/*.js']
  };

  for (var i = 0; i < allPackages.length; i++) {
    obj['packages/' + allPackages[i] + '/dist/' + allPackages[i] + '.js'] = ['packages/' + allPackages[i] + '/src/*.js'];
  }

  return obj;
}
var buildList = buildBuildList();

//
// Build the global docsList array for use in building the package's README.md documentation
//
function buildDocsList() {
  var ary = [];
  for (var i = 0; i < allPackages.length; i++) {
    var obj = {src: 'packages/' + allPackages[i] + '/src/*.js', dest: 'packages/' + allPackages[i] + '/README.md'};
    ary.push(obj);
  }

  return ary;
}
var docsList = buildDocsList();

module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-shell');

  grunt.initConfig({

    clean: {
      build: 'build'
    },

    browserify: {
      options: {
        browserifyOptions: {
          debug: true
        },
        ignore: false, // Don't ignore node_modules; i.e., process them too
        transform: ['babelify']
      },
      buildFiles: {
        files: buildList
      },
      watch: {
        files: buildList,
        options: {
          keepAlive: true,
          watch: true
        }
      }
    },

    jsdoc2md: {
      docs: {
        options: {
          "global-index-format": "none"
        },
        files: docsList
      }
    },

    jshint: {
      all: [
        'packages/**/*.js',
        '!packages/**/dist/*',
        'test/**/*.js'
      ],
      options: {
        jshintrc: true
      }
    },

    /*
     * NOTE: Mocha tests don't work from the command line yet, as the
     * webcomponents.js polyfill currently triggers a "Parse error" in
     * PhantomJS.
     */
    mocha: {
      test: {
        src: 'test/**/*.html',
        options: {
          log: true,
          logErrors: true,
          run: true
        }
      }
    },

    //
    // The shell section specifies shell-based commands to be executed and is implemented
    // by the Grunt grunt-shell plugin. Shell commands are specified under the "command" key,
    // and any code that needs to be executed upon completion is specified under
    // options/callback.
    //
    shell: {
      'npm-publish': {
        command: function(package) {
          if (!package || package.length < 1) {
            return '';
          }
          return 'npm publish packages/' + package;
        },
        options: {
          stderr: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            if (err && err.toString().indexOf('E403') < 0) {
                grunt.log.error('Package not published for unexpected reasons: ' + err);
            }
            else if (stdout && stdout.length > 0) {
              var output = stdout.trim();
              grunt.log.writeln(output);
              updatedPublishList.push(output);
            }
            if (cb) {
              cb();
            }
          }
        }
      },

      'npm-owner-add': {
        command: function(owner, package) {
          if (!package || package.length < 1 || !owner || owner.length < 1) {
            return '';
          }
          return 'npm owner add ' + owner + ' ' + package;
        },
        options: {
          stderr: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            if (err && err.toString().indexOf('E403') < 0) {
              grunt.log.error('Package owner not updated for unexpected reasons: ' + err);
            }
            else if (stdout && stdout.length > 0) {
              var output = stdout.trim();
              grunt.log.writeln(output);
            }
            if (cb) {
              cb();
            }
          }
        }
      }
    }

  });

  //
  // Default task - prints to the console the tasks that are available to be run from the command line
  //
  grunt.registerTask('default', function() {
    grunt.log.writeln('grunt commands this project supports:\n');
    grunt.log.writeln('  grunt build (builds consolidated basic-web-components.js, all package distributions, all documentation, and all tests)');
    grunt.log.writeln('  grunt docs (builds all packages README.md files)');
    grunt.log.writeln('  grunt lint (runs jshint on all .js files)');
    grunt.log.writeln('  grunt npm-publish:package-name|* (publishes packages/package-name or all packages (packages/*) to npm)');
    grunt.log.writeln('  grunt watch (builds and watches changes to project files)');
  });

  //
  // The build task is callable from the command line and executes the browserify:buildFiles task
  // defined in the Grunt config. This task builds ES5 transpiled files written to each package's
  // dist folder. A developer who uses "npm install" on that package can import the resulting
  // JavaScript file(s) from the package's dist folder without the need for Babel in an ES5
  // ecosystem.
  //
  // Note that this task also builds each package's README.md file via the jsdocs2md:docs task.
  //
  // This task makes use of the buildList global array.
  //
  grunt.registerTask('build', ['browserify:buildFiles', 'jsdoc2md:docs']);

  //
  // The docs task is callable from the command line and executes the jsdoc2md:docs task defined
  // in the Grunt config. This task builds each package's README.md file from jsdoc tags in the
  // package's src JavaScript files.
  //
  // This task makes use of the docsList global array.
  //
  grunt.registerTask('docs', ['jsdoc2md:docs']);

  //
  // The lint task is callable from the command line and executes the jshint task defined
  // in the Grunt config. This task looks for JavaScript warnings/errors.
  //
  grunt.registerTask('lint', ['jshint']);

  //
  // The test task is callable from the command line and executes the mocha task defined
  // in the Grunt config. This task executes the monorepo's test suite.
  //
  grunt.registerTask('test', ['mocha']);

  //
  // The watch task is callable from the command line and executes the browserify:watch task
  // defined in the Grunt config. This task performs a build and then watches for changes
  // for instant update during development.
  //
  grunt.registerTask('watch', ['browserify:watch']);

  //
  // The npm-publish task is callable from the command line and performs a publish operation
  // to npm for a specified package if named, or all packages in the monorepo when "*" is
  // used as the parameter (grunt npm-publish:*).
  //
  // This task also calls the npm-addowners task which assigns npm package ownership via
  // "npm owner add <ownername> <packagename>". The owners are specified in the npm-addowners
  // task code, referring to npm user accounts.
  //
  // This task makes use of the following globals:
  //
  // allPackages: In the case where "*" is used as the npm-publish parameter, the allPackages
  // global array specifies the list of packages to be published.
  //
  // updatedPublishList: This global array is used to store the list of successfully published
  // packages during the npm-publish run. At the completion of the task, the contents of the
  // updatedPublishList array are printed to the console as a summary.
  //
  grunt.registerTask('npm-publish', function(package) {
    updatedPublishList = [];

    // Handle an improperly specified command line invocation where no package is specified
    if (!package || package.length < 1) {
      return grunt.log.error('No package specified');
    }

    // We'll always assume we have an array of packages to publish, with the degenerate
    // case being a single package.
    var packages = [];

    // If the command line specifies "*", then set the array of packages to the global array, allPackages.
    // Otherwise, just push the single specified package name.
    if (package == '*') {
      packages = allPackages;
    }
    else {
      packages.push(package);
    }

    // For each of the packages in the array, call the Grunt config-based shell task, shell:npm-publish
    // (which uses grunt-shell to execute npm commands), and the task, npm-addowners, to assign
    // npm package ownership.
    //
    // Note that grunt.task.run adds tasks to Grunt's task queue in the order in which they're
    // specified, with the subsequent async operations executed sequentially in that order.
    for (var i = 0; i < packages.length; i++) {
      grunt.task.run(['shell:npm-publish:' + packages[i], 'npm-addowners:' + packages[i]]);
    }

    // Finally, output the summary report to the console regarding successfully published packages.
    // By virtue of Grunt's task queue, this task is guaranteed to run after each of the above
    // publish/addowner operations.
    grunt.task.run(['npm-publish-report']);
  });

  //
  // Helper task that prints to the console the list of successfully published tasks.
  // This task should not be called from the command line.
  //
  grunt.registerTask('npm-publish-report', function() {
    if (updatedPublishList.length <= 0) {
      grunt.log.writeln('No packages published');
      return;
    }

    grunt.log.writeln('Successfully published the following:');
    for (var i = 0; i < updatedPublishList.length; i++) {
      grunt.log.writeln(updatedPublishList[i]);
    }
  });

  //
  // Helper task that uses the Grunt config shell:npm-owner-add task to assign
  // npm account ownership to the specified package. This task should not be
  // called from the command line.
  //
  grunt.registerTask('npm-addowners', function(package) {
    if (!package || package.length < 1) {
      return grunt.log.error('No package specified');
    }

    grunt.task.run([
      'shell:npm-owner-add:jan.miksovsky:' + package,
      'shell:npm-owner-add:robbear:' + package]);
  });

};
<commit_msg>Add jshint as final task to grunt build<commit_after>/*
 * Grunt configuration.
 *
 * Note: this file is in ES5. The rest of this project is ES6.
 *
 * Note to contributors: Consider modifications to the npm publish mechanism,
 * including replacing the use of global variables and, potentially, utilizing a
 * promise-chain of tasks to improve readability of intent.
 */

//
// allPackages is the global array of npm-publishable packages in this monorepo
//
var allPackages = [
  'basic-arrow-selection',
  'basic-autosize-textarea',
  'basic-carousel',
  'basic-component-mixins',
  'basic-element-base',
  'basic-list-box',
  'basic-modes',
  'basic-page-dots',
  'basic-sliding-viewport',
  'basic-spread-items'
];

// Global array used for reporting successful npm publish tasks
var updatedPublishList = [];

//
// Build the global buildList object for use in browserify:components
//
function buildBuildList() {
  var obj = {
    'build/basic-web-components.js': ['packages/*/src/*.js'],
    'build/tests.js': ['packages/*/test/*.js']
  };

  for (var i = 0; i < allPackages.length; i++) {
    obj['packages/' + allPackages[i] + '/dist/' + allPackages[i] + '.js'] = ['packages/' + allPackages[i] + '/src/*.js'];
  }

  return obj;
}
var buildList = buildBuildList();

//
// Build the global docsList array for use in building the package's README.md documentation
//
function buildDocsList() {
  var ary = [];
  for (var i = 0; i < allPackages.length; i++) {
    var obj = {src: 'packages/' + allPackages[i] + '/src/*.js', dest: 'packages/' + allPackages[i] + '/README.md'};
    ary.push(obj);
  }

  return ary;
}
var docsList = buildDocsList();

module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-shell');

  grunt.initConfig({

    clean: {
      build: 'build'
    },

    browserify: {
      options: {
        browserifyOptions: {
          debug: true
        },
        ignore: false, // Don't ignore node_modules; i.e., process them too
        transform: ['babelify']
      },
      buildFiles: {
        files: buildList
      },
      watch: {
        files: buildList,
        options: {
          keepAlive: true,
          watch: true
        }
      }
    },

    jsdoc2md: {
      docs: {
        options: {
          "global-index-format": "none"
        },
        files: docsList
      }
    },

    jshint: {
      all: [
        'packages/**/*.js',
        '!packages/**/dist/*',
        'test/**/*.js'
      ],
      options: {
        jshintrc: true
      }
    },

    /*
     * NOTE: Mocha tests don't work from the command line yet, as the
     * webcomponents.js polyfill currently triggers a "Parse error" in
     * PhantomJS.
     */
    mocha: {
      test: {
        src: 'test/**/*.html',
        options: {
          log: true,
          logErrors: true,
          run: true
        }
      }
    },

    //
    // The shell section specifies shell-based commands to be executed and is implemented
    // by the Grunt grunt-shell plugin. Shell commands are specified under the "command" key,
    // and any code that needs to be executed upon completion is specified under
    // options/callback.
    //
    shell: {
      'npm-publish': {
        command: function(package) {
          if (!package || package.length < 1) {
            return '';
          }
          return 'npm publish packages/' + package;
        },
        options: {
          stderr: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            if (err && err.toString().indexOf('E403') < 0) {
                grunt.log.error('Package not published for unexpected reasons: ' + err);
            }
            else if (stdout && stdout.length > 0) {
              var output = stdout.trim();
              grunt.log.writeln(output);
              updatedPublishList.push(output);
            }
            if (cb) {
              cb();
            }
          }
        }
      },

      'npm-owner-add': {
        command: function(owner, package) {
          if (!package || package.length < 1 || !owner || owner.length < 1) {
            return '';
          }
          return 'npm owner add ' + owner + ' ' + package;
        },
        options: {
          stderr: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            if (err && err.toString().indexOf('E403') < 0) {
              grunt.log.error('Package owner not updated for unexpected reasons: ' + err);
            }
            else if (stdout && stdout.length > 0) {
              var output = stdout.trim();
              grunt.log.writeln(output);
            }
            if (cb) {
              cb();
            }
          }
        }
      }
    }

  });

  //
  // Default task - prints to the console the tasks that are available to be run from the command line
  //
  grunt.registerTask('default', function() {
    grunt.log.writeln('grunt commands this project supports:\n');
    grunt.log.writeln('  grunt build (builds consolidated basic-web-components.js, all package distributions, all documentation, and all tests)');
    grunt.log.writeln('  grunt docs (builds all packages README.md files)');
    grunt.log.writeln('  grunt lint (runs jshint on all .js files)');
    grunt.log.writeln('  grunt npm-publish:package-name|* (publishes packages/package-name or all packages (packages/*) to npm)');
    grunt.log.writeln('  grunt watch (builds and watches changes to project files)');
  });

  //
  // The build task is callable from the command line and executes the browserify:buildFiles task
  // defined in the Grunt config. This task builds ES5 transpiled files written to each package's
  // dist folder. A developer who uses "npm install" on that package can import the resulting
  // JavaScript file(s) from the package's dist folder without the need for Babel in an ES5
  // ecosystem.
  //
  // Note that this task also builds each package's README.md file via the jsdocs2md:docs task.
  //
  // This task makes use of the buildList global array.
  //
  grunt.registerTask('build', ['browserify:buildFiles', 'jsdoc2md:docs', 'jshint']);

  //
  // The docs task is callable from the command line and executes the jsdoc2md:docs task defined
  // in the Grunt config. This task builds each package's README.md file from jsdoc tags in the
  // package's src JavaScript files.
  //
  // This task makes use of the docsList global array.
  //
  grunt.registerTask('docs', ['jsdoc2md:docs']);

  //
  // The lint task is callable from the command line and executes the jshint task defined
  // in the Grunt config. This task looks for JavaScript warnings/errors.
  //
  grunt.registerTask('lint', ['jshint']);

  //
  // The test task is callable from the command line and executes the mocha task defined
  // in the Grunt config. This task executes the monorepo's test suite.
  //
  grunt.registerTask('test', ['mocha']);

  //
  // The watch task is callable from the command line and executes the browserify:watch task
  // defined in the Grunt config. This task performs a build and then watches for changes
  // for instant update during development.
  //
  grunt.registerTask('watch', ['browserify:watch']);

  //
  // The npm-publish task is callable from the command line and performs a publish operation
  // to npm for a specified package if named, or all packages in the monorepo when "*" is
  // used as the parameter (grunt npm-publish:*).
  //
  // This task also calls the npm-addowners task which assigns npm package ownership via
  // "npm owner add <ownername> <packagename>". The owners are specified in the npm-addowners
  // task code, referring to npm user accounts.
  //
  // This task makes use of the following globals:
  //
  // allPackages: In the case where "*" is used as the npm-publish parameter, the allPackages
  // global array specifies the list of packages to be published.
  //
  // updatedPublishList: This global array is used to store the list of successfully published
  // packages during the npm-publish run. At the completion of the task, the contents of the
  // updatedPublishList array are printed to the console as a summary.
  //
  grunt.registerTask('npm-publish', function(package) {
    updatedPublishList = [];

    // Handle an improperly specified command line invocation where no package is specified
    if (!package || package.length < 1) {
      return grunt.log.error('No package specified');
    }

    // We'll always assume we have an array of packages to publish, with the degenerate
    // case being a single package.
    var packages = [];

    // If the command line specifies "*", then set the array of packages to the global array, allPackages.
    // Otherwise, just push the single specified package name.
    if (package == '*') {
      packages = allPackages;
    }
    else {
      packages.push(package);
    }

    // For each of the packages in the array, call the Grunt config-based shell task, shell:npm-publish
    // (which uses grunt-shell to execute npm commands), and the task, npm-addowners, to assign
    // npm package ownership.
    //
    // Note that grunt.task.run adds tasks to Grunt's task queue in the order in which they're
    // specified, with the subsequent async operations executed sequentially in that order.
    for (var i = 0; i < packages.length; i++) {
      grunt.task.run(['shell:npm-publish:' + packages[i], 'npm-addowners:' + packages[i]]);
    }

    // Finally, output the summary report to the console regarding successfully published packages.
    // By virtue of Grunt's task queue, this task is guaranteed to run after each of the above
    // publish/addowner operations.
    grunt.task.run(['npm-publish-report']);
  });

  //
  // Helper task that prints to the console the list of successfully published tasks.
  // This task should not be called from the command line.
  //
  grunt.registerTask('npm-publish-report', function() {
    if (updatedPublishList.length <= 0) {
      grunt.log.writeln('No packages published');
      return;
    }

    grunt.log.writeln('Successfully published the following:');
    for (var i = 0; i < updatedPublishList.length; i++) {
      grunt.log.writeln(updatedPublishList[i]);
    }
  });

  //
  // Helper task that uses the Grunt config shell:npm-owner-add task to assign
  // npm account ownership to the specified package. This task should not be
  // called from the command line.
  //
  grunt.registerTask('npm-addowners', function(package) {
    if (!package || package.length < 1) {
      return grunt.log.error('No package specified');
    }

    grunt.task.run([
      'shell:npm-owner-add:jan.miksovsky:' + package,
      'shell:npm-owner-add:robbear:' + package]);
  });

};
<|endoftext|>


<commit_before>/*global module:false*/

function getConfig(name) {
	return require("./config/" + name);
}

module.exports = function(grunt) {
	"use strict";
	require("time-grunt")(grunt);
	require("load-grunt-tasks")(grunt);

	// register browserstack task
	require("./config/browserstack.js")(grunt);

	var config = {
		"pkg": grunt.file.readJSON("package.json"),
		"clean": getConfig("clean"),
		"gitinfo": grunt.task.run("exec:gitinfo"),
		"banner": getConfig("banner"),
		"exec": getConfig("exec"),
		"concat": getConfig("concat"),
		"copy": getConfig("copy"),
		"jscs": getConfig("jscs"),
		"jsdoc": getConfig("jsdoc"),
		"jshint": getConfig("jshint"),
		"qunit": getConfig("qunit"),
		"uglify": getConfig("uglify"),
		"watch": getConfig("watch")
	};
	grunt.initConfig(config);

	grunt.registerTask("test", function() {
		var eachfile = Array.prototype.slice.apply(arguments);
		if (eachfile.length) {
			eachfile = eachfile.map(function(v) {
				return "test/" + v + ".test.html";
			}, this);
		} else {
			eachfile.push("test/*.test.html");
		}
		grunt.config.set("qunit.each", eachfile);
		grunt.log.oklns(grunt.config.get("qunit.each"));
		grunt.task.run("qunit:each");
	});

	grunt.registerTask("validate-commit", function() {
		var fs = require("fs");
		if (grunt.file.exists(".git/hooks/commit-msg")) {
			grunt.file["delete"](".git/hooks/commit-msg", { force: true });
		}
		grunt.file.copy("config/validate-commit-msg.js", ".git/hooks/commit-msg", { force: true });
		fs.chmodSync(".git/hooks/commit-msg", "755");
	});

	grunt.registerTask("docBuild", ["copy:doc", "clean:doc", "jsdoc"]);
	grunt.registerTask("build", ["validate-commit", "concat", "uglify", "clean:pkgd", "docBuild"]);
	grunt.registerTask("default", ["jshint", "jscs", "build", "test"]);
	grunt.registerTask("check", ["jshint", "jscs", "test"]);
	grunt.registerTask("changelog", ["exec:changelog"]);
};<commit_msg>add browserstack task<commit_after>/*global module:false*/

function getConfig(name) {
	return require("./config/" + name);
}

module.exports = function(grunt) {
	"use strict";
	require("time-grunt")(grunt);
	require("load-grunt-tasks")(grunt);

	// register browserstack task
	require("./config/browserstack.js")(grunt);

	var config = {
		"pkg": grunt.file.readJSON("package.json"),
		"clean": getConfig("clean"),
		"gitinfo": grunt.task.run("exec:gitinfo"),
		"banner": getConfig("banner"),
		"exec": getConfig("exec"),
		"concat": getConfig("concat"),
		"copy": getConfig("copy"),
		"jscs": getConfig("jscs"),
		"jsdoc": getConfig("jsdoc"),
		"jshint": getConfig("jshint"),
		"qunit": getConfig("qunit"),
		"uglify": getConfig("uglify"),
		"watch": getConfig("watch")
	};
	grunt.initConfig(config);

	grunt.registerTask("test", function() {
		var eachfile = Array.prototype.slice.apply(arguments);
		if (eachfile.length) {
			eachfile = eachfile.map(function(v) {
				return "test/" + v + ".test.html";
			}, this);
		} else {
			eachfile.push("test/*.test.html");
		}
		grunt.config.set("qunit.each", eachfile);
		grunt.log.oklns(grunt.config.get("qunit.each"));
		grunt.task.run("qunit:each");
	});

	grunt.registerTask("validate-commit", function() {
		var fs = require("fs");
		if (grunt.file.exists(".git/hooks/commit-msg")) {
			grunt.file["delete"](".git/hooks/commit-msg", { force: true });
		}
		grunt.file.copy("config/validate-commit-msg.js", ".git/hooks/commit-msg", { force: true });
		fs.chmodSync(".git/hooks/commit-msg", "755");
	});

	grunt.registerTask("docBuild", ["copy:doc", "clean:doc", "jsdoc"]);
	grunt.registerTask("build", ["validate-commit", "concat", "uglify", "clean:pkgd", "docBuild"]);
	grunt.registerTask("default", ["jshint", "jscs", "build", "test"]);
	grunt.registerTask("check", ["jshint", "jscs", "test", "browserstack"]);
	grunt.registerTask("changelog", ["exec:changelog"]);
};
<|endoftext|>


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

	'use strict';

	grunt.initConfig({

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

		// License banner //
		banner: '/*! \n' +
			' * <%= pkg.name %>\n' +
			' * Copyright 2013-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
			' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
			' */\n',

		// Clean dist directory //
		clean: {
			dist: ['dist/'],
		},

		// Compile Less file //
		less: {
			options: {
				strictMath: true
			},
			dist: {
				files: {
					'dist/style/swif.css': 'style/startup.less'
				}
			}
		},

		// Clean and organize css file //
		csscomb: {
			options: {
				config: 'grunt/.csscomb.json'
			},
			dist: {
				files: {
					'dist/style/swif.css': ['dist/style/swif.css']
				}
			}
		},

		// Target HTML  //
		targethtml: {
			dist: {
				files: {
					'dist/index.html': 'index.html'
				}
			}
		},

		// Copy files to the Dist //
		copy: {
			dist: {
				files: {
					'dist/': [
						'app-interventions/**',
						'app-reservations/**',
						'fonts/**',
						'js/*.js',
						'js/**/*.js',
						'js/libs/**.js',
						'i18n/**',
						'templates/**',
						'config/*',
						'properties.json',
						'font/*',
						'medias/**/*',
						'LICENSE',
						'AUTHORS'
					]
				}
			}
		},

		// Check JS Files //
		jshint: {
			options: {
				jshintrc: 'grunt/.jshintrc'
			},
			gruntfile: {
				src: ['Gruntfile.js']
			},
			jsonFile: {
				src: ['properties.json', 'package.json', 'config/*.json.*', 'i18n/**/*.json', 'grunt/.*.json', 'app-interventions/config/*.json', 'app-reservations/config/*.json'],
			},
			scripts_main: {
				src: ['js/**/*.js', '!js/libs/*', '!js/i18n/*']
			},
			scripts_inter: {
				src: ['app-interventions/js/**/*.js', 'app-interventions/main.js']
			},
			scripts_resa: {
				//src: ['app-reservations/js/**/*.js', 'app-reservations/main.js']
				src: ['app-reservations/main.js', 'app-reservations/js/routers/*.js', 'app-reservations/js/models/*.js', 'app-reservations/js/collections/*.js']
			},
		},

		// Check CSS Files //
		csslint: {
			dist: {
				options: {
					csslintrc: 'grunt/.csslintrc'
				},
				src: ['dist/style/*.css']
			}
		},

		// Check Style JS Files //
		jscs: {
			options: {
				config: 'grunt/.jscsrc'
			},
			gruntfile: {
				src: ['Gruntfile.js']
			},
			scripts: {
				src: ['js/views/modals/ModalPlaceView.js']
			}
		},

		// Compress the CSS file //
		cssmin: {
			dist: {
				options: {
					banner: '<%= banner %>',
					keepSpecialComments: 0
				},
				files: {
					'dist/style/swif.css': ['dist/style/swif.css']
				}
			}
		},

		// Archive the dist //
		compress : {
			dist : {
				options : {
					mode   : 'tgz',
					level  : 9,
					archive: '<%= pkg.name %>_v<%= pkg.version %>.tar.gz',
					pretty : true
				},
				files : [
					{ expand: true, src : '**/*', cwd : 'dist/' }
				]
			}
		},

		// Add licence to the files //
		usebanner: {
			default: {
				options: {
					position: 'top',
					banner  : '<%= banner %>'
				},
				files: {
					src: ['js/**/*.js', '!js/libs/*', '!js/i18n/*', 'app-interventions/**/*.js', 'app-reservations/**/*.js', 'style/**/*.less', '!style/vendors/**/*.less']
				}
			}
		},

		// Create AUTHORS file //
		contributors: {
			master: {
				branch: 'master',
				chronologically: true
			}
		},

		// Hooks to run check task before each commit //
		githooks: {
			all: {
				'pre-commit': 'check',
			}
		},

		// Display notifications messages //
		notify: {
			check: {
				options: {
					title  : 'Check done without error',
					message: 'Changes can be commited and pushed!'
				}
			},
			build: {
				options: {
					title  : 'Build done without error',
					message: 'v<%= pkg.version %> ready for production!'
				}
			}
		},
		notify_hooks: {
			options: {
				enabled: true,
				max_jshint_notifications: 0
			}
		}

	});

	/** Check if the version in package.json and properties.json are equal
	*   && if the package version are equal to the last git Tag
	*/
	grunt.registerTask('checkVersion', 'Check if the version in package.json and properties.json are equal', function() {

		// Require semver //
		var semver = require('semver');

		// Get the Semver version in the package file //
		var packageVersion = grunt.file.readJSON('package.json').version;

		// Get the Semver version in the properties file //
		var propertiesVersion = grunt.file.readJSON('properties.json').version;

		// Get the last Git Tag version //
		var shell = require('shelljs');
		var cmdOutput = shell.exec('git describe --tags `git rev-list --tags --max-count=1`', {'silent': true});

		if (cmdOutput.code !== 0){
			grunt.fail.fatal('Git software are require');
		}

		var lastTagVersion = cmdOutput.output.replace(/(\r\n|\n|\r)/gm, '');

		// Check if the last Git Tag is correct //
		if (!semver.valid(lastTagVersion)){
			grunt.fail.warn('Last Git tag Version is not correct');
			grunt.log.error(lastTagVersion);
		}

		// Check if the properties.json version is correct //
		if (!semver.valid(propertiesVersion)){
			grunt.fail.warn('Version in properties.json file is not correct');
			grunt.log.error(propertiesVersion);
		}

		// Check if the package.json version is correct //
		if (!semver.valid(packageVersion)){
			grunt.fail.warn('Version in package.json file is not correct');
			grunt.log.error(packageVersion);
		}

		// Check if the package.json version and properties.json version are equal //
		if (packageVersion !== propertiesVersion){
			grunt.fail.warn('Versions in properties.json and package.json are not equal');
			grunt.log.error(packageVersion + ' != ' + propertiesVersion);
		}

		if (semver.gt(lastTagVersion, packageVersion)){
			grunt.fail.warn('App version are lower than the last Git tag');
			grunt.log.error(packageVersion + ' != ' + lastTagVersion);
		}
		else if (semver.lt(lastTagVersion, packageVersion)){
			grunt.fail.warn('App version are greater than the last Git tag');
			grunt.log.error(packageVersion + ' != ' + lastTagVersion);
		}

		grunt.log.writeln('Check version done without error.'.green);
		grunt.log.ok('App version ' + propertiesVersion);

	});

	// Load the Tasks //
	require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
	grunt.task.run('notify_hooks');

	grunt.registerTask('default', ['clean', 'checkVersion', 'build-css', 'targethtml', 'copy', 'compress', 'notify:build']);
	grunt.registerTask('build-css', ['clean', 'less', 'csscomb', 'cssmin']);

	// Check tasks //
	grunt.registerTask('check', ['jshint', 'checkVersion', 'notify:check']);
	grunt.registerTask('check-css', ['clean', 'less', 'csscomb', 'csslint']);

};<commit_msg>update compress grunt<commit_after>module.exports = function(grunt) {

	'use strict';

	grunt.initConfig({

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

		// License banner //
		banner: '/*! \n' +
			' * <%= pkg.name %>\n' +
			' * Copyright 2013-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
			' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
			' */\n',

		archiveName: '<%= pkg.name %>_v<%= pkg.version %>.tar.gz',

		// Clean dist directory //
		clean: {
			dist: ['dist/', '*.tar.gz'],
		},

		// Compile Less file //
		less: {
			options: {
				strictMath: true
			},
			dist: {
				files: {
					'dist/style/swif.css': 'style/startup.less'
				}
			}
		},

		// Clean and organize css file //
		csscomb: {
			options: {
				config: 'grunt/.csscomb.json'
			},
			dist: {
				files: {
					'dist/style/swif.css': ['dist/style/swif.css']
				}
			}
		},

		// Target HTML  //
		targethtml: {
			dist: {
				files: {
					'dist/index.html': 'index.html'
				}
			}
		},

		// Copy files to the Dist //
		copy: {
			dist: {
				files: {
					'dist/': [
						'app-interventions/**',
						'app-reservations/**',
						'fonts/**',
						'js/*.js',
						'js/**/*.js',
						'js/libs/**.js',
						'i18n/**',
						'templates/**',
						'config/*',
						'properties.json',
						'font/*',
						'medias/**/*',
						'LICENSE',
						'AUTHORS'
					]
				}
			}
		},

		// Check JS Files //
		jshint: {
			options: {
				jshintrc: 'grunt/.jshintrc'
			},
			gruntfile: {
				src: ['Gruntfile.js']
			},
			jsonFile: {
				src: ['properties.json', 'package.json', 'config/*.json.*', 'i18n/**/*.json', 'grunt/.*.json', 'app-interventions/config/*.json', 'app-reservations/config/*.json'],
			},
			scripts_main: {
				src: ['js/**/*.js', '!js/libs/*', '!js/i18n/*']
			},
			scripts_inter: {
				src: ['app-interventions/js/**/*.js', 'app-interventions/main.js']
			},
			scripts_resa: {
				//src: ['app-reservations/js/**/*.js', 'app-reservations/main.js']
				src: ['app-reservations/main.js', 'app-reservations/js/routers/*.js', 'app-reservations/js/models/*.js', 'app-reservations/js/collections/*.js']
			},
		},

		// Check CSS Files //
		csslint: {
			dist: {
				options: {
					csslintrc: 'grunt/.csslintrc'
				},
				src: ['dist/style/*.css']
			}
		},

		// Check Style JS Files //
		jscs: {
			options: {
				config: 'grunt/.jscsrc'
			},
			gruntfile: {
				src: ['Gruntfile.js']
			},
			scripts: {
				src: ['js/views/modals/ModalPlaceView.js']
			}
		},

		// Compress the CSS file //
		cssmin: {
			dist: {
				options: {
					banner: '<%= banner %>',
					keepSpecialComments: 0
				},
				files: {
					'dist/style/swif.css': ['dist/style/swif.css']
				}
			}
		},

		// Archive the dist //
		compress : {
			dist : {
				options : {
					mode   : 'tgz',
					level  : 9,
					archive: '<%= archiveName %>',
					pretty : true
				},
				files : [
					{ expand: true, src : '**/*', cwd : 'dist/' }
				]
			}
		},

		// Add licence to the files //
		usebanner: {
			default: {
				options: {
					position: 'top',
					banner  : '<%= banner %>'
				},
				files: {
					src: ['js/**/*.js', '!js/libs/*', '!js/i18n/*', 'app-interventions/**/*.js', 'app-reservations/**/*.js', 'style/**/*.less', '!style/vendors/**/*.less']
				}
			}
		},

		// Create AUTHORS file //
		contributors: {
			master: {
				branch: 'master',
				chronologically: true
			}
		},

		// Hooks to run check task before each commit //
		githooks: {
			all: {
				'pre-commit': 'check',
			}
		},

		// Display notifications messages //
		notify: {
			check: {
				options: {
					title  : 'Check done without error',
					message: 'Changes can be commited and pushed!'
				}
			},
			build: {
				options: {
					title  : 'Build done without error',
					message: 'v<%= pkg.version %> ready for production!'
				}
			}
		},
		notify_hooks: {
			options: {
				enabled: true,
				max_jshint_notifications: 0
			}
		}

	});

	/** Check if the version in package.json and properties.json are equal
	*   && if the package version are equal to the last git Tag
	*/
	grunt.registerTask('checkVersion', 'Check if the version in package.json and properties.json are equal', function() {

		// Require semver //
		var semver = require('semver');

		// Get the Semver version in the package file //
		var packageVersion = grunt.file.readJSON('package.json').version;

		// Get the Semver version in the properties file //
		var propertiesVersion = grunt.file.readJSON('properties.json').version;

		// Get the last Git Tag version //
		var shell = require('shelljs');
		var cmdOutput = shell.exec('git describe --tags `git rev-list --tags --max-count=1`', {'silent': true});

		if (cmdOutput.code !== 0){
			grunt.fail.fatal('Git software are require');
		}

		var lastTagVersion = cmdOutput.output.replace(/(\r\n|\n|\r)/gm, '');

		// Check if the last Git Tag is correct //
		if (!semver.valid(lastTagVersion)){
			grunt.fail.warn('Last Git tag Version is not correct');
			grunt.log.error(lastTagVersion);
		}

		// Check if the properties.json version is correct //
		if (!semver.valid(propertiesVersion)){
			grunt.fail.warn('Version in properties.json file is not correct');
			grunt.log.error(propertiesVersion);
		}

		// Check if the package.json version is correct //
		if (!semver.valid(packageVersion)){
			grunt.fail.warn('Version in package.json file is not correct');
			grunt.log.error(packageVersion);
		}

		// Check if the package.json version and properties.json version are equal //
		if (packageVersion !== propertiesVersion){
			grunt.fail.warn('Versions in properties.json and package.json are not equal');
			grunt.log.error(packageVersion + ' != ' + propertiesVersion);
		}

		if (semver.gt(lastTagVersion, packageVersion)){
			grunt.fail.warn('App version are lower than the last Git tag');
			grunt.log.error(packageVersion + ' != ' + lastTagVersion);
		}
		else if (semver.lt(lastTagVersion, packageVersion)){
			grunt.fail.warn('App version are greater than the last Git tag');
			grunt.log.error(packageVersion + ' != ' + lastTagVersion);
		}

		grunt.log.writeln('Check version done without error.'.green);
		grunt.log.ok('App version ' + propertiesVersion);

	});

	// Load the Tasks //
	require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
	grunt.task.run('notify_hooks');

	grunt.registerTask('default', ['clean', 'checkVersion', 'build-css', 'targethtml', 'copy', 'compress', 'notify:build']);
	grunt.registerTask('build-css', ['clean', 'less', 'csscomb', 'cssmin']);

	// Check tasks //
	grunt.registerTask('check', ['jshint', 'checkVersion', 'notify:check']);
	grunt.registerTask('check-css', ['clean', 'less', 'csscomb', 'csslint']);

};<|endoftext|>


<commit_before>/*jslint node: true */
'use strict';

var pkg = require('./package.json');
var AV_CONFIG_VERSION = '3.1.3';

//Using exclusion patterns slows down Grunt significantly
//instead of creating a set of patterns like '**/*.js' and '!**/node_modules/**'
//this method is used to create a set of inclusive patterns for all subdirectories
//skipping node_modules, bower_components, dist, and any .dirs
//This enables users to create any directory structure they desire.
var createFolderGlobs = function(fileTypePatterns) {
  fileTypePatterns = Array.isArray(fileTypePatterns) ? fileTypePatterns : [fileTypePatterns];
  var ignore = ['node_modules','bower_components','dist','temp'];
  var fs = require('fs');
  return fs.readdirSync(process.cwd())
          .map(function(file){
            if (ignore.indexOf(file) !== -1 ||
                file.indexOf('.') === 0 ||
                !fs.lstatSync(file).isDirectory()) {
              return null;
            } else {
              return fileTypePatterns.map(function(pattern) {
                return file + '/**/' + pattern;
              });
            }
          })
          .filter(function(patterns){
            return patterns;
          })
          .concat(fileTypePatterns);
};

module.exports = function (grunt) {

  // load all grunt tasks
  require('load-grunt-tasks')(grunt);

  // custom grunt task to check avConfig.js
  grunt.registerTask('check_config', function() {
    var fs = require('fs');
    var done = this.async();
    grunt.log.ok('Checking avConfig.js...');
    var conf = fs.readFile('avConfig.js', function(err, data) {
        if (err) {
            grunt.log.error('No avConfig.js file found');
            done(false);
        } else {
            var match = data.toString().match(/AV_CONFIG_VERSION = [\'\"]([\w\.]*)[\'\"];/);
            if (!match) {
                grunt.log.error('Invalid avConfig.js version');
            } else {
                var v = match[1];
                if (v === AV_CONFIG_VERSION) {
                    return done();
                } else {
                    grunt.log.error('Invalid avConfig.js version: ' + v);
                }
            }
            done(false);
        }
    });
  });

  // Project configuration.
  grunt.initConfig({
    connect: {
      main: {
        options: {
          port: 9001
        }
      }
    },
    watch: {
      main: {
        options: {
            livereload: true,
            livereloadOnError: false,
            spawn: false
        },
        files: [createFolderGlobs(['*.js','*.less','*.html']),'!_SpecRunner.html','!.grunt'],
        tasks: [] //all the tasks are run dynamically during the watch event handler
      }
    },
    jshint: {
      main: {
        options: {
            jshintrc: '.jshintrc'
        },
        src: createFolderGlobs('*.js')
      }
    },
    clean: {
      before:{
        src:['dist','temp']
      },
      after: {
        src:['temp']
      }
    },
    less: {
      production: {
        options: {
        },
        files: [{
          expand: true,
          src: ['bower_components/avCommon/themes/**/app.less', 'plugins/**/*.less'],
          dest: 'temp/',
          ext: '.css',
        }]
      }
    },
    autoprefixer: {
      options: {
        browsers: ['ie >= 8', 'ff > 4', 'last 8 versions']
      },
      main: {
        src: 'temp/bower_components/avCommon/themes/**/app.css'
      }
    },
    ngtemplates: {
      main: {
        options: {
            module: pkg.name,
            htmlmin:'<%= htmlmin.main.options %>'
        },
        src: [createFolderGlobs('*.html'),'!index.html','!_SpecRunner.html'],
        dest: 'temp/templates.js'
      },
      common: {
        options: {
            module: pkg.name,
            htmlmin:'<%= htmlmin.main.options %>'
        },
        cwd: 'bower_components/avCommon',
        src: ["avRegistration/**/*.html", "avUi/**/*.html" ],
        dest: 'temp/templates-common.js'
      }
    },
    copy: {
      main: {
        files: [
          {src: ['img/**'], dest: 'dist/'},
          {src: ['img/**'], dest: 'dist/'},
          {src: ['temp_data/**'], dest: 'dist/'},
          {
            expand: true,
            cwd:'bower_components/avCommon/themes',
            src: ['**/*.png'],
            dest: 'dist/themes/',
            ext: '.png',
            extDot: 'first'
          },
          {
            expand: true,
            cwd: 'bower_components/bootstrap/fonts/',
            src: ['**'],
            dest: 'dist/themes/fonts/'
          },
          {
            expand: true,
            cwd: 'bower_components/bootstrap/fonts/',
            src: ['**'],
            dest: 'dist/themes/fonts/'
          },
          {
            expand: true,
            cwd: 'bower_components/font-awesome/fonts/',
            src: ['**'],
            dest: 'dist/fonts/'
          }
          //{src: ['bower_components/angular-ui-utils/ui-utils-ieshiv.min.js'], dest: 'dist/'},
          //{src: ['bower_components/select2/*.png','bower_components/select2/*.gif'], dest:'dist/css/',flatten:true,expand:true},
          //{src: ['bower_components/angular-mocks/angular-mocks.js'], dest: 'dist/'}
        ]
      }
    },
    dom_munger:{
      read: {
        options: {
          read:[
            {selector:'script[class="libnocompat"]',attribute:'src',writeto:'libnocompatjs'},
            {selector:'script[class="lib"]',attribute:'src',writeto:'libjs'},
            {selector:'script[class="app"]',attribute:'src',writeto:'appjs'},
            {selector:'link[rel="stylesheet"][data-concat!="false"]',attribute:'href',writeto:'appcss'}
          ]
        },
        src: 'index.html'
      },
      update: {
        options: {
          remove: ['script[data-remove!="false"]','link[data-remove!="false"]'],
          append: [
            {selector:'body',html:'<!--[if lte IE 8]><script src="/admin/libcompat-v3.0.1.min.js"></script><![endif]--><!--[if gte IE 9]><script src="/admin/libnocompat-v3.0.1.min.js"></script><![endif]--><!--[if !IE]><!--><script src="/admin/libnocompat-v3.0.1.min.js"></script><!--<![endif]-->'},
            {selector:'body',html:'<!--All the source code of this program under copyright. Take a look at the license details at https://github.com/agoravoting/agora-core-view/blob/master/README.md -->'},
            {selector:'body',html:'<script src="/admin/lib-v3.0.1.min.js"></script>'},
            {selector:'body',html:'<script src="/admin/avConfig-v3.0.1.js"></script>'},
            {selector:'body',html:'<script src="/admin/avThemes-v3.0.1.js"></script>'},
            {selector:'body',html:'<script src="/admin/app-v3.0.1.min.js"></script>'},
            {selector:'body',html:'<script src="/admin/avPlugins-v3.0.1.js"></script>'},
            {selector:'head',html:'<link rel="stylesheet" id="theme" data-base="/admin/" href="/admin/themes/default/app.min.css">'},
            {selector:'head',html:'<link rel="stylesheet" id="plugins" data-base="/admin/" href="/admin/plugins.css">'}
          ]
        },
        src:'index.html',
        dest: 'dist/index.html'
      }
    },
    cssmin: {
      main: {
        files: [{
            expand: true,
            cwd:'temp/bower_components/avCommon/themes',
            src: ['**/app.css'],
            dest: 'dist/themes/',
            ext: '.min.css',
            extDot: 'first'
        }]
      },
    },
    concat: {
      main: {
        files: {
          'dist/plugins.css': ['temp/plugins/**/*.css'],
          'temp/libcompat.js': [
            'vendor/jquery.compat/jquery-1.11.1.js',
            'vendor/json3/json-v3.3.2.js',
            'vendor/crypto/unsupportedBrowser.js'
          ],
          'temp/libnocompat.js': ['<%= dom_munger.data.libnocompatjs %>'],
          'temp/lib.js': ['<%= dom_munger.data.libjs %>'],
          'temp/app.js': ['<%= dom_munger.data.appjs %>','<%= ngtemplates.main.dest %>','<%= ngtemplates.common.dest %>'],
          'dist/avConfig-v3.0.1.js': ['avConfig.js'],
          'dist/avThemes-v3.0.1.js': ['bower_components/avCommon/dist/avThemes-v3.0.1.js'],
          'dist/avPlugins-v3.0.1.js': ['plugins/**/*.js']
        }
      }
    },
    "merge-json": {
      main: {
        files: {
            "dist/locales/en.json": ["locales/en.json", "plugins/**/locales/en.json", "bower_components/avCommon/locales/en.json"],
            "dist/locales/es.json": ["locales/es.json", "plugins/**/locales/es.json", "bower_components/avCommon/locales/es.json"],
            "dist/locales/gl.json": ["locales/gl.json", "plugins/**/locales/gl.json", "bower_components/avCommon/locales/gl.json"],
            "dist/locales/ca.json": ["locales/ca.json", "plugins/**/locales/ca.json", "bower_components/avCommon/locales/ca.json"]
        }
      }
    },
    ngAnnotate: {
      main: {
        files: {
        'temp/app.js':['temp/app.js'],
        'temp/lib.js': ['temp/lib.js'],
        'temp/libnocompat.js': ['temp/libnocompat.js'],
        'temp/libcompat.js': ['temp/libcompat.js']
        }
      }
    },
    uglify: {
      main: {
        options:{
          mangle: false,
          compress: {},
          beautify: true
        },
        files: {
          'dist/app-v3.0.1.min.js': 'temp/app.js',
          'dist/lib-v3.0.1.min.js': 'temp/lib.js',
          'dist/libnocompat-v3.0.1.min.js': 'temp/libnocompat.js',
          'dist/libcompat-v3.0.1.min.js': 'temp/libcompat.js',
          'dist/avWidgets.min.js': 'avWidgets.js',

          "dist/locales/moment/en.js": "bower_components/moment/lang/en-gb.js",
          "dist/locales/moment/es.js": "bower_components/moment/lang/es.js",
          "dist/locales/moment/gl.js": "bower_components/moment/lang/gl.js",
          "dist/locales/moment/ca.js": "bower_components/moment/lang/ca.js"
        }
      }
    },
    htmlmin: {
      main: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          removeAttributeQuotes: false,
          removeComments: false,
          removeEmptyAttributes: true,
          removeScriptTypeAttributes: true,
          removeStyleLinkTypeAttributes: true
        },
        files: {
          'dist/index.html': 'dist/index.html'
        }
      }
    },
    karma: {
      options: {
        frameworks: ['jasmine'],
        files: [  //this files data is also updated in the watch handler, if updated change there too
          '<%= dom_munger.data.libnocompatjs %>',
          '<%= dom_munger.data.libjs %>',
          'avConfig.js',
          'avThemes.js',
          'avWidgets.js',
          '<%= dom_munger.data.appjs %>',
          '<%= ngtemplates.main.dest %>',
          '<%= ngtemplates.common.dest %>',
          'bower_components/angular-mocks/angular-mocks.js',
          createFolderGlobs('*-spec.js')
        ],
        logLevel:'ERROR',
        reporters:['mocha'],
        autoWatch: false, //watching is handled by grunt-contrib-watch
        singleRun: true
      },
      all_tests: {
        browsers: ['PhantomJS','Chrome','Firefox']
      },
      during_watch: {
        browsers: ['PhantomJS']
      },
    },
    protractor: {
      options: {
        configFile: "node_modules/protractor/referenceConf.js", // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
        // Arguments passed to the command
      }
    },
    //your_target: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
      all: {
      options: {
        configFile: "e2e.conf.js", // Target-specific config file
        args: {} // Target-specific arguments
      }
    },
  },

  });

  grunt.registerTask('build',['check_config', 'jshint','clean:before','less','autoprefixer','dom_munger','ngtemplates','cssmin','concat','merge-json','ngAnnotate','uglify','copy','htmlmin','clean:after']);
  grunt.registerTask('serve', ['dom_munger:read','jshint','connect', 'watch']);
  grunt.registerTask('test',['dom_munger:read','karma:all_tests']);

  grunt.event.on('watch', function(action, filepath) {
    //https://github.com/gruntjs/grunt-contrib-watch/issues/156

    var tasksToRun = [];

    if ((filepath.lastIndexOf('.json') !== -1 && filepath.lastIndexOf('.json') === filepath.length - 5) ||
        (filepath.lastIndexOf('.js') !== -1 && filepath.lastIndexOf('.js') === filepath.length - 3)) {

      //lint the changed js file
      grunt.config('jshint.main.src', filepath);
      tasksToRun.push('jshint');

      //find the appropriate unit t est for the changed file
      var spec = filepath;
      if (filepath.lastIndexOf('-spec.js') === -1 || filepath.lastIndexOf('-spec.js') !== filepath.length - 8) {
        spec = filepath.substring(0,filepath.length - 3) + '-spec.js';
      }

      //if the spec exists then lets run it
      if (grunt.file.exists(spec)) {
        var files = [].concat(grunt.config('dom_munger.data.libnocompatjs'));
        files.concat(grunt.config('dom_munger.data.libjs'));
        files.push('bower_components/angular-mocks/angular-mocks.js');
        files.push('avConfig.js');
        files.push('avThemes.js');
        files.push('avWidgets.js');
        files.concat(grunt.config('dom_munger.data.appjs'));
        files.concat(grunt.config('ngtemplates.main.dest'));
        files.push(spec);
        grunt.config('karma.options.files', files);
        tasksToRun.push('karma:during_watch');
      }
    }

    //if index.html changed, we need to reread the <script> tags so our next run of karma
    //will have the correct environment
    if (filepath === 'index.html') {
      tasksToRun.push('dom_munger:read');
    }

    grunt.config('watch.main.tasks',tasksToRun);

  });

  grunt.loadNpmTasks('grunt-protractor-runner');
};
<commit_msg>Necessary change of AV_CONFIG_VERSION<commit_after>/*jslint node: true */
'use strict';

var pkg = require('./package.json');
var AV_CONFIG_VERSION = '3.1.4';

//Using exclusion patterns slows down Grunt significantly
//instead of creating a set of patterns like '**/*.js' and '!**/node_modules/**'
//this method is used to create a set of inclusive patterns for all subdirectories
//skipping node_modules, bower_components, dist, and any .dirs
//This enables users to create any directory structure they desire.
var createFolderGlobs = function(fileTypePatterns) {
  fileTypePatterns = Array.isArray(fileTypePatterns) ? fileTypePatterns : [fileTypePatterns];
  var ignore = ['node_modules','bower_components','dist','temp'];
  var fs = require('fs');
  return fs.readdirSync(process.cwd())
          .map(function(file){
            if (ignore.indexOf(file) !== -1 ||
                file.indexOf('.') === 0 ||
                !fs.lstatSync(file).isDirectory()) {
              return null;
            } else {
              return fileTypePatterns.map(function(pattern) {
                return file + '/**/' + pattern;
              });
            }
          })
          .filter(function(patterns){
            return patterns;
          })
          .concat(fileTypePatterns);
};

module.exports = function (grunt) {

  // load all grunt tasks
  require('load-grunt-tasks')(grunt);

  // custom grunt task to check avConfig.js
  grunt.registerTask('check_config', function() {
    var fs = require('fs');
    var done = this.async();
    grunt.log.ok('Checking avConfig.js...');
    var conf = fs.readFile('avConfig.js', function(err, data) {
        if (err) {
            grunt.log.error('No avConfig.js file found');
            done(false);
        } else {
            var match = data.toString().match(/AV_CONFIG_VERSION = [\'\"]([\w\.]*)[\'\"];/);
            if (!match) {
                grunt.log.error('Invalid avConfig.js version');
            } else {
                var v = match[1];
                if (v === AV_CONFIG_VERSION) {
                    return done();
                } else {
                    grunt.log.error('Invalid avConfig.js version: ' + v);
                }
            }
            done(false);
        }
    });
  });

  // Project configuration.
  grunt.initConfig({
    connect: {
      main: {
        options: {
          port: 9001
        }
      }
    },
    watch: {
      main: {
        options: {
            livereload: true,
            livereloadOnError: false,
            spawn: false
        },
        files: [createFolderGlobs(['*.js','*.less','*.html']),'!_SpecRunner.html','!.grunt'],
        tasks: [] //all the tasks are run dynamically during the watch event handler
      }
    },
    jshint: {
      main: {
        options: {
            jshintrc: '.jshintrc'
        },
        src: createFolderGlobs('*.js')
      }
    },
    clean: {
      before:{
        src:['dist','temp']
      },
      after: {
        src:['temp']
      }
    },
    less: {
      production: {
        options: {
        },
        files: [{
          expand: true,
          src: ['bower_components/avCommon/themes/**/app.less', 'plugins/**/*.less'],
          dest: 'temp/',
          ext: '.css',
        }]
      }
    },
    autoprefixer: {
      options: {
        browsers: ['ie >= 8', 'ff > 4', 'last 8 versions']
      },
      main: {
        src: 'temp/bower_components/avCommon/themes/**/app.css'
      }
    },
    ngtemplates: {
      main: {
        options: {
            module: pkg.name,
            htmlmin:'<%= htmlmin.main.options %>'
        },
        src: [createFolderGlobs('*.html'),'!index.html','!_SpecRunner.html'],
        dest: 'temp/templates.js'
      },
      common: {
        options: {
            module: pkg.name,
            htmlmin:'<%= htmlmin.main.options %>'
        },
        cwd: 'bower_components/avCommon',
        src: ["avRegistration/**/*.html", "avUi/**/*.html" ],
        dest: 'temp/templates-common.js'
      }
    },
    copy: {
      main: {
        files: [
          {src: ['img/**'], dest: 'dist/'},
          {src: ['img/**'], dest: 'dist/'},
          {src: ['temp_data/**'], dest: 'dist/'},
          {
            expand: true,
            cwd:'bower_components/avCommon/themes',
            src: ['**/*.png'],
            dest: 'dist/themes/',
            ext: '.png',
            extDot: 'first'
          },
          {
            expand: true,
            cwd: 'bower_components/bootstrap/fonts/',
            src: ['**'],
            dest: 'dist/themes/fonts/'
          },
          {
            expand: true,
            cwd: 'bower_components/bootstrap/fonts/',
            src: ['**'],
            dest: 'dist/themes/fonts/'
          },
          {
            expand: true,
            cwd: 'bower_components/font-awesome/fonts/',
            src: ['**'],
            dest: 'dist/fonts/'
          }
          //{src: ['bower_components/angular-ui-utils/ui-utils-ieshiv.min.js'], dest: 'dist/'},
          //{src: ['bower_components/select2/*.png','bower_components/select2/*.gif'], dest:'dist/css/',flatten:true,expand:true},
          //{src: ['bower_components/angular-mocks/angular-mocks.js'], dest: 'dist/'}
        ]
      }
    },
    dom_munger:{
      read: {
        options: {
          read:[
            {selector:'script[class="libnocompat"]',attribute:'src',writeto:'libnocompatjs'},
            {selector:'script[class="lib"]',attribute:'src',writeto:'libjs'},
            {selector:'script[class="app"]',attribute:'src',writeto:'appjs'},
            {selector:'link[rel="stylesheet"][data-concat!="false"]',attribute:'href',writeto:'appcss'}
          ]
        },
        src: 'index.html'
      },
      update: {
        options: {
          remove: ['script[data-remove!="false"]','link[data-remove!="false"]'],
          append: [
            {selector:'body',html:'<!--[if lte IE 8]><script src="/admin/libcompat-v3.0.1.min.js"></script><![endif]--><!--[if gte IE 9]><script src="/admin/libnocompat-v3.0.1.min.js"></script><![endif]--><!--[if !IE]><!--><script src="/admin/libnocompat-v3.0.1.min.js"></script><!--<![endif]-->'},
            {selector:'body',html:'<!--All the source code of this program under copyright. Take a look at the license details at https://github.com/agoravoting/agora-core-view/blob/master/README.md -->'},
            {selector:'body',html:'<script src="/admin/lib-v3.0.1.min.js"></script>'},
            {selector:'body',html:'<script src="/admin/avConfig-v3.0.1.js"></script>'},
            {selector:'body',html:'<script src="/admin/avThemes-v3.0.1.js"></script>'},
            {selector:'body',html:'<script src="/admin/app-v3.0.1.min.js"></script>'},
            {selector:'body',html:'<script src="/admin/avPlugins-v3.0.1.js"></script>'},
            {selector:'head',html:'<link rel="stylesheet" id="theme" data-base="/admin/" href="/admin/themes/default/app.min.css">'},
            {selector:'head',html:'<link rel="stylesheet" id="plugins" data-base="/admin/" href="/admin/plugins.css">'}
          ]
        },
        src:'index.html',
        dest: 'dist/index.html'
      }
    },
    cssmin: {
      main: {
        files: [{
            expand: true,
            cwd:'temp/bower_components/avCommon/themes',
            src: ['**/app.css'],
            dest: 'dist/themes/',
            ext: '.min.css',
            extDot: 'first'
        }]
      },
    },
    concat: {
      main: {
        files: {
          'dist/plugins.css': ['temp/plugins/**/*.css'],
          'temp/libcompat.js': [
            'vendor/jquery.compat/jquery-1.11.1.js',
            'vendor/json3/json-v3.3.2.js',
            'vendor/crypto/unsupportedBrowser.js'
          ],
          'temp/libnocompat.js': ['<%= dom_munger.data.libnocompatjs %>'],
          'temp/lib.js': ['<%= dom_munger.data.libjs %>'],
          'temp/app.js': ['<%= dom_munger.data.appjs %>','<%= ngtemplates.main.dest %>','<%= ngtemplates.common.dest %>'],
          'dist/avConfig-v3.0.1.js': ['avConfig.js'],
          'dist/avThemes-v3.0.1.js': ['bower_components/avCommon/dist/avThemes-v3.0.1.js'],
          'dist/avPlugins-v3.0.1.js': ['plugins/**/*.js']
        }
      }
    },
    "merge-json": {
      main: {
        files: {
            "dist/locales/en.json": ["locales/en.json", "plugins/**/locales/en.json", "bower_components/avCommon/locales/en.json"],
            "dist/locales/es.json": ["locales/es.json", "plugins/**/locales/es.json", "bower_components/avCommon/locales/es.json"],
            "dist/locales/gl.json": ["locales/gl.json", "plugins/**/locales/gl.json", "bower_components/avCommon/locales/gl.json"],
            "dist/locales/ca.json": ["locales/ca.json", "plugins/**/locales/ca.json", "bower_components/avCommon/locales/ca.json"]
        }
      }
    },
    ngAnnotate: {
      main: {
        files: {
        'temp/app.js':['temp/app.js'],
        'temp/lib.js': ['temp/lib.js'],
        'temp/libnocompat.js': ['temp/libnocompat.js'],
        'temp/libcompat.js': ['temp/libcompat.js']
        }
      }
    },
    uglify: {
      main: {
        options:{
          mangle: false,
          compress: {},
          beautify: true
        },
        files: {
          'dist/app-v3.0.1.min.js': 'temp/app.js',
          'dist/lib-v3.0.1.min.js': 'temp/lib.js',
          'dist/libnocompat-v3.0.1.min.js': 'temp/libnocompat.js',
          'dist/libcompat-v3.0.1.min.js': 'temp/libcompat.js',
          'dist/avWidgets.min.js': 'avWidgets.js',

          "dist/locales/moment/en.js": "bower_components/moment/lang/en-gb.js",
          "dist/locales/moment/es.js": "bower_components/moment/lang/es.js",
          "dist/locales/moment/gl.js": "bower_components/moment/lang/gl.js",
          "dist/locales/moment/ca.js": "bower_components/moment/lang/ca.js"
        }
      }
    },
    htmlmin: {
      main: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          removeAttributeQuotes: false,
          removeComments: false,
          removeEmptyAttributes: true,
          removeScriptTypeAttributes: true,
          removeStyleLinkTypeAttributes: true
        },
        files: {
          'dist/index.html': 'dist/index.html'
        }
      }
    },
    karma: {
      options: {
        frameworks: ['jasmine'],
        files: [  //this files data is also updated in the watch handler, if updated change there too
          '<%= dom_munger.data.libnocompatjs %>',
          '<%= dom_munger.data.libjs %>',
          'avConfig.js',
          'avThemes.js',
          'avWidgets.js',
          '<%= dom_munger.data.appjs %>',
          '<%= ngtemplates.main.dest %>',
          '<%= ngtemplates.common.dest %>',
          'bower_components/angular-mocks/angular-mocks.js',
          createFolderGlobs('*-spec.js')
        ],
        logLevel:'ERROR',
        reporters:['mocha'],
        autoWatch: false, //watching is handled by grunt-contrib-watch
        singleRun: true
      },
      all_tests: {
        browsers: ['PhantomJS','Chrome','Firefox']
      },
      during_watch: {
        browsers: ['PhantomJS']
      },
    },
    protractor: {
      options: {
        configFile: "node_modules/protractor/referenceConf.js", // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
        // Arguments passed to the command
      }
    },
    //your_target: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
      all: {
      options: {
        configFile: "e2e.conf.js", // Target-specific config file
        args: {} // Target-specific arguments
      }
    },
  },

  });

  grunt.registerTask('build',['check_config', 'jshint','clean:before','less','autoprefixer','dom_munger','ngtemplates','cssmin','concat','merge-json','ngAnnotate','uglify','copy','htmlmin','clean:after']);
  grunt.registerTask('serve', ['dom_munger:read','jshint','connect', 'watch']);
  grunt.registerTask('test',['dom_munger:read','karma:all_tests']);

  grunt.event.on('watch', function(action, filepath) {
    //https://github.com/gruntjs/grunt-contrib-watch/issues/156

    var tasksToRun = [];

    if ((filepath.lastIndexOf('.json') !== -1 && filepath.lastIndexOf('.json') === filepath.length - 5) ||
        (filepath.lastIndexOf('.js') !== -1 && filepath.lastIndexOf('.js') === filepath.length - 3)) {

      //lint the changed js file
      grunt.config('jshint.main.src', filepath);
      tasksToRun.push('jshint');

      //find the appropriate unit t est for the changed file
      var spec = filepath;
      if (filepath.lastIndexOf('-spec.js') === -1 || filepath.lastIndexOf('-spec.js') !== filepath.length - 8) {
        spec = filepath.substring(0,filepath.length - 3) + '-spec.js';
      }

      //if the spec exists then lets run it
      if (grunt.file.exists(spec)) {
        var files = [].concat(grunt.config('dom_munger.data.libnocompatjs'));
        files.concat(grunt.config('dom_munger.data.libjs'));
        files.push('bower_components/angular-mocks/angular-mocks.js');
        files.push('avConfig.js');
        files.push('avThemes.js');
        files.push('avWidgets.js');
        files.concat(grunt.config('dom_munger.data.appjs'));
        files.concat(grunt.config('ngtemplates.main.dest'));
        files.push(spec);
        grunt.config('karma.options.files', files);
        tasksToRun.push('karma:during_watch');
      }
    }

    //if index.html changed, we need to reread the <script> tags so our next run of karma
    //will have the correct environment
    if (filepath === 'index.html') {
      tasksToRun.push('dom_munger:read');
    }

    grunt.config('watch.main.tasks',tasksToRun);

  });

  grunt.loadNpmTasks('grunt-protractor-runner');
};
<|endoftext|>


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

  // ----------------------------------------------------------
  // WARNING, BRAVE DEVELOPER
  // ----------------------------------------------------------
  // Webhook allows you to use local grunt tasks and files.
  // However, these tasks are ONLY RUN LOCALLY and not when
  // your live site needs to be rebuilt. This means you should
  // only use grunt for pre-processing tasks like building
  // Sass, less or coffescript files, not for reading things
  // from your templates and making dynamic changes during
  // the build process. Doing so will cause your live site
  // not to regerate.
  //
  // You have been warned!
  grunt.initConfig({

  });

  // NEVER REMOVE THESE LINES, OR ELSE YOUR PROJECT MAY NOT WORK
  require('./options/generatorOptions.js')(grunt);
  grunt.loadTasks('tasks');
};
<commit_msg>Typo in gruntfile<commit_after>'use strict';
module.exports = function(grunt) {

  // ----------------------------------------------------------
  // WARNING, BRAVE DEVELOPER
  // ----------------------------------------------------------
  // Webhook allows you to use local grunt tasks and files.
  // However, these tasks are ONLY RUN LOCALLY and not when
  // your live site needs to be rebuilt. This means you should
  // only use grunt for pre-processing tasks like building
  // Sass, less or coffescript files, not for reading things
  // from your templates and making dynamic changes during
  // the build process. Doing so will cause your live site
  // not to regenerate.
  //
  // You have been warned!
  grunt.initConfig({

  });

  // NEVER REMOVE THESE LINES, OR ELSE YOUR PROJECT MAY NOT WORK
  require('./options/generatorOptions.js')(grunt);
  grunt.loadTasks('tasks');
};
<|endoftext|>


<commit_before>// Generated on 2015-11-30 using generator-chrome-extension 0.4.4
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    srcScript: '<%= config.app %>/scripts'
  };

  grunt.initConfig({

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= config.srcScript %>/{,*/}*.js'],
        tasks: ['jshint', 'babel'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: [],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.app %>/*.html',
          '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= config.app %>/manifest.json',
          '<%= config.app %>/_locales/{,*/}*.json'
        ]
      }
    },

    // Grunt server and debug server setting
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      chrome: {
        options: {
          open: false,
          base: [
            '<%= config.app %>'
          ]
        }
      },
      test: {
        options: {
          open: false,
          base: [
            'test',
            '<%= config.app %>'
          ]
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      chrome: {
      },
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= config.dist %>/*',
            '!<%= config.dist %>/.git*'
          ]
        }]
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish'),
        force: true
      },
      all: [
        'Gruntfile.js',
        '<%= config.srcScript %>/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },

    // Automatically inject Bower components into the HTML file
    bowerInstall: {
      app: {
        src: [
          '<%= config.app %>/*.html'
        ]
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: [
        '<%= config.app %>/popup.html',
        '<%= config.app %>/options.html'
      ]
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      options: {
        assetsDirs: ['<%= config.dist %>', '<%= config.dist %>/images']
      },
      html: ['<%= config.dist %>/{,*/}*.html'],
      css: ['<%= config.dist %>/styles/{,*/}*.css']
    },

    // The following *-min tasks produce minifies files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // removeCommentsFromCDATA: true,
          // collapseWhitespace: true,
          // collapseBooleanAttributes: true,
          // removeAttributeQuotes: true,
          // removeRedundantAttributes: true,
          // useShortDoctype: true,
          // removeEmptyAttributes: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: '*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= config.dist %>/styles/main.css': [
    //         '<%= config.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= config.dist %>/scripts/scripts.js': [
    //         '<%= config.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp,gif}',
            '{,*/}*.html',
            'styles/{,*/}*.css',
            'styles/fonts/{,*/}*.*',
            '_locales/{,*/}*.json',
          ]
        }]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      chrome: [
      ],
      dist: [
        'imagemin',
        'svgmin'
      ],
      test: [
      ]
    },

    // Auto buildnumber, exclude debug files. smart builds that event pages
    chromeManifest: {
      dist: {
        options: {
          buildnumber: true,
          indentSize: 2,
          background: {
            target: 'scripts/background.js',
            exclude: [
              'scripts/chromereload.js'
            ]
          }
        },
        src: '<%= config.app %>',
        dest: '<%= config.dist %>'
      }
    },

    // Compress dist files to package
    compress: {
      dist: {
        options: {
          archive: function() {
            var manifest = grunt.file.readJSON('app/manifest.json');
            return 'package/Granottifier-' + manifest.version + '.zip';
          }
        },
        files: [{
          expand: true,
          cwd: 'dist/',
          src: ['**/*'],
          dest: ''
        }]
      }
    }
  });

  grunt.registerTask('debug', function () {
    grunt.task.run([
      'jshint',
      'concurrent:chrome',
      'connect:chrome',
      'watch'
    ]);
  });

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

  grunt.registerTask('build', [
    'clean:dist',
    'chromeManifest:dist',
    'useminPrepare',
    'concurrent:dist',
    // No UI feature selected, cssmin task will be commented
    'cssmin',
    'concat',
    'uglify',
    'copy',
    'usemin',
    'compress'
  ]);

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Remove 'babel' task from Gruntfile.js<commit_after>// Generated on 2015-11-30 using generator-chrome-extension 0.4.4
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    srcScript: '<%= config.app %>/scripts'
  };

  grunt.initConfig({

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= config.srcScript %>/{,*/}*.js'],
        // tasks: ['jshint', 'babel'],
        tasks: ['jshint'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: [],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.app %>/*.html',
          '<%= config.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= config.app %>/manifest.json',
          '<%= config.app %>/_locales/{,*/}*.json'
        ]
      }
    },

    // Grunt server and debug server setting
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      chrome: {
        options: {
          open: false,
          base: [
            '<%= config.app %>'
          ]
        }
      },
      test: {
        options: {
          open: false,
          base: [
            'test',
            '<%= config.app %>'
          ]
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      chrome: {
      },
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= config.dist %>/*',
            '!<%= config.dist %>/.git*'
          ]
        }]
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish'),
        force: true
      },
      all: [
        'Gruntfile.js',
        '<%= config.srcScript %>/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://localhost:<%= connect.options.port %>/index.html']
        }
      }
    },

    // Automatically inject Bower components into the HTML file
    bowerInstall: {
      app: {
        src: [
          '<%= config.app %>/*.html'
        ]
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: [
        '<%= config.app %>/popup.html',
        '<%= config.app %>/options.html'
      ]
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      options: {
        assetsDirs: ['<%= config.dist %>', '<%= config.dist %>/images']
      },
      html: ['<%= config.dist %>/{,*/}*.html'],
      css: ['<%= config.dist %>/styles/{,*/}*.css']
    },

    // The following *-min tasks produce minifies files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // removeCommentsFromCDATA: true,
          // collapseWhitespace: true,
          // collapseBooleanAttributes: true,
          // removeAttributeQuotes: true,
          // removeRedundantAttributes: true,
          // useShortDoctype: true,
          // removeEmptyAttributes: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: '*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= config.dist %>/styles/main.css': [
    //         '<%= config.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= config.dist %>/scripts/scripts.js': [
    //         '<%= config.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp,gif}',
            '{,*/}*.html',
            'styles/{,*/}*.css',
            'styles/fonts/{,*/}*.*',
            '_locales/{,*/}*.json',
          ]
        }]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      chrome: [
      ],
      dist: [
        'imagemin',
        'svgmin'
      ],
      test: [
      ]
    },

    // Auto buildnumber, exclude debug files. smart builds that event pages
    chromeManifest: {
      dist: {
        options: {
          buildnumber: true,
          indentSize: 2,
          background: {
            target: 'scripts/background.js',
            exclude: [
              'scripts/chromereload.js'
            ]
          }
        },
        src: '<%= config.app %>',
        dest: '<%= config.dist %>'
      }
    },

    // Compress dist files to package
    compress: {
      dist: {
        options: {
          archive: function() {
            var manifest = grunt.file.readJSON('app/manifest.json');
            return 'package/Granottifier-' + manifest.version + '.zip';
          }
        },
        files: [{
          expand: true,
          cwd: 'dist/',
          src: ['**/*'],
          dest: ''
        }]
      }
    }
  });

  grunt.registerTask('debug', function () {
    grunt.task.run([
      'jshint',
      'concurrent:chrome',
      'connect:chrome',
      'watch'
    ]);
  });

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

  grunt.registerTask('build', [
    'clean:dist',
    'chromeManifest:dist',
    'useminPrepare',
    'concurrent:dist',
    // No UI feature selected, cssmin task will be commented
    'cssmin',
    'concat',
    'uglify',
    'copy',
    'usemin',
    'compress'
  ]);

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


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

    var port = grunt.option('port') || 8080;
    // Project configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            banner:
                '/*!\n' +
                ' * consortium-viewer.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
                ' * https://github.com/consortium/hybrid-publishing-research\n' +
                ' * MIT licensed\n' +
                ' *\n' +
                ' * Copyright (c) 2015 Hybrid Publishing Consortium\n' +
                ' * Libraries used: \n' +
                ' * Copyright (c) 2010-2015 Google, Inc. http://angularjs.org\n' +
                ' * Copyright (c) 2011-2015 Twitter, Inc. http://getbootstrap.com\n' +
                ' * Copyright 2014 jQuery Foundation,  http://jquery.com/\n' +
                ' */'
        },

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

        uglify: {
            options: {
                banner: '<%= meta.banner %>\n',
                compress: true,
                sourceMap: true,
                mangle: false
            },
            myTarget: {
                files: {
                    'dist/js/all.min.js': ['js/bower.js','js/consortium-viewer.js']
                }
            }
        },
        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'dist/css/all.min.css': ['css/bower.css', 'css/main.css']
                }
            }
        },
        jshint: {
            options: {
                curly: false,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                undef: true,
                eqnull: true,
                browser: true,
                expr: true,
                globals: {
                    head: false,
                    module: false,
                    console: true,
                    unescape: false,
                    define: false,
                    exports: false,
                    angular: true
                }
            },
            files: [ 'Gruntfile.js', 'js/consortium-viewer.js' ]
        },

        gitfetch: {
            task: {
              options: {
                all: true
              }
            }
        },

        gitreset: {
            task: {
                options: {
                    mode: 'hard',
                    commit: 'origin/master'
                }
            }
        },

        connect: {
            server: {
                options: {
                    port: port,
                    base: './dist',
                    livereload: true,
                    open: true
                }
            }
        },

        watch: {
            options: {
                livereload: true
            },
            js: {
                files: [ 'Gruntfile.js', 'js/consortium-viewer.js' ],
                tasks: 'js'
            },
            html: {
                files: [ 'dist/index.html']
            },
            css: {
                files: [ 'css/main.css' ],
                tasks: 'cssmin'
            },
            json: {
                files: [ 'dist/index.json' ]
            }
        },

        validation: {
            options: {
                relaxerror: [
                    'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
                    'Bad value SCHEMA.DC for attribute rel on element link: The string schema.dc is not a registered keyword.'],
                doctype: 'HTML5',
                reset: true
                //reset: grunt.option('reset') || false,
                //stoponerror: false,
            },
            files: {
                src: [ 'dist/docs/**/*.html', '!dist/docs/_**/*.html', '!**/assets/**']
            }
        },

        "bower-install-simple": {
            prod: {
                options: {
                    production: true
                }
            }
        },

        bower: {
            dev: {
                dest: 'lib/',
                js_dest: 'lib/js/',
                css_dest: 'lib/css/',
                fonts_dest: 'lib/font/',
                options: {
                    expand: true
                }
            }
        },

        bower_concat: {
          all: {
            dest: 'js/bower.js',
            cssDest: 'css/bower.css',
            bowerOptions: {
              relative: false
            }
          }
        },

        execute: {
            options: {
                // execute node with additional arguments
                //args: ['docs/**/*.html', '!docs/_template*/*.html']
                args:['metadata.json','validation-report.json']
            },
            target: {
                src: ['createindex.js']
            }
        },

        metaparser: {
            'metadata.json': ['dist/docs/**/*.html', '!dist/docs/_template*/*.html', '!**/assets/**'],
            options: {
                required: [
                    // We omit "DC" and categories in metatags. Of course they have to exist in the document i.e. "DC.title" or "DC.identifier.URL"
                    // Beware this is case sensitive.
                    'title',
                    'creator',
                    'subject',
                    'abstract',
                    'date',
                    'type',
                    'format',
                    'language',
                    'uRL',
                    'rights'
                ]
            }
        }

    });

    grunt.event.on('watch', function(action, filepath, target) {
        grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
    });

    // Dependencies
    grunt.loadNpmTasks( 'grunt-contrib-qunit' );
    grunt.loadNpmTasks( 'grunt-contrib-jshint' );
    grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
    grunt.loadNpmTasks( 'grunt-contrib-uglify' );
    grunt.loadNpmTasks( 'grunt-contrib-watch' );
    grunt.loadNpmTasks( 'grunt-bower-install-simple' );

    grunt.loadNpmTasks( 'grunt-contrib-connect' );
    grunt.loadNpmTasks( 'grunt-autoprefixer' );
    grunt.loadNpmTasks( 'grunt-bower' );
    grunt.loadNpmTasks( 'grunt-html-validation' );
    grunt.loadNpmTasks( 'grunt-bower-concat' );
    grunt.loadNpmTasks( 'grunt-execute' );
    grunt.loadNpmTasks( 'grunt-metaparser' );
    grunt.loadNpmTasks( 'grunt-git' );

    // Default task
    grunt.registerTask( 'default', [ 'build', 'index' ] );

    // Building bricks
    grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
    grunt.registerTask( 'depbuild', [ 'bower-install-simple', 'bower', 'bower_concat', 'cssmin' ] );

    // git fetch and rebase
    grunt.registerTask( 'upgrade', [ 'gitfetch', 'gitreset', 'build', 'index' ] );

    // Build
    grunt.registerTask( 'build', [ 'depbuild', 'js' ] );

    // Indexing
    grunt.registerTask( 'index', [ 'validation', 'metaparser', 'execute' ] );

    // Run tests
    grunt.registerTask( 'test', [ 'jshint', 'qunit', 'validation' ] );

    // Serve presentation locally
    grunt.registerTask( 'serve', [ 'connect', 'watch'] );
};
<commit_msg>ignoring  $ jquery on jshint<commit_after>/* global module:false */
module.exports = function(grunt) {

    var port = grunt.option('port') || 8080;
    // Project configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            banner:
                '/*!\n' +
                ' * consortium-viewer.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
                ' * https://github.com/consortium/hybrid-publishing-research\n' +
                ' * MIT licensed\n' +
                ' *\n' +
                ' * Copyright (c) 2015 Hybrid Publishing Consortium\n' +
                ' * Libraries used: \n' +
                ' * Copyright (c) 2010-2015 Google, Inc. http://angularjs.org\n' +
                ' * Copyright (c) 2011-2015 Twitter, Inc. http://getbootstrap.com\n' +
                ' * Copyright 2014 jQuery Foundation,  http://jquery.com/\n' +
                ' */'
        },

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

        uglify: {
            options: {
                banner: '<%= meta.banner %>\n',
                compress: true,
                sourceMap: true,
                mangle: false
            },
            myTarget: {
                files: {
                    'dist/js/all.min.js': ['js/bower.js','js/consortium-viewer.js']
                }
            }
        },
        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'dist/css/all.min.css': ['css/bower.css', 'css/main.css']
                }
            }
        },
        jshint: {
            options: {
                curly: false,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                undef: true,
                eqnull: true,
                browser: true,
                expr: true,
                globals: {
                    head: false,
                    module: false,
                    console: true,
                    unescape: false,
                    define: false,
                    exports: false,
                    angular: true,
                    $: false
                }
            },
            files: [ 'Gruntfile.js', 'js/consortium-viewer.js' ]
        },

        gitfetch: {
            task: {
              options: {
                all: true
              }
            }
        },

        gitreset: {
            task: {
                options: {
                    mode: 'hard',
                    commit: 'origin/master'
                }
            }
        },

        connect: {
            server: {
                options: {
                    port: port,
                    base: './dist',
                    livereload: true,
                    open: true
                }
            }
        },

        watch: {
            options: {
                livereload: true
            },
            js: {
                files: [ 'Gruntfile.js', 'js/consortium-viewer.js' ],
                tasks: 'js'
            },
            html: {
                files: [ 'dist/index.html']
            },
            css: {
                files: [ 'css/main.css' ],
                tasks: 'cssmin'
            },
            json: {
                files: [ 'dist/index.json' ]
            }
        },

        validation: {
            options: {
                relaxerror: [
                    'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
                    'Bad value SCHEMA.DC for attribute rel on element link: The string schema.dc is not a registered keyword.'],
                doctype: 'HTML5',
                reset: true
                //reset: grunt.option('reset') || false,
                //stoponerror: false,
            },
            files: {
                src: [ 'dist/docs/**/*.html', '!dist/docs/_**/*.html', '!**/assets/**']
            }
        },

        "bower-install-simple": {
            prod: {
                options: {
                    production: true
                }
            }
        },

        bower: {
            dev: {
                dest: 'lib/',
                js_dest: 'lib/js/',
                css_dest: 'lib/css/',
                fonts_dest: 'lib/font/',
                options: {
                    expand: true
                }
            }
        },

        bower_concat: {
          all: {
            dest: 'js/bower.js',
            cssDest: 'css/bower.css',
            bowerOptions: {
              relative: false
            }
          }
        },

        execute: {
            options: {
                // execute node with additional arguments
                //args: ['docs/**/*.html', '!docs/_template*/*.html']
                args:['metadata.json','validation-report.json']
            },
            target: {
                src: ['createindex.js']
            }
        },

        metaparser: {
            'metadata.json': ['dist/docs/**/*.html', '!dist/docs/_template*/*.html', '!**/assets/**'],
            options: {
                required: [
                    // We omit "DC" and categories in metatags. Of course they have to exist in the document i.e. "DC.title" or "DC.identifier.URL"
                    // Beware this is case sensitive.
                    'title',
                    'creator',
                    'subject',
                    'abstract',
                    'date',
                    'type',
                    'format',
                    'language',
                    'uRL',
                    'rights'
                ]
            }
        }

    });

    grunt.event.on('watch', function(action, filepath, target) {
        grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
    });

    // Dependencies
    grunt.loadNpmTasks( 'grunt-contrib-qunit' );
    grunt.loadNpmTasks( 'grunt-contrib-jshint' );
    grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
    grunt.loadNpmTasks( 'grunt-contrib-uglify' );
    grunt.loadNpmTasks( 'grunt-contrib-watch' );
    grunt.loadNpmTasks( 'grunt-bower-install-simple' );

    grunt.loadNpmTasks( 'grunt-contrib-connect' );
    grunt.loadNpmTasks( 'grunt-autoprefixer' );
    grunt.loadNpmTasks( 'grunt-bower' );
    grunt.loadNpmTasks( 'grunt-html-validation' );
    grunt.loadNpmTasks( 'grunt-bower-concat' );
    grunt.loadNpmTasks( 'grunt-execute' );
    grunt.loadNpmTasks( 'grunt-metaparser' );
    grunt.loadNpmTasks( 'grunt-git' );

    // Default task
    grunt.registerTask( 'default', [ 'build', 'index' ] );

    // Building bricks
    grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
    grunt.registerTask( 'depbuild', [ 'bower-install-simple', 'bower', 'bower_concat', 'cssmin' ] );

    // git fetch and rebase
    grunt.registerTask( 'upgrade', [ 'gitfetch', 'gitreset', 'build', 'index' ] );

    // Build
    grunt.registerTask( 'build', [ 'depbuild', 'js' ] );

    // Indexing
    grunt.registerTask( 'index', [ 'validation', 'metaparser', 'execute' ] );

    // Run tests
    grunt.registerTask( 'test', [ 'jshint', 'qunit', 'validation' ] );

    // Serve presentation locally
    grunt.registerTask( 'serve', [ 'connect', 'watch'] );
};
<|endoftext|>