<commit_before>// Generated on 2014-02-26 using generator-angular 0.7.1

// # 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"
/* global module: false */
/* global process: false */
/* global require: false */
module.exports = function (grunt) {
	"use strict";
	var nowAsString = grunt.template.today("yyyymmddHHMMss");

	function loadNpmTasks() {
		// Load grunt tasks automatically
		require("load-grunt-tasks")(grunt);
		// Time how long tasks take. Can help when optimizing build times
		require("time-grunt")(grunt);

		grunt.loadNpmTasks("grunt-html2js");
		grunt.loadNpmTasks("grunt-targethtml");
		grunt.loadNpmTasks("grunt-html-angular-validate");
		grunt.loadNpmTasks("grunt-file-blocks");
		grunt.loadNpmTasks("grunt-replace");
		grunt.loadNpmTasks("grunt-flow-type-check");
		grunt.loadNpmTasks("grunt-exec");
		grunt.loadNpmTasks("grunt-githash");
	}
	function initConfig() {
		function getValidateTasks(allTasks) {
			if (process.env.SEDELAYEDLIST_FAST === "true") {
				return [];
			}
			if (process.env.SEDELAYEDLIST_W3C_LOCAL_URL && allTasks) {
				return [
					"jshint",
					"karma:unit",
					"htmlangular:index",
					"htmlangular:continuous",
					"flow:app"
				];
			} else {
				return [
					"jshint",
					"karma:unit",
					"flow:app"
				];
			}
		}
		grunt.initConfig({
			// Project settings
			yeoman: {
				// configurable paths
				app: require("./bower.json").appPath || "src",
				dist: "dist"
			},
			files: {
				scripts: "<%= yeoman.app %>/**/*.js",
				unittests: "test/spec/**/*.js",
				templates: "<%= yeoman.app %>/**/*.html"
			},

			// Watches files for changes and runs tasks based on the changed files
			watch: {
				js: {
					files: ["<%= files.scripts %>"],
					tasks: ["newer:jshint:all", "karma:continuous", "flow:app"],
					options: {
						event: ["changed", "added", "deleted"],
						livereload: true
					}
				},
				templates: {
					files: ["<%= files.templates %>"],
					tasks: ["newer:htmlangular:continuous"],
					options: {
						event: ["changed", "added", "deleted"],
						livereload: true
					}
				},
				jsUnitTest: {
					files: ["<%= files.unittests %>"],
					tasks: ["newer:jshint:test", "karma:continuous"],
					options: {
						event: ["changed", "added", "deleted"]
					}
				},
				gruntfile: {
					files: ["Gruntfile.js"],
					tasks: ["jshint:all", "karma:continuous"],
					options: {
						event: ["changed", "added", "deleted"]
					}
				}
			},

			// Make sure code styles are up to par and there are no obvious mistakes
			jshint: {
				options: {
					jshintrc: ".jshintrc",
					reporter: require("jshint-stylish"),
					globals: {
						jQuery: true
					}
				},
				all: [
					"Gruntfile.js",
					"<%= files.scripts %>"
				],
				test: {
					options: {
						jshintrc: "test/.jshintrc"
					},
					src: ["<%= files.unittests %>"]
				}
			},
			// Empties folders to start fresh
			clean: {
				dist: {
					files: [{
						dot: true,
						src: [
							".tmp",
							"<%= yeoman.dist %>/*",
							"!<%= yeoman.dist %>/.git*"
						]
					}]
				}
			},

			replace: {
				flowReportError: {
					options : {
						patterns: [
							{
								match: /^\s+return done\(false\);$/m,
								replacement: "return done('error');"
							},
							{
								match: /^\s+async.eachSeries\(this\.filesSrc, runFlow, callback\);$/m,
								replacement: "async.eachSeries(this.filesSrc, runFlow, function(error){callback(!error);});"
							}
						]
					},
					files: [
						{
							expand: true,
							src: ["<%= yeoman.app %>/../node_modules/grunt-flow-type-check/tasks/flow.js"/*, "<%= yeoman.app %>/bower_components/angular-carousel/dist/angular-carousel.min.js"*/]
						}
					]
				},
				versionInfo: {
					options: {
						patterns: [
							{
								match: new RegExp("return \\{version: \"_VERSION_\", buildDate: \"_BUILD_DATE_\", "+
									"buildDateAsString: \"_BUILD_DATE_AS_STRING_\", commit: \"_COMMIT_\"\\};", "mg"),
								replacement: "\treturn {\n\t\tversion: \""+"<%= githash.main.tag %>"+
									"\",\n\t\tBUILD_NUMBER: \""+ ("0000000"+process.env.BUILD_NUMBER).substr(-7)+
									"\",\n\t\tbuildDate: \""+ nowAsString+
									"\",\n\t\tbranch: \""+ "<%= githash.main.branch %>"+
									"\",\n\t\tcommit: \""+"<%= githash.main.hash %>"+"\"\n\t};"
							}

						]
					},
					files: [
						{
							expand: true,
							src: ["<%= yeoman.dist %>/index.html"]
						}
					]
				}
			},

			// Copies remaining files to places other tasks can use
			copy: {
				dist: {
					files: [{
						expand: true,
						dot: true,
						cwd: "<%= yeoman.app %>",
						dest: "<%= yeoman.dist %>",
						src: [
							"src/**/*.html",
							"src/**/*.js"
						]
					}]

				}
			},

			// Run some tasks in parallel to speed up the build process
			concurrent: {
				validate: getValidateTasks(true),
				jsvalidate: getValidateTasks(false)
			},
			// Test settings
			karma: {
				continuous: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: ["PhantomJS"]
				},
				debug: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: [],
					port: 60081
				},
				unit: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: getBrowsersForTest(),
					/* coverage */
					preprocessors: {
						"<%= files.scripts %>": ["coverage"]
					},
					// add the coverage plugin
					plugins: [ "karma-jasmine", "karma-firefox-launcher", "karma-chrome-launcher", "karma-phantomjs-launcher", "karma-coverage", "karma-junit-reporter"],
					// add coverage to reporters
					reporters: ["dots", "coverage", "junit"],
					// tell karma how you want the coverage results
					coverageReporter: {
						reporters : [
							{ type : "html", dir : "coverage/" },
							{ type : "cobertura", file: "coverage.xml" }
						]
					},
					junitReporter : {
						outputFile: "target/test-results.xml",
						suite: ""
					}
					/* /coverage */

				}
			},
			htmlangular: {
				options: {
					angular: false,
					wrapping: {
						"tr": "
{0}
"
					},
					w3clocal: process.env.SEDELAYEDLIST_W3C_LOCAL_URL?process.env.SEDELAYEDLIST_W3C_LOCAL_URL:null,
					//i'm not sure why in local instalation these errors exists:
					relaxerror: process.env.SEDELAYEDLIST_W3C_LOCAL_URL?[
						"The date input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.",

						"The Content-Type was text/html. Using the HTML parser.",
						"Using the schema for HTML5 + SVG 1.1 + MathML 3.0 + RDFa Lite 1.1.",
						"Attribute data-ng-attr-height not allowed on element rect at this point.",
						"Attribute data-ng-attr-y not allowed on element rect at this point."
					]:[]
				},
				continuous: {
					options: {
						tmplext: ".html"
					},
					files: {
						src: ["<%= files.templates %>"]
					}
				},
				selected: {
					options: {
						wrapping: {
							"tr": "
{0}
"
						},
						tmplext: ".html"
					},
					files: {
						src: process.env.file
					}
				}
			},
			flow: {
				app: {
					options: {
						"lib": "flow/",
						"retries": 25
					},
					files: {
						src: ["<%= files.scripts %>"]
					}
				}
			},
			exec: {
				stopFlow: "node_modules/grunt-flow-type-check/bin/"+process.platform+"/flow stop"
			},
			githash: {
				options: {},
				main: {}
			}
		});

	}
	function registerTasks() {
		grunt.registerTask("test", [
			"prepare",
			"concurrent:validate",
			"exec:stopFlow"
		]);

		grunt.registerTask("prepare", [
			"githash",
			"clean:dist",
			"replace:flowReportError"
		]);

		//update buildnotminified as described in comment
		grunt.registerTask("build", [
			// "prepare",
			"test",
			"concurrent:dist",
			"replace:versionInfo"
		]);

		//same as build, but useminPrepare:notminifiedjs replaces useminPrepare:minifiedjs and uglify is removed
		grunt.registerTask("buildnotminified", [
			// "prepare",
			"test",
			"concurrent:dist",
			"replace:versionInfo"
		]);
		grunt.registerTask("default", [
			"test"
			// "protractor:dist"
			// "build"
		]);

		grunt.registerTask("kd", ["karma:debug"]);
	}

	function getBrowsersForTest() {
		if (process.env.SEDELAYEDLIST_BROWSERS_FOR_TEST) {
			return process.env.SEDELAYEDLIST_BROWSERS_FOR_TEST.split(",");
		} else {
			return ["Chrome", "Firefox", "PhantomJS"];
		}
	}

	loadNpmTasks();
	initConfig();
	registerTasks();
};
<commit_msg>Fixed build script<commit_after>// Generated on 2014-02-26 using generator-angular 0.7.1

