<commit_before>'use strict';

// Directory reference:
//   css: styles
//   sass: _scss
//   javascript: scripts
//   images: images
//   fonts: fonts

module.exports = function (grunt) {
  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  // Load all Grunt tasks
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    // Configurable paths
    yeoman: {
      app: 'app',
      dist: 'dist'
    },
    devUpdate: {
      check: {
        options: {
          reportUpdated: false,
          updateType: 'report'
        }
      }
    },
    watch: {
      sass: {
        files: ['<%= yeoman.app %>/_scss/**/*.scss'],
        tasks: ['sass', 'autoprefixer:server']
      },
      autoprefixer: {
        files: ['<%= yeoman.app %>/styles/**/*.css'],
        tasks: ['copy:stageCss', 'autoprefixer:server']
      },
      jekyll: {
        files: [
          '<%= yeoman.app %>/**/*.{html,rb,svg,xml,yml}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      }
    },
    browserSync: {
      server: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/styles/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      },
      dist: {
        options: {
          server: {
            baseDir: '<%= yeoman.dist %>'
          }
        }
      },
      test: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/styles/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= yeoman.dist %>/*',
            // Running Jekyll also cleans the target directory.  Exclude any
            // non-standard `keep_files` here (e.g., the generated files
            // directory from Jekyll Picture Tag).
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/generated' // Jekyll Picture Tag
          ]
        }]
      },
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    sass: {
      options: {
        bundleExec: true
      },
      dist: {
        files: {
          '.tmp/styles/application.css': '<%= yeoman.app %>/_scss/application.scss'
        }
      },
    },
    uncss: {
      options: {
        htmlroot: '.tmp',
        // 1. Ignored by UnCSS?
        // 2. Added by Google Search in 404.html
        // 3. Added by keyboardNavigation function in application.js
        ignore: [
          'b', // 2
          /#goog.+/, // 2
          /h[1-6](.+)?/, // 1
          /input(.+)?/, // 2
          /\.is-.+/, // 3
        ],
        report: 'min'
      },
      dist: {
        files: {'.tmp/concat/styles/application.css': ['<%= yeoman.dist %>/**/*.html']}
      }
    },
    autoprefixer: {
      options: {
        browsers: [
          'last 2 version',
          'safari 6',
          'ie 9',
          'opera 12.1',
          'ios 6',
          'android 4'
        ]
      },
      dist: {
        expand: true,
        cwd: '.tmp',
        src: 'concat/styles/*.css',
        dest: '.tmp'
      },
      server: {
        expand: true,
        cwd: '.tmp',
        src: 'styles/*.css',
        dest: '.tmp'
      }
    },
    jekyll: {
      options: {
        bundleExec: true,
        config: '_config.yml,_config.build.yml',
        src: '<%= yeoman.app %>'
      },
      dist: {
        options: {
          dest: '<%= yeoman.dist %>',
        }
      },
      server: {
        options: {
          config: '_config.yml',
          dest: '.jekyll'
        }
      },
      check: {
        options: {
          doctor: true
        }
      }
    },
    useminPrepare: {
      options: {
        dest: '<%= yeoman.dist %>'
      },
      html: '<%= yeoman.dist %>/index.html'
    },
    usemin: {
      options: {
        assetsDirs: '<%= yeoman.dist %>'
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/styles/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          removeComments: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true,
          keepClosingSlash: true,
          minifyCSS: true,
          minifyJS: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.html',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    // Usemin adds files to concat
    concat: {},
    // Usemin adds files to uglify
    uglify: {},
    // Usemin adds files to cssmin
    cssmin: {
      dist: {
        options: {
          check: 'min'
        }
      }
    },
    imageoptim: {
      options: {
        quitAfter: true
      },
      distLossless: {
        options: {
          jpegMini: false,
          imageAlpha: true
        },
        src: ['<%= yeoman.dist %>/*.{gif,png}','<%= yeoman.dist %>/generated/*.{gif,png}']
      },
      distLossy: {
        options: {
          jpegMini: true,
          imageAlpha: false
        },
        src: ['<%= yeoman.dist %>/*.{jpg,jpeg}','<%= yeoman.dist %>/generated/*.{jpg,jpeg}']
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    xmlmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.xml',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          src: [
            // Jekyll processes and moves HTML and text files
            // Usemin moves CSS and javascript inside of Usemin blocks
            // Copy moves asset files and directories
            'images/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore
            '!**/_*{,/**}',
            // Explicitly add any files your site needs for distribution here.
            'favicon*.{ico,png}'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      },
      // Copy CSS into .tmp directory for Autoprefixer processing
      stageCss: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/styles',
          src: '**/*.css',
          dest: '.tmp/styles'
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          remote: 'git@github.com:davidensinger/webworke.rs.git',
          branch: 'gh-pages',
          commit: true,
          push: true
        }
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/scripts/**/*.js',
            '<%= yeoman.dist %>/styles/**/*.css',
            '<%= yeoman.dist %>/images/**/*.{gif,jpg,jpeg,png,svg}',
            '!<%= yeoman.dist %>/images/originals/**/*.{gif,jpg,jpeg,png,svg}',
            '<%= yeoman.dist %>/fonts/**/*.{woff,woff2}'
          ]
        }]
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/**/*.js',
        'test/spec/**/*.js',
        '!<%= yeoman.app %>/scripts/_vendor/**/*'
      ]
    },
    pagespeed: {
      options: {
        locale: 'en_GB',
        nokey: true,
        url: 'http://webworke.rs'
      },
      desktop: {
        options: {
          strategy: 'desktop'
        }
      },
      mobile: {
        options: {
          strategy: 'mobile'
        }
      }
    },
    concurrent: {
      server: [
        'sass',
        'copy:stageCss',
        'jekyll:server'
      ],
      dist: [
        'sass',
        'copy:dist'
      ]
    }
  });

  // Define Tasks
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'browserSync:dist']);
    }

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

  // No real tests yet. Add your own.
  grunt.registerTask('test', [
  //   'clean:server',
  //   'concurrent:test',
  //   'connect:test'
  ]);

  grunt.registerTask('check', [
    'devUpdate',
    'clean:server',
    'jekyll:check',
    'jshint:all',
    'pagespeed'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    // Jekyll cleans files from the target directory, so must run first
    'jekyll:dist',
    'concurrent:dist',
    'useminPrepare',
    'concat',
    'uncss',
    'autoprefixer:dist',
    'cssmin',
    'uglify',
    'newer:imageoptim',
    'svgmin',
    'filerev',
    'usemin',
    'htmlmin',
    'xmlmin'
  ]);

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

  grunt.registerTask('default', [
    'check',
    'test',
    'build'
  ]);
};
<commit_msg>Move pagespeed out of check task and into its own perf task in Gruntfile.js<commit_after>'use strict';

// Directory reference:
//   css: styles
//   sass: _scss
//   javascript: scripts
//   images: images
//   fonts: fonts

module.exports = function (grunt) {
  // Show elapsed time after tasks run
  require('time-grunt')(grunt);
  // Load all Grunt tasks
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    // Configurable paths
    yeoman: {
      app: 'app',
      dist: 'dist'
    },
    devUpdate: {
      check: {
        options: {
          reportUpdated: false,
          updateType: 'report'
        }
      }
    },
    watch: {
      sass: {
        files: ['<%= yeoman.app %>/_scss/**/*.scss'],
        tasks: ['sass', 'autoprefixer:server']
      },
      autoprefixer: {
        files: ['<%= yeoman.app %>/styles/**/*.css'],
        tasks: ['copy:stageCss', 'autoprefixer:server']
      },
      jekyll: {
        files: [
          '<%= yeoman.app %>/**/*.{html,rb,svg,xml,yml}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      }
    },
    browserSync: {
      server: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/styles/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      },
      dist: {
        options: {
          server: {
            baseDir: '<%= yeoman.dist %>'
          }
        }
      },
      test: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/styles/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      }
    },
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '<%= yeoman.dist %>/*',
            // Running Jekyll also cleans the target directory.  Exclude any
            // non-standard `keep_files` here (e.g., the generated files
            // directory from Jekyll Picture Tag).
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/generated' // Jekyll Picture Tag
          ]
        }]
      },
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    sass: {
      options: {
        bundleExec: true
      },
      dist: {
        files: {
          '.tmp/styles/application.css': '<%= yeoman.app %>/_scss/application.scss'
        }
      },
    },
    uncss: {
      options: {
        htmlroot: '.tmp',
        // 1. Ignored by UnCSS?
        // 2. Added by Google Search in 404.html
        // 3. Added by keyboardNavigation function in application.js
        ignore: [
          'b', // 2
          /#goog.+/, // 2
          /h[1-6](.+)?/, // 1
          /input(.+)?/, // 2
          /\.is-.+/, // 3
        ],
        report: 'min'
      },
      dist: {
        files: {'.tmp/concat/styles/application.css': ['<%= yeoman.dist %>/**/*.html']}
      }
    },
    autoprefixer: {
      options: {
        browsers: [
          'last 2 version',
          'safari 6',
          'ie 9',
          'opera 12.1',
          'ios 6',
          'android 4'
        ]
      },
      dist: {
        expand: true,
        cwd: '.tmp',
        src: 'concat/styles/*.css',
        dest: '.tmp'
      },
      server: {
        expand: true,
        cwd: '.tmp',
        src: 'styles/*.css',
        dest: '.tmp'
      }
    },
    jekyll: {
      options: {
        bundleExec: true,
        config: '_config.yml,_config.build.yml',
        src: '<%= yeoman.app %>'
      },
      dist: {
        options: {
          dest: '<%= yeoman.dist %>',
        }
      },
      server: {
        options: {
          config: '_config.yml',
          dest: '.jekyll'
        }
      },
      check: {
        options: {
          doctor: true
        }
      }
    },
    useminPrepare: {
      options: {
        dest: '<%= yeoman.dist %>'
      },
      html: '<%= yeoman.dist %>/index.html'
    },
    usemin: {
      options: {
        assetsDirs: '<%= yeoman.dist %>'
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/styles/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          removeComments: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true,
          keepClosingSlash: true,
          minifyCSS: true,
          minifyJS: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.html',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    // Usemin adds files to concat
    concat: {},
    // Usemin adds files to uglify
    uglify: {},
    // Usemin adds files to cssmin
    cssmin: {
      dist: {
        options: {
          check: 'min'
        }
      }
    },
    imageoptim: {
      options: {
        quitAfter: true
      },
      distLossless: {
        options: {
          jpegMini: false,
          imageAlpha: true
        },
        src: ['<%= yeoman.dist %>/*.{gif,png}','<%= yeoman.dist %>/generated/*.{gif,png}']
      },
      distLossy: {
        options: {
          jpegMini: true,
          imageAlpha: false
        },
        src: ['<%= yeoman.dist %>/*.{jpg,jpeg}','<%= yeoman.dist %>/generated/*.{jpg,jpeg}']
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    xmlmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.xml',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          src: [
            // Jekyll processes and moves HTML and text files
            // Usemin moves CSS and javascript inside of Usemin blocks
            // Copy moves asset files and directories
            'images/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore
            '!**/_*{,/**}',
            // Explicitly add any files your site needs for distribution here.
            'favicon*.{ico,png}'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      },
      // Copy CSS into .tmp directory for Autoprefixer processing
      stageCss: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/styles',
          src: '**/*.css',
          dest: '.tmp/styles'
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          remote: 'git@github.com:davidensinger/webworke.rs.git',
          branch: 'gh-pages',
          commit: true,
          push: true
        }
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/scripts/**/*.js',
            '<%= yeoman.dist %>/styles/**/*.css',
            '<%= yeoman.dist %>/images/**/*.{gif,jpg,jpeg,png,svg}',
            '!<%= yeoman.dist %>/images/originals/**/*.{gif,jpg,jpeg,png,svg}',
            '<%= yeoman.dist %>/fonts/**/*.{woff,woff2}'
          ]
        }]
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/**/*.js',
        'test/spec/**/*.js',
        '!<%= yeoman.app %>/scripts/_vendor/**/*'
      ]
    },
    pagespeed: {
      options: {
        locale: 'en_GB',
        nokey: true,
        url: 'http://webworke.rs'
      },
      desktop: {
        options: {
          strategy: 'desktop'
        }
      },
      mobile: {
        options: {
          strategy: 'mobile'
        }
      }
    },
    concurrent: {
      server: [
        'sass',
        'copy:stageCss',
        'jekyll:server'
      ],
      dist: [
        'sass',
        'copy:dist'
      ]
    }
  });

  // Define Tasks
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'browserSync:dist']);
    }

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

  grunt.registerTask('check', [
    'devUpdate',
    'clean:server',
    'jekyll:check',
    'jshint:all'
  ]);

  grunt.registerTask('perf', [
    'pagespeed'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    // Jekyll cleans files from the target directory, so must run first
    'jekyll:dist',
    'concurrent:dist',
    'useminPrepare',
    'concat',
    'uncss',
    'autoprefixer:dist',
    'cssmin',
    'uglify',
    'newer:imageoptim',
    'svgmin',
    'filerev',
    'usemin',
    'htmlmin',
    'xmlmin'
  ]);

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

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


