<commit_before>var toml = require("toml");
var S = require("string");

var CONTENT_PATH_PREFIX = "content";
var SITE_IDX_DEST = "static/js/pindex.json";

module.exports = function(grunt) {

    grunt.registerTask("lunr-index", function() {

        grunt.log.writeln("Build pages index");

        var indexPages = function() {
            var pagesIndex = [];
            grunt.file.recurse(CONTENT_PATH_PREFIX, function(abspath, rootdir, subdir, filename) {
                grunt.verbose.writeln("Parse file:",abspath);
                pagesIndex.push(processFile(abspath, filename));
            });

            return pagesIndex;
        };

        var processFile = function(abspath, filename) {
            var pageIndex;

            if (S(filename).endsWith(".html")) {
                pageIndex = processHTMLFile(abspath, filename);
            } else {
                pageIndex = processMDFile(abspath, filename);
            }

            return pageIndex;
        };

        var processHTMLFile = function(abspath, filename) {
            var content = grunt.file.read(abspath);
            var pageName = S(filename).chompRight(".html").s;
            var href = S(abspath)
                .chompLeft(CONTENT_PATH_PREFIX).s;
            return {
                title: pageName,
                href: href,
                content: S(content).trim().stripTags().stripPunctuation().s
            };
        };

        var processMDFile = function(abspath, filename) {
            var content = grunt.file.read(abspath);
            grunt.log.ok("READING FILE:" + abspath)
            var pageIndex;
            // First separate the Front Matter from the content and parse it
            content = content.split("+++");
            var frontMatter;
            try {
                frontMatter = toml.parse(content[1].trim());
            } catch (e) {
                grunt.log.error("ERROR WHILST PROCESSING: " + abspath + e.message);
            }
            if (frontMatter.url) {
                var href = frontMatter.url;
            } else {
                var href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(".md").s + ".html";
                // href for index.md files stops at the folder name - Not with ugly URLs
                // if (filename === "index.md") {
                //     href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(filename).s;
                // }
            }

            // Build Lunr index for this page
            pageIndex = {
                title: frontMatter.title,
                tags: frontMatter.tags,
                href: href,
                content: S(content[2]).trim().stripTags().stripPunctuation().s
            };

            return pageIndex;
        };

        grunt.file.write(SITE_IDX_DEST, JSON.stringify(indexPages()));
        grunt.log.ok("Index built");
    });
};
<commit_msg>Fix up path to lunr index<commit_after>var toml = require("toml");
var S = require("string");

var CONTENT_PATH_PREFIX = "content";
var SITE_IDX_DEST = "public/js/pindex.json";