// # 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"
/* global module: false */
/* global process: false */
/* global require: false */
module.exports = function (grunt) {
	"use strict";
	var nowAsString = grunt.template.today("yyyymmddHHMMss");

	function loadNpmTasks() {
		// Load grunt tasks automatically
		require("load-grunt-tasks")(grunt);
		// Time how long tasks take. Can help when optimizing build times
		require("time-grunt")(grunt);

		grunt.loadNpmTasks("grunt-html2js");
		grunt.loadNpmTasks("grunt-targethtml");
		grunt.loadNpmTasks("grunt-html-angular-validate");
		grunt.loadNpmTasks("grunt-file-blocks");
		grunt.loadNpmTasks("grunt-replace");
		grunt.loadNpmTasks("grunt-flow-type-check");
		grunt.loadNpmTasks("grunt-exec");
		grunt.loadNpmTasks("grunt-githash");
	}
	function initConfig() {
		function getValidateTasks(allTasks) {
			if (process.env.SEDELAYEDLIST_FAST === "true") {
				return [];
			}
			if (process.env.SEDELAYEDLIST_W3C_LOCAL_URL && allTasks) {
				return [
					"jshint",
					"karma:unit",
					// "htmlangular:index",
					// "htmlangular:continuous",
					"flow:app"
				];
			} else {
				return [
					"jshint",
					"karma:unit",
					"flow:app"
				];
			}
		}
		grunt.initConfig({
			// Project settings
			yeoman: {
				// configurable paths
				app: require("./bower.json").appPath || "src",
				dist: "dist"
			},
			files: {
				scripts: "<%= yeoman.app %>/**/*.js",
				unittests: "test/spec/**/*.js",
				templates: "<%= yeoman.app %>/**/*.html"
			},

			// Watches files for changes and runs tasks based on the changed files
			watch: {
				js: {
					files: ["<%= files.scripts %>"],
					tasks: ["newer:jshint:all", "karma:continuous", "flow:app"],
					options: {
						event: ["changed", "added", "deleted"],
						livereload: true
					}
				},
				templates: {
					files: ["<%= files.templates %>"],
					tasks: ["newer:htmlangular:continuous"],
					options: {
						event: ["changed", "added", "deleted"],
						livereload: true
					}
				},
				jsUnitTest: {
					files: ["<%= files.unittests %>"],
					tasks: ["newer:jshint:test", "karma:continuous"],
					options: {
						event: ["changed", "added", "deleted"]
					}
				},
				gruntfile: {
					files: ["Gruntfile.js"],
					tasks: ["jshint:all", "karma:continuous"],
					options: {
						event: ["changed", "added", "deleted"]
					}
				}
			},

			// Make sure code styles are up to par and there are no obvious mistakes
			jshint: {
				options: {
					jshintrc: ".jshintrc",
					reporter: require("jshint-stylish"),
					globals: {
						jQuery: true
					}
				},
				all: [
					"Gruntfile.js",
					"<%= files.scripts %>"
				],
				test: {
					options: {
						jshintrc: "test/.jshintrc"
					},
					src: ["<%= files.unittests %>"]
				}
			},
			// Empties folders to start fresh
			clean: {
				dist: {
					files: [{
						dot: true,
						src: [
							".tmp",
							"<%= yeoman.dist %>/*",
							"!<%= yeoman.dist %>/.git*"
						]
					}]
				}
			},

			replace: {
				flowReportError: {
					options : {
						patterns: [
							{
								match: /^\s+return done\(false\);$/m,
								replacement: "return done('error');"
							},
							{
								match: /^\s+async.eachSeries\(this\.filesSrc, runFlow, callback\);$/m,
								replacement: "async.eachSeries(this.filesSrc, runFlow, function(error){callback(!error);});"
							}
						]
					},
					files: [
						{
							expand: true,
							src: ["<%= yeoman.app %>/../node_modules/grunt-flow-type-check/tasks/flow.js"/*, "<%= yeoman.app %>/bower_components/angular-carousel/dist/angular-carousel.min.js"*/]
						}
					]
				},
				versionInfo: {
					options: {
						patterns: [
							{
								match: new RegExp("return \\{version: \"_VERSION_\", buildDate: \"_BUILD_DATE_\", "+
									"buildDateAsString: \"_BUILD_DATE_AS_STRING_\", commit: \"_COMMIT_\"\\};", "mg"),
								replacement: "\treturn {\n\t\tversion: \""+"<%= githash.main.tag %>"+
									"\",\n\t\tBUILD_NUMBER: \""+ ("0000000"+process.env.BUILD_NUMBER).substr(-7)+
									"\",\n\t\tbuildDate: \""+ nowAsString+
									"\",\n\t\tbranch: \""+ "<%= githash.main.branch %>"+
									"\",\n\t\tcommit: \""+"<%= githash.main.hash %>"+"\"\n\t};"
							}

						]
					},
					files: [
						{
							expand: true,
							src: ["<%= yeoman.dist %>/index.html"]
						}
					]
				}
			},

			// Copies remaining files to places other tasks can use
			copy: {
				dist: {
					files: [{
						expand: true,
						dot: true,
						cwd: "<%= yeoman.app %>",
						dest: "<%= yeoman.dist %>",
						src: [
							"src/**/*.html",
							"src/**/*.js"
						]
					}]

				}
			},

			// Run some tasks in parallel to speed up the build process
			concurrent: {
				validate: getValidateTasks(true),
				jsvalidate: getValidateTasks(false)
			},
			// Test settings
			karma: {
				continuous: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: ["PhantomJS"]
				},
				debug: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: [],
					port: 60081
				},
				unit: {
					configFile: "karma.conf.js",
					singleRun: true,
					browsers: getBrowsersForTest(),
					/* coverage */
					preprocessors: {
						"<%= files.scripts %>": ["coverage"]
					},
					// add the coverage plugin
					plugins: [ "karma-jasmine", "karma-firefox-launcher", "karma-chrome-launcher", "karma-phantomjs-launcher", "karma-coverage", "karma-junit-reporter"],
					// add coverage to reporters
					reporters: ["dots", "coverage", "junit"],
					// tell karma how you want the coverage results
					coverageReporter: {
						reporters : [
							{ type : "html", dir : "coverage/" },
							{ type : "cobertura", file: "coverage.xml" }
						]
					},
					junitReporter : {
						outputFile: "target/test-results.xml",
						suite: ""
					}
					/* /coverage */

				}
			},
			htmlangular: {
				options: {
					angular: false,
					wrapping: {
						"tr": "
{0}
"
					},
					w3clocal: process.env.SEDELAYEDLIST_W3C_LOCAL_URL?process.env.SEDELAYEDLIST_W3C_LOCAL_URL:null,
					//i'm not sure why in local instalation these errors exists:
					relaxerror: process.env.SEDELAYEDLIST_W3C_LOCAL_URL?[
						"The date input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.",

						"The Content-Type was text/html. Using the HTML parser.",
						"Using the schema for HTML5 + SVG 1.1 + MathML 3.0 + RDFa Lite 1.1.",
						"Attribute data-ng-attr-height not allowed on element rect at this point.",
						"Attribute data-ng-attr-y not allowed on element rect at this point."
					]:[]
				},
				continuous: {
					options: {
						tmplext: ".html"
					},
					files: {
						src: ["<%= files.templates %>"]
					}
				},
				selected: {
					options: {
						wrapping: {
							"tr": "
{0}
"
						},
						tmplext: ".html"
					},
					files: {
						src: process.env.file
					}
				}
			},
			flow: {
				app: {
					options: {
						"lib": "flow/",
						"retries": 25
					},
					files: {
						src: ["<%= files.scripts %>"]
					}
				}
			},
			exec: {
				stopFlow: "node_modules/grunt-flow-type-check/bin/"+process.platform+"/flow stop"
			},
			githash: {
				options: {},
				main: {}
			}
		});

	}
	function registerTasks() {
		grunt.registerTask("test", [
			"prepare",
			"concurrent:validate",
			"exec:stopFlow"
		]);

		grunt.registerTask("prepare", [
			"githash",
			"clean:dist",
			"replace:flowReportError"
		]);

		//update buildnotminified as described in comment
		grunt.registerTask("build", [
			// "prepare",
			"test",
			// "concurrent:dist",
			"replace:versionInfo"
		]);

		//same as build, but useminPrepare:notminifiedjs replaces useminPrepare:minifiedjs and uglify is removed
		grunt.registerTask("buildnotminified", [
			// "prepare",
			"test",
			"concurrent:dist",
			"replace:versionInfo"
		]);
		grunt.registerTask("default", [
			"test"
			// "protractor:dist"
			// "build"
		]);

		grunt.registerTask("kd", ["karma:debug"]);
	}

	function getBrowsersForTest() {
		if (process.env.SEDELAYEDLIST_BROWSERS_FOR_TEST) {
			return process.env.SEDELAYEDLIST_BROWSERS_FOR_TEST.split(",");
		} else {
			return ["Chrome", "Firefox", "PhantomJS"];
		}
	}

	loadNpmTasks();
	initConfig();
	registerTasks();
};
<|endoftext|>


