<commit_before>module.exports = function(grunt) {
  var pkg = grunt.file.readJSON("package.json"),
      build = require("./lib/build");

  // Load all avaiable tasks
  require("load-grunt-tasks")(grunt);

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

  grunt.initConfig({
    pkg: pkg,

    markdown: {
      all: {
        files: [{
          expand: true,
          src: "**/*.md",
          dest: "dist",
          ext: ".html",
          cwd: "chapters"
        }],
        options: {
          markdownOptions: {
            gfm: true,
            sanitize: false,
            breaks: true,
            smartypants: true
          },
          template: "lib/template/template.html",
          templateContext: {
            buildDate: (new Date()).toISOString(),
            revision: "<%= meta.revision %>"
          },
          postCompile: build.postCompile,
          preCompile: build.preCompile
        }
      }
    },

    clean: {
      build: ["dist/**/*"]
    },

    sass: {
      build: {
        files: {
          "dist/style.css": "lib/template/scss/style.scss"
        },
        options: {
          imagePath: "lib/template/images"
        }
      }
    },

    buildcontrol: {
      deploy: {
        options: {
          dir: "dist",
          commit: true,
          push: true,
          message: "Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%",
          remote: "git@github.com:RobinQu/Programing-In-Javascript.git",
          branch: "gh-pages"
        }
      }
    },

    revision: {
      options: {
        property: "meta.revision",
        ref: "HEAD",
        short: true
      }
    },

    committers: {
      options: {
        sort: "commits",
        email: true,
        nomerges: true,
        output: "CONTRIBUTORS.md"
      }
    },

    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // Change this to "0.0.0.0" to access the server from outside
        hostname: "0.0.0.0"
      },
      preview: {
        options: {
          open: true,
          base: ["dist"],
          livereload: false
        }
      }
    },

    gitcommit: {
      contributor: {
        files: {
          src: ["CONTRIBUTORS.md"]
        },
        options: {
          message: "update CONTRIBUTORS.md"
        }
      }
    },

    sitemap: {
      dist: {
        siteRoot: "dist",
        homepage: "http://pij.robinqu.me"
      }
    },

    copy: {
      cname: {
        src: "lib/template/CNAME",
        dest: "dist/CNAME"
      },
      graphic: {
        files: [{
          src: "**/*.{jpg,png,gif}",
          dest: "dist",
          cwd: "chapters",
          dot: true,
          expand: true
        }]
      },
      cssimages: {
        files: [{
          cwd: "lib/template",
          src: "images/**/*.{jpg,png,gif}",
          dest: "dist",
          expand: true
        }]
      }
    }
  });

  grunt.registerTask("default", "build");

  grunt.registerTask("build", ["revision", "clean:build", "copy:cname", "copy:graphic", "copy:cssimages", "sass:build", "committers", "markdown:all", "sitemap:dist"]);

  grunt.registerTask("preview", ["build", "connect:preview:keepalive"]);

  grunt.registerTask("publish", ["build", "gitcommit:contributor", "buildcontrol:deploy"]);
};<commit_msg>fix path<commit_after>module.exports = function(grunt) {
  var pkg = grunt.file.readJSON("package.json"),
      build = require("./lib/build");

  // Load all avaiable tasks
  require("load-grunt-tasks")(grunt);

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

  grunt.initConfig({
    pkg: pkg,

    markdown: {
      all: {
        files: [{
          expand: true,
          src: "**/*.md",
          dest: "dist",
          ext: ".html",
          cwd: "chapters"
        }],
        options: {
          markdownOptions: {
            gfm: true,
            sanitize: false,
            breaks: true,
            smartypants: true
          },
          template: "lib/template/template.html",
          templateContext: {
            buildDate: (new Date()).toISOString(),
            revision: "<%= meta.revision %>"
          },
          postCompile: build.postCompile,
          preCompile: build.preCompile
        }
      }
    },

    clean: {
      build: ["dist/**/*"]
    },

    sass: {
      build: {
        files: {
          "dist/style.css": "lib/template/scss/style.scss"
        },
        options: {
          imagePath: "lib/template/images"
        }
      }
    },

    buildcontrol: {
      deploy: {
        options: {
          dir: "dist",
          commit: true,
          push: true,
          message: "Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%",
          remote: "git@github.com:RobinQu/Programing-In-Javascript.git",
          branch: "gh-pages"
        }
      }
    },

    revision: {
      options: {
        property: "meta.revision",
        ref: "HEAD",
        short: true
      }
    },

    committers: {
      options: {
        sort: "commits",
        email: true,
        nomerges: true,
        output: "CONTRIBUTORS.md"
      }
    },

    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // Change this to "0.0.0.0" to access the server from outside
        hostname: "0.0.0.0"
      },
      preview: {
        options: {
          open: true,
          base: ["dist"],
          livereload: false
        }
      }
    },

    gitcommit: {
      contributor: {
        files: {
          src: ["CONTRIBUTORS.md"]
        },
        options: {
          message: "update CONTRIBUTORS.md"
        }
      }
    },

    sitemap: {
      dist: {
        siteRoot: "dist/",
        homepage: "http://pij.robinqu.me/"
      }
    },

    copy: {
      cname: {
        src: "lib/template/CNAME",
        dest: "dist/CNAME"
      },
      graphic: {
        files: [{
          src: "**/*.{jpg,png,gif}",
          dest: "dist",
          cwd: "chapters",
          dot: true,
          expand: true
        }]
      },
      cssimages: {
        files: [{
          cwd: "lib/template",
          src: "images/**/*.{jpg,png,gif}",
          dest: "dist",
          expand: true
        }]
      }
    }
  });

  grunt.registerTask("default", "build");

  grunt.registerTask("build", ["revision", "clean:build", "copy:cname", "copy:graphic", "copy:cssimages", "sass:build", "committers", "markdown:all", "sitemap:dist"]);

  grunt.registerTask("preview", ["build", "connect:preview:keepalive"]);

  grunt.registerTask("publish", ["build", "gitcommit:contributor", "buildcontrol:deploy"]);
};<|endoftext|>


<commit_before>/**
 * When using enketo-core in your own app, you'd want to replace
 * this build file with one of your own in your project root.
 */

/*jshint node:true*/
"use strict";

