<commit_before>'use strict';

var sass = require('node-sass');
var pngquant = require('imagemin-pngquant');
var mozjpeg = require('imagemin-mozjpeg');
var optipng = require('imagemin-optipng');
var svgo = require('imagemin-svgo');

module.exports = function (grunt) {

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

  require('dotenv').config();

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    s3: 'grunt-aws',
    cloudfront: 'grunt-aws',
    replace: 'grunt-text-replace'
  });

  // configurable paths
  var config = {
    app: 'app',
    assets: 'assets',
    dist: 'dist'
  };

  grunt.initConfig({

    // Project settings
    config: config,
    package: grunt.file.readJSON('package.json'),

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      assemble: {
        files: [
          '<%= config.app %>/data/{,*/}*.{yml,json}',
          '<%= config.app %>/{layouts,pages,partials}/{,**/}*.{hbs,md}'
        ],
        tasks: ['assemble']
      },
      js: {
        files: [
          '<%= config.app %>/scripts/{,*/}*.js'
        ],
        tasks: [
          'browserify',
          'eslint'
        ]
      },
      sass: {
        files: ['<%= config.app %>/styles/{,*/}*.scss'],
        tasks: [
          'sass:server',
          'postcss:server'
        ]
      },
      webfont: {
        files: [
          '<%= config.app %>/media/icons/*.svg'
        ],
        tasks: ['webfont']
      },
      favicon: {
        files: [
          '<%= config.assets %>/icon.svg'
        ],
        tasks: ['realFavicon']
      }
    },

    browserSync: {
      options: {
        port: 0,
        notify: false,
        background: true,
        timestamps: false
      },
      livereload: {
        options: {
          files: [
            '.tmp/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '.tmp/scripts/main.js',
            '<%= config.app %>/media/{,**/}*',
            '!<%= config.app %>/media/icons/*'
          ],
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/node_modules': './node_modules',
              '/app/styles': './app/styles'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>',
          snippetOptions: {
            rule: {
              // disable auto-injection
              match: /^$/
            }
          }
        }
      }
    },

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

    // Generate pages
    assemble: {
      options: {
        root: '.tmp',
        layout: 'default',
        layoutext: '.hbs',
        layoutdir: '<%= config.app %>/layouts',
        assets: '<%= config.app %>',
        data: '<%= config.app %>/data/*.{json,yml}',
        partials: '<%= config.app %>/partials/{,*/}*.hbs',
        helpers: ['<%= config.app %>/helpers/*.js'],
        plugins: [
          'grunt-assemble-contextual'
        ],
        contextual: {
          dest: '.tmp'
        },
        marked: {
          breaks: true
        }
      },
      pages: {
        options: {
          plugins: [
            'grunt-assemble-permalinks',
            'grunt-assemble-sitemap'
          ],
          sitemap: {
            relativedest: '.tmp',
            robot: false
          },
          permalinks: {
            preset: 'pretty'
          }
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            '{,**/}*.{hbs,md}',
            '!error.hbs'
          ]
        }]
      },
      special: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            'error.hbs'
          ]
        }]
      }
    },

    // Compile Sass
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: [
          '<%= config.app %>',
          'node_modules'
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: ['styles/{,*/}*.scss'],
          dest: '.tmp',
          ext: '.css'
        }]
      }
    },

    // Converts ES6 to ES5 for browser compatibility
    browserify: {
      options: {
        transform: [
          ['babelify', {
            'presets': ['@babel/preset-env']
          }]
        ]
      },
      server: {
        src: '<%= config.app %>/scripts/main.js',
        dest: '.tmp/scripts/main.js',
      }
    },

    // Process CSS
    postcss: {
      options: {
        map: {
          inline: false
        },
        processors: [
          require('postcss-flexbugs-fixes'),
          require('autoprefixer')
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      },
      dist: {
        options: {
          processors: [
            require('postcss-flexbugs-fixes'),
            require('autoprefixer'),
            require('postcss-uncss')({
              htmlroot: '.tmp',
              html: [
                '.tmp/{,*/}*.html'
              ],
              ignore: [
                '.arrow',
                '.show',
                '.hide',
                '.fade',
                /\.(bs-)?popover/,
                /\.(bs-)?tooltip/
              ]
            })
          ]
        },
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      }
    },

    // Generate custom icon font
    webfont: {
      icons: {
        src: '<%= config.app %>/media/icons/*.svg',
        dest: '.tmp/media/fonts',
        destCss: '.tmp/',
        options: {
          engine: 'node',
          hashes: false,
          stylesheet: 'css',
          types: 'woff2,woff',
          relativeFontPath: '/media/fonts',
          templateOptions: {
            classPrefix: 'icon-',
          }
        }
      }
    },

    // Generate favicons
    realFavicon: {
      favicons: {
        src: '<%= config.assets %>/icon.svg',
        dest: '<%= config.app %>/media/',
        options: {
          iconsPath: '/media/',
          // html: [ 'TODO: List of the HTML files where to inject favicon markups' ],
          design: {
            ios: {
              pictureAspect: 'backgroundAndMargin',
              backgroundColor: '#ffffff',
              margin: '14%',
              assets: {
                ios6AndPriorIcons: false,
                ios7AndLaterIcons: false,
                precomposedIcons: false,
                declareOnlyDefaultIcon: true
              }
            },
            desktopBrowser: {},
            windows: {
              pictureAspect: 'whiteSilhouette',
              backgroundColor: '#2d89ef',
              onConflict: 'override',
              assets: {
                windows80Ie10Tile: false,
                windows10Ie11EdgeTiles: {
                  small: false,
                  medium: true,
                  big: false,
                  rectangle: false
                }
              }
            },
            androidChrome: {
              pictureAspect: 'noChange',
              themeColor: '#ffffff',
              manifest: {
                name: '<%= package.name %>',
                display: 'standalone',
                orientation: 'notSet',
                onConflict: 'override',
                declared: true
              },
              assets: {
                legacyIcon: false,
                lowResolutionIcons: false
              }
            },
            safariPinnedTab: {
              pictureAspect: 'silhouette',
              themeColor: '#5bbad5'
            }
          },
          settings: {
            scalingAlgorithm: 'Mitchell',
            errorOnImageTooSmall: false,
            readmeFile: false,
            htmlCodeFile: false,
            usePathAsIs: false
          }
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: '.tmp/index.html'
    },

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      options: {
        use: [
          mozjpeg({
            quality: 80
          }),
          optipng(),
          pngquant(),
          svgo({
            plugins: [{
              removeViewBox: false
            }]
          })
        ]
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.{png,jpg,jpeg,svg}',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          removeRedundantAttributes: false,
          useShortDoctype: true,
          processScripts: ['application/ld+json']
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,**/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // Put files not handled in other tasks here
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '.htaccess',
            '*.txt',
            'media/{,**/}*.{webp,gif,ico,xml,webmanifest}',
            'media/fonts/*'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          flatten: true,
          src: [
            'media/favicon.ico'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            'media/fonts/*',
            'robots.txt',
            'sitemap.xml'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            '{,**/}*.html',
            '!icons.html'
          ]
        }]
      }
    },

    // Inline Critical CSS
    critical: {
      options: {
        base: '<%= config.dist %>',
        minify: true,
        width: 1440,
        height: 900
      },
      home: {
        src: '<%= config.dist %>/index.html',
        dest: '<%= config.dist %>/index.html'
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        configFile: '.eslintrc.json'
      },
      target: [
        '<%= config.app %>/scripts/{,*/}*.js'
      ]
    },

    // Pick an unused port for livereload
    portPick: {
      browserSync: {
        options: {
          port: 9000
        },
        targets: ['browserSync.options.port']
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}',
          '!<%= config.dist %>/media/{android,apple,favicon,mstile,safari}*.*'
        ]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      server: [
        'webfont',
        'sass',
        'browserify'
      ],
      dist: [
        'webfont',
        'sass',
        'browserify',
        'imagemin'
      ]
    },

    // Deploy to AWS S3
    s3: {
      options: {
        signatureVersion: 'v4',
        bucket: '<%= process.env.S3_BUCKET %>',
        gzip: false,
        headers: {
          CacheControl: 'public, no-cache, no-transform, s-maxage=31536000'
        }
      },
      // Define file location for all environments
      default: {
        src: [
          '{,**/}*.html',
          '{,*/}favicon.ico',
          'robots.txt',
          'sitemap.xml',
          'media/{android,apple,favicon,mstile,safari,}*.*',
          'media/*.{xml,webmanifest}'
        ]
      },
      defaultAssets: {
        src: [
          'scripts/{,*/}*.js',
          'styles/{,*/}*.css',
          'media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}',
          '!media/{android,apple,favicon,mstile,safari}*.*',
          '!media/*.{xml,webmanifest}'
        ]
      },
      dist: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=60, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.default.src %>'
      },
      distAssets: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=31536000, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.defaultAssets.src %>'
      }
    },

    // Invalidate Cloudfront
    cloudfront: {
      options: {
        distributionId: '<%= process.env.CLOUDFRONT_ID %>'
      },
      production: {
        options: {
          invalidations: [
            '/*'
          ]
        }
      }
    },

    // Increment version number, create and push tag
    bump: {
      options: {
        files: ['package.json'],
        commitFiles: '<%= bump.options.files %>',
        pushTo: 'origin'
      }
    },

    // Text replacements
    replace: {
      openGraphTag: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<meta property="og:(image|url)" content="?([^"]+)"?/g,
          to: '<meta property="og:$1" content="<%= package.homepage %>$2"'
        }]
      },
      relCanonical: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<link rel="canonical" href="?([^"]+)"?/g,
          to: '<link rel="canonical" href="<%= package.homepage %>$1"'
        }]
      },
      sitemap: {
        src: [
          '<%= config.dist %>/sitemap.xml',
        ],
        overwrite: true,
        replacements: [
          {
            from: 'index.html',
            to: ''
          }, {
            from: /\s+<changefreq>[a-z]+<\/changefreq>/g,
            to: ''
          }, {
            from: /\s+<priority>[0-9\.]+<\/priority>/g,
            to: ''
          }

        ]
      }
    },

  });

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

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

  grunt.registerTask('purge', [
    'cloudfront'
  ]);

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

  grunt.registerTask('build', [
    'clean:dist',
    'assemble',
    'useminPrepare',
    'concurrent:dist',
    'postcss:dist',
    'concat',
    'cssmin',
    'uglify',
    'copy:dist',
    'filerev',
    'usemin',
    'replace',
    'htmlmin',
    'critical'
  ]);

  grunt.registerTask('deploy', [
    'build',
    's3:dist',
    's3:distAssets',
    'purge'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);
};
<commit_msg>Adding critical css to all html pages<commit_after>'use strict';