module.exports = function(grunt) {

    grunt.registerTask("lunr-index", function() {

        grunt.log.writeln("Build pages index");

        var indexPages = function() {
            var pagesIndex = [];
            grunt.file.recurse(CONTENT_PATH_PREFIX, function(abspath, rootdir, subdir, filename) {
                grunt.verbose.writeln("Parse file:",abspath);
                pagesIndex.push(processFile(abspath, filename));
            });

            return pagesIndex;
        };

        var processFile = function(abspath, filename) {
            var pageIndex;

            if (S(filename).endsWith(".html")) {
                pageIndex = processHTMLFile(abspath, filename);
            } else {
                pageIndex = processMDFile(abspath, filename);
            }

            return pageIndex;
        };

        var processHTMLFile = function(abspath, filename) {
            var content = grunt.file.read(abspath);
            var pageName = S(filename).chompRight(".html").s;
            var href = S(abspath)
                .chompLeft(CONTENT_PATH_PREFIX).s;
            return {
                title: pageName,
                href: href,
                content: S(content).trim().stripTags().stripPunctuation().s
            };
        };

        var processMDFile = function(abspath, filename) {
            var content = grunt.file.read(abspath);
            grunt.log.ok("READING FILE:" + abspath)
            var pageIndex;
            // First separate the Front Matter from the content and parse it
            content = content.split("+++");
            var frontMatter;
            try {
                frontMatter = toml.parse(content[1].trim());
            } catch (e) {
                grunt.log.error("ERROR WHILST PROCESSING: " + abspath + e.message);
            }
            if (frontMatter.url) {
                var href = frontMatter.url;
            } else {
                var href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(".md").s + ".html";
                // href for index.md files stops at the folder name - Not with ugly URLs
                // if (filename === "index.md") {
                //     href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(filename).s;
                // }
            }

            // Build Lunr index for this page
            pageIndex = {
                title: frontMatter.title,
                tags: frontMatter.tags,
                href: href,
                content: S(content[2]).trim().stripTags().stripPunctuation().s
            };

            return pageIndex;
        };

        grunt.file.write(SITE_IDX_DEST, JSON.stringify(indexPages()));
        grunt.log.ok("Index built");
    });
};
<|endoftext|>


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

    "use strict";

    var fs = require('fs'), pkginfo = grunt.file.readJSON("package.json");

    grunt.initConfig({

        pkg: pkginfo,

        meta: {
          banner: "/*! <%= pkg.title %> <%= pkg.version %> | <%= pkg.homepage %> | (c) 2014 YOOtheme | MIT License */"
        },

        jshint: {
            src: {
                options: {
                    jshintrc: "src/.jshintrc"
                },
                src: ["src/js/*.js"]
            }
        },

        less: (function(){

            var lessconf = {
                "docsmin": {
                    options: { paths: ["docs/less"], cleancss: true },
                    files: { "docs/css/uikit.docs.min.css": ["docs/less/uikit.less"] }
                }
            },

            themes = [];

            //themes

            ["default", "custom"].forEach(function(f){

                if(fs.existsSync('themes/'+f)) {

                    fs.readdirSync('themes/'+f).forEach(function(t){

                        var themepath = 'themes/'+f+'/'+t,
                            distpath  = f=="default" ? "dist/css" : themepath+"/dist";

                        // Is it a directory?
                        if (fs.lstatSync(themepath).isDirectory() && t!=="blank" && t!=='.git') {

                            var files = {};

                            if(t=="default") {
                                files[distpath+"/uikit.css"] = [themepath+"/uikit.less"];
                            } else {
                                files[distpath+"/uikit."+t+".css"] = [themepath+"/uikit.less"];
                            }

                            lessconf[t] = {
                                "options": { paths: [themepath] },
                                "files": files
                            };

                            var filesmin = {};

                            if(t=="default") {
                                filesmin[distpath+"/uikit.min.css"] = [themepath+"/uikit.less"];
                            } else {
                                filesmin[distpath+"/uikit."+t+".min.css"] = [themepath+"/uikit.less"];
                            }

                            lessconf[t+"min"] = {
                                "options": { paths: [themepath], cleancss: true},
                                "files": filesmin
                            };

                            themes.push({ "path":themepath, "name":t, "dir":f });
                        }
                    });
                }
            });

            //addons

            fs.readdirSync('src/less/addons').forEach(function(f){

                if(f.match(/\.less$/)) {

                  var addon = f.replace(".less", "");

                    lessconf["addon-"+f] = {options: { paths: ['src/less/addons'] }, files: {} };
                    lessconf["addon-"+f].files["dist/addons/"+addon+"/"+addon+".css"] = ['src/less/addons/'+f];

                    lessconf["addon-min-"+f] = {options: { paths: ['src/less/addons'], cleancss: true }, files: {} };
                    lessconf["addon-min-"+f].files["dist/addons/"+addon+"/"+addon+".min.css"] = ['src/less/addons/'+f];

                    // look for theme overrides
                    themes.forEach(function(theme){

                       var override = theme.path+'/addon.'+f,
                           distpath = theme.dir=="default" ? "dist/addons/"+addon : theme.path+"/dist/addons/"+addon;

                       if(fs.existsSync(override)) {

                         if(theme.dir=="default" && theme.name=="default") {

                           lessconf["addon-"+f+"-"+theme.name] = {options: { paths: [theme.path] }, files: {} };
                           lessconf["addon-"+f+"-"+theme.name].files[distpath+"/"+addon+".css"] = [override];

                           lessconf["addon-min-"+f+"-"+theme.name] = {options: { paths: [theme.path], cleancss: true }, files: {} };
                           lessconf["addon-min-"+f+"-"+theme.name].files[distpath+"/"+addon+".min.css"] = [override];

                         } else {

                            lessconf["addon-"+f+"-"+theme.name] = {options: { paths: [theme.path] }, files: {} };
                            lessconf["addon-"+f+"-"+theme.name].files[distpath+"/"+addon+"."+theme.name+".css"] = [override];

                            lessconf["addon-min-"+f+"-"+theme.name] = {options: { paths: [theme.path], cleancss: true }, files: {} };
                            lessconf["addon-min-"+f+"-"+theme.name].files[distpath+"/"+addon+"."+theme.name+".min.css"] = [override];

                         }
                       }
                    });
                }

            });

            return lessconf;
        })(),

        copy: {
            fonts: {
                files: [{ expand: true, cwd: "src/fonts", src: ["*"], dest: "dist/fonts/" }]
            }
        },

        concat: {
            dist: {
                options: {
                    separator: "\n\n"
                },
                src: ["src/js/core.js",
                      "src/js/utility.js",
                      "src/js/touch.js",
                      "src/js/alert.js",
                      "src/js/button.js",
                      "src/js/dropdown.js",
                      "src/js/grid.js",
                      "src/js/modal.js",
                      "src/js/offcanvas.js",
                      "src/js/nav.js",
                      "src/js/tooltip.js",
                      "src/js/switcher.js",
                      "src/js/tab.js",
                      "src/js/search.js",
                      "src/js/scrollspy.js",
                      "src/js/smooth-scroll.js",
                      "src/js/toggle.js",
                      ],
                dest: "dist/js/uikit.js"
            }
        },

        usebanner: {
            dist: {
              options: {
                position: 'top',
                banner: "<%= meta.banner %>\n"
              },
              files: {
                src: [ 'dist/css/*.css', 'dist/js/*.js', 'dist/addons/**/*.css', 'dist/addons/**/*.js' ]
              }
            }
        },

        uglify: {
            distmin: {
                options: {
                    //banner: "<%= meta.banner %>\n"
                },
                files: {
                    "dist/js/uikit.min.js": ["dist/js/uikit.js"]
                }
            },
            addonsmin: {
              files: (function(){

                  var files = {};

                  fs.readdirSync('src/js/addons').forEach(function(f){

                      if(f.match(/\.js/)) {

                        var addon = f.replace(".js", "");

                        grunt.file.copy('src/js/addons/'+f, 'dist/addons/'+addon+'/'+f);

                        files['dist/addons/'+addon+'/'+addon+'.min.js'] = ['src/js/addons/'+f];

                      }
                  });

                  return files;
              })()
            }
        },

        compress: {
            dist: {
                options: {
                    archive: ("dist/uikit-"+pkginfo.version+".zip")
                },
                files: [
                    { expand: true, cwd: "dist/", src: ["css/*", "js/*", "fonts/*", "addons/css/*", "addons/js/*"], dest: "" }
                ]
            }
        },

        watch: {
            src: {
                files: ["src/**/*.less", "themes/**/*.less","src/js/*.js"],
                tasks: ["build"]
            }
        }

    });

    grunt.registerTask('indexthemes', 'Rebuilding theme index.', function() {

       var themes = [];

       ["default", "custom"].forEach(function(f){

           if(fs.existsSync('themes/'+f)) {

               fs.readdirSync('themes/'+f).forEach(function(t){

                   var themepath = 'themes/'+f+'/'+t;

                   // Is it a directory?
                   if (fs.lstatSync(themepath).isDirectory() && t!=="blank" && t!=='.git') {

                       var theme = {
                           "name"  : t.split("-").join(" ").replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) { return $1.toUpperCase(); }),
                           "url"   : "../"+themepath+"/uikit.less",
                           "config": (fs.existsSync(themepath+"/customizer.json") ? "../"+themepath+"/customizer.json" : "../themes/default/uikit/customizer.json"),
                           "styles": {}
                       };

                       if(fs.existsSync(themepath+'/styles')) {

                          var styles = {};

                          fs.readdirSync(themepath+'/styles').forEach(function(sf){

                              var stylepath = [themepath, 'styles', sf, 'style.less'].join('/');

                              if(fs.existsSync(stylepath)) {
                                styles[sf] = "../"+themepath+"/styles/"+sf+"/style.less";
                              }
                          });

                          theme.styles = styles;
                       }

                       themes.push(theme);
                   }
               });
           }
       });

       grunt.log.writeln(themes.length+' themes found: ' + themes.map(function(theme){ return theme.name;}).join(", "));

       fs.writeFileSync("themes/themes.json", JSON.stringify(themes, " ", 4));
    });

    grunt.registerTask('sublime', 'Building Sublime Text Package', function() {
      // css core
      var filepath = 'dist/css/uikit.css';
      var cssFiles = [filepath];
      if (!fs.existsSync(filepath)) {
        grunt.log.error("Not found: " + filepath);
        return;
      }
      // css addons
      fs.readdirSync('dist/addons').forEach(function(f){
        var addon_css_file = 'dist/addons/'+f+'/'+f+'.css';
        if (fs.existsSync(addon_css_file)) {
          cssFiles.push(addon_css_file);
        }
      });
      var cssContent = "";
      for (var i in cssFiles) {
        cssContent += grunt.file.read(cssFiles[i])+' ';
      }
      var classesList = cssContent.match(/\.(uk-[a-z\d\-]+)/g),
          classesSet  = {},
          pystring    = '# copy & paste into sublime plugin code:\n';

      // use object as set (no duplicates)
      classesList.forEach(function(c) {
        c = c.substr(1); // remove leading dot
        classesSet[c] = true;
      });

      // convert set back to list
      classesList = Object.keys(classesSet);

      pystring += 'uikit_classes = ["' + classesList.join('", "') + '"]\n';

      // JS core
      filepath = 'dist/js/uikit.js';
      if (!fs.existsSync(filepath)) {
        grunt.log.error("Not found: " + filepath);
        return;
      }
      var jsFiles = [filepath];

      // JS addons
      fs.readdirSync('dist/addons').forEach(function(f){
        var addon_js_file = 'dist/addons/'+f+'/'+f+'.js';
        if (fs.existsSync(addon_js_file)) {
          jsFiles.push(addon_js_file);
        }
      });
      var jsContent = "";
      for (var i in jsFiles) {
        jsContent += grunt.file.read(jsFiles[i]) + ' ';
      }

      var dataList    = jsContent.match(/data-uk-[a-z\d\-]+/g),
        dataSet     = {};

      dataList.forEach(function(s) { dataSet[s] = true; });
      dataList = Object.keys(dataSet);
      pystring += 'uikit_data = ["' + dataList.join('", "') + '"]\n';

      grunt.file.write('dist/uikit_completions.py', pystring);
      grunt.log.writeln('Written: dist/uikit_completions.py');
    });

    // Load grunt tasks from NPM packages
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-banner");

    // Register grunt tasks
    grunt.registerTask("build", ["jshint", "indexthemes", "less", "concat", "copy", "uglify", "usebanner"]);
    grunt.registerTask("default", ["build", "compress"]);

};
<commit_msg>Fixes #309<commit_after>module.exports = function(grunt) {

    "use strict";

    var fs = require('fs'), pkginfo = grunt.file.readJSON("package.json");

    grunt.initConfig({

        pkg: pkginfo,

        meta: {
          banner: "/*! <%= pkg.title %> <%= pkg.version %> | <%= pkg.homepage %> | (c) 2014 YOOtheme | MIT License */"
        },

        jshint: {
            src: {
                options: {
                    jshintrc: "src/.jshintrc"
                },
                src: ["src/js/*.js"]
            }
        },

        less: (function(){

            var lessconf = {
                "docsmin": {
                    options: { paths: ["docs/less"], cleancss: true },
                    files: { "docs/css/uikit.docs.min.css": ["docs/less/uikit.less"] }
                }
            },

            themes = [];

            //themes

            ["default", "custom"].forEach(function(f){

                if(fs.existsSync('themes/'+f)) {

                    fs.readdirSync('themes/'+f).forEach(function(t){

                        var themepath = 'themes/'+f+'/'+t,
                            distpath  = f=="default" ? "dist/css" : themepath+"/dist";

                        // Is it a directory?
                        if (fs.lstatSync(themepath).isDirectory() && t!=="blank" && t!=='.git') {

                            var files = {};

                            if(t=="default") {
                                files[distpath+"/uikit.css"] = [themepath+"/uikit.less"];
                            } else {
                                files[distpath+"/uikit."+t+".css"] = [themepath+"/uikit.less"];
                            }

                            lessconf[t] = {
                                "options": { paths: [themepath] },
                                "files": files
                            };

                            var filesmin = {};

                            if(t=="default") {
                                filesmin[distpath+"/uikit.min.css"] = [themepath+"/uikit.less"];
                            } else {
                                filesmin[distpath+"/uikit."+t+".min.css"] = [themepath+"/uikit.less"];
                            }

                            lessconf[t+"min"] = {
                                "options": { paths: [themepath], cleancss: true},
                                "files": filesmin
                            };

                            themes.push({ "path":themepath, "name":t, "dir":f });
                        }
                    });
                }
            });

            //addons

            fs.readdirSync('src/less/addons').forEach(function(f){

                if(f.match(/\.less$/)) {

                  var addon = f.replace(".less", "");

                    lessconf["addon-"+f] = {options: { paths: ['src/less/addons'] }, files: {} };
                    lessconf["addon-"+f].files["dist/addons/"+addon+"/"+addon+".css"] = ['src/less/addons/'+f];

                    lessconf["addon-min-"+f] = {options: { paths: ['src/less/addons'], cleancss: true }, files: {} };
                    lessconf["addon-min-"+f].files["dist/addons/"+addon+"/"+addon+".min.css"] = ['src/less/addons/'+f];

                    // look for theme overrides
                    themes.forEach(function(theme){

                       var override = theme.path+'/addon.'+f,
                           distpath = theme.dir=="default" ? "dist/addons/"+addon : theme.path+"/dist/addons/"+addon;

                       if(fs.existsSync(override)) {

                         if(theme.dir=="default" && theme.name=="default") {

                           lessconf["addon-"+f+"-"+theme.name] = {options: { paths: [theme.path] }, files: {} };
                           lessconf["addon-"+f+"-"+theme.name].files[distpath+"/"+addon+".css"] = [override];

                           lessconf["addon-min-"+f+"-"+theme.name] = {options: { paths: [theme.path], cleancss: true }, files: {} };
                           lessconf["addon-min-"+f+"-"+theme.name].files[distpath+"/"+addon+".min.css"] = [override];

                         } else {

                            lessconf["addon-"+f+"-"+theme.name] = {options: { paths: [theme.path] }, files: {} };
                            lessconf["addon-"+f+"-"+theme.name].files[distpath+"/"+addon+"."+theme.name+".css"] = [override];

                            lessconf["addon-min-"+f+"-"+theme.name] = {options: { paths: [theme.path], cleancss: true }, files: {} };
                            lessconf["addon-min-"+f+"-"+theme.name].files[distpath+"/"+addon+"."+theme.name+".min.css"] = [override];

                         }
                       }
                    });
                }

            });

            return lessconf;
        })(),

        copy: {
            fonts: {
                files: [{ expand: true, cwd: "src/fonts", src: ["*"], dest: "dist/fonts/" }]
            }
        },

        concat: {
            dist: {
                options: {
                    separator: "\n\n"
                },
                src: ["src/js/core.js",
                      "src/js/utility.js",
                      "src/js/touch.js",
                      "src/js/alert.js",
                      "src/js/button.js",
                      "src/js/dropdown.js",
                      "src/js/grid.js",
                      "src/js/modal.js",
                      "src/js/offcanvas.js",
                      "src/js/nav.js",
                      "src/js/tooltip.js",
                      "src/js/switcher.js",
                      "src/js/tab.js",
                      "src/js/search.js",
                      "src/js/scrollspy.js",
                      "src/js/smooth-scroll.js",
                      "src/js/toggle.js",
                      ],
                dest: "dist/js/uikit.js"
            }
        },

        usebanner: {
            dist: {
              options: {
                position: 'top',
                banner: "<%= meta.banner %>\n"
              },
              files: {
                src: [ 'dist/css/*.css', 'dist/js/*.js', 'dist/addons/**/*.css', 'dist/addons/**/*.js' ]
              }
            }
        },

        uglify: {
            distmin: {
                options: {
                    //banner: "<%= meta.banner %>\n"
                },
                files: {
                    "dist/js/uikit.min.js": ["dist/js/uikit.js"]
                }
            },
            addonsmin: {
              files: (function(){

                  var files = {};

                  fs.readdirSync('src/js/addons').forEach(function(f){

                      if(f.match(/\.js/)) {

                        var addon = f.replace(".js", "");

                        grunt.file.copy('src/js/addons/'+f, 'dist/addons/'+addon+'/'+f);

                        files['dist/addons/'+addon+'/'+addon+'.min.js'] = ['src/js/addons/'+f];

                      }
                  });

                  return files;
              })()
            }
        },

        compress: {
            dist: {
                options: {
                    archive: ("dist/uikit-"+pkginfo.version+".zip")
                },
                files: [
                    { expand: true, cwd: "dist/", src: ["css/*", "js/*", "fonts/*", "addons/**/*"], dest: "" }
                ]
            }
        },

        watch: {
            src: {
                files: ["src/**/*.less", "themes/**/*.less","src/js/*.js"],
                tasks: ["build"]
            }
        }

    });

    grunt.registerTask('indexthemes', 'Rebuilding theme index.', function() {

       var themes = [];

       ["default", "custom"].forEach(function(f){

           if(fs.existsSync('themes/'+f)) {

               fs.readdirSync('themes/'+f).forEach(function(t){

                   var themepath = 'themes/'+f+'/'+t;

                   // Is it a directory?
                   if (fs.lstatSync(themepath).isDirectory() && t!=="blank" && t!=='.git') {

                       var theme = {
                           "name"  : t.split("-").join(" ").replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) { return $1.toUpperCase(); }),
                           "url"   : "../"+themepath+"/uikit.less",
                           "config": (fs.existsSync(themepath+"/customizer.json") ? "../"+themepath+"/customizer.json" : "../themes/default/uikit/customizer.json"),
                           "styles": {}
                       };

                       if(fs.existsSync(themepath+'/styles')) {

                          var styles = {};

                          fs.readdirSync(themepath+'/styles').forEach(function(sf){

                              var stylepath = [themepath, 'styles', sf, 'style.less'].join('/');

                              if(fs.existsSync(stylepath)) {
                                styles[sf] = "../"+themepath+"/styles/"+sf+"/style.less";
                              }
                          });

                          theme.styles = styles;
                       }

                       themes.push(theme);
                   }
               });
           }
       });

       grunt.log.writeln(themes.length+' themes found: ' + themes.map(function(theme){ return theme.name;}).join(", "));

       fs.writeFileSync("themes/themes.json", JSON.stringify(themes, " ", 4));
    });

    grunt.registerTask('sublime', 'Building Sublime Text Package', function() {
      // css core
      var filepath = 'dist/css/uikit.css';
      var cssFiles = [filepath];
      if (!fs.existsSync(filepath)) {
        grunt.log.error("Not found: " + filepath);
        return;
      }
      // css addons
      fs.readdirSync('dist/addons').forEach(function(f){
        var addon_css_file = 'dist/addons/'+f+'/'+f+'.css';
        if (fs.existsSync(addon_css_file)) {
          cssFiles.push(addon_css_file);
        }
      });
      var cssContent = "";
      for (var i in cssFiles) {
        cssContent += grunt.file.read(cssFiles[i])+' ';
      }
      var classesList = cssContent.match(/\.(uk-[a-z\d\-]+)/g),
          classesSet  = {},
          pystring    = '# copy & paste into sublime plugin code:\n';

      // use object as set (no duplicates)
      classesList.forEach(function(c) {
        c = c.substr(1); // remove leading dot
        classesSet[c] = true;
      });

      // convert set back to list
      classesList = Object.keys(classesSet);

      pystring += 'uikit_classes = ["' + classesList.join('", "') + '"]\n';

      // JS core
      filepath = 'dist/js/uikit.js';
      if (!fs.existsSync(filepath)) {
        grunt.log.error("Not found: " + filepath);
        return;
      }
      var jsFiles = [filepath];

      // JS addons
      fs.readdirSync('dist/addons').forEach(function(f){
        var addon_js_file = 'dist/addons/'+f+'/'+f+'.js';
        if (fs.existsSync(addon_js_file)) {
          jsFiles.push(addon_js_file);
        }
      });
      var jsContent = "";
      for (var i in jsFiles) {
        jsContent += grunt.file.read(jsFiles[i]) + ' ';
      }

      var dataList    = jsContent.match(/data-uk-[a-z\d\-]+/g),
        dataSet     = {};

      dataList.forEach(function(s) { dataSet[s] = true; });
      dataList = Object.keys(dataSet);
      pystring += 'uikit_data = ["' + dataList.join('", "') + '"]\n';

      grunt.file.write('dist/uikit_completions.py', pystring);
      grunt.log.writeln('Written: dist/uikit_completions.py');
    });

    // Load grunt tasks from NPM packages
    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-banner");

    // Register grunt tasks
    grunt.registerTask("build", ["jshint", "indexthemes", "less", "concat", "copy", "uglify", "usebanner"]);
    grunt.registerTask("default", ["build", "compress"]);

};
<|endoftext|>


