<commit_before>/*global module:false*/
module.exports = function (grunt) {

  'use strict';

  require('matchdep').filterDev('grunt-*').forEach(function (name) {
    if (!/template/.test(name)) {
      grunt.loadNpmTasks(name);
    }
  });

  grunt.loadNpmTasks('grunt-bulk-symlink');

  var requireConfig = grunt.file.readJSON('./app/js/require.config.json');

  var requireJSPaths = {
    "requireLib": "lib/require",
    "underscore": "components/underscore/underscore-min",
    "backbone": "components/backbone/backbone-min",
    "backbone.localStorage": "components/backbone.localStorage/backbone.localStorage-min",
    "jquery": "components/jquery/jquery.min",
    "jquery.hammer": "components/hammerjs/dist/jquery.hammer.min",
    "backbone.wreqr": "components/backbone.wreqr/lib/amd/backbone.wreqr.min",
    "backbone.babysitter": "components/backbone.babysitter/lib/amd/backbone.babysitter.min",
    "backbone.marionette": "components/backbone.marionette/lib/core/amd/backbone.marionette.min",
    "moment": "components/moment/min/moment.min",
    "morris": "components/morris.js/morris.min",
    "mtchart": "lib/chart-api/core/amd/mtchart.core.amd",
    "main": "js/main",
    "boot": "js/boot",
    "app": "js/app",
    "vendor": "js/vendor",
    "template": "js/template",
    "widget": "js/widget"
  };

  var jasminPathsCoverage = grunt.util._.clone(requireConfig.paths);
  grunt.util._.forIn(jasminPathsCoverage, function (v, k) {
    jasminPathsCoverage[k] = '../../../app/' + v;
  });

  var hbsTemplates = [];
  grunt.util._.forEach(grunt.file.expand('app/js/template/helpers/*.js'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).js/, '$1'));
  });

  grunt.util._.forEach(grunt.file.expand('app/js/**/*.hbs'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
  });

  grunt.util._.forEach(grunt.file.expand('app/assets/**/*.hbs'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
  });

  var widgetLibs = [];
  var widgetTemplates = [];

  grunt.util._.forEach(grunt.file.expand('app/widgets/**/*.*'), function (v) {
    if (!/\/spec\//.test(v)) {
      if (/\.hbs$/.test(v)) {
        widgetTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
      } else if (/\.js$/.test(v)) {
        if (!/templates\/helpers/.test(v)) {
          widgetLibs.push(v.replace(/app\/(.*).js/, '$1'));
        }
      } else if (/\.(txt|text|tmpl|template|html|htm)/.test(v)) {
        widgetTemplates.push(v.replace(/app\/(.*)/, 'text!$1'));
      }
    }
  });

  var widgetLibsForJasmine = grunt.file.expand({
    filter: function (src) {
      return !(/\/spec\//).test(src);
    }
  }, 'app/widgets/**/*.js');

  var specs = [];
  var helpers = ['test/template.js', 'test/helper.js'];
  grunt.util._.forEach(grunt.file.expand('spec/**/*.js').concat(grunt.file.expand('app/widgets/*/spec/*.js')), function (src) {
    if (/_helper.js/.test(src)) {
      helpers.push(src);
    } else {
      specs.push(src);
    }
  });

  var testTarget = ['app/js/app.js', 'app/js/vent.js'].concat(grunt.file.expand('app/js/*/**/*.js')).concat(widgetLibsForJasmine);

  var settings = grunt.file.readJSON('settings.json');

  var bulkSymlinkLinks = grunt.file.expand('app/widgets/*/templates/helpers/*.js').map(function (filename) {
    return '../../../' + filename.replace('app/', '');
  });

  // Project configuration.
  grunt.initConfig({
    jshint: {
      options: grunt.file.readJSON('.jshintrc'),
      gruntfile: {
        options: {
          unused: false,
          evil: true
        },
        files: {
          src: ['Gruntfile.js']
        }
      },
      scripts: {
        files: {
          src: ['app/js/app.js', 'app/js/main.js', 'app/js/*/**/*.js']
        }
      }
    },
    plato: {
      options: {
        jshint: grunt.file.readJSON('.jshintrc')
      },
      files: {
        dest: 'test/reports',
        src: testTarget
      }
    },
    compass: {
      dev: {
        options: {
          sassDir: 'app',
          cssDir: 'app/css',
          specify: ['app/sass/*.scss', 'app/widgets/*/*.scss', 'app/widgets/*/sass/*.scss']
        }
      }
    },
    concat: {
      dev: {
        src: ['app/css/*/**/*.css'],
        dest: 'app/css/style.css'
      }
    },
    cssmin: {
      build: {
        files: {
          'build/css/style.css': ['app/css/*/**/*.css']
        }
      }
    },
    clean: {
      beforeCompass: ['app/css/style.css'],
      build: ['build/*'],
      afterBuild: [
          'build/build.txt',
          'build/components',
          'build/css/*',
          'build/index.html',
          'build/jade',
          'build/js/boot.js',
          'build/js/commands.js',
          'build/js/mtapi',
          'build/js/mtapi.js',
          'build/js/router',
          'build/js/main.js',
          'build/js/main.preprocess.js',
          'build/js/require.config.json',
          'build/js/lib',
          'build/js/layouts',
          'build/js/require.js',
          'build/js/template',
          'build/js/vent.js',
          'build/js/views',
          'build/lib',
          'build/sass',
          'build/template',
          'build/templates',
          'build/widgets',
          'build/assets/icons/index.html',
          'build/assets/icons/license.txt',
          'build/assets/icons/Read Me.txt'
      ],
      afterTest: ['template.js']
    },
    copy: {
      prep: {
        files: [{
            expand: true,
            src: ['app/lib/chart-api/mtchart.css'],
            dest: 'app/css/lib/',
            flatten: true
          }, {
            expand: true,
            src: ['**/app.js', '**/endpoints.js'],
            cwd: settings.mtApiPath,
            dest: 'app/lib/data-api'
          }
        ]
      },
      build: {
        files: [{
            expand: true,
            cwd: 'app/',
            src: ['widgets/**/assets/**'],
            dest: 'build',
            filter: 'isFile'
          }
        ]
      },
      beforeConcat: {
        files: [{
            expand: true,
            cwd: 'app/',
            src: ['widgets/**/*.css'],
            dest: 'app/css',
            filter: 'isFile'
          }
        ]
      }
    },
    symlink: {
      prep: {
        target: 'js/template',
        link: 'app/template',
        options: {
          overwrite: true
        }
      },
      bulkSymlink: {
        target: grunt.option('bulkSymlink'),
        link: 'app/js/template/helpers',
        options: {}
      }
    },
    bulkSymlink: {
      prep: {
        targets: bulkSymlinkLinks
      }
    },
    imagemin: {
      build: {
        files: [{
            expand: true,
            cwd: 'app/images',
            src: '*.{png,jpg,jpeg}',
            dest: 'build/images'
          }
        ]
      }
    },
    watch: {
      index: {
        files: 'app/jade/*.jade',
        tasks: ['jade']
      },
      css: {
        files: [
            'app/sass/*.scss',
            'app/widgets/*/**.scss'
        ],
        tasks: ['clean:beforeCompass', 'compass:dev', 'copy:beforeConcat', 'concat', 'cssmin']
      },
      ie: {
        files: ['app/ie/sass/*.scss'],
        tasks: ['compass:ie']
      }
    },
    preprocess: {
      prep: {
        files: {
          'app/js/main.js': 'app/js/main.preprocess.js'
        }
      }
    },
    connect: {
      server: {
        options: {
          hostname: grunt.option('host'),
          port: 9001,
          keepalive: true
        }
      },
      test: {
        options: {
          hostname: 'localhost',
          port: 9002,
          keepalive: true
        }
      }
    },
    jasmine: {
      test: {
        src: testTarget,
        options: {
          specs: specs,
          helpers: helpers,
          host: 'http://localhost:9002/',
          outfile: '_SpecRunner.html',
          template: require('grunt-template-jasmine-requirejs'),
          templateOptions: {
            requireConfig: {
              baseUrl: './app/',
              paths: requireConfig.paths,
              shim: requireConfig.shim,
              deps: requireConfig.deps,
              locale: requireConfig.locale,
              hbs: requireConfig.hbs
            }
          }
        }
      },
      coverage: {
        src: testTarget,
        options: {
          specs: specs,
          helpers: helpers,
          template: require('grunt-template-jasmine-istanbul'),
          templateOptions: {
            coverage: 'test/coverage/coverage.json',
            report: 'test/coverage',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
              requireConfig: {
                baseUrl: '.grunt/grunt-contrib-jasmine/app/',
                paths: jasminPathsCoverage,
                shim: requireConfig.shim,
                deps: requireConfig.deps,
                locale: requireConfig.locale,
                hbs: requireConfig.hbs
              }
            }
          }
        }
      }
    },
    open: {
      dev: {
        path: 'http://localhost:9001/app/index.html'
      },
      build: {
        path: 'http://localhost:9001/build/index.html'
      },
      test: {
        path: 'http://localhost:9002/test/coverage/index.html'
      }
    },
    'sass-convert': {
      files: {
        src: ['app/sass/*.scss', 'app/widgets/**/*.scss']
      }
    },
    htmlmin: {
      build: {
        options: {
          removeComments: true,
          removeCommentsFromCDATA: true,
          removeCDATASectionsFromCDATA: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true
        },
        files: {
          'build/index.html': 'build/index.html'
        }
      }
    },
    'string-replace': {
      build: {
        options: {
          replacements: [{
              pattern: /([,;])define\(/ig,
              replacement: '$1\ndefine('
            }, {
              pattern: /define\("[\-\.\w\/]*",function\(\)\{\}\);[\n]?/ig,
              replacement: ''
            }, {
              pattern: /;(require\(\["app"\])/,
              replacement: ';\n$1'
            }
          ]
        },
        files: {
          'build/js/app.js': 'build/js/app.js',
          'build/js/template.js': 'build/js/template.js',
          'build/js/vendor.js': 'build/js/vendor.js',
          'build/js/widget.js': 'build/js/widget.js'
        }
      }
    },
    codestyle: {
      dev: {
        files: {
          'app/js/app.js': 'app/js/app.js'
        }
      }
    },
    jade: {
      dev: {
        options: {
          pretty: true,
          data: {
            dev: true,
            mtApiCGIPath: settings.mtApiCGIPath
          }
        },
        files: {
          "app/index.html": "app/jade/index.jade"
        }
      },
      build: {
        options: {
          pretty: true,
          data: {
            dev: false,
            mtApiCGIPath: settings.mtApiCGIPath
          }
        },
        files: {
          "build/index.html": "app/jade/index.jade"
        }
      }
    },
    requirejs: {
      test: {
        options: {
          baseUrl: "app",
          mainConfigFile: 'app/js/main.js',
          name: 'js/template',
          out: 'test/template.js',
          include: ['lib/require', 'json!widgets/stats/settings.json', 'json!widgets/widgets.json'].concat(hbsTemplates).concat(widgetTemplates),
          exclude: ['jquery', 'handlebars', 'hbs'],
          optimize: 'none',
          optimizeCss: 'none'
        }
      },
      build: {
        options: {
          appDir: "app",
          baseUrl: ".",
          mainConfigFile: 'app/js/main.js',
          paths: requireJSPaths,
          dir: "build",
          modules: [{
              name: 'vendor',
              include: [
                  "requireLib",
                  "mtapi",
                  "mtendpoints",
                  "jquery",
                  "jquery.hammer",
                  "jquery.smartresize",
                  "jquery.smartscroll",
                  "underscore",
                  "backbone",
                  "backbone.localStorage",
                  "backbone.wreqr",
                  "backbone.babysitter",
                  "backbone.marionette",
                  "text",
                  "json",
                  "hbs",
                  "handlebars",
                  "i18nprecompile",
                  "json2",
                  "moment",
                  "eve",
                  "raphael",
                  "morris",
                  "easeljs",
                  "mtchart"
              ]
            }, {
              name: 'template',
              include: hbsTemplates,
              exclude: ['vendor']
            }, {
              name: 'app',
              include: ['boot'],
              exclude: ['vendor', 'template']
            }, {
              name: 'widget',
              include: widgetLibs.concat(widgetTemplates),
              exclude: ['vendor', 'template', 'app']
            }
          ],

          skipDirOptimize: true,
          removeCombined: false,
          optimize: "uglify2",
          optimizeCss: "none",

          uglify2: {
            output: {
              beautify: false,
              max_line_len: 1000000
            },
            compress: {
              sequences: false,
              global_defs: {
                DEBUG: false
              },
              unsafe: true
            },
            warnings: true,
            mangle: true,
            unsafe: true
          },

          stubModules: [],

          fileExclusionRegExp: /^\./,

          preserveLicenseComments: true,

          pragmasOnSave: {
            //removes Handlebars.Parser code (used to compile template strings) set
            //it to `false` if you need to parse template strings even after build
            excludeHbsParser: true,
            // kills the entire plugin set once it's built.
            excludeHbs: true,
            // removes i18n precompiler, handlebars and json2
            excludeAfterBuild: true
          },

          locale: "ja_jp",
          // default plugin settings, listing here just as a reference
          hbs: {
            templateExtension: 'hbs',
            // if disableI18n is `true` it won't load locales and the i18n helper
            // won't work as well.
            disableI18n: false
          }
        }
      }
    }
  });

  grunt.registerTask('build', [
      'symlink:prep',
      'copy:prep',
      'clean:build',
      'imagemin',
      'clean:beforeCompass',
      'compass',
      'requirejs:build',
      'clean:afterBuild',
      'string-replace',
      'copy:beforeConcat',
      'cssmin:build',
      'copy:build',
      'jade:build',
      'htmlmin',
      'copy:beforeConcat',
      'concat:dev'
  ]);

  grunt.registerTask('dev', [
      'symlink:prep',
      'copy:prep',
      'jade:dev',
      'compass:dev',
      'copy:beforeConcat',
      'concat:dev'
  ]);

  grunt.registerTask('test', [
      'requirejs:test',
      'jshint',
      'jasmine',
      'clean:afterTest',
      'open:test'
  ]);

  grunt.registerTask('none', []);
};
<commit_msg>remove collections/models directory after grunt build<commit_after>/*global module:false*/
module.exports = function (grunt) {

  'use strict';

  require('matchdep').filterDev('grunt-*').forEach(function (name) {
    if (!/template/.test(name)) {
      grunt.loadNpmTasks(name);
    }
  });

  grunt.loadNpmTasks('grunt-bulk-symlink');

  var requireConfig = grunt.file.readJSON('./app/js/require.config.json');

  var requireJSPaths = {
    "requireLib": "lib/require",
    "underscore": "components/underscore/underscore-min",
    "backbone": "components/backbone/backbone-min",
    "backbone.localStorage": "components/backbone.localStorage/backbone.localStorage-min",
    "jquery": "components/jquery/jquery.min",
    "jquery.hammer": "components/hammerjs/dist/jquery.hammer.min",
    "backbone.wreqr": "components/backbone.wreqr/lib/amd/backbone.wreqr.min",
    "backbone.babysitter": "components/backbone.babysitter/lib/amd/backbone.babysitter.min",
    "backbone.marionette": "components/backbone.marionette/lib/core/amd/backbone.marionette.min",
    "moment": "components/moment/min/moment.min",
    "morris": "components/morris.js/morris.min",
    "mtchart": "lib/chart-api/core/amd/mtchart.core.amd",
    "main": "js/main",
    "boot": "js/boot",
    "app": "js/app",
    "vendor": "js/vendor",
    "template": "js/template",
    "widget": "js/widget"
  };

  var jasminPathsCoverage = grunt.util._.clone(requireConfig.paths);
  grunt.util._.forIn(jasminPathsCoverage, function (v, k) {
    jasminPathsCoverage[k] = '../../../app/' + v;
  });

  var hbsTemplates = [];
  grunt.util._.forEach(grunt.file.expand('app/js/template/helpers/*.js'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).js/, '$1'));
  });

  grunt.util._.forEach(grunt.file.expand('app/js/**/*.hbs'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
  });

  grunt.util._.forEach(grunt.file.expand('app/assets/**/*.hbs'), function (v) {
    hbsTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
  });

  var widgetLibs = [];
  var widgetTemplates = [];

  grunt.util._.forEach(grunt.file.expand('app/widgets/**/*.*'), function (v) {
    if (!/\/spec\//.test(v)) {
      if (/\.hbs$/.test(v)) {
        widgetTemplates.push(v.replace(/app\/(.*).hbs/, 'hbs!$1'));
      } else if (/\.js$/.test(v)) {
        if (!/templates\/helpers/.test(v)) {
          widgetLibs.push(v.replace(/app\/(.*).js/, '$1'));
        }
      } else if (/\.(txt|text|tmpl|template|html|htm)/.test(v)) {
        widgetTemplates.push(v.replace(/app\/(.*)/, 'text!$1'));
      }
    }
  });

  var widgetLibsForJasmine = grunt.file.expand({
    filter: function (src) {
      return !(/\/spec\//).test(src);
    }
  }, 'app/widgets/**/*.js');

  var specs = [];
  var helpers = ['test/template.js', 'test/helper.js'];
  grunt.util._.forEach(grunt.file.expand('spec/**/*.js').concat(grunt.file.expand('app/widgets/*/spec/*.js')), function (src) {
    if (/_helper.js/.test(src)) {
      helpers.push(src);
    } else {
      specs.push(src);
    }
  });

  var testTarget = ['app/js/app.js', 'app/js/vent.js'].concat(grunt.file.expand('app/js/*/**/*.js')).concat(widgetLibsForJasmine);

  var settings = grunt.file.readJSON('settings.json');

  var bulkSymlinkLinks = grunt.file.expand('app/widgets/*/templates/helpers/*.js').map(function (filename) {
    return '../../../' + filename.replace('app/', '');
  });

  // Project configuration.
  grunt.initConfig({
    jshint: {
      options: grunt.file.readJSON('.jshintrc'),
      gruntfile: {
        options: {
          unused: false,
          evil: true
        },
        files: {
          src: ['Gruntfile.js']
        }
      },
      scripts: {
        files: {
          src: ['app/js/app.js', 'app/js/main.js', 'app/js/*/**/*.js']
        }
      }
    },
    plato: {
      options: {
        jshint: grunt.file.readJSON('.jshintrc')
      },
      files: {
        dest: 'test/reports',
        src: testTarget
      }
    },
    compass: {
      dev: {
        options: {
          sassDir: 'app',
          cssDir: 'app/css',
          specify: ['app/sass/*.scss', 'app/widgets/*/*.scss', 'app/widgets/*/sass/*.scss']
        }
      }
    },
    concat: {
      dev: {
        src: ['app/css/*/**/*.css'],
        dest: 'app/css/style.css'
      }
    },
    cssmin: {
      build: {
        files: {
          'build/css/style.css': ['app/css/*/**/*.css']
        }
      }
    },
    clean: {
      beforeCompass: ['app/css/style.css'],
      build: ['build/*'],
      afterBuild: [
          'build/build.txt',
          'build/components',
          'build/css/*',
          'build/index.html',
          'build/jade',
          'build/js/boot.js',
          'build/js/collections',
          'build/js/models',
          'build/js/commands.js',
          'build/js/mtapi',
          'build/js/mtapi.js',
          'build/js/router',
          'build/js/main.js',
          'build/js/main.preprocess.js',
          'build/js/require.config.json',
          'build/js/lib',
          'build/js/layouts',
          'build/js/require.js',
          'build/js/template',
          'build/js/vent.js',
          'build/js/views',
          'build/lib',
          'build/sass',
          'build/template',
          'build/templates',
          'build/widgets',
          'build/assets/icons/index.html',
          'build/assets/icons/license.txt',
          'build/assets/icons/Read Me.txt'
      ],
      afterTest: ['template.js']
    },
    copy: {
      prep: {
        files: [{
            expand: true,
            src: ['app/lib/chart-api/mtchart.css'],
            dest: 'app/css/lib/',
            flatten: true
          }, {
            expand: true,
            src: ['**/app.js', '**/endpoints.js'],
            cwd: settings.mtApiPath,
            dest: 'app/lib/data-api'
          }
        ]
      },
      build: {
        files: [{
            expand: true,
            cwd: 'app/',
            src: ['widgets/**/assets/**'],
            dest: 'build',
            filter: 'isFile'
          }
        ]
      },
      beforeConcat: {
        files: [{
            expand: true,
            cwd: 'app/',
            src: ['widgets/**/*.css'],
            dest: 'app/css',
            filter: 'isFile'
          }
        ]
      }
    },
    symlink: {
      prep: {
        target: 'js/template',
        link: 'app/template',
        options: {
          overwrite: true
        }
      },
      bulkSymlink: {
        target: grunt.option('bulkSymlink'),
        link: 'app/js/template/helpers',
        options: {}
      }
    },
    bulkSymlink: {
      prep: {
        targets: bulkSymlinkLinks
      }
    },
    imagemin: {
      build: {
        files: [{
            expand: true,
            cwd: 'app/images',
            src: '*.{png,jpg,jpeg}',
            dest: 'build/images'
          }
        ]
      }
    },
    watch: {
      index: {
        files: 'app/jade/*.jade',
        tasks: ['jade']
      },
      css: {
        files: [
            'app/sass/*.scss',
            'app/widgets/*/**.scss'
        ],
        tasks: ['clean:beforeCompass', 'compass:dev', 'copy:beforeConcat', 'concat', 'cssmin']
      },
      ie: {
        files: ['app/ie/sass/*.scss'],
        tasks: ['compass:ie']
      }
    },
    preprocess: {
      prep: {
        files: {
          'app/js/main.js': 'app/js/main.preprocess.js'
        }
      }
    },
    connect: {
      server: {
        options: {
          hostname: grunt.option('host'),
          port: 9001,
          keepalive: true
        }
      },
      test: {
        options: {
          hostname: 'localhost',
          port: 9002,
          keepalive: true
        }
      }
    },
    jasmine: {
      test: {
        src: testTarget,
        options: {
          specs: specs,
          helpers: helpers,
          host: 'http://localhost:9002/',
          outfile: '_SpecRunner.html',
          template: require('grunt-template-jasmine-requirejs'),
          templateOptions: {
            requireConfig: {
              baseUrl: './app/',
              paths: requireConfig.paths,
              shim: requireConfig.shim,
              deps: requireConfig.deps,
              locale: requireConfig.locale,
              hbs: requireConfig.hbs
            }
          }
        }
      },
      coverage: {
        src: testTarget,
        options: {
          specs: specs,
          helpers: helpers,
          template: require('grunt-template-jasmine-istanbul'),
          templateOptions: {
            coverage: 'test/coverage/coverage.json',
            report: 'test/coverage',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
              requireConfig: {
                baseUrl: '.grunt/grunt-contrib-jasmine/app/',
                paths: jasminPathsCoverage,
                shim: requireConfig.shim,
                deps: requireConfig.deps,
                locale: requireConfig.locale,
                hbs: requireConfig.hbs
              }
            }
          }
        }
      }
    },
    open: {
      dev: {
        path: 'http://localhost:9001/app/index.html'
      },
      build: {
        path: 'http://localhost:9001/build/index.html'
      },
      test: {
        path: 'http://localhost:9002/test/coverage/index.html'
      }
    },
    'sass-convert': {
      files: {
        src: ['app/sass/*.scss', 'app/widgets/**/*.scss']
      }
    },
    htmlmin: {
      build: {
        options: {
          removeComments: true,
          removeCommentsFromCDATA: true,
          removeCDATASectionsFromCDATA: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true
        },
        files: {
          'build/index.html': 'build/index.html'
        }
      }
    },
    'string-replace': {
      build: {
        options: {
          replacements: [{
              pattern: /([,;])define\(/ig,
              replacement: '$1\ndefine('
            }, {
              pattern: /define\("[\-\.\w\/]*",function\(\)\{\}\);[\n]?/ig,
              replacement: ''
            }, {
              pattern: /;(require\(\["app"\])/,
              replacement: ';\n$1'
            }
          ]
        },
        files: {
          'build/js/app.js': 'build/js/app.js',
          'build/js/template.js': 'build/js/template.js',
          'build/js/vendor.js': 'build/js/vendor.js',
          'build/js/widget.js': 'build/js/widget.js'
        }
      }
    },
    codestyle: {
      dev: {
        files: {
          'app/js/app.js': 'app/js/app.js'
        }
      }
    },
    jade: {
      dev: {
        options: {
          pretty: true,
          data: {
            dev: true,
            mtApiCGIPath: settings.mtApiCGIPath
          }
        },
        files: {
          "app/index.html": "app/jade/index.jade"
        }
      },
      build: {
        options: {
          pretty: true,
          data: {
            dev: false,
            mtApiCGIPath: settings.mtApiCGIPath
          }
        },
        files: {
          "build/index.html": "app/jade/index.jade"
        }
      }
    },
    requirejs: {
      test: {
        options: {
          baseUrl: "app",
          mainConfigFile: 'app/js/main.js',
          name: 'js/template',
          out: 'test/template.js',
          include: ['lib/require', 'json!widgets/stats/settings.json', 'json!widgets/widgets.json'].concat(hbsTemplates).concat(widgetTemplates),
          exclude: ['jquery', 'handlebars', 'hbs'],
          optimize: 'none',
          optimizeCss: 'none'
        }
      },
      build: {
        options: {
          appDir: "app",
          baseUrl: ".",
          mainConfigFile: 'app/js/main.js',
          paths: requireJSPaths,
          dir: "build",
          modules: [{
              name: 'vendor',
              include: [
                  "requireLib",
                  "mtapi",
                  "mtendpoints",
                  "jquery",
                  "jquery.hammer",
                  "jquery.smartresize",
                  "jquery.smartscroll",
                  "underscore",
                  "backbone",
                  "backbone.localStorage",
                  "backbone.wreqr",
                  "backbone.babysitter",
                  "backbone.marionette",
                  "text",
                  "json",
                  "hbs",
                  "handlebars",
                  "i18nprecompile",
                  "json2",
                  "moment",
                  "eve",
                  "raphael",
                  "morris",
                  "easeljs",
                  "mtchart"
              ]
            }, {
              name: 'template',
              include: hbsTemplates,
              exclude: ['vendor']
            }, {
              name: 'app',
              include: ['boot'],
              exclude: ['vendor', 'template']
            }, {
              name: 'widget',
              include: widgetLibs.concat(widgetTemplates),
              exclude: ['vendor', 'template', 'app']
            }
          ],

          skipDirOptimize: true,
          removeCombined: false,
          optimize: "uglify2",
          optimizeCss: "none",

          uglify2: {
            output: {
              beautify: false,
              max_line_len: 1000000
            },
            compress: {
              sequences: false,
              global_defs: {
                DEBUG: false
              },
              unsafe: true
            },
            warnings: true,
            mangle: true,
            unsafe: true
          },

          stubModules: [],

          fileExclusionRegExp: /^\./,

          preserveLicenseComments: true,

          pragmasOnSave: {
            //removes Handlebars.Parser code (used to compile template strings) set
            //it to `false` if you need to parse template strings even after build
            excludeHbsParser: true,
            // kills the entire plugin set once it's built.
            excludeHbs: true,
            // removes i18n precompiler, handlebars and json2
            excludeAfterBuild: true
          },

          locale: "ja_jp",
          // default plugin settings, listing here just as a reference
          hbs: {
            templateExtension: 'hbs',
            // if disableI18n is `true` it won't load locales and the i18n helper
            // won't work as well.
            disableI18n: false
          }
        }
      }
    }
  });

  grunt.registerTask('build', [
      'symlink:prep',
      'copy:prep',
      'clean:build',
      'imagemin',
      'clean:beforeCompass',
      'compass',
      'requirejs:build',
      'clean:afterBuild',
      'string-replace',
      'copy:beforeConcat',
      'cssmin:build',
      'copy:build',
      'jade:build',
      'htmlmin',
      'copy:beforeConcat',
      'concat:dev'
  ]);

  grunt.registerTask('dev', [
      'symlink:prep',
      'copy:prep',
      'jade:dev',
      'compass:dev',
      'copy:beforeConcat',
      'concat:dev'
  ]);

  grunt.registerTask('test', [
      'requirejs:test',
      'jshint',
      'jasmine',
      'clean:afterTest',
      'open:test'
  ]);

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


<commit_before>var path = require('path');

module.exports = function(grunt) {
  const asset_dir = '_assets';
  const build_dir = 'dist';

  function path_from_type(asset) {
    const path_map = {
      'css': 'css',
      'scss': 'sass',
      'js': 'js'
    };
    const default_path = 'assets';

    var type = path.extname(asset).substr(1);
    var type_path = (function() {
      if (path_map[type])
        return path_map[type];
      else
        return default_path;
    })();
    return type_path ? path.join(type_path, asset) : asset;
  }

  function asset_path(asset) {
    return path.join(asset_dir, path_from_type(asset));
  }
  function build_path(asset) {
    return path.join(build_dir, asset);
  }

  // Load all NPM grunt tasks
  require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

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

    meta: {
      scripts: [
        asset_path('**/*.js')
      ],
      styles: [
        asset_path('**/*.scss'),
        asset_path('**/*.css')
      ]
    },

    // Combine JS modules using Browserify
    browserify: {
      options: {
        transform: ['browserify-shim']
      },
      debug: {
        src: [asset_path('main.js')],
        dest: build_path('app.js'),
        options: {
          debug: true
        }
      },
      build: {
        src: [asset_path('main.js')],
        dest: build_path('app.js')
      }
    },

    // Compile Sass files to CSS
    compass: {
      options: {
        sassDir: path.join(asset_dir, 'sass'),
        cssDir: build_dir
      },
      debug: {
        options: {
          // For source maps
          debugInfo: true,
          outputStyle: 'expanded'
        }
      },
      build: {}
    },

    // Concatenate files
    concat: {
      build: {
        src: [asset_path('*.css'), build_path('main.css'), build_path('bigfoot*.css')],
        dest: build_path('style.css')
      }
    },

    // Minify CSS files
    cssmin: {
      build: {
        src: [build_path('style.css')],
        dest: build_path('style.min.css')
      }
    },

    // Minify JS files
    uglify: {
      build: {
        src: [build_path('app.js')],
        dest: build_path('app.min.js')
      }
    },

    copy: {
      assets: {
        expand: true,
        cwd: asset_dir,
        src: ['assets/**'],
        dest: build_dir
      },
      vendor: {
        expand: true,
        cwd: path.join(asset_dir, 'js'),
        src: ['vendor/**'],
        dest: build_dir
      },
    },

    imagemin: {
      options: {
        cache: false
      },
      build: {
        files: [{
          expand: true,
          cwd: path.join(asset_dir, 'assets'),
          src: ['*.jpg', '*.png'],
          dest: build_path('assets')
        }]
      }
    },

    // Clean target directories
    clean: {
      build: [build_dir],
      temp: { expand: true, cwd: build_dir, src: ['*.css', '!style*.css'] },
      all: [build_dir, '_site']
    },

    // Run Jekyll commands
    jekyll: {
      server: {
        options: {
          serve: true,
          watch: true
        }
      },
      build: {},
      production: {
        options: {
          config: ['_config.yml', '_config.production.yml'].join(',')
        }
      },
      prodServer: {
        options: {
          config: ['_config.yml', '_config.production.yml'].join(','),
          serve: true,
          watch: true
        }
      }
    },

    // Watch files for changes
    watch: {
      scripts: {
        files: ['<%= meta.scripts %>'],
        tasks: ['browserify:debug']
      },
      styles: {
        files: ['<%= meta.styles %>'],
        tasks: ['compass:debug', 'concat:build']
      },
      assets: {
        files: [path.join(asset_dir, 'assets/**/*')],
        tasks: ['copy:assets']
      },
      livereload: {
        // everything is regenerated on build, so we only need to watch one file
        files: ['_site/index.html'],
        options: { livereload: true, debounceDelay: 1000 }
      }
    },

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

    production: {
      fast: [],
      slow: ['imagemin']
    }
  });

  // Compile JS & CSS, run watch to recompile on change
  grunt.registerTask('debug', function() {
    grunt.task.run([
      'clean:build',
      'compass:debug',
      'browserify:debug',
      'concat:build',
      'copy',
      'clean:temp'
    ]);
    // Watch for changes
    grunt.task.run('concurrent:watch');
  });

  // Compile and minify JS & CSS, run Jekyll build for production
  grunt.registerMultiTask('production', function() {
    var useImagemin = this.data.indexOf('imagemin') !== -1;
    var tasks = [
      'clean:all',
      'compass:build',
      'browserify:build',
      'concat:build',
      'cssmin',
      'uglify',
      'copy',
      'imagemin',
      'clean:temp'
    ].filter(function(task) {
      return (task !== 'imagemin' || useImagemin);
    });

    grunt.task.run(tasks);
  });

  grunt.registerTask('build', [
    'production:fast',
    'jekyll:production'
  ]);

  grunt.registerTask('build-optim', [
    'production:slow',
    'jekyll:production'
  ]);

  // Run Jekyll with environment set to production
  grunt.registerTask('run', [
    'build',
    'jekyll:prodServer'
  ]);

  grunt.registerTask('run-optim', [
    'build-optim',
    'jekyll:prodServer'
  ]);

  grunt.registerTask('default', ['debug']);
};<commit_msg>Cleaned up Gruntfile<commit_after>var path = require('path');