var sass = require('node-sass');
var pngquant = require('imagemin-pngquant');
var mozjpeg = require('imagemin-mozjpeg');
var optipng = require('imagemin-optipng');
var svgo = require('imagemin-svgo');

module.exports = function (grunt) {

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

  require('dotenv').config();

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    s3: 'grunt-aws',
    cloudfront: 'grunt-aws',
    replace: 'grunt-text-replace'
  });

  // configurable paths
  var config = {
    app: 'app',
    assets: 'assets',
    dist: 'dist'
  };

  grunt.initConfig({

    // Project settings
    config: config,
    package: grunt.file.readJSON('package.json'),

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      assemble: {
        files: [
          '<%= config.app %>/data/{,*/}*.{yml,json}',
          '<%= config.app %>/{layouts,pages,partials}/{,**/}*.{hbs,md}'
        ],
        tasks: ['assemble']
      },
      js: {
        files: [
          '<%= config.app %>/scripts/{,*/}*.js'
        ],
        tasks: [
          'browserify',
          'eslint'
        ]
      },
      sass: {
        files: ['<%= config.app %>/styles/{,*/}*.scss'],
        tasks: [
          'sass:server',
          'postcss:server'
        ]
      },
      webfont: {
        files: [
          '<%= config.app %>/media/icons/*.svg'
        ],
        tasks: ['webfont']
      },
      favicon: {
        files: [
          '<%= config.assets %>/icon.svg'
        ],
        tasks: ['realFavicon']
      }
    },

    browserSync: {
      options: {
        port: 0,
        notify: false,
        background: true,
        timestamps: false
      },
      livereload: {
        options: {
          files: [
            '.tmp/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '.tmp/scripts/main.js',
            '<%= config.app %>/media/{,**/}*',
            '!<%= config.app %>/media/icons/*'
          ],
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/node_modules': './node_modules',
              '/app/styles': './app/styles'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>',
          snippetOptions: {
            rule: {
              // disable auto-injection
              match: /^$/
            }
          }
        }
      }
    },

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

    // Generate pages
    assemble: {
      options: {
        root: '.tmp',
        layout: 'default',
        layoutext: '.hbs',
        layoutdir: '<%= config.app %>/layouts',
        assets: '<%= config.app %>',
        data: '<%= config.app %>/data/*.{json,yml}',
        partials: '<%= config.app %>/partials/{,*/}*.hbs',
        helpers: ['<%= config.app %>/helpers/*.js'],
        plugins: [
          'grunt-assemble-contextual'
        ],
        contextual: {
          dest: '.tmp'
        },
        marked: {
          breaks: true
        }
      },
      pages: {
        options: {
          plugins: [
            'grunt-assemble-permalinks',
            'grunt-assemble-sitemap'
          ],
          sitemap: {
            relativedest: '.tmp',
            robot: false
          },
          permalinks: {
            preset: 'pretty'
          }
        },
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            '{,**/}*.{hbs,md}',
            '!error.hbs'
          ]
        }]
      },
      special: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/pages',
          dest: '.tmp',
          src: [
            'error.hbs'
          ]
        }]
      }
    },

    // Compile Sass
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
        includePaths: [
          '<%= config.app %>',
          'node_modules'
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>',
          src: ['styles/{,*/}*.scss'],
          dest: '.tmp',
          ext: '.css'
        }]
      }
    },

    // Converts ES6 to ES5 for browser compatibility
    browserify: {
      options: {
        transform: [
          ['babelify', {
            'presets': ['@babel/preset-env']
          }]
        ]
      },
      server: {
        src: '<%= config.app %>/scripts/main.js',
        dest: '.tmp/scripts/main.js',
      }
    },

    // Process CSS
    postcss: {
      options: {
        map: {
          inline: false
        },
        processors: [
          require('postcss-flexbugs-fixes'),
          require('autoprefixer')
        ]
      },
      server: {
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      },
      dist: {
        options: {
          processors: [
            require('postcss-flexbugs-fixes'),
            require('autoprefixer'),
            require('postcss-uncss')({
              htmlroot: '.tmp',
              html: [
                '.tmp/{,*/}*.html'
              ],
              ignore: [
                '.arrow',
                '.show',
                '.hide',
                '.fade',
                /\.(bs-)?popover/,
                /\.(bs-)?tooltip/
              ]
            })
          ]
        },
        files: [{
          expand: true,
          cwd: '.tmp/',
          src: '{,*/}*.css',
          dest: '.tmp/'
        }]
      }
    },

    // Generate custom icon font
    webfont: {
      icons: {
        src: '<%= config.app %>/media/icons/*.svg',
        dest: '.tmp/media/fonts',
        destCss: '.tmp/',
        options: {
          engine: 'node',
          hashes: false,
          stylesheet: 'css',
          types: 'woff2,woff',
          relativeFontPath: '/media/fonts',
          templateOptions: {
            classPrefix: 'icon-',
          }
        }
      }
    },

    // Generate favicons
    realFavicon: {
      favicons: {
        src: '<%= config.assets %>/icon.svg',
        dest: '<%= config.app %>/media/',
        options: {
          iconsPath: '/media/',
          // html: [ 'TODO: List of the HTML files where to inject favicon markups' ],
          design: {
            ios: {
              pictureAspect: 'backgroundAndMargin',
              backgroundColor: '#ffffff',
              margin: '14%',
              assets: {
                ios6AndPriorIcons: false,
                ios7AndLaterIcons: false,
                precomposedIcons: false,
                declareOnlyDefaultIcon: true
              }
            },
            desktopBrowser: {},
            windows: {
              pictureAspect: 'whiteSilhouette',
              backgroundColor: '#2d89ef',
              onConflict: 'override',
              assets: {
                windows80Ie10Tile: false,
                windows10Ie11EdgeTiles: {
                  small: false,
                  medium: true,
                  big: false,
                  rectangle: false
                }
              }
            },
            androidChrome: {
              pictureAspect: 'noChange',
              themeColor: '#ffffff',
              manifest: {
                name: '<%= package.name %>',
                display: 'standalone',
                orientation: 'notSet',
                onConflict: 'override',
                declared: true
              },
              assets: {
                legacyIcon: false,
                lowResolutionIcons: false
              }
            },
            safariPinnedTab: {
              pictureAspect: 'silhouette',
              themeColor: '#5bbad5'
            }
          },
          settings: {
            scalingAlgorithm: 'Mitchell',
            errorOnImageTooSmall: false,
            readmeFile: false,
            htmlCodeFile: false,
            usePathAsIs: false
          }
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      options: {
        dest: '<%= config.dist %>'
      },
      html: '.tmp/index.html'
    },

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      options: {
        use: [
          mozjpeg({
            quality: 80
          }),
          optipng(),
          pngquant(),
          svgo({
            plugins: [{
              removeViewBox: false
            }]
          })
        ]
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/media',
          src: '{,**/}*.{png,jpg,jpeg,svg}',
          dest: '<%= config.dist %>/media'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          removeRedundantAttributes: false,
          useShortDoctype: true,
          processScripts: ['application/ld+json']
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,**/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

    // Put files not handled in other tasks here
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          src: [
            '.htaccess',
            '*.txt',
            'media/{,**/}*.{webp,gif,ico,xml,webmanifest}',
            'media/fonts/*'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '<%= config.app %>',
          dest: '<%= config.dist %>',
          flatten: true,
          src: [
            'media/favicon.ico'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            'media/fonts/*',
            'robots.txt',
            'sitemap.xml'
          ]
        },{
          expand: true,
          dot: true,
          cwd: '.tmp',
          dest: '<%= config.dist %>',
          src: [
            '{,**/}*.html',
            '!icons.html'
          ]
        }]
      }
    },

    // Inline Critical CSS
    critical: {
      options: {
        base: '<%= config.dist %>',
        minify: true,
        width: 1440,
        height: 900,
        ignore: [
          '@font-face',
          '@import'
        ]
      },
      pages: {
        expand: true,
        cwd: '<%= config.dist %>',
        src: '{,**/}*.html',
        dest: '<%= config.dist %>',
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        configFile: '.eslintrc.json'
      },
      target: [
        '<%= config.app %>/scripts/{,*/}*.js'
      ]
    },

    // Pick an unused port for livereload
    portPick: {
      browserSync: {
        options: {
          port: 9000
        },
        targets: ['browserSync.options.port']
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}',
          '!<%= config.dist %>/media/{android,apple,favicon,mstile,safari}*.*'
        ]
      }
    },

    // Run some tasks in parallel to speed up build process
    concurrent: {
      server: [
        'webfont',
        'sass',
        'browserify'
      ],
      dist: [
        'webfont',
        'sass',
        'browserify',
        'imagemin'
      ]
    },

    // Deploy to AWS S3
    s3: {
      options: {
        signatureVersion: 'v4',
        bucket: '<%= process.env.S3_BUCKET %>',
        gzip: false,
        headers: {
          CacheControl: 'public, no-cache, no-transform, s-maxage=31536000'
        }
      },
      // Define file location for all environments
      default: {
        src: [
          '{,**/}*.html',
          '{,*/}favicon.ico',
          'robots.txt',
          'sitemap.xml',
          'media/{android,apple,favicon,mstile,safari,}*.*',
          'media/*.{xml,webmanifest}'
        ]
      },
      defaultAssets: {
        src: [
          'scripts/{,*/}*.js',
          'styles/{,*/}*.css',
          'media/{,**/}*.{png,jpg,jpeg,gif,webp,svg,eot,ttf,woff,woff2}',
          '!media/{android,apple,favicon,mstile,safari}*.*',
          '!media/*.{xml,webmanifest}'
        ]
      },
      dist: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=60, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.default.src %>'
      },
      distAssets: {
        options: {
          headers: {
            CacheControl: 'public, must-revalidate, no-transform, max-age=31536000, s-maxage=31536000'
          }
        },
        cwd: '<%= config.dist %>',
        src: '<%= s3.defaultAssets.src %>'
      }
    },

    // Invalidate Cloudfront
    cloudfront: {
      options: {
        distributionId: '<%= process.env.CLOUDFRONT_ID %>'
      },
      production: {
        options: {
          invalidations: [
            '/*'
          ]
        }
      }
    },

    // Increment version number, create and push tag
    bump: {
      options: {
        files: ['package.json'],
        commitFiles: '<%= bump.options.files %>',
        pushTo: 'origin'
      }
    },

    // Text replacements
    replace: {
      openGraphTag: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<meta property="og:(image|url)" content="?([^"]+)"?/g,
          to: '<meta property="og:$1" content="<%= package.homepage %>$2"'
        }]
      },
      relCanonical: {
        src: [
          '<%= config.dist %>/{,**/}*.html',
        ],
        overwrite: true,
        replacements: [{
          from: /<link rel="canonical" href="?([^"]+)"?/g,
          to: '<link rel="canonical" href="<%= package.homepage %>$1"'
        }]
      },
      sitemap: {
        src: [
          '<%= config.dist %>/sitemap.xml',
        ],
        overwrite: true,
        replacements: [
          {
            from: 'index.html',
            to: ''
          }, {
            from: /\s+<changefreq>[a-z]+<\/changefreq>/g,
            to: ''
          }, {
            from: /\s+<priority>[0-9\.]+<\/priority>/g,
            to: ''
          }

        ]
      }
    },

  });

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

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

  grunt.registerTask('purge', [
    'cloudfront'
  ]);

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

  grunt.registerTask('build', [
    'clean:dist',
    'assemble',
    'useminPrepare',
    'concurrent:dist',
    'postcss:dist',
    'concat',
    'cssmin',
    'uglify',
    'copy:dist',
    'filerev',
    'usemin',
    'replace',
    'htmlmin',
    'critical'
  ]);

  grunt.registerTask('deploy', [
    'build',
    's3:dist',
    's3:distAssets',
    'purge'
  ]);

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