<commit_before>// Generated on 2014-03-28 using generator-phaser-official 0.0.8-rc-2
'use strict';
var config = require('./config.json'),
    _ = require('underscore'),
    shell = require('shelljs'),
    LIVERELOAD_PORT = 35729,
    lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});

_.str = require('underscore.string');
_.mixin(_.str.exports());

function mountFolder(connect, dir) {
  return connect.static(require('path').resolve(dir));
}

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({
    manifest: grunt.file.readJSON('manifest.json'),
    watch: {
      scripts: {
        files: [
          '!game/main.js',
          'game/**/*',
          'templates/*.tpl',
          'config.json',
          'css/**/*.css'
        ],
        options: {
          spawn: false,
          livereload: LIVERELOAD_PORT
        },
        tasks: ['build:serve:dev']
      }
    },
    connect: {
      options: {
        port: 9000,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, 'serve')
            ];
          }
        }
      }
    },
    open: {
      server: {
        path: 'http://<%= connect.options.hostname %>:<%= connect.options.port %>'
      }
    },
    copy: {
      serve: {
        files: [
          // includes files within path and its sub-directories
          { expand: true, src: ['assets/**', 'fonts/**', 'css/**'], dest: 'serve/' },
          { expand: true, flatten: true, src: [
            'game/plugins/*{.js,.map}',
            'bower_components/*/build/*{.js,.map}',
            'bower_components/*/dist/*{.js,.map}',
            'game/index.html'
          ], dest: 'serve/' }
        ]
      },
      dist: {
        files: [
          // includes files within path and its sub-directories
          { expand: true, src: [
            'assets/**',
            'fonts/**',
            'css/**',
            'icon.png',
            'manifest.json'
          ], dest: 'dist/' },
          { expand: true, flatten: true, src: [
            'game/plugins/*{.min.js,.map}',
            'bower_components/*/build/*{.min.js,.map}',
            'bower_components/*/dist/*{.min.js,.map}',
            'game/index.html'
          ], dest: 'dist/' }
        ]
      },
      dev: {
        options: {
          process: function(content) {
            return grunt.template.process(content, {
              data: {
                dependencies: [
                  'cordova.js',
                  'phaser.js',
                  'phaser-state-transition-plugin.js',
                  'game.js'
                ]
              }
            });
          }
        },
        files: [
          { src: 'game/config/config.dev.json', dest: 'game/config.json' },
          { src: 'templates/_index.html.tpl', dest: 'game/index.html' }
        ]
      },
      prod: {
        options: {
          process: function(content) {
            return grunt.template.process(content, {
              data: {
                dependencies: [
                  'cordova.js',
                  'phaser.min.js',
                  'phaser-state-transition-plugin.min.js',
                  'game.min.js'
                ]
              }
            });
          }
        },
        files: [
          { src: 'game/config/config.prod.json', dest: 'game/config.json' },
          { src: 'templates/_index.html.tpl', dest: 'game/index.html' }
        ]
      }
    },
    browserify: {
      serve: {
        src: ['game/main.js'],
        dest: 'serve/game.js'
      },
      dist: {
        src: ['game/main.js'],
        // dest: 'dist/game.js'
        dest: '.cache/game.js'
      }
    },
    uglify: {
      prod: {
        // comment below to disable
        files: {
          'dist/game.min.js': ['.cache/game.js'],
          'serve/game.min.js': ['.cache/game.js']
        }
      },
      dev: {}
    },
    clean: {
      serve: ['serve'],
      dist: ['dist', 'build'],
    },
    shell: {
      options: {
        stderr: false
      },
      xwalkBuild: {
        command: [
          'python $CROSSWALK_HOME/make_apk.py',
          '--manifest=dist/manifest.json',
          '--package=<%= manifest.package %>',
          '--name=<%= manifest.name %>',
          '--target-dir=build',
          '--mode=' + grunt.option('mode', 'embedded'),
          grunt.option('enable-remote-debugging') ? '--enable-remote-debugging' : '',
          grunt.option('verbose') ? '--verbose' : '',
          // Options for signing the apk for google play
          grunt.option('keystore-path') ? '--keystore-path=' + grunt.option('keystore-path') : '',
          grunt.option('keystore-alias') ? '--keystore-alias=' + grunt.option('keystore-alias') : '',
          grunt.option('keystore-passcode') ? '--keystore-passcode=' + grunt.option('keystore-passcode') : '',
          grunt.option('keystore-alias-passcode') ? '--keystore-alias-passcode=' + grunt.option('keystore-alias-passcode') : '',
          grunt.option('compressor') ? '--compressor' : ''
        ].join(' ')
      },
      xwalkInstallx86: {
        command: 'adb install -r build/*_x86.apk'
      },
      xwalkInstallarm: {
        command: 'adb install -r build/*_arm.apk'
      },
      restartAdb: {
        command: [
          'sudo $(which adb) kill-server',
          'sudo $(which adb) start-server',
          'adb devices'
        ].join('&&')
      },
      cordovaPrepare: {
        command: [
          'rm -rf www',
          'cp -a dist www'
        ].join('&&')
      },
      cordovaSplashIcons: {
        command: [
          'cordova-icon',
          'cordova-splash'
        ].join('&&')
      }
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json', 'manifest.json', 'config.xml'],
        updateConfigs: [],
        commit: true,
        commitMessage: 'Release %VERSION%',
        commitFiles: ['package.json', 'bower.json', 'manifest.json', 'config.xml'],
        createTag: false,
        tagName: '%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: false,
        pushTo: 'upstream',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d'
      }
    },
    jshint: {
      all: ['game/**/*.js', 'Gruntfile.js'],
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      }
    },
    jscs: {
      src: [
        'game/**/*.js',
        '!game/main.js',
        '!game/plugins/*'
      ],
      options: {
        config: '.jscsrc',
        reporter: require('jscs-stylish').path
      }
    },
    githooks: {
      all: {
        'pre-commit': 'jshint jscs',
      }
    },
    'notify_hooks': {
      options: {
        enabled: true,
        'max_jshint_notifications': 5, // maximum number of notifications from jshint output
        success: true, // whether successful grunt executions should be notified automatically
        duration: 3 // the duration of notification in seconds, for `notify-send only
      }
    },
  });

  // Register Grunt Tasks
  grunt.registerTask('default', 'serve');
  grunt.registerTask('buildBootstrapper', function() {
    var stateFiles = grunt.file.expand('game/states/*.js'),
        gameStates = [],
        statePattern = new RegExp(/(\w+).js$/),
        bootstrapper = grunt.file.read('templates/_main.js.tpl');

    stateFiles.forEach(function(file) {
      var state = file.match(statePattern)[1];
      if (!!state) {
        gameStates.push({shortName: state, stateName: _.capitalize(state) + 'State'});
      }
    });
    config.gameStates = gameStates;
    bootstrapper = grunt.template.process(bootstrapper, {data: config});
    grunt.file.write('game/main.js', bootstrapper);
  });
  grunt.registerTask('build', function(dest, environment) {
    grunt.task.run([
      'buildBootstrapper',
      'browserify:' + (dest || 'dist'),
      'copy:' + (environment || 'prod'),
      'copy:' + (dest || 'dist'),
      'uglify:' + (environment || 'prod'),
      'notify_hooks'
    ]);
  });
  grunt.registerTask('serve', function(environment) {
    grunt.task.run([
      'githooks',
      'clean:serve',
      'copy:' + (environment || 'dev'),
      'build:serve:' + (environment || 'dev'),
      'connect:livereload',
      'open',
      'watch'
    ]);
  });
  grunt.registerTask('xwalkBuild', function(environment) {
    grunt.task.run([
      'clean:dist',
      'copy:' + (environment || 'prod'),
      'build:dist',
      'shell:xwalkBuild',
      'notify_hooks'
    ]);
  });
  grunt.registerTask('restartAdb', ['shell:restartAdb']);
  grunt.registerTask('xwalkInstall', function(arch) {
    // arch is x86 (Intel based tablets) or arm (non-Intel)
    grunt.task.run(['shell:xwalkInstall' + (arch || 'arm'), 'notify_hooks']);
  });
  grunt.registerTask('cordovaPlatformsPlugins', function() {
    var pkg = grunt.file.readJSON('package.json');
    if (!pkg.platforms) {
      return grunt.log.error('Platforms not found.');
    }
    if (grunt.option('preserve-platforms')) {
      return grunt.log.writeln('Preserves platforms and plugins');
    }
    _.forEach(pkg.platforms, function (platform) {
      grunt.log.writeln('Installing platform ' + platform);
      shell.exec('cordova platform add ' + platform);
    });
    _.forEach(pkg.plugins, function (plugin) {
      grunt.log.writeln('Installing plugin ' + plugin);
      shell.exec('cordova plugin add ' + plugin);
    });
  });
  grunt.registerTask('cordovaPrepare', function(environment) {
    var tasks = [
      'clean:dist',
      'copy:' + (environment || 'prod'),
      'build:dist',
      'shell:cordovaPrepare',
      'cordovaPlatformsPlugins'
    ];
    if (grunt.option('splashicons')) {
      tasks.push('shell:cordovaSplashIcons');
    }
    grunt.task.run(tasks);
  });
};
<commit_msg>refactor(build): removes duplicate copy env<commit_after>// Generated on 2014-03-28 using generator-phaser-official 0.0.8-rc-2
'use strict';
var config = require('./config.json'),
    _ = require('underscore'),
    shell = require('shelljs'),
    LIVERELOAD_PORT = 35729,
    lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});