module.exports = function(grunt) {
  const asset_dir = '_assets';
  const build_dir = 'dist';

  function path_from_type(asset) {
    const path_map = {
      'css': 'css',
      'scss': 'sass',
      'js': 'js'
    };
    const default_path = 'assets';

    var type = path.extname(asset).substr(1);
    var type_path = (function() {
      if (path_map[type])
        return path_map[type];
      else
        return default_path;
    })();
    return type_path ? path.join(type_path, asset) : asset;
  }

  function asset_path(asset) {
    return path.join(asset_dir, path_from_type(asset));
  }
  function build_path(asset) {
    return path.join(build_dir, asset);
  }

  // Load all NPM grunt tasks
  require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

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

    meta: {
      scripts: [
        asset_path('**/*.js')
      ],
      styles: [
        asset_path('**/*.scss'),
        asset_path('**/*.css')
      ]
    },

    // Combine JS modules using Browserify
    browserify: {
      options: {
        transform: ['browserify-shim']
      },
      debug: {
        src: [asset_path('main.js')],
        dest: build_path('app.js'),
        options: {
          debug: true
        }
      },
      build: {
        src: [asset_path('main.js')],
        dest: build_path('app.js')
      }
    },

    // Compile Sass files to CSS
    compass: {
      options: {
        sassDir: path.join(asset_dir, 'sass'),
        cssDir: build_dir
      },
      debug: {
        options: {
          // For source maps
          debugInfo: true,
          outputStyle: 'expanded'
        }
      },
      build: {}
    },

    // Concatenate files
    concat: {
      build: {
        src: [asset_path('*.css'), build_path('main.css'), build_path('bigfoot*.css')],
        dest: build_path('style.css')
      }
    },

    // Minify CSS files
    cssmin: {
      build: {
        src: [build_path('style.css')],
        dest: build_path('style.min.css')
      }
    },

    // Minify JS files
    uglify: {
      build: {
        src: [build_path('app.js')],
        dest: build_path('app.min.js')
      }
    },

    copy: {
      assets: {
        expand: true,
        cwd: asset_dir,
        src: ['assets/**'],
        dest: build_dir
      },
      vendor: {
        expand: true,
        cwd: path.join(asset_dir, 'js'),
        src: ['vendor/**'],
        dest: build_dir
      },
    },

    imagemin: {
      options: {
        cache: false
      },
      build: {
        files: [{
          expand: true,
          cwd: path.join(asset_dir, 'assets'),
          src: ['*.jpg', '*.png'],
          dest: build_path('assets')
        }]
      }
    },

    // Clean target directories
    clean: {
      build: [build_dir],
      temp: { expand: true, cwd: build_dir, src: ['*.css', '!style*.css'] },
      all: [build_dir, '_site']
    },

    // Run Jekyll commands
    jekyll: {
      server: {
        options: {
          serve: true,
          watch: true
        }
      },
      build: {},
      production: {
        options: {
          config: ['_config.yml', '_config.production.yml'].join(',')
        }
      },
      prodServer: {
        options: {
          config: ['_config.yml', '_config.production.yml'].join(','),
          serve: true,
          watch: true
        }
      }
    },

    // Watch files for changes
    watch: {
      scripts: {
        files: ['<%= meta.scripts %>'],
        tasks: ['browserify:debug']
      },
      styles: {
        files: ['<%= meta.styles %>'],
        tasks: ['compass:debug', 'concat:build']
      },
      assets: {
        files: [path.join(asset_dir, 'assets/**/*')],
        tasks: ['copy:assets']
      },
      livereload: {
        // everything is regenerated on build, so we only need to watch one file
        files: ['_site/index.html'],
        options: { livereload: true, debounceDelay: 2000 }
      }
    },

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

    production: {
      fast: {exclude: ['imagemin']},
      slow: {}
    }
  });

  // Compile JS & CSS, run watch to recompile on change
  grunt.registerTask('debug', function() {
    grunt.task.run([
      'clean:build',
      'compass:debug',
      'browserify:debug',
      'concat:build',
      'copy',
      'clean:temp'
    ]);
    // Watch for changes
    grunt.task.run('concurrent:watch');
  });

  // Compile and minify JS & CSS, run Jekyll build for production
  grunt.registerMultiTask('production', function() {
    var exclude = this.data.exclude || [];
    var tasks = [
      'clean:all',
      'compass:build',
      'browserify:build',
      'concat:build',
      'cssmin',
      'uglify',
      'copy',
      'imagemin',
      'clean:temp'
    ].filter(function(task) {
      return exclude.indexOf(task) === -1;
    });

    grunt.task.run(tasks);
  });

  grunt.registerTask('build', [
    'production:fast',
    'jekyll:production'
  ]);

  grunt.registerTask('build-optim', [
    'production:slow',
    'jekyll:production'
  ]);

  // Run Jekyll with environment set to production
  grunt.registerTask('run', [
    'production:fast',
    'jekyll:prodServer'
  ]);

  grunt.registerTask('run-optim', [
    'production:slow',
    'jekyll:prodServer'
  ]);

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