<commit_before>module.exports=function (callback) {
    var cheerio = require('cheerio');
    var http = require('http');

    var options = {
        host: "gaonnuri.ksain.net",
        path: "/xe/?mid=login"
    };

    // get html data from school website
    var data = "";
    var request = http.request(options, function (res) {
        res.setEncoding("utf8");
        res.on('data', function (chunk) {
            data += chunk;
            console.log("received chunk");
        });
        res.on('end', function () {
            parseSnack(data);
        });
    });

    var parseSnack =function (html) {
        $ = cheerio.load(html, {decodeEntities: false}); // option to avoid unicode hangul issue
        var snack=$(".snack").parent().find(".menu").text();
        callback(snack);
    }

    request.on('error', function () {
        throw new Error("Network error");
    });

    request.end();

    // callback(snack)
};<commit_msg>Removed whitespace in front of snack data<commit_after>module.exports=function (callback) {
    var cheerio = require('cheerio');
    var http = require('http');

    var options = {
        host: "gaonnuri.ksain.net",
        path: "/xe/?mid=login"
    };

    // get html data from school website
    var data = "";
    var request = http.request(options, function (res) {
        res.setEncoding("utf8");
        res.on('data', function (chunk) {
            data += chunk;
            console.log("received chunk");
        });
        res.on('end', function () {
            parseSnack(data);
        });
    });

    var parseSnack =function (html) {
        $ = cheerio.load(html, {decodeEntities: false}); // option to avoid unicode hangul issue
        var snack=$(".snack").parent().find(".menu").text();
        try {
            snack = snack.substring(1, snack.length);
        }catch(exception){
            console.log(exception);
            console.log("Substring operation for snack failed!");
        }
        callback(snack);
    }

    request.on('error', function () {
        throw new Error("Network error");
    });

    request.end();

    // callback(snack)
};<|endoftext|>


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

  grunt.initConfig({

    release: {
      options: {
        additionalFiles: ['bower.json'],
        npm: false,
        commitMessage: 'feat(release): release <%= version %>'
      }
    }

  });

  grunt.loadNpmTasks('grunt-release');

};
<commit_msg>feat(fix): grunt file release<commit_after>module.exports = function(grunt) {

  grunt.initConfig({

    release: {
      options: {
        additionalFiles: ['bower.json'],
        commitMessage: 'feat(release): release <%= version %>', //default: 'release <%= version %>'
        npm:false
      },
      npm: false
    }

  });

  grunt.loadNpmTasks('grunt-release');

};
<|endoftext|>


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

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

    grunt.registerMultiTask('rex', 'Generate Parsers', function(){
        var fs = require('fs');
        var request = require('request');
		var FormData = require('form-data');
		var path = require('path');

        var done = this.async();
		var count = this.data.parsers.length;

		this.data.parsers.forEach(function(parser){

            var requestCallback = function(err, res, body) {
                fs.writeFileSync(parser.destination, body);
                count--;
                if(count === 0) {
                    done();
                }
            };

			var grammar = fs.readFileSync(parser.source);

            var form = new FormData();
            form.append('tz', parser.tz, { knownLength: new Buffer(parser.tz).length, contentType: 'text/plain'  });
            form.append('command', parser.command, { knownLength: new Buffer(parser.command).length, contentType: 'text/plain' });
            form.append('input', grammar, { knownLength : new Buffer(grammar).length, contentType: 'text/plain', filename: path.basename(parser.source) });
            form.getLength(function(err, length){
                if (err) {
                    return requestCallback(err);
                }
                var r = request.post('http://www.bottlecaps.de/rex/', requestCallback);
                r._form = form;
                r.setHeader('content-length', length);
            });
        });
    });

    grunt.initConfig({
		rex: {
			dist: {
				parsers: [
					{
						source: 'lib/parsers/XQueryParser.ebnf',
						destination: 'lib/parsers/XQueryParser.js',
						command: '-ll 2 -backtrack -tree -javascript -a xqlint',
						tz: '-60',
					},
					{
						source: 'lib/parsers/JSONiqParser.ebnf',
						destination: 'lib/parsers/JSONiqParser.js',
						command: '-ll 2 -backtrack -tree -javascript -a xqlint',
						tz: '-60',
					},
                    {
						source: 'lib/lexers/XQueryTokenizer.ebnf',
                        destination: 'lib/lexers/XQueryTokenizer.js',
                        command: '-ll 2 -backtrack -tree -javascript -a xqlint',
                        tz: '-60'
                    },
                    {
						source: 'lib/lexers/JSONiqTokenizer.ebnf',
                        destination: 'lib/lexers/JSONiqTokenizer.js',
                        command: '-ll 2 -backtrack -tree -javascript -a xqlint',
                        tz: '-60'
                    }
				]
			}
		},
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                'lib/**/*.js',
                'test/**/*.js'
            ]
        },
        vows: {
            all: {
                options: {
                    verbose: true,
                    colors: true,
                    coverage: 'json'
                },
                // String or array of strings
                // determining which files to include.
                // This option is grunt's "full" file format.
                src: ['test/*.js', 'spec/*']
            }
        },
        browserify: {
            dist: {
                files: {
                    'build/xqlint.js': ['lib/**/*.js'],
                }
            }
        }
    });

    grunt.registerTask('default', ['jshint', 'vows']);
};
<commit_msg>Fix browserify build<commit_after>module.exports = function(grunt) {
	'use strict';

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

    grunt.registerMultiTask('rex', 'Generate Parsers', function(){
        var fs = require('fs');
        var request = require('request');
		var FormData = require('form-data');
		var path = require('path');

        var done = this.async();
		var count = this.data.parsers.length;

		this.data.parsers.forEach(function(parser){

            var requestCallback = function(err, res, body) {
                fs.writeFileSync(parser.destination, body);
                count--;
                if(count === 0) {
                    done();
                }
            };

			var grammar = fs.readFileSync(parser.source);

            var form = new FormData();
            form.append('tz', parser.tz, { knownLength: new Buffer(parser.tz).length, contentType: 'text/plain'  });
            form.append('command', parser.command, { knownLength: new Buffer(parser.command).length, contentType: 'text/plain' });
            form.append('input', grammar, { knownLength : new Buffer(grammar).length, contentType: 'text/plain', filename: path.basename(parser.source) });
            form.getLength(function(err, length){
                if (err) {
                    return requestCallback(err);
                }
                var r = request.post('http://www.bottlecaps.de/rex/', requestCallback);
                r._form = form;
                r.setHeader('content-length', length);
            });
        });
    });

    grunt.initConfig({
		rex: {
			dist: {
				parsers: [
					{
						source: 'lib/parsers/XQueryParser.ebnf',
						destination: 'lib/parsers/XQueryParser.js',
						command: '-ll 2 -backtrack -tree -javascript -a xqlint',
						tz: '-60',
					},
					{
						source: 'lib/parsers/JSONiqParser.ebnf',
						destination: 'lib/parsers/JSONiqParser.js',
						command: '-ll 2 -backtrack -tree -javascript -a xqlint',
						tz: '-60',
					},
                    {
						source: 'lib/lexers/XQueryTokenizer.ebnf',
                        destination: 'lib/lexers/XQueryTokenizer.js',
                        command: '-ll 2 -backtrack -tree -javascript -a xqlint',
                        tz: '-60'
                    },
                    {
						source: 'lib/lexers/JSONiqTokenizer.ebnf',
                        destination: 'lib/lexers/JSONiqTokenizer.js',
                        command: '-ll 2 -backtrack -tree -javascript -a xqlint',
                        tz: '-60'
                    }
				]
			}
		},
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                'lib/**/*.js',
                'test/**/*.js'
            ]
        },
        vows: {
            all: {
                options: {
                    verbose: true,
                    colors: true,
                    coverage: 'json'
                },
                // String or array of strings
                // determining which files to include.
                // This option is grunt's "full" file format.
                src: ['test/*.js', 'spec/*']
            }
        },
        browserify: {
            dist: {
                files: {
                    'build/xqlint.js': ['lib/xqlint.js'],
                    'build/xquery_lexer.js': ['lib/lexers/XQueryLexer.js'],
                    'build/jsoniq_lexer.js': ['lib/lexers/JSONiqLexer.js']
                }
            },
            options: {
              standalone: 'ace/mode/xquery'
            }
        }
    });

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


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

  grunt.initConfig({
    eslint: {
      src: ['speck.js', 'Gruntfile.js']
    },
    watch: {
      files: ['<%= eslint.src %>'],
      tasks: ['eslint']
    }
  });

  grunt.loadNpmTasks('gruntify-eslint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Lint files by typing "grunt lint" on the command line
  grunt.registerTask('lint', ['eslint']);

  // Test by typing "grunt test" on the command line
  grunt.registerTask('test', ['eslint']);
};
<commit_msg>Added tape template files to Grunt eslint<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    eslint: {
      src: ['speck.js', 'Gruntfile.js', './templates/tape/**.js']
    },
    watch: {
      files: ['<%= eslint.src %>'],
      tasks: ['eslint']
    }
  });

  grunt.loadNpmTasks('gruntify-eslint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Lint files by typing "grunt lint" on the command line
  grunt.registerTask('lint', ['eslint']);

  // Test by typing "grunt test" on the command line
  grunt.registerTask('test', ['eslint']);
};
<|endoftext|>


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

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

        // Takes your scss files and compiles them to css
        sass: {
          dist: {
            options: {
              style: 'expanded'
            },
            files: {
              'src/css/main.css': 'src/css/scss/main.scss',
              'src/css/responsive.css': 'src/css/scss/responsive.scss'
            }
          }
        },

        // Assembles your email content with html layout
        assemble: {
          options: {
            layoutdir: 'src/layouts',
            flatten: true
          },
          pages: {
            src: ['src/emails/*.hbs'],
            dest: 'dist/'
          }
        },

        // Inlines your css
        premailer: {
          simple: {
            options: {
              removeComments: true
            },
            files: [{
                expand: true,
                src: ['dist/*.html'],
                dest: ''
            }]
          }
        },

        // Watches for changes to css or email templates then runs grunt tasks
        watch: {
          files: ['src/css/scss/*','src/emails/*','src/layouts/*'],
          tasks: ['default']
        },

        // Use Mailgun option if you want to email the design to your inbox or to something like Litmus
        mailgun: {
          mailer: {
            options: {
              key: 'MAILGUN_KEY', // Enter your Mailgun API key here
              sender: 'me@me.com',
              recipient: 'you@you.com',
              subject: 'This is a test email'
            },
            src: ['dist/'+grunt.option('template')]
          }
        },

        // Use Rackspace Cloud Files if you're using images in your email
        cloudfiles: {
          prod: {
            'user': 'Rackspace Cloud Username', // Change this
            'key': 'Rackspace Cloud API Key', // Change this
            'region': 'ORD', // Might need to change this
            'upload': [{
              'container': 'Files Container Name', // Change this
              'src': 'src/img/*',
              'dest': '/',
              'stripcomponents': 0
            }]
          }
        },

        // CDN will replace local paths with your Cloud CDN path
        cdn: {
          options: {
            cdn: 'Rackspace Cloud CDN URI', // Change this
            flatten: true,
            supportedTypes: 'html'
          },
          dist: {
            src: ['./dist/*.html']
          }
        }

    });

    // Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('assemble');
    grunt.loadNpmTasks('grunt-mailgun');
    grunt.loadNpmTasks('grunt-premailer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-cloudfiles');
    grunt.loadNpmTasks('grunt-cdn');

    // Where we tell Grunt what to do when we type "grunt" into the terminal.
    grunt.registerTask('default', ['sass','assemble','premailer']);

    // Use grunt send if you want to actually send the email to your inbox
    grunt.registerTask('send', ['mailgun']);

    // Upload images to our CDN on Rackspace Cloud Files
    grunt.registerTask('cdnify', ['default','cloudfiles','cdn']);

};
<commit_msg>Add some tips to gruntfile<commit_after>module.exports = function(grunt) {

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

        // Takes your scss files and compiles them to css
        sass: {
          dist: {
            options: {
              style: 'expanded'
            },
            files: {
              'src/css/main.css': 'src/css/scss/main.scss',
              'src/css/responsive.css': 'src/css/scss/responsive.scss'
            }
          }
        },

        // Assembles your email content with html layout
        assemble: {
          options: {
            layoutdir: 'src/layouts',
            flatten: true
          },
          pages: {
            src: ['src/emails/*.hbs'],
            dest: 'dist/'
          }
        },

        // Inlines your css
        premailer: {
          simple: {
            options: {
              removeComments: true
            },
            files: [{
                expand: true,
                src: ['dist/*.html'],
                dest: ''
            }]
          }
        },

        // Watches for changes to css or email templates then runs grunt tasks
        watch: {
          files: ['src/css/scss/*','src/emails/*','src/layouts/*'],
          tasks: ['default']
        },

        // Use Mailgun option if you want to email the design to your inbox or to something like Litmus
        mailgun: {
          mailer: {
            options: {
              key: 'MAILGUN_KEY', // Enter your Mailgun API key here
              sender: 'me@me.com', // Change this
              recipient: 'you@you.com', // Change this
              subject: 'This is a test email'
            },
            src: ['dist/'+grunt.option('template')]
          }
        },

        // Use Rackspace Cloud Files if you're using images in your email
        cloudfiles: {
          prod: {
            'user': 'Rackspace Cloud Username', // Change this
            'key': 'Rackspace Cloud API Key', // Change this
            'region': 'ORD', // Might need to change this
            'upload': [{
              'container': 'Files Container Name', // Change this
              'src': 'src/img/*',
              'dest': '/',
              'stripcomponents': 0
            }]
          }
        },

        // CDN will replace local paths with your Cloud CDN path
        cdn: {
          options: {
            cdn: 'Rackspace Cloud CDN URI', // Change this
            flatten: true,
            supportedTypes: 'html'
          },
          dist: {
            src: ['./dist/*.html']
          }
        }

    });

    // Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('assemble');
    grunt.loadNpmTasks('grunt-mailgun');
    grunt.loadNpmTasks('grunt-premailer');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-cloudfiles');
    grunt.loadNpmTasks('grunt-cdn');

    // Where we tell Grunt what to do when we type "grunt" into the terminal.
    grunt.registerTask('default', ['sass','assemble','premailer']);

    // Use grunt send if you want to actually send the email to your inbox
    grunt.registerTask('send', ['mailgun']);

    // Upload images to our CDN on Rackspace Cloud Files
    grunt.registerTask('cdnify', ['default','cloudfiles','cdn']);

};
<|endoftext|>