_.str = require('underscore.string');
_.mixin(_.str.exports());

function mountFolder(connect, dir) {
  return connect.static(require('path').resolve(dir));
}

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({
    manifest: grunt.file.readJSON('manifest.json'),
    watch: {
      scripts: {
        files: [
          '!game/main.js',
          'game/**/*',
          'templates/*.tpl',
          'config.json',
          'css/**/*.css'
        ],
        options: {
          spawn: false,
          livereload: LIVERELOAD_PORT
        },
        tasks: ['build:serve:dev']
      }
    },
    connect: {
      options: {
        port: 9000,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, 'serve')
            ];
          }
        }
      }
    },
    open: {
      server: {
        path: 'http://<%= connect.options.hostname %>:<%= connect.options.port %>'
      }
    },
    copy: {
      serve: {
        files: [
          // includes files within path and its sub-directories
          { expand: true, src: ['assets/**', 'fonts/**', 'css/**'], dest: 'serve/' },
          { expand: true, flatten: true, src: [
            'game/plugins/*{.js,.map}',
            'bower_components/*/build/*{.js,.map}',
            'bower_components/*/dist/*{.js,.map}',
            'game/index.html'
          ], dest: 'serve/' }
        ]
      },
      dist: {
        files: [
          // includes files within path and its sub-directories
          { expand: true, src: [
            'assets/**',
            'fonts/**',
            'css/**',
            'icon.png',
            'manifest.json'
          ], dest: 'dist/' },
          { expand: true, flatten: true, src: [
            'game/plugins/*{.min.js,.map}',
            'bower_components/*/build/*{.min.js,.map}',
            'bower_components/*/dist/*{.min.js,.map}',
            'game/index.html'
          ], dest: 'dist/' }
        ]
      },
      dev: {
        options: {
          process: function(content) {
            return grunt.template.process(content, {
              data: {
                dependencies: [
                  'cordova.js',
                  'phaser.js',
                  'phaser-state-transition-plugin.js',
                  'game.js'
                ]
              }
            });
          }
        },
        files: [
          { src: 'game/config/config.dev.json', dest: 'game/config.json' },
          { src: 'templates/_index.html.tpl', dest: 'game/index.html' }
        ]
      },
      prod: {
        options: {
          process: function(content) {
            return grunt.template.process(content, {
              data: {
                dependencies: [
                  'cordova.js',
                  'phaser.min.js',
                  'phaser-state-transition-plugin.min.js',
                  'game.min.js'
                ]
              }
            });
          }
        },
        files: [
          { src: 'game/config/config.prod.json', dest: 'game/config.json' },
          { src: 'templates/_index.html.tpl', dest: 'game/index.html' }
        ]
      }
    },
    browserify: {
      serve: {
        src: ['game/main.js'],
        dest: 'serve/game.js'
      },
      dist: {
        src: ['game/main.js'],
        // dest: 'dist/game.js'
        dest: '.cache/game.js'
      }
    },
    uglify: {
      prod: {
        // comment below to disable
        files: {
          'dist/game.min.js': ['.cache/game.js'],
          'serve/game.min.js': ['.cache/game.js']
        }
      },
      dev: {}
    },
    clean: {
      serve: ['serve'],
      dist: ['dist', 'build'],
    },
    shell: {
      options: {
        stderr: false
      },
      xwalkBuild: {
        command: [
          'python $CROSSWALK_HOME/make_apk.py',
          '--manifest=dist/manifest.json',
          '--package=<%= manifest.package %>',
          '--name=<%= manifest.name %>',
          '--target-dir=build',
          '--mode=' + grunt.option('mode', 'embedded'),
          grunt.option('enable-remote-debugging') ? '--enable-remote-debugging' : '',
          grunt.option('verbose') ? '--verbose' : '',
          // Options for signing the apk for google play
          grunt.option('keystore-path') ? '--keystore-path=' + grunt.option('keystore-path') : '',
          grunt.option('keystore-alias') ? '--keystore-alias=' + grunt.option('keystore-alias') : '',
          grunt.option('keystore-passcode') ? '--keystore-passcode=' + grunt.option('keystore-passcode') : '',
          grunt.option('keystore-alias-passcode') ? '--keystore-alias-passcode=' + grunt.option('keystore-alias-passcode') : '',
          grunt.option('compressor') ? '--compressor' : ''
        ].join(' ')
      },
      xwalkInstallx86: {
        command: 'adb install -r build/*_x86.apk'
      },
      xwalkInstallarm: {
        command: 'adb install -r build/*_arm.apk'
      },
      restartAdb: {
        command: [
          'sudo $(which adb) kill-server',
          'sudo $(which adb) start-server',
          'adb devices'
        ].join('&&')
      },
      cordovaPrepare: {
        command: [
          'rm -rf www',
          'cp -a dist www'
        ].join('&&')
      },
      cordovaSplashIcons: {
        command: [
          'cordova-icon',
          'cordova-splash'
        ].join('&&')
      }
    },
    bump: {
      options: {
        files: ['package.json', 'bower.json', 'manifest.json', 'config.xml'],
        updateConfigs: [],
        commit: true,
        commitMessage: 'Release %VERSION%',
        commitFiles: ['package.json', 'bower.json', 'manifest.json', 'config.xml'],
        createTag: false,
        tagName: '%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: false,
        pushTo: 'upstream',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d'
      }
    },
    jshint: {
      all: ['game/**/*.js', 'Gruntfile.js'],
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      }
    },
    jscs: {
      src: [
        'game/**/*.js',
        '!game/main.js',
        '!game/plugins/*'
      ],
      options: {
        config: '.jscsrc',
        reporter: require('jscs-stylish').path
      }
    },
    githooks: {
      all: {
        'pre-commit': 'jshint jscs',
      }
    },
    'notify_hooks': {
      options: {
        enabled: true,
        'max_jshint_notifications': 5, // maximum number of notifications from jshint output
        success: true, // whether successful grunt executions should be notified automatically
        duration: 3 // the duration of notification in seconds, for `notify-send only
      }
    },
  });

  // Register Grunt Tasks
  grunt.registerTask('default', 'serve');
  grunt.registerTask('buildBootstrapper', function() {
    var stateFiles = grunt.file.expand('game/states/*.js'),
        gameStates = [],
        statePattern = new RegExp(/(\w+).js$/),
        bootstrapper = grunt.file.read('templates/_main.js.tpl');

    stateFiles.forEach(function(file) {
      var state = file.match(statePattern)[1];
      if (!!state) {
        gameStates.push({shortName: state, stateName: _.capitalize(state) + 'State'});
      }
    });
    config.gameStates = gameStates;
    bootstrapper = grunt.template.process(bootstrapper, {data: config});
    grunt.file.write('game/main.js', bootstrapper);
  });
  grunt.registerTask('build', function(dest, environment) {
    grunt.task.run([
      'buildBootstrapper',
      'browserify:' + (dest || 'dist'),
      'copy:' + (environment || 'prod'),
      'copy:' + (dest || 'dist'),
      'uglify:' + (environment || 'prod'),
      'notify_hooks'
    ]);
  });
  grunt.registerTask('serve', function(environment) {
    grunt.task.run([
      'githooks',
      'clean:serve',
      'copy:' + (environment || 'dev'),
      'build:serve:' + (environment || 'dev'),
      'connect:livereload',
      'open',
      'watch'
    ]);
  });
  grunt.registerTask('xwalkBuild', function(environment) {
    grunt.task.run([
      'clean:dist',
      'build:dist:' + (environment || 'prod'),
      'shell:xwalkBuild',
      'notify_hooks'
    ]);
  });
  grunt.registerTask('restartAdb', ['shell:restartAdb']);
  grunt.registerTask('xwalkInstall', function(arch) {
    // arch is x86 (Intel based tablets) or arm (non-Intel)
    grunt.task.run(['shell:xwalkInstall' + (arch || 'arm'), 'notify_hooks']);
  });
  grunt.registerTask('cordovaPlatformsPlugins', function() {
    var pkg = grunt.file.readJSON('package.json');
    if (!pkg.platforms) {
      return grunt.log.error('Platforms not found.');
    }
    if (grunt.option('preserve-platforms')) {
      return grunt.log.writeln('Preserves platforms and plugins');
    }
    _.forEach(pkg.platforms, function (platform) {
      grunt.log.writeln('Installing platform ' + platform);
      shell.exec('cordova platform add ' + platform);
    });
    _.forEach(pkg.plugins, function (plugin) {
      grunt.log.writeln('Installing plugin ' + plugin);
      shell.exec('cordova plugin add ' + plugin);
    });
  });
  grunt.registerTask('cordovaPrepare', function(environment) {
    var tasks = [
      'clean:dist',
      'build:dist:' + (environment || 'prod'),
      'shell:cordovaPrepare',
      'cordovaPlatformsPlugins'
    ];
    if (grunt.option('splashicons')) {
      tasks.push('shell:cordovaSplashIcons');
    }
    grunt.task.run(tasks);
  });
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/**\n' +
      ' * <%= pkg.description %>\n' +
      ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
      ' * @link <%= pkg.homepage %>\n' +
      ' * @author <%= pkg.author %>\n' +
      ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
      ' */\n'
    },
    dirs: {
      dest: 'dist'
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: ['src/*.js'],
        dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
      }
    },
    zip: {
      '<%= dirs.dest %>/commangular.zip': ['<%= dirs.dest %>/<%= pkg.name %>.js', '<%= dirs.dest %>/<%= pkg.name %>.min.js']
    },
    bower: {
        install: {
          	options: {
          		targetDir: './bower_components',
          		install: true,
          		verbose: false,
          		cleanTargetDir: false,
          		cleanBowerDir: false,
          		bowerOptions: {}
             }
           }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: ['<%= concat.dist.dest %>'],
        dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
      }
    },
    jshint: {
      files: ['Gruntfile.js', 'src/*.js'],
      options: {
        curly: false,
        browser: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        expr: true,
        node: true,
        globals: {
          exports: true,
          angular: false,
          $: false
        }
      }
    },
    karma: {
      options: {
        configFile: 'karma.conf.js'
      },
      build: {
        singleRun: true,
        autoWatch: false
      },
      travis: {
        singleRun: true,
        autoWatch: false,
        browsers: ['Chrome']
      },
      dev: {
        autoWatch: true
      }
    },

    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    }
  });

  // Load the plugin that provides the "jshint" task.
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Load the plugin that provides the "concat" task.
  grunt.loadNpmTasks('grunt-contrib-concat');

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.loadNpmTasks('grunt-bower-task');

  grunt.loadNpmTasks('grunt-karma');

  grunt.loadNpmTasks('grunt-conventional-changelog');

  grunt.loadNpmTasks('grunt-zip');

  // Default task.
  grunt.registerTask('default', ['build']);

  // Build task.
  grunt.registerTask('build', ['bower', 'karma:build','concat', 'uglify', 'zip']);

  grunt.registerTask('test', ['karma:build']);

  grunt.registerTask('travis', ['karma:travis']);

  // Provides the "bump" task.
  grunt.registerTask('bump', 'Increment version number', function() {
    var versionType = grunt.option('type');
    function bumpVersion(version, versionType) {
      var type = {patch: 2, minor: 1, major: 0},
          parts = version.split('.'),
          idx = type[versionType || 'patch'];
      parts[idx] = parseInt(parts[idx], 10) + 1;
      while(++idx < parts.length) { parts[idx] = 0; }
      return parts.join('.');
    }
    var version;
    function updateFile(file) {
      var json = grunt.file.readJSON(file);
      version = json.version = bumpVersion(json.version, versionType || 'patch');
      grunt.file.write(file, JSON.stringify(json, null, '  '));
    }
    updateFile('package.json');
    updateFile('bower.json');
    grunt.log.ok('Version bumped to ' + version);
  });

};
<commit_msg>Added bower task to travis task<commit_after>'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/**\n' +
      ' * <%= pkg.description %>\n' +
      ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
      ' * @link <%= pkg.homepage %>\n' +
      ' * @author <%= pkg.author %>\n' +
      ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
      ' */\n'
    },
    dirs: {
      dest: 'dist'
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: ['src/*.js'],
        dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
      }
    },
    zip: {
      '<%= dirs.dest %>/commangular.zip': ['<%= dirs.dest %>/<%= pkg.name %>.js', '<%= dirs.dest %>/<%= pkg.name %>.min.js']
    },
    bower: {
        install: {
          	options: {
          		targetDir: './bower_components',
          		install: true,
          		verbose: false,
          		cleanTargetDir: false,
          		cleanBowerDir: false,
          		bowerOptions: {}
             }
           }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: ['<%= concat.dist.dest %>'],
        dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
      }
    },
    jshint: {
      files: ['Gruntfile.js', 'src/*.js'],
      options: {
        curly: false,
        browser: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        expr: true,
        node: true,
        globals: {
          exports: true,
          angular: false,
          $: false
        }
      }
    },
    karma: {
      options: {
        configFile: 'karma.conf.js'
      },
      build: {
        singleRun: true,
        autoWatch: false
      },
      travis: {
        singleRun: true,
        autoWatch: false,
        browsers: ['Chrome']
      },
      dev: {
        autoWatch: true
      }
    },

    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    }
  });

  // Load the plugin that provides the "jshint" task.
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Load the plugin that provides the "concat" task.
  grunt.loadNpmTasks('grunt-contrib-concat');

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.loadNpmTasks('grunt-bower-task');

  grunt.loadNpmTasks('grunt-karma');

  grunt.loadNpmTasks('grunt-conventional-changelog');

  grunt.loadNpmTasks('grunt-zip');

  // Default task.
  grunt.registerTask('default', ['build']);

  // Build task.
  grunt.registerTask('build', ['bower', 'karma:build','concat', 'uglify', 'zip']);

  grunt.registerTask('test', ['karma:build']);

  grunt.registerTask('travis', ['bower','karma:travis']);

  // Provides the "bump" task.
  grunt.registerTask('bump', 'Increment version number', function() {
    var versionType = grunt.option('type');
    function bumpVersion(version, versionType) {
      var type = {patch: 2, minor: 1, major: 0},
          parts = version.split('.'),
          idx = type[versionType || 'patch'];
      parts[idx] = parseInt(parts[idx], 10) + 1;
      while(++idx < parts.length) { parts[idx] = 0; }
      return parts.join('.');
    }
    var version;
    function updateFile(file) {
      var json = grunt.file.readJSON(file);
      version = json.version = bumpVersion(json.version, versionType || 'patch');
      grunt.file.write(file, JSON.stringify(json, null, '  '));
    }
    updateFile('package.json');
    updateFile('bower.json');
    grunt.log.ok('Version bumped to ' + version);
  });

};
<|endoftext|>


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

  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-conventional-changelog');

  // Default task.
  grunt.registerTask('default', ['jshint', 'karma']);

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

  // Project configuration.
  grunt.initConfig({
    karma: {
      options: testConfig('test/test.conf.js'),
      singleRun: true
    },
    jshint:{
      files:['src/**/*.js', 'test/**/*.spec.js', 'demo/**/*.js'],
      options: {
          jshintrc: '.jshintrc'
      }
    },
    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    }
  });

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

  // Tasks
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-conventional-changelog');

  // Default task.
  grunt.registerTask('default', ['jshint', 'karma']);

  var testConfig = function(configFile, customOptions) {
    var options = {
      configFile: configFile,
      keepalive : true
    };

    var travisOptions = process.env.TRAVIS && {
      browsers : ['Firefox'],
      reporters: 'dots'
    };

    return grunt.util._.extend(options, customOptions, travisOptions);
  };

  // Project configuration.
  grunt.initConfig({
    karma: {
      options  : testConfig('test/test.conf.js'),
      singleRun: true
    },

    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },

      files: ['src/**/*.js', 'test/**/*.spec.js', 'demo/**/*.js']
    },

    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    }
  });

};
<|endoftext|>