<commit_before>// Generated on 2016-01-30 using generator-angular 0.15.1
'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) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn',
    configureProxies: 'grunt-connect-proxy',
    ngconstant: 'grunt-ng-constant'
  });

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

  // 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', 'newer:jscs:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'postcss']
      },
      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}'
        ]
      }
    },
    //ng-constant
    ngconstant: {
      options: {
        name: 'config',
        wrap: '"use strict";\n\n{%= __ngModule %}',
        space: '  '
      },
      development: {
        options: {
          dest: '<%= yeoman.app %>/scripts/config.js',
        },
        constants: {
          ENV: 'development',
          endpointBaseUrl:'https://ttlfc.herokuapp.com/tt'
        }
      },
      production: {
        options: {
          dest: '<%= yeoman.dist %>/scripts/config.js',
        },
        constants: {
          ENV: 'production',
          endpointBaseUrl:'https://ttlfc.herokuapp.com/tt'
        }
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
        proxies: [
                {
                    context: '/tt',
                    host: 'localhost',
                    port: 8080

                }
            ],
      livereload: {
        options: {
          open: true,
          middleware: function (connect,options) {
            var middlewares = [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect().use(
                '/app/styles',
                connect.static('./app/styles')
              ),
              connect.static(appConfig.app)
            ];
            if (!Array.isArray(options.base)) {
              options.base = [options.base];
            }

            // Setup the proxy
            middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);

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

            return middlewares;
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              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 %>'
        }
      }
    },

    // Make sure 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']
      }
    },

    // Make sure code styles are up to par
    jscs: {
      options: {
        config: '.jscsrc',
        verbose: true
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        src: ['test/spec/{,*/}*.js']
      }
    },

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

    // Add vendor prefixed styles
    postcss: {
      options: {
        processors: [
          require('autoprefixer-core')({browsers: ['last 1 version']})
        ]
      },
      server: {
        options: {
          map: true
        },
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      },
      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:  /\.\.\//
      },
      test: {
        devDependencies: true,
        src: '<%= karma.unit.configFile %>',
        ignorePath:  /\.\.\//,
        fileTypes:{
          js: {
            block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
              detect: {
                js: /'(.*\.js)'/gi
              },
              replace: {
                js: '\'{{filePath}}\','
              }
            }
          }
      }
    },

    // 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'],
      js: ['<%= yeoman.dist %>/scripts/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>',
          '<%= yeoman.dist %>/images',
          '<%= yeoman.dist %>/styles'
        ],
        patterns: {
          js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to 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
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    ngtemplates: {
      dist: {
        options: {
          module: 'ttlfcJsApp',
          htmlmin: '<%= htmlmin.dist.options %>',
          usemin: 'scripts/scripts.js'
        },
        cwd: '<%= yeoman.app %>',
        src: 'views/{,*/}*.html',
        dest: '.tmp/templateCache.js'
      }
    },

    // 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',
          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}',
            '*.html',
            'images/{,*/}*.{webp}',
            'styles/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']);
    }

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

  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',
    'wiredep',
    'concurrent:test',
    'postcss',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'ngconstant:production',
    'useminPrepare',
    'concurrent:dist',
    'postcss',
    'ngtemplates',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'newer:jscs',
    'test',
    'build'
  ]);
};
<commit_msg> set actual dev endpoint<commit_after>// Generated on 2016-01-30 using generator-angular 0.15.1
'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) {

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

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn',
    configureProxies: 'grunt-connect-proxy',
    ngconstant: 'grunt-ng-constant'
  });

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

  // 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', 'newer:jscs:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'postcss']
      },
      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}'
        ]
      }
    },
    //ng-constant
    ngconstant: {
      options: {
        name: 'config',
        wrap: '"use strict";\n\n{%= __ngModule %}',
        space: '  '
      },
      development: {
        options: {
          dest: '<%= yeoman.app %>/scripts/config.js',
        },
        constants: {
          ENV: 'development',
          endpointBaseUrl:'http://localhost:8080/tt'
        }
      },
      production: {
        options: {
          dest: '<%= yeoman.dist %>/scripts/config.js',
        },
        constants: {
          ENV: 'production',
          endpointBaseUrl:'https://ttlfc.herokuapp.com/tt'
        }
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
        proxies: [
                {
                    context: '/tt',
                    host: 'localhost',
                    port: 8080

                }
            ],
      livereload: {
        options: {
          open: true,
          middleware: function (connect,options) {
            var middlewares = [
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect().use(
                '/app/styles',
                connect.static('./app/styles')
              ),
              connect.static(appConfig.app)
            ];
            if (!Array.isArray(options.base)) {
              options.base = [options.base];
            }

            // Setup the proxy
            middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);

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

            return middlewares;
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function (connect) {
            return [
              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 %>'
        }
      }
    },

    // Make sure 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']
      }
    },

    // Make sure code styles are up to par
    jscs: {
      options: {
        config: '.jscsrc',
        verbose: true
      },
      all: {
        src: [
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        src: ['test/spec/{,*/}*.js']
      }
    },

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

    // Add vendor prefixed styles
    postcss: {
      options: {
        processors: [
          require('autoprefixer-core')({browsers: ['last 1 version']})
        ]
      },
      server: {
        options: {
          map: true
        },
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      },
      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:  /\.\.\//
      },
      test: {
        devDependencies: true,
        src: '<%= karma.unit.configFile %>',
        ignorePath:  /\.\.\//,
        fileTypes:{
          js: {
            block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
              detect: {
                js: /'(.*\.js)'/gi
              },
              replace: {
                js: '\'{{filePath}}\','
              }
            }
          }
      }
    },

    // 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'],
      js: ['<%= yeoman.dist %>/scripts/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>',
          '<%= yeoman.dist %>/images',
          '<%= yeoman.dist %>/styles'
        ],
        patterns: {
          js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to 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
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    ngtemplates: {
      dist: {
        options: {
          module: 'ttlfcJsApp',
          htmlmin: '<%= htmlmin.dist.options %>',
          usemin: 'scripts/scripts.js'
        },
        cwd: '<%= yeoman.app %>',
        src: 'views/{,*/}*.html',
        dest: '.tmp/templateCache.js'
      }
    },

    // 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',
          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}',
            '*.html',
            'images/{,*/}*.{webp}',
            'styles/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']);
    }

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

  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',
    'wiredep',
    'concurrent:test',
    'postcss',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'ngconstant:production',
    'useminPrepare',
    'concurrent:dist',
    'postcss',
    'ngtemplates',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin'
  ]);

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


