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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bower: {
            install: {
                options: {
                    targetDir: 'app/lib'
                }
            }
        },
        less: {
            dev: {
                options: {
                    sourceMap: true,
                    sourceMapRootpath: '../../'
                },
                files: {
                    ".tmp/css/addressbook.css": "app/less/addressbook.less"
                }
            },
            dist: {
                options: {
                    compress: true
                },
                files: {
                    "dist/css/addressbook.min.css": "app/less/addressbook.less"
                }
            }
        },
        coffee: {
            dev: {
                options: {
                    sourceMap: true
                },
                expand: true,
                cwd: 'app/scripts',
                src: '**/*.coffee',
                dest: '.tmp/js',
                ext: '.js'
            },
            dist: {
                files: {
                    '.tmp/js/main.js': 'app/scripts/**/*.coffee'
                }
            }
        },
        karma: {
            options: {
                configFile: 'karma.conf.js'
            },
            dev: {},
            dist: {
                singleRun: true,
                autoWatch: false,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                autoWatch: false,
                reporters: ['junit'],
                junitReporter: {
                    outputFile: 'test-results.xml'
                },
                browsers: ['PhantomJS']
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            dist: {
                files: {
                    'dist/js/app.min.js': [
                        'app/lib/angular/angular.js',
                        'app/hacks/h5shivhack.js', // must be loaded up front of modernizr
                        'app/lib/modernizr/modernizr.js',
                        '.tmp/js/main.js'
                    ]
                }
            }
        },
        watch: {
            less: {
                files: ['app/less/**/*.less'],
                tasks: ['less:dev']
            },
            coffee: {
                files: ['app/scripts/**/*.coffee'],
                tasks: ['coffee:dev']
            }
        },
        htmlbuild: {
            dist: {
                src: 'app/app.html',
                dest: 'dist',
                options: {
                    relative:true,
                    scripts: {
                        main: 'dist/js/app.min.js'
                    },
                    styles: {
                        main: 'dist/css/addressbook.min.css'
                    }
                }
            }
        },
        copy: {
            dev: {
                expand: true,
                cwd: 'app',
                src: ['fonts/*', 'img/*'],
                dest: '.tmp'
            },
            dist: {
                expand: true,
                cwd: 'app',
                src: ['fonts/*', 'img/*'],
                dest: 'dist'
            }
        },
        clean: ["dist", ".tmp"],
        shell: {
            git_tag: {
                command: function() {
                    return "git tag -a CI-" + process.env.BUILD_ID + " -m 'Successfully built by CI.'"
                }
            },
            git_push_tag: {
                command: function() {
                    return "git push CI-" + process.env.BUILD_ID
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-html-build');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-shell');

    grunt.registerTask('dev', ['bower', 'copy:dev', 'coffee:dev', 'less:dev', 'watch']);
    grunt.registerTask('test', ['karma:dev']);
    grunt.registerTask('dist', ['bower', 'karma:dist', 'less:dist', 'coffee:dist', 'uglify:dist', 'htmlbuild:dist', 'copy:dist']);
    grunt.registerTask('ci', ['bower', 'karma:ci', 'less:dist', 'coffee:dist', 'uglify:dist', 'htmlbuild:dist', 'copy:dist', 'shell:git_tag', 'shell:git_push_tag']);

};<commit_msg>maybe git tagging works now on jenkins<commit_after>module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bower: {
            install: {
                options: {
                    targetDir: 'app/lib'
                }
            }
        },
        less: {
            dev: {
                options: {
                    sourceMap: true,
                    sourceMapRootpath: '../../'
                },
                files: {
                    ".tmp/css/addressbook.css": "app/less/addressbook.less"
                }
            },
            dist: {
                options: {
                    compress: true
                },
                files: {
                    "dist/css/addressbook.min.css": "app/less/addressbook.less"
                }
            }
        },
        coffee: {
            dev: {
                options: {
                    sourceMap: true
                },
                expand: true,
                cwd: 'app/scripts',
                src: '**/*.coffee',
                dest: '.tmp/js',
                ext: '.js'
            },
            dist: {
                files: {
                    '.tmp/js/main.js': 'app/scripts/**/*.coffee'
                }
            }
        },
        karma: {
            options: {
                configFile: 'karma.conf.js'
            },
            dev: {},
            dist: {
                singleRun: true,
                autoWatch: false,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                autoWatch: false,
                reporters: ['junit'],
                junitReporter: {
                    outputFile: 'test-results.xml'
                },
                browsers: ['PhantomJS']
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
                    '<%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            dist: {
                files: {
                    'dist/js/app.min.js': [
                        'app/lib/angular/angular.js',
                        'app/hacks/h5shivhack.js', // must be loaded up front of modernizr
                        'app/lib/modernizr/modernizr.js',
                        '.tmp/js/main.js'
                    ]
                }
            }
        },
        watch: {
            less: {
                files: ['app/less/**/*.less'],
                tasks: ['less:dev']
            },
            coffee: {
                files: ['app/scripts/**/*.coffee'],
                tasks: ['coffee:dev']
            }
        },
        htmlbuild: {
            dist: {
                src: 'app/app.html',
                dest: 'dist',
                options: {
                    relative:true,
                    scripts: {
                        main: 'dist/js/app.min.js'
                    },
                    styles: {
                        main: 'dist/css/addressbook.min.css'
                    }
                }
            }
        },
        copy: {
            dev: {
                expand: true,
                cwd: 'app',
                src: ['fonts/*', 'img/*'],
                dest: '.tmp'
            },
            dist: {
                expand: true,
                cwd: 'app',
                src: ['fonts/*', 'img/*'],
                dest: 'dist'
            }
        },
        clean: ["dist", ".tmp"],
        shell: {
            git_tag: {
                command: function() {
                    return "git tag -a CI-" + process.env.BUILD_ID + " -m 'Successfully built by CI.'"
                }
            },
            git_push_tag: {
                command: function() {
                    return "git push --tags"
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-html-build');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-shell');

    grunt.registerTask('dev', ['bower', 'copy:dev', 'coffee:dev', 'less:dev', 'watch']);
    grunt.registerTask('test', ['karma:dev']);
    grunt.registerTask('dist', ['bower', 'karma:dist', 'less:dist', 'coffee:dist', 'uglify:dist', 'htmlbuild:dist', 'copy:dist']);
    grunt.registerTask('ci', ['bower', 'karma:ci', 'less:dist', 'coffee:dist', 'uglify:dist', 'htmlbuild:dist', 'copy:dist', 'shell:git_tag', 'shell:git_push_tag']);

};<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = function (grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),
    uglify: {
      options: {
        banner: '// Version <%= pkg.version %> <%= grunt.template.today("isoDateTime") %>;\n',
        sourceMap: true,
      },
      build: {
        src: jsFileList,
        dest: jsMinFile,
      },
      manager: {
        src: jsManagerSrc,
        dest: jsManagerMinFile,
      },
    },

    postcss: {
      options: {
        failOnError: true,
        map: false,
        processors: [
          require('autoprefixer'),
          require('cssnano')({preset: "default"})
        ]
      },
      dist: {
        src: "css/rg2.css",
        dest: "css/rg2-<%= pkg.version %>.min.css"
      }
    },

    sync: {
      rel: {
        files: [
          {
            src: ["rg2api.php", "index.php", "app/**", "html/**", "img/favicon.ico", "img/manifest.json"],
            dest: "rel/",
          },
        ],
        verbose: true,
        pretend: false, // Don't do any disk operations - just write log. Default: false
        failOnError: true, // Fail the task when copying is not possible. Default: false
        updateAndDelete: true,
      },
    },

    bumpup: "package.json",

    replace: {
      jsversion: {
        src: "js/config.js",
        overwrite: true,
        replacements: [
          {
            from: /RG2VERSION.*'/,
            to: "RG2VERSION: '<%= pkg.version %>'",
          },
        ],
      },
      phpversion: {
        src: ["rg2api.php", "index.php"],
        overwrite: true,
        replacements: [
          {
            from: /\('RG2VERSION'.*\)/,
            to: "('RG2VERSION', '<%= pkg.version %>')",
          },
        ],
      },
    },

    clean: {
      minified: ["js/*.min.js", "js/*.js.map", "css/*.min.css"],
    },
  });

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

  for (var i = 0; i < clubs.length; i++) {
    var club = clubs[i];
    grunt.config(["sync", club], {
      files: [
        {
          cwd: "rel/",
          expand: true,
          src: "**",
          dest: "website/" + club + ".routegadget.co.uk/public_html/rg2/",
        },
      ],
      verbose: true, // Default: false
      pretend: false, // Don't do any disk operations - just write log. Default: false
      failOnError: true, // Fail the task when copying is not possible. Default: false
      ignoreInDest: "rg2-config.php",
      updateAndDelete: true,
    });
  }

  // clok has a different directory set-up
  grunt.config(["sync", "clok"], {
    files: [
      {
        cwd: "rel/",
        expand: true,
        src: "**",
        dest: "website/clok.routegadget.co.uk/public_html/gadget/rg2/",
      },
    ],
    verbose: true, // Default: false
    pretend: false, // Don't do any disk operations - just write log. Default: false
    failOnError: true, // Fail the task when copying is not possible. Default: false
    ignoreInDest: "rg2-config.php",
    updateAndDelete: true,
  });

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

  // increment minor version number: do anything else by editting package.json by hand
  grunt.registerTask("bump", ["bumpup"]);

  grunt.registerTask("build", ["clean:minified", "postcss", "uglify", "build-manager"]);

  grunt.registerTask("build-manager", ["uglify:manager"]);

  grunt.registerTask("deploy", ["replace:jsversion", "replace:phpversion", "build", "sync:rel"]);
};

