<commit_before>var Player = function(id, x, y, key, game) {
	this.game = game;
	this.player = null;
	this.score = 0;
	this.direction = 1;
	this.id = id;
	this.x = x;
	this.y = y;
	this.key = key;
	this.killTrail = false;
	this.dead = false;
	this.groupTrail = null;
	this.ready = true;
	this.speed = 1;
	this.angularVelocity = 1;
	this.growth = 30;
	this.frameCount = 0;
	this.lastTrailLength = 0;
	this.enemyTrails = [];
	this.keyText = null;
};

Player.prototype = {

	create: function() {
		this.groupTrail = this.game.add.group();
		this.player = this.game.add.sprite(this.x, this.y, 'player' + this.id);
		this.player.anchor.setTo(.5,.5);
		groupTrails.push(this.groupTrail);

		this.game.physics.enable(this.player, Phaser.Physics.ARCADE);
		this.player.body.setSize(16*this.game.world.scale.x, 16*this.game.world.scale.x, 0, 0);
		this.groupTrail.enableBody = true;
    //this.groupTrail.physicsBodyType = Phaser.Physics.ARCADE;
    this.lastTrailLength = this.growth;

	},

	update: function() {
		//Show player's key
		if (!this.keyText) {
			this.keyText = this.game.add.text(
				Math.round(Math.cos(this.player.rotation + Math.PI/2)*80) + this.x,
				Math.round(Math.sin(this.player.rotation + Math.PI/2)*80) + this.y,
				String.fromCharCode(this.key), {
		      font: "80px Arial",
		      fill: "#ffffff",
		      align: "center"
		  	});
	  	this.keyText.anchor.setTo(0.5,0.5);
		}

		this.frameCount = (this.frameCount + 1) % 1/(this.speed*this.game.world.scale.x);

		this.game.physics.arcade.overlap(this.player, this.enemyTrails, this.kill, null, this);
		this.game.physics.arcade.overlap(this.player, groupPowers, this.collect, null, this);

		//Snake movement
		this.player.body.angularVelocity = this.direction*200*this.angularVelocity*this.speed;
		this.game.physics.arcade.velocityFromAngle(this.player.angle, 300*this.speed, this.player.body.velocity);

		//Create trail
		if (this.ready && this.frameCount == 0) {
			var trailPiece = this.groupTrail.create(this.player.x, this.player.y, 'trail' + this.id);
			trailPiece.body.immovable = true;
			trailPiece.anchor.setTo(.5,.5);
			trailPiece.body.setSize(16*this.game.world.scale.x, 16*this.game.world.scale.x, 0, 0);
		}

		//erase trail from behind
		if(this.dead && this.frameCount == 0){
			this.killTrail = true;
			this.ready = false;
			//getAt() returns -1 if the object doesn't exist
			var obj = this.groupTrail.getAt(this.groupTrail.length - 1);
			if (obj != -1)
	    	{
		        obj.kill();
		        obj.parent.removeChild(obj);
	    	}
		}

		if (!this.killTrail && (this.groupTrail.length >= (this.lastTrailLength + this.growth))) {
			this.killTrail = true;
			this.lastTrailLength = this.groupTrail.length;
		}

		//erase trail from front
		if(this.killTrail && this.frameCount == 0){

			//getFirstAlive() returns null if the object doesn't exist
			var obj = this.groupTrail.getFirstAlive();
		    if (obj)
		    {
		        obj.kill();
		        obj.parent.removeChild(obj);
		    }
		}

		this.game.input.onDown.add(this.keyPressed, this);
		this.game.input.keyboard.addKey(this.key).onDown.add(this.keyPressed, this);
	},

	keyPressed: function() {
		this.direction *= -1;
		if (this.keyText.alpha == 1) {
			console.log(this.keyText.alpha);
			this.game.add.tween(this.keyText).to( { alpha: 0 }, 2000, Phaser.Easing.Linear.None, true);
		}
	},

	kill: function(player, trail) {
		this.player.kill();
		this.dead = true;

		console.log('Player ' + this.id + 'collided with ' + trail.frameName)

		var newMax = -1;
		for (var i = 0; i < players.length; i++) {
			if (i != this.id && players[i].score > newMax && !players[i].dead) {
				newMax = players[i].score;
				crowned = i;
			}
		}
	},

	collect: function(player, power) {
		power.kill();
		this.killTrail = false;
		this.growth = 30*power.scale.x;
		this.score = this.score + power.scale.x;
		console.log("palyer" + this.id + " is now " + this.score)

		if (this.score > highScore) {
			highScore = this.score;
			crowned = this.id;
			players[crowned].removeCrown();
			console.log(crowned)
		}

	},

	addCrown: function() {
		this.player.loadTexture('crown' + this.id)
	},

	removeCrown: function() {
		this.player.loadTexture('player' + this.id)
	},

	render: function(){
		//this.game.debug.body(this.player);
	}
};<commit_msg>colisions with borders<commit_after>var Player = function(id, x, y, key, game) {
	this.game = game;
	this.player = null;
	this.score = 0;
	this.direction = 1;
	this.id = id;
	this.x = x;
	this.y = y;
	this.key = key;
	this.killTrail = false;
	this.dead = false;
	this.groupTrail = null;
	this.ready = true;
	this.speed = 1;
	this.angularVelocity = 1;
	this.growth = 30;
	this.frameCount = 0;
	this.lastTrailLength = 0;
	this.enemyTrails = [];
	this.keyText = null;
	this.border = [-((this.game.world.width/2)/this.game.world.scale.x),
			(this.game.world.width/2)/this.game.world.scale.x,
			-((this.game.world.height/2)/this.game.world.scale.y),
			(this.game.world.height/2)/this.game.world.scale.y]
};

Player.prototype = {

	create: function() {
		this.groupTrail = this.game.add.group();
		this.player = this.game.add.sprite(this.x, this.y, 'player' + this.id);
		this.player.anchor.setTo(.5,.5);
		groupTrails.push(this.groupTrail);

		this.game.physics.enable(this.player, Phaser.Physics.ARCADE);
		this.player.body.setSize(16*this.game.world.scale.x, 16*this.game.world.scale.x, 0, 0);
		this.groupTrail.enableBody = true;
    //this.groupTrail.physicsBodyType = Phaser.Physics.ARCADE;
    this.lastTrailLength = this.growth;

	},

	update: function() {
		//Show player's key
		if (!this.keyText) {
			this.keyText = this.game.add.text(
				Math.round(Math.cos(this.player.rotation + Math.PI/2)*80) + this.x,
				Math.round(Math.sin(this.player.rotation + Math.PI/2)*80) + this.y,
				String.fromCharCode(this.key), {
		      font: "80px Arial",
		      fill: "#ffffff",
		      align: "center"
		  	});
	  	this.keyText.anchor.setTo(0.5,0.5);
		}

		this.frameCount = (this.frameCount + 1) % 1/(this.speed*this.game.world.scale.x);

		this.game.physics.arcade.overlap(this.player, this.enemyTrails, this.kill, null, this);
		this.game.physics.arcade.overlap(this.player, groupPowers, this.collect, null, this);

		//Snake movement
		this.player.body.angularVelocity = this.direction*200*this.angularVelocity*this.speed;
		this.game.physics.arcade.velocityFromAngle(this.player.angle, 300*this.speed, this.player.body.velocity);

		//Create trail
		if (this.ready && this.frameCount == 0) {
			var trailPiece = this.groupTrail.create(this.player.x, this.player.y, 'trail' + this.id);
			trailPiece.body.immovable = true;
			trailPiece.anchor.setTo(.5,.5);
			trailPiece.body.setSize(16*this.game.world.scale.x, 16*this.game.world.scale.x, 0, 0);
		}

		//erase trail from behind
		if(this.dead && this.frameCount == 0){
			this.killTrail = true;
			this.ready = false;
			//getAt() returns -1 if the object doesn't exist
			var obj = this.groupTrail.getAt(this.groupTrail.length - 1);
			if (obj != -1)
	    	{
		        obj.kill();
		        obj.parent.removeChild(obj);
	    	}
		}

		if (!this.killTrail && (this.groupTrail.length >= (this.lastTrailLength + this.growth))) {
			this.killTrail = true;
			this.lastTrailLength = this.groupTrail.length;
		}

		//erase trail from front
		if(this.killTrail && this.frameCount == 0){

			//getFirstAlive() returns null if the object doesn't exist
			var obj = this.groupTrail.getFirstAlive();
		    if (obj)
		    {
		        obj.kill();
		        obj.parent.removeChild(obj);
		    }
		}

		if(((this.player.x-16)<=this.border[0]) || ((this.player.x+16)>=this.border[1])){
			this.kill();
		}
		if(((this.player.y-16)<=this.border[2]) || ((this.player.y+16)>=this.border[3])){
			this.kill();
		}

		this.game.input.onDown.add(this.keyPressed, this);
		this.game.input.keyboard.addKey(this.key).onDown.add(this.keyPressed, this);
	},

	keyPressed: function() {
		this.direction *= -1;
		if (this.keyText.alpha == 1) {
			console.log(this.keyText.alpha);
			this.game.add.tween(this.keyText).to( { alpha: 0 }, 2000, Phaser.Easing.Linear.None, true);
		}
	},

	kill: function(player, trail) {
		this.player.kill();
		this.dead = true;

		//console.log('Player ' + this.id + 'collided with ' + trail.frameName)

		var newMax = -1;
		for (var i = 0; i < players.length; i++) {
			if (i != this.id && players[i].score > newMax && !players[i].dead) {
				newMax = players[i].score;
				crowned = i;
			}
		}
	},

	collect: function(player, power) {
		power.kill();
		this.killTrail = false;
		this.growth = 30*power.scale.x;
		this.score = this.score + power.scale.x;
		console.log("palyer" + this.id + " is now " + this.score)

		if (this.score > highScore) {
			highScore = this.score;
			crowned = this.id;
			players[crowned].removeCrown();
			console.log(crowned)
		}

	},

	addCrown: function() {
		this.player.loadTexture('crown' + this.id)
	},

	removeCrown: function() {
		this.player.loadTexture('player' + this.id)
	},

	render: function(){
		//this.game.debug.body(this.player);
	}
};<|endoftext|>