<commit_before>/*!
 * Toro Gruntfile
 * http://jurs.me
 * @author Rasmus Jürs
 */

'use strict';

/**
 * Grunt Module
 */
module.exports = function(grunt) {

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

	  // Project object
	  project: {
		  app: 'toro',
		  sass: [
		    '<%= project.src %>sass'
		  ],
		  css: [
		    '<%= project.src %>stylesheets'
		  ],
      javascripts: [
        '<%= project.src %>/javascripts/build/'
      ],
		  bootstrap_scripts: [
		    'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/'
		  ],
		  bower: [
		    'bower_components'
		  ]
		},

		tag: {
		  banner: '/*!\n' +
		          ' * <%= pkg.name %>\n' +
		          ' * <%= pkg.title %>\n' +
		          ' * <%= pkg.url %>\n' +
		          ' * @author <%= pkg.author %>\n' +
		          ' * @version <%= pkg.version %>\n' +
		          ' * <%= pkg.license %> licensed.\n' +
		          ' */\n'
		},

    /*========================================
    =                ImageMin                =
    ========================================*/

    imagemin: {
      dynamic: {                         // Another target
        files: [{
          expand: true,                  // Enable dynamic expansion
          cwd: 'img/org/',                   // Src matches are relative to this path
          src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
          dest: 'img/min/'                  // Destination path prefix
        }]
      }
    },

    /*---------  End of ImageMin  ----------*/

		/*========================================
		=            Stylesheet stuff            =
		========================================*/

    mkdir: {
      all: {
        options: {
          create: ['<%= project.sass %>/vendors/fancybox', '<%= project.sass %>/vendors/OwlCarousel']
        },
      },
    },

    // Convert CSS TO SCSS
    "sass-convert" : {
      options: {
        from: 'css',
        to: 'scss'
      },
      fancybox: {
        cwd: '<%= project.bower %>/fancybox/source/',
        src: ['*.css','*/*.css'],
        filePrefix: '_',
        dest: '<%= project.sass %>/vendors/fancybox'
      },
      owlcarousel: {
        cwd: '<%= project.bower %>/OwlCarousel/owl-carousel/',
        src: ['*.css','*/*.css'],
        filePrefix: '_',
        dest: '<%= project.sass %>/vendors/OwlCarousel'
      }
    },

		// SASS
		sass: {
			options: {
		      style: 'expanded',
		      banner: '<%= tag.banner %>',
		      compass: false,
		      quiet: true,
          sourcemap: true,
          lineNumbers: true
		    },
		  frontend: {
		    files: {
		      '<%= project.css %>/global.css': '<%= project.sass %>/style.scss'
		    }
		  },
      backend: {
        files: {
          '<%= project.css %>/backend.css': '<%= project.sass %>/themes/backend.scss'
        }
      },
		},

		// CSS AUTOPREFIXER
		autoprefixer: {
	    options: {
	      cascade: true,
	      browsers: ['last 2 version', 'ie 8', 'ie 9'],
	    },
	    all: {
	      options: {
	        // Target-specific options go here.
	      },
	      expand: true,
    		ext: '.autoprefixed.css',
    		cwd: '<%= project.css %>/',
	      src: ['*.css', '!*.autoprefixed.css', '!*.min.css'],
	      dest: '<%= project.css %>/'
	    },
      dev: {
        options: {
          // Target-specific options go here.
        },
        expand: true,
        ext: '.css',
        cwd: '<%= project.css %>/',
        src: ['*.css', '!*.autoprefixed.css', '!*.min.css'],
        dest: '<%= project.css %>/'
      },
      backend: {
        options: {
          // Target-specific options go here.
        },
        expand: true,
        ext: '.autoprefixed.css',
        cwd: '<%= project.css %>/',
        src: 'backend.css',
        dest: '<%= project.css %>/'
      }
	  },

	  // CSS MINIFIER
		cssmin : {
			options: {
	      report: 'gzip',
	    },
      css:{
    		expand: true,
    		ext: '.min.css',
      	cwd: '<%= project.css %>/',
        src: ['*.autoprefixed.css', '!*.min.css',],
        dest: '<%= project.css %>/'
      },
      backend:{
        expand: true,
        ext: '.min.css',
        cwd: '<%= project.css %>/',
        src: 'backend.autoprefixed.css',
        dest: '<%= project.css %>/'
      }
    },

    bless: {
      css: {
        options: {},
        files: {
          'tmp/above-limit.css': 'test/input/global.css'
        }
      }
    },

		/*-----  End of Stylesheet stuff  ------*/

		/*========================================
		=            Javascript Stuff            =
		========================================*/

		// Concatinate javascripts.
		concat: {
	    options: {
	      separator: ';'
	    },
	    dist: {
	      src: [

	      	// Conditionizr
          // '<%= project.bower %>/conditionizr/dist/conditionizr.js',
          // Conditionizr - Detects
            // '<%= project.bower %>/conditionizr/detects/chrome.js',
            // '<%= project.bower %>/conditionizr/detects/chromium.js',
            // '<%= project.bower %>/conditionizr/detects/firefox.js',
            // '<%= project.bower %>/conditionizr/detects/ie6.js',
            // '<%= project.bower %>/conditionizr/detects/ie7.js',
            // '<%= project.bower %>/conditionizr/detects/ie8.js',
            // '<%= project.bower %>/conditionizr/detects/ie9.js',
            // '<%= project.bower %>/conditionizr/detects/ie10.js',
            // '<%= project.bower %>/conditionizr/detects/ie10touch.js',
            // '<%= project.bower %>/conditionizr/detects/ie11.js',
            // '<%= project.bower %>/conditionizr/detects/ios.js',
            // '<%= project.bower %>/conditionizr/detects/linux.js',
            // '<%= project.bower %>/conditionizr/detects/mac.js',
            // '<%= project.bower %>/conditionizr/detects/opera.js',
            // '<%= project.bower %>/conditionizr/detects/retina.js',
            // '<%= project.bower %>/conditionizr/detects/safari.js',
            // '<%= project.bower %>/conditionizr/detects/touch.js',
            // '<%= project.bower %>/conditionizr/detects/windows.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone7.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone75.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone8.js',

            // 'javascripts/conditionizr/conditionizr_setup.js',

	      	// Modernizr
	      	'<%= project.bower %>/modernizr/modernizr.js',

		      // Bootstrap
					// '<%= project.bootstrap_scripts %>/affix.js',
					'<%= project.bootstrap_scripts %>/alert.js',
					'<%= project.bootstrap_scripts %>/button.js',
					// '<%= project.bootstrap_scripts %>/carousel.js',
					'<%= project.bootstrap_scripts %>/collapse.js',
					'<%= project.bootstrap_scripts %>/dropdown.js',
					'<%= project.bootstrap_scripts %>/modal.js',
					// '<%= project.bootstrap_scripts %>/scrollspy.js',
					// '<%= project.bootstrap_scripts %>/tab.js',
					// '<%= project.bootstrap_scripts %>/transition.js',
					'<%= project.bootstrap_scripts %>/tooltip.js',
					// '<%= project.bootstrap_scripts %>/popover.js',

					// Isotope
					'<%= project.bower %>/isotope/dist/isotope.pkgd.min.js',

          // imagesLoaded
          '<%= project.bower %>/imagesloaded/imagesloaded.pkgd.js',

					// Owl Carousel
					'<%= project.bower %>/owlcarousel/owl-carousel/owl.carousel.js',

          // matchHeight
          '<%= project.bower %>/matchHeight/jquery.matchHeight.js',

					// Fancybox 2
					'/fancybox/lib/jquery.mousewheel-3.0.6.pack.js',
					'<%= project.bower %>/fancybox/source/jquery.fancybox.pack.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-buttons.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-media.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-thumbs.js',

					'javascripts/scripts.js'
				],
	      dest: '<%= project.src %>javascripts/build/global.concat.js',
	    },
	  },

	  // Uglify global.js
		uglify: {
		  all: {
		  	options: {
		  		report: 'gzip'
		  	},
		    files: {
	        '<%= project.src %>javascripts/build/global.js': ['<%= project.src %>javascripts/build/global.concat.js']
	      }
		  }
		},

		/*-----  End of Javascript Stuff  ------*/

		/*===================================
		=            The Watcher            =
		===================================*/

		// WATCH
		watch: {

			// Reloads of the GruntFile.js is changed.
			configFiles: {
		    files: [ 'Gruntfile.js'],
		    options: {
		      reload: false,
		      spawn: false
		    }
		  },
		  // Watch for changes to SCSS files.
		  sass_all: {
		  	options: {
					livereload: true
				},
      files: '<%= project.sass %>/{,*/}{,*/}*.{scss,sass}',
		    tasks: [
          'sass:frontend',
          'autoprefixer:dev',
          'rename:mintonone',
        ]
		  },
		  javascripts: {
      files: ['<%= project.bower %>/{,*/}*.js', '<%= project.src %>javascripts/*.js'],
		  	tasks: [
          'concat:dist',
          'rename:concattonone',
        ]
		  }
      ,
      conditionizr: {
      files: ['<%= project.bower %>/{,*/}*.js', '<%= project.src %>javascripts/conditionizr/*.js'],
        tasks: ['concat:dist', 'uglify:all']
      }
		},

		/*-----  End of The Watcher  ------*/

    // CLEAN

    clean: {
      all: {
        src: ["<%= project.css %>", "<%= project.src %>javascripts/build/"]
      },
      frontend: {
        src: ["<%= project.css %>/global.css", "<%= project.src %>javascripts/build/"]
      },
      backend: {
        src: ["<%= project.css %>/backend.css"]
      },
      globalcss: {
        src: ["<%= project.css %>/global.css"]
      },
      unused: {
        src: ["<%= project.css %>/global.autoprefixed.css", "<%= project.css %>/global.min.css", "<%= project.src %>javascripts/build/global.concat.js", "<%= project.css %>/backend.min.css", "<%= project.css %>/backend.autoprefixed.css"]
      }
    },

    rename: {
      options : {
        ignore: true
      },
      mintonone: {
          src: '<%= project.css %>/global.min.css',
          dest: '<%= project.css %>/global.css'
      },
      concattonone: {
          src: '<%= project.src %>javascripts/build/global.concat.js',
          dest: '<%= project.src %>javascripts/build/global.js'
      },
      backend: {
          src: "<%= project.css %>/backend.min.css",
          dest: "<%= project.css %>/backend.css"
      },
    },

	});

	// USE MATCHDEP TO DYNAMICALY LOAD PLUGINS
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	/**
	 * Default task
	 * Run `grunt` on the command line
	 */
	grunt.registerTask('default', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
    'watch',
	]);

  grunt.registerTask('release', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:all',
    'cssmin:css',
    'clean:globalcss',
    'rename:mintonone',
    'concat:dist',
    'uglify:all',
    'clean:backend',
    'sass:backend',
    'autoprefixer:backend',
    'cssmin:backend',
    'clean:backend',
    'rename:backend',
    'clean:unused',
  ]);

  grunt.registerTask('dev', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
  ]);

  grunt.registerTask('backend', [
    'clean:backend',
    'sass:backend',
    'autoprefixer:backend',
    'cssmin:backend',
    'clean:backend',
    'rename:backend',
    'clean:unused',
  ]);

  grunt.registerTask('clean-all', [
    'clean:all',
  ]);

  grunt.registerTask('setup', [
    'clean:all',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
  ]);

  grunt.registerTask('optimize', ['imagemin']);

};
<commit_msg>Add Build Task and remove .map generation<commit_after>/*!
 * Toro Gruntfile
 * http://jurs.me
 * @author Rasmus Jürs
 */