<commit_before>$(document).ready(function(){
  var user1, user2, currentSession, startTime, endTime, currentInterval,pairingDurationMs, timer;
  var sessions = [];
  var totalTimeWorking = 0;

  $('button.duration-button').on('click', function(event){
    event.preventDefault();
    if($('input.duration').val() !== "" ){
      currentInterval = parseInt($('input.duration').val());
      pairingDurationMs = currentInterval * 60000;
    } else {
      alert("Please Enter A Real Number");
    }
  });

  $('button.start-pairing').on('click', function(){
    startPairing();
  });

  $('.pause-pairing').on('click', function(){
    if(timer){
      stopTimer();
    } else {
      console.log("unpause");
      startTimerCount();
    }
  });

  $('.exit-pairing').on('click', function(){
    console.log('exit');
    if(currentSession.timeWorked === 0){
      endSession();
    }
    var activeTime = 0;
    var inActiveTime = 0;
    sessions.forEach(function(pairSession){
      activeTime += pairSession.timeWorked;
      inActiveTime += pairSession.timePaused;
    })
    stopTimer();
    sessions.push(new TotalSessionInfo(activeTime, inActiveTime));
    console.log(sessions);
  })

  function PairingSession(user1, user2){
    this.drive = user1;
    this.navigate = user2;
    this.timeWorked = 0;
    this.timePaused = 0;
  }

  function TotalSessionInfo(activeTime, pauseTime){
    this.totalTime = pauseTime + activeTime;
    this.activeTime = activeTime;
    this.pauseTime = pauseTime;
    this.user1 = user1;
    this.user2 = user2;
  }

  function startPairing(){
    var date = new Date();
    startTime = date.getTime();
    currentSession = new PairingSession(user1, user2);
    console.log(currentSession);
    sessions.push(currentSession);
    console.log(sessions);
    startTimerCount();
  }

  function startTimerCount(){
    timer = setInterval(function(){
      totalTimeWorking ++;
      console.log(totalTimeWorking)
      currentInterval --;
      updateTimerCountdown();
      checkDuration();
    }, 60000);
    console.log(timer);
  }

  function stopTimer(){
    console.log("timer", timer);
    clearInterval(timer);
    timer = null;
  }

  function checkDuration(){
    console.log(currentInterval);
    if(currentInterval === 0){
      endSession();
      alert('Switch it ^');
      startPairing();
    }
  }

  function endSession(){
    var date = new Date();
    endTime = date.getTime();
    currentInterval = pairingDurationMs / 60000;
    currentSession.timeWorked = currentInterval;
    console.log(startTime);
    console.log(endTime);
    currentSession.timePaused =  (endTime - startTime - totalTimeWorking) * 60000;
    if(currentSession.timePaused == null){
      currentSession.timePaused = 0;
    }
    totalTimeWorking = 0;
  }

  function updateTimerCountdown(){
    $('.countdown').val(currentInterval);
  }
});

<commit_msg>Fix Update Time to Screen<commit_after>$(document).ready(function(){
  var user1, user2, currentSession, startTime, endTime, currentInterval,pairingDurationMs, timer;
  var sessions = [];
  var totalTimeWorking = 0;

  $('button.duration-button').on('click', function(event){
    event.preventDefault();
    if($('input.duration').val() !== "" ){
      currentInterval = parseInt($('input.duration').val());
      pairingDurationMs = currentInterval * 60000;
    } else {
      alert("Please Enter A Real Number");
    }
  });

  $('button.start-pairing').on('click', function(){
    startPairing();
  });

  $('.pause-pairing').on('click', function(){
    if(timer){
      stopTimer();
    } else {
      console.log("unpause");
      startTimerCount();
    }
  });

  $('.exit-pairing').on('click', function(){
    console.log('exit');
    if(currentSession.timeWorked === 0){
      endSession();
    }
    var activeTime = 0;
    var inActiveTime = 0;
    sessions.forEach(function(pairSession){
      activeTime += pairSession.timeWorked;
      inActiveTime += pairSession.timePaused;
    })
    stopTimer();
    sessions.push(new TotalSessionInfo(activeTime, inActiveTime));
    console.log(sessions);
  })

  function PairingSession(user1, user2){
    this.drive = user1;
    this.navigate = user2;
    this.timeWorked = 0;
    this.timePaused = 0;
  }

  function TotalSessionInfo(activeTime, pauseTime){
    this.totalTime = pauseTime + activeTime;
    this.activeTime = activeTime;
    this.pauseTime = pauseTime;
    this.user1 = user1;
    this.user2 = user2;
  }

  function startPairing(){
    var date = new Date();
    startTime = date.getTime();
    currentSession = new PairingSession(user1, user2);
    console.log(currentSession);
    sessions.push(currentSession);
    console.log(sessions);
    startTimerCount();
    updateTimerCountdown();
  }

  function startTimerCount(){
    timer = setInterval(function(){
      totalTimeWorking ++;
      console.log(totalTimeWorking)
      currentInterval --;
      updateTimerCountdown();
      checkDuration();
    }, 60000);
    console.log(timer);
  }

  function stopTimer(){
    console.log("timer", timer);
    clearInterval(timer);
    timer = null;
  }

  function checkDuration(){
    console.log(currentInterval);
    if(currentInterval === 0){
      endSession();
      alert('Switch it ^');
      startPairing();
    }
  }

  function endSession(){
    var date = new Date();
    endTime = date.getTime();
    currentInterval = pairingDurationMs / 60000;
    currentSession.timeWorked = currentInterval;
    currentSession.timePaused =  (endTime - startTime - (totalTimeWorking * 60000)) / 60000;
    if(currentSession.timePaused == null || currentSession.timePaused < .1){
      currentSession.timePaused = 0;
    }
    totalTimeWorking = 0;
  }

  function updateTimerCountdown(){
    $('.countdown').html(currentInterval);
  }
});