var jsFileList = [
  "js/rg2.js",
  "js/animation.js",
  "js/canvas.js",
  "js/config.js",
  "js/control.js",
  "js/controls.js",
  "js/course.js",
  "js/courses.js",
  "js/draw.js",
  "js/event.js",
  "js/events.js",
  "js/gpstrack.js",
  "js/handles.js",
  "js/map.js",
  "js/overlay.js",
  "js/plugins.js",
  "js/result.js",
  "js/results.js",
  "js/rg2getjson.js",
  "js/rg2input.js",
  "js/rg2ui.js",
  "js/runner.js",
  "js/stats.js",
  "js/utils.js",
  "js/lib/he.js",
];

var jsManagerSrc = [
  "js/manager.js",
  "js/courseparser.js",
  "js/resultparseriofv2.js",
  "js/resultparseriofv3.js",
  "js/resultparsercsv.js",
  "js/resultparser.js",
  "js/managerui.js",
];

var jsMinFile = "js/rg2-<%= pkg.version %>.min.js";
var jsManagerMinFile = "js/rg2manager-<%= pkg.version %>.min.js";

// installed routegadget.co.uk clubs that need to be updated for a new release
// careful: clok has a different config so is set up separately
var clubs = [
  "aire",
  "albania",
  "ayroc",
  "bado",
  "baoc",
  "basoc",
  "bko",
  "boc",
  "bok",
  "bl",
  "chig",
  "claro",
  "clyde",
  "coboc",
  "cuoc",
  "cvfr",
  "darkandwhite",
  "dee",
  "devonoc",
  "ebor",
  "ecko",
  "elo",
  "epoc",
  "eryri",
  "esoc",
  "euoc",
  "gmoa",
  "gramp",
  "go",
  "halo",
  "happyherts",
  "havoc",
  "hoc",
  "interlopers",
  "invoc",
  "jk",
  "kerno",
  "kfo",
  "kongmmm",
  "lamm",
  "leioc",
  "loc",
  "log",
  "lok",
  "lvo",
  "maroc",
  "masterplanadventure",
  "mdoc",
  "mid-wales",
  "moravian",
  "mvoc",
  "nato",
  "ngoc",
  "noroc",
  "nwo",
  "od",
  "omm",
  "orox",
  "ouoc",
  "oureaevents",
  "pfo",
  "potoc",
  "quantock",
  "rafo",
  "roxburghreivers",
  "run-herts",
  "sa",
  "sarum",
  "saxons",
  "sboc",
  "scottish6days",
  "seloc",
  "sl_2020",
  "slow",
  "slmm",
  "smbo",
  "smoc",
  "sn",
  "so",
  "soa",
  "soc",
  "solway",
  "sos",
  "sportident",
  "sroc",
  "stag",
  "start",
  "suffoc",
  "swoc",
  "syo",
  "tay",
  "test",
  "purple-thistle",
  "tinto",
  "tvoc",
  "walton",
  "waoc",
  "wcoc",
  "wim",
  "wmoc",
  "wrekin",
  "wsco2008",
  "wsx",
];
<commit_msg>Add DFOK<commit_after>/* eslint-env node */
module.exports = function (grunt) {
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),
    uglify: {
      options: {
        banner: '// Version <%= pkg.version %> <%= grunt.template.today("isoDateTime") %>;\n',
        sourceMap: true,
      },
      build: {
        src: jsFileList,
        dest: jsMinFile,
      },
      manager: {
        src: jsManagerSrc,
        dest: jsManagerMinFile,
      },
    },

    postcss: {
      options: {
        failOnError: true,
        map: false,
        processors: [
          require('autoprefixer'),
          require('cssnano')({preset: "default"})
        ]
      },
      dist: {
        src: "css/rg2.css",
        dest: "css/rg2-<%= pkg.version %>.min.css"
      }
    },

    sync: {
      rel: {
        files: [
          {
            src: ["rg2api.php", "index.php", "app/**", "html/**", "img/favicon.ico", "img/manifest.json"],
            dest: "rel/",
          },
        ],
        verbose: true,
        pretend: false, // Don't do any disk operations - just write log. Default: false
        failOnError: true, // Fail the task when copying is not possible. Default: false
        updateAndDelete: true,
      },
    },

    bumpup: "package.json",

    replace: {
      jsversion: {
        src: "js/config.js",
        overwrite: true,
        replacements: [
          {
            from: /RG2VERSION.*'/,
            to: "RG2VERSION: '<%= pkg.version %>'",
          },
        ],
      },
      phpversion: {
        src: ["rg2api.php", "index.php"],
        overwrite: true,
        replacements: [
          {
            from: /\('RG2VERSION'.*\)/,
            to: "('RG2VERSION', '<%= pkg.version %>')",
          },
        ],
      },
    },

    clean: {
      minified: ["js/*.min.js", "js/*.js.map", "css/*.min.css"],
    },
  });

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

  for (var i = 0; i < clubs.length; i++) {
    var club = clubs[i];
    grunt.config(["sync", club], {
      files: [
        {
          cwd: "rel/",
          expand: true,
          src: "**",
          dest: "website/" + club + ".routegadget.co.uk/public_html/rg2/",
        },
      ],
      verbose: true, // Default: false
      pretend: false, // Don't do any disk operations - just write log. Default: false
      failOnError: true, // Fail the task when copying is not possible. Default: false
      ignoreInDest: "rg2-config.php",
      updateAndDelete: true,
    });
  }

  // clok has a different directory set-up
  grunt.config(["sync", "clok"], {
    files: [
      {
        cwd: "rel/",
        expand: true,
        src: "**",
        dest: "website/clok.routegadget.co.uk/public_html/gadget/rg2/",
      },
    ],
    verbose: true, // Default: false
    pretend: false, // Don't do any disk operations - just write log. Default: false
    failOnError: true, // Fail the task when copying is not possible. Default: false
    ignoreInDest: "rg2-config.php",
    updateAndDelete: true,
  });

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

  // increment minor version number: do anything else by editting package.json by hand
  grunt.registerTask("bump", ["bumpup"]);

  grunt.registerTask("build", ["clean:minified", "postcss", "uglify", "build-manager"]);

  grunt.registerTask("build-manager", ["uglify:manager"]);

  grunt.registerTask("deploy", ["replace:jsversion", "replace:phpversion", "build", "sync:rel"]);
};

var jsFileList = [
  "js/rg2.js",
  "js/animation.js",
  "js/canvas.js",
  "js/config.js",
  "js/control.js",
  "js/controls.js",
  "js/course.js",
  "js/courses.js",
  "js/draw.js",
  "js/event.js",
  "js/events.js",
  "js/gpstrack.js",
  "js/handles.js",
  "js/map.js",
  "js/overlay.js",
  "js/plugins.js",
  "js/result.js",
  "js/results.js",
  "js/rg2getjson.js",
  "js/rg2input.js",
  "js/rg2ui.js",
  "js/runner.js",
  "js/stats.js",
  "js/utils.js",
  "js/lib/he.js",
];

var jsManagerSrc = [
  "js/manager.js",
  "js/courseparser.js",
  "js/resultparseriofv2.js",
  "js/resultparseriofv3.js",
  "js/resultparsercsv.js",
  "js/resultparser.js",
  "js/managerui.js",
];

var jsMinFile = "js/rg2-<%= pkg.version %>.min.js";
var jsManagerMinFile = "js/rg2manager-<%= pkg.version %>.min.js";

// installed routegadget.co.uk clubs that need to be updated for a new release
// careful: clok has a different config so is set up separately
var clubs = [
  "aire",
  "albania",
  "ayroc",
  "bado",
  "baoc",
  "basoc",
  "bko",
  "boc",
  "bok",
  "bl",
  "chig",
  "claro",
  "clyde",
  "coboc",
  "cuoc",
  "cvfr",
  "darkandwhite",
  "dee",
  "dfok",
  "devonoc",
  "ebor",
  "ecko",
  "elo",
  "epoc",
  "eryri",
  "esoc",
  "euoc",
  "gmoa",
  "gramp",
  "go",
  "halo",
  "happyherts",
  "havoc",
  "hoc",
  "interlopers",
  "invoc",
  "jk",
  "kerno",
  "kfo",
  "kongmmm",
  "lamm",
  "leioc",
  "loc",
  "log",
  "lok",
  "lvo",
  "maroc",
  "masterplanadventure",
  "mdoc",
  "mid-wales",
  "moravian",
  "mvoc",
  "nato",
  "ngoc",
  "noroc",
  "nwo",
  "od",
  "omm",
  "orox",
  "ouoc",
  "oureaevents",
  "pfo",
  "potoc",
  "quantock",
  "rafo",
  "roxburghreivers",
  "run-herts",
  "sa",
  "sarum",
  "saxons",
  "sboc",
  "scottish6days",
  "seloc",
  "sl_2020",
  "slow",
  "slmm",
  "smbo",
  "smoc",
  "sn",
  "so",
  "soa",
  "soc",
  "solway",
  "sos",
  "sportident",
  "sroc",
  "stag",
  "start",
  "suffoc",
  "swoc",
  "syo",
  "tay",
  "test",
  "purple-thistle",
  "tinto",
  "tvoc",
  "walton",
  "waoc",
  "wcoc",
  "wim",
  "wmoc",
  "wrekin",
  "wsco2008",
  "wsx",
];
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2011-2012, Yahoo! Inc.  All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

/*jslint anon:true, sloppy:true, nomen:true, stupid:true, todo:true,
  regexp:true*/

var fs = require('fs'),
    util = require('util'),
    path = require('path'),
    existsSync = fs.existsSync || path.existsSync,
    hb = require('yui/handlebars').Handlebars,
    tty = require('tty'),
    isatty = tty.isatty(1) && tty.isatty(2);

if (!isatty) {
    // fake out the getters that the "color" library would have added
    (['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red',
        'green', 'blue', 'white', 'cyan', 'magenta']).forEach(function(style) {
        try {
            Object.defineProperty(String.prototype, style, {
                get: function() {
                    return this;
                }
            });
        } catch (e) {
            // just ignore
        }
    });
} else {
    require('colors');
}