<commit_before>/* To prevent jshint from yelling at module.exports. */
/* jshint node:true */

'use strict';

var LIVERELOAD_PORT = 35729;

module.exports = function(grunt) {

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

	// App configuration
	var config = grunt.file.readYAML('config/common.yml');

	// Tasks configuration
	grunt.initConfig({

		config: config,

		clean: {
			destination: {
				files: [{
					dot: true,
					src: '<%= config.destination %>/*'
				}]
			},
			icons: {
				files: [{
					dot: true,
					src: '<%= config.source %>/icons/icons*.*'
				}]
			}
		},

		copy: {
			cssToDest: {
				src: '*.css',
				dest: '<%= config.destination %>/css/',
				flatten: true,
				filter: 'isFile',
				expand: true,
				nonull: true,
				cwd: '<%= config.source %>/css/'
			}
		},

		csslint: {
			options: {
				csslintrc: '.csslintrc'
			},
			lax: {
				src: '<%= config.destination %>/css/*.css',
				options: {
					import: false
				}
			},
			strict: {
				src: '<%= config.destination %>/css/*.css',
				options: {
					import: 2
				}
			}
		},

		cssmin: {
			css: {
				src: '<%= config.source %>/css/styles.css',
				dest: '<%= config.source %>/css/styles.min.css',
				options: {
					keepSpecialComments: 0
				}
			}
		},

		gae: {
			options: {
				path: 'appengine',
				auth: 'oauth2'
			},
			deploy: {
				action: 'update'
			},
			local: {
				action: 'run',
				options: {
					async: true,
					asyncOutput: true,
					args: {
						port: config.port
					}
				}
			},
			stop: {
				action: 'kill'
			}
		},

		htmlmin: {
			all: {
				options: {
					removeCommentsFromCDATA: true,
					// https://github.com/yeoman/grunt-usemin/issues/44
					collapseWhitespace: true,
					collapseBooleanAttributes: true,
					// removeAttributeQuotes: true,
					removeRedundantAttributes: true,
					useShortDoctype: true,
					removeEmptyAttributes: true,
					removeOptionalTags: true
				},
				files: [{
					expand: true,
					cwd: '<%= config.destination %>',
					src: ['**/*.html'],
					dest: '<%= config.destination %>'
				}]
			}
		},

		imagemin: {
			normal: {
				options: {
					optimizationLevel: 7
				},
				files: [{
					expand: true,
					src: ['**/*.png']
				}]
			},
			o2: {
				options: {
					optimizationLevel: 2
				},
				files: [{
					expand: true,
					src: ['**/*.png']
				}]
			}
		},

		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			source: [
				'Gruntfile.js',
				'<%= config.source %>/**/*.js',
				'!<%= config.source %>/**/_code/**/*.js'
			]
		},

		open: {
			local: {
				path: 'http://localhost:<%=config.port%>/web/fundamentals'
			},
			staging: {
				path: 'http://web-central.appspot.com/web/fundamentals'
			},
		},

		sass: {
			options: {
				precision: 10,
				includePaths: ['<%= config.source %>/css'],
				imagePath: '<%= config.source %>/imgs',
				outputStyle: 'nested'
			},
			all: {
				files: {
					'<%= config.source %>/css/styles.css': '<%= config.source %>/_sass/styles.scss'
				}
			}
		},

		watch: {
			// When styles change, recompile them
			styles: {
				files: [
					'<%= config.source %>/_sass/**/*.scss',
					'<%= config.source %>/css/**/*.css',
					'!<%= config.source %>/css/**/*.min.css'
				],
				tasks: ['sass', 'cssmin', 'copy:cssToDest']
			},

			// when jekyll source changes, recompile them
			jekyll: {
				files: [
					'<%= config.source %>/**/*.liquid',
					'<%= config.source %>/**/*.markdown',
					'<%= config.source %>/**/*.rb',
					'<%= config.source %>/**/*.md',
					'<%= config.source %>/**/*.xml'
				],
				tasks: ['jekyll:appengine']
			},

			// when served files change, reload them in the browser
			served: {
				options: {
					livereload: LIVERELOAD_PORT
				},
				files: [
					'<%= config.destination %>/**/*.html',  // view files (from jekyll)
					'<%= config.destination %>/css/*.css'   // css files (from sass)
				]
			}
		},

		webfont: {
			icons: {
				src: '<%= config.source %>/icons/*.svg',
				dest: '<%= config.source %>/icons/',
				destCss: '<%= config.source %>/_sass/_components/',
				options: {
					hashes: false,
					stylesheet: 'scss',
					relativeFontPath: '../icons',
					htmlDemo: false,
					template: '<%= config.source %>/_templates/icons-template.css'
				}
			}

		}
	});

	grunt.registerTask('wsk-version', 'Uses the Github API to determine the latest web-starter-kit version, and writes it to ./config/wsk-version.yml', function() {
		var latest = require('latest-release');
		var done = this.async();
		var out = './config/wsk-version.yml';

		grunt.log.writeln('Determining latest web-starter-kit version..');

		latest('google', 'web-starter-kit', function(release, err) {
			if (err) {
				grunt.verbose.or.write('Failed to retrieve latest web-starter-kit release information').error().error(err.message);
			} else {
				grunt.log.writeln('Latest version is: ' + release.name);
				grunt.log.writeln('Saved release information under: ' + out);
				/*jshint camelcase: false */
				/*ignore the casing on the variables. These come directly from the Githup API.*/
				grunt.file.write(out,
					'wsk-tag: ' + release.tag_name + '\n' +
					'wsk-name: ' + release.name + '\n' +
					'wsk-zip-url: ' + release.zipball_url + '\n'
					);
				/*jshint camelcase: true */
				done();
			}
		});
	});

	// jekyll:target [--lang <lang_code,lang_code,...|all>]
	// where 'target' is config/target.yml file.
	// defaults to '--lang all'.
	// 'all' builds for all languages specified in config.yml/langs_available + 'en'.
	// builds w/o multilang support if config.yml is missing langs_available.
	grunt.registerTask('jekyll', 'Run jekyll build.\nOptions:\n  [--lang]: list of languages or "all"', function() {
		var langs = grunt.option('lang') || 'all';

		var cfgname = this.args[0] || 'appengine';

		// read langs from config/target.yml
		// returns langs_available + prime_lang
		//         or [] if langs_available is not defined.
		var langsFromConfig = function() {
			/*jshint camelcase: false */
			var cfg = grunt.file.readYAML('config/common.yml');
			if (typeof cfg.langs_available === 'undefined') {
				return [];
			}
			cfg.langs_available.unshift(cfg.prime_lang);
			return cfg.langs_available;
			/*jshint camelcase: true */
		};

		if (langs === 'all' ) {
			langs = langsFromConfig();
		} else {
			langs = langs.split(/,|\s/).filter(function(item) {
				return item.length > 0;
			});
		}

		var cfgfiles = 'config/wsk-version.yml,config/common.yml,config/' + cfgname + '.yml';
		var args = ['exec', 'jekyll', 'build', '--config', cfgfiles, '-t'];
		var spawnJekyll = function(lang, callback) {
			var opts = {env: process.env, stdio: 'inherit'};
			if (lang !== null) {
				opts.env.TRANS_LANG = lang;
				// opts.env.MENTOS_TIMEOUT = 32;
			}
			grunt.util.spawn({cmd: 'bundle', args: args, opts: opts}, callback);
		};

		var done = this.async();
		var count = 0;
		var waitAll = function(err, res, code) {
			if (err) {
				grunt.fatal(String(res), code);
			}
			if (++count >= langs.length) {
				done();
			}
		};

		// multilang build
		for (var i = 0; i < langs.length; i++) {
			spawnJekyll(langs[i], waitAll);
		}
		// simple build (no multilang support)
		if (langs.length === 0) {
			spawnJekyll(null, waitAll);
		}
	});

	// Test task
	grunt.registerTask('test', 'Lints all javascript and CSS sources.', 'jshint:source');

	grunt.registerTask('prepare', ['wsk-version', 'test', 'clean:destination', 'sass', 'cssmin']);

	// Build task
	grunt.registerTask('build', 'Runs the "test" task, then builds the website.', [
		'prepare',
		'jekyll:appengine'   // Build the site with Jekyll
	]);

	// Develop task
	grunt.registerTask('develop', 'The default task for developers.\nRuns the tests, builds the minimum required, serves the content and watches for changes.', [
		'build',   // Build the site with Jekyll
		'gae:local',
		'open:local',
		'watch'
	]);

	// Devsite task
	grunt.registerTask('devsite', 'Runs the build steps with devsite config', [
		'clean:icons',        // Clean up icon font files for regeneration
		'webfont:icons',      // Generate icon font files and SASS
		'prepare',
		'jekyll:devsite',     // Build the site with Jekyll
		'htmlmin:all'         // Minify the final HTML
	]);

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

};
<commit_msg>Adding some debugging to WSK version number task<commit_after>/* To prevent jshint from yelling at module.exports. */
/* jshint node:true */

