<commit_before>// Generated on 2014-11-25 using generator-angular 0.10.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
  var proxies = require('./config/grunt/proxies');
  var appConfig = require('./config/grunt/appConfig');

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

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

  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      babel: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.es6'],
        tasks: ['newer:babel:prod'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      babelTest:{
        files: ['test/spec/{,*/}*.es6'],
        tasks: ['newer:babel:tests']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    babel: {
      options: {
        sourceMap: false
      },
      prod: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts/',
          src: ['{,*/}*.es6'],
          dest: '<%= yeoman.app %>/scripts/',
          ext: '.js'
        }]
      },
      tests: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: ['{,*/}*.es6'],
          dest: 'test/spec/',
          ext: '.js'
        }]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        proxies: [proxies.proxyForStubby],
        options: {
          open: true,
          middleware: function (connect) {
            // if (!Array.isArray(options.base)) {
            //     options.base = [options.base];
            // }
            // var middlewares = [ proxyForStubby ];

            // // Serve static files.
            // options.base.forEach(function(base) {
            //     middlewares.push(connect.static(base));
            // });

            // // Make directory browse-able.
            // var directory = options.directory || options.base[options.base.length - 1];
            // middlewares.push(connect.directory(directory));

            // return middlewares;
            return [
              proxySnippet,
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        proxies: [proxies.proxyForStubby],
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              proxySnippet,
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      },
      integrate: {
        proxies: [proxies.proxyForDropwizard],
        options: {
          open: true,
          base: '<%= yeoman.dist %>',
          middleware: function (connect, options) {
            return [
              // Include the proxy first
              proxySnippet,
              // Serve static files.
              connect.static(String(options.base)),
              // Make empty directories browsable.
              connect.directory(String(options.base))
            ];
          }
        }
      }
    },

    stubby: {
      stubsServer: {
        files: [{
          src: ['stubs/*.{json,yaml,js}']
        }],
        options: {
          stubs: 8090,
          relativeFilesPath: 'stubs/'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/{,*/}*',
            '!<%= yeoman.dist %>/.git{,*/}*'
          ]
        }]
      },
      server: '.tmp',
      generatedJs: {
        files: [{
          src: ['<%= yeoman.app %>/scripts/{,*/}*.js']
        }]
      },
      generatedTestJs: {
        files: [{
          src: ['test/spec/{,*/}*.js']
        }]
      }
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath: /\.\.\//
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= yeoman.dist %>/scripts/{,*/}*.js',
          '<%= yeoman.dist %>/styles/{,*/}*.css',
          '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= yeoman.dist %>/styles/fonts/*'
        ]
      }
    },

    // 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: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

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

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ng-annotate tries to make the code safe for minification automatically
    // by using the Angular long form for dependency injection.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: ['*.js', '!oldieshim.js'],
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/{,*/}*.*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: 'bower_components/bootstrap/dist',
          src: 'fonts/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }
    if (target === 'integrate') {
      return grunt.task.run(['build', 'configureProxies:integrate', 'connect:integrate:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'babel:prod',
      'wiredep',
      'configureProxies:livereload',
      'concurrent:server',
      'autoprefixer',
      'stubby',
      'connect:livereload',
      'watch',
      'clean:generatedJs'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'babel:prod',
    'babel:tests',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma',
    'clean:generatedJs',
    'clean:generatedTestJs'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'babel:prod',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin',
    'clean:generatedJs'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>removed appConfig variable from gruntfile<commit_after>// Generated on 2014-11-25 using generator-angular 0.10.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
  var proxies = require('./config/grunt/proxies');
  var appConfig = require('./config/grunt/appConfig');

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

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

  var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      babel: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.es6'],
        tasks: ['newer:babel:prod'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      babelTest:{
        files: ['test/spec/{,*/}*.es6'],
        tasks: ['newer:babel:tests']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    babel: {
      options: {
        sourceMap: false
      },
      prod: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts/',
          src: ['{,*/}*.es6'],
          dest: '<%= yeoman.app %>/scripts/',
          ext: '.js'
        }]
      },
      tests: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: ['{,*/}*.es6'],
          dest: 'test/spec/',
          ext: '.js'
        }]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        proxies: [proxies.proxyForStubby],
        options: {
          open: true,
          middleware: function (connect) {
            // if (!Array.isArray(options.base)) {
            //     options.base = [options.base];
            // }
            // var middlewares = [ proxyForStubby ];

            // // Serve static files.
            // options.base.forEach(function(base) {
            //     middlewares.push(connect.static(base));
            // });

            // // Make directory browse-able.
            // var directory = options.directory || options.base[options.base.length - 1];
            // middlewares.push(connect.directory(directory));

            // return middlewares;
            return [
              proxySnippet,
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      test: {
        proxies: [proxies.proxyForStubby],
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              proxySnippet,
              connect.static('.tmp'),
              connect.static('test'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
      dist: {
        options: {
          open: true,
          base: '<%= yeoman.dist %>'
        }
      },
      integrate: {
        proxies: [proxies.proxyForDropwizard],
        options: {
          open: true,
          base: '<%= yeoman.dist %>',
          middleware: function (connect, options) {
            return [
              // Include the proxy first
              proxySnippet,
              // Serve static files.
              connect.static(String(options.base)),
              // Make empty directories browsable.
              connect.directory(String(options.base))
            ];
          }
        }
      }
    },

    stubby: {
      stubsServer: {
        files: [{
          src: ['stubs/*.{json,yaml,js}']
        }],
        options: {
          stubs: 8090,
          relativeFilesPath: 'stubs/'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/{,*/}*',
            '!<%= yeoman.dist %>/.git{,*/}*'
          ]
        }]
      },
      server: '.tmp',
      generatedJs: {
        files: [{
          src: ['<%= yeoman.app %>/scripts/{,*/}*.js']
        }]
      },
      generatedTestJs: {
        files: [{
          src: ['test/spec/{,*/}*.js']
        }]
      }
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath: /\.\.\//
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= yeoman.dist %>/scripts/{,*/}*.js',
          '<%= yeoman.dist %>/styles/{,*/}*.css',
          '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
          '<%= yeoman.dist %>/styles/fonts/*'
        ]
      }
    },

    // 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: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

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

    // The following *-min tasks will produce minified files in the dist folder
    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          conservativeCollapse: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ng-annotate tries to make the code safe for minification automatically
    // by using the Angular long form for dependency injection.
    ngAnnotate: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: ['*.js', '!oldieshim.js'],
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/{,*/}*.*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }, {
          expand: true,
          cwd: 'bower_components/bootstrap/dist',
          src: 'fonts/*',
          dest: '<%= yeoman.dist %>'
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }
    if (target === 'integrate') {
      return grunt.task.run(['build', 'configureProxies:integrate', 'connect:integrate:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'babel:prod',
      'wiredep',
      'configureProxies:livereload',
      'concurrent:server',
      'autoprefixer',
      'stubby',
      'connect:livereload',
      'watch',
      'clean:generatedJs'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'babel:prod',
    'babel:tests',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma',
    'clean:generatedJs',
    'clean:generatedTestJs'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'babel:prod',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin',
    'clean:generatedJs'
  ]);

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


<commit_before>var _ = require('underscore');
var yaml = require('js-yaml');
var http = require('http');
var url = require('url');
var fs = require('fs');
var completer = require('./placesindex/completer.js');

// Load places db
try {
    var config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8'));
    var places = JSON.parse(fs.readFileSync(config.paths.placesdb, 'utf8'));
} catch (err) {
    console.error(err);
    process.exit(1);
}

// Strips everything but title and ID from search results
function getIds(results) {
    var output = [];

    results.forEach(function(obj) {
	output.push({title: obj['title'], id: obj['id']});
    });

    return output;
}

// Create JSend style output object
function jsendOutput(status, dataFieldName, data) {
    var output = {status: status, data:{}};
    output['data'][dataFieldName] = data;
    return output;
}

// Send response to client
function respond(res, code, data) {
    res.writeHead(code, {'Content-Type': 'application/json'});
    res.write(JSON.stringify(data));
    res.end();
}

// Validate numbers
function isNumber(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

// HTTP server
console.log('Starting placequery server');
console.log('There are ' + _.size(places['all']) + ' places in the database.');

var server = http.createServer(function(req, res) {
    var parsedUrl = url.parse(req.url, true);

    // Log query
    if(config.log.verbose) {
	console.log('Processing query');
	for(get in parsedUrl['query']) {
	    console.log(get + ": " + parsedUrl['query'][get]);
	}
    }

    // Searching by text
    searchQuery = parsedUrl['query']['search'];
    if(searchQuery != undefined) {
	var results = getIds(completer.complete(places, searchQuery));
	var output = jsendOutput("success", "places", results);
	respond(res, 200, output);
	return;
    }

    // Searching by location
    lonQuery = parsedUrl['query']['longitude'];
    latQuery = parsedUrl['query']['latitude'];
    if(lonQuery != undefined && latQuery != undefined) {
	if(isNumber(lonQuery) && isNumber(latQuery)) {
	    var results = getIds(completer.nearby(places, latQuery, lonQuery, config.limits.nearby));
	    var output = jsendOutput("success", "places", results);
	    respond(res, 200, output);
	} else {
	    var output = jsendOutput("fail", "message", "Longitude and latitude arguments must be numbers");
	    respond(res, 400, output);
	}
	return;
    }

    // Get specific place by ID
    idQuery = parsedUrl['query']['id'];
    if(idQuery != undefined) {
	var place = places['all'][idQuery];
	if(place != undefined) {
	    var output = jsendOutput("success", "place", place);
	    respond(res, 200, output);
	} else {
	    var output = jsendOutput("fail", "message", "Invalid ID");
	    respond(res, 404, output);
	}
	return;
    }

    // No valid query
    var output = jsendOutput("fail", "message", "No valid query supplied");
    respond(res, 400, output);
});

server.listen(config.server.port, config.server.address);
console.log('Server listening on port ' + config.server.port);
<commit_msg>Fix comment; all single-quotes<commit_after>var _ = require('underscore');
var yaml = require('js-yaml');
var http = require('http');
var url = require('url');
var fs = require('fs');
var completer = require('./placesindex/completer.js');

// Load config & places db
try {
    var config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8'));
    var places = JSON.parse(fs.readFileSync(config.paths.placesdb, 'utf8'));
} catch (err) {
    console.error(err);
    process.exit(1);
}

// Strips everything but title and ID from search results
function getIds(results) {
    var output = [];

    results.forEach(function(obj) {
	output.push({title: obj['title'], id: obj['id']});
    });

    return output;
}

// Create JSend style output object
function jsendOutput(status, dataFieldName, data) {
    var output = {status: status, data:{}};
    output['data'][dataFieldName] = data;
    return output;
}

// Send response to client
function respond(res, code, data) {
    res.writeHead(code, {'Content-Type': 'application/json'});
    res.write(JSON.stringify(data));
    res.end();
}

// Validate numbers
function isNumber(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

// HTTP server
console.log('Starting placequery server');
console.log('There are ' + _.size(places['all']) + ' places in the database.');

var server = http.createServer(function(req, res) {
    var parsedUrl = url.parse(req.url, true);

    // Log query
    if(config.log.verbose) {
	console.log('Processing query');
	for(get in parsedUrl['query']) {
	    console.log(get + ': ' + parsedUrl['query'][get]);
	}
    }

    // Searching by text
    searchQuery = parsedUrl['query']['search'];
    if(searchQuery != undefined) {
	var results = getIds(completer.complete(places, searchQuery));
	var output = jsendOutput('success', 'places', results);
	respond(res, 200, output);
	return;
    }

    // Searching by location
    lonQuery = parsedUrl['query']['longitude'];
    latQuery = parsedUrl['query']['latitude'];
    if(lonQuery != undefined && latQuery != undefined) {
	if(isNumber(lonQuery) && isNumber(latQuery)) {
	    var results = getIds(completer.nearby(places, latQuery, lonQuery, config.limits.nearby));
	    var output = jsendOutput('success', 'places', results);
	    respond(res, 200, output);
	} else {
	    var output = jsendOutput('fail', 'message', 'Longitude and latitude arguments must be numbers');
	    respond(res, 400, output);
	}
	return;
    }

    // Get specific place by ID
    idQuery = parsedUrl['query']['id'];
    if(idQuery != undefined) {
	var place = places['all'][idQuery];
	if(place != undefined) {
	    var output = jsendOutput('success', 'place', place);
	    respond(res, 200, output);
	} else {
	    var output = jsendOutput('fail', 'message', 'Invalid ID');
	    respond(res, 404, output);
	}
	return;
    }

    // No valid query
    var output = jsendOutput('fail', 'message', 'No valid query supplied');
    respond(res, 400, output);
});

server.listen(config.server.port, config.server.address);
console.log('Server listening on port ' + config.server.port);
<|endoftext|>


<commit_before>module.exports = function (grunt) {
    'use strict';
    var extend = require('util')._extend;
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        imageoptim: {
            files: [
                'app/assets/images'
            ],
            options: {
                // also run images through ImageAlpha.app before ImageOptim.app
                imageAlpha: true,
                // also run images through JPEGmini.app after ImageOptim.app
                jpegMini: true,
                // quit all apps after optimisation
                quitAfter: true
            }
        },
        grunticon: {
            active: {
                files: [{
                    expand: true,
                    cwd: "app/assets/images/icons/active",
                    dest: "app/assets/stylesheets/icons",
                    src: ["*.svg", "*.png"]
                }],
                options: {
                    cssprefix: "icon--",
                    customselectors: {
                        "*": [".$1--before:before, .$1--after:after"]
                    },
                    datasvgcss: "active.css",
                    datapngcss: "active.png.css",
                    urlpngcss: "active.fallback.css"
                }
            },
            critical: {
                files: [{
                    expand: true,
                    cwd: "app/assets/images/icons/active",
                    dest: "app/assets/stylesheets/icons",
                    src: ["*.svg", "*.png"]
                }],
                options: {
                    cssprefix: "icon--",
                    customselectors: {
                        "*": [".$1--before:before, .$1--after:after"]
                    },
                    datasvgcss: "critical.svg.css",
                    datapngcss: "critical.png.css",
                    urlpngcss: "critical.css"
                }
            }
        },
        svgmin: {
            options: {
                plugins: [{
                    removeViewBox: false
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: './app/assets/images/icons/active',
                    src: ['*.svg'],
                    dest: './app/assets/images/icons/active',
                    ext: '.svg'
                }]
            }
        },
        shell: {
            clean_icons: {
                command: 'rm -rf app/assets/images/icons/png'
            },
            clean_js: {
                command: 'rm -rf public/assets/javascripts'
            },
            move: {
                command: 'mv app/assets/stylesheets/icons/png/  app/assets/images/icons/png/'
            },
            openPlato: {
                command: 'open .plato/index.html'
            },
            cat_styles: {
                command: 'cat app/assets/stylesheets/icons/critical.svg.css >> app/assets/stylesheets/icons/active.css'
            }
        },
        coffee: {
            compile: {
                files: [{
                    expand: true,
                    cwd: './app/assets/javascripts/lib',
                    src: ['**/*.coffee', '**/**/*.coffee'],
                    dest: './public/assets/javascripts/lib',
                    ext: '.js'
                }, {
                    expand: true,
                    cwd: './spec/javascripts/lib',
                    src: ['**/*.coffee'],
                    dest: './public/assets/javascripts/spec',
                    ext: '.js'
                }]
            }
        },
        connect: {
            server: {
                options: {
                    hostname: "127.0.0.1",
                    port: 8888
                }
            }
        },
        open: {
            jasmine: {
                path: 'http://127.0.0.1:8888/_SpecRunner.html'
            }
        },
        jasmine: {
            rizzo: {
                src: ['./public/assets/javascripts/lib/**/*.js'],
                options: {
                    helpers: ['./spec/javascripts/helpers/**/*.js', './vendor/assets/javascripts/jquery/jquery-1.7.2.min.js'],
                    host: 'http://127.0.0.1:8888/',
                    specs: './public/assets/javascripts/spec/**/*.js',
                    template: require('grunt-template-jasmine-requirejs'),
                    templateOptions: {
                        requireConfig: {
                            baseUrl: './',
                            paths: {
                                jquery: './vendor/assets/javascripts/jquery/jquery-1.7.2.min',
                                jsmin: './vendor/assets/javascripts/lonelyplanet_minjs/dist/$',
                                polyfills: './vendor/assets/javascripts/polyfills',
                                lib: './public/assets/javascripts/lib',
                                jplugs: './vendor/assets/javascripts/jquery/plugins',
                                s_code: './vendor/assets/javascripts/omniture/s_code',
                                maps_infobox: './vendor/assets/javascripts/google-maps-infobox',
                                gpt: 'http://www.googletagservices.com/tag/js/gpt'
                            }
                        }
                    }
                }
            }
        },
        watch: {
            scripts: {
                files: ['app/assets/javascripts/lib/**/*.coffee', 'spec/javascripts/lib/**/*.coffee'],
                tasks: ['shell:clean_js', 'newer:coffee', 'jasmine'],
                options: {
                    nospawn: true
                }
            }
        },
        plato: {
            rizzo: {
                files: {
                    '.plato/': ['./public/assets/javascripts/**/*.js']
                }
            }
        }

    });

    // This loads in all the grunt tasks auto-magically.
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Tasks
    grunt.registerTask('default', ['shell:clean_js', 'coffee', 'connect', 'jasmine']);
    grunt.registerTask('ci', ['coffee', 'connect', 'jasmine']);
    grunt.registerTask('dev', ['connect', 'open:jasmine', 'jasmine', 'watch']);
    grunt.registerTask('wip', ['jasmine:rizzo:build', 'open:jasmine', 'connect:server:keepalive']);
    grunt.registerTask('report', ['shell:clean_js', 'coffee', 'plato', 'shell:openPlato']);
    grunt.registerTask('imageoptim', ['imageoptim']);
    grunt.registerTask('icon', ['svgmin', 'grunticon', 'shell:clean_icons', 'shell:move']);
};
<commit_msg>Gah... fix missing `.` in cssprefix.<commit_after>module.exports = function (grunt) {
    'use strict';
    var extend = require('util')._extend;
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        imageoptim: {
            files: [
                'app/assets/images'
            ],
            options: {
                // also run images through ImageAlpha.app before ImageOptim.app
                imageAlpha: true,
                // also run images through JPEGmini.app after ImageOptim.app
                jpegMini: true,
                // quit all apps after optimisation
                quitAfter: true
            }
        },
        grunticon: {
            active: {
                files: [{
                    expand: true,
                    cwd: "app/assets/images/icons/active",
                    dest: "app/assets/stylesheets/icons",
                    src: ["*.svg", "*.png"]
                }],
                options: {
                    cssprefix: ".icon--",
                    customselectors: {
                        "*": [".$1--before:before, .$1--after:after"]
                    },
                    datasvgcss: "active.css",
                    datapngcss: "active.png.css",
                    urlpngcss: "active.fallback.css"
                }
            },
            critical: {
                files: [{
                    expand: true,
                    cwd: "app/assets/images/icons/active",
                    dest: "app/assets/stylesheets/icons",
                    src: ["*.svg", "*.png"]
                }],
                options: {
                    cssprefix: ".icon--",
                    customselectors: {
                        "*": [".$1--before:before, .$1--after:after"]
                    },
                    datasvgcss: "critical.svg.css",
                    datapngcss: "critical.png.css",
                    urlpngcss: "critical.css"
                }
            }
        },
        svgmin: {
            options: {
                plugins: [{
                    removeViewBox: false
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: './app/assets/images/icons/active',
                    src: ['*.svg'],
                    dest: './app/assets/images/icons/active',
                    ext: '.svg'
                }]
            }
        },
        shell: {
            clean_icons: {
                command: 'rm -rf app/assets/images/icons/png'
            },
            clean_js: {
                command: 'rm -rf public/assets/javascripts'
            },
            move: {
                command: 'mv app/assets/stylesheets/icons/png/  app/assets/images/icons/png/'
            },
            openPlato: {
                command: 'open .plato/index.html'
            },
            cat_styles: {
                command: 'cat app/assets/stylesheets/icons/critical.svg.css >> app/assets/stylesheets/icons/active.css'
            }
        },
        coffee: {
            compile: {
                files: [{
                    expand: true,
                    cwd: './app/assets/javascripts/lib',
                    src: ['**/*.coffee', '**/**/*.coffee'],
                    dest: './public/assets/javascripts/lib',
                    ext: '.js'
                }, {
                    expand: true,
                    cwd: './spec/javascripts/lib',
                    src: ['**/*.coffee'],
                    dest: './public/assets/javascripts/spec',
                    ext: '.js'
                }]
            }
        },
        connect: {
            server: {
                options: {
                    hostname: "127.0.0.1",
                    port: 8888
                }
            }
        },
        open: {
            jasmine: {
                path: 'http://127.0.0.1:8888/_SpecRunner.html'
            }
        },
        jasmine: {
            rizzo: {
                src: ['./public/assets/javascripts/lib/**/*.js'],
                options: {
                    helpers: ['./spec/javascripts/helpers/**/*.js', './vendor/assets/javascripts/jquery/jquery-1.7.2.min.js'],
                    host: 'http://127.0.0.1:8888/',
                    specs: './public/assets/javascripts/spec/**/*.js',
                    template: require('grunt-template-jasmine-requirejs'),
                    templateOptions: {
                        requireConfig: {
                            baseUrl: './',
                            paths: {
                                jquery: './vendor/assets/javascripts/jquery/jquery-1.7.2.min',
                                jsmin: './vendor/assets/javascripts/lonelyplanet_minjs/dist/$',
                                polyfills: './vendor/assets/javascripts/polyfills',
                                lib: './public/assets/javascripts/lib',
                                jplugs: './vendor/assets/javascripts/jquery/plugins',
                                s_code: './vendor/assets/javascripts/omniture/s_code',
                                maps_infobox: './vendor/assets/javascripts/google-maps-infobox',
                                gpt: 'http://www.googletagservices.com/tag/js/gpt'
                            }
                        }
                    }
                }
            }
        },
        watch: {
            scripts: {
                files: ['app/assets/javascripts/lib/**/*.coffee', 'spec/javascripts/lib/**/*.coffee'],
                tasks: ['shell:clean_js', 'newer:coffee', 'jasmine'],
                options: {
                    nospawn: true
                }
            }
        },
        plato: {
            rizzo: {
                files: {
                    '.plato/': ['./public/assets/javascripts/**/*.js']
                }
            }
        }

    });

    // This loads in all the grunt tasks auto-magically.
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Tasks
    grunt.registerTask('default', ['shell:clean_js', 'coffee', 'connect', 'jasmine']);
    grunt.registerTask('ci', ['coffee', 'connect', 'jasmine']);
    grunt.registerTask('dev', ['connect', 'open:jasmine', 'jasmine', 'watch']);
    grunt.registerTask('wip', ['jasmine:rizzo:build', 'open:jasmine', 'connect:server:keepalive']);
    grunt.registerTask('report', ['shell:clean_js', 'coffee', 'plato', 'shell:openPlato']);
    grunt.registerTask('imageoptim', ['imageoptim']);
    grunt.registerTask('icon', ['svgmin', 'grunticon', 'shell:clean_icons', 'shell:move']);
};
<|endoftext|>