<|endoftext|>


<commit_before>module.exports = function (grunt) {
	// time
	require('time-grunt')(grunt);

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

		sass: {

			options: {
				// If you can't get source maps to work, run the following command in your terminal:
				// $ sass scss/foundation.scss:css/foundation.css --sourcemap
				// (see this link for details: http://thesassway.com/intermediate/using-source-maps-with-sass )
				sourceMap: true
			},

			dist: {
				options: {
					outputStyle: 'compressed'
				},
				files: {
					'assets/stylesheets/foundation.css': 'assets/scss/foundation.scss'
				}
			}

		},

		copy: {

			scripts: {
				expand: true,
				cwd: 'assets/components/foundation/js/vendor/',
				src: '**',
				flatten: 'true',
				dest: 'assets/javascript/vendor/'
			},

			iconfonts: {
				expand: true,
				cwd: 'assets/components/fontawesome/fonts',
				src: ['**'],
				dest: 'assets/fonts/'
			}

		},

		'string-replace': {

			fontawesome: {
				files: {
					'assets/fontawesome/scss/_variables.scss': 'assets/fontawesome/scss/_variables.scss'
				},

				options: {
					replacements: [
						{
							pattern: '../fonts',
							replacement: '../assets/fonts'
						}
					]
				}

			}

		},

		concat: {

			options: {
				separator: ';'
			},

			dist: {

				src: [

					// Foundation core
					'assets/components/foundation/js/foundation/foundation.js',

					// Pick the componenets you need in your project
					'assets/components/foundation/js/foundation/foundation.abide.js',
					'assets/components/foundation/js/foundation/foundation.accordion.js',
					'assets/components/foundation/js/foundation/foundation.alert.js',
					'assets/components/foundation/js/foundation/foundation.clearing.js',
					'assets/components/foundation/js/foundation/foundation.dropdown.js',
					'assets/components/foundation/js/foundation/foundation.equalizer.js',
					'assets/components/foundation/js/foundation/foundation.interchange.js',
					'assets/components/foundation/js/foundation/foundation.joyride.js',
					'assets/components/foundation/js/foundation/foundation.magellan.js',
					'assets/components/foundation/js/foundation/foundation.offcanvas.js',
					'assets/components/foundation/js/foundation/foundation.orbit.js',
					'assets/components/foundation/js/foundation/foundation.reveal.js',
					'assets/components/foundation/js/foundation/foundation.slider.js',
					'assets/components/foundation/js/foundation/foundation.tab.js',
					'assets/components/foundation/js/foundation/foundation.tooltip.js',
					'assets/components/foundation/js/foundation/foundation.topbar.js',

					// Include your own custom scripts (located in the custom folder)
					'assets/javascript/custom/*.js'

				],

				// Finally, concatinate all the files above into one single file
				dest: 'assets/javascript/foundation.js'

			}

		},

		uglify: {

			dist: {
				files: {
					// Shrink the file size by removing spaces
					'assets/javascript/foundation.js': ['assets/javascript/foundation.js']
				}
			}

		},

		watch: {
			grunt: {files: ['Gruntfile.js']},

			sass: {
				files: 'assets/scss/**/*.scss',
				tasks: ['sass'],
				options: {
					livereload: true
				}
			},

			js: {
				files: 'assets/javascript/custom/**/*.js',
				tasks: ['concat', 'uglify'],
				options: {
					livereload: true
				}
			},

			all: {
				files: '**/*.php',
				options: {
					livereload: true
				}
			}

		}
	});

	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-string-replace');

	grunt.registerTask('build', ['copy', 'string-replace:fontawesome', 'sass', 'concat', 'uglify']);
	grunt.registerTask('default', ['watch']);
};<commit_msg>don't load all foundation js<commit_after>module.exports = function (grunt) {
	// time
	require('time-grunt')(grunt);

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

		sass: {

			options: {
				// If you can't get source maps to work, run the following command in your terminal:
				// $ sass scss/foundation.scss:css/foundation.css --sourcemap
				// (see this link for details: http://thesassway.com/intermediate/using-source-maps-with-sass )
				sourceMap: true
			},

			dist: {
				options: {
					outputStyle: 'compressed'
				},
				files: {
					'assets/stylesheets/foundation.css': 'assets/scss/foundation.scss'
				}
			}

		},

		copy: {

			scripts: {
				expand: true,
				cwd: 'assets/components/foundation/js/vendor/',
				src: '**',
				flatten: 'true',
				dest: 'assets/javascript/vendor/'
			},

			iconfonts: {
				expand: true,
				cwd: 'assets/components/fontawesome/fonts',
				src: ['**'],
				dest: 'assets/fonts/'
			}

		},

		'string-replace': {

			fontawesome: {
				files: {
					'assets/fontawesome/scss/_variables.scss': 'assets/fontawesome/scss/_variables.scss'
				},

				options: {
					replacements: [
						{
							pattern: '../fonts',
							replacement: '../assets/fonts'
						}
					]
				}

			}

		},

		concat: {

			options: {
				separator: ';'
			},

			dist: {

				src: [

					// Foundation core
					'assets/components/foundation/js/foundation/foundation.js',

					// Pick the componenets you need in your project
					//'assets/components/foundation/js/foundation/foundation.abide.js',
					//'assets/components/foundation/js/foundation/foundation.accordion.js',
					//'assets/components/foundation/js/foundation/foundation.alert.js',
					'assets/components/foundation/js/foundation/foundation.clearing.js',
					'assets/components/foundation/js/foundation/foundation.dropdown.js',
					'assets/components/foundation/js/foundation/foundation.equalizer.js',
					//'assets/components/foundation/js/foundation/foundation.interchange.js',
					//'assets/components/foundation/js/foundation/foundation.joyride.js',
					//'assets/components/foundation/js/foundation/foundation.magellan.js',
					'assets/components/foundation/js/foundation/foundation.offcanvas.js',
					//'assets/components/foundation/js/foundation/foundation.orbit.js',
					//'assets/components/foundation/js/foundation/foundation.reveal.js',
					//'assets/components/foundation/js/foundation/foundation.slider.js',
					//'assets/components/foundation/js/foundation/foundation.tab.js',
					//'assets/components/foundation/js/foundation/foundation.tooltip.js',
					'assets/components/foundation/js/foundation/foundation.topbar.js',

					// Include your own custom scripts (located in the custom folder)
					'assets/javascript/custom/*.js'

				],

				// Finally, concatinate all the files above into one single file
				dest: 'assets/javascript/foundation.js'

			}

		},

		uglify: {

			dist: {
				files: {
					// Shrink the file size by removing spaces
					'assets/javascript/foundation.js': ['assets/javascript/foundation.js']
				}
			}

		},

		watch: {
			grunt: {files: ['Gruntfile.js']},

			sass: {
				files: 'assets/scss/**/*.scss',
				tasks: ['sass'],
				options: {
					livereload: true
				}
			},

			js: {
				files: 'assets/javascript/custom/**/*.js',
				tasks: ['concat', 'uglify'],
				options: {
					livereload: true
				}
			},

			all: {
				files: '**/*.php',
				options: {
					livereload: true
				}
			}

		}
	});

	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-string-replace');

	grunt.registerTask('build', ['copy', 'string-replace:fontawesome', 'sass', 'concat', 'uglify']);
	grunt.registerTask('default', ['watch']);
};<|endoftext|>


<commit_before>// Copyright (c) 2015 Uber Technologies, Inc.

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;

var emptyBuffer = Buffer(0);

// TODO: provide streams for arg2/3