'use strict';

var LIVERELOAD_PORT = 35729;

module.exports = function(grunt) {

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

	// App configuration
	var config = grunt.file.readYAML('config/common.yml');

	// Tasks configuration
	grunt.initConfig({

		config: config,

		clean: {
			destination: {
				files: [{
					dot: true,
					src: '<%= config.destination %>/*'
				}]
			},
			icons: {
				files: [{
					dot: true,
					src: '<%= config.source %>/icons/icons*.*'
				}]
			}
		},

		copy: {
			cssToDest: {
				src: '*.css',
				dest: '<%= config.destination %>/css/',
				flatten: true,
				filter: 'isFile',
				expand: true,
				nonull: true,
				cwd: '<%= config.source %>/css/'
			}
		},

		csslint: {
			options: {
				csslintrc: '.csslintrc'
			},
			lax: {
				src: '<%= config.destination %>/css/*.css',
				options: {
					import: false
				}
			},
			strict: {
				src: '<%= config.destination %>/css/*.css',
				options: {
					import: 2
				}
			}
		},

		cssmin: {
			css: {
				src: '<%= config.source %>/css/styles.css',
				dest: '<%= config.source %>/css/styles.min.css',
				options: {
					keepSpecialComments: 0
				}
			}
		},

		gae: {
			options: {
				path: 'appengine',
				auth: 'oauth2'
			},
			deploy: {
				action: 'update'
			},
			local: {
				action: 'run',
				options: {
					async: true,
					asyncOutput: true,
					args: {
						port: config.port
					}
				}
			},
			stop: {
				action: 'kill'
			}
		},

		htmlmin: {
			all: {
				options: {
					removeCommentsFromCDATA: true,
					// https://github.com/yeoman/grunt-usemin/issues/44
					collapseWhitespace: true,
					collapseBooleanAttributes: true,
					// removeAttributeQuotes: true,
					removeRedundantAttributes: true,
					useShortDoctype: true,
					removeEmptyAttributes: true,
					removeOptionalTags: true
				},
				files: [{
					expand: true,
					cwd: '<%= config.destination %>',
					src: ['**/*.html'],
					dest: '<%= config.destination %>'
				}]
			}
		},

		imagemin: {
			normal: {
				options: {
					optimizationLevel: 7
				},
				files: [{
					expand: true,
					src: ['**/*.png']
				}]
			},
			o2: {
				options: {
					optimizationLevel: 2
				},
				files: [{
					expand: true,
					src: ['**/*.png']
				}]
			}
		},

		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			source: [
				'Gruntfile.js',
				'<%= config.source %>/**/*.js',
				'!<%= config.source %>/**/_code/**/*.js'
			]
		},

		open: {
			local: {
				path: 'http://localhost:<%=config.port%>/web/fundamentals'
			},
			staging: {
				path: 'http://web-central.appspot.com/web/fundamentals'
			},
		},

		sass: {
			options: {
				precision: 10,
				includePaths: ['<%= config.source %>/css'],
				imagePath: '<%= config.source %>/imgs',
				outputStyle: 'nested'
			},
			all: {
				files: {
					'<%= config.source %>/css/styles.css': '<%= config.source %>/_sass/styles.scss'
				}
			}
		},

		watch: {
			// When styles change, recompile them
			styles: {
				files: [
					'<%= config.source %>/_sass/**/*.scss',
					'<%= config.source %>/css/**/*.css',
					'!<%= config.source %>/css/**/*.min.css'
				],
				tasks: ['sass', 'cssmin', 'copy:cssToDest']
			},

			// when jekyll source changes, recompile them
			jekyll: {
				files: [
					'<%= config.source %>/**/*.liquid',
					'<%= config.source %>/**/*.markdown',
					'<%= config.source %>/**/*.rb',
					'<%= config.source %>/**/*.md',
					'<%= config.source %>/**/*.xml'
				],
				tasks: ['jekyll:appengine']
			},

			// when served files change, reload them in the browser
			served: {
				options: {
					livereload: LIVERELOAD_PORT
				},
				files: [
					'<%= config.destination %>/**/*.html',  // view files (from jekyll)
					'<%= config.destination %>/css/*.css'   // css files (from sass)
				]
			}
		},

		webfont: {
			icons: {
				src: '<%= config.source %>/icons/*.svg',
				dest: '<%= config.source %>/icons/',
				destCss: '<%= config.source %>/_sass/_components/',
				options: {
					hashes: false,
					stylesheet: 'scss',
					relativeFontPath: '../icons',
					htmlDemo: false,
					template: '<%= config.source %>/_templates/icons-template.css'
				}
			}

		}
	});

	grunt.registerTask('wsk-version', 'Uses the Github API to determine the latest web-starter-kit version, and writes it to ./config/wsk-version.yml', function() {
		var latest = require('latest-release');
		var done = this.async();
		var out = './config/wsk-version.yml';

		grunt.log.writeln('Determining latest web-starter-kit version..');

		latest('google', 'web-starter-kit', function(release, err) {
			grunt.log.writeln('release: ' + JSON.stringify(release));
			grunt.log.writeln('err: ' + JSON.stringify(err));
			if (err) {
				grunt.verbose.or.write('Failed to retrieve latest web-starter-kit release information').error().error(err.message);
			} else {
				grunt.log.writeln('Latest version is: ' + release.name);
				grunt.log.writeln('Saved release information under: ' + out);
				/*jshint camelcase: false */
				/*ignore the casing on the variables. These come directly from the Githup API.*/

				grunt.file.write(out,
					'wsk-tag: ' + release.tag_name + '\n' +
					'wsk-name: ' + release.name + '\n' +
					'wsk-zip-url: ' + release.zipball_url + '\n'
					);
				/*jshint camelcase: true */
				done();
			}
		});
	});

	// jekyll:target [--lang <lang_code,lang_code,...|all>]
	// where 'target' is config/target.yml file.
	// defaults to '--lang all'.
	// 'all' builds for all languages specified in config.yml/langs_available + 'en'.
	// builds w/o multilang support if config.yml is missing langs_available.
	grunt.registerTask('jekyll', 'Run jekyll build.\nOptions:\n  [--lang]: list of languages or "all"', function() {
		var langs = grunt.option('lang') || 'all';

		var cfgname = this.args[0] || 'appengine';

		// read langs from config/target.yml
		// returns langs_available + prime_lang
		//         or [] if langs_available is not defined.
		var langsFromConfig = function() {
			/*jshint camelcase: false */
			var cfg = grunt.file.readYAML('config/common.yml');
			if (typeof cfg.langs_available === 'undefined') {
				return [];
			}
			cfg.langs_available.unshift(cfg.prime_lang);
			return cfg.langs_available;
			/*jshint camelcase: true */
		};

		if (langs === 'all' ) {
			langs = langsFromConfig();
		} else {
			langs = langs.split(/,|\s/).filter(function(item) {
				return item.length > 0;
			});
		}

		var cfgfiles = 'config/wsk-version.yml,config/common.yml,config/' + cfgname + '.yml';
		var args = ['exec', 'jekyll', 'build', '--config', cfgfiles, '-t'];
		var spawnJekyll = function(lang, callback) {
			var opts = {env: process.env, stdio: 'inherit'};
			if (lang !== null) {
				opts.env.TRANS_LANG = lang;
				// opts.env.MENTOS_TIMEOUT = 32;
			}
			grunt.util.spawn({cmd: 'bundle', args: args, opts: opts}, callback);
		};

		var done = this.async();
		var count = 0;
		var waitAll = function(err, res, code) {
			if (err) {
				grunt.fatal(String(res), code);
			}
			if (++count >= langs.length) {
				done();
			}
		};

		// multilang build
		for (var i = 0; i < langs.length; i++) {
			spawnJekyll(langs[i], waitAll);
		}
		// simple build (no multilang support)
		if (langs.length === 0) {
			spawnJekyll(null, waitAll);
		}
	});

	// Test task
	grunt.registerTask('test', 'Lints all javascript and CSS sources.', 'jshint:source');

	grunt.registerTask('prepare', ['wsk-version', 'test', 'clean:destination', 'sass', 'cssmin']);

	// Build task
	grunt.registerTask('build', 'Runs the "test" task, then builds the website.', [
		'prepare',
		'jekyll:appengine'   // Build the site with Jekyll
	]);

	// Develop task
	grunt.registerTask('develop', 'The default task for developers.\nRuns the tests, builds the minimum required, serves the content and watches for changes.', [
		'build',   // Build the site with Jekyll
		'gae:local',
		'open:local',
		'watch'
	]);

	// Devsite task
	grunt.registerTask('devsite', 'Runs the build steps with devsite config', [
		'clean:icons',        // Clean up icon font files for regeneration
		'webfont:icons',      // Generate icon font files and SASS
		'prepare',
		'jekyll:devsite',     // Build the site with Jekyll
		'htmlmin:all'         // Minify the final HTML
	]);

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

};
<|endoftext|>


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

  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-kss');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-closure-linter');
  grunt.loadNpmTasks("grunt-contrib-concat");
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.initConfig({

    pkg: grunt.file.readJSON("bower.json"),

    meta: {
      banner: "/*\n" +
        " *  <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n" +
        " *  <%= pkg.description %>\n" +
        " *  <%= pkg.homepage %>\n" +
        " *\n" +
        " *  Made by <%= pkg.authors %>\n" +
        " *  Under <%= pkg.license %> License\n" +
        " */\n"
    },

    // JS - Fix Style
    closureFixStyle: {
      app:{
        closureLinterPath : '/usr/local/bin',
        command: 'fixjsstyle',
        src: 'js/*.js',
        options: {
          stdout: true,
          strict: true
        }
      }
    },

    // JS - Check errors
    jshint: {
      files: ['gruntfile.js', 'js/**/*.js'],
      options: {
        globals: {
          jQuery: true,
          console: true,
          module: true
        }
      }
    },

    // JS - Concatenate js
    concat: {
      options: {
        banner: "<%= meta.banner %>"
      },
      dist: {
        src: "js/*.js",
        dest: "dist/js/rapido.js"
      }
    },

    // JS - Create minified version
    uglify: {
      options: {
        mangle: {
          except: ['jQuery']
        },
        banner: "<%= meta.banner %>"
      },
      min: {
         src: "dist/js/rapido.js",
         dest: "dist/js/rapido.min.js"
      }
    },

    // CSS - Compile css
    compass: {
      dist: {
        options: {
          require: 'susy',
          sassDir: 'stylesheets',
          cssDir: 'dist/css',
          specify: 'stylesheets/rapido.scss',
          noLineComments: true,
          environment: 'development',
          outputStyle: 'expanded'
        }
      },
      min: {
        options: {
          require: 'susy',
          sassDir: 'stylesheets',
          cssDir: 'dist/css',
          specify: 'stylesheets/rapido.min.scss',
          noLineComments: true,
          environment: 'production',
          outputStyle: 'compressed'
        }
      }
    },

    // CSS - Create documentation
    kss: {
      options: {
        includeType: 'css',
        template: '../../forks/kss-node-template/template/',
        includePath: 'dist/css/rapido.css',
      },
      dist: {
        files: {
          'docs': ['stylesheets']
        }
      }
    },

    // CSS - Copy docs files to website repository
    copy: {
      main: {
        files: [
          {
          expand: true,
          cwd: 'docs/',
          src: ['**'],
          dest: '../../server/sites/raffone/rapido'
        },
        ]
      },
      js: {
        files: [
          {
          expand: true,
          cwd: 'dist/js',
          src: ['rapido.js'],
          dest: '../../forks/kss-node-template/template/public'
        },
        ]
      }
    },

    // Testing
    watch: {
      options: {
        interrupt: false,
        livereload: true
      },
      css: {
        files: ['stylesheets/**/*.scss'],
        tasks: ['compass:dist']
      },
      js: {
        files: ['js/*.js'],
      },
    },

  });

  grunt.registerTask('css',  ['compass']);
  grunt.registerTask('js',   ['concat', 'closureFixStyle', 'jshint', 'uglify']);
  grunt.registerTask('docs', ['compass:dist', 'js', 'copy:js', 'kss']);
  grunt.registerTask('site', ['compass:dist', 'kss', 'copy']);
  grunt.registerTask('default', ['compass', 'js']);

};
<commit_msg>Added watch for test files<commit_after>module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-kss');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-closure-linter');
  grunt.loadNpmTasks("grunt-contrib-concat");
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.initConfig({

    pkg: grunt.file.readJSON("bower.json"),

    meta: {
      banner: "/*\n" +
        " *  <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n" +
        " *  <%= pkg.description %>\n" +
        " *  <%= pkg.homepage %>\n" +
        " *\n" +
        " *  Made by <%= pkg.authors %>\n" +
        " *  Under <%= pkg.license %> License\n" +
        " */\n"
    },

    // JS - Fix Style
    closureFixStyle: {
      app:{
        closureLinterPath : '/usr/local/bin',
        command: 'fixjsstyle',
        src: 'js/*.js',
        options: {
          stdout: true,
          strict: true
        }
      }
    },

    // JS - Check errors
    jshint: {
      files: ['gruntfile.js', 'js/**/*.js'],
      options: {
        globals: {
          jQuery: true,
          console: true,
          module: true
        }
      }
    },

    // JS - Concatenate js
    concat: {
      options: {
        banner: "<%= meta.banner %>"
      },
      dist: {
        src: "js/*.js",
        dest: "dist/js/rapido.js"
      }
    },

    // JS - Create minified version
    uglify: {
      options: {
        mangle: {
          except: ['jQuery']
        },
        banner: "<%= meta.banner %>"
      },
      min: {
         src: "dist/js/rapido.js",
         dest: "dist/js/rapido.min.js"
      }
    },

    // CSS - Compile css
    compass: {
      dist: {
        options: {
          require: 'susy',
          sassDir: 'stylesheets',
          cssDir: 'dist/css',
          specify: 'stylesheets/rapido.scss',
          noLineComments: true,
          environment: 'development',
          outputStyle: 'expanded'
        }
      },
      min: {
        options: {
          require: 'susy',
          sassDir: 'stylesheets',
          cssDir: 'dist/css',
          specify: 'stylesheets/rapido.min.scss',
          noLineComments: true,
          environment: 'production',
          outputStyle: 'compressed'
        }
      }
    },

    // CSS - Create documentation
    kss: {
      options: {
        includeType: 'css',
        template: '../../forks/kss-node-template/template/',
        includePath: 'dist/css/rapido.css',
      },
      dist: {
        files: {
          'docs': ['stylesheets']
        }
      }
    },

    // CSS - Copy docs files to website repository
    copy: {
      main: {
        files: [
          {
          expand: true,
          cwd: 'docs/',
          src: ['**'],
          dest: '../../server/sites/raffone/rapido'
        },
        ]
      },
      js: {
        files: [
          {
          expand: true,
          cwd: 'dist/js',
          src: ['rapido.js'],
          dest: '../../forks/kss-node-template/template/public'
        },
        ]
      }
    },

    // Testing
    watch: {
      options: {
        interrupt: false,
        livereload: true
      },
      css: {
        files: ['stylesheets/**/*.scss'],
        tasks: ['compass:dist']
      },
      html: {
        files: ['tests/*.html'],
      },
      js: {
        files: ['js/*.js'],
      },
    },

  });

  grunt.registerTask('css',  ['compass']);
  grunt.registerTask('js',   ['concat', 'closureFixStyle', 'jshint', 'uglify']);
  grunt.registerTask('docs', ['compass:dist', 'js', 'copy:js', 'kss']);
  grunt.registerTask('site', ['compass:dist', 'kss', 'copy']);
  grunt.registerTask('default', ['compass', 'js']);

};
<|endoftext|>


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

    /**
     * Require it at the top and pass in the grunt instance
     */
    require('time-grunt')(grunt);

    /**
     * Setup configuration
     */
    grunt.initConfig({
        pkg: grunt.file.readJSON('config/banner.json'),
        buildTags: "/* Project Name : <%= pkg.application.name %> Release version : <%= pkg.application.version %> */",

        configuredFiles: grunt.file.readJSON('config/servefiles.json'),

        clean: {
            build: ['prod']
        },
        shell: {
            uglify: {
                command: [
                    'node config/r.js -o config/config-optimize-build.js',
                    'node config/r.js -o config/config-copy-build.js',
                    'rm src/main-optimize.js',
                    'rm prod/main.js',
                    'mv prod/main-optimize.js prod/main.js'
                ].join('&&')
            }
        },
        usebanner: {
            buildTags: {
                options: {
                    position: 'top',
                    banner: '<%= buildTags %>',
                    linebreak: true
                },
                files: {
                    src: '<%= configuredFiles.usebanner %>'
                }
            }
        },
        jshint: {
            options: {
                jshintrc: 'config/.jshintrc',
                ignores: '<%= configuredFiles.jshint.ignore %>'
            },
            all: '<%= configuredFiles.jshint.files %>'
        },
        jscs: {
            options: {
                config: 'config/.jscsrc'
            },
            src: '<%= configuredFiles.jscs.files %>',
        },
        jsonlint: {
            files: {
                src: '<%= configuredFiles.jsonlint %>'
            }
        },
        csslint: {
            strict: {
                options: {
                    csslintrc: 'config/.csslintrc',
                    ignores: '<%= configuredFiles.csslint.ignore %>'
                },
                src: '<%= configuredFiles.csslint.files %>'
            }
        },
        htmlhint: {
            Root_HTML_Files: {
                options: {
                    htmlhintrc: 'config/.htmlhint-n-rc',
                    ignores: '<%= configuredFiles.htmlhint.Root_HTML_Files.ignore %>'
                },
                src: '<%= configuredFiles.htmlhint.Root_HTML_Files.files %>'
            },
            Templates: {
                options: {
                    htmlhintrc: 'config/.htmlhint-t-rc',
                    ignores: '<%= configuredFiles.htmlhint.Templates.ignore %>'
                },
                src: '<%= configuredFiles.htmlhint.Templates.files %>'

            }
        },
        less: {
            readyMade: {
                options: {
                    compress: true
                },
                files: '<%= configuredFiles.less.readyMade.files %>'
            },
            customMade: {
                options: {
                    compress: false
                },
                files: '<%= configuredFiles.less.customMade.files %>'
            },
            prod: {
                options: {
                    compress: true
                },
                files: '<%= configuredFiles.less.customMade.files %>'
            }
        },
        watch: {
            less: {
                options: {
                    spawn: false
                },
                files: '<%= configuredFiles.watch.less.files %>',
                tasks: ['less:customMade']
            }
        },
        qunit: {
            options: {
                '--web-security': 'no',
                coverage: {
                    src: ['src/**/*.js'],
                    instrumentedFiles: 'temp/',
                    htmlReport: 'report/coverage',
                    coberturaReport: 'report/'
                }
            },
            all: ['tests/**/*.html']
        },
        strip: {
            main: {
                src: 'prod/src/apps/**/*.js',
                options: {
                    inline: true,
                    nodes: ['console.log', 'debug']
                }
            }
        },
        autoprefixer: {
            options: {
                'browsers': ['last 2 versions']
            },
            multiple: {
                expand: true,
                flatten: true,
                src: 'src/stylesheets/css/common/*.css',
                dest: 'src/stylesheets/css/common/'
            }
        },
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                files: '<%= configuredFiles.htmlmin.files %>'
            }
        }
    });

    /**
     * Load tasks
     */
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-strip');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jscs');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-csslint');
    grunt.loadNpmTasks('grunt-htmlhint');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-jsonlint');
    grunt.loadNpmTasks('grunt-banner');

    /**
     * Define tasks : Tasks for development eco - system.
     */
    grunt.registerTask('default', [
        'htmlhint',
        'csslint',
        'jshint',
        'jscs',
        'jsonlint',
        'less:readyMade',
        'less:customMade',
        'autofix'
    ]);
    grunt.registerTask('dev', ['default']); // Alias for `default`.

    /**
     * Define tasks : Tasks for build eco - system.
     */
    grunt.registerTask('build', [
        'htmlhint',
        'csslint',
        'jshint',
        'jsonlint',
        'compileless',
        'autofix',
        'clean',
        'shell',
        'strip',
        'htmlmin',
        'usebanner'
    ]);

    /**
     * Define sub-tasks : Tasks for Less compilation.
     */
    grunt.registerTask('compileless', ['less:readyMade', 'less:customMade']);

    /**
     * Define sub-tasks : Alias for `autofix`
     */
    grunt.registerTask('autofix', ['autoprefixer']);

    /**
     * Define sub-tasks : Alias for `tests`
     */
    grunt.registerTask('tests', ['qunit']);

};<commit_msg>Registers watch task for less<commit_after>module.exports = function(grunt) {
    'use strict';

    /**
     * Require it at the top and pass in the grunt instance
     */
    require('time-grunt')(grunt);

    /**
     * Setup configuration
     */
    grunt.initConfig({
        pkg: grunt.file.readJSON('config/banner.json'),
        buildTags: "/* Project Name : <%= pkg.application.name %> Release version : <%= pkg.application.version %> */",

        configuredFiles: grunt.file.readJSON('config/servefiles.json'),

        clean: {
            build: ['prod']
        },
        shell: {
            uglify: {
                command: [
                    'node config/r.js -o config/config-optimize-build.js',
                    'node config/r.js -o config/config-copy-build.js',
                    'rm src/main-optimize.js',
                    'rm prod/main.js',
                    'mv prod/main-optimize.js prod/main.js'
                ].join('&&')
            }
        },
        usebanner: {
            buildTags: {
                options: {
                    position: 'top',
                    banner: '<%= buildTags %>',
                    linebreak: true
                },
                files: {
                    src: '<%= configuredFiles.usebanner %>'
                }
            }
        },
        jshint: {
            options: {
                jshintrc: 'config/.jshintrc',
                ignores: '<%= configuredFiles.jshint.ignore %>'
            },
            all: '<%= configuredFiles.jshint.files %>'
        },
        jscs: {
            options: {
                config: 'config/.jscsrc'
            },
            src: '<%= configuredFiles.jscs.files %>',
        },
        jsonlint: {
            files: {
                src: '<%= configuredFiles.jsonlint %>'
            }
        },
        csslint: {
            strict: {
                options: {
                    csslintrc: 'config/.csslintrc',
                    ignores: '<%= configuredFiles.csslint.ignore %>'
                },
                src: '<%= configuredFiles.csslint.files %>'
            }
        },
        htmlhint: {
            Root_HTML_Files: {
                options: {
                    htmlhintrc: 'config/.htmlhint-n-rc',
                    ignores: '<%= configuredFiles.htmlhint.Root_HTML_Files.ignore %>'
                },
                src: '<%= configuredFiles.htmlhint.Root_HTML_Files.files %>'
            },
            Templates: {
                options: {
                    htmlhintrc: 'config/.htmlhint-t-rc',
                    ignores: '<%= configuredFiles.htmlhint.Templates.ignore %>'
                },
                src: '<%= configuredFiles.htmlhint.Templates.files %>'

            }
        },
        less: {
            readyMade: {
                options: {
                    compress: true
                },
                files: '<%= configuredFiles.less.readyMade.files %>'
            },
            customMade: {
                options: {
                    compress: false
                },
                files: '<%= configuredFiles.less.customMade.files %>'
            },
            prod: {
                options: {
                    compress: true
                },
                files: '<%= configuredFiles.less.customMade.files %>'
            }
        },
        watch: {
            less: {
                options: {
                    spawn: false
                },
                files: '<%= configuredFiles.watch.less.files %>',
                tasks: ['less:customMade']
            }
        },
        qunit: {
            options: {
                '--web-security': 'no',
                coverage: {
                    src: ['src/**/*.js'],
                    instrumentedFiles: 'temp/',
                    htmlReport: 'report/coverage',
                    coberturaReport: 'report/'
                }
            },
            all: ['tests/**/*.html']
        },
        strip: {
            main: {
                src: 'prod/src/apps/**/*.js',
                options: {
                    inline: true,
                    nodes: ['console.log', 'debug']
                }
            }
        },
        autoprefixer: {
            options: {
                'browsers': ['last 2 versions']
            },
            multiple: {
                expand: true,
                flatten: true,
                src: 'src/stylesheets/css/common/*.css',
                dest: 'src/stylesheets/css/common/'
            }
        },
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                files: '<%= configuredFiles.htmlmin.files %>'
            }
        }
    });

    /**
     * Load tasks
     */
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-strip');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jscs');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-csslint');
    grunt.loadNpmTasks('grunt-htmlhint');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-jsonlint');
    grunt.loadNpmTasks('grunt-banner');

    /**
     * Define tasks : Tasks for development eco - system.
     */
    grunt.registerTask('default', [
        'htmlhint',
        'csslint',
        'jshint',
        'jscs',
        'jsonlint',
        'less:readyMade',
        'less:customMade',
        'autofix'
    ]);
    grunt.registerTask('dev', ['default']); // Alias for `default`.

    /**
     * Define tasks : Tasks for build eco - system.
     */
    grunt.registerTask('build', [
        'htmlhint',
        'csslint',
        'jshint',
        'jsonlint',
        'compileless',
        'autofix',
        'clean',
        'shell',
        'strip',
        'htmlmin',
        'usebanner'
    ]);

    /**
     * Define tasks : Tasks for less:compilation watch, Also alias for `watch`
     */
    grunt.registerTask('watchless', ['watch:less']);

    /**
     * Define sub-tasks : Tasks for Less compilation.
     */
    grunt.registerTask('compileless', ['less:readyMade', 'less:customMade']);

    /**
     * Define sub-tasks : Alias for `autofix`
     */
    grunt.registerTask('autofix', ['autoprefixer']);

    /**
     * Define sub-tasks : Alias for `tests`
     */
    grunt.registerTask('tests', ['qunit']);

};<|endoftext|>