<commit_before>module.exports = function(grunt) {
  /**
   * Load required Grunt tasks. These are installed based on the versions listed
   * in `package.json` when you do `npm install` in this directory.
   */
  // grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-haml2html');
  grunt.loadNpmTasks('grunt-html2js');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-aws-s3');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks("grunt-ts");

  /**
   * Load in our build configuration file.
   */
  var userConfig = require( './build.config.js' );

  /**
   * Load in our AWS credentials
   */
  var awsConfig = require( './aws.config.js' );

  /**
   * Use port parameter for the http server (defaults to 8000)
   */
  var optionsConfig = {
    port: grunt.option('port') || '8000',
  };

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

    /**
     * The banner is the comment that is placed at the top of our compiled
     * source files. It is first processed as a Grunt template, where the `<%=`
     * pairs are evaluated based on this very configuration object.
     */
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.name %> - v<%= grunt.file.readJSON("package.json").version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.homepage %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
        ' * Licensed <%= pkg.license %> \n' +
        ' */\n'
    },

    coffee: {
      source: {
        options: {
          bare: true
        },
        expand: true,
        cwd: '.',
        src: [ '<%= app_files.coffee %>' ],
        dest: '<%= build_dir %>',
        ext: '.js'
      }
    },

    ts: {
      default : {
        src: [ '<%= app_files.ts %>' ],
        options: {
          rootDir: '<%= root_dir %>'
        },
        outDir: '<%= build_dir %>/src'
      }
    },

    /*
     * http://stackoverflow.com/questions/27494340/how-to-use-grunt-to-recursively-compile-a-directory-of-haml-or-jade
     */
    haml: {
      build: {
        files : [
          { expand: true,
            cwd: '.',
            src: [ '<%= app_files.haml %>' ],
            dest: '<%= build_dir %>',
            ext : '.html'
          }
        ]
      },
    },

    /**
     * HTML2JS is a Grunt plugin that takes all of your template files and
     * places them into JavaScript files as strings that are added to
     * AngularJS's template cache. This means that the templates too become
     * part of the initial payload as one JavaScript file. Neat!
     */
    html2js: {
      build: {
        options: {
          base: 'build/src',
          module: 'cloudStorm.templates'
        },
        src: [ '<%= app_files.template %>' ],
        dest: '<%= build_dir %>/templates.js'
      }
    },

    concat: {
      dist: {
        options: {
          process: function(src, filepath) {
            return  '\n\n' + '// Original: ' + filepath + '\n\n' + src;
          }
        },
        src: [
          '<%= app_files.sass_main %>'
        ],
        dest: '<%= build_dir %>/concat.scss',
      }
    },

    copy: {
      compiled_assets: {
        files: [
          {
            src: [ '**' ],
            cwd: '<%= build_dir %>/assets',
            dest: '<%= compile_dir %>/assets',
            expand: true
          }
        ]
      },
      sample_app: {
        files: [
          {
            src: [ '**'] ,
            cwd: '<%= sample_dir %>',
            dest: '<%= compile_dir %>/',
            expand:true
          }
       ]
      }
    },

    /**
     * `grunt-contrib-sass` handles SCSS compilation.
     * Only the main cloudstorm stylesheet file is included in compilation;
     * all other files must be imported from this file.
     */
    sass: {
      build: {
        options:{
          loadPath: [
            "src"
          ]
        },
        files: {
          '<%= build_dir %>/assets/<%= pkg.name %>.css': '<%= app_files.sass_main %>'
        }
      }
    },

    concat: {
      /**
       * The `compile_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file.
       */
      compile_js: {
        options: {
          banner: '<%= meta.banner %>',
          sourceMap: true
        },
        src: [
          // 'module.prefix',
          '<%= app_files.built_js %>',
          '<%= app_files.js %>',
          '<%= html2js.build.dest %>',
          // 'module.suffix'
        ],
        dest: '<%= compile_dir %>/assets/<%= pkg.name %>.js'
      }
    },

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

    exec: {
      say: {
        cmd: function(text) {
          return 'say ' + text;
        }
      },
      start_web: {
        command: 'cd bin && open "http://localhost:<%= port %>/sample.html" && python -m SimpleHTTPServer <%= port %>'
        // command: 'cd bin && python -m SimpleHTTPServer 8000'
      },
      stop_web: {
        command: "kill -9 `ps -ef |grep SimpleHTTPServer |awk '{print $2}'`"
      },
    },

    /**
     * Increments the version number, commits, tags and pushes to origin
     */
    bump: {
      options: {
        files: [
          "package.json",
          "bower.json"
        ],
        commit: true,
        commitMessage: 'Release: v%VERSION%',
        commitFiles: [
          "package.json",
          "bower.json"
        ],
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin'
      }
    },

    /**
     * Pushes compiled js and css files to CDN (AWS S3)
     */
    aws_s3: {
      options: {
        accessKeyId: '<%= aws.accessKeyId %>',
        secretAccessKey: '<%= aws.secretKey %>'
      },
      dist: {
        options: {
          bucket: '<%= aws.bucketName %>',
          region: '<%= aws.bucketRegion %>'
        },
        files: [
          {
            expand: true,
            cwd: 'bin/assets',
            src: [ '**' ],
            dest: '/'
          }
        ]
      }
    },

    karma: {
      options: {
        configFile: 'karma.conf.js',
      },
      unit: {
        singleRun: true
      },
      continuous: {
      }
    },

    /**
     * Watches
     * LiveReload is added through grunt-contrib-watch
     * User LiveReload with a browser extension or if you prefer to not,
     * then make sure the following is added to the end of the body tag in HTML:
     * <script src="http://localhost:35729/livereload.js"></script>
     */
    watch: {
      /**
       * By default, we want the Live Reload to work for all tasks; this is
       * overridden in some tasks (like this file) where browser resources are
       * unaffected. It runs by default on port 35729, which your browser
       * plugin should auto-detect.
       */
      options: {
        livereload: true
      },

      jssrc : {
        files: [
          '<%= app_files.js %>'
        ],
        tasks: ['concat:compile_js', 'karma:unit']
      },

      jsspecsrc : {
        files : [
          '<%= app_files.jsspec %>'
        ],
        tasks : ['concat:compile_js', 'karma:unit']
      },

      tssrc: {
        files: [
          '<%= app_files.ts %>'
        ],
        tasks: ['ts', 'concat:compile_js', 'karma:unit' ]
      },

      /**
       * When our CoffeeScript source files change, we want to  lint them and
       * run our unit tests.
       */
      coffeesrc: {
        files: [
          '<%= app_files.coffee %>'
        ],
        tasks: ['coffee', 'concat:compile_js', 'karma:unit' ]
        // tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build_appjs' ]
      },
      hamlsrc: {
        files: [
          '<%= app_files.haml %>'
        ],
        tasks: ['haml', 'html2js', 'concat:compile_js', 'karma:unit' ]
        // tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build_appjs' ]
      },
      sasssrc: {
        files: [
          '<%= app_files.sass %>'
        ],
        tasks: [ 'sass', 'copy:compiled_assets', 'karma:unit' ]
      },
      sample_app: {
        files: [
          '<%= sample_dir %>/**',
        ],
        //tasks: [ 'exec:say:sample', 'copy:sample_app', 'karma:unit' ]
        tasks: ['copy:sample_app', 'karma:unit' ]
      },
    },
  };

  grunt.initConfig( grunt.util._.extend( taskConfig, userConfig, awsConfig, optionsConfig ) );

  grunt.registerTask( 'start_web', ['exec:start_web' ]);

  /**
   * The default task is to build and compile.
   */
  grunt.registerTask( 'default', [ 'build', 'compile', 'start_web' ] );

  grunt.registerTask( 'cdn', 'aws_s3:dist' );

  grunt.registerTask( 'deploy', ['release', 'aws_s3:dist'] );

  grunt.registerTask ('release', function(t) {
    var target = t || 'patch';
    grunt.task.run('bump-only:' + target, 'build', 'compile', 'bump-commit');
  });

  grunt.registerTask ('testrelease', function(t) {
    var target = t || 'patch';
    grunt.task.run('bump-only:' + target, 'build', 'compile');
  });

  grunt.registerTask ('test', function(t) {
    var target = t || 'continuous';
    grunt.task.run('karma:' + target);
  });

  /**
   * The `build` task gets your app ready to run for development and testing.
   */
  grunt.registerTask( 'build', [
    'clean', 'coffee', 'ts', 'sass', 'haml', 'html2js', 'copy:sample_app'
  ]);

  /**
   * The `compile` task gets your app ready for deployment by concatenating and
   * minifying your code.
   */
  grunt.registerTask( 'compile', [
    'copy:compiled_assets', 'concat:compile_js'
  ]);

};
<commit_msg>GruntFile updates for the more convenient build<commit_after>module.exports = function(grunt) {
  /**
   * Load required Grunt tasks. These are installed based on the versions listed
   * in `package.json` when you do `npm install` in this directory.
   */
  // grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-haml2html');
  grunt.loadNpmTasks('grunt-html2js');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-aws-s3');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks("grunt-ts");

  /**
   * Load in our build configuration file.
   */
  var userConfig = require( './build.config.js' );

  /**
   * Load in our AWS credentials
   */
  var awsConfig = require( './aws.config.js' );

  /**
   * Use port parameter for the http server (defaults to 8000)
   */
  var optionsConfig = {
    port: grunt.option('port') || '8000',
  };

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

    /**
     * The banner is the comment that is placed at the top of our compiled
     * source files. It is first processed as a Grunt template, where the `<%=`
     * pairs are evaluated based on this very configuration object.
     */
    meta: {
      banner:
        '/**\n' +
        ' * <%= pkg.name %> - v<%= grunt.file.readJSON("package.json").version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.homepage %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
        ' * Licensed <%= pkg.license %> \n' +
        ' */\n'
    },

    coffee: {
      source: {
        options: {
          bare: true
        },
        expand: true,
        cwd: '.',
        src: [ '<%= app_files.coffee %>' ],
        dest: '<%= build_dir %>',
        ext: '.js'
      }
    },

    ts: {
      default : {
        src: [ '<%= app_files.ts %>' ],
        options: {
          rootDir: '<%= root_dir %>'
        },
        outDir: '<%= build_dir %>/src'
      }
    },

    /*
     * http://stackoverflow.com/questions/27494340/how-to-use-grunt-to-recursively-compile-a-directory-of-haml-or-jade
     */
    haml: {
      build: {
        files : [
          { expand: true,
            cwd: '.',
            src: [ '<%= app_files.haml %>' ],
            dest: '<%= build_dir %>',
            ext : '.html'
          }
        ]
      },
    },

    /**
     * HTML2JS is a Grunt plugin that takes all of your template files and
     * places them into JavaScript files as strings that are added to
     * AngularJS's template cache. This means that the templates too become
     * part of the initial payload as one JavaScript file. Neat!
     */
    html2js: {
      build: {
        options: {
          base: 'build/src',
          module: 'cloudStorm.templates'
        },
        src: [ '<%= app_files.template %>' ],
        dest: '<%= build_dir %>/templates.js'
      }
    },

    concat: {
      dist: {
        options: {
          process: function(src, filepath) {
            return  '\n\n' + '// Original: ' + filepath + '\n\n' + src;
          }
        },
        src: [
          '<%= app_files.sass_main %>'
        ],
        dest: '<%= build_dir %>/concat.scss',
      }
    },

    copy: {
      compiled_assets: {
        files: [
          {
            src: [ '**' ],
            cwd: '<%= build_dir %>/assets',
            dest: '<%= compile_dir %>/assets',
            expand: true
          }
        ]
      },
      sample_app: {
        files: [
          {
            src: [ '**'] ,
            cwd: '<%= sample_dir %>',
            dest: '<%= compile_dir %>/',
            expand:true
          }
       ]
      }
    },

    /**
     * `grunt-contrib-sass` handles SCSS compilation.
     * Only the main cloudstorm stylesheet file is included in compilation;
     * all other files must be imported from this file.
     */
    sass: {
      build: {
        options:{
          loadPath: [
            "src"
          ]
        },
        files: {
          '<%= build_dir %>/assets/<%= pkg.name %>.css': '<%= app_files.sass_main %>'
        }
      }
    },

    concat: {
      /**
       * The `compile_js` target is the concatenation of our application source
       * code and all specified vendor source code into a single file.
       */
      compile_js: {
        options: {
          banner: '<%= meta.banner %>',
          sourceMap: true
        },
        src: [
          // 'module.prefix',
          '<%= app_files.built_js %>',
          '<%= app_files.js %>',
          '<%= html2js.build.dest %>',
          // 'module.suffix'
        ],
        dest: '<%= compile_dir %>/assets/<%= pkg.name %>.js'
      }
    },

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

    exec: {
      say: {
        cmd: function(text) {
          return 'say ' + text;
        }
      },
      start_web: {
        command: 'cd bin && open "http://localhost:<%= port %>/sample.html" && python -m SimpleHTTPServer <%= port %>'
        // command: 'cd bin && python -m SimpleHTTPServer 8000'
      },
      stop_web: {
        command: "kill -9 `ps -ef |grep SimpleHTTPServer |awk '{print $2}'`"
      },
    },

    /**
     * Increments the version number, commits, tags and pushes to origin
     */
    bump: {
      options: {
        files: [
          "package.json",
          "bower.json"
        ],
        commit: true,
        commitMessage: 'Release: v%VERSION%',
        commitFiles: [
          "package.json",
          "bower.json"
        ],
        createTag: true,
        tagName: 'v%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin'
      }
    },

    /**
     * Pushes compiled js and css files to CDN (AWS S3)
     */
    aws_s3: {
      options: {
        accessKeyId: '<%= aws.accessKeyId %>',
        secretAccessKey: '<%= aws.secretKey %>'
      },
      dist: {
        options: {
          bucket: '<%= aws.bucketName %>',
          region: '<%= aws.bucketRegion %>'
        },
        files: [
          {
            expand: true,
            cwd: 'bin/assets',
            src: [ '**' ],
            dest: '/'
          }
        ]
      }
    },

    karma: {
      options: {
        configFile: 'karma.conf.js',
      },
      unit: {
        singleRun: true
      },
      continuous: {
      }
    },

    /**
     * Watches
     * LiveReload is added through grunt-contrib-watch
     * User LiveReload with a browser extension or if you prefer to not,
     * then make sure the following is added to the end of the body tag in HTML:
     * <script src="http://localhost:35729/livereload.js"></script>
     */
    watch: {
      /**
       * By default, we want the Live Reload to work for all tasks; this is
       * overridden in some tasks (like this file) where browser resources are
       * unaffected. It runs by default on port 35729, which your browser
       * plugin should auto-detect.
       */
      options: {
        livereload: true
      },

      jssrc : {
        files: [
          '<%= app_files.js %>'
        ],
        tasks: ['concat:compile_js', 'karma:unit']
      },

      jsspecsrc : {
        files : [
          '<%= app_files.jsspec %>'
        ],
        tasks : ['concat:compile_js', 'karma:unit']
      },

      tssrc: {
        files: [
          '<%= app_files.ts %>'
        ],
        tasks: ['ts', 'concat:compile_js', 'karma:unit' ]
      },

      /**
       * When our CoffeeScript source files change, we want to  lint them and
       * run our unit tests.
       */
      coffeesrc: {
        files: [
          '<%= app_files.coffee %>'
        ],
        tasks: ['coffee', 'concat:compile_js', 'karma:unit' ]
        // tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build_appjs' ]
      },
      hamlsrc: {
        files: [
          '<%= app_files.haml %>'
        ],
        tasks: ['haml', 'html2js', 'concat:compile_js', 'karma:unit' ]
        // tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build_appjs' ]
      },
      sasssrc: {
        files: [
          '<%= app_files.sass %>'
        ],
        tasks: [ 'sass', 'copy:compiled_assets' ]
      },
      sample_app: {
        files: [
          '<%= sample_dir %>/**',
        ],
        //tasks: [ 'exec:say:sample', 'copy:sample_app', 'karma:unit' ]
        tasks: ['copy:sample_app', 'karma:unit' ]
      },
    },
  };

  grunt.initConfig( grunt.util._.extend( taskConfig, userConfig, awsConfig, optionsConfig ) );

  grunt.registerTask( 'start_web', ['exec:start_web' ]);

  /**
   * The default task is to build and compile.
   */
  grunt.registerTask( 'default', [ 'build', 'compile', 'start_web' ] );

  grunt.registerTask( 'cdn', 'aws_s3:dist' );

  grunt.registerTask( 'deploy', ['release', 'aws_s3:dist'] );

  grunt.registerTask ('release', function(t) {
    var target = t || 'patch';
    grunt.task.run('bump-only:' + target, 'build', 'compile', 'bump-commit');
  });

  grunt.registerTask ('testrelease', function(t) {
    var target = t || 'patch';
    grunt.task.run('bump-only:' + target, 'build', 'compile');
  });

  grunt.registerTask ('test', function(t) {
    var target = t || 'continuous';
    grunt.task.run('karma:' + target);
  });

  /**
   * The `build` task gets your app ready to run for development and testing.
   */
  grunt.registerTask( 'build', [
    'clean', 'coffee', 'ts', 'sass', 'haml', 'html2js', 'copy:sample_app'
  ]);

  /**
   * The `compile` task gets your app ready for deployment by concatenating and
   * minifying your code.
   */
  grunt.registerTask( 'compile', [
    'copy:compiled_assets', 'concat:compile_js'
  ]);

  grunt.registerTask('haml_pre', [
    'haml', 'html2js'
  ]);

  grunt.registerTask('haml_compile', [
    'haml_pre', 'concat:compile_js'
  ]);

  grunt.registerTask('haml_sass', [
      'haml_pre', 'sass', 'compile'
  ]);

  grunt.registerTask('sass_compile', [
    'sass', 'copy:compiled_assets'
  ]);

  grunt.registerTask('js_compile', [
    'concat:compile_js'
  ]);

  grunt.registerTask('js_compile_t', [
    'concat:compile_js', 'karma:unit'
  ]);

  grunt.registerTask('coffee_compile', [
    'coffee', 'concat:compile_js'
  ]);

  grunt.registerTask('coffee_compile_t', [
    'coffee', 'concat:compile_js', 'karma:unit'
  ]);

  grunt.registerTask('haml_js', [
    'haml_compile', 'js_compile'
  ])

  grunt.registerTask('haml_coffee', [
    'haml_compile', 'coffee_compile'
  ])

  grunt.registerTask('haml_js_t', [
    'haml_compile', 'js_compile_t'
  ])

  grunt.registerTask('aj', [
    'haml_sass', 'js_compile_t'
  ])

  grunt.registerTask('a', [
    'haml_sass', 'coffee_compile_t'
  ])

  grunt.registerTask('haml_coffee_t', [
    'haml_compile', 'coffee_compile_t'
  ])
};
<|endoftext|>