function TChannelIncomingRequest(id, options) {
    if (!(this instanceof TChannelIncomingRequest)) {
        return new TChannelIncomingRequest(id, options);
    }
    options = options || {};
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.ttl = options.ttl || 0;
    self.tracing = options.tracing || null;
    self.service = options.service || '';
    self.remoteAddr = null;
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
}

inherits(TChannelIncomingRequest, EventEmitter);

function TChannelIncomingResponse(id, options) {
    if (!(this instanceof TChannelIncomingResponse)) {
        return new TChannelIncomingResponse(id, options);
    }
    options = options || {};
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.code = options.code || 0;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
    self.ok = self.code === 0; // TODO: probably okay, but a bit jank
}

inherits(TChannelIncomingResponse, EventEmitter);

function TChannelOutgoingRequest(id, options) {
    if (!(this instanceof TChannelOutgoingRequest)) {
        return new TChannelOutgoingRequest(id, options);
    }
    options = options || {};
    if (!options.sendFrame) {
        throw new Error('missing sendFrame');
    }
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.ttl = options.ttl || 0;
    self.tracing = options.tracing || null;
    self.service = options.service || '';
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.sendFrame = options.sendFrame;
    self.sent = false;
}

inherits(TChannelOutgoingRequest, EventEmitter);

TChannelOutgoingRequest.prototype.send = function send(arg1, arg2, arg3, callback) {
    var self = this;
    if (callback) self.hookupCallback(callback);
    if (self.sent) {
        throw new Error('request already sent');
    }
    self.sent = true;
    self.sendFrame.callRequest(
        arg1 ? Buffer(arg1) : null,
        arg2 ? Buffer(arg2) : null,
        arg3 ? Buffer(arg3) : null);
    self.emit('end');
    return self;
};

TChannelOutgoingRequest.prototype.hookupCallback = function hookupCallback(callback) {
    var self = this;
    self.once('error', onError);
    self.once('response', onResponse);
    function onError(err) {
        self.removeListener('response', onResponse);
        callback(err, null);
    }
    function onResponse(res) {
        self.removeListener('error', onError);
        callback(null, res);
    }
    return self;
};

function TChannelOutgoingResponse(id, options) {
    if (!(this instanceof TChannelOutgoingResponse)) {
        return new TChannelOutgoingResponse(id, options);
    }
    options = options || {};
    if (!options.sendFrame) {
        throw new Error('missing sendFrame');
    }
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.code = options.code || 0;
    self.tracing = options.tracing || null;
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.ok = true;
    self.sendFrame = options.sendFrame;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
    self.sent = false;
}

inherits(TChannelOutgoingResponse, EventEmitter);

TChannelOutgoingResponse.prototype.sendCallResponseFrame = function sendCallResponseFrame(arg1, res1, res2) {
    var self = this;
    self.sendFrame.callResponse(arg1, res1, res2);
};

TChannelOutgoingResponse.prototype.sendErrorFrame = function sendErrorFrame(codeString, message) {
    var self = this;
    self.sendFrame.error(codeString, message);
};

TChannelOutgoingResponse.prototype.sendOk = function send(res1, res2) {
    var self = this;
    if (self.sent) {
        throw new Error('response already sent');
    }

    self.sent = true;
    self.ok = true;

    self.sendCallResponseFrame(self.arg1,
        res1 ? Buffer(res1) : null,
        res2 ? Buffer(res2) : null);
    self.emit('end');
};

TChannelOutgoingResponse.prototype.sendNotOk = function sendNotOk(res1, res2) {
    var self = this;
    if (self.sent) {
        throw new Error('response already sent');
    }

    self.sent = true;
    self.ok = false;
    self.code = 1;

    self.sendCallResponseFrame(self.arg1,
        res1 ? Buffer(res1) : null,
        res2 ? Buffer(res2) : null);
    self.emit('end');
};

module.exports.IncomingRequest = TChannelIncomingRequest;
module.exports.IncomingResponse = TChannelIncomingResponse;
module.exports.OutgoingRequest = TChannelOutgoingRequest;
module.exports.OutgoingResponse = TChannelOutgoingResponse;
<commit_msg>TChannelOutgoingRequest: add .sendCallRequestFrame<commit_after>// Copyright (c) 2015 Uber Technologies, Inc.

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

'use strict';

var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;

var emptyBuffer = Buffer(0);

// TODO: provide streams for arg2/3

function TChannelIncomingRequest(id, options) {
    if (!(this instanceof TChannelIncomingRequest)) {
        return new TChannelIncomingRequest(id, options);
    }
    options = options || {};
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.ttl = options.ttl || 0;
    self.tracing = options.tracing || null;
    self.service = options.service || '';
    self.remoteAddr = null;
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
}

inherits(TChannelIncomingRequest, EventEmitter);

function TChannelIncomingResponse(id, options) {
    if (!(this instanceof TChannelIncomingResponse)) {
        return new TChannelIncomingResponse(id, options);
    }
    options = options || {};
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.code = options.code || 0;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
    self.ok = self.code === 0; // TODO: probably okay, but a bit jank
}

inherits(TChannelIncomingResponse, EventEmitter);

function TChannelOutgoingRequest(id, options) {
    if (!(this instanceof TChannelOutgoingRequest)) {
        return new TChannelOutgoingRequest(id, options);
    }
    options = options || {};
    if (!options.sendFrame) {
        throw new Error('missing sendFrame');
    }
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.ttl = options.ttl || 0;
    self.tracing = options.tracing || null;
    self.service = options.service || '';
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.sendFrame = options.sendFrame;
    self.sent = false;
}

inherits(TChannelOutgoingRequest, EventEmitter);

TChannelOutgoingRequest.prototype.sendCallRequestFrame = function sendCallRequestFrame(arg1, arg2, arg3) {
    var self = this;
    self.sendFrame.callRequest(arg1, arg2, arg3);
};

TChannelOutgoingRequest.prototype.send = function send(arg1, arg2, arg3, callback) {
    var self = this;
    if (callback) self.hookupCallback(callback);
    if (self.sent) {
        throw new Error('request already sent');
    }
    self.sent = true;
    self.sendCallRequestFrame(
        arg1 ? Buffer(arg1) : null,
        arg2 ? Buffer(arg2) : null,
        arg3 ? Buffer(arg3) : null);
    self.emit('end');
    return self;
};

TChannelOutgoingRequest.prototype.hookupCallback = function hookupCallback(callback) {
    var self = this;
    self.once('error', onError);
    self.once('response', onResponse);
    function onError(err) {
        self.removeListener('response', onResponse);
        callback(err, null);
    }
    function onResponse(res) {
        self.removeListener('error', onError);
        callback(null, res);
    }
    return self;
};

function TChannelOutgoingResponse(id, options) {
    if (!(this instanceof TChannelOutgoingResponse)) {
        return new TChannelOutgoingResponse(id, options);
    }
    options = options || {};
    if (!options.sendFrame) {
        throw new Error('missing sendFrame');
    }
    var self = this;
    EventEmitter.call(self);
    self.id = id || 0;
    self.code = options.code || 0;
    self.tracing = options.tracing || null;
    self.headers = options.headers || {};
    self.checksumType = options.checksumType || 0;
    self.ok = true;
    self.sendFrame = options.sendFrame;
    self.arg1 = options.arg1 || emptyBuffer;
    self.arg2 = options.arg2 || emptyBuffer;
    self.arg3 = options.arg3 || emptyBuffer;
    self.sent = false;
}

inherits(TChannelOutgoingResponse, EventEmitter);

TChannelOutgoingResponse.prototype.sendCallResponseFrame = function sendCallResponseFrame(arg1, res1, res2) {
    var self = this;
    self.sendFrame.callResponse(arg1, res1, res2);
};

TChannelOutgoingResponse.prototype.sendErrorFrame = function sendErrorFrame(codeString, message) {
    var self = this;
    self.sendFrame.error(codeString, message);
};