'use strict';

/**
 * Grunt Module
 */
module.exports = function(grunt) {

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

	  // Project object
	  project: {
		  app: 'toro',
		  sass: [
		    '<%= project.src %>sass'
		  ],
		  css: [
		    '<%= project.src %>stylesheets'
		  ],
      javascripts: [
        '<%= project.src %>/javascripts/build/'
      ],
		  bootstrap_scripts: [
		    'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/'
		  ],
		  bower: [
		    'bower_components'
		  ]
		},

		tag: {
		  banner: '/*!\n' +
		          ' * <%= pkg.name %>\n' +
		          ' * <%= pkg.title %>\n' +
		          ' * <%= pkg.url %>\n' +
		          ' * @author <%= pkg.author %>\n' +
		          ' * @version <%= pkg.version %>\n' +
		          ' * <%= pkg.license %> licensed.\n' +
		          ' */\n'
		},

    /*========================================
    =                ImageMin                =
    ========================================*/

    imagemin: {
      dynamic: {                         // Another target
        files: [{
          expand: true,                  // Enable dynamic expansion
          cwd: 'img/org/',                   // Src matches are relative to this path
          src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
          dest: 'img/min/'                  // Destination path prefix
        }]
      }
    },

    /*---------  End of ImageMin  ----------*/

		/*========================================
		=            Stylesheet stuff            =
		========================================*/

    mkdir: {
      all: {
        options: {
          create: ['<%= project.sass %>/vendors/fancybox', '<%= project.sass %>/vendors/OwlCarousel']
        },
      },
    },

    // Convert CSS TO SCSS
    "sass-convert" : {
      options: {
        from: 'css',
        to: 'scss'
      },
      fancybox: {
        cwd: '<%= project.bower %>/fancybox/source/',
        src: ['*.css','*/*.css'],
        filePrefix: '_',
        dest: '<%= project.sass %>/vendors/fancybox'
      },
      owlcarousel: {
        cwd: '<%= project.bower %>/OwlCarousel/owl-carousel/',
        src: ['*.css','*/*.css'],
        filePrefix: '_',
        dest: '<%= project.sass %>/vendors/OwlCarousel'
      }
    },

		// SASS
		sass: {
			options: {
		      style: 'expanded',
		      banner: '<%= tag.banner %>',
		      compass: false,
		      quiet: true,
          lineNumbers: true
		    },
		  frontend: {
		    files: {
		      '<%= project.css %>/global.css': '<%= project.sass %>/style.scss'
		    }
		  },
      backend: {
        files: {
          '<%= project.css %>/backend.css': '<%= project.sass %>/themes/backend.scss'
        }
      },
		},

		// CSS AUTOPREFIXER
		autoprefixer: {
	    options: {
	      cascade: true,
	      browsers: ['last 2 version', 'ie 8', 'ie 9'],
	    },
	    all: {
	      options: {
	        // Target-specific options go here.
	      },
	      expand: true,
    		ext: '.autoprefixed.css',
    		cwd: '<%= project.css %>/',
	      src: ['*.css', '!*.autoprefixed.css', '!*.min.css'],
	      dest: '<%= project.css %>/'
	    },
      dev: {
        options: {
          // Target-specific options go here.
        },
        expand: true,
        ext: '.css',
        cwd: '<%= project.css %>/',
        src: ['*.css', '!*.autoprefixed.css', '!*.min.css'],
        dest: '<%= project.css %>/'
      },
      backend: {
        options: {
          // Target-specific options go here.
        },
        expand: true,
        ext: '.autoprefixed.css',
        cwd: '<%= project.css %>/',
        src: 'backend.css',
        dest: '<%= project.css %>/'
      }
	  },

	  // CSS MINIFIER
		cssmin : {
			options: {
	      report: 'gzip',
	    },
      css:{
    		expand: true,
    		ext: '.min.css',
      	cwd: '<%= project.css %>/',
        src: ['*.autoprefixed.css', '!*.min.css',],
        dest: '<%= project.css %>/'
      },
      backend:{
        expand: true,
        ext: '.min.css',
        cwd: '<%= project.css %>/',
        src: 'backend.autoprefixed.css',
        dest: '<%= project.css %>/'
      }
    },

    bless: {
      css: {
        options: {},
        files: {
          'tmp/above-limit.css': 'test/input/global.css'
        }
      }
    },

		/*-----  End of Stylesheet stuff  ------*/

		/*========================================
		=            Javascript Stuff            =
		========================================*/

		// Concatinate javascripts.
		concat: {
	    options: {
	      separator: ';'
	    },
	    dist: {
	      src: [

	      	// Conditionizr
          // '<%= project.bower %>/conditionizr/dist/conditionizr.js',
          // Conditionizr - Detects
            // '<%= project.bower %>/conditionizr/detects/chrome.js',
            // '<%= project.bower %>/conditionizr/detects/chromium.js',
            // '<%= project.bower %>/conditionizr/detects/firefox.js',
            // '<%= project.bower %>/conditionizr/detects/ie6.js',
            // '<%= project.bower %>/conditionizr/detects/ie7.js',
            // '<%= project.bower %>/conditionizr/detects/ie8.js',
            // '<%= project.bower %>/conditionizr/detects/ie9.js',
            // '<%= project.bower %>/conditionizr/detects/ie10.js',
            // '<%= project.bower %>/conditionizr/detects/ie10touch.js',
            // '<%= project.bower %>/conditionizr/detects/ie11.js',
            // '<%= project.bower %>/conditionizr/detects/ios.js',
            // '<%= project.bower %>/conditionizr/detects/linux.js',
            // '<%= project.bower %>/conditionizr/detects/mac.js',
            // '<%= project.bower %>/conditionizr/detects/opera.js',
            // '<%= project.bower %>/conditionizr/detects/retina.js',
            // '<%= project.bower %>/conditionizr/detects/safari.js',
            // '<%= project.bower %>/conditionizr/detects/touch.js',
            // '<%= project.bower %>/conditionizr/detects/windows.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone7.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone75.js',
            // '<%= project.bower %>/conditionizr/detects/winPhone8.js',

            // 'javascripts/conditionizr/conditionizr_setup.js',

	      	// Modernizr
	      	'<%= project.bower %>/modernizr/modernizr.js',

		      // Bootstrap
					// '<%= project.bootstrap_scripts %>/affix.js',
					'<%= project.bootstrap_scripts %>/alert.js',
					'<%= project.bootstrap_scripts %>/button.js',
					// '<%= project.bootstrap_scripts %>/carousel.js',
					'<%= project.bootstrap_scripts %>/collapse.js',
					'<%= project.bootstrap_scripts %>/dropdown.js',
					'<%= project.bootstrap_scripts %>/modal.js',
					// '<%= project.bootstrap_scripts %>/scrollspy.js',
					// '<%= project.bootstrap_scripts %>/tab.js',
					// '<%= project.bootstrap_scripts %>/transition.js',
					'<%= project.bootstrap_scripts %>/tooltip.js',
					// '<%= project.bootstrap_scripts %>/popover.js',

					// Isotope
					'<%= project.bower %>/isotope/dist/isotope.pkgd.min.js',

          // imagesLoaded
          '<%= project.bower %>/imagesloaded/imagesloaded.pkgd.js',

					// Owl Carousel
					'<%= project.bower %>/owlcarousel/owl-carousel/owl.carousel.js',

          // matchHeight
          '<%= project.bower %>/matchHeight/jquery.matchHeight.js',

					// Fancybox 2
					'/fancybox/lib/jquery.mousewheel-3.0.6.pack.js',
					'<%= project.bower %>/fancybox/source/jquery.fancybox.pack.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-buttons.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-media.js',
					'<%= project.bower %>/fancybox/source/helpers/jquery.fancybox-thumbs.js',

					'javascripts/scripts.js'
				],
	      dest: '<%= project.src %>javascripts/build/global.concat.js',
	    },
	  },

	  // Uglify global.js
		uglify: {
		  all: {
		  	options: {
		  		report: 'gzip'
		  	},
		    files: {
	        '<%= project.src %>javascripts/build/global.js': ['<%= project.src %>javascripts/build/global.concat.js']
	      }
		  }
		},

		/*-----  End of Javascript Stuff  ------*/

		/*===================================
		=            The Watcher            =
		===================================*/

		// WATCH
		watch: {

			// Reloads of the GruntFile.js is changed.
			configFiles: {
		    files: [ 'Gruntfile.js'],
		    options: {
		      reload: false,
		      spawn: false
		    }
		  },
		  // Watch for changes to SCSS files.
		  sass_all: {
		  	options: {
					livereload: true
				},
      files: '<%= project.sass %>/{,*/}{,*/}*.{scss,sass}',
		    tasks: [
          'sass:frontend',
          'autoprefixer:dev',
          'rename:mintonone',
        ]
		  },
		  javascripts: {
      files: ['<%= project.bower %>/{,*/}*.js', '<%= project.src %>javascripts/*.js'],
		  	tasks: [
          'concat:dist',
          'rename:concattonone',
        ]
		  }
      ,
      conditionizr: {
      files: ['<%= project.bower %>/{,*/}*.js', '<%= project.src %>javascripts/conditionizr/*.js'],
        tasks: ['concat:dist', 'uglify:all']
      }
		},

		/*-----  End of The Watcher  ------*/

    // CLEAN

    clean: {
      all: {
        src: ["<%= project.css %>", "<%= project.src %>javascripts/build/"]
      },
      frontend: {
        src: ["<%= project.css %>/global.css", "<%= project.src %>javascripts/build/"]
      },
      backend: {
        src: ["<%= project.css %>/backend.css"]
      },
      globalcss: {
        src: ["<%= project.css %>/global.css"]
      },
      unused: {
        src: ["<%= project.css %>/global.autoprefixed.css", "<%= project.css %>/global.min.css", "<%= project.src %>javascripts/build/global.concat.js", "<%= project.css %>/backend.min.css", "<%= project.css %>/backend.autoprefixed.css"]
      }
    },

    rename: {
      options : {
        ignore: true
      },
      mintonone: {
          src: '<%= project.css %>/global.min.css',
          dest: '<%= project.css %>/global.css'
      },
      concattonone: {
          src: '<%= project.src %>javascripts/build/global.concat.js',
          dest: '<%= project.src %>javascripts/build/global.js'
      },
      backend: {
          src: "<%= project.css %>/backend.min.css",
          dest: "<%= project.css %>/backend.css"
      },
    },

	});

	// USE MATCHDEP TO DYNAMICALY LOAD PLUGINS
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	/**
	 * Default task
	 * Run `grunt` on the command line
	 */
	grunt.registerTask('default', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
    'watch',
	]);

  grunt.registerTask('build', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
  ]);

  grunt.registerTask('release', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:all',
    'cssmin:css',
    'clean:globalcss',
    'rename:mintonone',
    'concat:dist',
    'uglify:all',
    'clean:backend',
    'sass:backend',
    'autoprefixer:backend',
    'cssmin:backend',
    'clean:backend',
    'rename:backend',
    'clean:unused',
  ]);

  grunt.registerTask('dev', [
    'clean:frontend',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
  ]);

  grunt.registerTask('backend', [
    'clean:backend',
    'sass:backend',
    'autoprefixer:backend',
    'cssmin:backend',
    'clean:backend',
    'rename:backend',
    'clean:unused',
  ]);

  grunt.registerTask('clean-all', [
    'clean:all',
  ]);

  grunt.registerTask('setup', [
    'clean:all',
    'mkdir',
    'sass-convert',
    'sass:frontend',
    'autoprefixer:dev',
    'rename:mintonone',
    'concat:dist',
    'rename:concattonone',
    'clean:unused',
  ]);

  grunt.registerTask('optimize', ['imagemin']);

};
<|endoftext|>