<commit_before>/*
 * grunt-css-absolute-image-url
 * https://github.com/supersheep/grunt-css-absolute-image-url
 *
 * Copyright (c) 2013 supersheep
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

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

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

    // Configuration to be run (and then tested).
    css_absolute_image_url: {
      all: {
        options: {
          dir:"test/fixtures",
          root:"public",
          hosts:["i1.cdn.com","i2.cdn.com","i3.cdn.com"], // image host hashes
          no_version:true, // clear ver
          md5:true, // add md5 after
          allow_image_miss:true
        },
        files: [{expand: true, cwd:"test/fixtures/", src: ['**/*.css'], dest: 'dest/', filter: 'isFile',  ext: '.css'}]
      }
    },

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

  });

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

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

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'css_absolute_image_url', 'nodeunit']);

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

};
<commit_msg>add comments<commit_after>/*
 * grunt-css-absolute-image-url
 * https://github.com/supersheep/grunt-css-absolute-image-url
 *
 * Copyright (c) 2013 supersheep
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

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

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

    // Configuration to be run (and then tested).
    css_absolute_image_url: {
      all: {
        options: {
          /**
           * Grunt can only know the files to process,
           * it would not know which is the root directory of your source files
           * so here we tell it, so that the task can replace it with to `root` option
           */
          dir:"test/fixtures",
          /**
           * online static file root path
           * this will be used to replace `dir` in the final path
           */
          root:"public",
          /**
           * image host hashes
           */
          hosts:["i1.cdn.com","i2.cdn.com","i3.cdn.com"],
          /**
           * whether to clear version
           */
          no_version:true,
          /**
           * whether to add md5 after
           */
          md5:true,
          allow_image_miss:true
        },
        files: [{expand: true, cwd:"test/fixtures/", src: ['**/*.css'], dest: 'dest/', filter: 'isFile',  ext: '.css'}]
      }
    },

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

  });

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

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

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'css_absolute_image_url', 'nodeunit']);

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

};
<|endoftext|>


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

  // Time Grunt tasks
  require('time-grunt')(grunt);

  // Autoload Grunt tasks
  require('load-grunt-tasks')(grunt);

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    app: {
      dev: 'src',
      bin: 'bin',
      docs: 'docs',
      test: 'test',
      codeName: 'Turkey Gobbler'
    },

    // Watch for changes
    watch: {
      options: {
        debounceDelay: 250
      },
      scripts: {
        files: ['<%= app.dev %>/**/*.js', 'Gruntfile.js'],
        tasks: ['jshint:dev']
      },
      tests: {
        files: ['<%= app.test %>/**/*.js'],
        tasks: ['nodeunit']
      }
    },

    // JSHint
    jshint: {
      options: {
        reporter: require('jshint-stylish')
      },
      dev: ['<%= app.dev %>/**/*.js', '<%= app.bin %>/**/*.js', '<%= app.test %>/test/**/*.js', 'Gruntfile.js']
    },

    // Check for todos
    todos: {
      options: {
        verbose: false
      },
      all: {
        src: ['<%= app.dev %>/**/*.js', 'README.md', '<%= app.test %>/**/*.js', 'Gruntfile.js', 'package.json']
      }
    },

    // Document code
    docco: {
      all: {
        src: ['<%= app.dev %>/**/*.js', '<%= app.test %>/**/*.js'],
        options: {
          output: '<%= app.docs %>/'
        }
      }
    },

    // Run tests
    nodeunit: {
      all: ['<%= app.test %>/*_test.js'],
      options: {
        reporter: 'default',
        reporterOutput: '<%= app.test %>/results/<%= grunt.template.today("yyyymmdd") %>-test-results.txt'
      }
    },

    // Run shell commands
    shell: {
      publish: {
        command: ['git add .', 'git commit -m "<%= grunt.option("message") %>"', 'npm publish'].join('&&')
      }
    }
  });

  // Default task(s).
  grunt.registerTask('default', ['develop']);

  grunt.registerTask('develop', ['watch']);

  grunt.registerTask('build', [
    'jshint',
    'nodeunit',
    'docco',
    'todos'
    ]);

  grunt.registerTask('publish', ['build', 'shell:publish']);

};
<commit_msg>Test reporter will output to console so we can see errors on Travis.<commit_after>module.exports = function(grunt) {

  // Time Grunt tasks
  require('time-grunt')(grunt);

  // Autoload Grunt tasks
  require('load-grunt-tasks')(grunt);

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    app: {
      dev: 'src',
      bin: 'bin',
      docs: 'docs',
      test: 'test',
      codeName: 'Turkey Gobbler'
    },

    // Watch for changes
    watch: {
      options: {
        debounceDelay: 250
      },
      scripts: {
        files: ['<%= app.dev %>/**/*.js', 'Gruntfile.js'],
        tasks: ['jshint:dev']
      },
      tests: {
        files: ['<%= app.test %>/**/*.js'],
        tasks: ['nodeunit']
      }
    },

    // JSHint
    jshint: {
      options: {
        reporter: require('jshint-stylish')
      },
      dev: ['<%= app.dev %>/**/*.js', '<%= app.bin %>/**/*.js', '<%= app.test %>/test/**/*.js', 'Gruntfile.js']
    },

    // Check for todos
    todos: {
      options: {
        verbose: false
      },
      all: {
        src: ['<%= app.dev %>/**/*.js', 'README.md', '<%= app.test %>/**/*.js', 'Gruntfile.js', 'package.json']
      }
    },

    // Document code
    docco: {
      all: {
        src: ['<%= app.dev %>/**/*.js', '<%= app.test %>/**/*.js'],
        options: {
          output: '<%= app.docs %>/'
        }
      }
    },

    // Run tests
    nodeunit: {
      all: ['<%= app.test %>/*_test.js'],
      options: {
        reporter: 'default',
        //reporterOutput: '<%= app.test %>/results/<%= grunt.template.today("yyyymmdd") %>-test-results.txt'
      }
    },

    // Run shell commands
    shell: {
      publish: {
        command: ['git add .', 'git commit -m "<%= grunt.option("message") %>"', 'npm publish'].join('&&')
      }
    }
  });

  // Default task(s).
  grunt.registerTask('default', ['develop']);

  grunt.registerTask('develop', ['watch']);

  grunt.registerTask('build', [
    'jshint',
    'nodeunit',
    'docco',
    'todos'
    ]);

  grunt.registerTask('publish', ['build', 'shell:publish']);

};
<|endoftext|>