TChannelOutgoingResponse.prototype.sendOk = function send(res1, res2) {
    var self = this;
    if (self.sent) {
        throw new Error('response already sent');
    }

    self.sent = true;
    self.ok = true;

    self.sendCallResponseFrame(self.arg1,
        res1 ? Buffer(res1) : null,
        res2 ? Buffer(res2) : null);
    self.emit('end');
};

TChannelOutgoingResponse.prototype.sendNotOk = function sendNotOk(res1, res2) {
    var self = this;
    if (self.sent) {
        throw new Error('response already sent');
    }

    self.sent = true;
    self.ok = false;
    self.code = 1;

    self.sendCallResponseFrame(self.arg1,
        res1 ? Buffer(res1) : null,
        res2 ? Buffer(res2) : null);
    self.emit('end');
};

module.exports.IncomingRequest = TChannelIncomingRequest;
module.exports.IncomingResponse = TChannelIncomingResponse;
module.exports.OutgoingRequest = TChannelOutgoingRequest;
module.exports.OutgoingResponse = TChannelOutgoingResponse;
<|endoftext|>


<commit_before>/* global module, __dirname, process, require */
const path = require('path');

module.exports = (grunt) => {
  const BANNER = [
    '/**!',
    ' * VexFlow <%= pkg.version %> built on <%= grunt.template.today("yyyy-mm-dd") %>.',
    ' * Copyright (c) 2010 Mohit Muthanna Cheppudira <mohit@muthanna.com>',
    ' *',
    ' * http://www.vexflow.com  http://github.com/0xfe/vexflow',
    ' */',
  ].join('\n');
  const BASE_DIR = __dirname;
  const BUILD_DIR = path.join(BASE_DIR, 'build');
  const RELEASE_DIR = path.join(BASE_DIR, 'releases');
  const MODULE_ENTRY = path.join(BASE_DIR, 'src/index.js');
  const TARGET_RAW = 'vexflow-debug.js';
  const TARGET_MIN = 'vexflow-min.js';

  // Used for eslint and docco
  const SOURCES = ['src/*.js', '!src/header.js'];

  // Take all test files in 'tests/' and build TARGET_TESTS
  const TARGET_TESTS = path.join(BUILD_DIR, 'vexflow-tests.js');
  const TEST_SOURCES = ['tests/vexflow_test_helpers.js', 'tests/mocks.js', 'tests/*_tests.js', 'tests/run.js'];

  function webpackConfig(target, preset, mode) {
    return {
      mode,
      entry: MODULE_ENTRY,
      output: {
        path: BUILD_DIR,
        filename: target,
        library: 'Vex',
        libraryTarget: 'umd',
        libraryExport: 'default',
      },
      devtool: process.env.VEX_GENMAP || mode === 'production' ? 'source-map' : false,
      module: {
        rules: [
          {
            test: /\.js?$/,
            exclude: /(node_modules|bower_components)/,
            use: [
              {
                loader: 'babel-loader',
                options: {
                  presets: [preset],
                  plugins: ['@babel/plugin-transform-object-assign'],
                },
              },
            ],
          },
        ],
      },
    };
  }

  const webpackProd = webpackConfig(TARGET_MIN, ['@babel/preset-env'], 'production');
  const webpackDev = webpackConfig(TARGET_RAW, ['@babel/preset-env'], 'development');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        banner: BANNER,
        sourceMap: true,
      },
      tests: {
        src: TEST_SOURCES,
        dest: TARGET_TESTS,
      },
    },
    webpack: {
      build: webpackProd,
      buildDev: webpackDev,
      watch: {
        ...webpackDev,
        watch: true,
        keepalive: true,
        failOnError: false,
      },
    },
    eslint: {
      target: SOURCES.concat('./tests'),
    },
    qunit: {
      files: ['tests/flow.html'],
    },
    watch: {
      tests: {
        files: ['tests/*', 'src/*'],
        tasks: ['concat:tests'],
        options: {
          interrupt: true,
        },
      },
    },
    copy: {
      release: {
        files: [
          {
            expand: true,
            dest: RELEASE_DIR,
            cwd: BUILD_DIR,
            src: ['*.js', 'docs/**', '*.map'],
          },
        ],
      },
    },
    docco: {
      src: SOURCES,
      options: {
        layout: 'linear',
        output: 'build/docs',
      },
    },
    gitcommit: {
      releases: {
        options: {
          message: 'Committing release binaries for new version: <%= pkg.version %>',
          verbose: true,
        },
        files: [
          {
            src: [`${RELEASE_DIR}/*.js`, `${RELEASE_DIR}/*.map`],
            expand: true,
          },
        ],
      },
    },
    bump: {
      options: {
        files: ['package.json', 'component.json'],
        commitFiles: ['package.json', 'component.json'],
        updateConfigs: ['pkg'],
        createTag: false,
        push: false,
      },
    },
    release: {
      options: {
        bump: false,
        commit: false,
        npm: false, // Run npm publish by hand
      },
    },
    clean: [BUILD_DIR],
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-docco');
  grunt.loadNpmTasks('grunt-release');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-git');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-webpack');

  // Default task(s).
  grunt.registerTask('default', ['eslint', 'webpack:buildDev', 'webpack:build', 'concat', 'docco']);
  grunt.registerTask('test', 'Run qunit tests.', ['webpack:buildDev', 'concat', 'qunit']);

  // Release current build.
  grunt.registerTask('stage', 'Stage current bundles to releases/.', () => {
    grunt.task.run('default');
    grunt.task.run('qunit');
    grunt.task.run('copy:release');
  });

  grunt.registerTask('alldone', 'Publish VexFlow NPM.', () => {
    grunt.log.ok('NOT YET DONE: Run `npm publish` now to publish NPM.');
  });

  // Increment package version generate releases
  grunt.registerTask('publish', 'Generate releases.', ['bump', 'stage', 'gitcommit:releases', 'release', 'alldone']);
};
<commit_msg>Add eslint --fix to grunt.<commit_after>/* global module, __dirname, process, require */
const path = require('path');