module.exports = function( grunt ) {
    var js;

    // Project configuration.
    grunt.initConfig( {
        pkg: grunt.file.readJSON( 'package.json' ),
        connect: {
            server: {
                options: {
                    port: 8080
                }
            },
            test: {
                options: {
                    port: 8000
                }
            }
        },
        jsbeautifier: {
            test: {
                src: [ "*.js", "src/js/*.js", "src/widget/*/*.js" ],
                options: {
                    config: "./.jsbeautifyrc",
                    mode: "VERIFY_ONLY"
                }
            },
            fix: {
                src: [ "*.js", "src/js/*.js", "src/widget/*/*.js" ],
                options: {
                    config: "./.jsbeautifyrc"
                }
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [ '*.js', 'src/js/**/*.js', '!src/js/extern.js' ]
        },
        watch: {
            sass: {
                files: [ 'config.json', 'grid/sass/**/*.scss', 'src/sass/**/*.scss', 'src/widget/**/*.scss' ],
                tasks: [ 'style' ],
                options: {
                    spawn: false
                }
            },
            js: {
                files: [ '*.js', 'src/**/*.js', 'build/**/*.css' ],
                tasks: [ 'modernizr' ],
                options: {
                    spawn: false
                }
            }
        },
        jasmine: {
            test: {
                src: 'src/js/**/*.js',
                options: {
                    keepRunner: true,
                    specs: 'test/spec/*.js',
                    helpers: [ 'test/util/*.js', 'test/mock/*.js' ],
                    host: 'http://127.0.0.1:8000/',
                    template: require( 'grunt-template-jasmine-requirejs' ),
                    templateOptions: {
                        requireConfig: {
                            baseUrl: 'lib',
                            paths: {
                                'enketo-js': '../src/js',
                                'enketo-widget': '../src/widget',
                                'enketo-config': '../config.json',
                                text: 'text/text',
                                xpath: 'xpath/build/xpathjs_javarosa',
                                'jquery.xpath': 'jquery-xpath/jquery.xpath'
                            },
                            shim: {
                                'xpath': {
                                    exports: 'XPathJS'
                                },
                                'bootstrap': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.bootstrap'
                                },
                                'widget/date/bootstrap3-datepicker/js/bootstrap-datepicker': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.datepicker'
                                },
                                'widget/time/bootstrap3-timepicker/js/bootstrap-timepicker': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.timepicker'
                                }
                            },
                            map: {
                                '*': {
                                    'enketo-js': '../src/js',
                                    'enketo-widget': '../src/widget'
                                }
                            }
                        }
                    }
                },
            }
        },
        prepWidgetSass: {
            writePath: 'src/sass/_widgets.scss',
            widgetConfigPath: 'config.json'
        },
        sass: {
            dist: {
                options: {
                    style: 'expanded',
                    noCache: true
                },
                files: [ {
                    expand: true,
                    cwd: 'src/sass',
                    src: [ '**/*.scss', '!**/_*.scss' ],
                    dest: 'build/css',
                    ext: '.css'
                } ]
            }
        },
        // this compiles all javascript to a single minified file
        requirejs: {
            compile: {
                options: {
                    name: '../app',
                    baseUrl: 'lib',
                    mainConfigFile: "app.js",
                    findNestedDependencies: true,
                    include: ( function() {
                        //add widgets js and widget config.json files
                        var widgets = grunt.file.readJSON( 'config.json' ).widgets;
                        widgets.forEach( function( widget, index, arr ) {
                            arr.push( 'text!' + widget.substr( 0, widget.lastIndexOf( '/' ) + 1 ) + 'config.json' );
                        } );
                        return [ 'require.js' ].concat( widgets );
                    } )(),
                    out: "build/js/combined.min.js",
                    optimize: "uglify2"
                }
            }
        },
        modernizr: {
            "devFile": "remote",
            "outputFile": "lib/Modernizr.js",
            "extra": {
                "shiv": false,
                "printshiv": true,
                "load": false,
                "mq": false,
                "cssclasses": true
            },
            "uglify": false,
            "parseFiles": true
        }
    } );

    grunt.loadNpmTasks( 'grunt-contrib-connect' );
    grunt.loadNpmTasks( 'grunt-jsbeautifier' );
    grunt.loadNpmTasks( 'grunt-contrib-jasmine' );
    grunt.loadNpmTasks( 'grunt-contrib-watch' );
    grunt.loadNpmTasks( 'grunt-contrib-jshint' );
    grunt.loadNpmTasks( 'grunt-contrib-sass' );
    grunt.loadNpmTasks( 'grunt-contrib-requirejs' );
    grunt.loadNpmTasks( "grunt-modernizr" );

    //maybe this can be turned into a npm module?
    grunt.registerTask( 'prepWidgetSass', 'Preparing _widgets.scss dynamically', function() {
        var widgetConfig, widgetFolderPath, widgetSassPath, widgetConfigPath,
            config = grunt.config( 'prepWidgetSass' ),
            widgets = grunt.file.readJSON( config.widgetConfigPath ).widgets,
            content = '// Dynamically created list of widget stylesheets to import based on the content\r\n' +
                '// based on the content of config.json\r\n\r\n';

        widgets.forEach( function( widget ) {
            if ( widget.indexOf( 'enketo-widget/' ) === 0 ) {
                //strip require.js module name
                widgetFolderPath = widget.substr( 0, widget.lastIndexOf( '/' ) + 1 );
                //replace widget require.js path shortcut with proper path relative to src/js
                widgetSassPath = widgetFolderPath.replace( /^enketo-widget\//, '../widget/' );
                //create path to widget config file
                widgetConfigPath = widgetFolderPath.replace( /^enketo-widget\//, 'src/widget/' ) + 'config.json';
                grunt.log.writeln( 'widget config path: ' + widgetConfigPath );
                //create path to widget stylesheet file
                widgetSassPath += grunt.file.readJSON( widgetConfigPath ).stylesheet;
            } else {
                grunt.log.error( [ 'Expected widget path "' + widget + '" in config.json to be preceded by "widget/".' ] );
            }
            //replace this by a function that parses config.json in each widget folder to get the 'stylesheet' variable
            content += '@import "' + widgetSassPath + '";\r\n';
        } );

        grunt.file.write( config.writePath, content );

    } );

    grunt.registerTask( 'compile', [ 'requirejs:compile' ] );
    grunt.registerTask( 'test', [ 'jsbeautifier:test', 'jshint', 'connect:test', 'compile', 'jasmine' ] );
    grunt.registerTask( 'style', [ 'prepWidgetSass', 'sass' ] );
    grunt.registerTask( 'server', [ 'connect:server:keepalive' ] );
    grunt.registerTask( 'default', [ 'jshint', 'prepWidgetSass', 'sass', 'test' ] );
};
<commit_msg>fix tests<commit_after>/**
 * When using enketo-core in your own app, you'd want to replace
 * this build file with one of your own in your project root.
 */

/*jshint node:true*/
"use strict";

module.exports = function( grunt ) {
    var js;

    // Project configuration.
    grunt.initConfig( {
        pkg: grunt.file.readJSON( 'package.json' ),
        connect: {
            server: {
                options: {
                    port: 8080
                }
            },
            test: {
                options: {
                    port: 8000
                }
            }
        },
        jsbeautifier: {
            test: {
                src: [ "*.js", "src/js/*.js", "src/widget/*/*.js" ],
                options: {
                    config: "./.jsbeautifyrc",
                    mode: "VERIFY_ONLY"
                }
            },
            fix: {
                src: [ "*.js", "src/js/*.js", "src/widget/*/*.js" ],
                options: {
                    config: "./.jsbeautifyrc"
                }
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [ '*.js', 'src/js/**/*.js', '!src/js/extern.js' ]
        },
        watch: {
            sass: {
                files: [ 'config.json', 'grid/sass/**/*.scss', 'src/sass/**/*.scss', 'src/widget/**/*.scss' ],
                tasks: [ 'style' ],
                options: {
                    spawn: false
                }
            },
            js: {
                files: [ '*.js', 'src/**/*.js', 'build/**/*.css' ],
                tasks: [ 'modernizr' ],
                options: {
                    spawn: false
                }
            }
        },
        jasmine: {
            test: {
                src: 'src/js/**/*.js',
                options: {
                    keepRunner: true,
                    specs: 'test/spec/*.js',
                    helpers: [ 'test/util/*.js', 'test/mock/*.js' ],
                    host: 'http://127.0.0.1:8000/',
                    template: require( 'grunt-template-jasmine-requirejs' ),
                    templateOptions: {
                        requireConfig: {
                            baseUrl: 'lib',
                            paths: {
                                'enketo-js': '../src/js',
                                'enketo-widget': '../src/widget',
                                'enketo-config': '../config.json',
                                text: 'text/text',
                                xpath: 'xpath/build/xpathjs_javarosa',
                                'jquery.xpath': 'jquery-xpath/jquery.xpath',
                                'jquery.touchswipe': 'jquery-touchswipe/jquery.touchSwipe'
                            },
                            shim: {
                                'xpath': {
                                    exports: 'XPathJS'
                                },
                                'bootstrap': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.bootstrap'
                                },
                                'widget/date/bootstrap3-datepicker/js/bootstrap-datepicker': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.datepicker'
                                },
                                'widget/time/bootstrap3-timepicker/js/bootstrap-timepicker': {
                                    deps: [ 'jquery' ],
                                    exports: 'jQuery.fn.timepicker'
                                }
                            },
                            map: {
                                '*': {
                                    'enketo-js': '../src/js',
                                    'enketo-widget': '../src/widget'
                                }
                            }
                        }
                    }
                },
            }
        },
        prepWidgetSass: {
            writePath: 'src/sass/_widgets.scss',
            widgetConfigPath: 'config.json'
        },
        sass: {
            dist: {
                options: {
                    style: 'expanded',
                    noCache: true
                },
                files: [ {
                    expand: true,
                    cwd: 'src/sass',
                    src: [ '**/*.scss', '!**/_*.scss' ],
                    dest: 'build/css',
                    ext: '.css'
                } ]
            }
        },
        // this compiles all javascript to a single minified file
        requirejs: {
            compile: {
                options: {
                    name: '../app',
                    baseUrl: 'lib',
                    mainConfigFile: "app.js",
                    findNestedDependencies: true,
                    include: ( function() {
                        //add widgets js and widget config.json files
                        var widgets = grunt.file.readJSON( 'config.json' ).widgets;
                        widgets.forEach( function( widget, index, arr ) {
                            arr.push( 'text!' + widget.substr( 0, widget.lastIndexOf( '/' ) + 1 ) + 'config.json' );
                        } );
                        return [ 'require.js' ].concat( widgets );
                    } )(),
                    out: "build/js/combined.min.js",
                    optimize: "uglify2"
                }
            }
        },
        modernizr: {
            "devFile": "remote",
            "outputFile": "lib/Modernizr.js",
            "extra": {
                "shiv": false,
                "printshiv": true,
                "load": false,
                "mq": false,
                "cssclasses": true
            },
            "uglify": false,
            "parseFiles": true
        }
    } );

    grunt.loadNpmTasks( 'grunt-contrib-connect' );
    grunt.loadNpmTasks( 'grunt-jsbeautifier' );
    grunt.loadNpmTasks( 'grunt-contrib-jasmine' );
    grunt.loadNpmTasks( 'grunt-contrib-watch' );
    grunt.loadNpmTasks( 'grunt-contrib-jshint' );
    grunt.loadNpmTasks( 'grunt-contrib-sass' );
    grunt.loadNpmTasks( 'grunt-contrib-requirejs' );
    grunt.loadNpmTasks( "grunt-modernizr" );

    //maybe this can be turned into a npm module?
    grunt.registerTask( 'prepWidgetSass', 'Preparing _widgets.scss dynamically', function() {
        var widgetConfig, widgetFolderPath, widgetSassPath, widgetConfigPath,
            config = grunt.config( 'prepWidgetSass' ),
            widgets = grunt.file.readJSON( config.widgetConfigPath ).widgets,
            content = '// Dynamically created list of widget stylesheets to import based on the content\r\n' +
                '// based on the content of config.json\r\n\r\n';

        widgets.forEach( function( widget ) {
            if ( widget.indexOf( 'enketo-widget/' ) === 0 ) {
                //strip require.js module name
                widgetFolderPath = widget.substr( 0, widget.lastIndexOf( '/' ) + 1 );
                //replace widget require.js path shortcut with proper path relative to src/js
                widgetSassPath = widgetFolderPath.replace( /^enketo-widget\//, '../widget/' );
                //create path to widget config file
                widgetConfigPath = widgetFolderPath.replace( /^enketo-widget\//, 'src/widget/' ) + 'config.json';
                grunt.log.writeln( 'widget config path: ' + widgetConfigPath );
                //create path to widget stylesheet file
                widgetSassPath += grunt.file.readJSON( widgetConfigPath ).stylesheet;
            } else {
                grunt.log.error( [ 'Expected widget path "' + widget + '" in config.json to be preceded by "widget/".' ] );
            }
            //replace this by a function that parses config.json in each widget folder to get the 'stylesheet' variable
            content += '@import "' + widgetSassPath + '";\r\n';
        } );

        grunt.file.write( config.writePath, content );

    } );

    grunt.registerTask( 'compile', [ 'requirejs:compile' ] );
    grunt.registerTask( 'test', [ 'jsbeautifier:test', 'jshint', 'connect:test', 'compile', 'jasmine' ] );
    grunt.registerTask( 'style', [ 'prepWidgetSass', 'sass' ] );
    grunt.registerTask( 'server', [ 'connect:server:keepalive' ] );
    grunt.registerTask( 'default', [ 'jshint', 'prepWidgetSass', 'sass', 'test' ] );
};
<|endoftext|>


<commit_before>/* -------------------------------------------------------------------------- *\
   Gruntfile - project build instructions
   --------------------------------------------------------------------------

   This file is part of XML-to-bootstrap.
   https://github.com/acch/XML-to-bootstrap

   Copyright 2016 Achim Christ
   Released under the MIT license
   (https://github.com/acch/XML-to-bootstrap/blob/master/LICENSE)

\* -------------------------------------------------------------------------- */

// TODO: uncss task?
// TODO: jshint task? (inkl. .jshintrc)
// TODO: scsslint task?

module.exports = function(grunt) {
  "use strict";

  // dependencies
  var path = require('path');
  var parser = require('xml2json');

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

    // path definitions
    path: {
      anchor:          'lib/anchor-js',
      bootstrap:       'modules/bootstrap/dist',
      fontawesome:     'lib/font-awesome',
      headroom:        'lib/headroom.js',
      jquery:          'lib/jquery',
      photoswipe:      'lib/photoswipe',
      scrollposstyler: 'lib/scrollpos-styler',
      tether:          'lib/tether'
    },

    exec: {
      submodules: {
        cmd: 'git submodule update --init \
        && if ! grep -q customvars modules/bootstrap/scss/_custom.scss; then echo \'@import "customvars";\' >> modules/bootstrap/scss/_custom.scss; fi \
        && ln -sf ../../../sass/customvars.scss modules/bootstrap/scss/'
      }
    },

    subgrunt: {
      bootstrap: {
        'modules/bootstrap': 'dist'
      }
    },

    clean: {
      publish: [
        'css/*',
        'js/*',
        '!js/headings.js',
        '!js/navbar.js',
        'publish/*',
      ]
    },

    bower: {
      publish: {
        options: {
          cleanBowerDir: false,
          cleanTargetDir: true,
          copy: true,
          layout: 'byComponent'
        }
      }
    },

    copy: {
      publish: {
        files: [
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.anchor %>',
            src: '**/anchor.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.bootstrap %>',
            src: '**/bootstrap.min.css',
            dest: 'publish/css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.bootstrap %>',
            src: '**/bootstrap.min.js',
            dest: 'publish/js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.fontawesome %>',
            src: '**/font-awesome.min.css',
            dest: 'publish/css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.headroom %>',
            src: '**/headroom.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.jquery %>',
            src: '**/jquery.min.js',
            dest: 'publish/js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.photoswipe %>',
            src: ['**/photoswipe.css', '**/default-skin.css'],
            dest: 'css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.photoswipe %>',
            src: '**/photoswipe*.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.scrollposstyler %>',
            src: '**/scrollPosStyler.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.tether %>',
            src: '**/tether.min.js',
            dest: 'publish/js/'
          }
        ]
      },

      assets_pre: {
        expand: true,
        cwd: 'src/img/',
        src: '*.{png,jpg,gif}',
        dest: 'img/'
      },

      assets_post: {
        expand: true,
        cwd: 'img/min/',
        src: '**/*.{png,jpg,gif}',
        dest: 'publish/assets/'
      }
    },

    xsltproc: {
      options: {
        stylesheet: 'style/main.xsl',
        xinclude: true
      },
      dev: {
        options: {
          params: {
            'devmode': 'true()'
          }
        },
        src: 'src/main.xml',
        dest: 'publish/index.html'
      },
      prod: {
        options: {
          params: {
            'devmode': 'false()'
          }
        },
        src: '<%= xsltproc.dev.src %>',
        dest: '<%= xsltproc.dev.dest %>'
      }
    },

    concat: {
      publish: {
        files: [
          {
            src: [
              'js/options.json',
              'js/anchor.js',
              'js/headroom.js',
              'js/scrollPosStyler.js',
              'js/headings.js',
              'js/navbar.js'
            ],
            dest: 'publish/js/script.js'
          },
          {
            src: 'css/*.css',
            dest: 'publish/css/gallery.css'
          },
          {
            src: 'js/photoswipe*.js',
            dest: 'publish/js/gallery.js'
          }
        ]
      }
    },

    uglify: {
      publish: {
        files: {
          'publish/js/script.js': 'publish/js/script.js',
          'publish/js/gallery.js': 'publish/js/gallery.js'
        }
      }
    },

    sass: {
      options: {
        style: 'nested'
      },
      publish: {
        src: 'sass/style.scss',
        dest: 'publish/css/style.css'
      }
    },

    autoprefixer: {
//      options: {
//        browsers: '> 1%, last 2 versions'
//      },
      publish: {
        src: ['publish/css/style.css', 'publish/css/gallery.css']
      }
    },

    csslint: {
      options: {
        'adjoining-classes': false,
        'compatible-vendor-prefixes': false,
        'fallback-colors': false,
        'important': false
      },
      publish: {
        src: 'publish/css/style.css'
      }
    },

    cssmin: {
      publish: {
        files: {
          'publish/css/style.css': 'publish/css/style.css',
          'publish/css/gallery.css': 'publish/css/gallery.css'
        }
      }
    },

    htmllint: {
      options: {
        ignore: [
          'The "contentinfo" role is unnecessary for element "footer".',
          'The "banner" role is unnecessary for element "header".'
        ]
      },
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    htmlmin: {
      options: {
        removeComments: true,
        collapseWhitespace: true
      },
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    prettify: {
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    responsive_images: {
      options: {
        concurrency: 2
        // sizes are defined by 'xmlopts' task
      },
      assets: {
        expand: true,
        cwd: 'src/img/',
        src: '*/**/*.{png,jpg,gif}',
        dest: 'img/'
      }
    },

    imagemin: {
      assets: {
        expand: true,
        cwd: 'img/',
        src: [ '**/*.{png,jpg,gif}', '!min/**' ],
        dest: 'img/min/'
      }
    },

    connect: {
      publish: {
        options: {
          port: 8000,
          base: 'publish',
          keepalive: true,
          //open: 'http://localhost:8000/',
        }
      }
    }
  });

  // load the plugin(s)
  require('load-grunt-tasks')(grunt);

  // read options from XML
  grunt.registerTask('xmlopts', function() {

    // parse options.xml as object
    var xmlopts = parser.toJson(grunt.file.read('src/options.xml'), {
      coerce: true,
      object: true
    }).options;

    // extract Grunt options
    var gruntopts = xmlopts.export.filter(function(e) {
      return e.type == 'grunt';
    })[0].option;

    // temp configuration object
    var config = {
      responsive_images: {
        options: {
          sizes: []
        }
      }
    };

    // iterate over Grunt options
    for (var i = 0; gruntopts[i]; ++i) {
      // add options to temp configuration object
      switch (gruntopts[i].name) {

        case 'responive_image.size':
          config.responsive_images.options.sizes.push({
            name: gruntopts[i]['$t'],
            width: gruntopts[i]['$t']
          });
          break;

        // ...process further options...

      }
    }

    // apply temp Grunt configuration
    grunt.config.merge(config);
  });

  // copy sample files
  grunt.registerTask('copy_samples', function() {

    // copy sample files if they don't exist
    function copySampleIfNotExist(relpath) {

      // recurse sample subdirectory
      grunt.file.recurse(path.join(relpath, 'sample'), function(abspath, rootdir, subdir, filename) {

        // check if destination file exists
        var destfile = path.join(relpath, filename);
        if (! grunt.file.exists(destfile)) {

          // copy sample to destination
          grunt.log.writeln('Copying sample: ' + filename);
          grunt.file.copy(abspath, destfile);
        }
      });
    }

    // copy XML samples
    copySampleIfNotExist('src');

    // copy Sass samples
    copySampleIfNotExist('sass');

    // copy sample images only if directory doesn't exist, yet
    if (! grunt.file.isDir('src/img/')) {

      // copy sample images
      grunt.log.writeln('Copying sample images');
      grunt.file.copy('src/sampleimg/', 'src/img/');
    }
  });

  // initialize submodules
  grunt.registerTask('init', [
    'copy_samples',
    'exec:submodules',
    'subgrunt'
  ]);

  // no minification but linting (use this for development)
  grunt.registerTask('debug', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:dev',
    'concat',
    'sass',
    'autoprefixer',
    'csslint',
    'prettify',
    'htmllint',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

  // no linting but minification (use this for development)
  grunt.registerTask('default', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:dev',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'cssmin',
    'htmlmin',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

  // no linting but minification (use this for production)
  grunt.registerTask('prod', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:prod',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'cssmin',
    'htmlmin',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

};
<commit_msg>Use Bootstrap path definition<commit_after>/* -------------------------------------------------------------------------- *\
   Gruntfile - project build instructions
   --------------------------------------------------------------------------

   This file is part of XML-to-bootstrap.
   https://github.com/acch/XML-to-bootstrap

   Copyright 2016 Achim Christ
   Released under the MIT license
   (https://github.com/acch/XML-to-bootstrap/blob/master/LICENSE)

\* -------------------------------------------------------------------------- */

// TODO: uncss task?
// TODO: jshint task? (inkl. .jshintrc)
// TODO: scsslint task?

module.exports = function(grunt) {
  "use strict";

  // dependencies
  var path = require('path');
  var parser = require('xml2json');

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

    // path definitions
    path: {
      anchor:          'lib/anchor-js',
      bootstrap:       'modules/bootstrap',
      fontawesome:     'lib/font-awesome',
      headroom:        'lib/headroom.js',
      jquery:          'lib/jquery',
      photoswipe:      'lib/photoswipe',
      scrollposstyler: 'lib/scrollpos-styler',
      tether:          'lib/tether'
    },

    exec: {
      submodules: {
        cmd: 'git submodule update --init \
        && if ! grep -q customvars <%= path.bootstrap %>/scss/_custom.scss; then echo \'@import "customvars";\' >> <%= path.bootstrap %>/scss/_custom.scss; fi \
        && ln -sf ../../../sass/customvars.scss <%= path.bootstrap %>/scss/'
      }
    },

    subgrunt: {
      bootstrap: {
        'modules/bootstrap': 'dist'
      }
    },

    clean: {
      publish: [
        'css/*',
        'js/*',
        '!js/headings.js',
        '!js/navbar.js',
        'publish/*',
      ]
    },

    bower: {
      publish: {
        options: {
          cleanBowerDir: false,
          cleanTargetDir: true,
          copy: true,
          layout: 'byComponent'
        }
      }
    },

    copy: {
      publish: {
        files: [
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.anchor %>',
            src: '**/anchor.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.bootstrap %>/dist',
            src: '**/bootstrap.min.css',
            dest: 'publish/css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.bootstrap %>/dist',
            src: '**/bootstrap.min.js',
            dest: 'publish/js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.fontawesome %>',
            src: '**/font-awesome.min.css',
            dest: 'publish/css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.headroom %>',
            src: '**/headroom.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.jquery %>',
            src: '**/jquery.min.js',
            dest: 'publish/js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.photoswipe %>',
            src: ['**/photoswipe.css', '**/default-skin.css'],
            dest: 'css/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.photoswipe %>',
            src: '**/photoswipe*.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.scrollposstyler %>',
            src: '**/scrollPosStyler.js',
            dest: 'js/'
          },
          {
            expand: true,
            flatten: true,
            nonull: true,
            cwd: '<%= path.tether %>',
            src: '**/tether.min.js',
            dest: 'publish/js/'
          }
        ]
      },

      assets_pre: {
        expand: true,
        cwd: 'src/img/',
        src: '*.{png,jpg,gif}',
        dest: 'img/'
      },

      assets_post: {
        expand: true,
        cwd: 'img/min/',
        src: '**/*.{png,jpg,gif}',
        dest: 'publish/assets/'
      }
    },

    xsltproc: {
      options: {
        stylesheet: 'style/main.xsl',
        xinclude: true
      },
      dev: {
        options: {
          params: {
            'devmode': 'true()'
          }
        },
        src: 'src/main.xml',
        dest: 'publish/index.html'
      },
      prod: {
        options: {
          params: {
            'devmode': 'false()'
          }
        },
        src: '<%= xsltproc.dev.src %>',
        dest: '<%= xsltproc.dev.dest %>'
      }
    },

    concat: {
      publish: {
        files: [
          {
            src: [
              'js/options.json',
              'js/anchor.js',
              'js/headroom.js',
              'js/scrollPosStyler.js',
              'js/headings.js',
              'js/navbar.js'
            ],
            dest: 'publish/js/script.js'
          },
          {
            src: 'css/*.css',
            dest: 'publish/css/gallery.css'
          },
          {
            src: 'js/photoswipe*.js',
            dest: 'publish/js/gallery.js'
          }
        ]
      }
    },

    uglify: {
      publish: {
        files: {
          'publish/js/script.js': 'publish/js/script.js',
          'publish/js/gallery.js': 'publish/js/gallery.js'
        }
      }
    },

    sass: {
      options: {
        style: 'nested'
      },
      publish: {
        src: 'sass/style.scss',
        dest: 'publish/css/style.css'
      }
    },

    autoprefixer: {
//      options: {
//        browsers: '> 1%, last 2 versions'
//      },
      publish: {
        src: ['publish/css/style.css', 'publish/css/gallery.css']
      }
    },

    csslint: {
      options: {
        'adjoining-classes': false,
        'compatible-vendor-prefixes': false,
        'fallback-colors': false,
        'important': false
      },
      publish: {
        src: 'publish/css/style.css'
      }
    },

    cssmin: {
      publish: {
        files: {
          'publish/css/style.css': 'publish/css/style.css',
          'publish/css/gallery.css': 'publish/css/gallery.css'
        }
      }
    },

    htmllint: {
      options: {
        ignore: [
          'The "contentinfo" role is unnecessary for element "footer".',
          'The "banner" role is unnecessary for element "header".'
        ]
      },
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    htmlmin: {
      options: {
        removeComments: true,
        collapseWhitespace: true
      },
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    prettify: {
      publish: {
        expand: true,
        nonull: true,
        src: 'publish/**/*.html'
      }
    },

    responsive_images: {
      options: {
        concurrency: 2
        // sizes are defined by 'xmlopts' task
      },
      assets: {
        expand: true,
        cwd: 'src/img/',
        src: '*/**/*.{png,jpg,gif}',
        dest: 'img/'
      }
    },

    imagemin: {
      assets: {
        expand: true,
        cwd: 'img/',
        src: [ '**/*.{png,jpg,gif}', '!min/**' ],
        dest: 'img/min/'
      }
    },

    connect: {
      publish: {
        options: {
          port: 8000,
          base: 'publish',
          keepalive: true,
          //open: 'http://localhost:8000/',
        }
      }
    }
  });

  // load the plugin(s)
  require('load-grunt-tasks')(grunt);

  // read options from XML
  grunt.registerTask('xmlopts', function() {

    // parse options.xml as object
    var xmlopts = parser.toJson(grunt.file.read('src/options.xml'), {
      coerce: true,
      object: true
    }).options;

    // extract Grunt options
    var gruntopts = xmlopts.export.filter(function(e) {
      return e.type == 'grunt';
    })[0].option;

    // temp configuration object
    var config = {
      responsive_images: {
        options: {
          sizes: []
        }
      }
    };

    // iterate over Grunt options
    for (var i = 0; gruntopts[i]; ++i) {
      // add options to temp configuration object
      switch (gruntopts[i].name) {

        case 'responive_image.size':
          config.responsive_images.options.sizes.push({
            name: gruntopts[i]['$t'],
            width: gruntopts[i]['$t']
          });
          break;

        // ...process further options...

      }
    }

    // apply temp Grunt configuration
    grunt.config.merge(config);
  });

  // copy sample files
  grunt.registerTask('copy_samples', function() {

    // copy sample files if they don't exist
    function copySampleIfNotExist(relpath) {

      // recurse sample subdirectory
      grunt.file.recurse(path.join(relpath, 'sample'), function(abspath, rootdir, subdir, filename) {

        // check if destination file exists
        var destfile = path.join(relpath, filename);
        if (! grunt.file.exists(destfile)) {

          // copy sample to destination
          grunt.log.writeln('Copying sample: ' + filename);
          grunt.file.copy(abspath, destfile);
        }
      });
    }

    // copy XML samples
    copySampleIfNotExist('src');

    // copy Sass samples
    copySampleIfNotExist('sass');

    // copy sample images only if directory doesn't exist, yet
    if (! grunt.file.isDir('src/img/')) {

      // copy sample images
      grunt.log.writeln('Copying sample images');
      grunt.file.copy('src/sampleimg/', 'src/img/');
    }
  });

  // initialize submodules
  grunt.registerTask('init', [
    'copy_samples',
    'exec:submodules',
    'subgrunt'
  ]);

  // no minification but linting (use this for development)
  grunt.registerTask('debug', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:dev',
    'concat',
    'sass',
    'autoprefixer',
    'csslint',
    'prettify',
    'htmllint',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

  // no linting but minification (use this for development)
  grunt.registerTask('default', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:dev',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'cssmin',
    'htmlmin',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

  // no linting but minification (use this for production)
  grunt.registerTask('prod', [
    'copy_samples',
    'xmlopts',
    'clean',
    'bower',
    'copy:publish',
    'xsltproc:prod',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'cssmin',
    'htmlmin',
    'copy:assets_pre',
    'responsive_images',
    'newer:imagemin',
    'copy:assets_post'
  ]);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            allFiles: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js', 'index.js'],
            options: {
                jshintrc: '.jshintrc',
            }
        },
        mochacli: {
            all: ['test/**/*.js'],
            options: {
                reporter: 'spec',
                ui: 'tdd'
            }
        },
        'mocha_istanbul': {
            coveralls: {
                src: [ 'test/lib', 'test/lib/utils' ],
                options: {
                    coverage: true,
                    legend: true,
                    check: {
                        lines: 99,
                        statements: 100
                    },
                    root: './lib',
                    reportFormats: ['lcov']
                }
            }
        }
    })

    grunt.event.on('coverage', function(lcov, done){
        require('coveralls').handleInput(lcov, function(error) {
            if (error) {
                console.log(error)
                return done(error)
            }
            done()
        })
    })

    // Load the plugins
    grunt.loadNpmTasks('grunt-contrib-jshint')
    grunt.loadNpmTasks('grunt-mocha-cli')
    grunt.loadNpmTasks('grunt-mocha-istanbul')

    // Configure tasks
    grunt.registerTask('coveralls', ['mocha_istanbul:coveralls'])
    grunt.registerTask('default', ['test'])

    grunt.registerTask('test', ['mochacli', 'jshint', 'coveralls'])
}<commit_msg>99% coverage<commit_after>'use strict';

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
            allFiles: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js', 'index.js'],
            options: {
                jshintrc: '.jshintrc',
            }
        },
        mochacli: {
            all: ['test/**/*.js'],
            options: {
                reporter: 'spec',
                ui: 'tdd'
            }
        },
        'mocha_istanbul': {
            coveralls: {
                src: [ 'test/lib', 'test/lib/utils' ],
                options: {
                    coverage: true,
                    legend: true,
                    check: {
                        lines: 99,
                        statements: 99
                    },
                    root: './lib',
                    reportFormats: ['lcov']
                }
            }
        }
    })

    grunt.event.on('coverage', function(lcov, done){
        require('coveralls').handleInput(lcov, function(error) {
            if (error) {
                console.log(error)
                return done(error)
            }
            done()
        })
    })

    // Load the plugins
    grunt.loadNpmTasks('grunt-contrib-jshint')
    grunt.loadNpmTasks('grunt-mocha-cli')
    grunt.loadNpmTasks('grunt-mocha-istanbul')

    // Configure tasks
    grunt.registerTask('coveralls', ['mocha_istanbul:coveralls'])
    grunt.registerTask('default', ['test'])

    grunt.registerTask('test', ['mochacli', 'jshint', 'coveralls'])
}<|endoftext|>