function log(message) {
    console.log(message.cyan);
}

function error(message, usage, die) {
    if (message instanceof Error) {
        console.log(('✖ ' + message.message).red.bold);
        if (message.stack) {
            console.log(('\t' + message.stack).red.bold);
        }
    } else {
        console.log(('✖ ' + message).red.bold);
    }
    if (usage) {
        console.log('usage:\n' + usage.grey);
    }
    if (die) {
        process.exit(-1);
    }
}

function success(message) {
    console.log(('✔ ' + message).green.bold);
}

function warn(message) {
    console.log(('⚠ ' + message).yellow);
}

function heir(o) {
    function F() {}
    F.prototype = o;
    return new F();
}

/**
 * Decodes XML entities in the string.
 * Only decodes a subset of named entities.
 * @method decodeHTMLEntities
 * @param {string} txt String to decode
 * @return {string} input string with with XML entities decoded
 */
// TODO:  find a node module that can do this well
function decodeHTMLEntities(txt) {
    txt = txt.replace(/(&[^;]+;)/g, function(all, ent) {
        if ('&#x' === ent.substr(0, 3)) {
            return String.fromCharCode(parseInt(ent.substring(3, ent.length - 1), 16));
        }
        return ent;
    });
    txt = txt.replace(/</g, '<');
    txt = txt.replace(/>/g, '>');
    txt = txt.replace(/"/g, '"');
    txt = txt.replace(/'/g, "'");
    txt = txt.replace(/&/g, '&');
    return txt;
}

function process_template(archetype_path, file, mojit_dir, template) {

    var archetype_file = path.join(archetype_path, file),
        new_file = path.join(mojit_dir, file.substring(0, file.length - 3)),
        buffer = '',
        stat,
        tmpl,
        compiled,
        output;

    /* going to check for file size and use compileText to avoid
       possible problems with any handlebars templateRoot settings
     */
    stat = fs.statSync(archetype_file);
    if (stat.size > 0) {
        tmpl = fs.readFileSync(archetype_file, 'utf8');
        compiled = hb.compile(tmpl);
        output = compiled(template);
        fs.writeFileSync(new_file, output);
    } else {
        fs.writeFileSync(new_file, '');
    }
}

function process_file(archetype_path, file, mojit_dir, template) {
    if (/\.hb$/.test(file)) {
        // Process as a HB template
        process_template(archetype_path, file, mojit_dir, template);
    } else {
        // Just copy the file over
        util.pump(
            fs.createReadStream(path.join(archetype_path, file)),
            fs.createWriteStream(path.join(mojit_dir, file)),
            function(err) {
                if (err) {
                    warn('Failed to copy file: ' + file);
                }
            }
        );
    }
}

function process_directory(archetype_path, dir, mojit_dir, template, force) {
    //    console.log('process_directory(' + archetype_path + ', ' + dir +
    //        ', ' + mojit_dir + ', ' + template + ',' + force + ')');
    var new_dir = path.join(mojit_dir, dir),
        files;

    try {
        fs.mkdirSync(new_dir, parseInt('755', 8));
    } catch (err) {
        if (err.message.match(/EEXIST/)) {
            warn('Overwriting existing directory: ' + new_dir);
        } else if (err.message.match(/ENOENT/) &&
                   mojit_dir.indexOf('mojits') === 0) {
            if (!force) {
                error('Please cd into a Mojito application before creating' +
                    ' a Mojit.\nTo force Mojit creation, use --force.');
            }
        } else {
            error('Unexpected error: ' + err.message);
        }
    }

    // log('created dir: ' + new_dir);
    // console.log('reading dir: ' + path.join(archetype_path, dir));

    files = fs.readdirSync(path.join(archetype_path, dir));
    files.forEach(function(f) {
        var s = fs.statSync(path.join(archetype_path, '/', dir, '/', f));

        if (f.charAt(0) === '.') {
            return;
        }
        if (s.isDirectory()) {
            process_directory(path.join(archetype_path, '/', dir), f,
                path.join(mojit_dir, '/', dir), template, force);
        } else {
            process_file(path.join(archetype_path, '/', dir), f,
                new_dir, template);
        }
    });
}

/**
 * returns a function that determines whether a name is excluded from a list
 * using a set of firewall style rules.
 *
 * Each rule looks like this:
 *  { pattern: /matchPattern/, include: true|false, type: file|dir|any }
 *
 *  If a file matches a rule, it is included or excluded based on the value of
 *  the include flag If rule is a regexp, it is taken to be { pattern: regexp,
 *  include: false, type: 'any' } - i.e. it is an exclusion rule.
 *  The first rule that matches, wins.
 *  The defaultIsExclude value specifies the behavior when none of the rules
 *  match (if not specified, the file is included)
 *
 * @param {Array} rules set of rules to determine what files and directories are
 *     copied.
 * @param {boolean} defaultIsExclude determines what to do when none of the
 *     rules match.
 * @return {function} A match function.
 */
function getExclusionMatcher(rules, defaultIsExclude) {

    return function isExcluded(name, ofType) {
        var index,
            include,
            pattern,
            rule,
            type,
            matchedRule,
            ret = null;

        if (!(ofType === 'file' || ofType === 'dir')) {
            throw new Error(
                'Internal error: file type was not provided, was [' +
                    ofType + ']'
            );
        }

        /* check if there are any rules */

        if (rules.length < 1) {
            throw new Error('No rules specified');
        }

        // console.log('checking ' + name + '...');
        for (index in rules) {
            // console.log('\t against ' + excludes[regex] + ': ' +
            //     name.search(excludes[regex]));
            if (rules.hasOwnProperty(index)) {

                rule = rules[index];

                if (rule instanceof RegExp) {
                    pattern = rule;
                    include = false;
                    type = 'any';
                } else {
                    pattern = rule.pattern;
                    include = !!rule.include;
                    type = rule.type || 'any';
                }

                if (!(type === 'file' || type === 'dir' || type === 'any')) {
                    throw new Error('Invalid type for match [' + type + ']');
                }

                if (!(pattern instanceof RegExp)) {
                    console.log(rule);
                    throw new Error('Pattern was not a regexp for rule');
                }

                if (name.search(pattern) !== -1 &&
                        (type === 'any' || type === ofType)) {
                    matchedRule = rule;
                    ret = !include;
                    break;
                }
            }
        }

        ret = ret === null ? !!defaultIsExclude : ret;
        //console.log('Match [' + name + '], Exclude= [' + ret + ']');
        //console.log('Used rule');
        //console.log(matchedRule);
        return ret;
    };
}

function copyFile(from, to, cb) {
    var content = fs.readFileSync(from, 'utf-8');

    fs.writeFileSync(to, content, 'utf-8');
    if (typeof cb === 'function') {
        cb();
    }
}

/**
 * recursively copies the source to destination directory based on a matcher
 * that returns whether a file is to be excluded.
 * @param {string} src source dir.
 * @param {string} dest destination dir.
 * @param {function} excludeMatcher the matcher that determines if a given file
 *     is to be excluded.
 */
function copyUsingMatcher(src, dest, excludeMatcher) {

    var filenames,
        basedir,
        i,
        name,
        file,
        newdest,
        type;

    //console.log('copying ' + src + ' to ' + dest);
    /* check if source path exists */

    if (!existsSync(src)) {
        throw new Error(src + ' does not exist');
    }

    /* check if source is a directory */

    if (!fs.statSync(src).isDirectory()) {
        throw new Error(src + ' must be a directory');
    }

    /* get the names of all files and directories under source in an array */

    filenames = fs.readdirSync(src);
    basedir = src;

    /* check if destination directory exists */

    if (!existsSync(dest)) {
        fs.mkdirSync(dest, parseInt('755', 8));
    }

    for (i = 0; i < filenames.length; i += 1) {

        name = filenames[i];
        file = basedir + '/' + name;
        type = fs.statSync(file).isDirectory() ? 'dir' : 'file';
        newdest = dest + '/' + name;

        if (!excludeMatcher(file, type)) {
            //console.log('Copy ' + file + ' as ' + newdest);
            if (type === 'dir') {
                copyUsingMatcher(file, newdest, excludeMatcher);
            } else {
                copyFile(file, newdest);
            }
        }
    }
}

function copyExclude(src, dest, excludes) {
    copyUsingMatcher(src, dest, getExclusionMatcher(excludes, false));
}

function copy(obj) {
    var temp = null,
        key = '';

    if (!obj || typeof obj !== 'object') { return obj; }
    temp = new obj.constructor();
    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            temp[key] = copy(obj[key]);
        }
    }
    return temp;
}

function removeDir(src) {
    var filenames,
        basedir,
        emptydirs,
        name,
        file,
        count;

    /* check if source path exists */
    if (!existsSync(src)) {
        return;
    }

    /* check if source is a directory */
    if (!fs.statSync(src).isDirectory()) {
        throw new Error(src + ' must be a directory');
    }

    /* get the names of all files and directories under source in an array */

    filenames = fs.readdirSync(src);
    basedir = src;
    emptydirs = [];

    for (name in filenames) {
        if (filenames.hasOwnProperty(name)) {
            file = basedir + '/' + filenames[name];
            if (fs.statSync(file).isDirectory()) {
                emptydirs.push(file);
                removeDir(file);
            } else {
                fs.unlinkSync(file);
            }
        }
    }
    for (count = 0; count < emptydirs.length; count += 1) {
        fs.rmdirSync(emptydirs[count]);
    }
}

function makeDir(p, mode) {

    var ps = path.normalize(p).split('/'),
        i;

    if (!mode) {
        mode = parseInt('755', 8);
    }

    for (i = 0; i <= ps.length; i += 1) {
        try {
            fs.mkdirSync(ps.slice(0, i).join('/'), mode);
        } catch (err) {
            // Dirty way to check dir
        }
    }
}