<commit_before>var exec = require('child_process').exec,
	fs = require('fs'),
	path = require('path'),
	wrench = require('wrench');

var NAME = 'ti-node-require',
	TMP_DIR = 'tmp';

module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		mochaTest: {
			options: {
				require: ['should'],
				timeout: 3000,
				ignoreLeaks: false,
				reporter: 'spec'
			},
			src: ['test/*_test.js']
		},
		jshint: {
			options: {
				jshintrc: true
			},
			src: [
				'Gruntfile.js',
				'lib/**/*.js',
				'test/**/*.js'
			]
		},
		titanium: {
			create: {
				options: {
					command: 'create',
					name: TMP_DIR,
					workspaceDir: '.',
					platforms: ['ios']
				}
			},
			build: {
				options: {
					command: 'build',
					projectDir: TMP_DIR,
					logLevel: 'trace'
				}
			}
		},
		alloy: {
			all: {
				options: {
					command: 'new',
					args: [TMP_DIR]
				}
			}
		},
		clean: {
			src: [TMP_DIR]
		}
	});

	// Load grunt plugins for modules
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-titanium');
	grunt.loadNpmTasks('grunt-alloy');

	// load test app
	grunt.registerTask('app-prep', 'Load source files into example alloy app', function() {
		var done = this.async(),
			srcDir = path.join('test', 'app'),
			dstDir = path.join(TMP_DIR, 'app'),
			assetsDir = path.join(dstDir, 'assets'),
			tmpAssetsDir = path.join(TMP_DIR, 'assets'),
			libDir = path.join(dstDir, 'lib');

		// copy app source files
		grunt.log.write('Preparing test app at "%s"...', dstDir);
		fs.renameSync(assetsDir, tmpAssetsDir);
		wrench.copyDirSyncRecursive(srcDir, dstDir, { forceDelete: true });
		fs.renameSync(tmpAssetsDir, assetsDir);

		// copy in lib and jmk
		copyFileSync(path.join('lib', NAME + '.js'), path.join(libDir, NAME + '.js'));
		copyFileSync(path.join('lib', 'alloy.jmk'), path.join(dstDir, 'alloy.jmk'));
		grunt.log.ok();

		// copy in should.js
		//copyFileSync(path.join('node_modules', 'should', 'should.js'), path.join(libDir, 'should.js'));

		// run npm install
		exec('cd "' + libDir + '" && npm install', done);

	});

	// create test alloy app
	grunt.registerTask('app-create', ['clean', 'titanium:create', 'alloy']);

	// run example app
	grunt.registerTask('test', ['app-create', 'app-prep', 'titanium:build']);

	// Register tasks
	grunt.registerTask('default', ['jshint', 'test']);

};