<commit_before>const child_process = require("child_process");
const fs = require("fs");

module.exports = function(grunt) {
  var pkg = grunt.file.readJSON('package.json');

  var betaVersion = pkg.version.toString() + "." + process.env.TRAVIS_BUILD_NUMBER;

  grunt.initConfig({
    pkg: pkg,

    compress: {
      // Zip up the extension
      chrome: {
        options: {
          archive: 'dist/chrome.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist',
          src: [
            '**',
            '!data',
            '!chrome.zip',
            '!.htaccess',
            '!stats.html'
          ],
          dest: '/',
          filter: 'isFile'
        }, ]
      }
    },

    // See https://github.com/c301/grunt-webstore-upload
    webstore_upload: {
      accounts: {
        // This is set up by environment variables from Travis. To
        // push locally, create a file with these variables defined
        // and source it before running "grunt publish:beta". E.g.:
        //
        // ./beta_credentials:
        //
        // export CHROME_CLIENT_ID="foo"
        // export CHROME_SECRET="bar"
        // export CHROME_REFRESH_TOKEN="baz"
        //
        // Then run "source ./beta_credentials; grunt publish_chrome_beta"
        //
        // To set up these variables to be available in Travis:
        // travis encrypt CHROME_CLIENT_ID=super_secret --add env.matrix
        // travis encrypt CHROME_SECRET=super_secret --add env.matrix
        // travis encrypt CHROME_REFRESH_TOKEN=super_secret --add env.matrix
        default: { //account under this section will be used by default
          publish: true, //publish item right after uploading. default false
          client_id: process.env.CHROME_CLIENT_ID,
          client_secret: process.env.CHROME_SECRET,
          refresh_token: process.env.CHROME_REFRESH_TOKEN
        }
      },
      extensions: {
        release: {
          appID: "apghicjnekejhfancbkahkhdckhdagna",
          publish: false,
          zip: "dist/chrome.zip"
        },
        beta: {
          appID: "mkiipknpfaacbjdagdeppdacpgpdjklc",
          zip: "dist/chrome.zip"
        }
      }
    },

    // Tasks for uploading the website versions
    rsync: {
      options: {
        //dryRun: true,
        args: ["--verbose"],
        exclude: ["chrome.zip", "stats.html"],
        host: process.env.REMOTE_HOST,
        port: 2222,
        recursive: true,
        deleteAll: true,
        ssh: true,
        privateKey: 'config/dim_travis.rsa',
        sshCmdArgs: ["-o StrictHostKeyChecking=no"]
      },
      beta: {
        options: {
          src: "dist/",
          dest: process.env.REMOTE_PATH + "beta"
        }
      },
      prod: {
        options: {
          src: "dist/",
          dest: process.env.REMOTE_PATH + "prod"
        }
      }
    },

    precompress: {
      web: {
        src: "dist/**/*.{js,html,css,json,map,ttf,eot,svg}"
      }
    }
  });

  grunt.loadNpmTasks('grunt-webstore-upload');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-rsync');

  grunt.registerTask('update_chrome_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerMultiTask(
    'precompress',
    'Create gzip and brotli versions of web assets',
    function() {
      const done = this.async();
      const promises = [];
      this.filesSrc.forEach(function(file) {
        promises.push(new Promise(function(resolve, reject) {
          child_process.exec("gzip -c --no-name " + file + " > " + file + ".gz", function(error, stdout, stderr) {
            if (error) {
              grunt.log.writeln("gzip " + file + " => error: " + stdout + stderr);
              reject(error);
            } else {
              grunt.log.writeln("gzip " + file + " => success");
              resolve();
            }
          });
        }));

        promises.push(new Promise(function(resolve, reject) {
          child_process.execFile("brotli/out/bin/bin/brotli", ["--quality", "9", "--input", file, "--output", file + ".br"], function(error, stdout, stderr) {
            if (error) {
              grunt.log.writeln("brotli " + file + " => error: " + stdout + stderr);
              reject(error);
            } else {
              grunt.log.writeln("brotli " + file + " => success");
              resolve();
            }
          });
        }).then(function() {
          return new Promise(function(resolve, reject) {
            fs.chmod(file + ".br", 0644, resolve);
          });
        }));
      });

      Promise.all(promises).then(done);
    }
  );

  grunt.registerTask('publish_beta', [
    'update_chrome_beta_manifest',
    'compress:chrome',
    'log_beta_version',
    'webstore_upload:beta',
    'precompress',
    'rsync:beta'
  ]);

  grunt.registerTask('publish_release', [
    'compress:chrome',
    'webstore_upload:release',
    'precompress',
    'rsync:prod'
  ]);

  grunt.registerTask('log_beta_version', function() {
    grunt.log.ok("New Beta version is " + betaVersion);
  });
};
<commit_msg>Try different brotli arguments<commit_after>const child_process = require("child_process");
const fs = require("fs");