function isMojitoApp(dir, usage, die) {
    // Mojito apps must have:
    // - either server.js OR index.js
    // - the file above must require('mojito')

    var requiresMojito = /require\s*\(\s*'mojito'\s*\)/,
        isMojito = false,
        checker;

    checker = function(file) {
        var filepath,
            contents;

        if (isMojito) { return; }
        filepath = path.join(dir, file);
        if (existsSync(filepath)) {
            contents = fs.readFileSync(filepath, 'utf-8');
            isMojito = requiresMojito.test(contents);
        }
    };

    ['server.js', 'index.js'].forEach(checker);

    // if command usage is provided, it is assumed that we exit on error
    if (!isMojito && usage) {
        error("The directory '" + dir + "' is not a Mojito Application",
            usage, die);
    }

    return isMojito;
}

/**
 * Convert a CSV string into a context object.
 * @param {string} s A string of the form: 'key1:value1,key2:value2'.
 * @return {Object} The context object after conversion.
 */
function contextCsvToObject(s) {
    var ctx = {},
        pairs = s.split(','),
        pair,
        i;

    for (i = 0; i < pairs.length; i += 1) {
        pair = pairs[i].split(':');
        if (pair[0]) {
            if (!pair[1]) {
                warn('Missing value for context key: ' + pair[0]);
            } else {
                ctx[pair[0]] = pair[1];
            }
        }
    }

    return ctx;
}

/**
 */
exports.process_directory = process_directory;

/**
 */
exports.copyExclude = copyExclude;

/**
 */
exports.copyFile = copyFile;

/**
 */
exports.copy = copy;

/**
 */
exports.isMojitoApp = isMojitoApp;

/**
 */
exports.removeDir = removeDir;

/**
 */
exports.makeDir = makeDir;

/**
 */
exports.error = error;

/**
 */
exports.warn = warn;

/**
 */
exports.log = log;

/**
 */
exports.success = success;

/**
 */
exports.getExclusionMatcher = getExclusionMatcher;

/**
 */
exports.copyUsingMatcher = copyUsingMatcher;

/**
 */
exports.heir = heir;

/**
 */
exports.contextCsvToObject = contextCsvToObject;

exports.decodeHTMLEntities = decodeHTMLEntities;
<commit_msg>fix bz 5904449 garbled console output on node 0.8+<commit_after>/*
 * Copyright (c) 2011-2012, Yahoo! Inc.  All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

/*jslint anon:true, sloppy:true, nomen:true, stupid:true, todo:true,
  regexp:true*/

var fs = require('fs'),
    util = require('util'),
    path = require('path'),
    existsSync = fs.existsSync || path.existsSync,
    hb = require('yui/handlebars').Handlebars,
    tty = require('tty'), // use process.stdin/err.isTTY instead
    colors = require('colors');

colors.mode = (tty.isatty(1) && tty.isatty(2)) ? 'console' : 'none';

function log(message) {
    console.log(message.cyan + '');
}

function error(message, usage, die) {
    var msgs = [];

    if (message instanceof Error) {
        msgs.push(('✖ ' + message.message).red.bold);
        if (message.stack) {
            msgs.push('\n' + message.stack.red);
        }
    } else {
        msgs.push(('✖ ' + message).red.bold);
    }

    if (usage) {
        msgs.push('\nusage: ' + usage.grey);
    }

    console.error(msgs.join(' '));

    if (die) {
        process.exit(-1);
    }
}

function success(message) {
    console.log(('✔ ' + message).green.bold + '');
}

function warn(message) {
    console.warn(('⚠ ' + message).yellow + '');
}

function heir(o) {
    function F() {}
    F.prototype = o;
    return new F();
}

/**
 * Decodes XML entities in the string.
 * Only decodes a subset of named entities.
 * @method decodeHTMLEntities
 * @param {string} txt String to decode
 * @return {string} input string with with XML entities decoded
 */
// TODO:  find a node module that can do this well
function decodeHTMLEntities(txt) {
    txt = txt.replace(/(&[^;]+;)/g, function(all, ent) {
        if ('&#x' === ent.substr(0, 3)) {
            return String.fromCharCode(parseInt(ent.substring(3, ent.length - 1), 16));
        }
        return ent;
    });
    txt = txt.replace(/</g, '<');
    txt = txt.replace(/>/g, '>');
    txt = txt.replace(/"/g, '"');
    txt = txt.replace(/'/g, "'");
    txt = txt.replace(/&/g, '&');
    return txt;
}

function process_template(archetype_path, file, mojit_dir, template) {

    var archetype_file = path.join(archetype_path, file),
        new_file = path.join(mojit_dir, file.substring(0, file.length - 3)),
        buffer = '',
        stat,
        tmpl,
        compiled,
        output;

    /* going to check for file size and use compileText to avoid
       possible problems with any handlebars templateRoot settings
     */
    stat = fs.statSync(archetype_file);
    if (stat.size > 0) {
        tmpl = fs.readFileSync(archetype_file, 'utf8');
        compiled = hb.compile(tmpl);
        output = compiled(template);
        fs.writeFileSync(new_file, output);
    } else {
        fs.writeFileSync(new_file, '');
    }
}

function process_file(archetype_path, file, mojit_dir, template) {
    if (/\.hb$/.test(file)) {
        // Process as a HB template
        process_template(archetype_path, file, mojit_dir, template);
    } else {
        // Just copy the file over
        util.pump(
            fs.createReadStream(path.join(archetype_path, file)),
            fs.createWriteStream(path.join(mojit_dir, file)),
            function(err) {
                if (err) {
                    warn('Failed to copy file: ' + file);
                }
            }
        );
    }
}

function process_directory(archetype_path, dir, mojit_dir, template, force) {
    //    console.log('process_directory(' + archetype_path + ', ' + dir +
    //        ', ' + mojit_dir + ', ' + template + ',' + force + ')');
    var new_dir = path.join(mojit_dir, dir),
        files;

    try {
        fs.mkdirSync(new_dir, parseInt('755', 8));
    } catch (err) {
        if (err.message.match(/EEXIST/)) {
            warn('Overwriting existing directory: ' + new_dir);
        } else if (err.message.match(/ENOENT/) &&
                   mojit_dir.indexOf('mojits') === 0) {
            if (!force) {
                error('Please cd into a Mojito application before creating' +
                    ' a Mojit.\nTo force Mojit creation, use --force.');
            }
        } else {
            error('Unexpected error: ' + err.message);
        }
    }

    // log('created dir: ' + new_dir);
    // console.log('reading dir: ' + path.join(archetype_path, dir));

    files = fs.readdirSync(path.join(archetype_path, dir));
    files.forEach(function(f) {
        var s = fs.statSync(path.join(archetype_path, '/', dir, '/', f));

        if (f.charAt(0) === '.') {
            return;
        }
        if (s.isDirectory()) {
            process_directory(path.join(archetype_path, '/', dir), f,
                path.join(mojit_dir, '/', dir), template, force);
        } else {
            process_file(path.join(archetype_path, '/', dir), f,
                new_dir, template);
        }
    });
}

/**
 * returns a function that determines whether a name is excluded from a list
 * using a set of firewall style rules.
 *
 * Each rule looks like this:
 *  { pattern: /matchPattern/, include: true|false, type: file|dir|any }
 *
 *  If a file matches a rule, it is included or excluded based on the value of
 *  the include flag If rule is a regexp, it is taken to be { pattern: regexp,
 *  include: false, type: 'any' } - i.e. it is an exclusion rule.
 *  The first rule that matches, wins.
 *  The defaultIsExclude value specifies the behavior when none of the rules
 *  match (if not specified, the file is included)
 *
 * @param {Array} rules set of rules to determine what files and directories are
 *     copied.
 * @param {boolean} defaultIsExclude determines what to do when none of the
 *     rules match.
 * @return {function} A match function.
 */
function getExclusionMatcher(rules, defaultIsExclude) {

    return function isExcluded(name, ofType) {
        var index,
            include,
            pattern,
            rule,
            type,
            matchedRule,
            ret = null;

        if (!(ofType === 'file' || ofType === 'dir')) {
            throw new Error(
                'Internal error: file type was not provided, was [' +
                    ofType + ']'
            );
        }

        /* check if there are any rules */

        if (rules.length < 1) {
            throw new Error('No rules specified');
        }

        // console.log('checking ' + name + '...');
        for (index in rules) {
            // console.log('\t against ' + excludes[regex] + ': ' +
            //     name.search(excludes[regex]));
            if (rules.hasOwnProperty(index)) {

                rule = rules[index];

                if (rule instanceof RegExp) {
                    pattern = rule;
                    include = false;
                    type = 'any';
                } else {
                    pattern = rule.pattern;
                    include = !!rule.include;
                    type = rule.type || 'any';
                }

                if (!(type === 'file' || type === 'dir' || type === 'any')) {
                    throw new Error('Invalid type for match [' + type + ']');
                }

                if (!(pattern instanceof RegExp)) {
                    console.log(rule);
                    throw new Error('Pattern was not a regexp for rule');
                }

                if (name.search(pattern) !== -1 &&
                        (type === 'any' || type === ofType)) {
                    matchedRule = rule;
                    ret = !include;
                    break;
                }
            }
        }

        ret = ret === null ? !!defaultIsExclude : ret;
        //console.log('Match [' + name + '], Exclude= [' + ret + ']');
        //console.log('Used rule');
        //console.log(matchedRule);
        return ret;
    };
}

function copyFile(from, to, cb) {
    var content = fs.readFileSync(from, 'utf-8');

    fs.writeFileSync(to, content, 'utf-8');
    if (typeof cb === 'function') {
        cb();
    }
}

/**
 * recursively copies the source to destination directory based on a matcher
 * that returns whether a file is to be excluded.
 * @param {string} src source dir.
 * @param {string} dest destination dir.
 * @param {function} excludeMatcher the matcher that determines if a given file
 *     is to be excluded.
 */
function copyUsingMatcher(src, dest, excludeMatcher) {

    var filenames,
        basedir,
        i,
        name,
        file,
        newdest,
        type;

    //console.log('copying ' + src + ' to ' + dest);
    /* check if source path exists */

    if (!existsSync(src)) {
        throw new Error(src + ' does not exist');
    }

    /* check if source is a directory */

    if (!fs.statSync(src).isDirectory()) {
        throw new Error(src + ' must be a directory');
    }

    /* get the names of all files and directories under source in an array */

    filenames = fs.readdirSync(src);
    basedir = src;

    /* check if destination directory exists */

    if (!existsSync(dest)) {
        fs.mkdirSync(dest, parseInt('755', 8));
    }

    for (i = 0; i < filenames.length; i += 1) {

        name = filenames[i];
        file = basedir + '/' + name;
        type = fs.statSync(file).isDirectory() ? 'dir' : 'file';
        newdest = dest + '/' + name;

        if (!excludeMatcher(file, type)) {
            //console.log('Copy ' + file + ' as ' + newdest);
            if (type === 'dir') {
                copyUsingMatcher(file, newdest, excludeMatcher);
            } else {
                copyFile(file, newdest);
            }
        }
    }
}

function copyExclude(src, dest, excludes) {
    copyUsingMatcher(src, dest, getExclusionMatcher(excludes, false));
}

function copy(obj) {
    var temp = null,
        key = '';

    if (!obj || typeof obj !== 'object') { return obj; }
    temp = new obj.constructor();
    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            temp[key] = copy(obj[key]);
        }
    }
    return temp;
}