<commit_before>// const Fiber = require('fibers');
const sass = require('dart-sass');

module.exports = function(grunt) {

    'use strict';

    grunt.initConfig({

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

        browserify: {
            dev: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            lexicon: {
                files: {
                    'dist/js/lexicon-bundle.js': ['js/lexicon/lexicon-index.js']
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            dist: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar'
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        'uglifyify'
                    ]
                }
            },
            browserTests: {
                files: {
                    'dist/js/bundle.js': ['js/index.js'],
                    'dist/js/browser.test.js': ['tests/harness/browser.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        ['require-globify']
                    ]
                }
            }
        },

        phpunit: {
            classes: {
                dir: 'tests/unit/'
            },
            options: {
                bin: 'php -d memory_limit=-1 ./vendor/bin/phpunit',
                bootstrap: 'tests/unit/bootstrap.php',
                colors: true
            }
        },

        sass: {
            dev: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    sourceMap: true
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            },
            dist: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    outputStyle: 'compressed'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    ['pulsar.scss']
                }]
            },
            lexicon: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    sourceMap: true
                },
                files: [{
                    cwd: 'stylesheets/lexicon/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            }
        },

        autoprefixer: {
            dev: {
                options: {
                    browsers: ['last 2 versions', 'IE 10']
                },
                expand: true,
                src:    'css/*.css'
            }
        },

        scsslint: {
            allFiles: [
                'stylesheets/**/*.scss',
            ],
            options: {
                config: '.scss-lint.yml',
                colorizeOutput: true
            },
        },

        watch: {
            css: {
                files: ['stylesheets/**/*.scss'],
                tasks: ['sass:dev', 'sass:lexicon', 'autoprefixer']
            },
            scsslint: {
                files: 'stylesheets/**/*.scss',
                tasks: ['scsslint']
            },
            lexicon: {
                files: ['js/lexicon/**/*.js'],
                tasks: ['browserify:lexicon']
            },
            js: {
                files: ['js/**/*.js', 'package.json', '!js/lexicon/**/*'],
                tasks: ['browserify:dev']
            },
            tests: {
                files: ['tests/**/*.js'],
                tasks: ['browserify:browserTests']
            }
        },

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

        mocha: {
            test: {
                src: ['tests/**/*.html'],
                options: {
                    reporter: 'Nyan',
                    run: true
                }
            },
        },

        uglify: {
            concat: {
                options: {
                    banner: '<%= pkg.banner %>',
                    beautify: true
                },
                files: {
                    'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
                }
                },
                minify: {
                options: {
                    banner: '<%= pkg.banner %>',
                    compress: true,
                    report: 'min'
                },
                files: {
                    'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
                }
            }
        },

        asciify: {
            banner:{
            text: '<%= pkg.name %>',
            options: {
                font: 'univers',
                log: true
            }
            },
        },

        copy: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '',
                    src: [
                        'fonts/**/*',
                        'images/**/*',
                        'libs/**/*',
                        'views/pulsar/**/*',
                        'src/**/*'
                    ],
                    dest: 'dist/'
                }]
            }
        },

        clean: {
            dist: ['dist'],
            favicons: ['views/pulsar/components/favicons-*.html'],
            smoketest: ['tmp/failures/*']
        },

        bump: {
            options: {
                updateConfigs: ['pkg'],
                files: ['pulsar.json', 'package.json', 'composer.json', 'bower.json', 'VERSION'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['-a'],
                createTag: true,
                tagName: '%VERSION%',
                push: true,
                pushTo: 'origin'
            }
        },

        exec: {
            phantomcss: {
                cmd: 'phantomjs tests/css/testsuite.js'
            },
            updateComposer: {
                cmd: 'sudo php composer.phar update'
            },
            updateBrew: {
                cmd: 'brew update && brew upgrade'
            },
            updateBower: {
                cmd: 'bower update'
            },
            updateGems: {
                cmd: 'sudo gem update'
            },
            updateNpm: {
                cmd: 'sudo npm install'
            },
            fixProximaNova: {
                cmd: 'git update-index --skip-worktree fonts/_config.fonts.scss'
            }
        },

        realFavicon: {
            options: {
                settings: {
                    scalingAlgorithm: 'Mitchell',
                    errorOnImageTooSmall: false
                }
            },
            cms: {
                src: 'images/branding/jadu-central-logomark.svg',
                dest: 'images/favicons/cms',
                options: {
                    iconsPath: '/jadu/bundles/pulsar/images/favicons/cms/',
                    html: [ 'views/pulsar/components/favicons-cms.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#15a6d1',
                            onConflict: 'override'
                        }
                    }
                }
            },
            xfp: {
                src: 'images/branding/jadu-central-logomark.svg',
                dest: 'images/favicons/xfp',
                options: {
                    iconsPath: '/images/favicons/xfp/',
                    html: [ 'views/pulsar/components/favicons-xfp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#80BA27',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cxm: {
                src: 'images/branding/jadu-connect-logomark.svg',
                dest: 'images/favicons/cxm',
                options: {
                    iconsPath: '/images/favicons/cxm/',
                    html: [ 'views/pulsar/components/favicons-cxm.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#54B9A9',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cp: {
                src: 'images/favicons/src/favicon-cp.svg',
                dest: 'images/favicons/cp',
                options: {
                    iconsPath: '/images/favicons/cp/',
                    html: [ 'views/pulsar/components/favicons-cp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#DC5172',
                            onConflict: 'override'
                        }
                    }
                }
            },
            deployer: {
                src: 'images/favicons/src/favicon-deployer.svg',
                dest: 'images/favicons/deployer',
                options: {
                    iconsPath: '/images/favicons/deployer/',
                    html: [ 'views/pulsar/components/favicons-deployer.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#3d4796',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#3d4796',
                            themeColor: '#3d4796',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'noChange',
                            backgroundColor: '#3d4796',
                            onConflict: 'override'
                        }
                    }
                }
            }
        },

        compress: {
            dist: {
                options: {
                    archive: 'pulsar.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**/*']
                }]
            }
        },

        browserSync: {
            files: [
                'css/*',
                'dist/**/*',
                'images/**/*',
                'views/**/*'
            ],
            options: {
                proxy: 'http://localhost:9000/app/app.php/lexicon',
                reloadOnRestart: true,
                watchTask: true
            }
	    }

    });

    grunt.config.set('leadingIndent.indentation', 'spaces');

    grunt.config.set('leadingIndent.files', {
        src : [
            'css/**/*',
            'js/**/*',
            'src/**/*',
            'stylesheets/**/*',
            'tests/**/*',
            'views/**/*'
        ]
    });

    grunt.registerTask('default', [
        'copy',
        'scsslint',
        'sass:dev',
        'sass:lexicon',
        'autoprefixer',
        'browserify:dev',
        'browserify:lexicon',
        'browserSync',
        'watch'
    ]);

    grunt.registerTask('post-merge', [
        'exec:fixProximaNova',
        'sass:dev',
        'browserify'
    ]);

    grunt.registerTask('build', [
        'scsslint',
        'sass:dist',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('deploy', [
        'sass:dist',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('favicons', [
        'clean:favicons',
        'realFavicon'
    ]);

    grunt.registerTask('update', [
        'exec:updateComposer',
        'exec:updateBrew',
        'exec:updateBower',
        'exec:updateGems',
        'exec:updateNpm'
    ]);

    grunt.registerTask('javascript:tests', [
        'browserify:browserTests',
    ]);

    grunt.registerTask('javascript:tests:watch', [
        'browserify:browserTests',
        'watch:tests'
    ]);

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

};
<commit_msg>No longer maintain a version number in composer.json<commit_after>// const Fiber = require('fibers');
const sass = require('dart-sass');

module.exports = function(grunt) {

    'use strict';

    grunt.initConfig({

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

        browserify: {
            dev: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            lexicon: {
                files: {
                    'dist/js/lexicon-bundle.js': ['js/lexicon/lexicon-index.js']
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }]
                    ]
                }
            },
            dist: {
                files: {
                    'dist/js/bundle.js': ['js/index.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar'
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        'uglifyify'
                    ]
                }
            },
            browserTests: {
                files: {
                    'dist/js/bundle.js': ['js/index.js'],
                    'dist/js/browser.test.js': ['tests/harness/browser.js']
                },
                options: {
                    browserifyOptions: {
                        standalone: 'pulsar',
                        debug: true
                    },
                    transform: [
                        ['babelify', { presets: ['es2015'] } ],
                        ['aliasify', { global: true }],
                        ['require-globify']
                    ]
                }
            }
        },

        phpunit: {
            classes: {
                dir: 'tests/unit/'
            },
            options: {
                bin: 'php -d memory_limit=-1 ./vendor/bin/phpunit',
                bootstrap: 'tests/unit/bootstrap.php',
                colors: true
            }
        },

        sass: {
            dev: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    sourceMap: true
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            },
            dist: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    outputStyle: 'compressed'
                },
                files: [{
                    cwd:    'stylesheets/',
                    dest:   'dist/css/',
                    expand: true,
                    flatten: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    ['pulsar.scss']
                }]
            },
            lexicon: {
                options: {
                    implementation: sass,
                    // fiber: Fiber,
                    sourceMap: true
                },
                files: [{
                    cwd: 'stylesheets/lexicon/',
                    dest:   'css/',
                    expand: true,
                    ext:    '.css',
                    extDot: 'first',
                    src:    '*.scss'
                }]
            }
        },

        autoprefixer: {
            dev: {
                options: {
                    browsers: ['last 2 versions', 'IE 10']
                },
                expand: true,
                src:    'css/*.css'
            }
        },

        scsslint: {
            allFiles: [
                'stylesheets/**/*.scss',
            ],
            options: {
                config: '.scss-lint.yml',
                colorizeOutput: true
            },
        },

        watch: {
            css: {
                files: ['stylesheets/**/*.scss'],
                tasks: ['sass:dev', 'sass:lexicon', 'autoprefixer']
            },
            scsslint: {
                files: 'stylesheets/**/*.scss',
                tasks: ['scsslint']
            },
            lexicon: {
                files: ['js/lexicon/**/*.js'],
                tasks: ['browserify:lexicon']
            },
            js: {
                files: ['js/**/*.js', 'package.json', '!js/lexicon/**/*'],
                tasks: ['browserify:dev']
            },
            tests: {
                files: ['tests/**/*.js'],
                tasks: ['browserify:browserTests']
            }
        },

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

        mocha: {
            test: {
                src: ['tests/**/*.html'],
                options: {
                    reporter: 'Nyan',
                    run: true
                }
            },
        },

        uglify: {
            concat: {
                options: {
                    banner: '<%= pkg.banner %>',
                    beautify: true
                },
                files: {
                    'dist/js/<%= pkg.name %>.js': ['js/**/*.js']
                }
                },
                minify: {
                options: {
                    banner: '<%= pkg.banner %>',
                    compress: true,
                    report: 'min'
                },
                files: {
                    'dist/js/<%= pkg.name %>.min.js': ['js/**/*.js']
                }
            }
        },

        asciify: {
            banner:{
            text: '<%= pkg.name %>',
            options: {
                font: 'univers',
                log: true
            }
            },
        },

        copy: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '',
                    src: [
                        'fonts/**/*',
                        'images/**/*',
                        'libs/**/*',
                        'views/pulsar/**/*',
                        'src/**/*'
                    ],
                    dest: 'dist/'
                }]
            }
        },

        clean: {
            dist: ['dist'],
            favicons: ['views/pulsar/components/favicons-*.html'],
            smoketest: ['tmp/failures/*']
        },

        bump: {
            options: {
                updateConfigs: ['pkg'],
                files: ['pulsar.json', 'package.json', 'VERSION'],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['-a'],
                createTag: true,
                tagName: '%VERSION%',
                push: true,
                pushTo: 'origin'
            }
        },

        exec: {
            phantomcss: {
                cmd: 'phantomjs tests/css/testsuite.js'
            },
            updateComposer: {
                cmd: 'sudo php composer.phar update'
            },
            updateBrew: {
                cmd: 'brew update && brew upgrade'
            },
            updateBower: {
                cmd: 'bower update'
            },
            updateGems: {
                cmd: 'sudo gem update'
            },
            updateNpm: {
                cmd: 'sudo npm install'
            },
            fixProximaNova: {
                cmd: 'git update-index --skip-worktree fonts/_config.fonts.scss'
            }
        },

        realFavicon: {
            options: {
                settings: {
                    scalingAlgorithm: 'Mitchell',
                    errorOnImageTooSmall: false
                }
            },
            cms: {
                src: 'images/branding/jadu-central-logomark.svg',
                dest: 'images/favicons/cms',
                options: {
                    iconsPath: '/jadu/bundles/pulsar/images/favicons/cms/',
                    html: [ 'views/pulsar/components/favicons-cms.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#15a6d1',
                            onConflict: 'override'
                        }
                    }
                }
            },
            xfp: {
                src: 'images/branding/jadu-central-logomark.svg',
                dest: 'images/favicons/xfp',
                options: {
                    iconsPath: '/images/favicons/xfp/',
                    html: [ 'views/pulsar/components/favicons-xfp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#80BA27',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cxm: {
                src: 'images/branding/jadu-connect-logomark.svg',
                dest: 'images/favicons/cxm',
                options: {
                    iconsPath: '/images/favicons/cxm/',
                    html: [ 'views/pulsar/components/favicons-cxm.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#54B9A9',
                            onConflict: 'override'
                        }
                    }
                }
            },
            cp: {
                src: 'images/favicons/src/favicon-cp.svg',
                dest: 'images/favicons/cp',
                options: {
                    iconsPath: '/images/favicons/cp/',
                    html: [ 'views/pulsar/components/favicons-cp.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#ffffff',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#ffffff',
                            themeColor: '#ffffff',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'whiteSilhouette',
                            backgroundColor: '#DC5172',
                            onConflict: 'override'
                        }
                    }
                }
            },
            deployer: {
                src: 'images/favicons/src/favicon-deployer.svg',
                dest: 'images/favicons/deployer',
                options: {
                    iconsPath: '/images/favicons/deployer/',
                    html: [ 'views/pulsar/components/favicons-deployer.html' ],
                    design: {
                        ios: {
                            pictureAspect: 'backgroundAndMargin',
                            backgroundColor: '#3d4796',
                            margin: '14%'
                        },
                        desktopBrowser: {},
                        androidChrome: {
                            pictureAspect: 'backgroundAndMargin',
                            margin: '17%',
                            backgroundColor: '#3d4796',
                            themeColor: '#3d4796',
                            manifest: {
                                name: 'Continuum',
                                display: 'browser',
                                orientation: 'notSet',
                                onConflict: 'override'
                            }
                        },
                        windows: {
                            pictureAspect: 'noChange',
                            backgroundColor: '#3d4796',
                            onConflict: 'override'
                        }
                    }
                }
            }
        },

        compress: {
            dist: {
                options: {
                    archive: 'pulsar.zip'
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**/*']
                }]
            }
        },

        browserSync: {
            files: [
                'css/*',
                'dist/**/*',
                'images/**/*',
                'views/**/*'
            ],
            options: {
                proxy: 'http://localhost:9000/app/app.php/lexicon',
                reloadOnRestart: true,
                watchTask: true
            }
	    }

    });

    grunt.config.set('leadingIndent.indentation', 'spaces');

    grunt.config.set('leadingIndent.files', {
        src : [
            'css/**/*',
            'js/**/*',
            'src/**/*',
            'stylesheets/**/*',
            'tests/**/*',
            'views/**/*'
        ]
    });

    grunt.registerTask('default', [
        'copy',
        'scsslint',
        'sass:dev',
        'sass:lexicon',
        'autoprefixer',
        'browserify:dev',
        'browserify:lexicon',
        'browserSync',
        'watch'
    ]);

    grunt.registerTask('post-merge', [
        'exec:fixProximaNova',
        'sass:dev',
        'browserify'
    ]);

    grunt.registerTask('build', [
        'scsslint',
        'sass:dist',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('deploy', [
        'sass:dist',
        'autoprefixer',
        'browserify:dist',
        'copy:dist',
        'compress'
    ]);

    grunt.registerTask('favicons', [
        'clean:favicons',
        'realFavicon'
    ]);

    grunt.registerTask('update', [
        'exec:updateComposer',
        'exec:updateBrew',
        'exec:updateBower',
        'exec:updateGems',
        'exec:updateNpm'
    ]);

    grunt.registerTask('javascript:tests', [
        'browserify:browserTests',
    ]);

    grunt.registerTask('javascript:tests:watch', [
        'browserify:browserTests',
        'watch:tests'
    ]);

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

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  this.registerTask('default', ['test']);

  this.registerTask('dist', 'Builds a distributable version of Ember Simple Auth', [
    'lint',
    'build',
    'docs',
    'copy:dist'
  ]);

  this.registerTask('build', 'Builds Ember Simple Auth', [
    'clean',
    'transpile:amd',
    'concat:amd',
    'concat:browser'
  ]);

  this.registerTask('build_tests', "Builds Ember Simple Auth's tests", [
    'build',
    'transpile:tests',
    'concat:tests',
  ]);

  this.registerTask('lint', 'Applies all the JSHint/spacing rules', [
    'jshint',
    'lintspaces'
  ]);

  this.registerTask('server', 'Runs a development server', [
    'build_tests',
    'connect:dev',
    'watch'
  ]);

  this.registerTask('test', 'Executes the tests', [
    'lint',
    'build_tests',
    'connect:dev',
    'mocha'
  ]);

  this.registerTask('docs', 'Builds the documentation', [
    'yuidoc',
    'compile-handlebars'
  ]);

  this.registerTask('copy:dist', 'Copies all distribution files to /dist', [
    'copy:plain_download',
    'copy:plain_bower',
    'copy:amd_download',
    'copy:amd_bower',
    'copy:docs'
  ]);

  var packages = grunt.file.expand('packages/*/package.json').reduce(function(acc, package) {
    var packageContents = grunt.file.readJSON(package);
    acc.push(packageContents);
    return acc;
  }, []);

  grunt.initConfig({
    connect: {
      dev:{
        server: {},
        options: {
          hostname: '0.0.0.0',
          port: grunt.option('port') || 8000,
          base: '.',
          middleware: function(connect, options) {
            return [
              connect.logger('short'),
              connect.json(),
              connect.query(),
              require('body-parser')(),
              require('connect-redirection')(),
              function(request, response, next) {
                if (request.url === '/') {
                  response.redirect('/examples');
                } else {
                  next();
                }
              },
              require('./examples/middleware'),
              connect.static(options.base)
            ];
          }
        }
      }
    },

    watch: {
      files: ['packages/**/*'],
      tasks: ['build_tests', 'lint']
    },

    transpile: {
      amd: {
        type: 'amd',
        files: packages.map(function(pkg) {
          return {
            expand: true,
            cwd: 'packages/' + pkg.name + '/lib/',
            src: ['**/*.js'],
            dest: 'tmp/libs'
          };
        })
      },
      tests: {
        type: 'amd',
        files: packages.map(function(pkg) {
          return {
            expand: true,
            cwd: 'packages/' + pkg.name + '/',
            src: ['tests/' + pkg.main + '/**/*.js'],
            dest: 'tmp/tests/' + pkg.name
          };
        })
      }
    },

    concat: {
      amd: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '.amd.js'] = ['tmp/libs/' + pkg.main + '.js', 'tmp/libs/' + pkg.main + '/**/*.js'];
          });
          return files;
        })()
      },
      browser: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '.js'] = ['packages/' + pkg.name + '/wrap/browser.start', 'vendor/loader.js', 'tmp/libs/' + pkg.main + '.js', 'tmp/libs/' + pkg.main + '/**/*.js', 'packages/' + pkg.name + '/wrap/browser.end'];
          });
          return files;
        })()
      },
      tests: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '-tests.amd.js'] = ['tmp/tests/' + pkg.name + '/**/*.js'];
          });
          return files;
        })()
      }
    },

    copy: {
      plain_download: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.js'],
            dest: 'dist/download/' + pkg.name + '-' + pkg.version + '.js'
          };
        })
      },
      plain_bower: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.js'],
            dest: 'dist/bower/' + pkg.main + '.js'
          };
        })
      },
      amd_download: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.amd.js'],
            dest: 'dist/download/' + pkg.name + '-' + pkg.version + '.amd.js'
          };
        })
      },
      amd_bower: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.amd.js'],
            dest: 'dist/bower/' + pkg.main + '.amd.js'
          };
        })
      },
      docs: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/docs/' + pkg.name + '/api.html'],
            dest: 'dist/docs/' + pkg.name + '-api-docs.html'
          };
        })
      }
    },

    jshint: {
      library: 'packages/*/lib/**/*.js',
      options: {
        jshintrc: '.jshintrc'
      },
      tests: {
        files: {
          src: ['packages/*/tests/**/*.js']
        },
        options: {
          jshintrc: '.jshintrc-tests'
        }
      }
    },

    clean: ['dist', 'tmp'],

    lintspaces: {
      all: {
        src: [
          'docs/theme/**/*',
          'examples/*',
          'packages/**/*',
          'test/lib/**/*',
          'test/index.html',
          'wrap/**/*'
        ],
        options: {
          newline: true,
          trailingspaces: true,
          indentation: 'spaces',
          spaces: 2
        }
      }
    },

    mocha: {
      test: {
        options: {
          run: true,
          reporter: process.env.REPORTER || 'Spec',
          urls: function() {
            var bundle = process.env.BUNDLE || '';
            return [
              'http://localhost:8000/test/index.html?' + bundle
            ]
          }()
        }
      }
    },

    yuidoc: packages.reduce(function(acc, pkg) {
      acc[pkg.name] = {
        name: pkg.name,
        description: pkg.description,
        version: pkg.version,
        options: {
          parseOnly: true,
          paths: 'packages/' + pkg.name,
          outdir: 'tmp/docs/' + pkg.name
        }
      };
      return acc;
    }, {}),

    'compile-handlebars': packages.reduce(function(acc, pkg) {
      acc[pkg.name] = {
        template: 'docs/theme/main.hbs',
        templateData: 'tmp/docs/' + pkg.name +  '/data.json',
        globals: ['docs/config.json', 'packages/' + pkg.name + '/package.json'],
        partials: 'docs/theme/partials/**/*.hbs',
        helpers: 'docs/theme/helpers/**/*.js',
        output: 'tmp/docs/' + pkg.name + '/api.html'
      }
      return acc;
    }, {})
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-es6-module-transpiler');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-compile-handlebars');
  grunt.loadNpmTasks('grunt-lintspaces');
};
<commit_msg>fixed deprecation warning in Gruntfile<commit_after>module.exports = function(grunt) {
  this.registerTask('default', ['test']);

  this.registerTask('dist', 'Builds a distributable version of Ember Simple Auth', [
    'lint',
    'build',
    'docs',
    'copy:dist'
  ]);

  this.registerTask('build', 'Builds Ember Simple Auth', [
    'clean',
    'transpile:amd',
    'concat:amd',
    'concat:browser'
  ]);

  this.registerTask('build_tests', "Builds Ember Simple Auth's tests", [
    'build',
    'transpile:tests',
    'concat:tests',
  ]);

  this.registerTask('lint', 'Applies all the JSHint/spacing rules', [
    'jshint',
    'lintspaces'
  ]);

  this.registerTask('server', 'Runs a development server', [
    'build_tests',
    'connect:dev',
    'watch'
  ]);

  this.registerTask('test', 'Executes the tests', [
    'lint',
    'build_tests',
    'connect:dev',
    'mocha'
  ]);

  this.registerTask('docs', 'Builds the documentation', [
    'yuidoc',
    'compile-handlebars'
  ]);

  this.registerTask('copy:dist', 'Copies all distribution files to /dist', [
    'copy:plain_download',
    'copy:plain_bower',
    'copy:amd_download',
    'copy:amd_bower',
    'copy:docs'
  ]);

  var packages = grunt.file.expand('packages/*/package.json').reduce(function(acc, package) {
    var packageContents = grunt.file.readJSON(package);
    acc.push(packageContents);
    return acc;
  }, []);

  grunt.initConfig({
    connect: {
      dev:{
        server: {},
        options: {
          hostname: '0.0.0.0',
          port: grunt.option('port') || 8000,
          base: '.',
          middleware: function(connect, options) {
            return [
              connect.logger('short'),
              connect.json(),
              connect.query(),
              require('body-parser').urlencoded({ extended: true }),
              require('body-parser').json(),
              require('connect-redirection')(),
              function(request, response, next) {
                if (request.url === '/') {
                  response.redirect('/examples');
                } else {
                  next();
                }
              },
              require('./examples/middleware'),
              connect.static(options.base)
            ];
          }
        }
      }
    },

    watch: {
      files: ['packages/**/*'],
      tasks: ['build_tests', 'lint']
    },

    transpile: {
      amd: {
        type: 'amd',
        files: packages.map(function(pkg) {
          return {
            expand: true,
            cwd: 'packages/' + pkg.name + '/lib/',
            src: ['**/*.js'],
            dest: 'tmp/libs'
          };
        })
      },
      tests: {
        type: 'amd',
        files: packages.map(function(pkg) {
          return {
            expand: true,
            cwd: 'packages/' + pkg.name + '/',
            src: ['tests/' + pkg.main + '/**/*.js'],
            dest: 'tmp/tests/' + pkg.name
          };
        })
      }
    },

    concat: {
      amd: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '.amd.js'] = ['tmp/libs/' + pkg.main + '.js', 'tmp/libs/' + pkg.main + '/**/*.js'];
          });
          return files;
        })()
      },
      browser: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '.js'] = ['packages/' + pkg.name + '/wrap/browser.start', 'vendor/loader.js', 'tmp/libs/' + pkg.main + '.js', 'tmp/libs/' + pkg.main + '/**/*.js', 'packages/' + pkg.name + '/wrap/browser.end'];
          });
          return files;
        })()
      },
      tests: {
        files: (function() {
          var files = {};
          packages.forEach(function(pkg) {
            files['tmp/' + pkg.name + '-tests.amd.js'] = ['tmp/tests/' + pkg.name + '/**/*.js'];
          });
          return files;
        })()
      }
    },

    copy: {
      plain_download: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.js'],
            dest: 'dist/download/' + pkg.name + '-' + pkg.version + '.js'
          };
        })
      },
      plain_bower: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.js'],
            dest: 'dist/bower/' + pkg.main + '.js'
          };
        })
      },
      amd_download: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.amd.js'],
            dest: 'dist/download/' + pkg.name + '-' + pkg.version + '.amd.js'
          };
        })
      },
      amd_bower: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/' + pkg.name + '.amd.js'],
            dest: 'dist/bower/' + pkg.main + '.amd.js'
          };
        })
      },
      docs: {
        files: packages.map(function(pkg) {
          return {
            src: ['tmp/docs/' + pkg.name + '/api.html'],
            dest: 'dist/docs/' + pkg.name + '-api-docs.html'
          };
        })
      }
    },

    jshint: {
      library: 'packages/*/lib/**/*.js',
      options: {
        jshintrc: '.jshintrc'
      },
      tests: {
        files: {
          src: ['packages/*/tests/**/*.js']
        },
        options: {
          jshintrc: '.jshintrc-tests'
        }
      }
    },

    clean: ['dist', 'tmp'],

    lintspaces: {
      all: {
        src: [
          'docs/theme/**/*',
          'examples/*',
          'packages/**/*',
          'test/lib/**/*',
          'test/index.html',
          'wrap/**/*'
        ],
        options: {
          newline: true,
          trailingspaces: true,
          indentation: 'spaces',
          spaces: 2
        }
      }
    },

    mocha: {
      test: {
        options: {
          run: true,
          reporter: process.env.REPORTER || 'Spec',
          urls: function() {
            var bundle = process.env.BUNDLE || '';
            return [
              'http://localhost:8000/test/index.html?' + bundle
            ]
          }()
        }
      }
    },

    yuidoc: packages.reduce(function(acc, pkg) {
      acc[pkg.name] = {
        name: pkg.name,
        description: pkg.description,
        version: pkg.version,
        options: {
          parseOnly: true,
          paths: 'packages/' + pkg.name,
          outdir: 'tmp/docs/' + pkg.name
        }
      };
      return acc;
    }, {}),

    'compile-handlebars': packages.reduce(function(acc, pkg) {
      acc[pkg.name] = {
        template: 'docs/theme/main.hbs',
        templateData: 'tmp/docs/' + pkg.name +  '/data.json',
        globals: ['docs/config.json', 'packages/' + pkg.name + '/package.json'],
        partials: 'docs/theme/partials/**/*.hbs',
        helpers: 'docs/theme/helpers/**/*.js',
        output: 'tmp/docs/' + pkg.name + '/api.html'
      }
      return acc;
    }, {})
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-es6-module-transpiler');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-compile-handlebars');
  grunt.loadNpmTasks('grunt-lintspaces');
};
<|endoftext|>