module.exports = function(grunt) {
  var pkg = grunt.file.readJSON('package.json');

  var betaVersion = pkg.version.toString() + "." + process.env.TRAVIS_BUILD_NUMBER;

  grunt.initConfig({
    pkg: pkg,

    compress: {
      // Zip up the extension
      chrome: {
        options: {
          archive: 'dist/chrome.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist',
          src: [
            '**',
            '!data',
            '!chrome.zip',
            '!.htaccess',
            '!stats.html'
          ],
          dest: '/',
          filter: 'isFile'
        }, ]
      }
    },

    // See https://github.com/c301/grunt-webstore-upload
    webstore_upload: {
      accounts: {
        // This is set up by environment variables from Travis. To
        // push locally, create a file with these variables defined
        // and source it before running "grunt publish:beta". E.g.:
        //
        // ./beta_credentials:
        //
        // export CHROME_CLIENT_ID="foo"
        // export CHROME_SECRET="bar"
        // export CHROME_REFRESH_TOKEN="baz"
        //
        // Then run "source ./beta_credentials; grunt publish_chrome_beta"
        //
        // To set up these variables to be available in Travis:
        // travis encrypt CHROME_CLIENT_ID=super_secret --add env.matrix
        // travis encrypt CHROME_SECRET=super_secret --add env.matrix
        // travis encrypt CHROME_REFRESH_TOKEN=super_secret --add env.matrix
        default: { //account under this section will be used by default
          publish: true, //publish item right after uploading. default false
          client_id: process.env.CHROME_CLIENT_ID,
          client_secret: process.env.CHROME_SECRET,
          refresh_token: process.env.CHROME_REFRESH_TOKEN
        }
      },
      extensions: {
        release: {
          appID: "apghicjnekejhfancbkahkhdckhdagna",
          publish: false,
          zip: "dist/chrome.zip"
        },
        beta: {
          appID: "mkiipknpfaacbjdagdeppdacpgpdjklc",
          zip: "dist/chrome.zip"
        }
      }
    },

    // Tasks for uploading the website versions
    rsync: {
      options: {
        //dryRun: true,
        args: ["--verbose"],
        exclude: ["chrome.zip", "stats.html"],
        host: process.env.REMOTE_HOST,
        port: 2222,
        recursive: true,
        deleteAll: true,
        ssh: true,
        privateKey: 'config/dim_travis.rsa',
        sshCmdArgs: ["-o StrictHostKeyChecking=no"]
      },
      beta: {
        options: {
          src: "dist/",
          dest: process.env.REMOTE_PATH + "beta"
        }
      },
      prod: {
        options: {
          src: "dist/",
          dest: process.env.REMOTE_PATH + "prod"
        }
      }
    },

    precompress: {
      web: {
        src: "dist/**/*.{js,html,css,json,map,ttf,eot,svg}"
      }
    }
  });

  grunt.loadNpmTasks('grunt-webstore-upload');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-rsync');

  grunt.registerTask('update_chrome_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerMultiTask(
    'precompress',
    'Create gzip and brotli versions of web assets',
    function() {
      const done = this.async();
      const promises = [];
      this.filesSrc.forEach(function(file) {
        promises.push(new Promise(function(resolve, reject) {
          child_process.exec("gzip -c --no-name " + file + " > " + file + ".gz", function(error, stdout, stderr) {
            if (error) {
              grunt.log.writeln("gzip " + file + " => error: " + stdout + stderr);
              reject(error);
            } else {
              grunt.log.writeln("gzip " + file + " => success");
              resolve();
            }
          });
        }));

        promises.push(new Promise(function(resolve, reject) {
          child_process.execFile("brotli/out/bin/bin/brotli", [file], function(error, stdout, stderr) {
            if (error) {
              grunt.log.writeln("brotli " + file + " => error: " + stdout + stderr);
              reject(error);
            } else {
              grunt.log.writeln("brotli " + file + " => success");
              resolve();
            }
          });
        }).then(function() {
          return new Promise(function(resolve, reject) {
            fs.chmod(file + ".br", 0644, resolve);
          });
        }));
      });

      Promise.all(promises).then(done);
    }
  );

  grunt.registerTask('publish_beta', [
    'update_chrome_beta_manifest',
    'compress:chrome',
    'log_beta_version',
    'webstore_upload:beta',
    'precompress',
    'rsync:beta'
  ]);

  grunt.registerTask('publish_release', [
    'compress:chrome',
    'webstore_upload:release',
    'precompress',
    'rsync:prod'
  ]);

  grunt.registerTask('log_beta_version', function() {
    grunt.log.ok("New Beta version is " + betaVersion);
  });
};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      plugin: {
        files: [{
          expand: true,
          cwd: 'js/',
          src: '*.js',
          dest: 'js/',
          ext: '.min.js'
        }],
        options: {
          banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
            '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
            '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
            '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
            ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
        }
      }
    },
    coffee : {
      plugin : {
        files: [{
          expand: true,
          cwd: 'js/',
          src: '*.coffee',
          dest: 'js/',
          ext: '.js'
        }]
      },
      specs : {
        files: [{
          expand: true,
          cwd: 'spec/coffeescripts/',
          src: '*.coffee',
          dest: 'spec/javascripts/',
          ext: '.js'
        }]
      },
      helpers : {
        files: [{
          expand: true,
          cwd: 'spec/coffeescripts/helpers/',
          src: '*.coffee',
          dest: 'spec/javascripts/helpers/',
          ext: '.js'
        }]
      }
    },
    jasmine : {
      src     : ['js/libs/*.js', 'spec/javascripts/libs/*.js', 'js/*[^(min)].js'],
      options : {
        specs   : 'spec/javascripts/**/*.js',
        helpers : 'spec/javascripts/helpers/**/*.js'
      }
    },
    watch : {
      files: [
        'js/*.coffee',
        'spec/coffeescripts/**/*.coffee'
      ],
      tasks: ['coffee', 'growl:coffee', 'jasmine', 'growl:jasmine']
    },
    growl : {
      coffee : {
        title   : 'CoffeeScript',
        message : 'Compiled successfully'
      },
      jasmine : {
        title   : 'Jasmine',
        message : 'Tests passed successfully'
      }
    }
  });

  // Lib tasks.
  grunt.loadNpmTasks('grunt-growl');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default and Build tasks
  mainTasks = ['coffee', 'growl:coffee', 'jasmine', 'growl:jasmine']
  grunt.registerTask('default', mainTasks);
  grunt.registerTask('build', mainTasks.concat(['uglify']));

  // Travis CI task.
  grunt.registerTask('travis', ['coffee', 'jasmine']);
};
<commit_msg>Fixes bug when plugin name file ended in m, i, or n.<commit_after>/*global module:false*/
module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      plugin: {
        files: [{
          expand: true,
          cwd: 'js/',
          src: '*.js',
          dest: 'js/',
          ext: '.min.js'
        }],
        options: {
          banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
            '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
            '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
            '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
            ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
        }
      }
    },
    coffee : {
      plugin : {
        files: [{
          expand: true,
          cwd: 'js/',
          src: '*.coffee',
          dest: 'js/',
          ext: '.js'
        }]
      },
      specs : {
        files: [{
          expand: true,
          cwd: 'spec/coffeescripts/',
          src: '*.coffee',
          dest: 'spec/javascripts/',
          ext: '.js'
        }]
      },
      helpers : {
        files: [{
          expand: true,
          cwd: 'spec/coffeescripts/helpers/',
          src: '*.coffee',
          dest: 'spec/javascripts/helpers/',
          ext: '.js'
        }]
      }
    },
    jasmine : {
      src     : ['js/libs/*.js', 'spec/javascripts/libs/*.js', 'js/*.js', '!js/*.min.js'],
      options : {
        specs   : 'spec/javascripts/**/*.js',
        helpers : 'spec/javascripts/helpers/**/*.js'
      }
    },
    watch : {
      files: [
        'js/*.coffee',
        'spec/coffeescripts/**/*.coffee'
      ],
      tasks: ['coffee', 'growl:coffee', 'jasmine', 'growl:jasmine']
    },
    growl : {
      coffee : {
        title   : 'CoffeeScript',
        message : 'Compiled successfully'
      },
      jasmine : {
        title   : 'Jasmine',
        message : 'Tests passed successfully'
      }
    }
  });

  // Lib tasks.
  grunt.loadNpmTasks('grunt-growl');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default and Build tasks
  mainTasks = ['coffee', 'growl:coffee', 'jasmine', 'growl:jasmine']
  grunt.registerTask('default', mainTasks);
  grunt.registerTask('build', mainTasks.concat(['uglify']));

  // Travis CI task.
  grunt.registerTask('travis', ['coffee', 'jasmine']);
};
<|endoftext|>


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

    grunt.loadNpmTasks('grunt-release');
    grunt.loadNpmTasks('grunt-tag');

    grunt.initConfig({
        release: {
            options: {
                npm: false,
                afterReleaseTasks: ['tag'],
                github: {
                    repo: "AirVantage/node-tech-ruuid",
                    usernameVar: 'GITHUB_USERNAME',
                    passwordVar: 'GITHUB_PASSWORD'
                }
            }
        },
        tag: {
            options: {
                tagName: '<%= version.match(/\\d*/) %>.x'
            }
        }
    });
};
<commit_msg>PLTFRS-5532 - Use access token for GitHub release<commit_after>module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-release');
    grunt.loadNpmTasks('grunt-tag');

    grunt.initConfig({
        release: {
            options: {
                npm: false,
                afterReleaseTasks: ['tag'],
                github: {
                    repo: "AirVantage/node-tech-ruuid",
                    accessTokenVar: "GITHUB_ACCESS_TOKEN"
                }
            }
        },
        tag: {
            options: {
                tagName: '<%= version.match(/\\d*/) %>.x'
            }
        }
    });
};
<|endoftext|>