<commit_before>var assert = require("assert");
var fiberPool = require("./fiber_pool.js").makePool();

exports.makeCompatible = function (Promise, Fiber) {
  var es6PromiseThen = Promise.prototype.then;

  if (typeof Fiber === "function") {
    Promise.Fiber = Fiber;
  }

  // Replace Promise.prototype.then with a wrapper that ensures the
  // onResolved and onRejected callbacks always run in a Fiber.
  Promise.prototype.then = function (onResolved, onRejected) {
    var P = this.constructor;

    if (typeof P.Fiber === "function") {
      var fiber = P.Fiber.current;
      var dynamics = cloneFiberOwnProperties(fiber);

      return es6PromiseThen.call(
        this,
        wrapCallback(onResolved, P, dynamics),
        wrapCallback(onRejected, P, dynamics)
      );
    }

    return es6PromiseThen.call(this, onResolved, onRejected);
  };

  Promise.awaitAll = function (args) {
    return awaitPromise(this.all(args));
  };

  Promise.await = function (arg) {
    return awaitPromise(this.resolve(arg));
  };

  Promise.prototype.await = function () {
    return awaitPromise(this);
  };

  // Yield the current Fiber until the given Promise has been fulfilled.
  function awaitPromise(promise) {
    var Promise = promise.constructor;
    var Fiber = Promise.Fiber;

    assert.strictEqual(
      typeof Fiber, "function",
      "Cannot await unless Promise.Fiber is defined"
    );

    var fiber = Fiber.current;

    assert.ok(
      fiber instanceof Fiber,
      "Cannot await without a Fiber"
    );

    var run = fiber.run;
    var throwInto = fiber.throwInto;

    if (process.domain) {
      run = process.domain.bind(run);
      throwInto = process.domain.bind(throwInto);
    }

    // The overridden es6PromiseThen function is adequate here because these
    // two callbacks do not need to run in a Fiber.
    es6PromiseThen.call(promise, function (result) {
      tryCatchNextTick(fiber, run, [result]);
    }, function (error) {
      tryCatchNextTick(fiber, throwInto, [error]);
    });

    return stackSafeYield(Fiber, awaitPromise);
  }

  function stackSafeYield(Fiber, caller) {
    try {
      return Fiber.yield();
    } catch (thrown) {
      if (thrown) {
        var e = new Error;
        Error.captureStackTrace(e, caller);
        thrown.stack += e.stack.replace(/^.*?\n/, "\n => awaited here:\n");
      }
      throw thrown;
    }
  }

  // Return a wrapper function that returns a Promise for the eventual
  // result of the original function.
  Promise.async = function (fn, allowReuseOfCurrentFiber) {
    var Promise = this;
    return function () {
      return Promise.asyncApply(
        fn, this, arguments,
        allowReuseOfCurrentFiber
      );
    };
  };

  Promise.asyncApply = function (
    fn, context, args, allowReuseOfCurrentFiber
  ) {
    var Promise = this;
    var Fiber = Promise.Fiber;
    var fiber = Fiber && Fiber.current;

    if (fiber && allowReuseOfCurrentFiber) {
      return this.resolve(fn.apply(context, args));
    }

    return fiberPool.run({
      callback: fn,
      context: context,
      args: args,
      dynamics: cloneFiberOwnProperties(fiber)
    }, Promise);
  };
};

