<commit_before>var gulp = require('gulp')
    connect = require('connect'),
    static = require('serve-static'),
    gutil = require('gulp-util'),
    http = require('http'),
    browserify = require('gulp-browserify'),
    watch = require('gulp-watch'),
    clean = require('gulp-rimraf'),
    notify = require('gulp-notify'),
    concat = require('gulp-concat'),
    rev = require('gulp-rev'),
    compress = require('gulp-uglify'),
    mocha = require('gulp-mocha')

var build = function() {
  gulp.src('app.js')
    .pipe(browserify())
    .on('error', notify.onError("<%= error.message%>"))
    .pipe(concat('bundle.js'))
    .pipe(gulp.dest('./build'))
}

var testAll = function() {
  gulp.src(['tests/*.js'], { read: false })
    .pipe(mocha({
      globals: ['should'],
      reporter: 'spec'
    }))
    .on('error', notify.onError("<%= error.message%>"))
}

gulp.task('default', ['build'])

gulp.task('build', build)

gulp.task('dist', ['clean:dist'], function() {
  gulp.src('app.js')
    .pipe(browserify())
    .pipe(concat('spotify-export.min.js'))
    .pipe(rev())
    .pipe(compress())
    .pipe(gulp.dest('./dist'))
})

gulp.task('serve', function() {
  var port = 3000

  var app = connect()
  app.use(static(__dirname))
  app.listen(port)
  gutil.log("Server listening on localhost:"+port+" ...")
})

gulp.task('watch', ['serve'], function() {
  var files = gulp.src(['app.js', 'lib/*.js'])

  files.pipe(watch(build))
  files.pipe(watch(testAll))

})

gulp.task('test', function() {
  testAll()
})

gulp.task('clean', ['clean:build', 'clean:dist'])

gulp.task('clean:build', function() {
	gulp.src('./build', {read: false}).pipe(clean());
});

gulp.task('clean:dist', function() {
  gulp.src('./dist', {read: false}).pipe(clean());
});
<commit_msg>Run tests when the specs themselves change<commit_after>var gulp = require('gulp')
    connect = require('connect'),
    static = require('serve-static'),
    gutil = require('gulp-util'),
    http = require('http'),
    browserify = require('gulp-browserify'),
    watch = require('gulp-watch'),
    clean = require('gulp-rimraf'),
    notify = require('gulp-notify'),
    concat = require('gulp-concat'),
    rev = require('gulp-rev'),
    compress = require('gulp-uglify'),
    mocha = require('gulp-mocha')

var build = function() {
  gulp.src('app.js')
    .pipe(browserify())
    .on('error', notify.onError("<%= error.message%>"))
    .pipe(concat('bundle.js'))
    .pipe(gulp.dest('./build'))
}

var testAll = function() {
  gulp.src(['tests/*.js'], { read: false })
    .pipe(mocha({
      globals: ['should'],
      reporter: 'spec'
    }))
    .on('error', notify.onError("<%= error.message%>"))
}

gulp.task('default', ['build'])

gulp.task('build', build)

gulp.task('dist', ['clean:dist'], function() {
  gulp.src('app.js')
    .pipe(browserify())
    .pipe(concat('spotify-export.min.js'))
    .pipe(rev())
    .pipe(compress())
    .pipe(gulp.dest('./dist'))
})

gulp.task('serve', function() {
  var port = 3000

  var app = connect()
  app.use(static(__dirname))
  app.listen(port)
  gutil.log("Server listening on localhost:"+port+" ...")
})

gulp.task('watch', ['serve'], function() {
  var files = ['app.js', 'lib/*.js']

  gulp.src(files).pipe(watch(build))
  gulp.src((files.push('tests/*.js') && files)).pipe(watch(testAll))

})

gulp.task('test', function() {
  testAll()
})

gulp.task('clean', ['clean:build', 'clean:dist'])

gulp.task('clean:build', function() {
	gulp.src('./build', {read: false}).pipe(clean());
});

gulp.task('clean:dist', function() {
  gulp.src('./dist', {read: false}).pipe(clean());
});
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        ts: {
            options: {
                target: 'es6',
                module: 'commonjs',
                moduleResolution: 'node',
                sourceMap: true,
                emitDecoratorMetadata: true,
                experimentalDecorators: true,
                removeComments: false,
                noImplicitAny: false,
                allowJs: true
            },
            all: {
                src: ['hedgehog/**/*.ts', 'typings/index.d.ts'],
                outDir: 'build/hedgehog'
            },
            test: {
                src: ['test/**/*.ts', 'typings/index.d.ts'],
                outDir: 'build'
            }
        },
        babel: {
            options: {
                presets: ['es2015']
            },
            all: {
                files: [{
                    expand: true,
                    cwd: 'build',
                    src: ['**/*.js', '!src/client/node_modules/*'],
                    dest: 'build'
                }]
            }
        },
        clean: [
            'build',
            'tmp'
        ],
        copy: {
            proto: {
                files: [
                    {
                        expand: true,
                        cwd: 'proto/',
                        src: ['**/*.proto'],
                        dest: 'build/proto'
                    },
                    {
                        expand: true,
                        cwd: 'protoLib/',
                        src: ['*.js'],
                        dest: 'build/protoLib'
                    }
                ]
            }
        },
        tslint: {
            options: {
                configuration: "tslint.json"
            },
            proto: 'hedgehog/proto/**/*.ts',
            test: 'test/**/*.ts'
        }
    });

    grunt.loadNpmTasks('grunt-ts');
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-symlink');
    grunt.loadNpmTasks('grunt-babel');

    grunt.registerTask('compile', ['ts', 'babel']);
    grunt.registerTask('build', ['clean', 'compile', 'copy']);
};<commit_msg>add task to generate proto files<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        ts: {
            options: {
                target: 'es6',
                module: 'commonjs',
                moduleResolution: 'node',
                sourceMap: true,
                emitDecoratorMetadata: true,
                experimentalDecorators: true,
                removeComments: false,
                noImplicitAny: false,
                allowJs: true
            },
            all: {
                src: ['hedgehog/**/*.ts', 'typings/index.d.ts'],
                outDir: 'build/hedgehog'
            },
            test: {
                src: ['test/**/*.ts', 'typings/index.d.ts'],
                outDir: 'build'
            }
        },
        babel: {
            options: {
                presets: ['es2015']
            },
            all: {
                files: [{
                    expand: true,
                    cwd: 'build',
                    src: ['**/*.js', '!src/client/node_modules/*'],
                    dest: 'build'
                }]
            }
        },
        clean: [
            'build',
            'tmp'
        ],
        copy: {
            proto: {
                files: [
                    {
                        expand: true,
                        cwd: 'hedgehog/protocol/proto',
                        src: ['*.js'],
                        dest: 'build/hedgehog/protocol/proto'
                    }
                ]
            }
        },
        tslint: {
            options: {
                configuration: "tslint.json"
            },
            proto: 'hedgehog/proto/**/*.ts',
            test: 'test/**/*.ts'
        }
    });

    grunt.loadNpmTasks('grunt-ts');
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-symlink');
    grunt.loadNpmTasks('grunt-babel');

    grunt.registerTask('protoc', function() {
        var options = {
            cmd: 'protoc',
            args: ["--proto_path=proto --js_out=import_style=commonjs,binary:. `find proto -name '*.proto'`"]
        };

        var done = this.async();

        var protoctask = grunt.util.spawn(options, function doneFunction(error, result, code) {
            done()
        });

        protoctask.stdout.pipe(process.stdout);
        protoctask.stderr.pipe(process.stderr);
    });

    grunt.registerTask('compile', ['ts', 'babel']);
    grunt.registerTask('build', ['clean', 'compile', 'copy']);
};<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
    'meta': {
      version: '0.1.0',
      banner: '/*! Cardr.org - v<%= meta.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '* http://rollingjubilee.org/\n' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
        'Cardr.org; Licensed MIT */'
    },
    'less': {
      production: {
        options: {
          yuicompress: true
        },
        files: {
          'views/assets/css/cardr.min.css': ['views/assets/css/reset.css', 'views/assets/css/bootstrap.css', 'views/assets/css/cardr.less']
        }
      }
    },
    'minify': {
      'dist': {
        'src': ['<banner:meta.banner>', 'views/assets/js/jquery.min.js', 'views/assets/js/cardr.js'],
        'dest': 'views/assets/js/cardr.min.js'
      }
    },
    'rev': {
      assets: {
        files: [
          'index.html'
        ]
      }
    },
    'watch': {
      files: ['views/assets/css/cardr.less', 'views/assets/js/cardr.js', 'grunt.js'],
      tasks: 'less min'
    }
  });

  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-assets-revving');

  // Default task.
  grunt.registerTask('default', ['less', 'minify', 'rev']);

};
<commit_msg>removing minify, need to redo grunt file<commit_after>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    'meta': {
      version: '0.1.0',
      banner: '/*! Cardr.org - v<%= meta.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '* http://rollingjubilee.org/\n' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
        'Cardr.org; Licensed MIT */'
    },
    'less': {
      production: {
        options: {
          yuicompress: true
        },
        files: {
          'views/assets/css/cardr.min.css': ['views/assets/css/reset.css', 'views/assets/css/bootstrap.css', 'views/assets/css/cardr.less']
        }
      }
    },
    // 'minify': {
    //   'dist': {
    //     'src': ['<banner:meta.banner>', 'views/assets/js/jquery.min.js', 'views/assets/js/cardr.js'],
    //     'dest': 'views/assets/js/cardr.min.js'
    //   }
    // },
    'rev': {
      assets: {
        files: [
          'views/index.html'
        ]
      }
    },
    'watch': {
      files: ['views/assets/css/cardr.less', 'views/assets/js/cardr.js', 'grunt.js'],
      tasks: 'less min'
    }
  });

  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-min');
  // grunt.loadNpmTasks('grunt-contrib-rev');
  grunt.loadNpmTasks('grunt-assets-revving');

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

};
<|endoftext|>