<commit_before>const _ = require('lodash')
const fs = require('fs')
const resolve = require('resolve-dir')

// generic experimentId matcher. index 2: experimentId, 3 or 4: experimentName
const expIdRegex = /(\-e\s+)?(([a-zA-Z0-9_]+)\-\d{4}_\d{2}_\d{2}_\d{6}|([a-zA-Z0-9_]+))/
const historyPath = './config/history.json'
const finishMsg = `
===========================================
Experiments complete. Press Ctrl+C to exit.
===========================================
`

module.exports = function(grunt) {
  process.env.NODE_ENV = grunt.option('prod') ? 'production' : 'development'

  const config = require('config')
  const dataSrc = 'data'
  const dataDest = resolve(config.data_sync_destination)
  const experiments = config.experiments
  const experimentTasks = _.map(experiments, function(name) {
    return `shell:experiment:${name}`
  })

  function writeHistory(history) {
    fs.writeFileSync(historyPath, JSON.stringify(history, null, 2))
    return history
  }

  function readHistory() {
    if (grunt.option('resume')) {
      try {
        return JSON.parse(fs.readFileSync(historyPath, 'utf8'))
      } catch (err) {
        grunt.log.ok(`No existing ${historyPath} to resume, creating new`)
        return writeHistory({})
      }
    } else {
      return {}
    }
  }

  let history = readHistory()

  function updateHistory(filepath) {
    if (fs.lstatSync(filepath).isFile()) {
      // only interested in data folder, skip otherwise
      return
    }
    const matchedPath = filepath.split('/').pop().match(expIdRegex)
    if (matchedPath) {
      const experimentId = matchedPath[2]
      const experimentName = matchedPath[3] || matchedPath[4]
      history[experimentName] = experimentId
      writeHistory(history)
    }
  }

  function remoteCmd() {
    return (grunt.option('remote')) ? 'xvfb-run -a -s "-screen 0 1400x900x24" --' : ''
  }

  function plotCmd() {
    return grunt.option('plotOnly') ? ' -a' : ''
  }

  function notiCmd(experiment) {
    return (grunt.option('prod') && !grunt.option('plotOnly')) ? `NOTI_SLACK_DEST='${config.NOTI_SLACK_DEST}' NOTI_SLACK_TOK='${config.NOTI_SLACK_TOK}' noti -k -t 'Experiment completed' -m '[${new Date().toISOString()}] ${experiment} on ${process.env.USER}'` : ''
  }

  function resumeExperimentStr(eStr) {
    const matchedExp = eStr.match(expIdRegex)
    if (matchedExp) {
      const experimentIdOrName = matchedExp[2]
      const experimentName = matchedExp[3] || matchedExp[4]
      if (history[experimentName]) {
        return eStr.replace(experimentIdOrName, history[experimentName])
      }
    }
    return eStr
  }

  function composeCommand(experimentStr) {
    var eStr = experimentStr
    if (grunt.option('resume')) {
      eStr = resumeExperimentStr(eStr)
    }

    // override with custom command if has 'python'
    var pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py -bgp -e ${eStr} -t 5${plotCmd()}`
    const cmd = `${remoteCmd()} ${pyCmd} | tee -a ./data/terminal.log; ${notiCmd(eStr)}`
    grunt.log.ok(`Composed command: ${cmd}`)
    return cmd
  }

  require('load-grunt-tasks')(grunt)

  grunt.initConfig({
    sync: {
      main: {
        files: [{
          cwd: dataSrc,
          src: ['**'],
          dest: dataDest,
        }],
        pretend: !grunt.option('prod'), // Don't do real IO
      }
    },

    watch: {
      data: {
        files: `${dataSrc}/**`,
        tasks: ['sync'],
        options: {
          debounceDelay: 60000,
          interval: 60000,
        },
      }
    },

    shell: {
      options: {
        execOptions: {
          killSignal: 'SIGINT',
          env: process.env
        }
      },
      experiment: {
        command(experimentStr) {
          return composeCommand(experimentStr)
        },
        options: {
          stdout: true
        }
      },
      finish: `echo "${finishMsg}"`,
      clear: 'rm -rf .cache __pycache__ */__pycache__ *egg-info htmlcov .coverage data/**/ data/*.log config/history.json',
    },

    concurrent: {
      default: ['watch', ['lab', 'shell:finish']],
      options: {
        logConcurrentOutput: true
      }
    },
  })

  grunt.event.on('watch', function(action, filepath) {
    updateHistory(filepath)
  })

  grunt.registerTask('lab', 'run all the experiments', experimentTasks)
  grunt.registerTask('lab_sync', 'run lab with auto file syncing', ['concurrent:default'])
  grunt.registerTask('default', ['lab_sync'])

  grunt.registerTask('plot', function() {
    grunt.option('plotOnly', true)
    grunt.option('resume', true)
    grunt.task.run('default')
  })
  grunt.registerTask('clear', ['shell:clear'])
}
<commit_msg>be explicit and use json as history detection<commit_after>const _ = require('lodash')
const fs = require('fs')
const resolve = require('resolve-dir')

// generic experimentId matcher. index 2: experimentId, 3 or 4: experimentName
const expIdRegex = /(\-e\s+)?(([a-zA-Z0-9_]+)\-\d{4}_\d{2}_\d{2}_\d{6}|([a-zA-Z0-9_]+))/
const historyPath = './config/history.json'
const finishMsg = `
===========================================
Experiments complete. Press Ctrl+C to exit.
===========================================
`

module.exports = function(grunt) {
  process.env.NODE_ENV = grunt.option('prod') ? 'production' : 'development'

  const config = require('config')
  const dataSrc = 'data'
  const dataDest = resolve(config.data_sync_destination)
  const experiments = config.experiments
  const experimentTasks = _.map(experiments, function(name) {
    return `shell:experiment:${name}`
  })

  function writeHistory(history) {
    grunt.log.ok(`Writing updated lab history ${JSON.stringify(history, null, 2)}`)
    fs.writeFileSync(historyPath, JSON.stringify(history, null, 2))
    return history
  }

  function readHistory() {
    if (grunt.option('resume')) {
      try {
        return JSON.parse(fs.readFileSync(historyPath, 'utf8'))
      } catch (err) {
        grunt.log.ok(`No existing ${historyPath} to resume, creating new`)
        return writeHistory({})
      }
    } else {
      return {}
    }
  }

  let history = readHistory()

  function updateHistory(filepath) {
    if (fs.lstatSync(filepath).isFile() && _.endsWith(filepath, '.json')) {
      filepath = _.join(_.initial(filepath.split('_')), '_')
    } else {
      return
    }
    const matchedPath = filepath.split('/').pop().match(expIdRegex)
    if (matchedPath) {
      const experimentId = matchedPath[2]
      const experimentName = matchedPath[3] || matchedPath[4]
      history[experimentName] = experimentId
      writeHistory(history)
    }
  }

  function remoteCmd() {
    return (grunt.option('remote')) ? 'xvfb-run -a -s "-screen 0 1400x900x24" --' : ''
  }

  function plotCmd() {
    return grunt.option('plotOnly') ? ' -a' : ''
  }

  function notiCmd(experiment) {
    return (grunt.option('prod') && !grunt.option('plotOnly')) ? `NOTI_SLACK_DEST='${config.NOTI_SLACK_DEST}' NOTI_SLACK_TOK='${config.NOTI_SLACK_TOK}' noti -k -t 'Experiment completed' -m '[${new Date().toISOString()}] ${experiment} on ${process.env.USER}'` : ''
  }

  function resumeExperimentStr(eStr) {
    const matchedExp = eStr.match(expIdRegex)
    if (matchedExp) {
      const experimentIdOrName = matchedExp[2]
      const experimentName = matchedExp[3] || matchedExp[4]
      if (history[experimentName]) {
        return eStr.replace(experimentIdOrName, history[experimentName])
      }
    }
    return eStr
  }

  function composeCommand(experimentStr) {
    var eStr = experimentStr
    if (grunt.option('resume')) {
      eStr = resumeExperimentStr(eStr)
    }

    // override with custom command if has 'python'
    var pyCmd = _.includes(eStr, 'python') ? eStr : `python3 main.py -bgp -e ${eStr} -t 5${plotCmd()}`
    const cmd = `${remoteCmd()} ${pyCmd} | tee -a ./data/terminal.log; ${notiCmd(eStr)}`
    grunt.log.ok(`Composed command: ${cmd}`)
    return cmd
  }

  require('load-grunt-tasks')(grunt)

  grunt.initConfig({
    sync: {
      main: {
        files: [{
          cwd: dataSrc,
          src: ['**'],
          dest: dataDest,
        }],
        pretend: !grunt.option('prod'), // Don't do real IO
      }
    },

    watch: {
      data: {
        files: `${dataSrc}/**`,
        tasks: ['sync'],
        options: {
          debounceDelay: 60000,
          interval: 60000,
        },
      }
    },

    shell: {
      options: {
        execOptions: {
          killSignal: 'SIGINT',
          env: process.env
        }
      },
      experiment: {
        command(experimentStr) {
          return composeCommand(experimentStr)
        },
        options: {
          stdout: true
        }
      },
      finish: `echo "${finishMsg}"`,
      clear: 'rm -rf .cache __pycache__ */__pycache__ *egg-info htmlcov .coverage data/**/ data/*.log config/history.json',
    },

    concurrent: {
      default: ['watch', ['lab', 'shell:finish']],
      options: {
        logConcurrentOutput: true
      }
    },
  })

  grunt.event.on('watch', function(action, filepath) {
    updateHistory(filepath)
  })

  grunt.registerTask('lab', 'run all the experiments', experimentTasks)
  grunt.registerTask('lab_sync', 'run lab with auto file syncing', ['concurrent:default'])
  grunt.registerTask('default', ['lab_sync'])

  grunt.registerTask('plot', function() {
    grunt.option('plotOnly', true)
    grunt.option('resume', true)
    grunt.task.run('default')
  })
  grunt.registerTask('clear', ['shell:clear'])
}
<|endoftext|>


<commit_before>module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

    sass: {
      dist: {

        files: {
          'css/app.css': 'scss/app.scss'
        }
      }
    },

    watch: {
            grunt: { files: ['Gruntfile.js'] },
      sass: {
        files: 'scss/*.scss',
        tasks: ['sass'],
      }

    }
    });

    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('build', ['sass' , 'watch']);
};
<commit_msg>Code format<commit_after>module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        sass: {
          dist: {
            files: {
              'css/app.css': 'scss/app.scss'
            }
          }
        },

        watch: {
                grunt: { files: ['Gruntfile.js'] },
          sass: {
            files: 'scss/*.scss',
            tasks: ['sass'],
          }
        }

     });

    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');

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


<commit_before>'use strict';

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

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

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

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

		//
		// Meta
		//

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

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

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

		// Original Task configuration.
/*		concat: {
			options: {
				banner: '<%= banner %>',
				stripBanners: true
			},
			dist: {
			src: ['lib/<%= pkg.name %>.js'],
			dest: 'dist/<%= pkg.name %>.js'
			}
		},
		uglify: {
			options: {
				banner: '<%= banner %>'
			},
			dist: {
				src: '<%= concat.dist.dest %>',
				dest: 'dist/<%= pkg.name %>.min.js'
			}
		}
*/

		//
		// Server Related Tasks
		//

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

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

		//
		// JS Tasks
		//

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

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

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

		//
		// CSS Tasks
		//

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

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

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

		//
		// Housekeeping
		//

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

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

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

	});

	//
	// Tasks Registry
	//

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

	/**
	 * Build task
	 * Run `grunt build` on the command line
	 * Then compress all JS/CSS files
	 */
	grunt.registerTask('build', ['sass:dev', 'autoprefixer:dev', 'cssmin:build', 'concat:dev', 'jshint', 'uglify', 'copy:build']);
};
<commit_msg>enabling Sass sourcemap<commit_after>'use strict';

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

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

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

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

		//
		// Meta
		//

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

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

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

		// Original Task configuration.