<commit_before>// Generated on 2014-05-05 using generator-angular 0.8.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

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

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      coffee: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
        tasks: ['newer:coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
        tasks: ['newer:coffee:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '.tmp/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      proxies: [
        {
          context: '/api',
          host: 'localhost',
          port: 5000,
          https: false,
          changeOrigin: false
        }
      ],
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ],
          middleware: function (connect, options) {
            if (!Array.isArray(options.base)) {
              options.base = [options.base];
            }

            // Setup the proxy
            var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

            // Serve static files.
            options.base.forEach(function(base) {
              middlewares.push(connect.static(base));
            });

            // Make directory browse-able.
            var directory = options.directory || options.base[options.base.length - 1];
            middlewares.push(connect.directory(directory));

            return middlewares;
          }
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js'
      ]
    },

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

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Compiles CoffeeScript to JavaScript
    coffee: {
      options: {
        sourceMap: true,
        sourceRoot: ''
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // 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: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

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

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= yeoman.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{png,jpg,jpeg,gif,webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'coffee:dist',
        'copy:styles'
      ],
      test: [
        'coffee',
        'copy:styles'
      ],
      dist: [
        'coffee',
        'copy:styles',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

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

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

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

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

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Simplify livereload middleware configuration for proxy<commit_after>// Generated on 2014-05-05 using generator-angular 0.8.0
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

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

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

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      coffee: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
        tasks: ['newer:coffee:dist']
      },
      coffeeTest: {
        files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
        tasks: ['newer:coffee:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '.tmp/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      proxies: [
        {
          context: '/api',
          host: 'localhost',
          port: 5000,
          https: false,
          changeOrigin: false
        }
      ],
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ],
          middleware: function (connect) {
            return [
              require('grunt-connect-proxy/lib/utils').proxyRequest,
              connect.static(require('path').resolve('.tmp')),
              connect.static(require('path').resolve('app'))
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js'
      ]
    },

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

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Compiles CoffeeScript to JavaScript
    coffee: {
      options: {
        sourceMap: true,
        sourceRoot: ''
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // 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: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

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

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= yeoman.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{png,jpg,jpeg,gif,webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'coffee:dist',
        'copy:styles'
      ],
      test: [
        'coffee',
        'copy:styles'
      ],
      dist: [
        'coffee',
        'copy:styles',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

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

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

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

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

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

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


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

  require('shelljs/global');

  /* Inputs and outputs */

  // The source file compilation order is important.
  SOURCE = [
    'src/rimu.ts',
    'src/helpers.ts',
    'src/options.ts',
    'src/io.ts',
    'src/macros.ts',
    'src/lineblocks.ts',
    'src/delimitedblocks.ts',
    'src/lists.ts',
    'src/spans.ts',
    'src/quotes.ts',
    'src/replacements.ts'
  ];

  TESTS = ls('test/*.js');

  DOCS = [
    {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup'},
    {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips'},
    {src: 'doc/showcase.rmu', dst: 'doc/showcase.html', title: 'Rimu Showcase'}
  ];

  PKG = grunt.file.readJSON('package.json');

  /* Tasks */

  grunt.registerTask('default', ['compile', 'lint', 'uglify', 'test', 'docs']);

  grunt.registerTask('lint', 'Lint Javascript and JSON files', function() {
    exec('jshint ' + TESTS.join(' ') + ' bin/rimuc.js');
    exec('jsonlint --quiet package.json');
  });

  grunt.registerTask('compile', 'Compile Typescript to JavaScript then uglify', function() {
    exec('tsc --declaration --out bin/rimu.js ' + SOURCE.join(' '));
  });

  grunt.registerTask('uglify', 'Minimize compiled JavaScript', function() {
    var preamble = '/* ' + PKG.name + ' ' + PKG.version + ' (' + PKG.repository.url + ') */';
    exec('uglifyjs --preamble "' + preamble + '" bin/rimu.js', {silent: true})
        .output
        .to('bin/rimu.min.js');
  });

  grunt.registerTask('test', 'Run unit tests', function() {
    TESTS.forEach(function(file) {
      exec('nodeunit ' + file);
    });
  });

  grunt.registerTask('docs', 'Generate HTML documentation', function() {
    DOCS.forEach(function(doc) {
      exec('node ./bin/rimuc.js --output ' + doc.dst
              + ' --prepend "{--title}=\'' + doc.title + '\'"'
              + ' doc/doc-header.rmu ' + doc.src + ' doc/doc-footer.rmu'
      )
    });
  });

  grunt.registerTask('version', 'Display or update (--package-version option) the project version number', function() {
    var version = grunt.option('package-version');
    if (!version) {
      echo('\nversion: ' + PKG.version);
    }
    else {
      if (!version.match(/^\d+\.\d+\.\d+$/)) {
        grunt.warn('Invalid version number: ' + version + '\n');
      }
      ['package.json','smart.json'].forEach(function(file) {
        sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', file);
      });
    }
  });

  grunt.registerTask('commit', 'Commit changes to local Git repo', function() {
    var commit_message = grunt.option('m') || grunt.option('message');
    if (!commit_message) {
      grunt.warn('Missing command-line option: -m "commit-message"\n');
    }
    exec('git commit -a -m "' + commit_message + '"');
  });

  grunt.registerTask('push', 'Push local commits to Github', function() {
    exec('git push -u --tags origin master');
  });

  grunt.registerTask('publish', ['push', 'publish-npm', 'publish-meteor']);

  grunt.registerTask('publish-npm', 'Publish to npm', function() {
    exec('npm publish');
  });

  grunt.registerTask('publish-meteor', 'Publish to Meteor', function() {
    exec('mrt publish');
  });

};

<commit_msg>Explicitly reference shelljs methods instead of importing globally.<commit_after>module.exports = function(grunt) {

  var shelljs = require('shelljs');

  /* Inputs and outputs */

  // The source file compilation order is important.
  var SOURCE = [
    'src/rimu.ts',
    'src/helpers.ts',
    'src/options.ts',
    'src/io.ts',
    'src/macros.ts',
    'src/lineblocks.ts',
    'src/delimitedblocks.ts',
    'src/lists.ts',
    'src/spans.ts',
    'src/quotes.ts',
    'src/replacements.ts'
  ];

  var TESTS = shelljs.ls('test/*.js');

  var DOCS = [
    {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup'},
    {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips'},
    {src: 'doc/showcase.rmu', dst: 'doc/showcase.html', title: 'Rimu Showcase'}
  ];

  var PKG = grunt.file.readJSON('package.json');

  /* Tasks */

  grunt.registerTask('default', ['compile', 'lint', 'uglify', 'test', 'docs']);

  grunt.registerTask('lint', 'Lint Javascript and JSON files', function() {
    shelljs.exec('jshint ' + TESTS.join(' ') + ' bin/rimuc.js');
    shelljs.exec('jsonlint --quiet package.json');
  });

  grunt.registerTask('compile', 'Compile Typescript to JavaScript then uglify', function() {
    shelljs.exec('tsc --declaration --out bin/rimu.js ' + SOURCE.join(' '));
  });

  grunt.registerTask('uglify', 'Minimize compiled JavaScript', function() {
    var preamble = '/* ' + PKG.name + ' ' + PKG.version + ' (' + PKG.repository.url + ') */';
    shelljs.exec('uglifyjs --preamble "' + preamble + '" bin/rimu.js', {silent: true})
        .output
        .to('bin/rimu.min.js');
  });

  grunt.registerTask('test', 'Run unit tests', function() {
    TESTS.forEach(function(file) {
      shelljs.exec('nodeunit ' + file);
    });
  });

  grunt.registerTask('docs', 'Generate HTML documentation', function() {
    DOCS.forEach(function(doc) {
      shelljs.exec('node ./bin/rimuc.js --output ' + doc.dst
              + ' --prepend "{--title}=\'' + doc.title + '\'"'
              + ' doc/doc-header.rmu ' + doc.src + ' doc/doc-footer.rmu'
      )
    });
  });

  grunt.registerTask('version', 'Display or update (--package-version option) the project version number', function() {
    var version = grunt.option('package-version');
    if (!version) {
      shelljs.echo('\nversion: ' + PKG.version);
    }
    else {
      if (!version.match(/^\d+\.\d+\.\d+$/)) {
        grunt.warn('Invalid version number: ' + version + '\n');
      }
      ['package.json', 'smart.json'].forEach(function(file) {
        shelljs.sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', file);
      });
    }
  });

  grunt.registerTask('commit', 'Commit changes to local Git repo', function() {
    var commit_message = grunt.option('m') || grunt.option('message');
    if (!commit_message) {
      grunt.warn('Missing command-line option: -m "commit-message"\n');
    }
    shelljs.exec('git commit -a -m "' + commit_message + '"');
  });

  grunt.registerTask('push', 'Push local commits to Github', function() {
    shelljs.exec('git push -u --tags origin master');
  });

  grunt.registerTask('publish', ['push', 'publish-npm', 'publish-meteor']);

  grunt.registerTask('publish-npm', 'Publish to npm', function() {
    shelljs.exec('npm publish');
  });

  grunt.registerTask('publish-meteor', 'Publish to Meteor', function() {
    shelljs.exec('mrt publish');
  });

};

<|endoftext|>


<commit_before>// *************************************************
// INIT CONFIG SETTINGS
// Project specific settings
// *************************************************

var jslib_folder = 'project'; // Javascript lib folder
var scss_folder = 'scss'; // CSS folder
var css_folder = 'css'; // CSS folder
var img_folder = 'images'; // Images folder
var js_folder = 'js'; // JS folder
var project_path = "D:/TFS2012/Hello World/Foo.HelloWorld.Website"; // Full project path (do not include "/" end of path)
var sitecore_path = "C:/Sitecore/HelloWorld/Website"; // Full Sitecore path (do not include "/" end of path)
var watch_scss = ['style.scss', 'normalize.scss', 'print.scss', 'ie-master.scss']; // List of SCSS files
var minify_css = ['style.css']; // List of compiled CSS files for minification (SASS' compressed was unstable)
var net_js = ['custom-net.js']; // Any NET specific JS files (e.g. custom NET validation overrides for better experience)
var watch_coffee = ['project/*.coffee', 'app.coffee', 'lib.coffee']; // List of CoffeeScript files to watch
var copy_js = ["lib.js", "app.js", net_js]; // List of compiled JS files
var app_js = ['app.coffee']; // Main app Coffee file
// List of "mini" Coffee files for concatenation (generating lib.js)
var lib_js = [
            jslib_folder + '/' + 'initfoundation.coffee',
            jslib_folder + '/' + 'general.coffee',
            jslib_folder + '/' + 'mobile.coffee',
            jslib_folder + '/' + 'language-toggler.coffee',
            jslib_folder + '/' + 'mini-basket.coffee',
            jslib_folder + '/' + 'ajax-progress.coffee',
            jslib_folder + '/' + 'lazy-pagination.coffee',
            jslib_folder + '/' + 'product-filter.coffee',
            jslib_folder + '/' + 'share.coffee',
            jslib_folder + '/' + 'newsletter-signup.coffee',
            jslib_folder + '/' + 'sync-height.coffee',
            jslib_folder + '/' + 'product-tabs.coffee',
            jslib_folder + '/' + 'search-tabs.coffee',
            jslib_folder + '/' + 'image-maps.coffee',
            jslib_folder + '/' + 'video-modal.coffee',
            jslib_folder + '/' + 'google-maps.coffee',
            jslib_folder + '/' + 'user-account.coffee',
            jslib_folder + '/' + 'same-address.coffee',
            jslib_folder + '/' + 'currency-conversion.coffee',
            jslib_folder + '/' + 'password-switch.coffee',
            jslib_folder + '/' + 'password-strength.coffee',
            jslib_folder + '/' + 'ecommerce.coffee',
            jslib_folder + '/' + 'toggle-select.coffee'
          ];

// *************************************************
// DO NOT MODIFY ANYTHING BELOW THIS LINE
// Unless you really need to...!
// *************************************************

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    coffee: {
      compile: {
        options: {
          bare: true,
          sourceMap: true
        },
        files: {
          'app.js': app_js,
          'lib.js':  lib_js
        }
      }
    },
    sass: {
      dist: {
        files: [
          { // compile to project css folder
            expand: true,
            cwd: project_path + '/' + scss_folder,
            src: watch_scss,
            dest: project_path + '/' + css_folder,
            ext: '.css'
          },
          { // compile and copy over to sitecore folder
            expand: true,
            cwd: project_path + '/' + scss_folder,
            src: watch_scss,
            dest: sitecore_path + '/' + css_folder,
            ext: '.css'
          }
        ]
      }
    },
    cssmetrics: {
      dev: {
        src: [project_path + '/' + css_folder + '/*.css']
      }
    },
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: project_path + "/" + js_folder + "/",
            src: copy_js,
            dest: sitecore_path + "/" + js_folder + "/",
            filter: "isFile"
          }
        ]
      }
    },
    docco: {
      debug: {
        src: [jslib_folder + '/*.coffee'],
        options: {
          output: 'docs/'
        }
      }
    },
    watch: {
      coffee: {
        files: watch_coffee,
        tasks: ['default']
      },
      sass: {
        files: project_path + '/' + scss_folder + '/**/*.scss',
        tasks: ['sass'],
        options: {
          livereload: true
        }
      }
    },
    grunticon: {
      all: {
        files: [
          {
            expand: true,
            cwd: project_path + '/' + img_path,
            src: ['*.svg'],
            dest: project_path + '/' + img_path
          }
        ],
        options: {
          pngfolder: "_ie"
        }
      }
    },
    cssmin: {
      minify: {
        expand: true,
        cwd: project_path + '/' + css_path + '/',
        src: minify_css,
        dest: project_path + '/' + css_path + '/',
        ext: '.min.css'
      }
    }
  });

  // Load plugins
  require('time-grunt')(grunt);
  require('load-grunt-tasks')(grunt);

  // Default task(s)
  grunt.registerTask('default', ['newer:coffee', 'newer:sass', 'newer:copy', 'newer:docco']);

};
<commit_msg>Update Gruntfile.js<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    globalConfig: grunt.file.readJSON('gruntconfig.json'),
    pkg: grunt.file.readJSON('package.json'),
    coffee: {
      compile: {
        options: {
          bare: true,
          sourceMap: true
        },
        files: {
          'app.js': '<%= globalConfig.app_js %>',
          'lib.js':  '<%= globalConfig.lib_js %>'
        }
      }
    },
    sass: {
      dist: {
        files: [
          { // compile to project css folder
            expand: true,
            cwd: '<%= globalConfig.project_path %>/<%= globalConfig.scss_folder %>',
            src: '<%= globalConfig.watch_scss %>',
            dest: '<%= globalConfig.project_path %>/<%= globalConfig.css_folder %>',
            ext: '.css'
          },
          { // compile and copy over to sitecore folder
            expand: true,
            cwd: '<%= globalConfig.project_path%>/<%= globalConfig.scss_folder %>',
            src: '<%= globalConfig.watch_scss%>',
            dest: '<%= globalConfig.sitecore_path%>/<%= globalConfig.css_folder %>',
            ext: '.css'
          }
        ]
      }
    },
    cssmetrics: {
      dev: {
        src: ['<%= globalConfig.project_path%>/<%= globalConfig.css_folder %>/*.css']
      }
    },
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: '<%= globalConfig.project_path%>/<%= globalConfig.js_folder %>/',
            src: '<%= globalConfig.copy_js',
            dest: '<%= globalConfig.sitecore_path%>/<%= globalConfig.js_folder %>/',
            filter: "isFile"
          }
        ]
      }
    },
    docco: {
      debug: {
        src: ['<%= globalConfig.jsdocs_folder %>/*.coffee'],
        options: {
          output: '<%= globalConfig.jsdocs_folder_output %>/'
        }
      }
    },
    watch: {
      coffee: {
        files: '<%= globalConfig.watch_coffee%>',
        tasks: ['default']
      },
      sass: {
        files: '<%= globalConfig.project_path%>/<%= globalConfig.scss_folder %>/**/*.scss',
        tasks: ['sass'],
        options: {
          livereload: true
        }
      }
    },
    grunticon: {
      all: {
        files: [
          {
            expand: true,
            cwd: '<%= globalConfig.project_path%>/<%= globalConfig.img_folder %>',
            src: ['*.svg'],
            dest: '<%= globalConfig.project_path%>/<%= globalConfig.img_folder %>'
          }
        ],
        options: {
          pngfolder: "_ie"
        }
      }
    },
    cssmin: {
      minify: {
        expand: true,
        cwd: '<%= globalConfig.project_path%>/<%= globalConfig.css_folder %>/',
        src: ['*.css'],
        dest: '<%= globalConfig.project_path%>/<%= globalConfig.css_folder %>/',
        ext: '.min.css'
      }
    }
  });

  // Load plugins
  require('time-grunt')(grunt);
  require('load-grunt-tasks')(grunt);

  // Default task(s)
  grunt.registerTask('default', ['newer:coffee', 'newer:sass', 'newer:copy', 'newer:docco']);
};
<|endoftext|>


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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      mini_src: {
        options: {
          banner: '/*! <%= pkg.name %>.min.js v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        },
        files: {
          './<%= pkg.name %>-<%= pkg.version %>.min.js': 'src/<%= pkg.name %>.js'
        }
      }
    },
    less: {
      development: {
       files: {
          "example/styles/clndr.css": "example/styles/clndr.less"
        }
      },
      production: {
        options: {
          compress: true,
          report: "min",
          sourceMap: true
        },
        files: {
          "example/styles/clndr.css": "example/styles/clndr.less"
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      uglify: {
        files: ['src/*.js'],
        tasks: ['uglify'],
        options: {
          spawn: false,
          debounceDelay: 1000 // Don't call uglify more than once per second
        }
      },
      less: {
        files: ['example/styles/*.less'],
        tasks: ['less:development']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['uglify', 'less:development']);

};<commit_msg>Remove version from minified filename<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      mini_src: {
        options: {
          banner: '/*! <%= pkg.name %>.min.js v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
        },
        files: {
          './<%= pkg.name %>.min.js': 'src/<%= pkg.name %>.js'
        }
      }
    },
    less: {
      development: {
       files: {
          "example/styles/clndr.css": "example/styles/clndr.less"
        }
      },
      production: {
        options: {
          compress: true,
          report: "min",
          sourceMap: true
        },
        files: {
          "example/styles/clndr.css": "example/styles/clndr.less"
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      uglify: {
        files: ['src/*.js'],
        tasks: ['uglify'],
        options: {
          spawn: false,
          debounceDelay: 1000 // Don't call uglify more than once per second
        }
      },
      less: {
        files: ['example/styles/*.less'],
        tasks: ['less:development']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['uglify', 'less:development']);

};<|endoftext|>