function wrapCallback(callback, Promise, dynamics) {
  if (! callback) {
    return callback;
  }

  // Don't wrap callbacks that are flagged as not wanting to be called in a
  // fiber.
  if (callback._meteorPromiseAlreadyWrapped) {
    return callback;
  }

  var result = function (arg) {
    return fiberPool.run({
      callback: callback,
      args: [arg], // Avoid dealing with arguments objects.
      dynamics: dynamics
    }, Promise);
  };

  // Flag this callback as not wanting to be called in a fiber because it is
  // already creating a fiber.
  result._meteorPromiseAlreadyWrapped = true;

  return result;
}

function cloneFiberOwnProperties(fiber) {
  if (fiber) {
    var dynamics = {};

    Object.keys(fiber).forEach(function (key) {
      dynamics[key] = shallowClone(fiber[key]);
    });

    return dynamics;
  }
}

function shallowClone(value) {
  if (Array.isArray(value)) {
    return value.slice(0);
  }

  if (value && typeof value === "object") {
    var copy = Object.create(Object.getPrototypeOf(value));
    var keys = Object.keys(value);
    var keyCount = keys.length;

    for (var i = 0; i < keyCount; ++i) {
      var key = keys[i];
      copy[key] = value[key];
    }

    return copy;
  }

  return value;
}