/*		concat: {
			options: {
				banner: '<%= banner %>',
				stripBanners: true
			},
			dist: {
			src: ['lib/<%= pkg.name %>.js'],
			dest: 'dist/<%= pkg.name %>.js'
			}
		},
		uglify: {
			options: {
				banner: '<%= banner %>'
			},
			dist: {
				src: '<%= concat.dist.dest %>',
				dest: 'dist/<%= pkg.name %>.min.js'
			}
		}
*/

		//
		// Server Related Tasks
		//

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

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

		//
		// JS Tasks
		//

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

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

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

		//
		// CSS Tasks
		//

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

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

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

		//
		// Housekeeping
		//

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

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

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

	});

	//
	// Tasks Registry
	//

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

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


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    umd: {
      intercooler: {
        options: {
          src: 'src/intercooler.js',
          dest: 'www/release/intercooler-<%= pkg.version %>.js',
          amdModuleId: 'intercooler', // The `require('intercooler')` id used to import, lower-case name is traditional
          objectToExport: 'Intercooler',
          globalAlias: 'Intercooler', // Always force an Intercooler object
          deps: {
              'default': [{jquery: '$'}],
              amd: [{jquery: '$'}],
              cjs: [{jquery: '$'}],
              global: [{jQuery: '$'}] // Capital Q because that is how jQuery is in the global scope unlike the others
          }
        }
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %>  <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'www/release/intercooler-<%= pkg.version %>.js',
        dest: 'www/release/intercooler-<%= pkg.version %>.min.js'
      }
    },
    "regex-replace": {
      "update-test-ref": { //specify a target with any name
        src: ['www/release/unit-tests-<%= pkg.version %>.html'],
        actions: [
          {
            name: 'lib ref',
            search: "../src/intercooler.js",
            replace: './intercooler-<%= pkg.version %>.js',
            flags: 'g'
          }
        ]
      }
    }
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-regex-replace');
  grunt.loadNpmTasks('grunt-umd');

  grunt.registerTask('dist', "Copy Distribution files", function () {
    grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.js', 'dist/intercooler.js');
    grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.min.js', 'dist/intercooler.min.js');
  });

  grunt.registerTask('release', "Releases a new version of the library", function () {
    grunt.file.copy("src/intercooler-debugger.js", 'www/release/intercooler-debugger.js');
    grunt.file.copy("test/blanket.min.js", 'www/release/blanket.min.js');
    grunt.file.copy("test/jquery.mockjax.js", 'www/release/jquery.mockjax.js');
    grunt.file.copy("test/unit_tests.html", 'www/release/unit-tests-' + grunt.config.get('pkg').version + '.html');
    grunt.task.run('umd:intercooler');
    grunt.task.run('uglify');
    grunt.task.run('regex-replace');
    grunt.task.run('dist');
  });

  // Default task(s).
  grunt.registerTask('default', ['release']);

};
<commit_msg>Changed AMD name to use it from file<commit_after>module.exports = function (grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    umd: {
      intercooler: {
        options: {
          src: 'src/intercooler.js',
          dest: 'www/release/intercooler-<%= pkg.version %>.js',
          // amdModuleId: 'intercooler', // The `require('intercooler')` id used to import, lower-case name is traditional
          objectToExport: 'Intercooler',
          globalAlias: 'Intercooler', // Always force an Intercooler object
          deps: {
              'default': [{jquery: '$'}],
              amd: [{jquery: '$'}],
              cjs: [{jquery: '$'}],
              global: [{jQuery: '$'}] // Capital Q because that is how jQuery is in the global scope unlike the others
          }
        }
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %>  <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'www/release/intercooler-<%= pkg.version %>.js',
        dest: 'www/release/intercooler-<%= pkg.version %>.min.js'
      }
    },
    "regex-replace": {
      "update-test-ref": { //specify a target with any name
        src: ['www/release/unit-tests-<%= pkg.version %>.html'],
        actions: [
          {
            name: 'lib ref',
            search: "../src/intercooler.js",
            replace: './intercooler-<%= pkg.version %>.js',
            flags: 'g'
          }
        ]
      }
    }
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-regex-replace');
  grunt.loadNpmTasks('grunt-umd');

  grunt.registerTask('dist', "Copy Distribution files", function () {
    grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.js', 'dist/intercooler.js');
    grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.min.js', 'dist/intercooler.min.js');
  });

  grunt.registerTask('release', "Releases a new version of the library", function () {
    grunt.file.copy("src/intercooler-debugger.js", 'www/release/intercooler-debugger.js');
    grunt.file.copy("test/blanket.min.js", 'www/release/blanket.min.js');
    grunt.file.copy("test/jquery.mockjax.js", 'www/release/jquery.mockjax.js');
    grunt.file.copy("test/unit_tests.html", 'www/release/unit-tests-' + grunt.config.get('pkg').version + '.html');
    grunt.task.run('umd:intercooler');
    grunt.task.run('uglify');
    grunt.task.run('regex-replace');
    grunt.task.run('dist');
  });

  // Default task(s).
  grunt.registerTask('default', ['release']);

};
<|endoftext|>


