<commit_before>// Generated on 2015-03-09 using generator-jekyllrb 1.4.1
'use strict';

// Directory reference:
//   css: css
//   compass: _scss
//   javascript: js
//   images: img
//   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'
    },
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/js/{,*/}*.js'],
        tasks: ['jshint'],
        options: {
          livereload: true
        }
      },
      compass: {
        files: ['<%= yeoman.app %>/_scss/**/*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      jekyll: {
        files: [
          '<%= yeoman.app %>/**/*.{html,yml,md,mkd,markdown}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      }
    },
    browserSync: {
      server: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/css/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '{<%= yeoman.app %>}/_bower_components/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      },
      dist: {
        options: {
          server: {
            baseDir: '<%= yeoman.dist %>'
          }
        }
      },
      test: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/css/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '{<%= yeoman.app %>}/_bower_components/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
          ]
        },
        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*'
          ]
        }]
      },
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    compass: {
      options: {
        // If you're using global Sass gems, require them here.
        // require: ['singularity', 'jacket'],
        sassDir: '<%= yeoman.app %>/_scss',
        cssDir: '.tmp/css',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        fontsDir: '<%= yeoman.app %>/_scss/fonts',
        httpFontsPath: '/_scss/fonts',
        relativeAssets: false,
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img',
        outputStyle: 'expanded',
        importPath: '<%= yeoman.app %>/_bower_components',
        // raw: 'extensions_dir = "<%= yeoman.app %>/_bower_components"\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/img'
        }
      },
      server: {
        options: {
          debugInfo: true,
          generatedImagesDir: '.tmp/img'
        }
      }
    },
    jekyll: {
      options: {
        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 %>', '<%= yeoman.dist %>/img']
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/css/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: 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: 'gzip'
        }
      }
    },
    imagemin: {
      dist: {
        options: {
          progressive: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.{jpg,jpeg,png}',
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          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.
            'img/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore.
            '!**/_*{,/**}'
            // Explicitly add any files your site needs for distribution here.
            //'_bower_components/jquery/jquery.min.js',
            //'favicon.ico',
            //'apple-touch*.png'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/js/**/*.js',
            '<%= yeoman.dist %>/css/**/*.css',
            '<%= yeoman.dist %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}',
            '<%= yeoman.dist %>/fonts/**/*.{eot*,otf,svg,ttf,woff}'
          ]
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          remote: '../',
          branch: 'gh-pages',
          commit: true,
          push: true
        }
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/js/**/*.js',
        'test/spec/**/*.js'
      ]
    },
    csslint: {
      options: {
        csslintrc: '.csslintrc'
      },
      check: {
        src: [
          '<%= yeoman.app %>/css/**/*.css'
        ]
      }
    },
    // https://github.com/robwierzbowski/generator-jekyllrb/issues/106
    // scsslint: {
    //   // See https://www.npmjs.org/package/grunt-scss-lint for options.
    //   allFiles: [
    //     '<%= yeoman.app %>/_scss/**/*.scss'
    //   ]
    // },
    concurrent: {
      server: [
        'compass:server',
        'jekyll:server'
      ],
      dist: [
        'compass:dist',
        'copy:dist'
      ]
    },

    // Automatically inject Bower components into the HTML file
    wiredep: {
      app: {
        ignorePath: /^\/|\.\.\//,
        src: ['<%= yeoman.app %>/_layouts/default.html'],
        exclude: ['_bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js']
      },
      sass: {
        src: ['<%= yeoman.app %>/{_scss, css}/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}_bower_components\//
      }
    }
  });

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

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

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

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

  grunt.registerTask('check', [
    'clean:server',
    'jekyll:check',
    'compass:server',
    'jshint:all',
    'csslint:check'
    // 'scsslint'
  ]);

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

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

  grunt.registerTask('default', [
    'check',
    'test',
    'build'
  ]);
};
<commit_msg>update grunt tasks<commit_after>// Generated on 2015-03-09 using generator-jekyllrb 1.4.1
'use strict';