<commit_before>
// Base AST class.

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST = function() {};

yate.AST._asts = {};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.options = {};

yate.AST.prototype.Rid = 0;
yate.AST.prototype.Cid = 0;

yate.AST.prototype._init = function() {};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.error = function(s) {
    require('util').puts(new Error().stack);
    throw 'ERROR: ' + s + '\n' + yate.parser._where(this.where);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.make = function(id) {
    var ast = new (yate.AST.$(id))();
    ast.id = id; // Если делать это в прототипе, то не видно в console.log.
    ast._init.apply(ast, Array.prototype.slice.call(arguments, 1));
    return ast;
};

yate.AST.prototype.make = function() {
    var ast = yate.AST.make.apply(null, arguments);
    ast.parent = this;
    ast.setLocals();
    return ast;
};

yate.AST.$ = function(id) {
    var ast = this._asts[id];

    if (!ast) {

        ast = function() {};

        var info = yate.AST[id] || {};
        var options = info.options = info.options || {};

        var base = (options.base) ? this.$(options.base) : yate.AST;
        var mixin = [];
        if (options.mixin) {
            options.mixin = yate.makeArray(options.mixin);
            mixin = mixin.concat(yate.map(options.mixin, function(id) { return yate.AST[id] || {}; }));
        }
        mixin.push(info);
        yate.inherits(ast, base, mixin);

        this._asts[id] = ast;
    }

    return ast;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.yate = function(id, data, mode) {
    return this._yate(id, data, mode);
};

yate.AST.prototype._yate = function(id, data, mode) {
    return this._fill('yate', id, data, mode);
};

yate.AST.prototype.js = function(id, data, mode) {
    return this._js(id, data, mode);
};

yate.AST.prototype._js = function(id, data, mode) {
    return this._fill('js', id, data, mode);
};

yate.AST.prototype._fill = function(type, id, data, mode) {
    if (typeof id == 'object') {
        data = id.data;
        mode = id.mode;
        id = id.id;
    }

    id = id || this.id;
    data = data || this;
    mode = mode || '';

    return CodeTemplates.fill(type, id, mode, data, type);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.childrenKeys = function() {
    var keys = [];
    var order = this.options.order;
    if (order) {
        for (var i = 0, l = order.length; i < l; i++) {
            keys.push(order[i]);
        }
    } else {
        for (var key in this) {
            if (this.hasOwnProperty(key) && /^[A-Z]/.test(key)) {
                keys.push(key);
            }
        }
    }
    return keys;
};

yate.AST.prototype.children = function() {
    var children = [];

    var keys = this.childrenKeys();
    for (var i = 0, l = keys.length; i < l; i++) {
        var key = keys[i];
        var child = this[key];
        if (child !== undefined) {
            children.push( this[key] );
        }
    }

    return children;
    /*
    var order = this.options.order;
    if (order) {
        for (var i = 0, l = order.length; i < l; i++) {
            children.push(this[order[i]]);
        }
    } else {
        for (var key in this) {
            if (this.hasOwnProperty(key) && /^[A-Z]/.test(key)) {
                children.push(this[key]);
            }
        }
    }
    return children;
    */
};

yate.AST.prototype._apply = function(callback) {
    var args = Array.prototype.slice.call(arguments, 1);

    var children = this.children();
    for (var i = 0, l = children.length; i < l; i++) {
        step(children[i]);
    }

    function step(child) {
        if (child instanceof Array) {
            for (var j = 0, m = child.length; j < m; j++) {
                step(child[j]);
            }
        } else if (child instanceof yate.AST) {
            callback.apply(child, args);
        }
    }
};

yate.AST.prototype.trigger = function(method) {
    var args = Array.prototype.slice.call(arguments, 1);

    run.apply(this, args);

    function run() {
        var callback;
        if ((typeof method == 'function')) {
            callback = method;
        } else if (typeof method == 'string' && typeof this[method] == 'function') {
            callback = this[method];
        }
        var args = Array.prototype.slice.call(arguments);
        if (callback) {
            callback.apply(this, args);
        }
        this._apply.apply(this, [ run ].concat(args));
    };
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.setParents = function() {
    function set(parent) {
        this.parent = parent;
        this._apply(set, this);
    }

    set.call(this, null);
};

// ----------------------------------------------------------------------------------------------------------------- //
// Type methods
// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.type = function(to) {
    var type = this._type;
    if (type === undefined) {
        type = this._type = this._getType();
    }

    return (to) ? yate.types.convertable(type, to) : type;
};

yate.AST.prototype._getType = function() {
    return yate.types.NONE;
};

yate.AST.prototype.cast = function(to) {
    var from = this.type();
    to = to || from;

    if (from != to) {
        this.AsType = to;

        if (!yate.types.convertable(from, to)) {
            this.error('Cannot convert type from ' + from + ' to ' + to + ' ' + this.id);
        }
    }

    this.oncast(to);
};

yate.AST.prototype.oncast = function(to) {
    // Do nothing.
};

yate.AST.prototype.toValue = function() {
    var type = this.type();

    if (type == yate.types.ARRAY || type == yate.types.OBJECT) {
        this.cast(type);
    } else {
        this.cast(yate.types.XML);
    }
};

yate.AST.prototype.is = function(type) {
    if (type instanceof Array) {
        for (var i = 0, l = type.length; i < l; i++) {
            if (this instanceof yate.AST.$(type[i])) {
                return true;
            }
        }
    } else {
        return this instanceof yate.AST.$(type);
    }
};

yate.AST.prototype.inline = function() {
    return false;
};

// ----------------------------------------------------------------------------------------------------------------- //
// Walk methods
// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.setLocals = function() {
    var options = this.options.locals || {};
    var locals = yate.AST.locals;
    var parent = this.parent;

    for (var local in locals) {
        var parentLocal = (parent) ? parent[local] : null;
        if (options[local]) {
            this[local] = (parentLocal) ? parentLocal.child() : new locals[local]();
        } else {
            this[local] = parentLocal;
        }
    }

    this.Sid = this.scope.id;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.log = function() {
    // console.log(this.id);
    return require('util').inspect(this, true, null);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.set = function(key, value) {
    this.trigger(function() {
        this[key] = value;
    });
};

yate.AST.prototype.rid = function() {
    this.set('Rid', this.Rid + 1);
};

yate.AST.prototype.cid = function() {
    this.set('Cid', this.Cid + 1);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.isOpen = function() {
    if (this.type() == yate.types.ATTR || this.type() == yate.types.XML) {
        return undefined;
    }
    return false;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.toString = function() {
    var r = [];
    var keys = this.childrenKeys();
    for (var i = 0, l = keys.length; i < l; i++) {
        var key = keys[i];
        var child = this[key];
        if (child !== undefined) {
            if (child instanceof yate.AST) {
                var s = child.toString();
                if (s) {
                    r.push( key.blue.bold + ': ' + s);
                }
            } else {
                r.push( key.blue.bold + ': ' + JSON.stringify(child) );
            }
        }
    }
    if (r.length) {
        var s = this.id.bold + '( ' + this.type().lime;
        if (this.AsType) {
            s += ' -> '.lime + this.AsType.lime;
        }
        s += ' )\n' + r.join('\n').replace(/^/gm, '    ');
        return s;
    }
    return '';
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.var_type = {
    USER: 'user',
    ARGUMENT: 'argument'
};

yate.AST.function_type = {
    USER: 'user',
    INTERNAL: 'internal',
    EXTERNAL: 'external',
    KEY: 'key'
};

<commit_msg>yate.false<commit_after>
// Base AST class.

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST = function() {};

yate.AST._asts = {};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.options = {};

yate.AST.prototype.Rid = 0;
yate.AST.prototype.Cid = 0;

yate.AST.prototype._init = function() {};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.error = function(s) {
    require('util').puts(new Error().stack);
    throw 'ERROR: ' + s + '\n' + yate.parser._where(this.where);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.make = function(id) {
    var ast = new (yate.AST.$(id))();
    ast.id = id; // Если делать это в прототипе, то не видно в console.log.
    ast._init.apply(ast, Array.prototype.slice.call(arguments, 1));
    return ast;
};

yate.AST.prototype.make = function() {
    var ast = yate.AST.make.apply(null, arguments);
    ast.parent = this;
    ast.setLocals();
    return ast;
};

yate.AST.$ = function(id) {
    var ast = this._asts[id];

    if (!ast) {

        ast = function() {};

        var info = yate.AST[id] || {};
        var options = info.options = info.options || {};

        var base = (options.base) ? this.$(options.base) : yate.AST;
        var mixin = [];
        if (options.mixin) {
            options.mixin = yate.makeArray(options.mixin);
            mixin = mixin.concat(yate.map(options.mixin, function(id) { return yate.AST[id] || {}; }));
        }
        mixin.push(info);
        yate.inherits(ast, base, mixin);

        this._asts[id] = ast;
    }

    return ast;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.yate = function(id, data, mode) {
    return this._yate(id, data, mode);
};

yate.AST.prototype._yate = function(id, data, mode) {
    return this._fill('yate', id, data, mode);
};

yate.AST.prototype.js = function(id, data, mode) {
    return this._js(id, data, mode);
};

yate.AST.prototype._js = function(id, data, mode) {
    return this._fill('js', id, data, mode);
};

yate.AST.prototype._fill = function(type, id, data, mode) {
    if (typeof id == 'object') {
        data = id.data;
        mode = id.mode;
        id = id.id;
    }

    id = id || this.id;
    data = data || this;
    mode = mode || '';

    return CodeTemplates.fill(type, id, mode, data, type);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.childrenKeys = function() {
    var keys = [];
    var order = this.options.order;
    if (order) {
        for (var i = 0, l = order.length; i < l; i++) {
            keys.push(order[i]);
        }
    } else {
        for (var key in this) {
            if (this.hasOwnProperty(key) && /^[A-Z]/.test(key)) {
                keys.push(key);
            }
        }
    }
    return keys;
};

yate.AST.prototype.children = function() {
    var children = [];

    var keys = this.childrenKeys();
    for (var i = 0, l = keys.length; i < l; i++) {
        var key = keys[i];
        var child = this[key];
        if (child !== undefined) {
            children.push( this[key] );
        }
    }

    return children;
    /*
    var order = this.options.order;
    if (order) {
        for (var i = 0, l = order.length; i < l; i++) {
            children.push(this[order[i]]);
        }
    } else {
        for (var key in this) {
            if (this.hasOwnProperty(key) && /^[A-Z]/.test(key)) {
                children.push(this[key]);
            }
        }
    }
    return children;
    */
};

yate.AST.prototype._apply = function(callback) {
    var args = Array.prototype.slice.call(arguments, 1);

    var children = this.children();
    for (var i = 0, l = children.length; i < l; i++) {
        step(children[i]);
    }

    function step(child) {
        if (child instanceof Array) {
            for (var j = 0, m = child.length; j < m; j++) {
                step(child[j]);
            }
        } else if (child instanceof yate.AST) {
            callback.apply(child, args);
        }
    }
};

yate.AST.prototype.trigger = function(method) {
    var args = Array.prototype.slice.call(arguments, 1);

    run.apply(this, args);

    function run() {
        var callback;
        if ((typeof method == 'function')) {
            callback = method;
        } else if (typeof method == 'string' && typeof this[method] == 'function') {
            callback = this[method];
        }
        var args = Array.prototype.slice.call(arguments);
        if (callback) {
            callback.apply(this, args);
        }
        this._apply.apply(this, [ run ].concat(args));
    };
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.setParents = function() {
    function set(parent) {
        this.parent = parent;
        this._apply(set, this);
    }

    set.call(this, null);
};

// ----------------------------------------------------------------------------------------------------------------- //
// Type methods
// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.type = function(to) {
    var type = this._type;
    if (type === undefined) {
        type = this._type = this._getType();
    }

    return (to) ? yate.types.convertable(type, to) : type;
};

yate.AST.prototype._getType = function() {
    return yate.types.NONE;
};

yate.AST.prototype.cast = function(to) {
    var from = this.type();
    to = to || from;

    if (from != to) {
        this.AsType = to;

        if (!yate.types.convertable(from, to)) {
            this.error('Cannot convert type from ' + from + ' to ' + to + ' ' + this.id);
        }
    }

    this.oncast(to);
};

yate.AST.prototype.oncast = function(to) {
    // Do nothing.
};

yate.AST.prototype.toValue = function() {
    var type = this.type();

    if (type == yate.types.ARRAY || type == yate.types.OBJECT) {
        this.cast(type);
    } else {
        this.cast(yate.types.XML);
    }
};

yate.AST.prototype.is = function(type) {
    if (type instanceof Array) {
        for (var i = 0, l = type.length; i < l; i++) {
            if (this instanceof yate.AST.$(type[i])) {
                return true;
            }
        }
    } else {
        return this instanceof yate.AST.$(type);
    }
};

yate.AST.prototype.inline = yate.false;

// ----------------------------------------------------------------------------------------------------------------- //
// Walk methods
// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.setLocals = function() {
    var options = this.options.locals || {};
    var locals = yate.AST.locals;
    var parent = this.parent;

    for (var local in locals) {
        var parentLocal = (parent) ? parent[local] : null;
        if (options[local]) {
            this[local] = (parentLocal) ? parentLocal.child() : new locals[local]();
        } else {
            this[local] = parentLocal;
        }
    }

    this.Sid = this.scope.id;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.log = function() {
    // console.log(this.id);
    return require('util').inspect(this, true, null);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.set = function(key, value) {
    this.trigger(function() {
        this[key] = value;
    });
};

yate.AST.prototype.rid = function() {
    this.set('Rid', this.Rid + 1);
};

yate.AST.prototype.cid = function() {
    this.set('Cid', this.Cid + 1);
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.isOpen = function() {
    if (this.type() == yate.types.ATTR || this.type() == yate.types.XML) {
        return undefined;
    }
    return false;
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.prototype.toString = function() {
    var r = [];
    var keys = this.childrenKeys();
    for (var i = 0, l = keys.length; i < l; i++) {
        var key = keys[i];
        var child = this[key];
        if (child !== undefined) {
            if (child instanceof yate.AST) {
                var s = child.toString();
                if (s) {
                    r.push( key.blue.bold + ': ' + s);
                }
            } else {
                r.push( key.blue.bold + ': ' + JSON.stringify(child) );
            }
        }
    }
    if (r.length) {
        var s = this.id.bold + '( ' + this.type().lime;
        if (this.AsType) {
            s += ' -> '.lime + this.AsType.lime;
        }
        s += ' )\n' + r.join('\n').replace(/^/gm, '    ');
        return s;
    }
    return '';
};

// ----------------------------------------------------------------------------------------------------------------- //

yate.AST.var_type = {
    USER: 'user',
    ARGUMENT: 'argument'
};

yate.AST.function_type = {
    USER: 'user',
    INTERNAL: 'internal',
    EXTERNAL: 'external',
    KEY: 'key'
};

<|endoftext|>


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

    grunt.initConfig({
        less : {
            dev : {
                options : {
                    paths : ['./src/css/']
                },
                files : {
                    './src/css/style.css' : './src/css/style.less'
                }
            },
            build : {
                options : {
                    paths : ['./src/css/']
                },
                files : {
                    './dst/css/style.css' : './src/css/style.less'
                }
            }
        },

        copy : {
            html : {
                files : [
                    {
                        src  : './src/index.html',
                        dest : './dst/index.html'
                    }
                ]
            }
        },

        jsdoc : {
            build : {
                src : ['./src/js/purgatory/**/*.js', './src/js/main.js'],
                options : {
                    destination : './doc',
                    configure   : './jsdoc.conf',
                    template    : './node_modules/grunt-jsdoc/node_modules/ink-docstrap/template'
                }
            }
        },

        concat_in_order : {
            js : {
                options : {
                    extractRequired : function (filePath, fileContent) {
                        var workingdir = filePath.split('/');
                        workingdir.pop();

                        var deps = this.getMatches(/\*\s*@depend\s(.*\.js)/g, fileContent);
                        deps.forEach(function(dep, i) {
                            var dependency = workingdir.concat([dep]);
                            deps[i] = dependency.join('/');
                        });
                        return deps;
                    },
                    extractDeclared : function (filePath) {
                        return [filePath];
                    },
                    onlyConcatRequiredFiles : true
                },
                files : {
                    './src/js/main.min.js' : ['./src/js/main.js']
                }
            }
        },

        uglify : {
            js : {
                files : {
                    './dst/js/main.min.js' : ['./src/js/main.min.js']
                }
            }
        },

        cssmin : {
            css : {
                files : {
                    './dst/css/style.css' : ['./src/css/style.css']
                }
            }
        },

        clean : {
            dst :   ['./dst'],
            doc :   ['./doc'],
            build : ['./dst', './doc', './src/js/main.min.js']
        },

        watch : {
            css : {
                files : ['./src/css/*.less'],
                tasks : ['less:dev']
            },
            js : {
                files : ['./src/js/purgatory/**/*.js', './src/js/main.js'],
                tasks : ['concat_in_order:js']
            },
            doc : {
                files : ['./src/js/purgatory/**/*.js', './src/js/main.js'],
                tasks : ['doc']
            }
        }
    });

    // Sub tasks
    grunt.registerTask('jsBuild',  ['concat_in_order:js', 'uglify:js']);
    grunt.registerTask('cssBuild', ['less:dev', 'cssmin:css']);
    grunt.registerTask('doc',      ['clean:doc', 'jsdoc:build']);

    // Macro tasks
    grunt.registerTask('dev',   ['concat_in_order:js', 'less:dev', 'doc']);
    grunt.registerTask('build', ['clean:build', 'copy:html', 'jsBuild', 'cssBuild', 'doc']);
};<commit_msg>Adjusting grunt_watch task<commit_after>module.exports = function(grunt) {
    require('time-grunt')(grunt);
    require('jit-grunt')(grunt);

    grunt.initConfig({
        less : {
            dev : {
                options : {
                    paths : ['./src/css/']
                },
                files : {
                    './src/css/style.css' : './src/css/style.less'
                }
            },
            build : {
                options : {
                    paths : ['./src/css/']
                },
                files : {
                    './dst/css/style.css' : './src/css/style.less'
                }
            }
        },

        copy : {
            html : {
                files : [
                    {
                        src  : './src/index.html',
                        dest : './dst/index.html'
                    }
                ]
            }
        },

        jsdoc : {
            build : {
                src : ['./src/js/purgatory/**/*.js', './src/js/main.js'],
                options : {
                    destination : './doc',
                    configure   : './jsdoc.conf',
                    template    : './node_modules/grunt-jsdoc/node_modules/ink-docstrap/template'
                }
            }
        },

        concat_in_order : {
            js : {
                options : {
                    extractRequired : function (filePath, fileContent) {
                        var workingdir = filePath.split('/');
                        workingdir.pop();

                        var deps = this.getMatches(/\*\s*@depend\s(.*\.js)/g, fileContent);
                        deps.forEach(function(dep, i) {
                            var dependency = workingdir.concat([dep]);
                            deps[i] = dependency.join('/');
                        });
                        return deps;
                    },
                    extractDeclared : function (filePath) {
                        return [filePath];
                    },
                    onlyConcatRequiredFiles : true
                },
                files : {
                    './src/js/main.min.js' : ['./src/js/main.js']
                }
            }
        },

        uglify : {
            js : {
                files : {
                    './dst/js/main.min.js' : ['./src/js/main.min.js']
                }
            }
        },

        cssmin : {
            css : {
                files : {
                    './dst/css/style.css' : ['./src/css/style.css']
                }
            }
        },

        clean : {
            dst :   ['./dst'],
            doc :   ['./doc'],
            build : ['./dst', './doc', './src/js/main.min.js']
        },

        watch : {
            css : {
                files : ['./src/css/*.less'],
                tasks : ['cssBuild']
            },
            js : {
                files : ['./src/js/purgatory/**/*.js', './src/js/main.js'],
                tasks : ['jsBuild', 'doc']
            },
            html : {
                files : ['./src/index.html'],
                tasks : ['copy:html']
            }
        }
    });

    // Sub tasks
    grunt.registerTask('jsBuild',  ['concat_in_order:js', 'uglify:js']);
    grunt.registerTask('cssBuild', ['less:dev', 'cssmin:css']);
    grunt.registerTask('doc',      ['clean:doc', 'jsdoc:build']);

    // Macro tasks
    grunt.registerTask('dev',   ['concat_in_order:js', 'less:dev', 'doc']);
    grunt.registerTask('build', ['clean:build', 'copy:html', 'jsBuild', 'cssBuild', 'doc']);
};<|endoftext|>


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        clean: {
            options: { force: true},
            all: {
                src: ['build/**/*.*']
            }
        },
        concat: {
            dist: {
                src: ['src/js/**/*.js'],
                dest: 'build/mdi-desktop.js'
            }
        },
        // Test settings
        karma: {
            options: {
                configFile: 'karma.conf.js',
                browsers: ['PhantomJS']
            },
            unit: {
                singleRun: true,
                options: {
                    reporters: ['dots', 'coverage']
                }
            },
            server: {
                autoWatch: true
            }
        }
    });

    grunt.registerTask('default', ['build']);
    grunt.registerTask('build', ['clean', 'concat']);
    grunt.registerTask('test', ['karma:unit']);

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-karma');
}<commit_msg>Update<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        clean: {
            options: { force: true},
            all: {
                src: ['build/**/*.*']
            }
        },
        concat: {
            dist: {
                src: ['src/js/**/*.js'],
                dest: 'build/mdi-desktop.js'
            }
        },
        // Test settings
        karma: {
            options: {
                configFile: 'karma.conf.js',
                browsers: ['PhantomJS']
            },
            unit: {
                singleRun: true,
                options: {
                    reporters: ['dots', 'coverage']
                }
            },
            server: {
                autoWatch: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-karma');

    grunt.registerTask('build', ['clean', 'concat']);

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

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


<commit_before>// Generated on 2015-11-22 using
// generator-webapp 1.1.0
'use strict';

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

module.exports = function (grunt) {

  grunt.loadNpmTasks('grunt-processhtml');

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

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    server: 'http://46.101.214.124:8080'
  };

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

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      babel: {
        files: ['<%= config.app %>/scripts/{,*/}*.js'],
        tasks: ['babel:dist']
      },
      babelTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['babel:test', 'test:watch']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'postcss']
      }
    },

    processhtml: {
      options: {
        data: {
          vector:     "<%= config.server %>/sh_vector.js",
          collisions: "<%= config.server %>/sh_collisions.js",
          simulation: "<%= config.server %>/sh_simulation.js"
        }
      },
      dist: {
        files: {
          '<%= config.dist %>/index.html': ['<%= config.app %>/index.html']
        }
      }
    },

    browserSync: {
      options: {
        notify: false,
        background: true,
        watchOptions: {
          ignored: ''
        }
      },
      livereload: {
        options: {
          files: [
            '<%= config.app %>/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '<%= config.app %>/images/{,*/}*',
            '.tmp/scripts/{,*/}*.js'
          ],
          port: 9000,
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/bower_components': './bower_components'
            }
          }
        }
      },
      test: {
        options: {
          port: 9001,
          open: false,
          logLevel: 'silent',
          host: 'localhost',
          server: {
            baseDir: ['.tmp', './test', config.app],
            routes: {
              '/bower_components': './bower_components'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>'
        }
      }
    },

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

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      target: [
        'Gruntfile.js',
        '<%= config.app %>/scripts/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },

    // Mocha testing framework configuration options
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://<%= browserSync.test.options.host %>:<%= browserSync.test.options.port %>/index.html']
        }
      }
    },

    // Compiles ES6 with Babel
    babel: {
      options: {
        sourceMap: true
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/scripts',
          src: '{,*/}*.js',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.js',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },

    postcss: {
      options: {
        map: true,
        processors: [
          // Add vendor prefixed styles
          require('autoprefixer')({
            browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']
          })
        ]
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the HTML file
    wiredep: {
      app: {
        src: ['<%= config.app %>/index.html'],
        exclude: ['bootstrap.js'],
        ignorePath: /^(\.\.\/)*\.\./
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/images/{,*/}*.*',
          '<%= config.dist %>/styles/fonts/{,*/}*.*',
          '<%= config.dist %>/*.{ico,png}'
        ]
      }
    },

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

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

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

    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          // true would impact styles with attribute selectors
          removeRedundantAttributes: false,
          useShortDoctype: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,*/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

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

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

    // Generates a custom Modernizr build that includes only the tests you
    // reference in your app
    modernizr: {
      dist: {
        devFile: 'bower_components/modernizr/modernizr.js',
        outputFile: '<%= config.dist %>/scripts/vendor/modernizr.js',
        files: {
          src: [
            '<%= config.dist %>/scripts/{,*/}*.js',
            '<%= config.dist %>/styles/{,*/}*.css',
            '!<%= config.dist %>/scripts/vendor/*'
          ]
        },
        uglify: true
      }
    },

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

  grunt.registerTask('serve', 'start the server and preview your app', function (target) {

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

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

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

  grunt.registerTask('test', function (target) {
    if (target !== 'watch') {
      grunt.task.run([
        'clean:server',
        'concurrent:test',
        'postcss'
      ]);
    }

    grunt.task.run([
      'browserSync:test',
      'mocha'
    ]);
  });

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

  grunt.registerTask('default', [
    'newer:eslint',
    'test',
    'build'
  ]);
};
<commit_msg>disable cross device sync<commit_after>// Generated on 2015-11-22 using
// generator-webapp 1.1.0
'use strict';

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

module.exports = function (grunt) {

  grunt.loadNpmTasks('grunt-processhtml');

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

  // Automatically load required grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin'
  });

  // Configurable paths
  var config = {
    app: 'app',
    dist: 'dist',
    server: 'http://46.101.214.124:8080'
  };

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

    // Project settings
    config: config,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      babel: {
        files: ['<%= config.app %>/scripts/{,*/}*.js'],
        tasks: ['babel:dist']
      },
      babelTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['babel:test', 'test:watch']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      styles: {
        files: ['<%= config.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'postcss']
      }
    },

    processhtml: {
      options: {
        data: {
          vector:     "<%= config.server %>/sh_vector.js",
          collisions: "<%= config.server %>/sh_collisions.js",
          simulation: "<%= config.server %>/sh_simulation.js"
        }
      },
      dist: {
        files: {
          '<%= config.dist %>/index.html': ['<%= config.app %>/index.html']
        }
      }
    },

    browserSync: {
      options: {
        notify: false,
        background: true,
        ghostMode: false,
        watchOptions: {
          ignored: ''
        }
      },
      livereload: {
        options: {
          files: [
            '<%= config.app %>/{,*/}*.html',
            '.tmp/styles/{,*/}*.css',
            '<%= config.app %>/images/{,*/}*',
            '.tmp/scripts/{,*/}*.js'
          ],
          port: 9000,
          server: {
            baseDir: ['.tmp', config.app],
            routes: {
              '/bower_components': './bower_components'
            }
          }
        }
      },
      test: {
        options: {
          port: 9001,
          open: false,
          logLevel: 'silent',
          host: 'localhost',
          server: {
            baseDir: ['.tmp', './test', config.app],
            routes: {
              '/bower_components': './bower_components'
            }
          }
        }
      },
      dist: {
        options: {
          background: false,
          server: '<%= config.dist %>'
        }
      }
    },

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

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      target: [
        'Gruntfile.js',
        '<%= config.app %>/scripts/{,*/}*.js',
        '!<%= config.app %>/scripts/vendor/*',
        'test/spec/{,*/}*.js'
      ]
    },

    // Mocha testing framework configuration options
    mocha: {
      all: {
        options: {
          run: true,
          urls: ['http://<%= browserSync.test.options.host %>:<%= browserSync.test.options.port %>/index.html']
        }
      }
    },

    // Compiles ES6 with Babel
    babel: {
      options: {
        sourceMap: true
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/scripts',
          src: '{,*/}*.js',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.js',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },

    postcss: {
      options: {
        map: true,
        processors: [
          // Add vendor prefixed styles
          require('autoprefixer')({
            browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']
          })
        ]
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the HTML file
    wiredep: {
      app: {
        src: ['<%= config.app %>/index.html'],
        exclude: ['bootstrap.js'],
        ignorePath: /^(\.\.\/)*\.\./
      }
    },

    // Renames files for browser caching purposes
    filerev: {
      dist: {
        src: [
          '<%= config.dist %>/scripts/{,*/}*.js',
          '<%= config.dist %>/styles/{,*/}*.css',
          '<%= config.dist %>/images/{,*/}*.*',
          '<%= config.dist %>/styles/fonts/{,*/}*.*',
          '<%= config.dist %>/*.{ico,png}'
        ]
      }
    },

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

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

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= config.app %>/images',
          src: '{,*/}*.{gif,jpeg,jpg,png}',
          dest: '<%= config.dist %>/images'
        }]
      }
    },

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

    htmlmin: {
      dist: {
        options: {
          collapseBooleanAttributes: true,
          collapseWhitespace: true,
          conservativeCollapse: true,
          removeAttributeQuotes: true,
          removeCommentsFromCDATA: true,
          removeEmptyAttributes: true,
          removeOptionalTags: true,
          // true would impact styles with attribute selectors
          removeRedundantAttributes: false,
          useShortDoctype: true
        },
        files: [{
          expand: true,
          cwd: '<%= config.dist %>',
          src: '{,*/}*.html',
          dest: '<%= config.dist %>'
        }]
      }
    },

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

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

    // Generates a custom Modernizr build that includes only the tests you
    // reference in your app
    modernizr: {
      dist: {
        devFile: 'bower_components/modernizr/modernizr.js',
        outputFile: '<%= config.dist %>/scripts/vendor/modernizr.js',
        files: {
          src: [
            '<%= config.dist %>/scripts/{,*/}*.js',
            '<%= config.dist %>/styles/{,*/}*.css',
            '!<%= config.dist %>/scripts/vendor/*'
          ]
        },
        uglify: true
      }
    },

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

  grunt.registerTask('serve', 'start the server and preview your app', function (target) {

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

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

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

  grunt.registerTask('test', function (target) {
    if (target !== 'watch') {
      grunt.task.run([
        'clean:server',
        'concurrent:test',
        'postcss'
      ]);
    }

    grunt.task.run([
      'browserSync:test',
      'mocha'
    ]);
  });

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

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


<commit_before>var gulp = require('gulp');
var chug = require('gulp-chug');
var gulpWebpack = require('gulp-webpack');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var file = require('gulp-file');
var preprocess = require('gulp-preprocess');
var gulpif = require('gulp-if');
var assign = require('object-assign');
var webpack = require('webpack');
var del = require('del');
var path = require('path');
var fs = require('fs');
var coveralls = require('gulp-coveralls');
var blanket = require('gulp-blanket-mocha');

var packageJSON = require('./package.json');
delete packageJSON.devDependencies;
delete packageJSON.config;
packageJSON.main = 'index.js';
packageJSON.dependencies = {
  'react': '^0.13.1',
  'inuit-box-sizing': '~0.2.0',
  'inuit-clearfix': '^0.2.1',
  'inuit-defaults': '~0.2.1',
  'inuit-functions': '~0.2.0',
  'inuit-headings': '~0.3.0',
  'inuit-images': '~0.3.3',
  'inuit-list-bare': '~0.3.0',
  'inuit-lists': '~0.1.0',
  'inuit-mixins': '~0.2.3',
  'inuit-normalize': '~3.0.2',
  'inuit-page': '~0.2.1',
  'inuit-reset': '~0.1.1',
  'inuit-responsive-settings': '~0.1.2',
  'inuit-responsive-tools': '~0.1.1',
  'inuit-shared': '~0.1.5',
  'mkdirp': '^0.5.0',
  'gulp': '^3.8.11',
  'gulp-template': '^3.0.0',
  'gulp-install': '^0.4.0',
  "lodash": "^3.8.0",
  "reflux": "^0.2.7",
  "superagent": "^1.1.0"
};

var opts = {
  dist: path.resolve(__dirname, 'dist'),
  copyAssets: [
    'README.md',
    'src/js/**',
    {
      asset: 'src/scss/**',
      dist: 'dist/scss/'
    },
    'design/**',
    'src/img/**',
    {
      asset: 'bin/**',
      dist: 'dist/bin/'
    },
    {
      asset: 'templates/**',
      dist: 'dist/templates/'
    },
    {
      filename: 'package.json',
      asset: JSON.stringify(packageJSON, null, 2)
    }
  ],
  scssAssets: ['src/scss/**/*.scss'],
  jsAssets: ['src/js/**/*.js'],
  mainJs: 'src/js/index.js',
  mainScss: 'src/scss/grommet-core/index.scss',
  sync: {
    hostname: 'grommet.usa.hp.com',
    username: 'ligo',
    remoteDestination: '/var/www/html/assets/' + packageJSON.version
  },
  webpack: {
    output: {
      filename: 'grommet.min.js',
      libraryTarget: 'var',
      library: 'Grommet'
    },
    resolve: {
      modulesDirectories: ['node_modules', 'src/js', 'src/scss']
    },
    externals: {
      'react': 'React'
    }
  },
  distPreprocess: ['dist-css'],
  scsslint: true,
  testPaths: [
    'test/**/*.js'
  ]
};

require('./src/js/utils/gulp-tasks')(gulp, opts);

gulp.task('dist-css', function () {
  gulp.src('src/scss/hpe/*.scss')
    .pipe(sass({includePaths: [path.resolve(__dirname, './node_modules')]}))
    .pipe(rename('grommet-hpe.min.css'))
    .pipe(minifyCss())
    .pipe(gulp.dest('dist/'));

  return gulp.src('src/scss/grommet-core/*.scss')
        .pipe(sass({includePaths: [path.resolve(__dirname, './node_modules')]}))
        .pipe(rename('grommet.min.css'))
        .pipe(minifyCss())
        .pipe(gulp.dest('dist/'));
});

gulp.task('sync-all', function() {

  gulp.src('./examples/demo/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./examples/tour/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./examples/server/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./docs/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));
});

var bowerWebpackConfig = {
  output: {
    filename: 'grommet.js',
    libraryTarget: 'var',
    library: 'Grommet'
  },
  resolve: {
    root: [
      path.resolve(__dirname, 'src/js'),
      path.resolve(__dirname, 'src/scss'),
      path.resolve(__dirname, 'node_modules')
    ],
    extensions: ['', '.js', '.json', '.htm', '.html', '.scss']
  },
  externals: {
    'react': 'React'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'jsx-loader'
      },
      {
        test: /\.svg$/,
        loader: 'file-loader?mimetype=image/svg'
      },
      {
        test: /\.jpg$/,
        loader: 'file-loader?mimetype=image/jpg'
      },
      {
        test: /\.woff$/,
        loader: 'file-loader?mimetype=application/font-woff'
      }
    ]
  },
  plugins: [
    new webpack.optimize.DedupePlugin()
  ]
};

var bowerMinWebpackConfig = assign({}, bowerWebpackConfig, {
  output: {
    filename: 'grommet.min.js',
    libraryTarget: 'var',
    library: 'Grommet'
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    }),
    new webpack.optimize.DedupePlugin()
  ]
});

function distCss(path, name, minify) {
  gulp.src(path)
    .pipe(sass({includePaths: [ 'node_modules' ]}))
    .pipe(rename(name))
    .pipe(gulpif(minify, minifyCss()))
    .pipe(gulp.dest('dist-bower/css'));
}

gulp.task('dist-bower', function() {
  del.sync(['dist-bower']);

  //grommet exploded
  gulp.src(opts.mainJs)
    .pipe(gulpWebpack(bowerWebpackConfig))
    .pipe(gulp.dest('dist-bower'));

  //grommet minified
  gulp.src(opts.mainJs)
    .pipe(gulpWebpack(bowerMinWebpackConfig))
    .pipe(gulp.dest('dist-bower'));

  distCss('src/scss/grommet-core/*.scss', 'grommet.css');
  distCss('src/scss/grommet-core/*.scss', 'grommet.min.css', true);
  distCss('src/scss/hpe/*.scss', 'grommet-hpe.css');
  distCss('src/scss/hpe/*.scss', 'grommet-hpe.min.css', true);
  distCss('src/scss/hpinc/*.scss', 'grommet-hpinc.css');
  distCss('src/scss/hpinc/*.scss', 'grommet-hpinc.min.css', true);

  //sample-grommet
  gulp.src('examples/todo-app/index.html')
        .pipe(preprocess({context: { NODE_ENV: 'production'}}))
        .pipe(rename('sample-grommet.html'))
        .pipe(gulp.dest('dist-bower'));

  var bowerJSON = require('./package.json');
  bowerJSON.dependencies = { 'react': '^0.13.1', 'grommet': 'HewlettPackard/grommet-bower' };
  bowerJSON.main = 'grommet.js';
  delete bowerJSON.devDependencies;
  delete bowerJSON.scripts;
  delete bowerJSON.config;

  gulp.src('./dist-bower')
          .pipe(file('bower.json', JSON.stringify(bowerJSON, null, 2)))
          .pipe(gulp.dest('dist-bower'));
});

gulp.task('coveralls-preprocess', function(done) {
  require('./src/js/utils/test-compiler');
  require('./src/js/utils/mocked-dom')('');

  return gulp.src('./test/**/*.js', { read: false })
    .pipe(blanket({
      instrument:[path.join(__dirname, 'src/js')],
      captureFile: 'test/lcov.info',
      reporter: 'mocha-lcov-reporter'
    })).end(function() {
      done();
    });
});

gulp.task('coveralls', ['coveralls-preprocess'], function() {
  fs.exists('./test/lcov.info', function (exists) {
    if (exists) {
      gulp.src('./test/lcov.info').pipe(coveralls());
    } else {
      console.error('Could not find lcov report file.');
      process.exit(1);
    }
  });
});<commit_msg>Coveralls: making sure the report file actually exists.<commit_after>var gulp = require('gulp');
var chug = require('gulp-chug');
var gulpWebpack = require('gulp-webpack');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var file = require('gulp-file');
var preprocess = require('gulp-preprocess');
var gulpif = require('gulp-if');
var assign = require('object-assign');
var webpack = require('webpack');
var del = require('del');
var path = require('path');
var fs = require('fs');
var coveralls = require('gulp-coveralls');
var blanket = require('gulp-blanket-mocha');

var packageJSON = require('./package.json');
delete packageJSON.devDependencies;
delete packageJSON.config;
packageJSON.main = 'index.js';
packageJSON.dependencies = {
  'react': '^0.13.1',
  'inuit-box-sizing': '~0.2.0',
  'inuit-clearfix': '^0.2.1',
  'inuit-defaults': '~0.2.1',
  'inuit-functions': '~0.2.0',
  'inuit-headings': '~0.3.0',
  'inuit-images': '~0.3.3',
  'inuit-list-bare': '~0.3.0',
  'inuit-lists': '~0.1.0',
  'inuit-mixins': '~0.2.3',
  'inuit-normalize': '~3.0.2',
  'inuit-page': '~0.2.1',
  'inuit-reset': '~0.1.1',
  'inuit-responsive-settings': '~0.1.2',
  'inuit-responsive-tools': '~0.1.1',
  'inuit-shared': '~0.1.5',
  'mkdirp': '^0.5.0',
  'gulp': '^3.8.11',
  'gulp-template': '^3.0.0',
  'gulp-install': '^0.4.0',
  "lodash": "^3.8.0",
  "reflux": "^0.2.7",
  "superagent": "^1.1.0"
};

var opts = {
  dist: path.resolve(__dirname, 'dist'),
  copyAssets: [
    'README.md',
    'src/js/**',
    {
      asset: 'src/scss/**',
      dist: 'dist/scss/'
    },
    'design/**',
    'src/img/**',
    {
      asset: 'bin/**',
      dist: 'dist/bin/'
    },
    {
      asset: 'templates/**',
      dist: 'dist/templates/'
    },
    {
      filename: 'package.json',
      asset: JSON.stringify(packageJSON, null, 2)
    }
  ],
  scssAssets: ['src/scss/**/*.scss'],
  jsAssets: ['src/js/**/*.js'],
  mainJs: 'src/js/index.js',
  mainScss: 'src/scss/grommet-core/index.scss',
  sync: {
    hostname: 'grommet.usa.hp.com',
    username: 'ligo',
    remoteDestination: '/var/www/html/assets/' + packageJSON.version
  },
  webpack: {
    output: {
      filename: 'grommet.min.js',
      libraryTarget: 'var',
      library: 'Grommet'
    },
    resolve: {
      modulesDirectories: ['node_modules', 'src/js', 'src/scss']
    },
    externals: {
      'react': 'React'
    }
  },
  distPreprocess: ['dist-css'],
  scsslint: true,
  testPaths: [
    'test/**/*.js'
  ]
};

require('./src/js/utils/gulp-tasks')(gulp, opts);

gulp.task('dist-css', function () {
  gulp.src('src/scss/hpe/*.scss')
    .pipe(sass({includePaths: [path.resolve(__dirname, './node_modules')]}))
    .pipe(rename('grommet-hpe.min.css'))
    .pipe(minifyCss())
    .pipe(gulp.dest('dist/'));

  return gulp.src('src/scss/grommet-core/*.scss')
        .pipe(sass({includePaths: [path.resolve(__dirname, './node_modules')]}))
        .pipe(rename('grommet.min.css'))
        .pipe(minifyCss())
        .pipe(gulp.dest('dist/'));
});

gulp.task('sync-all', function() {

  gulp.src('./examples/demo/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./examples/tour/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./examples/server/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./docs/gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));

  gulp.src('./gulpfile.js').pipe(chug({
    tasks: ['sync']
  }));
});

var bowerWebpackConfig = {
  output: {
    filename: 'grommet.js',
    libraryTarget: 'var',
    library: 'Grommet'
  },
  resolve: {
    root: [
      path.resolve(__dirname, 'src/js'),
      path.resolve(__dirname, 'src/scss'),
      path.resolve(__dirname, 'node_modules')
    ],
    extensions: ['', '.js', '.json', '.htm', '.html', '.scss']
  },
  externals: {
    'react': 'React'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'jsx-loader'
      },
      {
        test: /\.svg$/,
        loader: 'file-loader?mimetype=image/svg'
      },
      {
        test: /\.jpg$/,
        loader: 'file-loader?mimetype=image/jpg'
      },
      {
        test: /\.woff$/,
        loader: 'file-loader?mimetype=application/font-woff'
      }
    ]
  },
  plugins: [
    new webpack.optimize.DedupePlugin()
  ]
};

var bowerMinWebpackConfig = assign({}, bowerWebpackConfig, {
  output: {
    filename: 'grommet.min.js',
    libraryTarget: 'var',
    library: 'Grommet'
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    }),
    new webpack.optimize.DedupePlugin()
  ]
});

function distCss(path, name, minify) {
  gulp.src(path)
    .pipe(sass({includePaths: [ 'node_modules' ]}))
    .pipe(rename(name))
    .pipe(gulpif(minify, minifyCss()))
    .pipe(gulp.dest('dist-bower/css'));
}

gulp.task('dist-bower', function() {
  del.sync(['dist-bower']);

  //grommet exploded
  gulp.src(opts.mainJs)
    .pipe(gulpWebpack(bowerWebpackConfig))
    .pipe(gulp.dest('dist-bower'));

  //grommet minified
  gulp.src(opts.mainJs)
    .pipe(gulpWebpack(bowerMinWebpackConfig))
    .pipe(gulp.dest('dist-bower'));

  distCss('src/scss/grommet-core/*.scss', 'grommet.css');
  distCss('src/scss/grommet-core/*.scss', 'grommet.min.css', true);
  distCss('src/scss/hpe/*.scss', 'grommet-hpe.css');
  distCss('src/scss/hpe/*.scss', 'grommet-hpe.min.css', true);
  distCss('src/scss/hpinc/*.scss', 'grommet-hpinc.css');
  distCss('src/scss/hpinc/*.scss', 'grommet-hpinc.min.css', true);

  //sample-grommet
  gulp.src('examples/todo-app/index.html')
        .pipe(preprocess({context: { NODE_ENV: 'production'}}))
        .pipe(rename('sample-grommet.html'))
        .pipe(gulp.dest('dist-bower'));

  var bowerJSON = require('./package.json');
  bowerJSON.dependencies = { 'react': '^0.13.1', 'grommet': 'HewlettPackard/grommet-bower' };
  bowerJSON.main = 'grommet.js';
  delete bowerJSON.devDependencies;
  delete bowerJSON.scripts;
  delete bowerJSON.config;

  gulp.src('./dist-bower')
          .pipe(file('bower.json', JSON.stringify(bowerJSON, null, 2)))
          .pipe(gulp.dest('dist-bower'));
});

gulp.task('coveralls-preprocess', function(done) {
  require('./src/js/utils/test-compiler');
  require('./src/js/utils/mocked-dom')('');

  return gulp.src('./test/**/*.js', { read: false })
    .pipe(blanket({
      instrument:[path.join(__dirname, 'src/js')],
      captureFile: 'test/lcov.info',
      reporter: 'mocha-lcov-reporter'
    })).end(function() {
      done();
    });
});

gulp.task('coveralls', ['coveralls-preprocess'], function(done) {
  fs.exists('./test/lcov.info', function (exists) {
    if (exists) {
      gulp.src('./test/lcov.info').pipe(coveralls()).end(function() {
        done();
      });
    } else {
      console.error('Could not find lcov report file.');
      process.exit(1);
    }
  });
});<|endoftext|>


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

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    copy: {
      vendor: {
        files: [
          {
            expand: true, cwd: 'node_modules/bootstrap/',
            src: ['js/**', 'less/**'], dest: 'assets/vendor/bootstrap/'
          },
          {
            expand: true, cwd: 'node_modules/backbone/',
            src: ['backbone.js'], dest: 'assets/vendor/backbone/'
          },
          {
            expand: true, cwd: 'node_modules/font-awesome/',
            src: ['fonts/**', 'less/**'], dest: 'assets/vendor/font-awesome/'
          },
          {
            expand: true, cwd: 'node_modules/html5shiv/dist/',
            src: ['html5shiv.js'], dest: 'assets/vendor/html5shiv/'
          },
          {
            expand: true, cwd: 'node_modules/jquery/dist/',
            src: ['jquery.js'], dest: 'assets/vendor/jquery/'
          },
          {
            expand: true, cwd: 'node_modules/jquery.cookie/',
            src: ['jquery.cookie.js'], dest: 'assets/vendor/jquery.cookie/'
          },
          {
            expand: true, cwd: 'node_modules/moment/',
            src: ['moment.js'], dest: 'assets/vendor/momentjs/'
          },
          {
            expand: true, cwd: 'node_modules/respond.js/src/',
            src: ['respond.js'], dest: 'assets/vendor/respond/'
          },
          {
            expand: true, cwd: 'node_modules/underscore/',
            src: ['underscore.js'], dest: 'assets/vendor/underscore/'
          }
        ]
      },
      backboneapp: {
        files: [
          { expand: true, cwd: 'assets/', src: ['media/*'], dest: 'www/' },
          { expand: true, cwd: 'assets/vendor/font-awesome', src: ['fonts/*'], dest: 'www/' },
          { expand: true, cwd: 'assets/', src: ['favicon.ico'], dest: 'www/' },
          { expand: true, cwd: 'assets/views', src: ['templates.js'], dest: 'www/views/' },
          { expand: true, cwd: 'assets/views/about/', src: ['*.jade'], dest: 'www/views/about/' },
          { expand: true, cwd: 'assets/views/account/', src: ['*.jade'], dest: 'www/views/account/' },
          { expand: true, cwd: 'assets/views/account/settings/', src: ['*.jade'], dest: 'www/views/account/settings/' },
          { expand: true, cwd: 'assets/views/account/verification/', src: ['*.jade'], dest: 'www/views/account/verification/' },
          { expand: true, cwd: 'assets/views/admin/', src: ['*.jade'], dest: 'www/views/admin/' },
          { expand: true, cwd: 'assets/views/admin/accounts/', src: ['*.jade'], dest: 'www/views/admin/accounts/' },
          { expand: true, cwd: 'assets/views/admin/admin-groups/', src: ['*.jade'], dest: 'www/views/admin/admin-groups/' },
          { expand: true, cwd: 'assets/views/admin/administrators/', src: ['*.jade'], dest: 'www/views/admin/administrators/' },
          { expand: true, cwd: 'assets/views/admin/categories/', src: ['*.jade'], dest: 'www/views/admin/categories/' },
          { expand: true, cwd: 'assets/views/admin/statuses/', src: ['*.jade'], dest: 'www/views/admin/statuses/' },
          { expand: true, cwd: 'assets/views/admin/users/', src: ['*.jade'], dest: 'www/views/admin/users/' },
          { expand: true, cwd: 'assets/views/contact/', src: ['*.jade'], dest: 'www/views/contact/' },
          { expand: true, cwd: 'assets/views/http/', src: ['*.jade'], dest: 'www/views/http/' },
          { expand: true, cwd: 'assets/views/login/', src: ['*.jade'], dest: 'www/views/login/' },
          { expand: true, cwd: 'assets/views/login/forgot/', src: ['*.jade'], dest: 'www/views/login/forgot/' },
          { expand: true, cwd: 'assets/views/login/reset/', src: ['*.jade'], dest: 'www/views/login/reset/' },
          { expand: true, cwd: 'assets/views/signup/', src: ['*.jade'], dest: 'www/views/signup/' },
        ]
      }
    },
    jst: {
      options: {
        amd: true
      },
      compile: {
        files: {
          "assets/views/templates.js": ["assets/views/**/*.html"]
        }
      }
    },
    jade: {
      compile: {
        options: {
          data: {
            debug: false
          }
        },
        files: {
          "www/index.html": ["assets/views/index/*.jade"],
          "assets/views/index/tmpl-index.html": ["assets/views/index/*.jade"]
        }
      }
    },
    uglify: {
      options: {
        sourceMap: true,
        sourceMapName: function(filePath) {
          return filePath + '.map';
        }
      },
      layouts: {
        files: {
          'www/scripts/vendor.min.js': [
            'assets/vendor/jquery/jquery.js',
            'assets/vendor/jquery.cookie/jquery.cookie.js',
            'assets/vendor/underscore/underscore.js',
            'assets/vendor/backbone/backbone.js',
            'assets/vendor/bootstrap/js/affix.js',
            'assets/vendor/bootstrap/js/alert.js',
            'assets/vendor/bootstrap/js/button.js',
            'assets/vendor/bootstrap/js/carousel.js',
            'assets/vendor/bootstrap/js/collapse.js',
            'assets/vendor/bootstrap/js/dropdown.js',
            'assets/vendor/bootstrap/js/modal.js',
            'assets/vendor/bootstrap/js/tooltip.js',
            'assets/vendor/bootstrap/js/popover.js',
            'assets/vendor/bootstrap/js/scrollspy.js',
            'assets/vendor/bootstrap/js/tab.js',
            'assets/vendor/bootstrap/js/transition.js',
            'assets/vendor/momentjs/moment.js'
          ],
          'www/scripts/ie-sucks.min.js': [
            'assets/vendor/html5shiv/html5shiv.js',
            'assets/vendor/respond/respond.js',
            'assets/layouts/ie-sucks.js'
          ],
          'www/scripts/admin.min.js': ['assets/layouts/admin.js'],
          'www/scripts/account.min.js': ['assets/layouts/account.js'],
          'www/scripts/public.min.js': ['assets/layouts/public.js'],
          'www/scripts/index.min.js': ['assets/views/index.js']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'assets/views/',
          src: ['**/*.js', '!**/*.min.js'],
          dest: 'assets/views/',
          ext: '.min.js'
        }]
      }
    },
    jshint: {
      assets: {
        options: {
          jshintrc: '.jshintrc-assets',
          ignores: [
            'assets/layouts/**/*.min.js',
            'assets/views/**/*.min.js'
          ]
        },
        src: [
          'assets/layouts/**/*.js',
          'assets/views/**/*.js'
        ]
      }
    },
    less: {
      options: {
        compress: true
      },
      layouts: {
        files: {
          'www/styles/vendor.min.css': [
            'assets/less/bootstrap-build.less',
            'assets/less/font-awesome-build.less'
          ],
          'www/styles/admin.min.css': ['assets/layouts/admin.less'],
          'www/styles/account.min.css': ['assets/layouts/account.less'],
          'www/styles/public.min.css': ['assets/layouts/public.less'],
          'www/styles/index.min.css': ['assets/views/index.less']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'assets/views/',
          src: ['**/*.less'],
          dest: 'assets/views/',
          ext: '.min.css'
        }]
      }
    },
    clean: {
      js: {
        src: [
          'assets/layouts/**/*.min.js',
          'assets/layouts/**/*.min.js.map',
          'www/scripts/**/*.min.js',
          'www/scripts/**/*.min.js.map'
        ]
      },
      css: {
        src: [
          'assets/layouts/**/*.min.css',
          'www/styles/**/*.min.css'
        ]
      },
      vendor: {
        src: ['assets/vendor/**']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jst');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-newer');

  //grunt.registerTask('default', ['copy:vendor', 'newer:uglify', 'newer:less', 'concurrent']);
  grunt.registerTask('build', ['copy:vendor', 'jade', 'jst', 'uglify', 'less', 'copy:backboneapp']);
  grunt.registerTask('lint', ['jshint']);
};
<commit_msg>testing jst<commit_after>var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    copy: {
      vendor: {
        files: [
          {
            expand: true, cwd: 'node_modules/bootstrap/',
            src: ['js/**', 'less/**'], dest: 'assets/vendor/bootstrap/'
          },
          {
            expand: true, cwd: 'node_modules/backbone/',
            src: ['backbone.js'], dest: 'assets/vendor/backbone/'
          },
          {
            expand: true, cwd: 'node_modules/font-awesome/',
            src: ['fonts/**', 'less/**'], dest: 'assets/vendor/font-awesome/'
          },
          {
            expand: true, cwd: 'node_modules/html5shiv/dist/',
            src: ['html5shiv.js'], dest: 'assets/vendor/html5shiv/'
          },
          {
            expand: true, cwd: 'node_modules/jquery/dist/',
            src: ['jquery.js'], dest: 'assets/vendor/jquery/'
          },
          {
            expand: true, cwd: 'node_modules/jquery.cookie/',
            src: ['jquery.cookie.js'], dest: 'assets/vendor/jquery.cookie/'
          },
          {
            expand: true, cwd: 'node_modules/moment/',
            src: ['moment.js'], dest: 'assets/vendor/momentjs/'
          },
          {
            expand: true, cwd: 'node_modules/respond.js/src/',
            src: ['respond.js'], dest: 'assets/vendor/respond/'
          },
          {
            expand: true, cwd: 'node_modules/underscore/',
            src: ['underscore.js'], dest: 'assets/vendor/underscore/'
          }
        ]
      },
      backboneapp: {
        files: [
          { expand: true, cwd: 'assets/', src: ['media/*'], dest: 'www/' },
          { expand: true, cwd: 'assets/vendor/font-awesome', src: ['fonts/*'], dest: 'www/' },
          { expand: true, cwd: 'assets/', src: ['favicon.ico'], dest: 'www/' },
          { expand: true, cwd: 'assets/views', src: ['templates.js'], dest: 'www/views/' },
          { expand: true, cwd: 'assets/views/about/', src: ['*.jade'], dest: 'www/views/about/' },
          { expand: true, cwd: 'assets/views/account/', src: ['*.jade'], dest: 'www/views/account/' },
          { expand: true, cwd: 'assets/views/account/settings/', src: ['*.jade'], dest: 'www/views/account/settings/' },
          { expand: true, cwd: 'assets/views/account/verification/', src: ['*.jade'], dest: 'www/views/account/verification/' },
          { expand: true, cwd: 'assets/views/admin/', src: ['*.jade'], dest: 'www/views/admin/' },
          { expand: true, cwd: 'assets/views/admin/accounts/', src: ['*.jade'], dest: 'www/views/admin/accounts/' },
          { expand: true, cwd: 'assets/views/admin/admin-groups/', src: ['*.jade'], dest: 'www/views/admin/admin-groups/' },
          { expand: true, cwd: 'assets/views/admin/administrators/', src: ['*.jade'], dest: 'www/views/admin/administrators/' },
          { expand: true, cwd: 'assets/views/admin/categories/', src: ['*.jade'], dest: 'www/views/admin/categories/' },
          { expand: true, cwd: 'assets/views/admin/statuses/', src: ['*.jade'], dest: 'www/views/admin/statuses/' },
          { expand: true, cwd: 'assets/views/admin/users/', src: ['*.jade'], dest: 'www/views/admin/users/' },
          { expand: true, cwd: 'assets/views/contact/', src: ['*.jade'], dest: 'www/views/contact/' },
          { expand: true, cwd: 'assets/views/http/', src: ['*.jade'], dest: 'www/views/http/' },
          { expand: true, cwd: 'assets/views/login/', src: ['*.jade'], dest: 'www/views/login/' },
          { expand: true, cwd: 'assets/views/login/forgot/', src: ['*.jade'], dest: 'www/views/login/forgot/' },
          { expand: true, cwd: 'assets/views/login/reset/', src: ['*.jade'], dest: 'www/views/login/reset/' },
          { expand: true, cwd: 'assets/views/signup/', src: ['*.jade'], dest: 'www/views/signup/' },
        ]
      }
    },
    jst: {
      compile: {
        files: {
          "assets/views/templates.js": ["assets/views/**/*.html"]
        }
      }
    },
    jade: {
      compile: {
        options: {
          data: {
            debug: false
          }
        },
        files: {
          "www/index.html": ["assets/views/index/*.jade"],
          "assets/views/index/tmpl-index.html": ["assets/views/index/*.jade"]
        }
      }
    },
    uglify: {
      options: {
        sourceMap: true,
        sourceMapName: function(filePath) {
          return filePath + '.map';
        }
      },
      layouts: {
        files: {
          'www/scripts/vendor.min.js': [
            'assets/vendor/jquery/jquery.js',
            'assets/vendor/jquery.cookie/jquery.cookie.js',
            'assets/vendor/underscore/underscore.js',
            'assets/vendor/backbone/backbone.js',
            'assets/vendor/bootstrap/js/affix.js',
            'assets/vendor/bootstrap/js/alert.js',
            'assets/vendor/bootstrap/js/button.js',
            'assets/vendor/bootstrap/js/carousel.js',
            'assets/vendor/bootstrap/js/collapse.js',
            'assets/vendor/bootstrap/js/dropdown.js',
            'assets/vendor/bootstrap/js/modal.js',
            'assets/vendor/bootstrap/js/tooltip.js',
            'assets/vendor/bootstrap/js/popover.js',
            'assets/vendor/bootstrap/js/scrollspy.js',
            'assets/vendor/bootstrap/js/tab.js',
            'assets/vendor/bootstrap/js/transition.js',
            'assets/vendor/momentjs/moment.js'
          ],
          'www/scripts/ie-sucks.min.js': [
            'assets/vendor/html5shiv/html5shiv.js',
            'assets/vendor/respond/respond.js',
            'assets/layouts/ie-sucks.js'
          ],
          'www/scripts/admin.min.js': ['assets/layouts/admin.js'],
          'www/scripts/account.min.js': ['assets/layouts/account.js'],
          'www/scripts/public.min.js': ['assets/layouts/public.js'],
          'www/scripts/index.min.js': ['assets/views/index.js']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'assets/views/',
          src: ['**/*.js', '!**/*.min.js'],
          dest: 'assets/views/',
          ext: '.min.js'
        }]
      }
    },
    jshint: {
      assets: {
        options: {
          jshintrc: '.jshintrc-assets',
          ignores: [
            'assets/layouts/**/*.min.js',
            'assets/views/**/*.min.js'
          ]
        },
        src: [
          'assets/layouts/**/*.js',
          'assets/views/**/*.js'
        ]
      }
    },
    less: {
      options: {
        compress: true
      },
      layouts: {
        files: {
          'www/styles/vendor.min.css': [
            'assets/less/bootstrap-build.less',
            'assets/less/font-awesome-build.less'
          ],
          'www/styles/admin.min.css': ['assets/layouts/admin.less'],
          'www/styles/account.min.css': ['assets/layouts/account.less'],
          'www/styles/public.min.css': ['assets/layouts/public.less'],
          'www/styles/index.min.css': ['assets/views/index.less']
        }
      },
      views: {
        files: [{
          expand: true,
          cwd: 'assets/views/',
          src: ['**/*.less'],
          dest: 'assets/views/',
          ext: '.min.css'
        }]
      }
    },
    clean: {
      js: {
        src: [
          'assets/layouts/**/*.min.js',
          'assets/layouts/**/*.min.js.map',
          'www/scripts/**/*.min.js',
          'www/scripts/**/*.min.js.map'
        ]
      },
      css: {
        src: [
          'assets/layouts/**/*.min.css',
          'www/styles/**/*.min.css'
        ]
      },
      vendor: {
        src: ['assets/vendor/**']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jst');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-newer');

  //grunt.registerTask('default', ['copy:vendor', 'newer:uglify', 'newer:less', 'concurrent']);
  grunt.registerTask('build', ['copy:vendor', 'jade', 'jst', 'uglify', 'less', 'copy:backboneapp']);
  grunt.registerTask('lint', ['jshint']);
};
<|endoftext|>


<commit_before>/*jshint unused:true */
'use strict';

var path = require('path');
var spawn = require('child_process').spawn;

var $ = require('gulp-load-plugins')();
var browserify = require('browserify');
var gulp = require('gulp');
var mergeStream = require('merge-stream');
var rimraf = require('rimraf');
var source = require('vinyl-source-stream');
var stylish = require('jshint-stylish');
var tapSpec = require('tap-spec');

var pkg = require('./package.json');
var bower = require('./bower.json');
var banner = require('tiny-npm-license')(pkg);

gulp.task('lint', function() {
  gulp.src('{,test/}*.js')
    .pipe($.jscs('package.json'))
    .pipe($.jshint())
    .pipe($.jshint.reporter(stylish));
  gulp.src('*.json')
    .pipe($.jsonlint())
    .pipe($.jsonlint.reporter());
});

gulp.task('clean', rimraf.bind(null, 'dist'));

gulp.task('build', ['lint', 'clean'], function() {
  return mergeStream(
    gulp.src('index.js')
      .pipe($.replace(/^.+?require.+?\n\n/mg, ''))
      .pipe($.replace(banner + '\n', ''))
      .pipe($.replace(/isVarName/g, 'window.$&'))
      .pipe($.replace('module.exports', 'window.gaTrackerSnippet'))
      .pipe($.wrap(banner + '!function() {\n<%= contents %>\n}();\n'))
      .pipe($.rename(bower.main))
      .pipe(gulp.dest('')),
    browserify({
      entries: ['./index.js'],
      standalone: 'gaTrackerSnippet'
    })
      .bundle()
      .pipe(source(pkg.name))
      .pipe($.rename({suffix: '-standalone', extname: '.js'}))
      .pipe(gulp.dest(path.dirname(bower.main)))
  );
});

gulp.task('test', ['build'], function(cb) {
  var cp = spawn('node', ['node_modules/.bin/tape', 'test-*.js'], {
    stdio: [null, null, process.stderr]
  });
  cp.stdout.pipe(tapSpec()).pipe(process.stdout);
  cp.on('close', function(code) {
    cb(code ? new Error('Exited with code ' + code) : null);
  });
});

gulp.task('watch', function() {
  gulp.watch(['{,src/}*.js'], ['test']);
  gulp.watch(['*.json', '.jshintrc'], ['lint']);
});

gulp.task('default', ['test', 'watch']);
<commit_msg>tweak gulpfile<commit_after>/*jshint unused:true */
'use strict';

var pkg = require('./package.json');

var path = require('path');
var spawn = require('child_process').spawn;

var $ = require('gulp-load-plugins')({config: pkg});
var browserify = require('browserify');
var gulp = require('gulp');
var mergeStream = require('merge-stream');
var rimraf = require('rimraf');
var source = require('vinyl-source-stream');
var stylish = require('jshint-stylish');
var tapSpec = require('tap-spec');

var bower = require('./bower.json');
var banner = require('tiny-npm-license')(pkg);

gulp.task('lint', function() {
  return mergeStream(
    gulp.src('{,test/}*.js')
      .pipe($.jscs(pkg.jscsConfig))
      .pipe($.jshint())
      .pipe($.jshint.reporter(stylish)),
    gulp.src('*.json')
      .pipe($.jsonlint())
      .pipe($.jsonlint.reporter())
  );
});

gulp.task('clean', rimraf.bind(null, 'dist'));

gulp.task('build', ['lint', 'clean'], function() {
  return mergeStream(
    gulp.src('index.js')
      .pipe($.replace(/^.+?require.+?\n\n/mg, ''))
      .pipe($.replace(banner + '\n', ''))
      .pipe($.replace(/isVarName/g, 'window.$&'))
      .pipe($.replace('module.exports', 'window.gaTrackerSnippet'))
      .pipe($.replace(/[\s\S]*/, banner + '!function() {\n$&\n}();\n'))
      .pipe($.rename(bower.main))
      .pipe(gulp.dest('')),
    browserify({
      entries: ['./index.js'],
      standalone: 'gaTrackerSnippet'
    })
      .bundle()
      .pipe(source(pkg.name))
      .pipe($.rename({suffix: '-standalone', extname: '.js'}))
      .pipe(gulp.dest(path.dirname(bower.main)))
  );
});

gulp.task('test', ['build'], function(cb) {
  var cp = spawn('node', ['node_modules/.bin/tape', 'test-*.js'], {
    stdio: [null, null, process.stderr]
  });
  cp.stdout.pipe(tapSpec()).pipe(process.stdout);
  cp.on('close', function(code) {
    cb(code ? new Error('Exited with code ' + code) : null);
  });
});

gulp.task('watch', function() {
  gulp.watch(['{,src/}*.js'], ['test']);
  gulp.watch(['*.json', '.jshintrc'], ['lint']);
});

gulp.task('default', ['test', 'watch']);
<|endoftext|>