module.exports = (grunt) => {
  const BANNER = [
    '/**!',
    ' * VexFlow <%= pkg.version %> built on <%= grunt.template.today("yyyy-mm-dd") %>.',
    ' * Copyright (c) 2010 Mohit Muthanna Cheppudira <mohit@muthanna.com>',
    ' *',
    ' * http://www.vexflow.com  http://github.com/0xfe/vexflow',
    ' */',
  ].join('\n');
  const BASE_DIR = __dirname;
  const BUILD_DIR = path.join(BASE_DIR, 'build');
  const RELEASE_DIR = path.join(BASE_DIR, 'releases');
  const MODULE_ENTRY = path.join(BASE_DIR, 'src/index.js');
  const TARGET_RAW = 'vexflow-debug.js';
  const TARGET_MIN = 'vexflow-min.js';

  // Used for eslint and docco
  const SOURCES = ['src/*.js', '!src/header.js'];

  // Take all test files in 'tests/' and build TARGET_TESTS
  const TARGET_TESTS = path.join(BUILD_DIR, 'vexflow-tests.js');
  const TEST_SOURCES = ['tests/vexflow_test_helpers.js', 'tests/mocks.js', 'tests/*_tests.js', 'tests/run.js'];

  function webpackConfig(target, preset, mode) {
    return {
      mode,
      entry: MODULE_ENTRY,
      output: {
        path: BUILD_DIR,
        filename: target,
        library: 'Vex',
        libraryTarget: 'umd',
        libraryExport: 'default',
      },
      devtool: process.env.VEX_GENMAP || mode === 'production' ? 'source-map' : false,
      module: {
        rules: [
          {
            test: /\.js?$/,
            exclude: /(node_modules|bower_components)/,
            use: [
              {
                loader: 'babel-loader',
                options: {
                  presets: [preset],
                  plugins: ['@babel/plugin-transform-object-assign'],
                },
              },
            ],
          },
        ],
      },
    };
  }

  const webpackProd = webpackConfig(TARGET_MIN, ['@babel/preset-env'], 'production');
  const webpackDev = webpackConfig(TARGET_RAW, ['@babel/preset-env'], 'development');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        banner: BANNER,
        sourceMap: true,
      },
      tests: {
        src: TEST_SOURCES,
        dest: TARGET_TESTS,
      },
    },
    webpack: {
      build: webpackProd,
      buildDev: webpackDev,
      watch: {
        ...webpackDev,
        watch: true,
        keepalive: true,
        failOnError: false,
      },
    },
    eslint: {
      target: SOURCES.concat('./tests'),
      options: { fix: true },
    },
    qunit: {
      files: ['tests/flow.html'],
    },
    watch: {
      tests: {
        files: ['tests/*', 'src/*'],
        tasks: ['concat:tests'],
        options: {
          interrupt: true,
        },
      },
    },
    copy: {
      release: {
        files: [
          {
            expand: true,
            dest: RELEASE_DIR,
            cwd: BUILD_DIR,
            src: ['*.js', 'docs/**', '*.map'],
          },
        ],
      },
    },
    docco: {
      src: SOURCES,
      options: {
        layout: 'linear',
        output: 'build/docs',
      },
    },
    gitcommit: {
      releases: {
        options: {
          message: 'Committing release binaries for new version: <%= pkg.version %>',
          verbose: true,
        },
        files: [
          {
            src: [`${RELEASE_DIR}/*.js`, `${RELEASE_DIR}/*.map`],
            expand: true,
          },
        ],
      },
    },
    bump: {
      options: {
        files: ['package.json', 'component.json'],
        commitFiles: ['package.json', 'component.json'],
        updateConfigs: ['pkg'],
        createTag: false,
        push: false,
      },
    },
    release: {
      options: {
        bump: false,
        commit: false,
        npm: false, // Run npm publish by hand
      },
    },
    clean: [BUILD_DIR],
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-docco');
  grunt.loadNpmTasks('grunt-release');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-git');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-webpack');

  // Default task(s).
  grunt.registerTask('default', ['eslint', 'webpack:buildDev', 'webpack:build', 'concat', 'docco']);
  grunt.registerTask('test', 'Run qunit tests.', ['webpack:buildDev', 'concat', 'qunit']);

  // Release current build.
  grunt.registerTask('stage', 'Stage current bundles to releases/.', () => {
    grunt.task.run('default');
    grunt.task.run('qunit');
    grunt.task.run('copy:release');
  });

  grunt.registerTask('alldone', 'Publish VexFlow NPM.', () => {
    grunt.log.ok('NOT YET DONE: Run `npm publish` now to publish NPM.');
  });

  // Increment package version generate releases
  grunt.registerTask('publish', 'Generate releases.', ['bump', 'stage', 'gitcommit:releases', 'release', 'alldone']);
};
<|endoftext|>


