Added node-modules

This commit is contained in:
Dobie Wollert
2014-09-14 07:04:16 -04:00
parent 663941bf57
commit 6a92348cf5
4870 changed files with 670395 additions and 0 deletions

47
node_modules/moment/tasks/concat-lang.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
/*jshint onevar:false*/
module.exports = function (grunt) {
var helpers = require('grunt-lib-legacyhelpers').init(grunt);
var START = "(function(){\n";
var END = "})();\n";
var GLOBAL_START = [
"(function(){",
" function onload (moment) {",
""
].join('\n');
var GLOBAL_RESET = "\nmoment.lang('en');\n";
var GLOBAL_END = [
"",
" }",
" if (typeof define === \"function\" && define.amd) {",
" define([\"moment\"], onload);",
" }",
" if (typeof window !== \"undefined\" && window.moment) {",
" onload(window.moment);",
" }",
"})();",
""
].join('\n');
grunt.registerMultiTask('concatlang', 'Concatenate files.', function() {
var files = grunt.file.expand(this.data.src);
// Concat specified files.
var src = helpers.concat(files, {separator: END + START});
grunt.file.write(this.data.dest, wrapFile(src));
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message.
grunt.log.writeln('File "' + this.data.dest + '" created.');
});
function wrapFile(code) {
code = code.replace(/require\([\'\"]\.\.\/moment[\'\"]\)/g, "moment");
return GLOBAL_START + START + code + END + GLOBAL_RESET + GLOBAL_END;
}
};

123
node_modules/moment/tasks/history.js generated vendored Normal file
View File

@ -0,0 +1,123 @@
var https = require("https"),
zlib = require('zlib'),
path = require('path'),
fs = require('fs');
var count = 0;
var resolved = 0;
var outputs = [];
var done;
function check() {
if (resolved === count) {
normalize();
display();
}
}
function makeBar(length) {
var i = '';
while (i.length < length) {
i += '=';
}
return i;
}
function normalize() {
var i,
max = 0,
max2 = 0;
for (i = 0; i < count; i ++) {
max = Math.max(max, outputs[i].gzip);
max2 = Math.max(max2, outputs[i].original);
}
for (i = 0; i < count; i ++) {
outputs[i].bargraph = makeBar((outputs[i].gzip / max) * 80);
outputs[i].bargraph2 = makeBar((outputs[i].original / max2) * 80);
}
}
function display() {
var i;
for (i = 0; i < count; i ++) {
console.log(outputs[i].version + ' ' + outputs[i].gzip + ' ' + outputs[i].original);
console.log('gzip ' + outputs[i].bargraph);
console.log('orig ' + outputs[i].bargraph2);
}
done();
}
function getSizeAtVersion(version, path) {
var data = '',
op = {},
req = https.request({
host: 'raw.github.com',
port: 443,
path: '/timrwood/moment/' + version + path
}, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function (e) {
zlib.gzip(data, function (error, result) {
op.version = version;
op.gzip = result.length;
op.original = data.length;
resolved ++;
check();
});
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
count++;
outputs.push(op);
}
function getRemote() {
var old_versions = '1.0.1 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.4.0'.split(' '),
new_versions = '1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.7.1'.split(' '),
i;
for (i = 0; i < old_versions.length; i++) {
getSizeAtVersion(old_versions[i], '/moment.min.js');
}
for (i = 0; i < new_versions.length; i++) {
getSizeAtVersion(new_versions[i], '/min/moment.min.js');
}
}
function getLocal() {
count ++;
var op = {};
outputs.push(op);
fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
if (err) {
throw err;
}
zlib.gzip(data, function (error, result) {
op.version = '.next';
op.gzip = result.length;
op.original = data.length;
resolved ++;
check();
});
});
}
module.exports = function (grunt) {
grunt.registerTask('history', 'Check the codebase filesize over different releases.', function () {
done = this.async();
getRemote();
getLocal();
});
};

82
node_modules/moment/tasks/minify-lang.js generated vendored Normal file
View File

@ -0,0 +1,82 @@
/*jshint onevar:false*/
var fs = require('fs'),
uglifyjs = require('uglify-js');
module.exports = function (grunt) {
var helpers = require('grunt-lib-legacyhelpers').init(grunt);
var START = [
"(function(){",
" function onload (moment) {",
""
].join('\n');
var END = [
"",
" }",
" if (typeof define === \"function\" && define.amd) {",
" define([\"moment\"], onload);",
" }",
" if (typeof window !== \"undefined\" && window.moment) {",
" onload(window.moment);",
" }",
"})()",
""
].join('\n');
// UglifyJS does not support keeping the first line comments unless using the CLI.
// This multi-task ensures that the first comments are kept.
grunt.registerMultiTask('minlang', 'Minify lang files with UglifyJS.', function () {
var files = grunt.file.expand(this.data.src),
min,
code,
comments,
tok,
result;
// Concat specified files. This should really be a single, pre-built (and
// linted) file, but it supports any number of files.
code = helpers.concat(files, {separator: this.data.separator});
// Add the first comments
//tok = uglifyjs.parse(code);
tok = uglifyjs.parse(code);
min = showCopyright(tok.start.comments_before);
// Add the minified source.
result = uglifyjs.minify(wrapFile(code), grunt.config('uglify.options'));
min += result.code;
grunt.file.write(this.data.dest, min);
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message....
grunt.log.writeln('File "' + this.data.dest + '" created.');
// ...and report some size information.
helpers.min_max_info(min, code);
});
// Helper for the 'mincomment' multitask
function showCopyright(comments) {
var ret = "", i, c;
for (i = 0; i < comments.length; ++i) {
c = comments[i];
if (c.type === "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
}
function wrapFile(code) {
code = code.replace(/require\([\'\"]\.\.\/moment[\'\"]\)/g, "moment");
return START + code + END;
}
};

57
node_modules/moment/tasks/minify.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
/*jshint onevar:false*/
var fs = require('fs'),
uglifyjs = require('uglify-js');
module.exports = function (grunt) {
var helpers = require('grunt-lib-legacyhelpers').init(grunt);
// UglifyJS does not support keeping the first line comments unless using the CLI.
// This multi-task ensures that the first comments are kept.
grunt.registerMultiTask('minwithcomments', 'Minify lang files with UglifyJS.', function () {
var files = grunt.file.expand(this.data.src),
min,
code,
comments,
tok,
result;
// Concat specified files. This should really be a single, pre-built (and
// linted) file, but it supports any number of files.
code = helpers.concat(files, {separator: this.data.separator});
// Add the first comments
tok = uglifyjs.parse(code);
min = showCopyright(tok.start.comments_before);
// Add the minified source.
result = uglifyjs.minify(code, grunt.config('uglify.options'));
min += result.code;
grunt.file.write(this.data.dest, min);
// Fail task if errors were logged.
if (this.errorCount) { return false; }
// Otherwise, print a success message....
grunt.log.writeln('File "' + this.data.dest + '" created.');
// ...and report some size information.
helpers.min_max_info(min, code);
});
// Helper for the 'mincomment' multitask
function showCopyright(comments) {
var ret = "", i, c;
for (i = 0; i < comments.length; ++i) {
c = comments[i];
if (c.type === "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
}
};

60
node_modules/moment/tasks/size.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
var https = require("https"),
zlib = require('zlib'),
path = require('path'),
fs = require('fs');
var stable = '1.7.1',
done;
function getVersion(path, cb) {
var data = '',
req = https.request({
host: 'raw.github.com',
port: 443,
path: '/timrwood/moment/' + path
}, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function (e) {
zlib.gzip(data, function (error, result) {
cb(data.length, result.length);
});
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
req.end();
}
function printDiffs(stableLen, stableGzip, currentLen, currentGzip) {
var diff = currentLen - stableLen,
gzipDiff = currentGzip - stableGzip;
console.log("Filesize difference from current branch to " + stable);
console.log(stable + " " + stableLen + ' / ' + stableGzip);
console.log("curr " + currentLen + ' / ' + currentGzip);
console.log("diff " + (diff > 0 ? '+' : '') + diff);
console.log("gzip " + (gzipDiff > 0 ? '+' : '') + gzipDiff);
}
module.exports = function (grunt) {
grunt.registerTask('size', 'Check the codebase filesize against the latest stable version.', function () {
done = this.async();
fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
if (err) {
throw err;
}
zlib.gzip(data, function (error, result) {
getVersion(stable + '/min/moment.min.js', function (stableLength, stableGzipLength) {
printDiffs(stableLength, stableGzipLength, data.length, result.length);
done();
});
});
});
});
};

123
node_modules/moment/tasks/zone.js generated vendored Normal file
View File

@ -0,0 +1,123 @@
var path = require('path'),
nodeunit = require('nodeunit'),
moment = require('../moment');
module.exports = function (grunt) {
// placeholder for an array of timezones
var ALL_ZONES,
INITIAL_ZONE,
failedZones = [],
failedTests = [],
logTableWidths = [4, 6, 46, 12, 12],
failedZoneCount = 0,
passedZoneCount = 0;
/******************************
Grunt task
******************************/
grunt.registerTask('zone', 'Run the unit tests in the current timezone.', function () {
var done = this.async();
getCurrentTimezone(function (zone) {
testZone(zone, function() {
logFinalOutput();
done();
});
});
});
/******************************
Timezones
******************************/
function getCurrentTimezone(cb) {
grunt.util.spawn({
cmd: "systemsetup",
args: ["gettimezone"]
}, function (err, result, code) {
cb(result.stdout.replace('Time Zone: ', ''));
});
}
/******************************
Tests
******************************/
function testZone(zone, cb) {
nodeunit.runFiles([path.join(process.cwd(), "test/moment"), path.join(process.cwd(), "test/lang")], {
testDone: function (name, assertions) {
if (assertions.failures()) {
failedTests.push([zone, name, assertions]);
}
},
done: function (assertions) {
logZone(zone, assertions);
cb();
}
});
}
/******************************
Logging
******************************/
function setupLoggingTable() {
var i,
longestZone = 0;
for (i = 0; i < ALL_ZONES.length; i++) {
longestZone = Math.max(longestZone, ALL_ZONES[i].length + 2);
}
logTableWidths[1] = longestZone;
grunt.log.writetableln(logTableWidths, ['', 'Zone', 'Offset', 'Pass', 'Fail']);
}
function logFailedTest(zone, name, assertions) {
grunt.log.writeln("");
grunt.log.error(zone + ' failed: ' + name);
assertions.forEach(function (a) {
var e = a.error;
if (a.failed()) {
if (a.message) {
grunt.log.error(a.message);
}
if (e && e.actual && e.expected && e.operator) {
grunt.log.error([e.actual, e.operator, e.expected].join(' '));
}
}
});
}
function logZone(zone, assertions) {
var failed = assertions.failures(),
passed = assertions.length - failed,
status = failed ? "XX".red : "OK".green,
passMsg = passed + ' passed',
failMsg = failed ? (failed + ' failed').red : failed + ' failed',
offset = "" + (-moment().zone() / 60);
grunt.log.writetableln(logTableWidths, [status, offset, zone, passMsg, failMsg]);
if (failed) {
failedZoneCount++;
} else {
passedZoneCount++;
}
}
function logFinalOutput() {
var i;
if (!failedZoneCount) {
return;
}
grunt.log.writeln(failedZoneCount + " failures");
for (i = 0; i < failedTests.length; i++) {
logFailedTest.apply(null, failedTests[i]);
}
}
};

104
node_modules/moment/tasks/zones.js generated vendored Normal file
View File

@ -0,0 +1,104 @@
var path = require('path'),
nodeunit = require('nodeunit'),
moment = require('../moment');
module.exports = function (grunt) {
// placeholder for an array of timezones
var ALL_ZONES,
INITIAL_ZONE,
done;
/******************************
Grunt task
******************************/
grunt.registerTask('zones', 'Run the unit tests in different timezones.', function () {
done = this.async();
getCurrentTimezone(function (zone) {
// save the initial timezone so we dont break our computers
INITIAL_ZONE = zone;
getAllTimezones(function (zones) {
// store all the timezones
ALL_ZONES = zones;
// start running the tests
nextTest(function () {
// reset the timezone like nothing ever happened
resetTimezone();
});
});
});
});
/******************************
Timezones
******************************/
function resetTimezone() {
setTimezone(INITIAL_ZONE, function () {
grunt.log.writeln("Resetting timezone back to " + INITIAL_ZONE);
done();
});
}
function getCurrentTimezone(cb) {
grunt.util.spawn({
cmd: "systemsetup",
args: ["gettimezone"]
}, function (err, result, code) {
cb(result.stdout.replace('Time Zone: ', ''));
});
}
function getAllTimezones(cb) {
grunt.util.spawn({
cmd: "systemsetup",
args: ["listtimezones"]
}, function (err, result, code) {
var zones = result.stdout.replace('Time Zones:', '');
zones = zones.match(/\S+/g);
cb(zones);
});
}
function setTimezone(zone, cb) {
grunt.util.spawn({
cmd: "systemsetup",
args: ["settimezone", zone]
}, function (err, result, code) {
cb();
});
}
/******************************
Tests
******************************/
function nextTest(cb) {
var zone = ALL_ZONES.pop();
if (zone) {
setTimezone(zone, function () {
testZone(zone, function () {
nextTest(cb);
});
});
} else {
cb();
}
}
function testZone(zone, cb) {
grunt.util.spawn({
cmd: "grunt",
args: ["zone"]
}, function (err, result, code) {
if (err) {
resetTimezone();
throw err;
}
console.log(result.stdout);
cb();
});
}
};