// Invoke method with args against object in a try-catch block,
// re-throwing any exceptions in the next tick of the event loop, so that
// they won't get captured/swallowed by the caller.
function tryCatchNextTick(object, method, args) {
  try {
    return method.apply(object, args);
  } catch (error) {
    process.nextTick(function () {
      throw error;
    });
  }
}
<commit_msg>Avoid wrapping native callback functions.<commit_after>var assert = require("assert");
var fiberPool = require("./fiber_pool.js").makePool();

exports.makeCompatible = function (Promise, Fiber) {
  var es6PromiseThen = Promise.prototype.then;

  if (typeof Fiber === "function") {
    Promise.Fiber = Fiber;
  }

  // Replace Promise.prototype.then with a wrapper that ensures the
  // onResolved and onRejected callbacks always run in a Fiber.
  Promise.prototype.then = function (onResolved, onRejected) {
    var Promise = this.constructor;

    if (typeof Promise.Fiber === "function") {
      return es6PromiseThen.call(
        this,
        wrapCallback(onResolved, Promise),
        wrapCallback(onRejected, Promise)
      );
    }

    return es6PromiseThen.call(this, onResolved, onRejected);
  };

  Promise.awaitAll = function (args) {
    return awaitPromise(this.all(args));
  };

  Promise.await = function (arg) {
    return awaitPromise(this.resolve(arg));
  };

  Promise.prototype.await = function () {
    return awaitPromise(this);
  };

  // Yield the current Fiber until the given Promise has been fulfilled.
  function awaitPromise(promise) {
    var Promise = promise.constructor;
    var Fiber = Promise.Fiber;

    assert.strictEqual(
      typeof Fiber, "function",
      "Cannot await unless Promise.Fiber is defined"
    );

    var fiber = Fiber.current;

    assert.ok(
      fiber instanceof Fiber,
      "Cannot await without a Fiber"
    );

    var run = fiber.run;
    var throwInto = fiber.throwInto;

    if (process.domain) {
      run = process.domain.bind(run);
      throwInto = process.domain.bind(throwInto);
    }

    // The overridden es6PromiseThen function is adequate here because these
    // two callbacks do not need to run in a Fiber.
    es6PromiseThen.call(promise, function (result) {
      tryCatchNextTick(fiber, run, [result]);
    }, function (error) {
      tryCatchNextTick(fiber, throwInto, [error]);
    });

    return stackSafeYield(Fiber, awaitPromise);
  }

  function stackSafeYield(Fiber, caller) {
    try {
      return Fiber.yield();
    } catch (thrown) {
      if (thrown) {
        var e = new Error;
        Error.captureStackTrace(e, caller);
        thrown.stack += e.stack.replace(/^.*?\n/, "\n => awaited here:\n");
      }
      throw thrown;
    }
  }

  // Return a wrapper function that returns a Promise for the eventual
  // result of the original function.
  Promise.async = function (fn, allowReuseOfCurrentFiber) {
    var Promise = this;
    return function () {
      return Promise.asyncApply(
        fn, this, arguments,
        allowReuseOfCurrentFiber
      );
    };
  };

  Promise.asyncApply = function (
    fn, context, args, allowReuseOfCurrentFiber
  ) {
    var Promise = this;
    var Fiber = Promise.Fiber;
    var fiber = Fiber && Fiber.current;

    if (fiber && allowReuseOfCurrentFiber) {
      return this.resolve(fn.apply(context, args));
    }

    return fiberPool.run({
      callback: fn,
      context: context,
      args: args,
      dynamics: cloneFiberOwnProperties(fiber)
    }, Promise);
  };
};

function wrapCallback(callback, Promise, dynamics) {
  if (! callback) {
    return callback;
  }

  // Don't wrap callbacks that are flagged as not wanting to be called in a
  // fiber.
  if (callback._meteorPromiseAlreadyWrapped) {
    return callback;
  }

  if (isNativeFunction(callback)) {
    return callback;
  }

  var dynamics = cloneFiberOwnProperties(Promise.Fiber.current);
  var result = function (arg) {
    return fiberPool.run({
      callback: callback,
      args: [arg], // Avoid dealing with arguments objects.
      dynamics: dynamics
    }, Promise);
  };

  // Flag this callback as not wanting to be called in a fiber because it is
  // already creating a fiber.
  result._meteorPromiseAlreadyWrapped = true;

  return result;
}

var funToStr = Function.prototype.toString;
var nativeNeedle = "{ [native code] }";

function isNativeFunction(value) {
  return typeof value === "function" &&
    funToStr.call(value).endsWith(nativeNeedle);
}

function cloneFiberOwnProperties(fiber) {
  if (fiber) {
    var dynamics = {};

    Object.keys(fiber).forEach(function (key) {
      dynamics[key] = shallowClone(fiber[key]);
    });

    return dynamics;
  }
}

function shallowClone(value) {
  if (Array.isArray(value)) {
    return value.slice(0);
  }

  if (value && typeof value === "object") {
    var copy = Object.create(Object.getPrototypeOf(value));
    var keys = Object.keys(value);
    var keyCount = keys.length;

    for (var i = 0; i < keyCount; ++i) {
      var key = keys[i];
      copy[key] = value[key];
    }

    return copy;
  }

  return value;
}

// Invoke method with args against object in a try-catch block,
// re-throwing any exceptions in the next tick of the event loop, so that
// they won't get captured/swallowed by the caller.
function tryCatchNextTick(object, method, args) {
  try {
    return method.apply(object, args);
  } catch (error) {
    process.nextTick(function () {
      throw error;
    });
  }
}
<|endoftext|>


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

'use strict';

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