// Directory reference:
//   css: css
//   compass: _scss
//   javascript: js
//   images: img
//   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'
    },
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/js/{,*/}*.js'],
        tasks: ['jshint'],
        options: {
          livereload: true
        }
      },
      compass: {
        files: ['<%= yeoman.app %>/_scss/**/*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      jekyll: {
        files: [
          '<%= yeoman.app %>/**/*.{html,yml,md,mkd,markdown}',
          '!<%= yeoman.app %>/_bower_components/**/*'
        ],
        tasks: ['jekyll:server']
      }
    },
    browserSync: {
      server: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/css/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '{<%= yeoman.app %>}/_bower_components/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
          ]
        },
        options: {
          server: {
            baseDir: [
              '.jekyll',
              '.tmp',
              '<%= yeoman.app %>'
            ]
          },
          watchTask: true
        }
      },
      dist: {
        options: {
          server: {
            baseDir: '<%= yeoman.dist %>'
          }
        }
      },
      test: {
        bsFiles: {
          src: [
            '.jekyll/**/*.html',
            '.tmp/css/**/*.css',
            '{.tmp,<%= yeoman.app %>}/js/**/*.js',
            '{<%= yeoman.app %>}/_bower_components/**/*.js',
            '<%= yeoman.app %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}'
          ]
        },
        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*'
          ]
        }]
      },
      server: [
        '.tmp',
        '.jekyll'
      ]
    },
    compass: {
      options: {
        // If you're using global Sass gems, require them here.
        // require: ['singularity', 'jacket'],
        sassDir: '<%= yeoman.app %>/_scss',
        cssDir: '.tmp/css',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        fontsDir: '<%= yeoman.app %>/fonts',
        httpFontsPath: '/fonts',
        relativeAssets: false,
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img',
        outputStyle: 'expanded',
        importPath: '<%= yeoman.app %>/_bower_components',
        // raw: 'extensions_dir = "<%= yeoman.app %>/_bower_components"\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/img'
        }
      },
      server: {
        options: {
          debugInfo: true,
          generatedImagesDir: '.tmp/img'
        }
      }
    },
    jekyll: {
      options: {
        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 %>', '<%= yeoman.dist %>/img', '<%= yeoman.app %>/_bower_components' ]
      },
      html: ['<%= yeoman.dist %>/**/*.html'],
      css: ['<%= yeoman.dist %>/css/**/*.css']
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeAttributeQuotes: true,
          removeRedundantAttributes: 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: 'gzip'
        }
      }
    },
    imagemin: {
      dist: {
        options: {
          progressive: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['**/*.{jpg,jpeg,png}'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: '**/*.svg',
          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.
            'img/**/*',
            'fonts/**/*',
            // Like Jekyll, exclude files & folders prefixed with an underscore.
            '!**/_*{,/**}'
            // Explicitly add any files your site needs for distribution here.
            //'_bower_components/jquery/jquery.min.js',
            //'favicon.ico',
            //'apple-touch*.png'
          ],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    filerev: {
      options: {
        length: 4
      },
      dist: {
        files: [{
          src: [
            '<%= yeoman.dist %>/js/**/*.js',
            '<%= yeoman.dist %>/css/**/*.css',
            '<%= yeoman.dist %>/img/**/*.{gif,jpg,jpeg,png,svg,webp}',
            '!<%= yeoman.dist %>/img/{covers,covers-hd}/*',
            '!<%= yeoman.dist %>/img/{logos,logos-hd}/*',
            '<%= yeoman.dist %>/fonts/**/*.{eot*,otf,svg,ttf,woff}'
          ]
        }]
      }
    },
    buildcontrol: {
      dist: {
        options: {
          remote: '../',
          branch: 'gh-pages',
          commit: true,
          push: true
        }
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/js/**/*.js',
        'test/spec/**/*.js'
      ]
    },
    csslint: {
      options: {
        csslintrc: '.csslintrc'
      },
      check: {
        src: [
          '<%= yeoman.app %>/css/**/*.css'
        ]
      }
    },
    // https://github.com/robwierzbowski/generator-jekyllrb/issues/106
    // scsslint: {
    //   // See https://www.npmjs.org/package/grunt-scss-lint for options.
    //   allFiles: [
    //     '<%= yeoman.app %>/_scss/**/*.scss'
    //   ]
    // },
    concurrent: {
      server: [
        'compass:server',
        'jekyll:server'
      ],
      dist: [
        'compass:dist',
        'copy:dist'
      ]
    },

    // Automatically inject Bower components into the HTML file
    wiredep: {
      options: {
        // cwd: '/'
      },
      app: {
        ignorePath: /^\/|\.\./,
        src: ['<%= yeoman.app %>/_layouts/{default,place}.html'],
        exclude: ['_bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js']
      },
      sass: {
        src: ['<%= yeoman.app %>/{_scss, css}/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}_bower_components\//
      }
    }
  });

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

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

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

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

  grunt.registerTask('check', [
    'clean:server',
    'jekyll:check',
    'compass:server',
    'jshint:all',
    'csslint:check'
    // 'scsslint'
  ]);

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

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

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


<commit_before>module.exports = function (grunt) {
    var shortid = require('shortid');

    /**
     * An ID that is unique for each build to prevent browser caching. This needs to be set before the other
     * configuration which relies on this ID.
     */
        // ToDo: why are these id's not equal?
    var uniqueIdJs = shortid.generate();
    var uniqueIdCss = shortid.generate();

    grunt.config.set('uniqueIdJs', uniqueIdJs);
    grunt.config.set('uniqueIdCss', uniqueIdCss);

    grunt.initConfig({
        babel: require('./grunt/babel')(grunt),
        bower_concat: require('./grunt/bower-concat'),
        clean: require('./grunt/clean'),
        concat: require('./grunt/concat')(grunt),
        connect: require('./grunt/connect'),
        'console-log-test': require('./grunt/console-log-test'),
        copy: require('./grunt/copy'),
        jshint: require('./grunt/jshint'),
        eslint: require('./grunt/eslint'),
        karma: require('./grunt/karma'),
        ngtemplates: require('./grunt/angular-templates'),
        postcss: require('./grunt/postcss')(grunt),
        sass: require('./grunt/sass'),
        sasslint: require('./grunt/sasslint'),
        tags: require('./grunt/script-link-tags')(grunt),
        watch: require('./grunt/watch')
    });

    grunt.registerTask('build-develop', [
        'clean:build',

        'copy:index',
        'copy:assets',
        'copy:bower_bbga_fonts',
        'copy:bower_leaflet_images',
        'copy:bower_leaflet_measure_images',

        'build-js',
        'build-css'
    ]);

    grunt.registerTask('build-release', [
        'build-develop',
        'clean:temp'
    ]);

    grunt.registerTask('build-bower', [
        'bower_concat:js',
        'concat:bower',
    ]);

    grunt.registerTask('build-babel', [
        'concat:modules',
        'babel-modules-configure',
        'babel:modules'
    ]);

    grunt.registerTask('test-js', [
        'jshint',
        'test-babel',
        'console-log-test'
    ]);

    grunt.registerTask('test-css', [
        'sasslint'
    ]);

    grunt.registerTask('test-babel', [
        'concat:tests',
        'babel-tests-configure',
        'babel:tests',
        'karma:coverage'
    ]);

    grunt.registerTask('babel-tests-configure', 'Configure babel tests options', function() {
        // Inject the source maps from the concat operation in the new babel sourcemap
        grunt.config.set('babel.tests.options.inputSourceMap',
            grunt.file.readJSON('build/temp/babel/atlas.tests.es6.js.map'));
    });

    grunt.registerTask('babel-modules-configure', 'Configure babel options', function() {
        // Inject the source maps from the concat operation in the new babel sourcemap
        grunt.config.set('babel.options.inputSourceMap',
            grunt.file.readJSON('build/temp/babel/atlas.' + uniqueIdJs + '.js.map'));
    });

    /**
     * The output of build-js are two files 'build/atlas.js' and a source map.
     */
    grunt.registerTask('build-js', [
        'build-bower',
        'ngtemplates',
        'build-babel',
        'tags:js'
    ]);

    /**
     * The output of build-css are two files 'build/atlas.css' and a source map.
     */
    grunt.registerTask('build-css', [
        'bower_concat:css',
        'sass',
        'concat:css',
        'postcss',
        'tags:css'
    ]);

    /**
     * 'default' formerly known as 'grunt serve'
     */
    grunt.registerTask('default', [
        'build-develop',
        'connect:build',
        'watch'
    ]);

    grunt.registerTask('test', [
        'build-develop',
        'test-js',
        'test-css'
    ]);

    grunt.loadNpmTasks('grunt-angular-templates');
    grunt.loadNpmTasks('grunt-babel');
    // grunt.loadNpmTasks('karma-babel-preprocessor');
    grunt.loadNpmTasks('grunt-bower-concat');
    grunt.loadNpmTasks('grunt-console-log-test');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-postcss');
    grunt.loadNpmTasks("grunt-eslint");
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-sass-lint');
    grunt.loadNpmTasks('grunt-script-link-tags');
};<commit_msg>eslint in testjs task verwerkt<commit_after>module.exports = function (grunt) {
    var shortid = require('shortid');

    /**
     * An ID that is unique for each build to prevent browser caching. This needs to be set before the other
     * configuration which relies on this ID.
     */
        // ToDo: why are these id's not equal?
    var uniqueIdJs = shortid.generate();
    var uniqueIdCss = shortid.generate();

    grunt.config.set('uniqueIdJs', uniqueIdJs);
    grunt.config.set('uniqueIdCss', uniqueIdCss);

    grunt.initConfig({
        babel: require('./grunt/babel')(grunt),
        bower_concat: require('./grunt/bower-concat'),
        clean: require('./grunt/clean'),
        concat: require('./grunt/concat')(grunt),
        connect: require('./grunt/connect'),
        'console-log-test': require('./grunt/console-log-test'),
        copy: require('./grunt/copy'),
        jshint: require('./grunt/jshint'),
        eslint: require('./grunt/eslint'),
        karma: require('./grunt/karma'),
        ngtemplates: require('./grunt/angular-templates'),
        postcss: require('./grunt/postcss')(grunt),
        sass: require('./grunt/sass'),
        sasslint: require('./grunt/sasslint'),
        tags: require('./grunt/script-link-tags')(grunt),
        watch: require('./grunt/watch')
    });

    grunt.registerTask('build-develop', [
        'clean:build',

        'copy:index',
        'copy:assets',
        'copy:bower_bbga_fonts',
        'copy:bower_leaflet_images',
        'copy:bower_leaflet_measure_images',

        'build-js',
        'build-css'
    ]);

    grunt.registerTask('build-release', [
        'build-develop',
        'clean:temp'
    ]);

    grunt.registerTask('build-bower', [
        'bower_concat:js',
        'concat:bower',
    ]);

    grunt.registerTask('build-babel', [
        'concat:modules',
        'babel-modules-configure',
        'babel:modules'
    ]);

    grunt.registerTask('test-js', [
        'jshint',
        'eslint',
        'test-babel',
        'console-log-test'
    ]);

    grunt.registerTask('test-css', [
        'sasslint'
    ]);

    grunt.registerTask('test-babel', [
        'concat:tests',
        'babel-tests-configure',
        'babel:tests',
        'karma:coverage'
    ]);

    grunt.registerTask('babel-tests-configure', 'Configure babel tests options', function() {
        // Inject the source maps from the concat operation in the new babel sourcemap
        grunt.config.set('babel.tests.options.inputSourceMap',
            grunt.file.readJSON('build/temp/babel/atlas.tests.es6.js.map'));
    });

    grunt.registerTask('babel-modules-configure', 'Configure babel options', function() {
        // Inject the source maps from the concat operation in the new babel sourcemap
        grunt.config.set('babel.options.inputSourceMap',
            grunt.file.readJSON('build/temp/babel/atlas.' + uniqueIdJs + '.js.map'));
    });

    /**
     * The output of build-js are two files 'build/atlas.js' and a source map.
     */
    grunt.registerTask('build-js', [
        'build-bower',
        'ngtemplates',
        'build-babel',
        'tags:js'
    ]);

    /**
     * The output of build-css are two files 'build/atlas.css' and a source map.
     */
    grunt.registerTask('build-css', [
        'bower_concat:css',
        'sass',
        'concat:css',
        'postcss',
        'tags:css'
    ]);

    /**
     * 'default' formerly known as 'grunt serve'
     */
    grunt.registerTask('default', [
        'build-develop',
        'connect:build',
        'watch'
    ]);

    grunt.registerTask('test', [
        'build-develop',
        'test-js',
        'test-css'
    ]);

    grunt.loadNpmTasks('grunt-angular-templates');
    grunt.loadNpmTasks('grunt-babel');
    // grunt.loadNpmTasks('karma-babel-preprocessor');
    grunt.loadNpmTasks('grunt-bower-concat');
    grunt.loadNpmTasks('grunt-console-log-test');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-postcss');
    grunt.loadNpmTasks('grunt-eslint');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-sass-lint');
    grunt.loadNpmTasks('grunt-script-link-tags');
};<|endoftext|>


<commit_before>'use strict';

module.exports = function( grunt ) {
    var JS_INCLUDE = [ '**/*.js', '!node_modules/**', '!test/**/*.spec.js', '!public/js/*-bundle.js', '!public/js/*-bundle.min.js' ];
    var pkg = grunt.file.readJSON( 'package.json' );

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

    grunt.config.init( {
        concurrent: {
            develop: {
                tasks: [ 'nodemon', 'watch' ],
                options: {
                    logConcurrentOutput: true
                }
            }
        },
        nodemon: {
            dev: {
                script: 'app.js',
                options: {
                    watch: [ 'app', 'config' ],
                    //nodeArgs: [ '--debug' ],
                    env: {
                        NODE_ENV: 'development',
                        DEBUG: '*, -express:*, -send, -compression, -body-parser:*'
                    }
                }
            }
        },
        sass: {
            options: {
                sourceMap: false,
                importer: function( url, prev, done ) {
                    // fixes relative enketo-core submodule references in npm 3.x.x
                    if ( grunt.option( 'npmv' ) === '3' && /\/node_modules\//.test( url ) && /\/node_modules\/enketo-core\//.test( prev ) ) {
                        url = '../../' + url;
                    }
                    done( {
                        file: url
                    } );
                }
            },
            compile: {
                cwd: 'app/views/styles',
                dest: 'public/css',
                expand: true,
                outputStyle: 'compressed',
                src: '**/*.scss',
                ext: '.css',
                flatten: true,
                extDot: 'last'
            }
        },
        watch: {
            config: {
                files: [ 'config/*.json' ],
                tasks: [ 'client-config-file:create' ]
            },
            sass: {
                files: [ 'app/views/styles/**/*.scss', 'public/widget/**/*.scss' ],
                tasks: [ 'sass' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            },
            jade: {
                files: [ 'app/views/**/*.jade' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            },
            language: {
                files: [ 'app/views/**/*.jade', 'app/controllers/**/*.js', 'app/models/**/*.js', 'public/js/src/**/*.js' ],
                tasks: [ 'shell:translation' ]
            },
            js: {
                files: [ 'public/js/src/**/*.js', 'public/widget/**/*.js' ],
                tasks: [ 'js-dev' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            }
        },
        shell: {
            translation: {
                command: [
                    'cd locales',
                    'gulp',
                    'cd ..'
                ].join( '&&' )
            },
            npmv: {
                command: 'npm -v',
                options: {
                    callback: function( err, stdout, stderr, cb ) {
                        grunt.option( 'npmv', stdout.split( '.' )[ 0 ] );
                        cb( err );
                    }
                }
            }
        },
        jsbeautifier: {
            test: {
                src: JS_INCLUDE,
                options: {
                    config: './.jsbeautifyrc',
                    mode: 'VERIFY_ONLY'
                }
            },
            fix: {
                src: JS_INCLUDE,
                options: {
                    config: './.jsbeautifyrc'
                }
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: JS_INCLUDE,
        },
        // test server JS
        mochaTest: {
            all: {
                options: {
                    reporter: 'dot'
                },
                src: [ 'test/server/**/*.spec.js' ]
            },
            account: {
                src: [ 'test/server/account-*.spec.js' ]
            }
        },
        // test client JS
        karma: {
            options: {
                singleRun: true,
                reporters: [ 'dots' ]
            },
            headless: {
                configFile: 'test/client/config/karma.conf.js',
                browsers: [ 'PhantomJS' ]
            },
            browsers: {
                configFile: 'test/client/config/karma.conf.js',
                browsers: [ 'Chrome', 'ChromeCanary', 'Firefox', 'Opera' /*,'Safari'*/ ],
            }
        },
        browserify: {
            development: {
                files: {
                    'public/js/enketo-webform-dev-bundle.js': [ 'public/js/src/main-webform.js' ],
                    'public/js/enketo-webform-edit-dev-bundle.js': [ 'public/js/src/main-webform-edit.js' ],
                    'public/js/enketo-offline-fallback-dev-bundle.js': [ 'public/js/src/main-offline-fallback.js' ]
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    }
                },
            },
            production: {
                files: {
                    'public/js/enketo-webform-bundle.js': [ 'public/js/src/main-webform.js' ],
                    'public/js/enketo-webform-edit-bundle.js': [ 'public/js/src/main-webform-edit.js' ],
                    'public/js/enketo-offline-fallback-bundle.js': [ 'public/js/src/main-offline-fallback.js' ]
                },
            },
            options: {
                // ensure that enketo-config and widgets are overridden in **enketo-core**
                transform: [
                    [ 'aliasify', {
                        aliases: pkg.aliasify.aliases,
                        global: true
                    } ]
                ]
            },
        },
        uglify: {
            all: {
                files: {
                    'public/js/enketo-webform-bundle.min.js': [ 'public/js/enketo-webform-bundle.js' ],
                    'public/js/enketo-webform-edit-bundle.min.js': [ 'public/js/enketo-webform-edit-bundle.js' ],
                    'public/js/enketo-offline-fallback-bundle.min.js': [ 'public/js/enketo-offline-fallback-bundle.js' ],
                },
            },
        },
        env: {
            develop: {
                NODE_ENV: 'develop'
            },
            test: {
                NODE_ENV: 'test'
            }
        }
    } );

    grunt.registerTask( 'client-config-file', 'Temporary client-config file', function( task ) {
        var clientConfigPath = 'public/temp-client-config.json';
        if ( task === 'create' ) {
            var config = require( './app/models/config-model' );
            grunt.file.write( clientConfigPath, JSON.stringify( config.client ) );
            grunt.log.writeln( 'File ' + clientConfigPath + ' created' );
        } else if ( task === 'remove' ) {
            grunt.file.delete( clientConfigPath );
            grunt.log.writeln( 'File ' + clientConfigPath + ' removed' );
        }
    } );

    grunt.registerTask( 'system-sass-variables', 'Creating _system_variables.scss', function( task ) {
        var systemSassVariablesPath = 'app/views/styles/component/_system_variables.scss';
        var config = require( './app/models/config-model' );
        grunt.file.write( systemSassVariablesPath, '$base-path: "' + config.server[ 'base path' ] + '";' );
        grunt.log.writeln( 'File ' + systemSassVariablesPath + ' created' );
    } );

    grunt.registerTask( 'default', [ 'css', 'js', 'uglify' ] );
    grunt.registerTask( 'js', [ 'client-config-file:create', 'browserify:production' ] );
    grunt.registerTask( 'js-dev', [ 'client-config-file:create', 'browserify:development' ] );
    grunt.registerTask( 'css', [ 'shell:npmv', 'system-sass-variables:create', 'sass' ] );
    grunt.registerTask( 'test', [ 'env:test', 'js', 'css', 'mochaTest:all', 'karma:headless', 'jsbeautifier:test', 'jshint' ] );
    grunt.registerTask( 'test-browser', [ 'env:test', 'css', 'client-config-file:create', 'karma:browsers' ] );
    grunt.registerTask( 'develop', [ 'env:develop', 'js-dev', 'concurrent:develop' ] );
};
<commit_msg>added: test-and-build grunt task that prevents building js and css if tests fail<commit_after>'use strict';

module.exports = function( grunt ) {
    var JS_INCLUDE = [ '**/*.js', '!node_modules/**', '!test/**/*.spec.js', '!public/js/*-bundle.js', '!public/js/*-bundle.min.js' ];
    var pkg = grunt.file.readJSON( 'package.json' );

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

    grunt.config.init( {
        concurrent: {
            develop: {
                tasks: [ 'nodemon', 'watch' ],
                options: {
                    logConcurrentOutput: true
                }
            }
        },
        nodemon: {
            dev: {
                script: 'app.js',
                options: {
                    watch: [ 'app', 'config' ],
                    //nodeArgs: [ '--debug' ],
                    env: {
                        NODE_ENV: 'development',
                        DEBUG: '*, -express:*, -send, -compression, -body-parser:*'
                    }
                }
            }
        },
        sass: {
            options: {
                sourceMap: false,
                importer: function( url, prev, done ) {
                    // fixes relative enketo-core submodule references in npm 3.x.x
                    if ( grunt.option( 'npmv' ) === '3' && /\/node_modules\//.test( url ) && /\/node_modules\/enketo-core\//.test( prev ) ) {
                        url = '../../' + url;
                    }
                    done( {
                        file: url
                    } );
                }
            },
            compile: {
                cwd: 'app/views/styles',
                dest: 'public/css',
                expand: true,
                outputStyle: 'compressed',
                src: '**/*.scss',
                ext: '.css',
                flatten: true,
                extDot: 'last'
            }
        },
        watch: {
            config: {
                files: [ 'config/*.json' ],
                tasks: [ 'client-config-file:create' ]
            },
            sass: {
                files: [ 'app/views/styles/**/*.scss', 'public/widget/**/*.scss' ],
                tasks: [ 'sass' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            },
            jade: {
                files: [ 'app/views/**/*.jade' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            },
            language: {
                files: [ 'app/views/**/*.jade', 'app/controllers/**/*.js', 'app/models/**/*.js', 'public/js/src/**/*.js' ],
                tasks: [ 'shell:translation' ]
            },
            js: {
                files: [ 'public/js/src/**/*.js', 'public/widget/**/*.js' ],
                tasks: [ 'js-dev' ],
                options: {
                    spawn: false,
                    livereload: true
                }
            }
        },
        shell: {
            translation: {
                command: [
                    'cd locales',
                    'gulp',
                    'cd ..'
                ].join( '&&' )
            },
            npmv: {
                command: 'npm -v',
                options: {
                    callback: function( err, stdout, stderr, cb ) {
                        grunt.option( 'npmv', stdout.split( '.' )[ 0 ] );
                        cb( err );
                    }
                }
            }
        },
        jsbeautifier: {
            test: {
                src: JS_INCLUDE,
                options: {
                    config: './.jsbeautifyrc',
                    mode: 'VERIFY_ONLY'
                }
            },
            fix: {
                src: JS_INCLUDE,
                options: {
                    config: './.jsbeautifyrc'
                }
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: JS_INCLUDE,
        },
        // test server JS
        mochaTest: {
            all: {
                options: {
                    reporter: 'dot'
                },
                src: [ 'test/server/**/*.spec.js' ]
            },
            account: {
                src: [ 'test/server/account-*.spec.js' ]
            }
        },
        // test client JS
        karma: {
            options: {
                singleRun: true,
                reporters: [ 'dots' ]
            },
            headless: {
                configFile: 'test/client/config/karma.conf.js',
                browsers: [ 'PhantomJS' ]
            },
            browsers: {
                configFile: 'test/client/config/karma.conf.js',
                browsers: [ 'Chrome', 'ChromeCanary', 'Firefox', 'Opera' /*,'Safari'*/ ],
            }
        },
        browserify: {
            development: {
                files: {
                    'public/js/enketo-webform-dev-bundle.js': [ 'public/js/src/main-webform.js' ],
                    'public/js/enketo-webform-edit-dev-bundle.js': [ 'public/js/src/main-webform-edit.js' ],
                    'public/js/enketo-offline-fallback-dev-bundle.js': [ 'public/js/src/main-offline-fallback.js' ]
                },
                options: {
                    browserifyOptions: {
                        debug: true
                    }
                },
            },
            production: {
                files: {
                    'public/js/enketo-webform-bundle.js': [ 'public/js/src/main-webform.js' ],
                    'public/js/enketo-webform-edit-bundle.js': [ 'public/js/src/main-webform-edit.js' ],
                    'public/js/enketo-offline-fallback-bundle.js': [ 'public/js/src/main-offline-fallback.js' ]
                },
            },
            options: {
                // ensure that enketo-config and widgets are overridden in **enketo-core**
                transform: [
                    [ 'aliasify', {
                        aliases: pkg.aliasify.aliases,
                        global: true
                    } ]
                ]
            },
        },
        uglify: {
            all: {
                files: {
                    'public/js/enketo-webform-bundle.min.js': [ 'public/js/enketo-webform-bundle.js' ],
                    'public/js/enketo-webform-edit-bundle.min.js': [ 'public/js/enketo-webform-edit-bundle.js' ],
                    'public/js/enketo-offline-fallback-bundle.min.js': [ 'public/js/enketo-offline-fallback-bundle.js' ],
                },
            },
        },
        env: {
            develop: {
                NODE_ENV: 'develop'
            },
            test: {
                NODE_ENV: 'test'
            },
            production: {
                NODE_ENV: 'production'
            }
        }
    } );

    grunt.registerTask( 'client-config-file', 'Temporary client-config file', function( task ) {
        var clientConfigPath = 'public/temp-client-config.json';
        if ( task === 'create' ) {
            var config = require( './app/models/config-model' );
            grunt.file.write( clientConfigPath, JSON.stringify( config.client ) );
            grunt.log.writeln( 'File ' + clientConfigPath + ' created' );
        } else if ( task === 'remove' ) {
            grunt.file.delete( clientConfigPath );
            grunt.log.writeln( 'File ' + clientConfigPath + ' removed' );
        }
    } );

    grunt.registerTask( 'system-sass-variables', 'Creating _system_variables.scss', function( task ) {
        var systemSassVariablesPath = 'app/views/styles/component/_system_variables.scss';
        var config = require( './app/models/config-model' );
        grunt.file.write( systemSassVariablesPath, '$base-path: "' + config.server[ 'base path' ] + '";' );
        grunt.log.writeln( 'File ' + systemSassVariablesPath + ' created' );
    } );

    grunt.registerTask( 'default', [ 'css', 'js', 'uglify' ] );
    grunt.registerTask( 'js', [ 'client-config-file:create', 'browserify:production' ] );
    grunt.registerTask( 'js-dev', [ 'client-config-file:create', 'browserify:development' ] );
    grunt.registerTask( 'css', [ 'shell:npmv', 'system-sass-variables:create', 'sass' ] );
    grunt.registerTask( 'test', [ 'env:test', 'js', 'css', 'mochaTest:all', 'karma:headless', 'jsbeautifier:test', 'jshint' ] );
    grunt.registerTask( 'test-browser', [ 'env:test', 'css', 'client-config-file:create', 'karma:browsers' ] );
    grunt.registerTask( 'develop', [ 'env:develop', 'js-dev', 'concurrent:develop' ] );
    grunt.registerTask( 'test-and-build', [ 'env:test', 'mochaTest:all', 'karma:headless', 'env:production', 'default' ] );
};
<|endoftext|>


<commit_before>'use strict';

var fs = require('fs');

module.exports = function(grunt) {

    // Project configuration.
    var gruntConf = {
        watch: {
            options: {
                nospawn: true
            },
            src: {
                files: ['src/**/*.coffee'],
                tasks: ['coffee:src']
            },
            cli: {
                files: ['cli/**/*.coffee'],
                tasks: ['coffee:cli']
            },
            static: {
                files: ['src/**/*.png','src/**/*.less','src/**/*.html','src/**/*.css','src/**/*.js','src/**/*.eot','src/**/*.otf','src/**/*.svg','src/**/*.ttf', 'src/**/*.woff', '**/*.ico'],
                tasks: ['copy']
            }
        },
        coffee: {
            src: {
                expand: true,
                cwd: 'src',
                src: ['**/*.coffee'],
                dest: 'bin',
                ext: '.js',
                options: {
                    bare: true
                }
            },
            cli: {
                expand: true,
                cwd: 'cli',
                src: ['**/*.coffee'],
                dest: 'cli/bin',
                ext: '.js',
                options: {
                    bare: true
                }
            }
        },
        copy: {
            main: {
                files: [
                    {
                        expand: true,
                        src: ['**/*.less', '**/*.html', '**/*.png','**/*.js','**/*.eot','**/*.css','**/*.svg', '**/*.ttf', '**/*.woff', '**/*.otf', '**/*.ico'],
                        dest: 'bin',
                        cwd: 'src'
                    },
                ]
            }
        },
        subgrunt: {}
    };

    var tasks = [];
    var default_plg = fs.readdirSync(__dirname + '/default_plugins');
    for (var i in default_plg) {
        var plugin = default_plg[i];
        if (fs.existsSync(__dirname + '/default_plugins/' + plugin + '/gruntConfig.js')) {
            var task = require('./default_plugins/' + plugin + '/gruntConfig').call(this, gruntConf);
            if (task)
                tasks.push(task);
        }

        if (fs.existsSync(__dirname + '/default_plugins/' + plugin + '/Gruntfile.js')) {
            gruntConf.subgrunt[plugin] = {
                options: {},
                projects: {}
            };
            gruntConf.subgrunt[plugin].projects['./default_plugins/' + plugin] =  'default';
        }
    }

    grunt.initConfig(gruntConf);

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-subgrunt');

    // Default task.
    grunt.registerTask('default', ['coffee', 'copy', 'subgrunt']);
    grunt.registerTask('test', ['nodeunit']);
};<commit_msg>Updated gruntfile to ignore default plugins (which were removed)<commit_after>'use strict';

var fs = require('fs');

module.exports = function(grunt) {

    // Project configuration.
    var gruntConf = {
        watch: {
            options: {
                nospawn: true
            },
            src: {
                files: ['src/**/*.coffee'],
                tasks: ['coffee:src']
            },
            cli: {
                files: ['cli/**/*.coffee'],
                tasks: ['coffee:cli']
            },
            static: {
                files: ['src/**/*.png','src/**/*.less','src/**/*.html','src/**/*.css','src/**/*.js','src/**/*.eot','src/**/*.otf','src/**/*.svg','src/**/*.ttf', 'src/**/*.woff', '**/*.ico'],
                tasks: ['copy']
            }
        },
        coffee: {
            src: {
                expand: true,
                cwd: 'src',
                src: ['**/*.coffee'],
                dest: 'bin',
                ext: '.js',
                options: {
                    bare: true
                }
            },
            cli: {
                expand: true,
                cwd: 'cli',
                src: ['**/*.coffee'],
                dest: 'cli/bin',
                ext: '.js',
                options: {
                    bare: true
                }
            }
        },
        copy: {
            main: {
                files: [
                    {
                        expand: true,
                        src: ['**/*.less', '**/*.html', '**/*.png','**/*.js','**/*.eot','**/*.css','**/*.svg', '**/*.ttf', '**/*.woff', '**/*.otf', '**/*.ico'],
                        dest: 'bin',
                        cwd: 'src'
                    },
                ]
            }
        },
        subgrunt: {}
    };

    var tasks = [];
    // var default_plg = fs.readdirSync(__dirname + '/default_plugins');
    // for (var i in default_plg) {
    //     var plugin = default_plg[i];
    //     if (fs.existsSync(__dirname + '/default_plugins/' + plugin + '/gruntConfig.js')) {
    //         var task = require('./default_plugins/' + plugin + '/gruntConfig').call(this, gruntConf);
    //         if (task)
    //             tasks.push(task);
    //     }

    //     if (fs.existsSync(__dirname + '/default_plugins/' + plugin + '/Gruntfile.js')) {
    //         gruntConf.subgrunt[plugin] = {
    //             options: {},
    //             projects: {}
    //         };
    //         gruntConf.subgrunt[plugin].projects['./default_plugins/' + plugin] =  'default';
    //     }
    // }

    grunt.initConfig(gruntConf);

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-subgrunt');

    // Default task.
    grunt.registerTask('default', ['coffee', 'copy']);
    grunt.registerTask('test', ['nodeunit']);
};<|endoftext|>


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

  // load grunt tasks from package.json
  require('load-grunt-tasks')(grunt);
  var S = require('string');

  function items(obj, callback){
    Object.keys(obj).forEach(function(key, i){
      callback(key, obj[key], i);
    });
  }

  // Project configuration.
  grunt.initConfig({

    bower: {
      install: {
        options: {
          targetDir: 'thusoy/static/libs',
        }
      }
    },

    clean: {
      dist: [
        '.tmp',
        'dist',
        'thusoy/**/*.pyc',
        'thusoy/server-assets',
        '*.egg-info',
      ]
    },

    compass: {
      dist: {
        options: {
          sassDir: '.tmp/static/sass/',
          cssDir: '.tmp/static/css/',
          outputStyle: 'compressed',
        }
      }
    },

    concurrent: {
      server: {
        tasks: ['watch', 'shell:server'],
        options: {
          logConcurrentOutput: true,
        }
      }
    },

    copy: {
      bootstrap: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/libs/sass-bootstrap/lib',
          src: ['_*'],
          dest: '.tmp/static/sass/bootstrap',
        }]
      },
      thusoySass: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/sass',
          src: ['**'],
          dest: '.tmp/static/sass',
        }]
      },
      'fetch-server-assets': {
        files: [{
          src: '.tmp/static/css/core.css',
          dest: 'thusoy/server-assets/core.css',
        }]
      },
      'js-sources': {
        files: [{
          expand: true,
          cwd: 'thusoy/static/js',
          src: '**/*.js',
          dest: '.tmp/static/js/',
        }]
      }
    },

    filerev: {
      options: {
        algorithm: 'md5',
        length: 8,
      },
      images: {
        src: '.tmp/static/img/*.jpg',
      },
      styles: {
        src: '.tmp/static/css/*.css',
      },
      js: {
        src: '.tmp/static/js/*.js',
      }
    },

    imagemin: {
      static: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/',
          src: 'img/*.{png,jpg}',
          dest: '.tmp/static/',
        }]
      }
    },

    shell: {
      options: {
        stdout: true,
        stderr: true,
      },
      server: {
        command: 'python manage.py devserver',
      },
      'build-python': {
        command: 'python setup.py sdist --formats gztar'
      },
      'package-static': {
        command: [
          'cd .tmp/static',
          'tar czf ../../dist/static.tar.gz *',
        ].join('&&')
      },

    },

    uglify: {
      options: {
        sourceMap: function (uglifyDest) {
          return uglifyDest.slice(0, -3) + '.map';
        },
        sourceMapPrefix: 3,
        sourceMappingURL: function (uglifyDest) {
          // Strip the first '.tmp' from the destination
          // replace \ with / to work on both windows and *nix
          return S(uglifyDest.slice(4)).replaceAll('\\', '/').slice(0, -2) + 'map';
        },
        //sourceMapRoot: 'thusoy/static',
      }
    },

    useminPrepare: {
      options: {
        dest: '.tmp/static',
        root: 'thusoy/',
        flow: {
          html: {
            steps: {'js': ['uglifyjs']},
            post: {}
          }
        }
      },
      html: 'thusoy/templates/**/*.html',
    },

    watch: {
      options: {
        livereload: true,
      },
      python: {
        files: ['thusoy/**/*.py'],
        tasks: []
      },
      sass: {
        files: ['thusoy/static/sass/*.scss'],
        tasks: ['buildStyles', 'preprocess-html'],
      },
      js: {
        files: ['thusoy/static/js/*.js', '!**/*.min.js'],
        tasks: ['buildJs']
      },
      templates: {
        files: ['thusoy/templates/*.html', '!thusoy/templates/base.html'],
        tasks: ['preprocess-html'],
      },
    },

  });

  grunt.registerTask('dump-revs', 'Dump the changes by filerev to a json file', function(){
    var revs = {};
    items(grunt.filerev.summary, function(key, val){
      var stripLeadingDirs = function (path) {
        return S(path.substring('.tmp/static/'.length)).replaceAll('\\', '/').toString();
      };
      revs[stripLeadingDirs(key)] = stripLeadingDirs(val);
    });
    grunt.file.write('thusoy/server-assets/filerevs.json', JSON.stringify(revs));
  });

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

  grunt.registerTask('build', [
    'clean',
    'buildStyles',
    'buildJs',
    'imagemin',
    'server-assets',
    'rev-static',
    'copy:js-sources',
    'shell:build-python',
    'shell:package-static',
  ]);

  grunt.registerTask('rev-static', [
    'filerev',
    'dump-revs',
  ]);

  grunt.registerTask('buildStyles', [
    'copy:bootstrap',
    'copy:thusoySass',
    'compass',
  ]);

  grunt.registerTask('server-assets', [
    'copy:fetch-server-assets',
  ]);

  grunt.registerTask('buildJs', [
    'useminPrepare',
    'uglify',
  ]);
};
<commit_msg>Include external libs in static bundle<commit_after>module.exports = function(grunt) {

  // load grunt tasks from package.json
  require('load-grunt-tasks')(grunt);
  var S = require('string');

  function items(obj, callback){
    Object.keys(obj).forEach(function(key, i){
      callback(key, obj[key], i);
    });
  }

  // Project configuration.
  grunt.initConfig({

    bower: {
      install: {
        options: {
          targetDir: 'thusoy/static/libs',
        }
      }
    },

    clean: {
      dist: [
        '.tmp',
        'dist',
        'thusoy/**/*.pyc',
        'thusoy/server-assets',
        '*.egg-info',
      ]
    },

    compass: {
      dist: {
        options: {
          sassDir: '.tmp/static/sass/',
          cssDir: '.tmp/static/css/',
          outputStyle: 'compressed',
        }
      }
    },

    concurrent: {
      server: {
        tasks: ['watch', 'shell:server'],
        options: {
          logConcurrentOutput: true,
        }
      }
    },

    copy: {
      bootstrap: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/libs/sass-bootstrap/lib',
          src: ['_*'],
          dest: '.tmp/static/sass/bootstrap',
        }]
      },
      thusoySass: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/sass',
          src: ['**'],
          dest: '.tmp/static/sass',
        }]
      },
      'fetch-server-assets': {
        files: [{
          src: '.tmp/static/css/core.css',
          dest: 'thusoy/server-assets/core.css',
        }]
      },
      'js-sources': {
        files: [{
          expand: true,
          cwd: 'thusoy/static/js',
          src: '**/*.js',
          dest: '.tmp/static/js/',
        }]
      },
      'js-libs': {
        files: [{
          expand: true,
          cwd: 'thusoy/static',
          src: 'libs/**/*',
          dest: '.tmp/static/',
        }]
      }
    },

    filerev: {
      options: {
        algorithm: 'md5',
        length: 8,
      },
      images: {
        src: '.tmp/static/img/*.jpg',
      },
      styles: {
        src: '.tmp/static/css/*.css',
      },
      js: {
        src: '.tmp/static/js/*.js',
      }
    },

    imagemin: {
      static: {
        files: [{
          expand: true,
          cwd: 'thusoy/static/',
          src: 'img/*.{png,jpg}',
          dest: '.tmp/static/',
        }]
      }
    },

    shell: {
      options: {
        stdout: true,
        stderr: true,
      },
      server: {
        command: 'python manage.py devserver',
      },
      'build-python': {
        command: 'python setup.py sdist --formats gztar'
      },
      'package-static': {
        command: [
          'cd .tmp/static',
          'tar czf ../../dist/static.tar.gz *',
        ].join('&&')
      },

    },

    uglify: {
      options: {
        sourceMap: function (uglifyDest) {
          return uglifyDest.slice(0, -3) + '.map';
        },
        sourceMapPrefix: 3,
        sourceMappingURL: function (uglifyDest) {
          // Strip the first '.tmp' from the destination
          // replace \ with / to work on both windows and *nix
          return S(uglifyDest.slice(4)).replaceAll('\\', '/').slice(0, -2) + 'map';
        },
        //sourceMapRoot: 'thusoy/static',
      }
    },

    useminPrepare: {
      options: {
        dest: '.tmp/static',
        root: 'thusoy/',
        flow: {
          html: {
            steps: {'js': ['uglifyjs']},
            post: {}
          }
        }
      },
      html: 'thusoy/templates/**/*.html',
    },

    watch: {
      options: {
        livereload: true,
      },
      python: {
        files: ['thusoy/**/*.py'],
        tasks: []
      },
      sass: {
        files: ['thusoy/static/sass/*.scss'],
        tasks: ['buildStyles', 'preprocess-html'],
      },
      js: {
        files: ['thusoy/static/js/*.js', '!**/*.min.js'],
        tasks: ['buildJs']
      },
      templates: {
        files: ['thusoy/templates/*.html', '!thusoy/templates/base.html'],
        tasks: ['preprocess-html'],
      },
    },

  });

  grunt.registerTask('dump-revs', 'Dump the changes by filerev to a json file', function(){
    var revs = {};
    items(grunt.filerev.summary, function(key, val){
      var stripLeadingDirs = function (path) {
        return S(path.substring('.tmp/static/'.length)).replaceAll('\\', '/').toString();
      };
      revs[stripLeadingDirs(key)] = stripLeadingDirs(val);
    });
    grunt.file.write('thusoy/server-assets/filerevs.json', JSON.stringify(revs));
  });

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

  grunt.registerTask('build', [
    'clean',
    'buildStyles',
    'buildJs',
    'imagemin',
    'server-assets',
    'rev-static',
    'copy:js-sources',
    'shell:build-python',
    'shell:package-static',
  ]);

  grunt.registerTask('rev-static', [
    'filerev',
    'dump-revs',
  ]);

  grunt.registerTask('buildStyles', [
    'copy:bootstrap',
    'copy:thusoySass',
    'compass',
  ]);

  grunt.registerTask('server-assets', [
    'copy:fetch-server-assets',
  ]);

  grunt.registerTask('buildJs', [
    'useminPrepare',
    'uglify',
    'copy:js-libs',
  ]);
};
<|endoftext|>


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

	// configuracion del proyecto
	grunt.initConfig({

		// metadatos
		leerJson: grunt.file.readJSON('package.json'),
		banner: '/**\n' +
				'* <%= leerJson.name %> v<%= leerJson.version %> por @fizzvr\n' +
				'*/\n',
		// grunt-frontend plugin configuracion
		frontendConfig: {
			srcWebroot: './src/files',
			webroot: './out'
		},
		frontend: {
			main: {
				css: {
					src: './src/files/css',
					dest: './final/css'
				},
				js: {
					files: {
						'./final/js/principal.js': [
							'./src/files/js/principal.js'
						],
						'./final/js/piw.js': [
							'./src/files/js/piw.js'
						]
					}

				}
			}
		},
		htmlcompressor: {
			compile: {
				files: {
					'final/index.html': 'out/index.html'
				},
				options: {
					type: 'html',
					preserveServerScript: true
				}
			}
		}
	});

	// carga de los plugins para el proyecto
	grunt.loadNpmTasks('grunt-frontend');
	grunt.loadNpmTasks('grunt-htmlcompressor');

	// distribucion JS y CSS
	grunt.registerTask('dist-jscss', ['frontend']);
	// compresion HTML
	grunt.registerTask('comp-hmtl', ['htmlcompressor']);
};<commit_msg>cambiado el nombre de las carpetas docpad y agregado el plugin grunt-contrib-clean<commit_after>module.exports = function(grunt) {

	// configuracion del proyecto
	grunt.initConfig({

		// metadatos
		leerJson: grunt.file.readJSON('package.json'),
		banner: '/**\n' +
				'* <%= leerJson.name %> v<%= leerJson.version %> por @fizzvr\n' +
				'*/\n',
		// grunt-contrib-clean plugin configuracion
		clean: [
			'./final',
			'./out'
		],
		// grunt-frontend plugin configuracion
		frontendConfig: {
			srcWebroot: './src/public/',
			webroot: './out/'
		},
		frontend: {
			main: {
				css: {
					src: './src/public/css',
					dest: './final/css'
				},
				js: {
					files: {
						'./final/js/principal.js': [
							'./src/public/js/principal.js'
						],
						'./final/js/piw.js': [
							'./src/public/js/piw.js'
						]
					}

				}
			}
		},
		htmlcompressor: {
			compile: {
				files: {
					'final/index.html': 'out/index.html'
				},
				options: {
					type: 'html',
					preserveServerScript: true
				}
			}
		}
	});

	// carga de los plugins para el proyecto
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-frontend');
	grunt.loadNpmTasks('grunt-htmlcompressor');

	// distribucion JS y CSS
	grunt.registerTask('dist-jscss', ['frontend']);
	// compresion HTML
	grunt.registerTask('comp-hmtl', ['htmlcompressor']);
	// distribucion FULL
	grunt.registerTask('dist', ['clean', 'dist-jscss', 'comp-hmtl']);
	// tarea por default
	grunt.registerTask('default', ['dist']);
};<|endoftext|>