<commit_before>module.exports = (function (grunt) {
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-mocha-test');
	var paths = [
		"src/main.js",
		"src/utils/*.js",
		"src/registry.js",
		"src/routers/*.js",
		"src/emitters/*.js",
		"src/receivers/*.js",
		"src/module.exports.js"
	];
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		clean: ["./msngr.js", "./msngr.min.js"],
		concat: {
			dist: {
				src: paths,
				dest: "./msngr.js"
			}
		},
		uglify: {
			minify: {
				options: {
					mangle: false,
					preserveComments: false,
					compress: true
				},
				files: {
					"./msngr.min.js": paths
				}
			}
		},
		mochaTest: {
			test: {
				options: {
					reporter: "spec"
				},
				src: ["./test/*.spec.js"]
			}
		}
	});
	grunt.registerTask("build", ["clean", "concat", "uglify:minify", "mochaTest"]);
	grunt.registerTask("test", ["mochaTest"]);
});<commit_msg>Separating building and testing to make travis function better.<commit_after>module.exports = (function (grunt) {
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-mocha-test');
	var paths = [
		"src/main.js",
		"src/utils/*.js",
		"src/registry.js",
		"src/routers/*.js",
		"src/emitters/*.js",
		"src/receivers/*.js",
		"src/module.exports.js"
	];
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		clean: ["./msngr.js", "./msngr.min.js"],
		concat: {
			dist: {
				src: paths,
				dest: "./msngr.js"
			}
		},
		uglify: {
			minify: {
				options: {
					mangle: false,
					preserveComments: false,
					compress: true
				},
				files: {
					"./msngr.min.js": paths
				}
			}
		},
		mochaTest: {
			test: {
				options: {
					reporter: "spec"
				},
				src: ["./test/*.spec.js"]
			}
		}
	});
	grunt.registerTask("build", ["clean", "concat", "uglify:minify"]);
	grunt.registerTask("test", ["mochaTest"]);
});
<|endoftext|>


<commit_before>/*
 * @copyright 2015 CoNWeT Lab., Universidad Politécnica de Madrid
 * @license Apache v2 (http://www.apache.org/licenses/)
 */