module.exports = function(grunt) {

  require('time-grunt')(grunt);

  // Project configuration.
  grunt.initConfig({

    config: {
      src: 'source',
      dist: '.'
    },

    watch: {
      assemble: {
        files: ['<%= config.src %>/{content,data,templates,assets}/{,*/}*.{md,hbs,yml,sass,scss}'],
        tasks: ['assemble', 'sass']
      },

      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/{,*/}*.html',
          '<%= config.dist %>/assets/{,*/}*.css',
          '<%= config.dist %>/assets/{,*/}*.js',
          '<%= config.dist %>/assets/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          open: true,
          base: [
            '<%= config.dist %>'
          ]
        }
      }
    },

    sass: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.src %>/assets/styles',
          src: ['*.scss', '*.sass'],
          dest: '<%= config.dist %>/assets/css',
          ext: '.css'
        }]
      }
    },

    copy: {
      main: {
        files: [
          // Copy any vanilla CSS files included in the style source
          {expand: true, cwd: '<%= config.src %>/assets/styles', src: ['**', '!*.scss', '!*.sass'], dest: '<%= config.dist %>/assets/css'},

          // Copy any vanilla JS files included in the script source
          {expand: true, cwd: '<%= config.src %>/assets/scripts', src: ['**', '!*.coffee'], dest: '<%= config.dist %>/assets/js'}
        ]
      }
    },

    assemble: {
      pages: {
        options: {
          flatten: true,
          assets: '<%= config.dist %>/assets',
          layout: '<%= config.src %>/templates/layouts/default.hbs',
          data: '<%= config.src %>/data/*.{json,yml}',
          partials: '<%= config.src %>/templates/partials/*.hbs',
          plugins: ['assemble-markdown-data'],
          helpers: ['handlebars-helper-slugify']
        },
        files: {
          '<%= config.dist %>/': ['<%= config.src %>/templates/pages/*.hbs']
        }
      }
    },

    // Before generating any new files,
    // remove any previously-created files.
    // ** ALL FILES IN /build WILL BE DELETED **
    //clean: ['<%= config.dist %>/**/*.{html,xml,css,js}']

  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-copy');

  grunt.registerTask('server', [
    //'clean',
    'copy',
    'sass',
    'assemble',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    //'clean',
    'copy',
    'sass',
    'assemble',
  ]);

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

};
<commit_msg>update gruntfile to copy js files<commit_after>/*
 * Generated on 2014-02-05
 * generator-assemble v0.4.8
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

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

module.exports = function(grunt) {

  require('time-grunt')(grunt);

  // Project configuration.
  grunt.initConfig({

    config: {
      src: 'source',
      dist: '.'
    },

    watch: {
      assemble: {
        files: ['<%= config.src %>/{content,data,templates,assets}/{,*/}*.{md,hbs,yml,sass,scss,js}'],
        tasks: ['assemble', 'sass', 'copy']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/{,*/}*.html',
          '<%= config.dist %>/assets/{,*/}*.css',
          '<%= config.dist %>/assets/{,*/}*.js',
          '<%= config.dist %>/assets/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          open: true,
          base: [
            '<%= config.dist %>'
          ]
        }
      }
    },

    sass: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.src %>/assets/styles',
          src: ['*.scss', '*.sass'],
          dest: '<%= config.dist %>/assets/css',
          ext: '.css'
        }]
      }
    },

    copy: {
      main: {
        files: [
          // Copy any vanilla CSS files included in the style source
          {expand: true, cwd: '<%= config.src %>/assets/styles', src: ['**', '!*.scss', '!*.sass'], dest: '<%= config.dist %>/assets/css'},

          // Copy any vanilla JS files included in the script source
          {expand: true, cwd: '<%= config.src %>/assets/scripts', src: ['**', '!*.coffee'], dest: '<%= config.dist %>/assets/js'}
        ]
      }
    },

    assemble: {
      pages: {
        options: {
          flatten: true,
          assets: '<%= config.dist %>/assets',
          layout: '<%= config.src %>/templates/layouts/default.hbs',
          data: '<%= config.src %>/data/*.{json,yml}',
          partials: '<%= config.src %>/templates/partials/*.hbs',
          plugins: ['assemble-markdown-data'],
          helpers: ['handlebars-helper-slugify']
        },
        files: {
          '<%= config.dist %>/': ['<%= config.src %>/templates/pages/*.hbs']
        }
      }
    },

    // Before generating any new files,
    // remove any previously-created files.
    // ** ALL FILES IN /build WILL BE DELETED **
    //clean: ['<%= config.dist %>/**/*.{html,xml,css,js}']

  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-copy');

  grunt.registerTask('server', [
    //'clean',
    'copy',
    'sass',
    'assemble',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    //'clean',
    'copy',
    'sass',
    'assemble',
  ]);

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

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    grunt.loadTasks('tasks');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        mochaTest: {
            unit: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            },
            functional: {
                options: {
                    reporter: 'spec'
                },
                src: ['functionalTest/**/*.js']
            },
            performance: {
                options: {
                    reporter: 'spec'
                },
                src: ['performanceTest/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'coverage.html',
                    require: 'coverage/blanket'
                },
                src: ['test/**/*.js']
            }
        },
        jshint: {
            all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', 'functionalTest/**/*.js', 'performanceTest/**/*.js', 'bin/mb'],
            options: {
                node: true,
                globals: {
                    describe: false,
                    it: false,
                    before: false,
                    beforeEach: false,
                    after: false,
                    afterEach: false
                },
                newcap: false,
                camelcase: true,
                curly: true,
                eqeqeq: true,
                latedef: true,
                undef: true,
                unused: true,
                trailing: true,
                maxparams: 4,
                maxdepth: 3,
                maxcomplexity: 5
            }
        }
    });

    grunt.registerTask('setAirplaneMode', function () {
        process.env.MB_AIRPLANE_MODE = 'true';
    });

    grunt.registerTask('test:unit', 'Run the unit tests', ['mochaTest:unit']);
    grunt.registerTask('test:functional', 'Run the functional tests',
        ['mb:start', 'try', 'mochaTest:functional', 'finally', 'mb:stop', 'checkForErrors']);
    grunt.registerTask('test:performance', 'Run the performance tests', ['mochaTest:performance']);
    grunt.registerTask('test', 'Run all non-performance tests', ['test:unit', 'test:functional']);
    grunt.registerTask('coverage', 'Generate code coverage', ['mochaTest:coverage']);
    grunt.registerTask('lint', 'Run all JavaScript lint checks', ['wsCheck', 'jsCheck', 'deadCheck', 'jshint']);
    grunt.registerTask('default', ['dist', 'version', 'test', 'lint']);

    grunt.registerTask('local', 'Fast build for local development (avoids distribution)', ['test', 'lint']);
    grunt.registerTask('airplane', 'Build that avoids tests requiring network access', ['setAirplaneMode', 'local']);

    // Package-specific testing
    grunt.registerTask('test:tarball:x64', 'Run tests against packaged tarball',
        ['dist', 'version', 'dist:tarball:x64', 'install:tarball:x64', 'test', 'lint']);
    grunt.registerTask('test:zip:x64', 'Run tests against packaged zipfile',
        ['download:zip:x64', 'install:zip:x64', 'test', 'lint']);
    grunt.registerTask('test:zip:x86', 'Run tests against packaged zipfile',
        ['download:zip:x86', 'install:zip:x86', 'test', 'lint']);
    grunt.registerTask('test:npm', 'Run tests against npm package',
        ['dist', 'version', 'dist:npm', 'install:npm', 'test']);
    grunt.registerTask('test:pkg', 'Run tests against OSX pkg file',
        ['dist', 'version', 'dist:package:osxpkg', 'install:pkg', 'test']);
    grunt.registerTask('test:deb', 'Run tests against Debian package',
        ['dist', 'version', 'dist:package:deb', 'install:deb', 'test', 'uninstall:deb']);
};
<commit_msg>fixing task to run in arch-independent fashion<commit_after>'use strict';

module.exports = function (grunt) {

    grunt.loadTasks('tasks');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        mochaTest: {
            unit: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            },
            functional: {
                options: {
                    reporter: 'spec'
                },
                src: ['functionalTest/**/*.js']
            },
            performance: {
                options: {
                    reporter: 'spec'
                },
                src: ['performanceTest/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'coverage.html',
                    require: 'coverage/blanket'
                },
                src: ['test/**/*.js']
            }
        },
        jshint: {
            all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', 'functionalTest/**/*.js', 'performanceTest/**/*.js', 'bin/mb'],
            options: {
                node: true,
                globals: {
                    describe: false,
                    it: false,
                    before: false,
                    beforeEach: false,
                    after: false,
                    afterEach: false
                },
                newcap: false,
                camelcase: true,
                curly: true,
                eqeqeq: true,
                latedef: true,
                undef: true,
                unused: true,
                trailing: true,
                maxparams: 4,
                maxdepth: 3,
                maxcomplexity: 5
            }
        }
    });

    grunt.registerTask('setAirplaneMode', function () {
        process.env.MB_AIRPLANE_MODE = 'true';
    });

    grunt.registerTask('test:unit', 'Run the unit tests', ['mochaTest:unit']);
    grunt.registerTask('test:functional', 'Run the functional tests',
        ['mb:start', 'try', 'mochaTest:functional', 'finally', 'mb:stop', 'checkForErrors']);
    grunt.registerTask('test:performance', 'Run the performance tests', ['mochaTest:performance']);
    grunt.registerTask('test', 'Run all non-performance tests', ['test:unit', 'test:functional']);
    grunt.registerTask('coverage', 'Generate code coverage', ['mochaTest:coverage']);
    grunt.registerTask('lint', 'Run all JavaScript lint checks', ['wsCheck', 'jsCheck', 'deadCheck', 'jshint']);
    grunt.registerTask('default', ['dist', 'version', 'test', 'lint']);

    grunt.registerTask('local', 'Fast build for local development (avoids distribution)', ['test', 'lint']);
    grunt.registerTask('airplane', 'Build that avoids tests requiring network access', ['setAirplaneMode', 'local']);

    // Package-specific testing
    grunt.registerTask('test:tarball:x64', 'Run tests against packaged tarball',
        ['dist', 'version', 'dist:tarball:x64', 'install:tarball:x64', 'test', 'lint']);
    grunt.registerTask('test:zip', 'Run tests against packaged zipfile',
        ['download:zip', 'install:zip', 'test', 'lint']);
    grunt.registerTask('test:npm', 'Run tests against npm package',
        ['dist', 'version', 'dist:npm', 'install:npm', 'test']);
    grunt.registerTask('test:pkg', 'Run tests against OSX pkg file',
        ['dist', 'version', 'dist:package:osxpkg', 'install:pkg', 'test']);
    grunt.registerTask('test:deb', 'Run tests against Debian package',
        ['dist', 'version', 'dist:package:deb', 'install:deb', 'test', 'uninstall:deb']);
};
<|endoftext|>


<commit_before>"use strict";