<commit_before>import Ember from "ember";
import layout from "../../templates/components/nypr-accounts/membership-card";
import computed from "ember-computed";
import moment from "moment";
import service from 'ember-service/inject';

export default Ember.Component.extend({
  layout,
  session: service(),
  taxLetterUrl: computed(function() {
    let config = Ember.getOwner(this).resolveRegistration('config:environment');
    let urlRoot = config.membershipAPI || "https://api.wnyc.org";
    return `${urlRoot}/v1/taxes`;
  }),
  previousYear: computed(function() {
    return moment()
      .subtract(1, "year")
      .year();
  }),
  hasPledgesInPastTaxYear: computed.filter("pledges", function(pledge) {
    let previousYear = moment().subtract(1, "year").year();
    let pledgeYear = pledge.orderDate || pledge.get("orderDate").year();
    return moment(pledgeYear == previousYear);
  }),
  actions: {
    downloadTaxLetter() {
      this.get('session').authorize('authorizer:nypr', (header, value) => {
        Ember.$.ajax({
          url: "https://api.demo.nypr.digital/membership/v1/taxes",
          beforeSend: function(xhr){xhr.setRequestHeader(header, value);},
          type: "GET",
          success: function(data, textStatus, jqxhr) {
            // Create data blob from response
            var blob = new Blob([data], {type: "application/pdf"});
            var url = window.URL.createObjectURL(blob);

            // Create hidden <a>, click on it, remove it
            var a = document.createElement("a");
            document.body.appendChild(a);
            a.style = "display: none";
            a.href = url;
            a.download = "NYPR_Tax_Documentation.pdf";
            a.click();
            window.URL.revokeObjectURL(url);

          }
        });
      });
    }
  }
});
<commit_msg>Fix blank PDF issue w/ arrayBuffer<commit_after>import Ember from "ember";
import layout from "../../templates/components/nypr-accounts/membership-card";
import computed from "ember-computed";
import moment from "moment";
import service from 'ember-service/inject';