function copyFileSync(src, dst) {
	fs.writeFileSync(dst, fs.readFileSync(src));
}<commit_msg>don't move alloy.jmk<commit_after>var exec = require('child_process').exec,
	fs = require('fs'),
	path = require('path'),
	wrench = require('wrench');

var NAME = 'ti-node-require',
	TMP_DIR = 'tmp';

module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		mochaTest: {
			options: {
				require: ['should'],
				timeout: 3000,
				ignoreLeaks: false,
				reporter: 'spec'
			},
			src: ['test/*_test.js']
		},
		jshint: {
			options: {
				jshintrc: true
			},
			src: [
				'Gruntfile.js',
				'lib/**/*.js',
				'test/**/*.js'
			]
		},
		titanium: {
			create: {
				options: {
					command: 'create',
					name: TMP_DIR,
					workspaceDir: '.',
					platforms: ['ios']
				}
			},
			build: {
				options: {
					command: 'build',
					projectDir: TMP_DIR,
					logLevel: 'trace'
				}
			}
		},
		alloy: {
			all: {
				options: {
					command: 'new',
					args: [TMP_DIR]
				}
			}
		},
		clean: {
			src: [TMP_DIR]
		}
	});

	// Load grunt plugins for modules
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-titanium');
	grunt.loadNpmTasks('grunt-alloy');

	// load test app
	grunt.registerTask('app-prep', 'Load source files into example alloy app', function() {
		var done = this.async(),
			srcDir = path.join('test', 'app'),
			dstDir = path.join(TMP_DIR, 'app'),
			assetsDir = path.join(dstDir, 'assets'),
			tmpAssetsDir = path.join(TMP_DIR, 'assets'),
			libDir = path.join(dstDir, 'lib');

		// copy app source files
		grunt.log.write('Preparing test app at "%s"...', dstDir);
		fs.renameSync(assetsDir, tmpAssetsDir);
		wrench.copyDirSyncRecursive(srcDir, dstDir, { forceDelete: true });
		fs.renameSync(tmpAssetsDir, assetsDir);

		// copy in lib and jmk
		copyFileSync(path.join('lib', NAME + '.js'), path.join(libDir, NAME + '.js'));
		//copyFileSync(path.join('lib', 'alloy.jmk'), path.join(dstDir, 'alloy.jmk'));
		grunt.log.ok();

		// copy in should.js
		//copyFileSync(path.join('node_modules', 'should', 'should.js'), path.join(libDir, 'should.js'));

		// run npm install
		exec('cd "' + libDir + '" && npm install', done);

	});

	// create test alloy app
	grunt.registerTask('app-create', ['clean', 'titanium:create', 'alloy']);

	// run example app
	grunt.registerTask('test', ['app-create', 'app-prep', 'titanium:build']);

	// Register tasks
	grunt.registerTask('default', ['jshint', 'test']);

};

function copyFileSync(src, dst) {
	fs.writeFileSync(dst, fs.readFileSync(src));
}<|endoftext|>