module.exports = function (grunt) {

    grunt.initConfig({

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

        config: {
            outputDir: "dist/",

            applicationFiles: [
                "app/js/sn-example-app/app.js",
                "app/js/*.js",
                "app/js/**/*.js",
                "app/js/**/**/*.js"
            ],

            vendorFiles: [
                "app/components/angular/angular.js",
                "app/components/angular-mocks/angular-mocks.js",
                "app/components/angular-route/angular-route.js",
            ]
        },

        connect: {
            server: {
                options: {
                    hostname: "0.0.0.0",
                    port: 8000,
                    livereload: true,
                    open: "http://localhost:8000/app/"
                }
            },
            servertest: {
                options: {
                    keepalive: false,
                    hostname: "0.0.0.0",
                    port: 8000,
                    livereload: false,
                    open: "http://localhost:8000/app/"
                }
            }
        },

        watch: {
            css: {
                files: [
                    "app/index.html",
                    "app/less/*.less",
                    "app/less/**/*.less",
                    "app/less/**/**/*.less",
                    "app/modules/*.html",
                    "app/modules/**/*.html",
                    "app/modules/**/**/*.html",
                    "app/partials/*.html",
                    "app/partials/**/*.html",
                    "app/partials/**/**/*.html"
                ],
                tasks: ["less:development"],
                options: {
                    nospawn: false,
                    livereload: true
                }
            },
            javascript: {
                files: [
                    "app/js/*.js",
                    "app/js/**/*.js",
                    "app/js/**/**/*.js",
                    "test/unit/**/*.js",
                    "test/unit/**/**/*.js",
                    "test/unit/**/**/**/*.js"
                ],
                tasks: ["jshint", "jasmine"],
                options: {
                    nospawn: false,
                    livereload: true
                }
            }
        },

        less: {
            development: {
                options: {
                    paths: ["app/less/"],
                    cleancss: false
                },
                files: {
                    "app/css/all.css": "app/less/main.less"
                }
            },
            production: {
                options: {
                    paths: ["app/less/"],
                    cleancss: true
                },
                files: {
                    "<%= config.outputDir %>/css/all.min.css": "app/less/main.less"
                }
            }
        },

        jshint: {
            dist: {
                src: ["<%= config.applicationFiles %>"]
            },
            options: {
                strict: false,
                browser: true,
                devel: true,
                asi: true,
                globalstrict: true,
                globals: {
                    "angular": true
                }
            }
        },

        jasmine: {
            dist: {
                src: ["<%= config.applicationFiles %>"],
                options: {
                    specs: ["tests/unit/**/*.js"],
                    keepRunner: true,
                    vendor: "<%= config.vendorFiles %>"
                }
            }
        },

        protractor: {
            options: {
                configFile: "node_modules/protractor/referenceConf.js", // Default config file
                keepAlive: true, // If false, the grunt process stops when the test fails.
                noColor: false, // If true, protractor will not use colors in its output.
                args: {
                    // Arguments passed to the command
                }
            },
            dist: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
                options: {
                    configFile: "tests/e2e/e2e.conf.js", // Target-specific config file
                    args: {} // Target-specific arguments
                }
            }
        },

        protractor_webdriver: {
            dist: {
                options: {

                }
            }
        },

        concat: {
            options: {
                separator: ";",
            },
            dist: {
                src: ["<%= config.vendorFiles %>", "<%= config.applicationFiles %>"],
                dest: "<%= config.outputDir %>/js/app.js",
            }
        },

        uglify: {
            dist: {
                files: {
                    "<%= config.outputDir %>/js/app.min.js": ["<%= config.vendorFiles %>", "<%= config.applicationFiles %>"]
                }
            }
        },

        copy: {
            images: {
                files: [{
                    expand: true,
                    cwd: "app/img",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/img/"
                }]
            },
            javascript: {
                files: [{
                    expand: true,
                    cwd: "app/components",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/components/"
                },
                {
                    expand: true,
                    cwd: "app/js",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/js/"
                }]
            },
            css: {
                files: [{
                    expand: true,
                    cwd: "app/css",
                    src: ["*.css"],
                    dest: "<%= config.outputDir %>/css/"
                }]
            },
            partials: {
                files: [{
                    expand: true,
                    cwd: "app/partials",
                    src: ["*.html"],
                    dest: "<%= config.outputDir %>/partials/"
                }]
            }
        },

        clean: {
            beforeBuild: {
                src: ["<%= config.outputDir %>"]
            }
        },

        processhtml: {
            options: {
                data: {
                    message: "processing 'index.html' file"
                }
            },
            development: {
                files: {
                    "<%= config.outputDir %>/index.html": ["app/index.html"]
                }
            },
            dist: {
                files: {
                    "<%= config.outputDir %>/index.html": ["app/index.html"]
                }
            }
        },

        yuidoc: {
            compile: {
                name: "<%= pkg.name %>",
                description: "<%= pkg.description %>",
                version: "<%= pkg.version %>",
                url: "<%= pkg.homepage %>",
                options: {
                    paths: "app/js/",
                	themedir: "node_modules/yuidoc-bootstrap-theme",
        			helpers: ["node_modules/yuidoc-bootstrap-theme/helpers/helpers.js"],
                    outdir: "docs/"
                }
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks('grunt-contrib-yuidoc');
    grunt.loadNpmTasks("grunt-contrib-jasmine");
    grunt.loadNpmTasks('grunt-protractor-runner');
    grunt.loadNpmTasks('grunt-protractor-webdriver');
    grunt.loadNpmTasks("grunt-processhtml");

    grunt.registerTask("build", [
        "jshint",
        "jasmine",
        "clean:beforeBuild",
        "yuidoc",
        "less:production",
        "uglify",
        "copy:images",
        "copy:partials",
        "processhtml:dist"
    ]);

    grunt.registerTask("stage", [
        "jshint",
        "jasmine",
        "clean:beforeBuild",
        "yuidoc",
        "less:development",
        "copy",
        "processhtml:development"
    ]);

    grunt.registerTask("server", [
        "less:development",
        "connect:server",
        "watch:css"
    ]);

    grunt.registerTask("serverall", [
        "less:development",
        "connect:server",
        "watch"
    ]);

    grunt.registerTask("test", [
        "jshint",
        "jasmine"
    ]);

    grunt.registerTask("e2e", [
        "connect:servertest",
        "protractor_webdriver",
        "protractor"
    ]);

    grunt.registerTask("default", ["stage"]);
    grunt.registerTask("release", ["build"]);

};
<commit_msg>add e2e tests to build tasks<commit_after>"use strict";

module.exports = function (grunt) {

    grunt.initConfig({

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

        config: {
            outputDir: "dist/",

            applicationFiles: [
                "app/js/sn-example-app/app.js",
                "app/js/*.js",
                "app/js/**/*.js",
                "app/js/**/**/*.js"
            ],

            vendorFiles: [
                "app/components/angular/angular.js",
                "app/components/angular-mocks/angular-mocks.js",
                "app/components/angular-route/angular-route.js",
            ]
        },

        connect: {
            server: {
                options: {
                    hostname: "0.0.0.0",
                    port: 8000,
                    livereload: true,
                    open: "http://localhost:8000/app/"
                }
            },
            servertest: {
                options: {
                    keepalive: false,
                    hostname: "0.0.0.0",
                    port: 8000,
                    livereload: false,
                    open: "http://localhost:8000/app/"
                }
            }
        },

        watch: {
            css: {
                files: [
                    "app/index.html",
                    "app/less/*.less",
                    "app/less/**/*.less",
                    "app/less/**/**/*.less",
                    "app/modules/*.html",
                    "app/modules/**/*.html",
                    "app/modules/**/**/*.html",
                    "app/partials/*.html",
                    "app/partials/**/*.html",
                    "app/partials/**/**/*.html"
                ],
                tasks: ["less:development"],
                options: {
                    nospawn: false,
                    livereload: true
                }
            },
            javascript: {
                files: [
                    "app/js/*.js",
                    "app/js/**/*.js",
                    "app/js/**/**/*.js",
                    "test/unit/**/*.js",
                    "test/unit/**/**/*.js",
                    "test/unit/**/**/**/*.js"
                ],
                tasks: ["jshint", "jasmine"],
                options: {
                    nospawn: false,
                    livereload: true
                }
            }
        },

        less: {
            development: {
                options: {
                    paths: ["app/less/"],
                    cleancss: false
                },
                files: {
                    "app/css/all.css": "app/less/main.less"
                }
            },
            production: {
                options: {
                    paths: ["app/less/"],
                    cleancss: true
                },
                files: {
                    "<%= config.outputDir %>/css/all.min.css": "app/less/main.less"
                }
            }
        },

        jshint: {
            dist: {
                src: ["<%= config.applicationFiles %>"]
            },
            options: {
                strict: false,
                browser: true,
                devel: true,
                asi: true,
                globalstrict: true,
                globals: {
                    "angular": true
                }
            }
        },

        jasmine: {
            dist: {
                src: ["<%= config.applicationFiles %>"],
                options: {
                    specs: ["tests/unit/**/*.js"],
                    keepRunner: true,
                    vendor: "<%= config.vendorFiles %>"
                }
            }
        },

        protractor: {
            options: {
                configFile: "node_modules/protractor/referenceConf.js", // Default config file
                keepAlive: true, // If false, the grunt process stops when the test fails.
                noColor: false, // If true, protractor will not use colors in its output.
                args: {
                    // Arguments passed to the command
                }
            },
            dist: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
                options: {
                    configFile: "tests/e2e/e2e.conf.js", // Target-specific config file
                    args: {} // Target-specific arguments
                }
            }
        },

        protractor_webdriver: {
            dist: {
                options: {

                }
            }
        },

        concat: {
            options: {
                separator: ";",
            },
            dist: {
                src: ["<%= config.vendorFiles %>", "<%= config.applicationFiles %>"],
                dest: "<%= config.outputDir %>/js/app.js",
            }
        },

        uglify: {
            dist: {
                files: {
                    "<%= config.outputDir %>/js/app.min.js": ["<%= config.vendorFiles %>", "<%= config.applicationFiles %>"]
                }
            }
        },

        copy: {
            images: {
                files: [{
                    expand: true,
                    cwd: "app/img",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/img/"
                }]
            },
            javascript: {
                files: [{
                    expand: true,
                    cwd: "app/components",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/components/"
                },
                {
                    expand: true,
                    cwd: "app/js",
                    src: ["**/*"],
                    dest: "<%= config.outputDir %>/js/"
                }]
            },
            css: {
                files: [{
                    expand: true,
                    cwd: "app/css",
                    src: ["*.css"],
                    dest: "<%= config.outputDir %>/css/"
                }]
            },
            partials: {
                files: [{
                    expand: true,
                    cwd: "app/partials",
                    src: ["*.html"],
                    dest: "<%= config.outputDir %>/partials/"
                }]
            }
        },

        clean: {
            beforeBuild: {
                src: ["<%= config.outputDir %>"]
            }
        },

        processhtml: {
            options: {
                data: {
                    message: "processing 'index.html' file"
                }
            },
            development: {
                files: {
                    "<%= config.outputDir %>/index.html": ["app/index.html"]
                }
            },
            dist: {
                files: {
                    "<%= config.outputDir %>/index.html": ["app/index.html"]
                }
            }
        },

        yuidoc: {
            compile: {
                name: "<%= pkg.name %>",
                description: "<%= pkg.description %>",
                version: "<%= pkg.version %>",
                url: "<%= pkg.homepage %>",
                options: {
                    paths: "app/js/",
                	themedir: "node_modules/yuidoc-bootstrap-theme",
        			helpers: ["node_modules/yuidoc-bootstrap-theme/helpers/helpers.js"],
                    outdir: "docs/"
                }
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks('grunt-contrib-yuidoc');
    grunt.loadNpmTasks("grunt-contrib-jasmine");
    grunt.loadNpmTasks('grunt-protractor-runner');
    grunt.loadNpmTasks('grunt-protractor-webdriver');
    grunt.loadNpmTasks("grunt-processhtml");

    grunt.registerTask("build", [
        "jshint",
        "jasmine",
        "e2e",
        "clean:beforeBuild",
        "yuidoc",
        "less:production",
        "uglify",
        "copy:images",
        "copy:partials",
        "processhtml:dist"
    ]);

    grunt.registerTask("stage", [
        "jshint",
        "jasmine",
        "e2e",
        "clean:beforeBuild",
        "yuidoc",
        "less:development",
        "copy",
        "processhtml:development"
    ]);

    grunt.registerTask("server", [
        "less:development",
        "connect:server",
        "watch:css"
    ]);

    grunt.registerTask("serverall", [
        "less:development",
        "connect:server",
        "watch"
    ]);

    grunt.registerTask("test", [
        "jshint",
        "jasmine"
    ]);

    grunt.registerTask("e2e", [
        "connect:servertest",
        "protractor_webdriver",
        "protractor"
    ]);

    grunt.registerTask("default", ["stage"]);
    grunt.registerTask("release", ["build"]);

};
<|endoftext|>