module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    isDev: grunt.option('target') === 'release' ? '' : '-dev',

    banner: ' * @version <%= pkg.version %>\n' +
            ' * \n' +
            ' * @copyright 2014 <%= pkg.author %>\n' +
            ' * @license <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */',

    compress: {
      widget: {
        options: {
          archive: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %><%= isDev %>.wgt',
          mode: 'zip',
          level: 9,
          pretty: true
        },
        files: [
          {expand: true, src: ['**/*'], cwd: 'build/wgt'}
        ]
      }
    },

    copy: {
      main: {
        files: [
          {expand: true, src: ['**/*', '!test/**'], dest: 'build/wgt', cwd: 'src'},
          {expand: true, src: ['jquery.min.map', 'jquery.min.js'], dest: 'build/wgt/lib/js', cwd: 'node_modules/jquery/dist'},
          {expand: true, src: ['*'], dest: 'build/wgt/lib/fonts', cwd: 'node_modules/bootstrap/dist/fonts'},
          {expand: true, src: ['vis.min.js'], dest: 'build/wgt/lib/js', cwd: 'node_modules/vis/dist/'},
          {expand: true, src: ['vis.min.css'], dest: 'build/wgt/lib/js', cwd: 'node_modules/vis/dist/'},
          {expand: true, src: ['delete.png'], dest: 'build/wgt/lib/js/img/timeline', cwd: 'node_modules/vis/dist/img/timeline'}
        ]
      }
    },

    karma: {
      headless: {
        configFile: 'karma.conf.js',
        options: {
          browsers: ['PhantomJS']
        }
      },

      all: {
        configFile: 'karma.conf.js'
      },

      debug: {
        configFile: 'karma.conf.js',
        options: {
          preprocessors: [],
          singleRun: false
        }
      }
    },

    replace: {
      version: {
        src: ['src/config.xml'],
        overwrite: true,
        replacements: [{
          from: /version="[0-9]+\.[0-9]+\.[0-9]+(-dev)?"/g,
          to: 'version="<%= pkg.version %>"'
        }]
      }
    },

    clean: ['build'],

    jshint: {
        options: {
            jshintrc: true
        },
        all: {
            files: {
                src: ['src/js/**/*.js']
            }
        },
        grunt: {
            options: {
                jshintrc: '.jshintrc-node'
            },
            files: {
                src: ['Gruntfile.js']
            }
        },
        test: {
            options: {
                jshintrc: '.jshintrc-jasmine'
            },
            files: {
                src: ['src/test/**/*.js', '!src/test/fixtures/', '!src/test/StyledElements/*']
            }
        }
    },

    watch: {
      src: {
        files: ['src/js/**/*.js'],
        tasks: ['karma:all', 'default'],
        options: {
          livereload: true
        }
      },
      tests: {
        files: ['src/js/test/**/*.js'],
        tasks: ['karma:all'],
        options: {
          livereload: true
        }
      }
    },

    wirecloud: {
      publish: {
        file: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %>-dev.wgt'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-gitinfo');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-wirecloud');

  grunt.registerTask('manifest', 'Creates a manifest.json file', function() {

    this.requiresConfig('gitinfo');
    var current = grunt.config(['gitinfo', 'local', 'branch', 'current']);
    var content = JSON.stringify({
      'Branch': current.name,
      'SHA': current.SHA,
      'User': current.currentUser,
      'Build-Timestamp': grunt.template.today('UTC:yyyy-mm-dd HH:MM:ss Z'),
      'Build-By' : 'Grunt ' + grunt.version
    }, null, '\t');
    grunt.file.write('build/wgt/manifest.json', content);
  });

  grunt.registerTask('package', ['gitinfo', 'manifest', 'copy', 'compress:widget']);
  grunt.registerTask('test', ['karma:headless']);
  grunt.registerTask('default',
    [
    'jshint',
    'test',
    'replace:version',
    'package'
    ]);
};<commit_msg>Add bootstrap dependency<commit_after>/*
 * @copyright 2015 CoNWeT Lab., Universidad Politécnica de Madrid
 * @license Apache v2 (http://www.apache.org/licenses/)
 */

module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    isDev: grunt.option('target') === 'release' ? '' : '-dev',

    banner: ' * @version <%= pkg.version %>\n' +
            ' * \n' +
            ' * @copyright 2014 <%= pkg.author %>\n' +
            ' * @license <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */',

    compress: {
      widget: {
        options: {
          archive: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %><%= isDev %>.wgt',
          mode: 'zip',
          level: 9,
          pretty: true
        },
        files: [
          {expand: true, src: ['**/*'], cwd: 'build/wgt'}
        ]
      }
    },

    copy: {
      main: {
        files: [
          {expand: true, src: ['**/*', '!test/**'], dest: 'build/wgt', cwd: 'src'},
          {expand: true, src: ['jquery.min.map', 'jquery.min.js'], dest: 'build/wgt/lib/js', cwd: 'node_modules/jquery/dist'},
          {expand: true, src: ['*'], dest: 'build/wgt/lib/fonts', cwd: 'node_modules/bootstrap/dist/fonts'},
          {expand: true, src: ['vis.min.js'], dest: 'build/wgt/lib/js', cwd: 'node_modules/vis/dist'},
          {expand: true, src: ['vis.min.css'], dest: 'build/wgt/lib/css', cwd: 'node_modules/vis/dist'},
          {expand: true, src: ['bootstrap.min.js'], dest: 'build/wgt/lib/js', cwd: 'node_modules/bootstrap/dist/js'},
          {expand: true, src: ['bootstrap.min.css'], dest: 'build/wgt/lib/css', cwd: 'node_modules/bootstrap/dist/css'},
          {expand: true, src: ['delete.png'], dest: 'build/wgt/lib/css/img/timeline', cwd: 'node_modules/vis/dist/img/timeline'}
        ]
      }
    },

    karma: {
      headless: {
        configFile: 'karma.conf.js',
        options: {
          browsers: ['PhantomJS']
        }
      },

      all: {
        configFile: 'karma.conf.js'
      },

      debug: {
        configFile: 'karma.conf.js',
        options: {
          preprocessors: [],
          singleRun: false
        }
      }
    },

    replace: {
      version: {
        src: ['src/config.xml'],
        overwrite: true,
        replacements: [{
          from: /version="[0-9]+\.[0-9]+\.[0-9]+(-dev)?"/g,
          to: 'version="<%= pkg.version %>"'
        }]
      }
    },

    clean: ['build'],

    jshint: {
        options: {
            jshintrc: true
        },
        all: {
            files: {
                src: ['src/js/**/*.js']
            }
        },
        grunt: {
            options: {
                jshintrc: '.jshintrc-node'
            },
            files: {
                src: ['Gruntfile.js']
            }
        },
        test: {
            options: {
                jshintrc: '.jshintrc-jasmine'
            },
            files: {
                src: ['src/test/**/*.js', '!src/test/fixtures/', '!src/test/StyledElements/*']
            }
        }
    },

    watch: {
      src: {
        files: ['src/js/**/*.js'],
        tasks: ['karma:all', 'default'],
        options: {
          livereload: true
        }
      },
      tests: {
        files: ['src/js/test/**/*.js'],
        tasks: ['karma:all'],
        options: {
          livereload: true
        }
      }
    },

    wirecloud: {
      publish: {
        file: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %>-dev.wgt'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-gitinfo');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-wirecloud');

  grunt.registerTask('manifest', 'Creates a manifest.json file', function() {

    this.requiresConfig('gitinfo');
    var current = grunt.config(['gitinfo', 'local', 'branch', 'current']);
    var content = JSON.stringify({
      'Branch': current.name,
      'SHA': current.SHA,
      'User': current.currentUser,
      'Build-Timestamp': grunt.template.today('UTC:yyyy-mm-dd HH:MM:ss Z'),
      'Build-By' : 'Grunt ' + grunt.version
    }, null, '\t');
    grunt.file.write('build/wgt/manifest.json', content);
  });

  grunt.registerTask('package', ['gitinfo', 'manifest', 'copy', 'compress:widget']);
  grunt.registerTask('test', ['karma:headless']);
  grunt.registerTask('default',
    [
    'jshint',
    'test',
    'replace:version',
    'package'
    ]);
};<|endoftext|>


<commit_before>'use strict';

var userhome = require('userhome');

module.exports = function(grunt) {

    grunt.initConfig({

        config: {
            path_dotfiles: process.cwd(),

            neovim: {
                path_vimplug: userhome('.local/share/nvim/site/autoload/plug.vim'),
                url_vimplug: 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim',
                path: '<%= config.path_dotfiles%>' + '/nvim',
                path_system: userhome('.config/nvim')
            },

            vim: {
                path_vimrc: '<%=  config.path_dotfiles%>' + '/vim/vimrc',
                path_vimrc_system: userhome('.vimrc'),
                path_vim: '<%= config.path_dotfiles%>' + '/vim',
                path_vim_system: userhome('.vim'),
                path_vundle: userhome('.vim/vundle/Vundle.vim'),
                url_vundle: 'https://github.com/VundleVim/Vundle.vim.git'
            },

            git: {
                path_gitconfig_system: userhome('.gitconfig'),
                path_gitconfig: '<%= config.path_dotfiles%>' + '/git/gitconfig',
                path_gitignore_system: userhome('.gitignore'),
                path_gitignore: '<%= config.path_dotfiles%>' + '/git/gitignore'
            }
        },

        curl: {
            vimplug: {
                src: '<%= config.neovim.url_vimplug%>',
                dest: '<%= config.neovim.path_vimplug%>'
            }
        },

        gitclone: {
            vundle: {
                options: {
                    directory: '<%= config.vim.path_vundle%>',
                    repository: '<%= config.vim.url_vundle%>'
                }
            }
        },

        symlink: {
            neovim: {
                dest: "<%= config.neovim.path_system%>",
                relativeSrc: "<%= config.neovim.path%>",
                options: {type: 'dir'}
            },

            vimrc: {
                dest: "<%= config.vim.path_vimrc_system%>",
                relativeSrc: "<%= config.vim.path_vimrc%>"
            },

            vim: {
                dest: "<%= config.vim.path_vim_system%>",
                relativeSrc: "<%= config.vim.path_vim%>",
                options: {type: 'dir'}
            },

            gitconfig: {
                dest: "<%= config.git.path_gitconfig_system%>",
                relativeSrc: "<%= config.git.path_gitconfig%>"
            },

            gitignore: {
                dest: "<%= config.git.path_gitignore_system%>",
                relativeSrc: "<%= config.git.path_gitignore%>"
            }
        }

    });

    grunt.loadNpmTasks('grunt-curl');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-symlink');

    grunt.registerTask('neovim', ['curl:vimplug', 'symlink:neovim']);
    grunt.registerTask('vim', ['gitclone:vundle', 'symlink:vimrc', 'symlink:vim']);
    grunt.registerTask('git', ['symlink:gitconfig', 'symlink:gitignore']);
    grunt.registerTask('banner', function(){
        grunt.log.writeln(grunt.file.read('templates/banner'));
    });
    grunt.registerTask('default', ['banner']);
};
<commit_msg>Add task for zsh<commit_after>'use strict';