<commit_before>/*jslint indent:2, node:true*/

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

  grunt.initConfig({

    jslint: {
      all: {
        src: [
          '**/*.js',
          '**/*.json',
          '!**/node_modules/**/*'
        ],
        options: {
          errorsOnly: true,
          failOnError: true
        }
      }
    },

    mochacli: {
      all: [
        'tests/**/test.js'
      ],
      options: {
        ui: 'tdd'
      }
    }

  });

  grunt.loadNpmTasks('grunt-jslint');
  grunt.loadNpmTasks('grunt-mocha-cli');

  grunt.registerTask('test', ['jslint', 'mochacli']);

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

};
<commit_msg>JSLint errors in test files no longer break the build<commit_after>/*jslint indent:2, node:true*/

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

  grunt.initConfig({

    jslint: {
      main: {
        src: [
          '**/*.js',
          '**/*.json',
          '!tests/**/*',
          '!**/node_modules/**/*'
        ],
        options: {
          errorsOnly: true,
          failOnError: true
        }
      },
      tests: {
        src: [
          'tests/**/*.js'
        ],
        options: {
          errorsOnly: true,
          failOnError: false
        }
      }
    },

    mochacli: {
      all: [
        'tests/**/test.js'
      ],
      options: {
        ui: 'tdd'
      }
    }

  });

  grunt.loadNpmTasks('grunt-jslint');
  grunt.loadNpmTasks('grunt-mocha-cli');

  grunt.registerTask('test', ['jslint', 'mochacli']);

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

};
<|endoftext|>


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

	// load all grunt tasks
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-istanbul-coverage');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-karma-coveralls');
	grunt.loadNpmTasks('grunt-conventional-changelog');

	// Default task.
	grunt.registerTask('default', ['uglify', 'test']);
	grunt.registerTask('test', ['clean', 'jshint', 'karma', 'coverage']);
	grunt.registerTask('travis-test', ['jshint', 'karma', 'coverage', 'coveralls']);

	var testConfig = function (configFile, customOptions) {
		var options = { configFile: configFile, keepalive: true };
		var travisOptions = process.env.TRAVIS && { browsers: ['PhantomJS'], reporters: ['dots','coverage'] };
		return grunt.util._.extend(options, customOptions, travisOptions);
	};

	// Project configuration.
	grunt.initConfig({
		changelog: {options: {dest: 'changelog.md'}},
		clean: ["coverage"],
		coverage: {
		  options: {
		  	thresholds: {
			  'statements': 100,
			  'branches': 100,
			  'lines': 100,
			  'functions': 100
			},
			dir: 'coverage'
		  }
		},
		coveralls: {
			options: {
				debug: true,
				coverage_dir: 'coverage',
				force: true
			}
		},
		karma: {
		  jquery: {
			options: testConfig('karma-jquery.conf.js')
		  },
		  jqlite: {
			options: testConfig('karma-jqlite.conf.js')
		  }
		},
		jshint: {
		  files: ['src/textAngular.js', 'src/textAngularSetup.js', 'test/*.spec.js', 'test/taBind/*.spec.js'],// don't hint the textAngularSanitize as they will fail
		  options: {
			eqeqeq: true,
			immed: true,
			latedef: true,
			newcap: true,
			noarg: true,
			sub: true,
			boss: true,
			eqnull: true,
			globals: {}
		  }
		},
		uglify: {
			options: {
				mangle: true,
				compress: true,
				wrap: true
			},
			my_target: {
				files: {
					'dist/textAngular-rangy.min.js': ['bower_components/rangy/rangy-core.js', 'bower_components/rangy/rangy-selectionsaverestore.js'],
					'dist/textAngular.min.js': ['src/textAngularSetup.js','src/textAngular.js'],
					'dist/textAngular-sanitize.min.js': ['src/textAngular-sanitize.js']
				}
			}
		}
	});
};<commit_msg>fix(compile): Keep copyright notices in minified files<commit_after>module.exports = function (grunt) {

	// load all grunt tasks
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-istanbul-coverage');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-karma-coveralls');
	grunt.loadNpmTasks('grunt-conventional-changelog');

	// Default task.
	grunt.registerTask('default', ['uglify', 'test']);
	grunt.registerTask('test', ['clean', 'jshint', 'karma', 'coverage']);
	grunt.registerTask('travis-test', ['jshint', 'karma', 'coverage', 'coveralls']);

	var testConfig = function (configFile, customOptions) {
		var options = { configFile: configFile, keepalive: true };
		var travisOptions = process.env.TRAVIS && { browsers: ['PhantomJS'], reporters: ['dots','coverage'] };
		return grunt.util._.extend(options, customOptions, travisOptions);
	};

	// Project configuration.
	grunt.initConfig({
		changelog: {options: {dest: 'changelog.md'}},
		clean: ["coverage"],
		coverage: {
		  options: {
		  	thresholds: {
			  'statements': 100,
			  'branches': 100,
			  'lines': 100,
			  'functions': 100
			},
			dir: 'coverage'
		  }
		},
		coveralls: {
			options: {
				debug: true,
				coverage_dir: 'coverage',
				force: true
			}
		},
		karma: {
		  jquery: {
			options: testConfig('karma-jquery.conf.js')
		  },
		  jqlite: {
			options: testConfig('karma-jqlite.conf.js')
		  }
		},
		jshint: {
		  files: ['src/textAngular.js', 'src/textAngularSetup.js', 'test/*.spec.js', 'test/taBind/*.spec.js'],// don't hint the textAngularSanitize as they will fail
		  options: {
			eqeqeq: true,
			immed: true,
			latedef: true,
			newcap: true,
			noarg: true,
			sub: true,
			boss: true,
			eqnull: true,
			globals: {}
		  }
		},
		uglify: {
			options: {
				mangle: true,
				compress: true,
				wrap: true,
				preserveComments: 'some'
			},
			my_target: {
				files: {
					'dist/textAngular-rangy.min.js': ['bower_components/rangy/rangy-core.js', 'bower_components/rangy/rangy-selectionsaverestore.js'],
					'dist/textAngular.min.js': ['src/textAngularSetup.js','src/textAngular.js'],
					'dist/textAngular-sanitize.min.js': ['src/textAngular-sanitize.js']
				}
			}
		}
	});
};<|endoftext|>