function removeDir(src) {
    var filenames,
        basedir,
        emptydirs,
        name,
        file,
        count;

    /* check if source path exists */
    if (!existsSync(src)) {
        return;
    }

    /* check if source is a directory */
    if (!fs.statSync(src).isDirectory()) {
        throw new Error(src + ' must be a directory');
    }

    /* get the names of all files and directories under source in an array */

    filenames = fs.readdirSync(src);
    basedir = src;
    emptydirs = [];

    for (name in filenames) {
        if (filenames.hasOwnProperty(name)) {
            file = basedir + '/' + filenames[name];
            if (fs.statSync(file).isDirectory()) {
                emptydirs.push(file);
                removeDir(file);
            } else {
                fs.unlinkSync(file);
            }
        }
    }
    for (count = 0; count < emptydirs.length; count += 1) {
        fs.rmdirSync(emptydirs[count]);
    }
}

function makeDir(p, mode) {

    var ps = path.normalize(p).split('/'),
        i;

    if (!mode) {
        mode = parseInt('755', 8);
    }

    for (i = 0; i <= ps.length; i += 1) {
        try {
            fs.mkdirSync(ps.slice(0, i).join('/'), mode);
        } catch (err) {
            // Dirty way to check dir
        }
    }
}

function isMojitoApp(dir, usage, die) {
    // Mojito apps must have:
    // - either server.js OR index.js
    // - the file above must require('mojito')

    var requiresMojito = /require\s*\(\s*'mojito'\s*\)/,
        isMojito = false,
        checker;

    checker = function(file) {
        var filepath,
            contents;

        if (isMojito) { return; }
        filepath = path.join(dir, file);
        if (existsSync(filepath)) {
            contents = fs.readFileSync(filepath, 'utf-8');
            isMojito = requiresMojito.test(contents);
        }
    };

    ['server.js', 'index.js'].forEach(checker);

    // if command usage is provided, it is assumed that we exit on error
    if (!isMojito && usage) {
        error("The directory '" + dir + "' is not a Mojito Application",
            usage, die);
    }

    return isMojito;
}

/**
 * Convert a CSV string into a context object.
 * @param {string} s A string of the form: 'key1:value1,key2:value2'.
 * @return {Object} The context object after conversion.
 */
function contextCsvToObject(s) {
    var ctx = {},
        pairs = s.split(','),
        pair,
        i;

    for (i = 0; i < pairs.length; i += 1) {
        pair = pairs[i].split(':');
        if (pair[0]) {
            if (!pair[1]) {
                warn('Missing value for context key: ' + pair[0]);
            } else {
                ctx[pair[0]] = pair[1];
            }
        }
    }

    return ctx;
}

/**
 */
exports.process_directory = process_directory;

/**
 */
exports.copyExclude = copyExclude;

/**
 */
exports.copyFile = copyFile;

/**
 */
exports.copy = copy;

/**
 */
exports.isMojitoApp = isMojitoApp;

/**
 */
exports.removeDir = removeDir;

/**
 */
exports.makeDir = makeDir;

/**
 */
exports.error = error;

/**
 */
exports.warn = warn;

/**
 */
exports.log = log;

/**
 */
exports.success = success;

/**
 */
exports.getExclusionMatcher = getExclusionMatcher;

/**
 */
exports.copyUsingMatcher = copyUsingMatcher;

/**
 */
exports.heir = heir;

/**
 */
exports.contextCsvToObject = contextCsvToObject;