var userhome = require('userhome');

module.exports = function(grunt) {

    grunt.initConfig({
        config: {
            path_dotfiles: process.cwd(),
            neovim: {
                path_vimplug: userhome('.local/share/nvim/site/autoload/plug.vim'),
                url_vimplug: 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim',
            },
            vim: {
                path_vundle: userhome('.vim/vundle/Vundle.vim'),
                url_vundle: 'https://github.com/VundleVim/Vundle.vim.git'
            }
        },

        curl: {
            vimplug: {
                src: '<%= config.neovim.url_vimplug%>',
                dest: '<%= config.neovim.path_vimplug%>'
            }
        },

        gitclone: {
            vundle: {
                options: {
                    directory: '<%= config.vim.path_vundle%>',
                    repository: '<%= config.vim.url_vundle%>'
                }
            }
        },

        symlink: {
            // neovim symlink
            neovim: {
                dest: userhome('.config/nvim'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/nvim',
                options: {type: 'dir'}
            },

            // vim symlinks
            vimrc: {
                dest: userhome('.vimrc'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/vim/vimrc'
            },
            vim: {
                dest: userhome('.vim'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/vim',
                options: {type: 'dir'}
            },

            // git symlinks
            gitconfig: {
                dest: userhome('.gitconfig'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/git/gitconfig'
            },
            gitignore: {
                dest: userhome('.gitignore'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/git/gitignore'
            },

            // zsh symlinks
            zlogin: {
                dest: userhome('.zlogin'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zlogin'
            },
            zshrc: {
                dest: userhome('.zshrc'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zshrc'
            },
            zshenv: {
                dest: userhome('.zshenv'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zshenv'
            },
            zprofile: {
                dest: userhome('.zprofile'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zprofile'
            },
            zpreztorc: {
                dest: userhome('.zpreztorc'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zpreztorc'
            },
            zlogout: {
                dest: userhome('.zlogout'),
                relativeSrc: '<%= config.path_dotfiles%>' + '/zsh/zlogout'
            }
        }

    });

    grunt.loadNpmTasks('grunt-curl');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-symlink');

    grunt.registerTask('neovim', ['curl:vimplug', 'symlink:neovim']);
    grunt.registerTask('vim', ['gitclone:vundle', 'symlink:vimrc', 'symlink:vim']);
    grunt.registerTask('git', ['symlink:gitconfig', 'symlink:gitignore']);
    grunt.registerTask('zsh', [
        'symlink:zlogin',
        'symlink:zshrc',
        'symlink:zshenv',
        'symlink:zprofile',
        'symlink:zpreztorc',
        'symlink:zlogout'
    ]);
    grunt.registerTask('banner', function(){
        grunt.log.writeln(grunt.file.read('templates/banner'));
    });
    grunt.registerTask('default', ['banner']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    'use strict';
    grunt.initConfig({
        encryptedDirectory: 'vault',
        encryptedExtension: '.protected',

        /**
         * Clear files and folders
         * @see {@link https://github.com/gruntjs/grunt-contrib-clean}
         **/
        clean: {
            plain:  [
                '<%= encryptedDirectory %>/*',
                '!<%= encryptedDirectory %>/*<%= encryptedExtension %>',
                '!<%= encryptedDirectory %>/README.md'
            ],
            cipher: [
                '<%= encryptedDirectory %>/*<%= encryptedExtension %>'
            ]
        },

        /**
         * Encrypt and decrypt files located in the vault directory (performed in place)
         * @see {@link https://github.com/openhoat/grunt-contrib-crypt}
         **/
        crypt:{
            options: {
                key: grunt.cli.options.key || 'password'
            },
            files: [
                {
                    dir: '<%= encryptedDirectory %>',
                    include: '**/!(README.md|README.MD)',
                    encryptedExtension: '<%= encryptedExtension %>'
                }
            ]
        }
    });
    grunt.task.loadNpmTasks('grunt-contrib-clean');
    grunt.task.loadNpmTasks('grunt-contrib-crypt');
    grunt.registerTask('lock',    ['encrypt', 'clean:plain']);
    grunt.registerTask('unlock',  ['decrypt', 'clean:cipher']);
};<commit_msg>Adding sed string replacement for easy datastore selection<commit_after>module.exports = function(grunt) {
    'use strict';
    grunt.initConfig({
        encryptedDirectory: 'vault',
        encryptedExtension: '.protected',

        /**
         * Clear files and folders
         * @see {@link https://github.com/gruntjs/grunt-contrib-clean}
         **/
        clean: {
            plain:  [
                '<%= encryptedDirectory %>/*',
                '!<%= encryptedDirectory %>/*<%= encryptedExtension %>',
                '!<%= encryptedDirectory %>/README.md'
            ],
            cipher: [
                '<%= encryptedDirectory %>/*<%= encryptedExtension %>'
            ]
        },

        /**
         * Encrypt and decrypt files located in the vault directory (performed in place)
         * @see {@link https://github.com/openhoat/grunt-contrib-crypt}
         **/
        crypt:{
            options: {
                key: grunt.cli.options.key || 'password'
            },
            files: [
                {
                    dir: '<%= encryptedDirectory %>',
                    include: '**/!(README.md|README.MD)',
                    encryptedExtension: '<%= encryptedExtension %>'
                }
            ]
        },

        /**
         * Plugin built on top of replace, for performing search and replace on files.
         * @see {@link https://github.com/jharding/grunt-sed}
         **/
        sed: {
            mongo: {
                path: 'Vagrantfile',
                pattern: 'inline: [$]install_mongo',
                replacement: 'inline: $install_mongo'
            },
            redis: {
                path: 'Vagrantfile',
                pattern: 'inline: [$]install_.*',
                replacement: 'inline: $install_redis'
            },
            couch: {
                path: 'Vagrantfile',
                pattern: 'inline: [$]install_mongo',
                replacement: 'inline: $install_couch'
            }
        }
    });
    grunt.task.loadNpmTasks('grunt-contrib-clean');
    grunt.task.loadNpmTasks('grunt-contrib-crypt');
    grunt.task.loadNpmTasks('grunt-sed');
    grunt.registerTask('lock',    ['encrypt', 'clean:plain']);
    grunt.registerTask('unlock',  ['decrypt', 'clean:cipher']);
};<|endoftext|>


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

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

    requirejs: {
      compile: {
        options: {
          baseUrl: "/",
          paths: {
            jquery: "empty:",
            async: "empty:"
          },
          name: "xooie",
          include: [
            "xooie/carousel",
            "xooie/dropdown",
            "xooie/tab",
            "xooie/dialog",
            "xooie/addons/carousel_lentils",
            "xooie/addons/carousel_pagination",
            "xooie/addons/dropdown_accordion",
            "xooie/addons/tab_automation",
            "xooie/addons/tab_animation"
          ],
          out: "bin/xooie-<%= pkg.version %>.js",
          optimize: "none"
        }
      }
    },
    jasmine: {
      test: {
        //src: "xooie/**/*.js",
        src: ['xooie/widgets/base.js', 'xooie/widgets/dropdown.js', 'xooie/widgets/carousel.js', 'xooie/addons/base.js', 'xooie/**.js'],
        options: {
          //specs: "spec/**/*.spec.js",
          specs: ['spec/widgets/base.spec.js', 'spec/widgets/dropdown.spec.js', 'spec/widgets/carousel.spec.js', 'spec/addons/base.spec.js', 'spec/**.js'],
          template: require("grunt-template-jasmine-requirejs"),
          vendor: ["lib/jquery.js","lib/require.js","lib/micro_tmpl.js","lib/jasmine-jquery.js"],
          helpers: "spec/helpers.js",
          templateOptions: {
            requireConfigFile: 'lib/config.js'
          }
        }
      }
    },
    jshint: {
      files: 'xooie/**/*.js'
    }
  });

  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');

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

};<commit_msg>Adding build functionality back into new release<commit_after>module.exports = function(grunt) {

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

    requirejs: {
      compile: {
        options: {
          baseUrl: "",
          paths: {
            jquery: "empty:",
            async: "empty:"
          },
          name: "xooie/xooie",
          include: [
            "xooie/widgets/carousel",
            "xooie/widgets/dropdown",
            "xooie/widgets/tab",
            "xooie/widgets/dialog",
            "xooie/addons/carousel_lentils",
            "xooie/addons/carousel_pagination",
            "xooie/addons/tab_automation",
            "xooie/addons/tab_animation"
          ],
          out: "source/javascripts/xooie-<%= pkg.version %>.js",
          optimize: "none"
        }
      }
    },
    jasmine: {
      test: {
        //src: "xooie/**/*.js",
        src: ['xooie/widgets/base.js', 'xooie/widgets/dropdown.js', 'xooie/widgets/carousel.js', 'xooie/addons/base.js', 'xooie/**.js'],
        options: {
          //specs: "spec/**/*.spec.js",
          specs: ['spec/widgets/base.spec.js', 'spec/widgets/dropdown.spec.js', 'spec/widgets/carousel.spec.js', 'spec/addons/base.spec.js', 'spec/**.js'],
          template: require("grunt-template-jasmine-requirejs"),
          vendor: ["lib/jquery.js","lib/require.js","lib/micro_tmpl.js","lib/jasmine-jquery.js"],
          helpers: "spec/helpers.js",
          templateOptions: {
            requireConfigFile: 'lib/config.js'
          }
        }
      }
    },
    jshint: {
      files: 'xooie/**/*.js'
    }
  });

  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('test', ['jshint', 'jasmine']);
  grunt.registerTask('build', ['test', 'requirejs']);

};<|endoftext|>


<commit_before>import React from 'react';
import { FeatureTogglesContext } from './context';

export const withFeatures = Component => props => {
	return (
		<FeatureTogglesContext.Consumer>
			{features => (
				<Component {...props} features={features}/>
			)}
		</FeatureTogglesContext.Consumer>
	);
};
<commit_msg>prettier<commit_after>import React from 'react';
import { FeatureTogglesContext } from './context';

export const withFeatures = Component => props => {
  return (
    <FeatureTogglesContext.Consumer>
      {features => <Component {...props} features={features} />}
    </FeatureTogglesContext.Consumer>
  );
};
<|endoftext|>


<commit_before>const responseHandlers = require("../response.js");
const { encodePath, joinURL, prepareRequestOptions, request } = require("../request.js");

function createReadStream(filePath, options) {
    const Stream = require("stream");
    const PassThroughStream = Stream.PassThrough;
    const outStream = new PassThroughStream();
    getFileStream(filePath, options)
        .then(stream => {
            stream.pipe(outStream);
        })
        .catch(err => {
            outStream.emit("error", err);
        });
    return outStream;
}

function createWriteStream(filePath, options, callback) {
    const Stream = require("stream");
    const PassThroughStream = Stream.PassThrough;
    const writeStream = new PassThroughStream();
    const headers = {};
    if (options.overwrite === false) {
        headers["If-None-Match"] = "*";
    }
    const requestOptions = {
        url: joinURL(options.remoteURL, encodePath(filePath)),
        method: "PUT",
        headers,
        data: writeStream
    };
    prepareRequestOptions(requestOptions, options);

    if (!callback || typeof callback !== "function") {
        callback=responseHandlers.handleResponseCode;
    }

    request(requestOptions)
        .then(callback)
        .catch(err => {
            writeStream.emit("error", err);
        });
    return writeStream;
}

function getFileStream(filePath, options) {
    let rangeHeader;
    const headers = {};
    if (typeof options.range === "object" && typeof options.range.start === "number") {
        rangeHeader = "bytes=" + options.range.start + "-";
        if (typeof options.range.end === "number") {
            rangeHeader += options.range.end;
        }
        headers.Range = rangeHeader;
    }
    const requestOptions = {
        url: joinURL(options.remoteURL, encodePath(filePath)),
        method: "GET",
        headers,
        responseType: "stream"
    };
    prepareRequestOptions(requestOptions, options);
    return request(requestOptions)
        .then(responseHandlers.handleResponseCode)
        .then(res => res.data);
}

module.exports = {
    createReadStream,
    createWriteStream
};
<commit_msg>Improve createWriteStream callback handler<commit_after>const responseHandlers = require("../response.js");
const { encodePath, joinURL, prepareRequestOptions, request } = require("../request.js");

const NOOP = () => {};

function createReadStream(filePath, options) {
    const Stream = require("stream");
    const PassThroughStream = Stream.PassThrough;
    const outStream = new PassThroughStream();
    getFileStream(filePath, options)
        .then(stream => {
            stream.pipe(outStream);
        })
        .catch(err => {
            outStream.emit("error", err);
        });
    return outStream;
}

function createWriteStream(filePath, options, callback = NOOP) {
    const Stream = require("stream");
    const PassThroughStream = Stream.PassThrough;
    const writeStream = new PassThroughStream();
    const headers = {};
    if (options.overwrite === false) {
        headers["If-None-Match"] = "*";
    }
    const requestOptions = {
        url: joinURL(options.remoteURL, encodePath(filePath)),
        method: "PUT",
        headers,
        data: writeStream
    };
    prepareRequestOptions(requestOptions, options);
    request(requestOptions)
        .then(response => {
            // Fire callback asynchronously to avoid errors
            setTimeout(callback, 0);
            return response;
        })
        .then(responseHandlers.handleResponseCode)
        .catch(err => {
            writeStream.emit("error", err);
        });
    return writeStream;
}

function getFileStream(filePath, options) {
    let rangeHeader;
    const headers = {};
    if (typeof options.range === "object" && typeof options.range.start === "number") {
        rangeHeader = "bytes=" + options.range.start + "-";
        if (typeof options.range.end === "number") {
            rangeHeader += options.range.end;
        }
        headers.Range = rangeHeader;
    }
    const requestOptions = {
        url: joinURL(options.remoteURL, encodePath(filePath)),
        method: "GET",
        headers,
        responseType: "stream"
    };
    prepareRequestOptions(requestOptions, options);
    return request(requestOptions)
        .then(responseHandlers.handleResponseCode)
        .then(res => res.data);
}

module.exports = {
    createReadStream,
    createWriteStream
};
<|endoftext|>


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

    less: {
      development: {
        options: {
          compress: true,
          yuicompress: true,
          optimization: 2
        },
        files: {
          // "_assets/css/main.css": "_less/main.less"
          "css/main.css": "_less/main.less"
        }
      }
    },
    concat: {
      css: {
        src: [
        '_css/*'
        ],
        dest: 'css/main.css'
      }
    },
    cssmin: {
      css: {
        src:  'css/main.css',
        dest: 'css/main.min.css'
      }
    },
    jekyll: {
      options: {
        src: '.',
        dest: './_site',
        config: '_config.yml',
        serve: false,
        watch: false,
        future: true,
        force_polling: false,
        bundleExec: true
      },
      devel: {
        options: {
          dest: './_site',
          config: '_config.yml',
          serve: true,
          watch: true,
          future: true,
          force_polling: true,
          bundleExec: true
        }
      },
      dist: {
        options: {
          dest: './_site',
          config: '_config.yml',
          serve: false,
          watch: false,
          future: true,
          force_polling: false,
          bundleExec: true
        }
      }
    },
    watch: {
      options: {
        livereload: true,
      },
      css: {
        files: [
          '_less/*.less',
          '_less/partials/*.less'
          ],
        tasks: ['less', 'cssmin:css'],
      },
      html: {
        files: [
          '.htaccess',
          '*.png',
          '*.ico',
          '*.txt',
          '*.xml',
          '*.html',
          '*.md',
          '_assets/js/*',
          '_assets/stylesheets/*',
          'css/*.css',
          '_includes/*.html',
          '_layouts/*.html',
          '_includes/components/*',
          '_includes/*',
          '_posts/*',
          '_works/*',
          '_pages/*',
          'media/*',
          '_data/*'
          ],
        tasks: ['jekyll:dist'],
        options: {
          spawn: false,
        }
      }
    },
    connect: {
      server: {
        options: {
          port: 8000,
          base: './_site',
          open: {
            target: 'http://localhost:8000'
          }
        }
      }
    }
  });
  require('load-grunt-tasks')(grunt);

  // grunt.registerTask('default', ['less', 'concat:css', 'cssmin:css', 'jekyll']);
  // grunt.registerTask('css', ['less', 'concat:css', 'cssmin:css']);

  // Only compile the custom less->css for Christina's site theme
  // Using grunt 'grunt-contrib-less' + 'grunt-contrib-cssmin'
  // resulting on -> css/main.min.css
  grunt.registerTask('css', ['less', 'cssmin:css']);

  // Build the full site
  // Less -> sass + js -> jekyll -> _dist
  grunt.registerTask('build', ['less', 'cssmin:css', 'jekyll:dist']);

  // Watch for content creation serving from jekyll
  // "_assets" asset pipeline will work: js + sass
  // "_less"   asset pipeline will NOT work: less
  grunt.registerTask('content', ['jekyll:devel']);

  // Server option: tails connect + watch
  // "_assets" + "_less" asset pipeline will both work:
  // [js + sass] + [less]
  grunt.registerTask('theming', ['connect', 'watch']);

  // Watch for content and forget about the rest
  grunt.registerTask('default', ['theming']);

};<commit_msg>modified grunt theming command to rebuild everything before going<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    less: {
      development: {
        options: {
          compress: true,
          yuicompress: true,
          optimization: 2
        },
        files: {
          // "_assets/css/main.css": "_less/main.less"
          "css/main.css": "_less/main.less"
        }
      }
    },
    concat: {
      css: {
        src: [
        '_css/*'
        ],
        dest: 'css/main.css'
      }
    },
    cssmin: {
      css: {
        src:  'css/main.css',
        dest: 'css/main.min.css'
      }
    },
    jekyll: {
      options: {
        src: '.',
        dest: './_site',
        config: '_config.yml',
        serve: false,
        watch: false,
        future: true,
        force_polling: false,
        bundleExec: true
      },
      devel: {
        options: {
          dest: './_site',
          config: '_config.yml',
          serve: true,
          watch: true,
          future: true,
          force_polling: true,
          bundleExec: true
        }
      },
      dist: {
        options: {
          dest: './_site',
          config: '_config.yml',
          serve: false,
          watch: false,
          future: true,
          force_polling: false,
          bundleExec: true
        }
      }
    },
    watch: {
      options: {
        livereload: true,
      },
      css: {
        files: [
          '_less/*.less',
          '_less/partials/*.less'
          ],
        tasks: ['less', 'cssmin:css'],
      },
      html: {
        files: [
          '.htaccess',
          '*.png',
          '*.ico',
          '*.txt',
          '*.xml',
          '*.html',
          '*.md',
          '_assets/js/*',
          '_assets/stylesheets/*',
          'css/*.css',
          '_includes/*.html',
          '_layouts/*.html',
          '_includes/components/*',
          '_includes/*',
          '_posts/*',
          '_works/*',
          '_pages/*',
          'media/*',
          'media/images/*',
          'media/pdf/*',
          '_data/*'
          ],
        tasks: ['jekyll:dist'],
        options: {
          spawn: false,
        }
      }
    },
    connect: {
      server: {
        options: {
          port: 8000,
          base: './_site',
          open: {
            target: 'http://localhost:8000'
          }
        }
      }
    }
  });
  require('load-grunt-tasks')(grunt);

  // grunt.registerTask('default', ['less', 'concat:css', 'cssmin:css', 'jekyll']);
  // grunt.registerTask('css', ['less', 'concat:css', 'cssmin:css']);

  // Only compile the custom less->css for Christina's site theme
  // Using grunt 'grunt-contrib-less' + 'grunt-contrib-cssmin'
  // resulting on -> css/main.min.css
  grunt.registerTask('css', ['less', 'cssmin:css']);

  // Build the full site
  // Less -> sass + js -> jekyll -> _dist
  grunt.registerTask('build', ['less', 'cssmin:css', 'jekyll:dist']);

  // Watch for content creation serving from jekyll
  // "_assets" asset pipeline will work: js + sass
  // "_less"   asset pipeline will NOT work: less
  grunt.registerTask('content', ['jekyll:devel']);

  // Server option: tails connect + watch
  // "_assets" + "_less" asset pipeline will both work:
  // [js + sass] + [less]
  grunt.registerTask('theming', ['less','cssmin:css','jekyll:dist','connect', 'watch']);

  // Watch for content and forget about the rest
  grunt.registerTask('default', ['theming']);

};<|endoftext|>