<commit_before>/* global module */

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

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

        meta: {
            componentsJsFiles: [
                'src/**/*.js'
            ],
            testJsFiles: [
                'tests/**/*Spec.js'
            ],
            visualTestFiles: [
                'visual-tests/src/**/*'
            ],
            visualTestJsFiles: [
                'visual-tests/src/**/*.js'
            ],
            componentsCssFiles: [
                'src/**/*.css'
            ],
            ourJsFiles: [
                '<%= meta.componentsJsFiles %>',
                '<%= meta.testJsFiles %>',
                '<%= meta.visualTestJsFiles %>'
            ]
        },

        assemble: {
            options: {
                assets: 'visual-tests/dist/assets',
                partials: 'visual-tests/src/site/templates/includes/*.hbs',
                layoutdir: 'visual-tests/src/site/templates/layouts'
            },
            visualTests: {
                files : [
                    // Index page
                    {
                        expand: true,
                        cwd: 'visual-tests/src/site/pages/',
                        src: ['index.hbs'],
                        dest: 'visual-tests/dist/'
                    },
                    // Visual tests
                    {
                        expand: true,
                        cwd: 'visual-tests/src/test-fixtures/',
                        src: ['**/*.hbs'],
                        dest: 'visual-tests/dist/'
                    }
                ],
                options: {
                    layout: 'test.hbs'
                }
            }
        },

        concat: {
            options: {
                sourceMap: false
            },
            dist: {
                src: ['src/fc.js', 'src/utilities/*.js', '<%= meta.componentsJsFiles %>'],
                dest: 'dist/<%= pkg.name %>.js'
            },
            visualTests: {
                options: {
                    sourceMap: true
                },
                src: 'visual-tests/src/site/assets/js/**/*.js',
                dest: 'visual-tests/dist/assets/index.js',
            }
        },

        connect: {
            options: {
                base: 'visual-tests/dist',
                useAvailablePort: true
            },
            dev: { },
            keepalive: {
                options: {
                    keepalive: true
                }
            }
        },

        copy: {
            visualTests: {
                files: [
                    {
                        expand: true,
                        cwd: 'visual-tests/src/site/assets/css',
                        src: ['**/*.css'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/d3/',
                        src: ['d3.js'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/css-layout/src/',
                        src: ['Layout.js'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'dist',
                        src: ['d3-financial-components.js', 'd3-financial-components.css'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/bootstrap/dist/',
                        src: ['**'],
                        dest: 'visual-tests/dist/assets/bootstrap/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/jquery/dist/',
                        src: ['jquery.min.*'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'visual-tests/src/test-fixtures/',
                        src: ['**/*', '!**/*.hbs'],
                        dest: 'visual-tests/dist/',
                    }
                ]
            }
        },

        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
                sourceMap: true
            },
            dist: {
                files: {
                    'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
                }
            }
        },

        concat_css: {
            options: {},
            all: {
                src: ['<%= meta.componentsCssFiles %>'],
                dest: 'dist/<%= pkg.name %>.css'
            }
        },

        cssmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['<%= pkg.name %>.css'],
                    dest: 'dist/',
                    ext: '.min.css'
                }]
            }
        },

        watch: {
            components: {
                files: [
                    '<%= meta.componentsJsFiles %>',
                    '<%= meta.testJsFiles %>',
                    '<%= meta.componentsCssFiles %>'
                ],
                tasks: ['build']
            },
            visualTests: {
                files: [
                    '<%= meta.visualTestFiles %>'
                ],
                tasks: ['build:visual-tests']
            },
            options: {
                livereload: true
            }
        },

        jscs: {
            options: {
                config: '.jscsrc'
            },
            failOnError: {
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            },
            warnOnly: {
                options: {
                    force: true
                },
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            }
        },

        jshint: {
            options: {
                jshintrc: true
            },
            failOnError: {
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            },
            warnOnly: {
                options: {
                    force: true
                },
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            }
        },

        jsdoc : {
            dist : {
                src: ['<%= meta.componentsJsFiles %>'],
                options: {
                    destination: 'doc'
                }
            }
        },

        jasmine: {
            options: {
                specs: '<%= meta.testJsFiles %>',
                vendor: [
                    'node_modules/d3/d3.js',
                    'node_modules/css-layout/src/Layout.js'
                ]
            },
            test: {
                src: ['dist/*.js'],
            },
            testDebug: {
                src: ['dist/*.js'],
                options: {
                    keepRunner: true
                }
            }
        },

        clean: {
            dist: ['dist/*', '!dist/README.md'],
            doc: ['doc'],
            visualTests: ['visual-tests/dist']
        },

        release: {
            options: {
                beforeRelease: ['default'],
                remote: 'upstream',
                github: {
                    repo: 'ScottLogic/d3-financial-components',
                    usernameVar: 'GITHUB_USERNAME',
                    passwordVar: 'GITHUB_PASSWORD'
                }
            }
        }
    });

    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.loadNpmTasks('assemble');

    grunt.registerTask('check:failOnError', ['jshint:failOnError', 'jscs:failOnError']);
    grunt.registerTask('check:warnOnly', ['jshint:warnOnly', 'jscs:warnOnly']);
    grunt.registerTask('check', ['check:failOnError']);
    grunt.registerTask('build:visual-tests', ['check', 'clean:visualTests', 'copy:visualTests', 'concat:visualTests', 'assemble:visualTests']);
    grunt.registerTask('build:components', ['check', 'clean:dist', 'concat:dist', 'uglify:dist', 'concat_css:all', 'cssmin:dist', 'jasmine:test']);
    grunt.registerTask('build', ['build:components', 'build:visual-tests']);
    grunt.registerTask('dev:serve', ['build', 'connect:dev', 'watch']);
    grunt.registerTask('dev', ['build', 'watch']);
    grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
    grunt.registerTask('ci', ['default']);
    grunt.registerTask('test', ['jasmine:test', 'build:visual-tests']);
    grunt.registerTask('serve', ['connect:keepalive']);
    grunt.registerTask('default', ['build', 'doc']);
};
<commit_msg>Work around geddski/grunt-release#118<commit_after>/* global module */

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

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

        meta: {
            componentsJsFiles: [
                'src/**/*.js'
            ],
            testJsFiles: [
                'tests/**/*Spec.js'
            ],
            visualTestFiles: [
                'visual-tests/src/**/*'
            ],
            visualTestJsFiles: [
                'visual-tests/src/**/*.js'
            ],
            componentsCssFiles: [
                'src/**/*.css'
            ],
            ourJsFiles: [
                '<%= meta.componentsJsFiles %>',
                '<%= meta.testJsFiles %>',
                '<%= meta.visualTestJsFiles %>'
            ]
        },

        assemble: {
            options: {
                assets: 'visual-tests/dist/assets',
                partials: 'visual-tests/src/site/templates/includes/*.hbs',
                layoutdir: 'visual-tests/src/site/templates/layouts'
            },
            visualTests: {
                files : [
                    // Index page
                    {
                        expand: true,
                        cwd: 'visual-tests/src/site/pages/',
                        src: ['index.hbs'],
                        dest: 'visual-tests/dist/'
                    },
                    // Visual tests
                    {
                        expand: true,
                        cwd: 'visual-tests/src/test-fixtures/',
                        src: ['**/*.hbs'],
                        dest: 'visual-tests/dist/'
                    }
                ],
                options: {
                    layout: 'test.hbs'
                }
            }
        },

        concat: {
            options: {
                sourceMap: false
            },
            dist: {
                src: ['src/fc.js', 'src/utilities/*.js', '<%= meta.componentsJsFiles %>'],
                dest: 'dist/<%= pkg.name %>.js'
            },
            visualTests: {
                options: {
                    sourceMap: true
                },
                src: 'visual-tests/src/site/assets/js/**/*.js',
                dest: 'visual-tests/dist/assets/index.js',
            }
        },

        connect: {
            options: {
                base: 'visual-tests/dist',
                useAvailablePort: true
            },
            dev: { },
            keepalive: {
                options: {
                    keepalive: true
                }
            }
        },

        copy: {
            visualTests: {
                files: [
                    {
                        expand: true,
                        cwd: 'visual-tests/src/site/assets/css',
                        src: ['**/*.css'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/d3/',
                        src: ['d3.js'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/css-layout/src/',
                        src: ['Layout.js'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'dist',
                        src: ['d3-financial-components.js', 'd3-financial-components.css'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/bootstrap/dist/',
                        src: ['**'],
                        dest: 'visual-tests/dist/assets/bootstrap/',
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/jquery/dist/',
                        src: ['jquery.min.*'],
                        dest: 'visual-tests/dist/assets/',
                    },
                    {
                        expand: true,
                        cwd: 'visual-tests/src/test-fixtures/',
                        src: ['**/*', '!**/*.hbs'],
                        dest: 'visual-tests/dist/',
                    }
                ]
            }
        },

        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
                sourceMap: true
            },
            dist: {
                files: {
                    'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
                }
            }
        },

        concat_css: {
            options: {},
            all: {
                src: ['<%= meta.componentsCssFiles %>'],
                dest: 'dist/<%= pkg.name %>.css'
            }
        },

        cssmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['<%= pkg.name %>.css'],
                    dest: 'dist/',
                    ext: '.min.css'
                }]
            }
        },

        watch: {
            components: {
                files: [
                    '<%= meta.componentsJsFiles %>',
                    '<%= meta.testJsFiles %>',
                    '<%= meta.componentsCssFiles %>'
                ],
                tasks: ['build']
            },
            visualTests: {
                files: [
                    '<%= meta.visualTestFiles %>'
                ],
                tasks: ['build:visual-tests']
            },
            options: {
                livereload: true
            }
        },

        jscs: {
            options: {
                config: '.jscsrc'
            },
            failOnError: {
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            },
            warnOnly: {
                options: {
                    force: true
                },
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            }
        },

        jshint: {
            options: {
                jshintrc: true
            },
            failOnError: {
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            },
            warnOnly: {
                options: {
                    force: true
                },
                files: {
                    src: ['<%= meta.ourJsFiles %>']
                }
            }
        },

        jsdoc : {
            dist : {
                src: ['<%= meta.componentsJsFiles %>'],
                options: {
                    destination: 'doc'
                }
            }
        },

        jasmine: {
            options: {
                specs: '<%= meta.testJsFiles %>',
                vendor: [
                    'node_modules/d3/d3.js',
                    'node_modules/css-layout/src/Layout.js'
                ]
            },
            test: {
                src: ['dist/*.js'],
            },
            testDebug: {
                src: ['dist/*.js'],
                options: {
                    keepRunner: true
                }
            }
        },

        clean: {
            dist: ['dist/*', '!dist/README.md'],
            doc: ['doc'],
            visualTests: ['visual-tests/dist']
        },

        _release: {
            options: {
                remote: 'upstream',
                github: {
                    repo: 'ScottLogic/d3-financial-components',
                    usernameVar: 'GITHUB_USERNAME',
                    passwordVar: 'GITHUB_PASSWORD'
                }
            }
        }
    });

    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.loadNpmTasks('assemble');

    grunt.renameTask('release', '_release');

    grunt.registerTask('check:failOnError', ['jshint:failOnError', 'jscs:failOnError']);
    grunt.registerTask('check:warnOnly', ['jshint:warnOnly', 'jscs:warnOnly']);
    grunt.registerTask('check', ['check:failOnError']);
    grunt.registerTask('build:visual-tests', ['check', 'clean:visualTests', 'copy:visualTests', 'concat:visualTests', 'assemble:visualTests']);
    grunt.registerTask('build:components', ['check', 'clean:dist', 'concat:dist', 'uglify:dist', 'concat_css:all', 'cssmin:dist', 'jasmine:test']);
    grunt.registerTask('build', ['build:components', 'build:visual-tests']);
    grunt.registerTask('dev:serve', ['build', 'connect:dev', 'watch']);
    grunt.registerTask('dev', ['build', 'watch']);
    grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
    grunt.registerTask('ci', ['default']);
    grunt.registerTask('test', ['jasmine:test', 'build:visual-tests']);
    grunt.registerTask('serve', ['connect:keepalive']);
    grunt.registerTask('default', ['build', 'doc']);
    grunt.registerTask('release', ['default', '_release']);
};
<|endoftext|>