exports.decodeHTMLEntities = decodeHTMLEntities;
<|endoftext|>


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

  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.initConfig({
    watch: {
      scripts: {
        files: ['V1.Backbone.coffee', 'tests/**/*.coffee'],
        tasks: ["mochaTest", "coffee:compile", 'uglify'],
        options: { spawn: true }
      }
    },

    coffee: {
      compile: {
        files: {
          'V1.Backbone.js': 'V1.Backbone.coffee'
        }
      }
    },

    uglify: {
      scripts: {
        files: {
          'V1.Backbone.min.js': ['V1.Backbone.js']
        }
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'dot',
          require: 'coffee-script/register'
        },
        src: ['tests/**/*.coffee']
      }
    }
  });

  grunt.registerTask('default', 'mochaTest');
};<commit_msg>node will prefer javascript compiles vs coffeescript -- so perfer to generate new compiled versions before running the tests so it has up-to-date bits.<commit_after>module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.initConfig({
    watch: {
      scripts: {
        files: ['V1.Backbone.coffee', 'tests/**/*.coffee'],
        tasks: ["coffee:compile", 'uglify', "mochaTest"],
        options: { spawn: true }
      }
    },

    coffee: {
      compile: {
        files: {
          'V1.Backbone.js': 'V1.Backbone.coffee'
        }
      }
    },

    uglify: {
      scripts: {
        files: {
          'V1.Backbone.min.js': ['V1.Backbone.js']
        }
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'dot',
          require: 'coffee-script/register'
        },
        src: ['tests/**/*.coffee']
      }
    }
  });

  grunt.registerTask('default', 'mochaTest');
};<|endoftext|>


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

	require('load-grunt-tasks')(grunt);

	var config = {
		pkg: grunt.file.readJSON('package.json'),

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

		comments: {
			js: {
				options: {
					singleline: true,
					multiline: true
				},
				src: ['<%= concat.dist.dest %>']
			}
		},

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

		jshint: {
			options: grunt.file.readJSON('.jshintrc'),
			files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
		},

		jscs: {
			options: {
				config: '.jscs.json'
			},
			src: [
				'Gruntfile.js',
				'src/**/*.js',
				'test/**/*.js'
			]
		},

		bump: {
			options: {
				files: [
					'bower.json',
					'package.json'
				],
				commit: true,
				commitMessage: 'Release: v%VERSION%',
				commitFiles: [
					'bower.json',
					'package.json',
					'dist/*.js'
				],
				createTag: true,
				tagName: '%VERSION%',
				tagMessage: 'Version %VERSION%',
				push: false,
				pushTo: 'origin'
			}
		},

		changelog: {
			options: {}
		},

		//Server-side tests
		simplemocha: {
			test: {
				src: 'test/node.js',
				options: {
					globals: ['should'],
					timeout: 3000,
					ignoreLeaks: false,
					reporter: 'spec'
				}
			}
		}
	};

	grunt.initConfig(config);

	grunt.registerTask('lint', ['jshint', 'jscs']);
	grunt.registerTask('test', ['lint', 'simplemocha']);
	grunt.registerTask('build', ['test', 'concat', 'comments', 'uglify']);
	grunt.registerTask('release', ['build', 'bump']);

	grunt.registerTask('default', []);
};
<commit_msg>Commit js.map files on release<commit_after>module.exports = function(grunt) {
	'use strict';

	require('load-grunt-tasks')(grunt);

	var config = {
		pkg: grunt.file.readJSON('package.json'),

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

		comments: {
			js: {
				options: {
					singleline: true,
					multiline: true
				},
				src: ['<%= concat.dist.dest %>']
			}
		},

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

		jshint: {
			options: grunt.file.readJSON('.jshintrc'),
			files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
		},

		jscs: {
			options: {
				config: '.jscs.json'
			},
			src: [
				'Gruntfile.js',
				'src/**/*.js',
				'test/**/*.js'
			]
		},

		bump: {
			options: {
				files: [
					'bower.json',
					'package.json'
				],
				commit: true,
				commitMessage: 'Release: v%VERSION%',
				commitFiles: [
					'bower.json',
					'package.json',
					'dist/*.js',
					'dist/*.js.map'
				],
				createTag: true,
				tagName: '%VERSION%',
				tagMessage: 'Version %VERSION%',
				push: false,
				pushTo: 'origin'
			}
		},

		changelog: {
			options: {}
		},

		//Server-side tests
		simplemocha: {
			test: {
				src: 'test/node.js',
				options: {
					globals: ['should'],
					timeout: 3000,
					ignoreLeaks: false,
					reporter: 'spec'
				}
			}
		}
	};

	grunt.initConfig(config);

	grunt.registerTask('lint', ['jshint', 'jscs']);
	grunt.registerTask('test', ['lint', 'simplemocha']);
	grunt.registerTask('build', ['test', 'concat', 'comments', 'uglify']);
	grunt.registerTask('release', ['build', 'bump']);

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


<commit_before>module.exports = function(grunt) {
  require('time-grunt')(grunt);

  require('load-grunt-tasks')(grunt, {
    pattern: ['grunt-*', '!grunt-log-headers']
  });

  require('grunt-log-headers')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    newer: {
      options: {
        gruntLogHeader: false
      }
    },
    'newer-postrun': {
      options: {
        gruntLogHeader: false
      }
    },
    clean: {
      src: [
        'app/public/**/*.css',
        'app/public/**/*.js'
      ]
    },
    jshint: {
      src: [
          'app/app.js',
          'app/control-panel/**/*.js'
      ],
      options: {
        reporter: require('jshint-stylish'),
        globals: {
          jQuery: true,
          console: true
        }
      },

    },
    jscs: {
      src: [
          'app/app.js',
          'app/control-panel/**/*.js'
      ],
      options: {
        "config": ".jscsrc",
        "preset": "node-style-guide",
        "maximumLineLength": 160,
        "validateIndentation": 2,
        "fix": true
      }
    },
    ngAnnotate: {
        angular_app: {
            files: {
              'app/public/js/app.js': [
                'bower_components/angular/angular.js',
                'bower_components/angular-ui-router/release/angular-ui-router.js',
                'bower_components/angular-cookie/angular-cookie.js',
                'bower_components/angular-local-storage/dist/angular-local-storage.js',
                'bower_components/ng-token-auth/dist/ng-token-auth.js',
                'bower_components/angular-bootstrap/ui-bootstrap.js',
                'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
                'bower_components/angular-bootstrap-show-errors/src/showErrors.js',
                'bower_components/angular-validation-match/dist/angular-validation-match.js',
                'bower_components/angular-datatables/dist/angular-datatables.js',
                'app/app.js',
                'app/control-panel/**/*.js'
              ]
            }
        },
    },
    uglify: {
      options: {
        banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */\n',
        sourceMap: false,
        beautify: true,
        //beautify: false,
        mangle: false
      },
      base: {
        files: {
          'app/public/js/base.js': [
            'bower_components/jquery/dist/jquery.js',
            'bower_components/bootstrap/dist/js/bootstrap.js',
            'bower_components/metisMenu/dist/metisMenu.js',
            'bower_components/startbootstrap-sb-admin-2/dist/js/sb-admin-2.js',
            'bower_components/datatables/media/js/jquery.dataTables.js',
            'bower_components/datatables/media/js/dataTables.bootstrap.js',
            'bower_components/angular-datatables/dist/angular-datatables.js'
          ],
          'app/public/js/graphs.js': [
            'bower_components/raphael/raphael.js',
            'bower_components/morrisjs/morris.js'
          ]
        }
      },
      app: {
        files: {
          'app/public/js/app.js': [
            'app/public/js/app.js'
          ]
        }
      }
    },
    less: {
      base: {
        options: {
          paths: ["app/assets/less"]
        },
        files: {
          "app/public/css/sb-admin-2.css": "app/assets/less/sb-admin-2.less",
          "app/public/css/stratus-print.css": "app/assets/less/themes/stratus-print.less",
          "app/public/css/styles.css": "app/assets/less/styles.less"
        }
      }
    },
    cssmin: {
      options: {
        banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */',
        root: './app/'
      },
      base: {
        files: {
          'app/public/css/base.css': [
            'bower_components/bootstrap/dist/css/bootstrap.css',
            'bower_components/metisMenu/dist/metisMenu.css',
            'bower_components/startbootstrap-sb-admin-2/dist/css/timeline.css',
            'bower_components/font-awesome/css/font-awesome.css',
            'bower_components/morrisjs/morris.css',
            'bower_components/datatables/media/css/dataTables.bootstrap.css',
            'app/public/css/sb-admin-2.css',
            'app/public/css/stratus-print.css',
            'app/public/css/styles.css'
          ]
        }
      }
    },
    watch: {
      scripts: {
        files: [
          'app/app.js',
          'app/control-panel/**/*.js'
        ],
        tasks: ['default'],
        options: {
          spawn: false,
        },
      },
      styles: {
        files: [
          'app/assets/less/*.less',
          'app/assets/less/**/*.less'
        ],
        tasks: ['less', 'cssmin'],
        options: {
          spawn: false,
        },
      },
    }
  });

  grunt.registerTask('default', [
    'newer:jshint',
    'ngAnnotate:angular_app',
    'newer:uglify',
    'newer:less',
    'newer:cssmin',
    'newer:jscs'
  ]);

  grunt.registerTask('lint', [
    'jshint',
    'jscs',
  ]);
};
<commit_msg>Put the grunt file back how it was.  Still get the error from datatables about angular not being defined.<commit_after>module.exports = function(grunt) {
  require('time-grunt')(grunt);

  require('load-grunt-tasks')(grunt, {
    pattern: ['grunt-*', '!grunt-log-headers']
  });

  require('grunt-log-headers')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    newer: {
      options: {
        gruntLogHeader: false
      }
    },
    'newer-postrun': {
      options: {
        gruntLogHeader: false
      }
    },
    clean: {
      src: [
        'app/public/**/*.css',
        'app/public/**/*.js'
      ]
    },
    jshint: {
      src: [
          'app/app.js',
          'app/control-panel/**/*.js'
      ],
      options: {
        reporter: require('jshint-stylish'),
        globals: {
          jQuery: true,
          console: true
        }
      },

    },
    jscs: {
      src: [
          'app/app.js',
          'app/control-panel/**/*.js'
      ],
      options: {
        "config": ".jscsrc",
        "preset": "node-style-guide",
        "maximumLineLength": 160,
        "validateIndentation": 2,
        "fix": true
      }
    },
    ngAnnotate: {
        angular_app: {
            files: {
              'app/public/js/app.js': [
                'bower_components/angular/angular.js',
                'bower_components/angular-ui-router/release/angular-ui-router.js',
                'bower_components/angular-cookie/angular-cookie.js',
                'bower_components/angular-local-storage/dist/angular-local-storage.js',
                'bower_components/ng-token-auth/dist/ng-token-auth.js',
                'bower_components/angular-bootstrap/ui-bootstrap.js',
                'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
                'bower_components/angular-bootstrap-show-errors/src/showErrors.js',
                'bower_components/angular-validation-match/dist/angular-validation-match.js',
                'bower_components/angular-datatables/dist/angular-datatables.js',
                'app/app.js',
                'app/control-panel/**/*.js'
              ]
            }
        },
    },
    uglify: {
      options: {
        banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */\n',
        sourceMap: false,
        beautify: true,
        //beautify: false,
        mangle: false
      },
      base: {
        files: {
          'app/public/js/base.js': [
            'bower_components/jquery/dist/jquery.js',
            'bower_components/bootstrap/dist/js/bootstrap.js',
            'bower_components/metisMenu/dist/metisMenu.js',
            'bower_components/startbootstrap-sb-admin-2/dist/js/sb-admin-2.js',
            'bower_components/datatables/media/js/jquery.dataTables.js',
            'bower_components/datatables/media/js/dataTables.bootstrap.js'
          ],
          'app/public/js/graphs.js': [
            'bower_components/raphael/raphael.js',
            'bower_components/morrisjs/morris.js'
          ]
        }
      },
      app: {
        files: {
          'app/public/js/app.js': [
            'app/public/js/app.js'
          ]
        }
      }
    },
    less: {
      base: {
        options: {
          paths: ["app/assets/less"]
        },
        files: {
          "app/public/css/sb-admin-2.css": "app/assets/less/sb-admin-2.less",
          "app/public/css/stratus-print.css": "app/assets/less/themes/stratus-print.less",
          "app/public/css/styles.css": "app/assets/less/styles.less"
        }
      }
    },
    cssmin: {
      options: {
        banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */',
        root: './app/'
      },
      base: {
        files: {
          'app/public/css/base.css': [
            'bower_components/bootstrap/dist/css/bootstrap.css',
            'bower_components/metisMenu/dist/metisMenu.css',
            'bower_components/startbootstrap-sb-admin-2/dist/css/timeline.css',
            'bower_components/font-awesome/css/font-awesome.css',
            'bower_components/morrisjs/morris.css',
            'bower_components/datatables/media/css/dataTables.bootstrap.css',
            'app/public/css/sb-admin-2.css',
            'app/public/css/stratus-print.css',
            'app/public/css/styles.css'
          ]
        }
      }
    },
    watch: {
      scripts: {
        files: [
          'app/app.js',
          'app/control-panel/**/*.js'
        ],
        tasks: ['default'],
        options: {
          spawn: false,
        },
      },
      styles: {
        files: [
          'app/assets/less/*.less',
          'app/assets/less/**/*.less'
        ],
        tasks: ['less', 'cssmin'],
        options: {
          spawn: false,
        },
      },
    }
  });

  grunt.registerTask('default', [
    'newer:jshint',
    'ngAnnotate:angular_app',
    'newer:uglify',
    'newer:less',
    'newer:cssmin',
    'newer:jscs'
  ]);

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


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

  "use strict";

  require("jit-grunt")(grunt);

  grunt.initConfig({

    /**
     * grunt-contrib-connect
     */
    connect : {
      dev : {
        options : {
          port : 8000,
          hostname : "*",
          base : "dist"
        }
      }
    },

    /**
     * grunt-webpack
     */
    webpack : {
      options : {
        module: {
          loaders: [
            {
              test: /\.js$/,
              exclude: /node_modules/,
              loader: 'babel-loader',
              query: {
                optional: ['es7.classProperties']
              }
            },
            {
              test: /\.json$/,
              exclude: /node_modules/,
              loader: 'json-loader'
            }
          ]
        }
      },
      static : {
        entry: "./src/js/app.js",
        output: {
          path: "dist",
          filename: "app.js",
        },
        stats: {
          colors: true,
          modules: false,
          reasons: true
        },
        progress: false,
        watch: false,
        keepalive: false
      }
    },

    /**
     * grunt-contrib-uglify
     */
    uglify: {
      options: {
        mangle: true,
        compress: true,
        report: "gzip"
      },
      static: {
        files: {
          "dist/app.min.js" : ["dist/app.js"]
        }
      }
    },

    /**
     * grunt-contrib-stylus
     */
    stylus: {
      options: {
        compress : false,
        use: [
          require('jeet'),
          function() {
            return require("autoprefixer-stylus")({
              browsers : ["last 2 versions", "ie 9"]
            });
          }
        ]
      },
      static: {
        files: {
          "dist/app.css": "src/styl/app.styl"
        }
      }
    },

    /**
     * grunt-csso
     */
    csso: {
      options: {
        report: "gzip"
      },
      static: {
        files: {
          "dist/app.min.css": ["dist/app.css"]
        }
      }
    },

    /**
     * grunt-contrib-copy
     */
    copy : {
      images : {
        files : [
          {expand: true, cwd: "src/img/", src: ["**"], dest: "dist/img/"}
        ]
      },
      fonts : {
        files : [
          {expand: true, cwd: "src/font/", src: ["**"], dest: "dist/font/"}
        ]
      }
    },

    /**
     * grunt-twig-render
     */
    twigRender: {
      static: {
        options: {
          client: false,
          pretty: false
        },
        files: [{
          data: "src/config/globals.json",
          cwd: "src/twig",
          src: ["*.twig"],
          dest: "dist",
          expand: true,
          ext: ".html"
        }]
      }
    },

    /**
     * grunt-contrib-watch
     */
    watch: {
      livereload : {
        options : {
          livereload : 8001
        },
        files: [
          "dist/**"
        ]
      },
      images : {
        files : ["src/img/**"],
        tasks : ["copy:images"]
      },
      fonts : {
        files : ["src/font/**"],
        tasks : ["copy:fonts"]
      },
      stylesheets : {
        files : ["src/styl/**"],
        tasks : ["stylus:static"]
      },
      twig : {
        files : ["src/twig/**"],
        tasks : ["twigRender:static"]
      },
      scripts : {
        files : ["src/js/**"],
        tasks : ["webpack:static"]
      }
    },

    /**
     * grunt-sftp-deploy
     */
    "sftp-deploy": {
      static: {
        auth: {
          host: "000.000.000.000",
          port: 0000,
          authKey: "key1"
        },
        cache: "sftpCache.json",
        src: "dist",
        dest: "/path/to/destination/directory",
        exclusions: ["dist/**/.DS_Store", "dist/**/Thumbs.db"],
        serverSep: "/",
        concurrency: 4,
        progress: true
      }
    }

  });

  grunt.registerTask("default", ["connect:dev", "copy:images", "copy:fonts", "twigRender:static", "stylus:static", "webpack:static", "watch"]);
  grunt.registerTask("dist", ["copy:images", "copy:fonts", "twigRender:static", "stylus:static", "csso:static", "webpack:static", "uglify:static"]);
  grunt.registerTask("stage",  ["dist", "sftp-deploy:static"]);

};
<commit_msg>Fixed a couple of inconsistencies.<commit_after>module.exports = function(grunt) {

  "use strict";

  require("jit-grunt")(grunt);

  grunt.initConfig({

    /**
     * grunt-contrib-connect
     */
    connect : {
      dev : {
        options : {
          port : 8000,
          hostname : "*",
          base : "dist"
        }
      }
    },

    /**
     * grunt-webpack
     */
    webpack : {
      options : {
        module: {
          loaders: [
            {
              test: /\.js$/,
              exclude: /node_modules/,
              loader: 'babel-loader',
              query: {
                optional: ['es7.classProperties']
              }
            },
            {
              test: /\.json$/,
              exclude: /node_modules/,
              loader: 'json-loader'
            }
          ]
        }
      },
      static : {
        entry: "./src/js/app.js",
        output: {
          path: "dist",
          filename: "app.js",
        },
        stats: {
          colors: true,
          modules: false,
          reasons: true
        },
        progress: false,
        watch: false,
        keepalive: false
      }
    },

    /**
     * grunt-contrib-uglify
     */
    uglify: {
      options: {
        mangle: true,
        compress: true,
        report: "gzip"
      },
      static: {
        files: {
          "dist/app.min.js" : ["dist/app.js"]
        }
      }
    },

    /**
     * grunt-contrib-stylus
     */
    stylus: {
      options: {
        compress : false,
        use: [
          require('jeet'),
          function() {
            return require("autoprefixer-stylus")({
              browsers : ["last 2 versions", "ie 9"]
            });
          }
        ]
      },
      static: {
        files: {
          "dist/app.css": "src/styl/app.styl"
        }
      }
    },

    /**
     * grunt-csso
     */
    csso: {
      options: {
        report: "gzip"
      },
      static: {
        files: {
          "dist/app.min.css": ["dist/app.css"]
        }
      }
    },

    /**
     * grunt-contrib-copy
     */
    copy : {
      images : {
        files : [
          {expand: true, cwd: "src/img/", src: ["**"], dest: "dist/img/"}
        ]
      },
      fonts : {
        files : [
          {expand: true, cwd: "src/font/", src: ["**"], dest: "dist/font/"}
        ]
      }
    },

    /**
     * grunt-twig-render
     */
    twigRender: {
      static: {
        options: {
          client: false,
          pretty: false
        },
        files: [{
          data: "src/config/example.json",
          cwd: "src/twig",
          src: ["*.twig"],
          dest: "dist",
          expand: true,
          ext: ".html"
        }]
      }
    },

    /**
     * grunt-contrib-watch
     */
    watch: {
      livereload : {
        options : {
          livereload : 8001
        },
        files: [
          "dist/**"
        ]
      },
      images : {
        files : ["src/img/**"],
        tasks : ["copy:images"]
      },
      fonts : {
        files : ["src/font/**"],
        tasks : ["copy:fonts"]
      },
      stylesheets : {
        files : ["src/styl/**"],
        tasks : ["stylus:static"]
      },
      twig : {
        files : ["src/twig/**"],
        tasks : ["twigRender:static"]
      },
      scripts : {
        files : ["src/js/**"],
        tasks : ["webpack:static"]
      }
    },

    /**
     * grunt-sftp-deploy
     */
    "sftp-deploy": {
      static: {
        auth: {
          host: "000.000.000.000",
          port: 22,
          authKey: "key1"
        },
        cache: "sftpCache.json",
        src: "dist",
        dest: "/path/to/destination/directory",
        exclusions: ["dist/**/.DS_Store", "dist/**/Thumbs.db"],
        serverSep: "/",
        concurrency: 4,
        progress: true
      }
    }

  });

  grunt.registerTask("default", ["connect:dev", "copy:images", "copy:fonts", "twigRender:static", "stylus:static", "webpack:static", "watch"]);
  grunt.registerTask("dist", ["copy:images", "copy:fonts", "twigRender:static", "stylus:static", "csso:static", "webpack:static", "uglify:static"]);
  grunt.registerTask("stage",  ["dist", "sftp-deploy:static"]);

};
<|endoftext|>