<commit_before>var pConfig = require('./../../../utils/protractor.configuration.js');

var config = pConfig.getConfig({
    configFileName: 'recordset/ind-facet.dev.json',
    chaiseConfigFilePath: 'test/e2e/specs/delete-prohibited/chaise-config.js',
    specs: [
        // "ind-facet.spec.js",
        "misc-facet.spec.js"
    ],
    setBaseUrl: function(browser, data) {
      browser.params.url = process.env.CHAISE_BASE_URL;
      return browser.params.url;
    }
});

exports.config = config;
<commit_msg>uncomment test spec<commit_after>var pConfig = require('./../../../utils/protractor.configuration.js');

var config = pConfig.getConfig({
    configFileName: 'recordset/ind-facet.dev.json',
    chaiseConfigFilePath: 'test/e2e/specs/delete-prohibited/chaise-config.js',
    specs: [
        "ind-facet.spec.js",
        "misc-facet.spec.js"
    ],
    setBaseUrl: function(browser, data) {
      browser.params.url = process.env.CHAISE_BASE_URL;
      return browser.params.url;
    }
});

exports.config = config;
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    jekyllConfig: grunt.file.readYAML('_config.yml'),

    jekyll: {
      build: {
      },
      devel: {
        options: {
          drafts: true,
        },
      },
      serve: {
        options: {
          watch: true,
        }
      }
    },

    vulcanize: {
      options: {
        strip: true,
        csp: false,
        inline: true
      },
      build: {
        files: {
          'elements/elements.vulcanized.html': 'elements/elements.html'
        },
      }
    },

    watch: {
      elements: {
        files: ['elements/**/*.html', '**/*.md'],
        tasks: ['vulcanize', 'jekyll:devel'],
        options: {
          spawn: false,
        }
      },
    },

    concurrent: {
      options: {
        logConcurrentOutput: true,
        limit: 5
      },
      target1: [
        'vulcanize',
        'jekyll:devel',
        'copy:components',
        'watch',
      ]
    },

    copy: {
      components: {
        files: [
          {
            expand: true, src: [ 'js/bower_components/platform/**' ],
            dest: '_site/components/platform/',
            flatten: true,
          },
        ],
      },
    },

  });

  // Fetch publications task
  grunt.registerTask('fetchpubs', function() {
    var done = this.async();
    grunt.log.writeln('Fetching publications...');
    // Run this script via node from the project root.

    var http = require('http'),
        fs = require('fs');

    // List of URLs to grab
    var PUB_URLS = [
        'http://publications.eng.cam.ac.uk/cgi/exportview/creators/Wareham=3ARJ=3A=3A/JSON/Wareham=3ARJ=3A=3A.js',
        'http://publications.eng.cam.ac.uk/cgi/exportview/creators/Wareham=3AR=3A=3A/JSON/Wareham=3AR=3A=3A.js',
    ];

    var processUrls = function(urls, cb) {
      var pubs = [];
      var processEntry = function(idx) {
        if(idx >= urls.length) { return; }
        var url = urls[idx];
        grunt.log.writeln('GET-ing', url);
        http.get(url, function(res) {
          var json_data = '';
          res.on('data', function(chunk) { json_data += chunk; });
          res.on('end', function() {
            // We use naked evals because the CUED database has some naked unescape-s in them :(
            var parsed_pubs = eval(json_data);
            grunt.log.writeln('Got ' + parsed_pubs.length + ' publication(s)');

            // Do some post-processing
            parsed_pubs.forEach(function(pub) {
              // Parse date
              pub.timestamp = Date.parse(pub.date);
              pub.date = new Date(pub.timestamp).toISOString();

              // Add to output
              pubs.push(pub);
            });

            if(idx+1 < PUB_URLS.length) {
              processEntry(idx+1);
            } else {
              // Sort publications by descending date
              pubs.sort(function(a,b) {
                return b.timestamp - a.timestamp;
              });

              if(cb) { cb(pubs); }
            }
          });
        });
      };

      processEntry(0);
    };

    processUrls(PUB_URLS, function(pubs) {
      fs.writeFile('publications.json', JSON.stringify(pubs), function() {
        grunt.log.writeln('Wrote ' + pubs.length + ' publications');
        done(true);
      });
    });
  });

  // Plugin and grunt tasks.
  require('load-grunt-tasks')(grunt);

  // Default task
  // Task to run vulcanize, jekyll, app engine server, compass watch, vulcanize watch
  grunt.registerTask('default', ['concurrent']);

  // Task to run vulcanize and build the jekyll site
  grunt.registerTask('build', ['fetchpubs', 'vulcanize', 'jekyll:build', 'copy:components']);
};
<commit_msg>gruntfile: add "quickbuild" option<commit_after>module.exports = function(grunt) {
  // Project configuration.
  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    jekyllConfig: grunt.file.readYAML('_config.yml'),

    jekyll: {
      build: {
      },
      devel: {
        options: {
          drafts: true,
        },
      },
      serve: {
        options: {
          watch: true,
        }
      }
    },

    vulcanize: {
      options: {
        strip: true,
        csp: false,
        inline: true
      },
      build: {
        files: {
          'elements/elements.vulcanized.html': 'elements/elements.html'
        },
      }
    },

    watch: {
      elements: {
        files: ['elements/**/*.html', '**/*.md'],
        tasks: ['vulcanize', 'jekyll:devel'],
        options: {
          spawn: false,
        }
      },
    },

    concurrent: {
      options: {
        logConcurrentOutput: true,
        limit: 5
      },
      target1: [
        'vulcanize',
        'jekyll:devel',
        'copy:components',
        'watch',
      ]
    },

    copy: {
      components: {
        files: [
          {
            expand: true, src: [ 'js/bower_components/platform/**' ],
            dest: '_site/components/platform/',
            flatten: true,
          },
        ],
      },
    },

  });

  // Fetch publications task
  grunt.registerTask('fetchpubs', function() {
    var done = this.async();
    grunt.log.writeln('Fetching publications...');
    // Run this script via node from the project root.

    var http = require('http'),
        fs = require('fs');

    // List of URLs to grab
    var PUB_URLS = [
        'http://publications.eng.cam.ac.uk/cgi/exportview/creators/Wareham=3ARJ=3A=3A/JSON/Wareham=3ARJ=3A=3A.js',
        'http://publications.eng.cam.ac.uk/cgi/exportview/creators/Wareham=3AR=3A=3A/JSON/Wareham=3AR=3A=3A.js',
    ];

    var processUrls = function(urls, cb) {
      var pubs = [];
      var processEntry = function(idx) {
        if(idx >= urls.length) { return; }
        var url = urls[idx];
        grunt.log.writeln('GET-ing', url);
        http.get(url, function(res) {
          var json_data = '';
          res.on('data', function(chunk) { json_data += chunk; });
          res.on('end', function() {
            // We use naked evals because the CUED database has some naked unescape-s in them :(
            var parsed_pubs = eval(json_data);
            grunt.log.writeln('Got ' + parsed_pubs.length + ' publication(s)');

            // Do some post-processing
            parsed_pubs.forEach(function(pub) {
              // Parse date
              pub.timestamp = Date.parse(pub.date);
              pub.date = new Date(pub.timestamp).toISOString();

              // Add to output
              pubs.push(pub);
            });

            if(idx+1 < PUB_URLS.length) {
              processEntry(idx+1);
            } else {
              // Sort publications by descending date
              pubs.sort(function(a,b) {
                return b.timestamp - a.timestamp;
              });

              if(cb) { cb(pubs); }
            }
          });
        });
      };

      processEntry(0);
    };

    processUrls(PUB_URLS, function(pubs) {
      fs.writeFile('publications.json', JSON.stringify(pubs), function() {
        grunt.log.writeln('Wrote ' + pubs.length + ' publications');
        done(true);
      });
    });
  });

  // Plugin and grunt tasks.
  require('load-grunt-tasks')(grunt);

  // Default task
  // Task to run vulcanize, jekyll, app engine server, compass watch, vulcanize watch
  grunt.registerTask('default', ['concurrent']);

  // Task to run vulcanize and build the jekyll site without fetching publications
  grunt.registerTask('quickbuild', ['vulcanize', 'jekyll:build', 'copy:components']);

  // Task to run vulcanize and build the jekyll site
  grunt.registerTask('build', ['fetchpubs', 'vulcanize', 'jekyll:build', 'copy:components']);
};
<|endoftext|>