<commit_before>// Generated on 2014-11-02 using generator-angular 0.9.8
'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) {

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

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

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'public'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            express: {
                files: [
                    '<%= yeoman.app %>/{,*//*}*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*//*}*.js',
                    '<%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}',
                    'index.js',
                    'server/{,*//*}*.{js,json}'
                ],
                tasks: ['express:dev'],
                options: {
                    livereload: true,
                    nospawn: true //Without this option specified express won't be reloaded
                }
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

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

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath:  /\.\.\//,
                exclude: [
                    '/jquery/',
                    'bower_components/bootstrap/dist/js/bootstrap.js',
                    'bower_components/highlightjs/styles/default.css'
                ]
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // 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: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

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

        // The following *-min tasks will produce minified files in the dist folder
        // 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: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

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

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html', 'views/**/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: ['*.js', '!oldieshim.js'],
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/**/*.html',
                        'views/**/*.json',
                        'views/codesnippets/*',
                        'images/{,*/}*.{webp}',
                        'fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'bower_components/bootstrap/dist',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }, {
                    expand: true,
                    cwd: 'bower_components/components-font-awesome',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

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

        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },

        express: {
            options: {
                port: process.env.PORT || 9001
            },
            dev: {
                options: {
                    script: 'index.js'
                }
            },
            prod: {
                options: {
                    script: 'index.js'
                }
            }
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'marked',
            'extractheaders',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('serve-express', 'Compile then start an express node', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'marked',
            'extractheaders',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'express:dev',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'marked',
        'extractheaders',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('heroku:production', 'build');
    grunt.registerTask('heroku:dev', 'build');

    grunt.loadTasks('tasks');
};
<commit_msg>removed docs from site<commit_after>// Generated on 2014-11-02 using generator-angular 0.9.8
'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) {

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

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

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'public'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            express: {
                files: [
                    '<%= yeoman.app %>/{,*//*}*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*//*}*.js',
                    '<%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}',
                    'index.js',
                    'server/{,*//*}*.{js,json}'
                ],
                tasks: ['express:dev'],
                options: {
                    livereload: true,
                    nospawn: true //Without this option specified express won't be reloaded
                }
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

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

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath:  /\.\.\//,
                exclude: [
                    '/jquery/',
                    'bower_components/bootstrap/dist/js/bootstrap.js',
                    'bower_components/highlightjs/styles/default.css'
                ]
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // 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: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

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

        // The following *-min tasks will produce minified files in the dist folder
        // 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: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

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

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html', 'views/**/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: ['*.js', '!oldieshim.js'],
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/**/*.html',
                        'views/**/*.json',
                        'views/codesnippets/*',
                        'images/{,*/}*.{webp}',
                        'fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'bower_components/bootstrap/dist',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }, {
                    expand: true,
                    cwd: 'bower_components/components-font-awesome',
                    src: 'fonts/*',
                    dest: '<%= yeoman.dist %>'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

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

        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },

        express: {
            options: {
                port: process.env.PORT || 9001
            },
            dev: {
                options: {
                    script: 'index.js'
                }
            },
            prod: {
                options: {
                    script: 'index.js'
                }
            }
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('serve-express', 'Compile then start an express node', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'express:dev',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('heroku:production', 'build');
    grunt.registerTask('heroku:dev', 'build');

    grunt.loadTasks('tasks');
};
<|endoftext|>


<commit_before>var bower = require('bower'),
  path = require('path'),
  crypto = require('crypto'),
  async = require('async');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      all: [
        'Gruntfile.js',
        'server/**/*.js',
        'test/**/*.js',
        'server/**/*.json',
        'test/**/*.json',
        'client/**/*.js',
        'client/**/*.json'
      ]
    },
    nodeunit: {
      all: ['test/server/**/*.js']
    },
    apidoc: {
      tgio: {
        src: "server/",
        dest: "build/www/apidoc/"
      }
    },
    bower: {
      target: {
        rjsConfig: 'client/www/js/config.js'
      }
    },
    requirejs: {
      prod: {
        options: {
          mainConfigFile: 'client/www/js/config.js',
          name: 'tgio',
          out: 'build/www/js/main.js',
          optimize: "none",
        },
      },
    },
    copy: {
      main: {
        files: [
          // includes files within path and its sub-directories
          {
            expand: true,
            src: ['**'],
            cwd: 'client/www/static/',
            dest: 'build/www'
          }, {
            expand: true,
            src: ['require.js'],
            cwd: 'bower_components/requirejs/',
            dest: 'build/www/js'
          }
        ]
      }
    },
    less: {
      development: {
        options: {
          paths: ["."]
        },
        files: {
          "build/www/css/main.css": "client/www/less/main.less"
        }
      }
    },
    watch: {
      scripts: {
        files: ['client/www/**', 'server/**', 'test/**'],
        tasks: ['default', 'express-restart'],
        options: {
          interrupt: true,
        },
      },
    },
    jsbeautifier: {
      "default": {
        src: ['Gruntfile.js', "server/**/*.js", "test/**/*.js", "server/**/*.json", "test/**/*.json", 'client/**/*.js', 'client/**/*.json'],
        options: {
          js: {
            indent_size: 2,
            "preserve_newlines": true,
            "max_preserve_newlines": 10,
            "jslint_happy": false,
          }
        }
      },
      "git-pre-commit": {
        src: ['Gruntfile.js', "server/**/*.js", "test/**/*.js", "server/**/*.json", "test/**/*.json", 'client/**/*.js', 'client/**/*.json'],
        options: {
          mode: "VERIFY_ONLY",
          js: {
            indent_size: 2,
            "preserve_newlines": true,
            "max_preserve_newlines": 10,
            "jslint_happy": false,
          }
        }
      }
    },
    express: {
      server: {
        options: {
          debug: true,
          verbose: true,
          hostname: '*',
          server: path.resolve(__dirname, 'server'),
          serverreload: true
        }
      }
    },
    encrypt: {
      default: {
        files: [{
          src: ["secure/*.json"],
          dest: "server",
          ext: ".json.encrypted",
          expand: true
        }],
        options: {
          keyfile: ".keyfile"
        }
      }
      /*,
      test: {
        files: [{
          src: ["test/secure/*.json"],
          ext: ".json.encrypted",
          expand: true
        }],
        options: {
          keyfile: ".testkeyfile"
        }
      }*/
    }
  });

  // A very basic default task.
  grunt.registerTask('sample', 'Log some stuff.', function() {
    grunt.log.write('Logging some stuff...').ok();
  });

  grunt.registerTask('bower-install', function() {
    var done = this.async();
    var install = bower.commands.install();

    function log(obj) {
      grunt.verbose.writeln(obj.id + ": " + obj.message);
    }
    install.on('log', log);
    install.on('error', grunt.log.error);
    install.on('end', done);
  });

  grunt.registerMultiTask('encrypt', function() {
    var options = this.options({
      "action": grunt.cli.options.crypt || "encrypt",
      "keyfile": grunt.cli.options.keyfile
    });
    var done = this.async();
    var key = grunt.file.read(options.keyfile);
    console.log(key);

    async.each(this.files, function(file, cb) {
        var text = grunt.file.read(file.src[0]),
          cipher = crypto.createCipher('aes-256-cbc', key),
          crypted = cipher.update(text, 'utf8', 'hex');

        crypted += cipher.final('hex');
        console.log(crypted);
        grunt.file.write(file.dest, crypted);
        grunt.log.writeln('Encrypting ' + file.src[0].cyan + ' -> ' + file.dest.cyan);
        cb();
      },
      function(result) {
        done(result);
      });
  });

  grunt.registerTask('build', ['encrypt', 'bower-install', 'bower', 'nodeunit', 'jshint', 'jsbeautifier', 'copy', 'requirejs', 'less', 'apidoc']);
  grunt.registerTask('server', ['express:server', 'build:default']);
  grunt.registerTask('default', 'build');
  grunt.registerTask('heroku:development', 'default');
  grunt.registerTask('heroku:', 'default');
  grunt.registerTask('heroku', 'default');
  grunt.loadNpmTasks('grunt-jsbeautifier');
  grunt.loadNpmTasks('grunt-apidoc');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-bower-requirejs');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-express');
};
<commit_msg>using environment variable for key<commit_after>var bower = require('bower'),
  path = require('path'),
  crypto = require('crypto'),
  async = require('async');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      all: [
        'Gruntfile.js',
        'server/**/*.js',
        'test/**/*.js',
        'server/**/*.json',
        'test/**/*.json',
        'client/**/*.js',
        'client/**/*.json'
      ]
    },
    nodeunit: {
      all: ['test/server/**/*.js']
    },
    apidoc: {
      tgio: {
        src: "server/",
        dest: "build/www/apidoc/"
      }
    },
    bower: {
      target: {
        rjsConfig: 'client/www/js/config.js'
      }
    },
    requirejs: {
      prod: {
        options: {
          mainConfigFile: 'client/www/js/config.js',
          name: 'tgio',
          out: 'build/www/js/main.js',
          optimize: "none",
        },
      },
    },
    copy: {
      main: {
        files: [
          // includes files within path and its sub-directories
          {
            expand: true,
            src: ['**'],
            cwd: 'client/www/static/',
            dest: 'build/www'
          }, {
            expand: true,
            src: ['require.js'],
            cwd: 'bower_components/requirejs/',
            dest: 'build/www/js'
          }
        ]
      }
    },
    less: {
      development: {
        options: {
          paths: ["."]
        },
        files: {
          "build/www/css/main.css": "client/www/less/main.less"
        }
      }
    },
    watch: {
      scripts: {
        files: ['client/www/**', 'server/**', 'test/**'],
        tasks: ['default', 'express-restart'],
        options: {
          interrupt: true,
        },
      },
    },
    jsbeautifier: {
      "default": {
        src: ['Gruntfile.js', "server/**/*.js", "test/**/*.js", "server/**/*.json", "test/**/*.json", 'client/**/*.js', 'client/**/*.json'],
        options: {
          js: {
            indent_size: 2,
            "preserve_newlines": true,
            "max_preserve_newlines": 10,
            "jslint_happy": false,
          }
        }
      },
      "git-pre-commit": {
        src: ['Gruntfile.js', "server/**/*.js", "test/**/*.js", "server/**/*.json", "test/**/*.json", 'client/**/*.js', 'client/**/*.json'],
        options: {
          mode: "VERIFY_ONLY",
          js: {
            indent_size: 2,
            "preserve_newlines": true,
            "max_preserve_newlines": 10,
            "jslint_happy": false,
          }
        }
      }
    },
    express: {
      server: {
        options: {
          debug: true,
          verbose: true,
          hostname: '*',
          server: path.resolve(__dirname, 'server'),
          serverreload: true
        }
      }
    },
    encrypt: {
      default: {
        files: [{
          src: ["secure/*.json"],
          dest: "server",
          ext: ".json.encrypted",
          expand: true
        }],
        options: {
          keyfile: ".keyfile"
        }
      }
      /*,
      test: {
        files: [{
          src: ["test/secure/*.json"],
          ext: ".json.encrypted",
          expand: true
        }],
        options: {
          keyfile: ".testkeyfile"
        }
      }*/
    }
  });

  // A very basic default task.
  grunt.registerTask('sample', 'Log some stuff.', function() {
    grunt.log.write('Logging some stuff...').ok();
  });

  grunt.registerTask('bower-install', function() {
    var done = this.async();
    var install = bower.commands.install();

    function log(obj) {
      grunt.verbose.writeln(obj.id + ": " + obj.message);
    }
    install.on('log', log);
    install.on('error', grunt.log.error);
    install.on('end', done);
  });

  grunt.registerMultiTask('encrypt', function() {
    var options = this.options({
      "action": grunt.cli.options.crypt || "encrypt",
      "keyfile": grunt.cli.options.keyfile
    });
    var done = this.async();
    var key = process.env.KEY || grunt.file.read(options.keyfile);
    console.log(key);

    async.each(this.files, function(file, cb) {
        var text = grunt.file.read(file.src[0]),
          cipher = crypto.createCipher('aes-256-cbc', key),
          crypted = cipher.update(text, 'utf8', 'hex');

        crypted += cipher.final('hex');
        console.log(crypted);
        grunt.file.write(file.dest, crypted);
        grunt.log.writeln('Encrypting ' + file.src[0].cyan + ' -> ' + file.dest.cyan);
        cb();
      },
      function(result) {
        done(result);
      });
  });

  grunt.registerTask('build', ['encrypt', 'bower-install', 'bower', 'nodeunit', 'jshint', 'jsbeautifier', 'copy', 'requirejs', 'less', 'apidoc']);
  grunt.registerTask('server', ['express:server', 'build:default']);
  grunt.registerTask('default', 'build');
  grunt.registerTask('heroku:development', 'default');
  grunt.registerTask('heroku:', 'default');
  grunt.registerTask('heroku', 'default');
  grunt.loadNpmTasks('grunt-jsbeautifier');
  grunt.loadNpmTasks('grunt-apidoc');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-bower-requirejs');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-express');
};
<|endoftext|>