<commit_before>'use strict';

var exec = require('child_process').exec;

module.exports = function(grunt) {
  grunt.initConfig({
    vimlint: {
      succeeded: {
        src: ['test/succeeded.vim']
      },
      failed: {
        src: ['test/failed.vim']
      }
    }
  });

  grunt.registerTask('test', function() {
    var done = this.async();

    console.log('> grunt vimlint:succeeded');
    exec('grunt vimlint:succeeded', function (err, stdout, stderr) {
      if (err) {
        grunt.log.error(stdout || stderr);
        return done(err);
      }

      console.log('> grunt vimlint:failed');
      exec('grunt vimlint:failed', function (err, stdout, stderr) {
        if (!err) {
          grunt.log.error('vimlint succeeded');
          return done(true);
        }

        done();
      });
    });
  });

  grunt.loadTasks('tasks');
};<commit_msg>Fix test<commit_after>'use strict';

var exec = require('child_process').exec;

module.exports = function(grunt) {
  grunt.initConfig({
    vimlint: {
      succeeded: {
        src: ['test/succeeded.vim']
      },
      failed: {
        src: ['test/failed.vim']
      }
    }
  });

  grunt.registerTask('test', function() {
    var done = this.async();

    console.log('> grunt vimlint:succeeded');
    exec('grunt vimlint:succeeded', function (err, stdout, stderr) {
      if (err) {
        console.error(stdout || stderr);
        return done(err);
      }

      console.log('> grunt vimlint:failed');
      exec('grunt vimlint:failed', function (err, stdout, stderr) {
        if (!err) {
          console.error('vimlint succeeded');
          return done(true);
        }

        done();
      });
    });
  });

  grunt.loadTasks('tasks');
};<|endoftext|>