<commit_before> /*
  * sublimetext-gruntfile.js
  * https://github.com/idleberg/sublimetext-gruntfile.js
  *
  * Copyright (c) 2014-2016 Jan T. Sott
  * Licensed under the MIT license.
  */

 module.exports = function(grunt) {

    var jsonFiles = [
        '**/*.JSON-sublime-syntax',
        '**/*.JSON-tmLanguage',
        '**/*.JSON-tmTheme',
        '**/*.sublime-build',
        '**/*.sublime-commands',
        '**/*.sublime-completions',
        '**/*.sublime-keymap',
        '**/*.sublime-macro',
        '**/*.sublime-menu',
        '**/*.sublime-settings',
        '**/*.sublime-theme',
        'messages.json',
        '!node_modules/**/*.*'
    ];

    var pyFiles = [
        '*.py'
    ];

    var ymlFiles = [
        '**/*.sublime-syntax',
        '**/*.YAML-tmLanguage',
        '**/*.YAML-tmTheme'
    ];

    var xmlFiles = [
        '**/*.plist',
        '**/*.PLIST-sublime-syntax',
        '**/*.PLIST-tmLanguage',
        '**/*.PLIST-tmTheme',
        '**/*.sublime-snippet',
        '**/*.tmCommand',
        '**/*.tmLanguage',
        '**/*.tmPreferences',
        '**/*.tmSnippet',
        '**/*.tmTheme',
        '**/*.xml',
        '*.bbcolors',
        '*.dvtcolortheme',
        '*.icls',
        '*.itermcolors',
        '*.terminal',
        '!node_modules/**/*.*'
    ];

    grunt.initConfig({

        // default task
        jsonlint: {
          files: {
            src: jsonFiles
          }
        },

        yamllint: {
            files: {
                src: ymlFiles
            },
        },

        xml_validator: {
            files: {
                src: xmlFiles
            },
        },

        // watch task
        watch: {
            json: {
                files: jsonFiles,
                tasks: ['jsonlint']
            },
            yml: {
                files: ymlFiles,
                tasks: ['yamllint']
            },
            xml: {
                files: xmlFiles,
                tasks: ['xml_validator']
            }
        },

        // pylint task, not yet part of default
        pylint: {
          files: {
            options: {
                errorsOnly: true
            },
            src: pyFiles
          }
        },

    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-jsonlint');
    grunt.loadNpmTasks('grunt-pylint');
    grunt.loadNpmTasks('grunt-yamllint');
    grunt.loadNpmTasks('grunt-xml-validator');
    grunt.registerTask('default', 'lint');

    // task shortcuts
    grunt.registerTask('json',   'jsonlint');
    grunt.registerTask('lint',  ['jsonlint', 'yamllint', 'xml_validator']);
    grunt.registerTask('py',     'pylint');
    grunt.registerTask('travis', 'lint');
    grunt.registerTask('xml',    'xml_validator');
 };<commit_msg>replace linter<commit_after><|endoftext|>