<commit_before>'use strict';

var path, paths;

path = require('path');

// ## Directory and File Path Configurations

paths = {

  server: {
    tld: __dirname,
    files: {
      scripts: [
        '<%= paths.server.tld %>/**/*.js',
        '!<%= paths.server.tld %>/node_modules/**/*.js'
      ]
    }
  },

  heroku: {
    tld: path.normalize(__dirname + '../../_heroku'),
    dirs: {
      server: '<%= paths.heroku.tld %>/server'
    }
  }
};

module.exports = function (grunt) {

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

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

  // ## Define the configuration for all the tasks

  grunt.initConfig({

    paths: paths,

    watch: {
      express: {
        files: [
          'server.js',
          'middleware/**/*.js',
          'routes/**/*.js',
          'utils/**/*.js'
        ],
        tasks:  ['express:dev']
      },
      options: {
        //Without this option the specified express won't be reloaded
        nospawn: true
      }
    },

    express: {
      // jshint camelcase:false
      options: {
        script: '<%= paths.server.tld %>/server.js',
        port: 3000
      },
      dev: {
        options: {
          node_env: 'development',
          debug: true
        }
      },
      dist: {
        options: {
          node_env: 'production'
        }
      }
    },

    copy: {

      // Copy files from server -> heroku/server
      heroku: {
        files: [{
          expand: true,
          cwd: '<%= paths.server.tld %>',
          src: [
            'config/*.js',
            'utils/*.js',
            'middleware/*.js',
            'server.js'
          ],
          dest: '<%= paths.heroku.dirs.server %>'
        }]
      },
    },

    // Automatically g browser
    open: {
      all: {
        path: 'http://127.0.0.1:<%= express.options.port %>'
      }
    },

    // Check javascript for errors
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        '<%= paths.server.files.scripts %>'
      ]
    },

    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    }
  });

  // ## Register all Grunt Tasks

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run([
        'build',
        'express:dist',
        'open'
      ]);
    }

    grunt.task.run([
      'newer:jshint:all',
      'build',
      'express:dev',
      'open',
      'watch'
    ]);
  });

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

  grunt.registerTask('heroku', [
    'newer:jshint:all',
    'build',
    'copy:heroku'
  ]);
};
<commit_msg>refactoring grunt tasks<commit_after>'use strict';