<commit_before>module.exports = function(grunt){
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        seperator: ';'
      },
      dist: {
        src: ['client/app.js',
              'client/app/**/*.js'
        ],
        dest: 'client/dist/app.js'
      }
    },
    nodemon: {
      dev: {
        script: 'server/server.js'
      }
    },

    uglify: {
      dist: {
        files: {
          'client/dist/app.min.js': ['client/dist/app.js']
        }
      }
    },

    jshint: {
      files: [
        'server/server.js',
        'client/app/**/*.js',
        // client folder
        'client/*.js'
      ],
      options: {
        force: 'true',
        jshintrc: '.jshintrc',
        ignores: [
        'client/dist/**/*.js'
        ]
      }
    },

    cssmin: {
      target: {
        files:[{
          src: ['client/styles.css'],
          dest: 'client/dist/styles.css',
          ext: '.min.css'
        }]
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['specs/**/*.js']
      }
    },

    watch: {
      scripts: {
        files: [
          'client/**/*.js'
        ],
        tasks: [
        'concat',
        'uglify'
        ]
      },
      css: {
        files: 'client/*.css',
        tasks: ['cssmin']
      }
    },

    shell: {
      prodServer: {
        command: 'git push heroku master'
      }
    },
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-nodemon');

  grunt.registerTask('server-dev', function(target){
    var nodemon = grunt.util.spawn({
         cmd: 'grunt',
         grunt: true,
         args: 'nodemon'
    });
    nodemon.stdout.pipe(process.stdout);
    nodemon.stderr.pipe(process.stderr);

    grunt.task.run([ 'watch' ]);
    });

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

    grunt.registerTask('build', [
      'concat',
      'uglify',
      'cssmin',
      'jshint',
      'test'
    ]);

    grunt.registerTask('upload', function(n) {
      if(grunt.option('prod')) {
        grunt.task.run(['shell:prodServer']);
      } else {
        grunt.task.run([ 'server-dev' ]);
      }
    });

    grunt.registerTask('default', [
      'build',
      'upload'
    ]);
};
<commit_msg>Finishes travis.yml and gruntfile<commit_after>module.exports = function(grunt){
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        seperator: ';'
      },
      dist: {
        src: ['client/app.js',
              'client/app/**/*.js'
        ],
        dest: 'client/dist/app.js'
      }
    },
    nodemon: {
      dev: {
        script: 'server/server.js'
      }
    },

    uglify: {
      dist: {
        files: {
          'client/dist/app.min.js': ['client/dist/app.js']
        }
      }
    },

    jshint: {
      files: [
        'server/server.js',
        'client/app/**/*.js',
        // client folder
        'client/*.js'
      ],
      options: {
        force: 'true',
        jshintrc: '.jshintrc',
        ignores: [
        'client/dist/**/*.js'
        ]
      }
    },

    cssmin: {
      target: {
        files:[{
          src: ['client/styles.css'],
          dest: 'client/dist/styles.css',
          ext: '.min.css'
        }]
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['specs/**/*.js']
      }
    },

    watch: {
      scripts: {
        files: [
          'client/**/*.js'
        ],
        tasks: [
        'concat',
        'uglify'
        ]
      },
      css: {
        files: 'client/*.css',
        tasks: ['cssmin']
      }
    },

    shell: {
      prodServer: {
        command: 'git push heroku master'
      }
    },
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-nodemon');

  grunt.registerTask('server-dev', function(target){
    var nodemon = grunt.util.spawn({
         cmd: 'grunt',
         grunt: true,
         args: 'nodemon'
    });
    nodemon.stdout.pipe(process.stdout);
    nodemon.stderr.pipe(process.stderr);

    grunt.task.run([ 'watch' ]);
    });

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

    grunt.registerTask('build', [
      'concat',
      'uglify',
      'cssmin',
      'jshint',
      'test'
    ]);

    grunt.registerTask('upload', function(n) {
      if(grunt.option('prod')) {
        grunt.task.run(['shell:prodServer']);
      } else {
        grunt.task.run([ 'server-dev' ]);
      }
    });

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


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

    watch: {
      // scripts: {
      //   files: [ 'Gruntfile.js', 'js/*.js', 'css/*.css', '!**/all.**' ],
      //   tasks: ['prod'],
      //   options: {
      //     interrupt: true,
      //     livereload: true
      //   },
      // },
      html: {
        files: ['**/*.html'],
         options: {
          interrupt: true,
          livereload: true,
        }
      },
      css: {
        files: ['scss/**/*.scss'],
        tasks: ['default'],
        options: {
          interrupt: true,
          livereload: true,
        }
      }
    },

    sass: {
      options: {
        style: 'expanded',
        sourcemap: 'none',
        noCache: true
      },
      single_file: {
        files: {
          'dist/css/style.css': 'scss/general.scss'
        }
      }
    },

    cssmin: {
      my_target: {
        files: [{
          expand: true,
          cwd: 'dist/css/',
          src: ['*.css', '!*.min.css'],
          dest: 'dist/css/',
          ext: '.min.css'
        }]
      }
    },

    postcss: {
      options: {
        safe: true,
        processors: [
          require('autoprefixer-core')({browsers: 'last 2 version'}),
          // require('csswring')
        ]
      },
      dist: {
        expand: true,
        cascade: true,
        remove: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/'
      }
    },

    uglify: {
      my_target: {
        files: [{
          expand: true,
          flatten: true,
          mangle: false,
          cwd: 'dist/js/',
          src: [
          '*.js',
          '!*.min.js'
          ],
          dest: 'dist/js/',
          ext: '.min.js'
        }]
      }
    },

    concat: {
      basic: {
        files: {
          'dist/css/style.css': [
            '../normalize.css/normalize.css',
            'dist/css/style.css'
          ],
        },
      },
      // extras: {
      //   options: {
      //     separator: ';'
      //   },
      //   files: {
      //     'js/all.js': [
      //     'js/minified/move-top.min.js',
      //     ],
      //   }
      // }
    }

  });

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-postcss');

grunt.registerTask( 'default', [ 'sass', 'postcss', 'concat:basic', 'cssmin' ] );
grunt.registerTask( 'css', [ 'sass', 'postcss', 'concat:basic', 'cssmin' ] );
grunt.registerTask( 'js', [ 'uglify'] );

};<commit_msg>Changed normalize path.<commit_after>module.exports = function (grunt) {
  grunt.initConfig({

    watch: {
      // scripts: {
      //   files: [ 'Gruntfile.js', 'js/*.js', 'css/*.css', '!**/all.**' ],
      //   tasks: ['prod'],
      //   options: {
      //     interrupt: true,
      //     livereload: true
      //   },
      // },
      html: {
        files: ['**/*.html'],
         options: {
          interrupt: true,
          livereload: true,
        }
      },
      css: {
        files: ['scss/**/*.scss'],
        tasks: ['default'],
        options: {
          interrupt: true,
          livereload: true,
        }
      }
    },

    sass: {
      options: {
        style: 'expanded',
        sourcemap: 'none',
        noCache: true
      },
      single_file: {
        files: {
          'dist/css/style.css': 'scss/general.scss'
        }
      }
    },

    cssmin: {
      my_target: {
        files: [{
          expand: true,
          cwd: 'dist/css/',
          src: ['*.css', '!*.min.css'],
          dest: 'dist/css/',
          ext: '.min.css'
        }]
      }
    },

    postcss: {
      options: {
        safe: true,
        processors: [
          require('autoprefixer-core')({browsers: 'last 2 version'}),
          // require('csswring')
        ]
      },
      dist: {
        expand: true,
        cascade: true,
        remove: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/'
      }
    },

    uglify: {
      my_target: {
        files: [{
          expand: true,
          flatten: true,
          mangle: false,
          cwd: 'dist/js/',
          src: [
          '*.js',
          '!*.min.js'
          ],
          dest: 'dist/js/',
          ext: '.min.js'
        }]
      }
    },

    concat: {
      basic: {
        files: {
          'dist/css/style.css': [
            '../normalize-css/normalize.css',
            'dist/css/style.css'
          ],
        },
      },
      // extras: {
      //   options: {
      //     separator: ';'
      //   },
      //   files: {
      //     'js/all.js': [
      //     'js/minified/move-top.min.js',
      //     ],
      //   }
      // }
    }

  });

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-postcss');

grunt.registerTask( 'default', [ 'sass', 'postcss', 'concat:basic', 'cssmin' ] );
grunt.registerTask( 'css', [ 'sass', 'postcss', 'concat:basic', 'cssmin' ] );
grunt.registerTask( 'js', [ 'uglify'] );

};<|endoftext|>


<commit_before>/*
* getUserEmail()
* Figure out the user's correct email address. This helps the differing keys
* in the database when using oAuth login.
*/
getUserEmail = function(){
  if ( Meteor.user().emails ) {
    if (Meteor.user().emails[0]) {
      return Meteor.user().emails[0].address;
    } else {
      return null;
    }
  } else if ( Meteor.user().services ) {
    var services = Meteor.user().services;
    if ( services.facebook ) {
      return services.facebook.email;
    } else if ( services.github ) {
      return services.github.email;
    } else if ( services.google ) {
      return services.google.email;
    } else {
      return null;
    }
  }
}

trackLogins = function () {
  if (Meteor.user) {
    if (Meteor.user()) {
      var user = Meteor.user();
      var userEmail = getUserEmail()
      analytics.identify(user._id, {email: userEmail});
      analytics.track("Signed in");
    }

    if (!Meteor.user()) {
      analytics.track("Signed out");
    }
  }
};

if (Package['iron:router']) {
  Package['iron:router'].Router.onRun(function() {
    analytics.page(this.route.getName());
    this.next();
  });
}

Meteor.startup(function () {
  Tracker.autorun(trackLogins);
});
<commit_msg>Use userId() over user(), wrap getUserEmail in nonreactive function<commit_after>/*
* getUserEmail()
* Figure out the user's correct email address. This helps the differing keys
* in the database when using oAuth login.
*/
getUserEmail = function(){
  if ( Meteor.user().emails ) {
    if (Meteor.user().emails[0]) {
      return Meteor.user().emails[0].address;
    } else {
      return null;
    }
  } else if ( Meteor.user().services ) {
    var services = Meteor.user().services;
    if ( services.facebook ) {
      return services.facebook.email;
    } else if ( services.github ) {
      return services.github.email;
    } else if ( services.google ) {
      return services.google.email;
    } else {
      return null;
    }
  }
}

trackLogins = function () {
  if (Meteor.user) {
    if (Meteor.userId()) {
      var userId = Meteor.userId();
      console.log(">> new userId: ", userId);
      var userEmail;
      Tracker.nonreactive(function (){
        userEmail = getUserEmail();
      })
      analytics.identify(userId, {email: userEmail});
      analytics.track("Signed in");
    }

    if (!Meteor.userId()) {
      console.log(">> user logged out");
      analytics.track("Signed out");
    }
  }
};

if (Package['iron:router']) {
  console.log("package iron:router found!!");
  Package['iron:router'].Router.onRun(function() {
    console.log("hit onRun!!");
    analytics.page(this.route.getName());
    this.next();
  });
}

Meteor.startup(function () {
  Tracker.autorun(trackLogins);
});
<|endoftext|>