export default Ember.Component.extend({
  layout,
  session: service(),
  taxLetterUrl: computed(function() {
    let config = Ember.getOwner(this).resolveRegistration('config:environment');
    let urlRoot = config.membershipAPI || "https://api.wnyc.org";
    return `${urlRoot}/v1/taxes`;
  }),
  previousYear: computed(function() {
    return moment()
      .subtract(1, "year")
      .year();
  }),
  hasPledgesInPastTaxYear: computed.filter("pledges", function(pledge) {
    let previousYear = moment().subtract(1, "year").year();
    let pledgeYear = pledge.orderDate || pledge.get("orderDate").year();
    return moment(pledgeYear == previousYear);
  }),
  actions: {
    downloadTaxLetter() {
      this.get('session').authorize('authorizer:nypr', (header, value) => {
        let taxLetterUrl = this.get("taxLetterUrl");
        let fetchOptions = {};
        fetchOptions[header] = value;

        fetch(taxLetterUrl, fetchOptions).then(response => {
          response.arrayBuffer().then(data =>{
            var blob = new Blob([data], {type: "application/pdf"});
            var url = window.URL.createObjectURL(blob);

            // Create hidden <a>, click on it, remove it
            var a = document.createElement("a");
            document.body.appendChild(a);
            a.href = url;
            a.download = "NYPR_Tax_Documentation.pdf";
            a.click();
            window.URL.revokeObjectURL(url);
          });
        })
      });
    }
  }
});
<|endoftext|>


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

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-bump');
    grunt.loadNpmTasks('grunt-shell');

    grunt.initConfig({

        // used by the changelog task
        pkg: grunt.file.readJSON('package.json'),

        jshint: {
            options: {
                node: true
            },
            all: ['*.js','./modules/*.js']
        },

        shell: {
            publish: {
                command: 'npm publish'
            },

            pubinit: {
                command: 'npm publish --access public'
            }
        },

        // To test: grunt bump --dry-run

        bump: {
            options: {

                commit: true,
                createTag: true,
                push: true,
                pushTo: 'origin',

                updateConfigs: ['pkg'],
                commitFiles: ['package.json']
            }
        },

        browserify: {
            dist: {
                options: {
                    browserifyOptions: {
                        // standalone: 'MitchAllen.aframeMazeComponent'
                    },
                    transform: [['babelify', {presets: ['es2015']}]],
                    plugin: [[ "browserify-derequire" ]]
                },
                files: {
                   // if the source file has an extension of es6 then
                   // we change the name of the source file accordingly.
                   // The result file's extension is always .js
                   "./dist/aframe-maze-component.js": ["./browser.js"]
                }
            }
        },

        uglify: {
            my_target: {
                files: {
                    './dist/aframe-maze-component.min.js': ['./dist/aframe-maze-component.js']
                }
            }
        },

        watch: {
             scripts: {
                files: ["./modules/*.js","./*.js"],
                tasks: ['build']
             }
        }
    });

    grunt.loadNpmTasks("grunt-browserify");
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks("grunt-contrib-watch");

    grunt.registerTask('default', ['build']);
    grunt.registerTask("build", ['jshint','browserify','uglify']);
    grunt.registerTask('pubinit', ['jshint','browserify','uglify','shell:pubinit']);
    grunt.registerTask('publish', ['jshint','browserify','uglify','bump','shell:publish']);
};<commit_msg>added pubminor to grunt file for calling bump:minor on publish<commit_after>module.exports = function (grunt) {

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-bump');
    grunt.loadNpmTasks('grunt-shell');

    grunt.initConfig({

        // used by the changelog task
        pkg: grunt.file.readJSON('package.json'),

        jshint: {
            options: {
                node: true
            },
            all: ['*.js','./modules/*.js']
        },

        shell: {
            publish: {
                command: 'npm publish'
            },

            pubinit: {
                command: 'npm publish --access public'
            }
        },

        // To test: grunt bump --dry-run

        bump: {
            options: {

                commit: true,
                createTag: true,
                push: true,
                pushTo: 'origin',

                updateConfigs: ['pkg'],
                commitFiles: ['package.json']
            }
        },

        browserify: {
            dist: {
                options: {
                    browserifyOptions: {
                        // standalone: 'MitchAllen.aframeMazeComponent'
                    },
                    transform: [['babelify', {presets: ['es2015']}]],
                    plugin: [[ "browserify-derequire" ]]
                },
                files: {
                   // if the source file has an extension of es6 then
                   // we change the name of the source file accordingly.
                   // The result file's extension is always .js
                   "./dist/aframe-maze-component.js": ["./browser.js"]
                }
            }
        },

        uglify: {
            my_target: {
                files: {
                    './dist/aframe-maze-component.min.js': ['./dist/aframe-maze-component.js']
                }
            }
        },

        watch: {
             scripts: {
                files: ["./modules/*.js","./*.js"],
                tasks: ['build']
             }
        }
    });

    grunt.loadNpmTasks("grunt-browserify");
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks("grunt-contrib-watch");

    grunt.registerTask('default', ['build']);
    grunt.registerTask("build", ['jshint','browserify','uglify']);
    grunt.registerTask('pubinit', ['jshint','browserify','uglify','shell:pubinit']);
    grunt.registerTask('publish',  ['jshint','browserify','uglify','bump','shell:publish']);
    grunt.registerTask('pubminor', ['jshint','browserify','uglify','bump:minor','shell:publish']);
};<|endoftext|>


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

  /**
   * This is the configuration object Grunt uses to give each plugin its
   * instructions.
   */
  grunt.initConfig({
    /**
     * We read in our `package.json` file so we can access the package name and
     * version. It's already there, so we don't repeat ourselves here.
     */
    pkg: grunt.file.readJSON('bower.json'),

    build_dir: 'build',
    dist_dir: 'dist',
    src_files: {
      js: [ 'src/**/*.js' ],
      coffee: [ 'src/**/*.coffee' ]
    },

    vendor_files: {
      js: [
        'vendor/angular/angular.js',
      ]
    },

    // used only during testing
    test_files: {
      js: [
        'vendor/angular-mocks/angular-mocks.js'
      ]
    },

    /**
     * The banner is the comment that is placed at the top of our compiled
     * source files. It is first processed as a Grunt template, where the `<%=`
     * pairs are evaluated based on this very configuration object.
     */
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.description %>\n' +
        ' * @version <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * @link <%= pkg.homepage %>\n' +
        ' * @author <%= pkg.authors.join(", ") %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.authors.join(", ") %>\n' +
        ' * Licensed under the MIT License, http://opensource.org/licenses/MIT\n' +
        ' */\n'
    },

    /**
     * Creates a changelog on a new version.
     */
    changelog: {
      options: {
        dest: 'CHANGELOG.md',
        template: 'changelog.tpl'
      }
    },

    /**
     * Increments the version number, etc.
     */
    bump: {
      options: {
        files: [
          "package.json",
          "bower.json"
        ],
        commit: false,
        commitMessage: 'chore(release): v%VERSION%',
        commitFiles: [
          "package.json",
          "client/bower.json"
        ],
        createTag: false,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: false,
        pushTo: 'origin'
      }
    },

    /**
     * The directories to delete when `grunt clean` is executed.
     */
    clean: [
      '<%= build_dir %>',
      '<%= dist_dir %>'
    ],

    /**
     * The `copy` task just copies files from A to B. We use it here to copy
     * our project assets (images, fonts, etc.) and javascripts into
     * `build_dir`, and then to copy the assets to `dist_dir`.
     */
    copy: {
      build: {
        files: [
          {
            src: [ '<%= src_files.js %>' ],
            dest: '<%= build_dir %>/',
            cwd: '.',
            expand: true
          }
        ]
      }
    },

    /**
     * `grunt concat` concatenates multiple source files into a single file.
     */
    concat: {
      /**
       * The `dist_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file.
       */
      dist_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'module.prefix',
          '<%= build_dir %>/src/**/*.js',
          'module.suffix'
        ],
        dest: '<%= dist_dir %>/<%= pkg.name %>.js'
      },
      /**
       * The `dist_min_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file and will
       * be minified later by uglify.
       */
      dist_min_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'module.prefix',
          '<%= build_dir %>/src/**/*.js',
          'module.suffix'
        ],
        dest: '<%= dist_dir %>/<%= pkg.name %>.min.js'
      }
    },

    /**
     * `grunt coffee` compiles the CoffeeScript sources. To work well with the
     * rest of the build, we have a separate compilation task for sources and
     * specs so they can go to different places. For example, we need the
     * sources to live with the rest of the copied JavaScript so we can include
     * it in the final build, but we don't want to include our specs there.
     */
    coffee: {
      source: {
        options: {
          bare: true
        },
        expand: true,
        cwd: '.',
        src: [ '<%= src_files.coffee %>' ],
        dest: '<%= build_dir %>',
        ext: '.js'
      }
    },

    /**
     * `ng-min` annotates the sources before minifying. That is, it allows us
     * to code without the array syntax.
     */
    ngAnnotate: {
      options: {
        // Tells if ngAnnotate should add annotations (true by default).
        add: true,
        // Tells if ngAnnotate should remove annotations (false by default).
        remove: false,
        // Switches the quote type for strings in the annotations array to single
        // ones; e.g. '$scope' instead of "$scope" (false by default).
        singleQuotes: true
      },
      dist: {
        files: [
          {
            src: [ '<%= src_files.js %>' ],
            cwd: '<%= build_dir %>',
            dest: '<%= build_dir %>',
            expand: true
          }
        ]
      }
    },

    /**
     * Minify the sources!
     */
    uglify: {
      dist: {
        options: {
          banner: '<%= meta.banner %>'
        },
        files: {
          '<%= concat.dist_min_js.dest %>': '<%= concat.dist_min_js.dest %>'
        }
      }
    },

    /**
     * `jshint` defines the rules of our linter as well as which files we
     * should check. This file, all javascript sources, and all our unit tests
     * are linted based on the policies listed in `options`. But we can also
     * specify exclusionary patterns by prefixing them with an exclamation
     * point (!); this is useful when code comes from a third party but is
     * nonetheless inside `src/`.
     */
    jshint: {
      src: [
        '<%= src_files.js %>'
      ],
      // test: [
      //   '<%= app_files.jsunit %>'
      // ],
      gruntfile: [
        'Gruntfile.js'
      ],
      options: {
        curly: true,
        immed: true,
        newcap: true,
        noarg: true,
        sub: true,
        boss: true,
        eqnull: true
      },
      globals: {}
    },

    /**
     * `coffeelint` does the same as `jshint`, but for CoffeeScript.
     * CoffeeScript is not the default in ngBoilerplate, so we're just using
     * the defaults here.
     */
    coffeelint: {
      src: {
        files: {
          src: [ '<%= src_files.coffee %>' ]
        }
      },
      // test: {
      //   files: {
      //     src: [ '<%= src_files.coffeeunit %>' ]
      //   }
      // },
      options: {
        configFile: 'coffeelint.json'
      }
    },

    /**
     * The Karma configurations.
     */
    karma: {
      options: {
        configFile: '<%= build_dir %>/karma-unit.js'
      },
      unit: {
        port: 9019,
        background: true
      },
      continuous: {
        singleRun: true
      }
    },

    /**
     * This task compiles the karma template so that changes to its file array
     * don't have to be managed manually.
     */
    karmaconfig: {
      unit: {
        dir: '<%= build_dir %>',
        src: [
          '<%= vendor_files.js %>',
          '<%= test_files.js %>'
        ]
      }
    },

    /**
     * And for rapid development, we have a watch set up that checks to see if
     * any of the files listed below change, and then to execute the listed
     * tasks when they do. This just saves us from having to type "grunt" into
     * the command-line every time we want to see what we're working on; we can
     * instead just leave "grunt watch" running in a background terminal. Set it
     * and forget it, as Ron Popeil used to tell us.
     *
     * But we don't need the same thing to happen for all the files.
     */
    delta: {
      /**
       * By default, we want the Live Reload to work for all tasks; this is
       * overridden in some tasks (like this file) where browser resources are
       * unaffected. It runs by default on port 35729, which your browser
       * plugin should auto-detect.
       */
      options: {
        livereload: true
      },

      /**
       * When the Gruntfile changes, we just want to lint it. In fact, when
       * your Gruntfile changes, it will automatically be reloaded!
       */
      gruntfile: {
        files: 'Gruntfile.js',
        tasks: [ 'jshint:gruntfile' ],
        options: {
          livereload: false
        }
      },

      /**
       * When our JavaScript source files change, we want to run lint them and
       * run our unit tests.
       */
      jssrc: {
        files: [
          '<%= src_files.js %>'
        ],
        tasks: [ 'jshint:src', 'karma:unit:run', 'copy:build' ]
      },

      /**
       * When our CoffeeScript source files change, we want to run lint them and
       * run our unit tests.
       */
      coffeesrc: {
        files: [
          '<%= src_files.coffee %>'
        ],
        tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build' ]
      },

      /**
       * When a JavaScript unit test file changes, we only want to lint it and
       * run the unit tests. We don't want to do any live reloading.
       */
      jsunit: {
        files: [
          '<%= app_files.jsunit %>'
        ],
        tasks: [ 'jshint:test', 'karma:unit:run' ],
        options: {
          livereload: false
        }
      },

      /**
       * When a CoffeeScript unit test file changes, we only want to lint it and
       * run the unit tests. We don't want to do any live reloading.
       */
      coffeeunit: {
        files: [
          '<%= app_files.coffeeunit %>'
        ],
        tasks: [ 'coffeelint:test', 'karma:unit:run' ],
        options: {
          livereload: false
        }
      }
    }
  });

  // Load required Grunt tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-conventional-changelog');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-coffeelint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-ng-annotate');

  /**
   * In order to make it safe to just compile or copy *only* what was changed,
   * we need to ensure we are starting from a clean, fresh build. So we rename
   * the `watch` task to `delta` (that's why the configuration var above is
   * `delta`) and then add a new task called `watch` that does a clean build
   * before watching for changes.
   */
  grunt.renameTask( 'watch', 'delta' );
  grunt.registerTask( 'watch', [ 'build', 'karma:unit', 'delta' ] );

  // Default task: `build` and `dist`
  grunt.registerTask( 'default', [ 'build', 'dist' ] );

  // build task: get the library ready for development and testing
  grunt.registerTask( 'build', [
    'clean', 'jshint', 'coffeelint', 'coffee',
    'copy:build', 'karmaconfig',
    'karma:continuous'
  ]);

  // dist task: get the library ready for distribution
  grunt.registerTask( 'dist', [
    'ngAnnotate', 'concat:dist_js', 'concat:dist_min_js', 'uglify'
  ]);

  /**
   * A utility function to get all JavaScript sources.
   */
  function filterForJS ( files ) {
    return files.filter( function ( file ) {
      return file.match( /\.js$/ );
    });
  }

  /**
   * In order to avoid having to specify manually the files needed for karma to
   * run, we use grunt to manage the list for us. The `karma/*` files are
   * compiled as grunt templates for use by Karma. Yay!
   */
  grunt.registerMultiTask( 'karmaconfig', 'Process karma config templates', function () {
    var jsFiles = filterForJS( this.filesSrc );

    grunt.file.copy( 'karma/karma-unit.tpl.js', grunt.config( 'build_dir' ) + '/karma-unit.js', {
      process: function ( contents, path ) {
        return grunt.template.process( contents, {
          data: {
            scripts: jsFiles
          }
        });
      }
    });
  });
};
<commit_msg>chore(Gruntfile): change 'bump' logic<commit_after>module.exports = function (grunt) {

  /**
   * This is the configuration object Grunt uses to give each plugin its
   * instructions.
   */
  grunt.initConfig({
    /**
     * We read in our `package.json` file so we can access the package name and
     * version. It's already there, so we don't repeat ourselves here.
     */
    pkg: grunt.file.readJSON('bower.json'),

    build_dir: 'build',
    dist_dir: 'dist',
    src_files: {
      js: [ 'src/**/*.js' ],
      coffee: [ 'src/**/*.coffee' ]
    },

    vendor_files: {
      js: [
        'vendor/angular/angular.js',
      ]
    },

    // used only during testing
    test_files: {
      js: [
        'vendor/angular-mocks/angular-mocks.js'
      ]
    },

    /**
     * The banner is the comment that is placed at the top of our compiled
     * source files. It is first processed as a Grunt template, where the `<%=`
     * pairs are evaluated based on this very configuration object.
     */
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.description %>\n' +
        ' * @version <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * @link <%= pkg.homepage %>\n' +
        ' * @author <%= pkg.authors.join(", ") %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.authors.join(", ") %>\n' +
        ' * Licensed under the MIT License, http://opensource.org/licenses/MIT\n' +
        ' */\n'
    },

    /**
     * Creates a changelog on a new version.
     */
    changelog: {
      options: {
        dest: 'CHANGELOG.md',
        template: 'changelog.tpl'
      }
    },

    /**
     * Increments the version number, etc.
     */
    bump: {
      options: {
        files: [
          "package.json",
          "bower.json"
        ],
        updateConfigs: ['pkg'],
        commit: false,
        commitMessage: 'chore(release): v%VERSION%',
        commitFiles: [
          "package.json",
          "bower.json"
        ],
        createTag: false,
        tagName: '%VERSION%',
        tagMessage: 'Release %VERSION% version',
        push: false,
        pushTo: 'origin'
      }
    },

    /**
     * The directories to delete when `grunt clean` is executed.
     */
    clean: [
      '<%= build_dir %>',
      '<%= dist_dir %>'
    ],

    /**
     * The `copy` task just copies files from A to B. We use it here to copy
     * our project assets (images, fonts, etc.) and javascripts into
     * `build_dir`, and then to copy the assets to `dist_dir`.
     */
    copy: {
      build: {
        files: [
          {
            src: [ '<%= src_files.js %>' ],
            dest: '<%= build_dir %>/',
            cwd: '.',
            expand: true
          }
        ]
      }
    },

    /**
     * `grunt concat` concatenates multiple source files into a single file.
     */
    concat: {
      /**
       * The `dist_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file.
       */
      dist_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'module.prefix',
          '<%= build_dir %>/src/**/*.js',
          'module.suffix'
        ],
        dest: '<%= dist_dir %>/<%= pkg.name %>.js'
      },
      /**
       * The `dist_min_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file and will
       * be minified later by uglify.
       */
      dist_min_js: {
        options: {
          banner: '<%= meta.banner %>'
        },
        src: [
          'module.prefix',
          '<%= build_dir %>/src/**/*.js',
          'module.suffix'
        ],
        dest: '<%= dist_dir %>/<%= pkg.name %>.min.js'
      }
    },

    /**
     * `grunt coffee` compiles the CoffeeScript sources. To work well with the
     * rest of the build, we have a separate compilation task for sources and
     * specs so they can go to different places. For example, we need the
     * sources to live with the rest of the copied JavaScript so we can include
     * it in the final build, but we don't want to include our specs there.
     */
    coffee: {
      source: {
        options: {
          bare: true
        },
        expand: true,
        cwd: '.',
        src: [ '<%= src_files.coffee %>' ],
        dest: '<%= build_dir %>',
        ext: '.js'
      }
    },

    /**
     * `ng-min` annotates the sources before minifying. That is, it allows us
     * to code without the array syntax.
     */
    ngAnnotate: {
      options: {
        // Tells if ngAnnotate should add annotations (true by default).
        add: true,
        // Tells if ngAnnotate should remove annotations (false by default).
        remove: false,
        // Switches the quote type for strings in the annotations array to single
        // ones; e.g. '$scope' instead of "$scope" (false by default).
        singleQuotes: true
      },
      dist: {
        files: [
          {
            src: [ '<%= src_files.js %>' ],
            cwd: '<%= build_dir %>',
            dest: '<%= build_dir %>',
            expand: true
          }
        ]
      }
    },

    /**
     * Minify the sources!
     */
    uglify: {
      dist: {
        options: {
          banner: '<%= meta.banner %>'
        },
        files: {
          '<%= concat.dist_min_js.dest %>': '<%= concat.dist_min_js.dest %>'
        }
      }
    },

    /**
     * `jshint` defines the rules of our linter as well as which files we
     * should check. This file, all javascript sources, and all our unit tests
     * are linted based on the policies listed in `options`. But we can also
     * specify exclusionary patterns by prefixing them with an exclamation
     * point (!); this is useful when code comes from a third party but is
     * nonetheless inside `src/`.
     */
    jshint: {
      src: [
        '<%= src_files.js %>'
      ],
      // test: [
      //   '<%= app_files.jsunit %>'
      // ],
      gruntfile: [
        'Gruntfile.js'
      ],
      options: {
        curly: true,
        immed: true,
        newcap: true,
        noarg: true,
        sub: true,
        boss: true,
        eqnull: true
      },
      globals: {}
    },

    /**
     * `coffeelint` does the same as `jshint`, but for CoffeeScript.
     * CoffeeScript is not the default in ngBoilerplate, so we're just using
     * the defaults here.
     */
    coffeelint: {
      src: {
        files: {
          src: [ '<%= src_files.coffee %>' ]
        }
      },
      // test: {
      //   files: {
      //     src: [ '<%= src_files.coffeeunit %>' ]
      //   }
      // },
      options: {
        configFile: 'coffeelint.json'
      }
    },

    /**
     * The Karma configurations.
     */
    karma: {
      options: {
        configFile: '<%= build_dir %>/karma-unit.js'
      },
      unit: {
        port: 9019,
        background: true
      },
      continuous: {
        singleRun: true
      }
    },

    /**
     * This task compiles the karma template so that changes to its file array
     * don't have to be managed manually.
     */
    karmaconfig: {
      unit: {
        dir: '<%= build_dir %>',
        src: [
          '<%= vendor_files.js %>',
          '<%= test_files.js %>'
        ]
      }
    },

    /**
     * And for rapid development, we have a watch set up that checks to see if
     * any of the files listed below change, and then to execute the listed
     * tasks when they do. This just saves us from having to type "grunt" into
     * the command-line every time we want to see what we're working on; we can
     * instead just leave "grunt watch" running in a background terminal. Set it
     * and forget it, as Ron Popeil used to tell us.
     *
     * But we don't need the same thing to happen for all the files.
     */
    delta: {
      /**
       * By default, we want the Live Reload to work for all tasks; this is
       * overridden in some tasks (like this file) where browser resources are
       * unaffected. It runs by default on port 35729, which your browser
       * plugin should auto-detect.
       */
      options: {
        livereload: true
      },

      /**
       * When the Gruntfile changes, we just want to lint it. In fact, when
       * your Gruntfile changes, it will automatically be reloaded!
       */
      gruntfile: {
        files: 'Gruntfile.js',
        tasks: [ 'jshint:gruntfile' ],
        options: {
          livereload: false
        }
      },

      /**
       * When our JavaScript source files change, we want to run lint them and
       * run our unit tests.
       */
      jssrc: {
        files: [
          '<%= src_files.js %>'
        ],
        tasks: [ 'jshint:src', 'karma:unit:run', 'copy:build' ]
      },

      /**
       * When our CoffeeScript source files change, we want to run lint them and
       * run our unit tests.
       */
      coffeesrc: {
        files: [
          '<%= src_files.coffee %>'
        ],
        tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build' ]
      },

      /**
       * When a JavaScript unit test file changes, we only want to lint it and
       * run the unit tests. We don't want to do any live reloading.
       */
      jsunit: {
        files: [
          '<%= app_files.jsunit %>'
        ],
        tasks: [ 'jshint:test', 'karma:unit:run' ],
        options: {
          livereload: false
        }
      },

      /**
       * When a CoffeeScript unit test file changes, we only want to lint it and
       * run the unit tests. We don't want to do any live reloading.
       */
      coffeeunit: {
        files: [
          '<%= app_files.coffeeunit %>'
        ],
        tasks: [ 'coffeelint:test', 'karma:unit:run' ],
        options: {
          livereload: false
        }
      }
    }
  });

  // Load required Grunt tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-conventional-changelog');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-coffeelint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-ng-annotate');

  /**
   * In order to make it safe to just compile or copy *only* what was changed,
   * we need to ensure we are starting from a clean, fresh build. So we rename
   * the `watch` task to `delta` (that's why the configuration var above is
   * `delta`) and then add a new task called `watch` that does a clean build
   * before watching for changes.
   */
  grunt.renameTask( 'watch', 'delta' );
  grunt.registerTask( 'watch', [ 'build', 'karma:unit', 'delta' ] );

  // Default task: `build` and `dist`
  grunt.registerTask( 'default', [ 'build', 'dist' ] );

  // build task: get the library ready for development and testing
  grunt.registerTask( 'build', [
    'clean', 'jshint', 'coffeelint', 'coffee',
    'copy:build', 'karmaconfig',
    'karma:continuous'
  ]);

  // dist task: get the library ready for distribution
  grunt.registerTask( 'dist', [
    'ngAnnotate', 'concat:dist_js', 'concat:dist_min_js', 'uglify'
  ]);

  /**
   * A utility function to get all JavaScript sources.
   */
  function filterForJS ( files ) {
    return files.filter( function ( file ) {
      return file.match( /\.js$/ );
    });
  }

  /**
   * In order to avoid having to specify manually the files needed for karma to
   * run, we use grunt to manage the list for us. The `karma/*` files are
   * compiled as grunt templates for use by Karma. Yay!
   */
  grunt.registerMultiTask( 'karmaconfig', 'Process karma config templates', function () {
    var jsFiles = filterForJS( this.filesSrc );

    grunt.file.copy( 'karma/karma-unit.tpl.js', grunt.config( 'build_dir' ) + '/karma-unit.js', {
      process: function ( contents, path ) {
        return grunt.template.process( contents, {
          data: {
            scripts: jsFiles
          }
        });
      }
    });
  });
};
<|endoftext|>