module.exports = function (grunt) {

  // Look for grunt config files in the 'grunt' directory
  // Uses load-grunt-tasks to load tasks
  require('load-grunt-config')(grunt);

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

  // ## Register all Grunt Tasks
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run([
        'build',
        'express:dist',
      ]);
    }

    grunt.task.run([
      'newer:jshint:all',
      'build',
      'express:dev',
      'watch'
    ]);
  });

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

  grunt.registerTask('heroku', [
    'newer:jshint:all',
    'build',
    'copy:heroku'
  ]);

  grunt.registerTask('azure', [
    'newer:jshint:all',
    'build',
    'copy:azure'
  ]);
};
<|endoftext|>


<commit_before>/**
 * Created by novacrazy on 8/9/14.
 */

module.exports = function(grunt) {

    grunt.loadNpmTasks( 'grunt-ts' );
    grunt.loadNpmTasks( 'grunt-contrib-clean' );

    grunt.initConfig( {
        ts:    {
            options: {
                target:         'es5',
                module:         'commonjs',
                sourceMap:      false,
                declaration:    false,
                removeComments: false
            },
            build:   {
                src:       ['!./src/reference.ts', './src/**/*.ts'],
                outDir:    './',
                reference: './src/reference.ts'
            }
        },
        clean: {
            build:   {
                src: ['./lib/**/*.js', './test']
            },
            post:    {
                src: ['./**/.baseDir.js', './reference.js']
            },
            release: {
                src: ['./.tscache', './**/.baseDir.ts', './src/.baseDir.ts']
            }
        }
    } );

    grunt.registerTask( 'build', ['clean:build', 'ts:build', 'clean:post'] );

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

    grunt.registerTask( 'default', ['build'] );
};
<commit_msg>Gruntfile: Made the clean stage better<commit_after>/**
 * Created by novacrazy on 8/9/14.
 */

module.exports = function(grunt) {

    grunt.loadNpmTasks( 'grunt-ts' );
    grunt.loadNpmTasks( 'grunt-contrib-clean' );

    grunt.initConfig( {
        ts:    {
            options: {
                target:         'es5',
                module:         'commonjs',
                sourceMap:      false,
                declaration:    false,
                removeComments: false
            },
            build:   {
                src:       ['!./src/reference.ts', './src/**/*.ts'],
                outDir:    './',
                reference: './src/reference.ts'
            }
        },
        clean: {
            build:   {
                src: ['./lib/**/*.js', './test']
            },
            post:    {
                src: ['./**/.baseDir.*', './reference.js']
            },
            release: {
                src: ['./.tscache']
            }
        }
    } );

    grunt.registerTask( 'build', ['clean:build', 'ts:build', 'clean:post'] );

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

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