Merge Aether tools
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sh eol=lf
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,7 +14,7 @@ project/winrt/shaders/
|
||||
*.swp
|
||||
.idea/
|
||||
*.iml
|
||||
tools/run.n
|
||||
tools/tools.n
|
||||
haxedoc.xml
|
||||
documentation/*.xml
|
||||
documentation/pages*
|
||||
|
||||
@@ -17,8 +17,6 @@ install:
|
||||
- haxelib setup ~/haxelib
|
||||
- haxelib install hxcpp
|
||||
- haxelib install format
|
||||
- git clone https://github.com/openfl/aether ~/aether --depth 1
|
||||
- haxelib dev aether ~/aether
|
||||
- haxelib dev lime $(pwd)
|
||||
|
||||
script:
|
||||
|
||||
@@ -42,11 +42,6 @@ Next, until the new version of Lime is released, you can download the current [d
|
||||
|
||||
haxelib local filename.zip
|
||||
|
||||
You will also want to install Aether:
|
||||
|
||||
haxelib install aether
|
||||
haxelib run aether setup
|
||||
|
||||
|
||||
Building from Source
|
||||
====================
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
<architecture name="armv7" if="android" />
|
||||
|
||||
<include haxelib="aether" unless="openfl" />
|
||||
<haxelib name="aether" if="setup" />
|
||||
<!-- <include haxelib="aether" unless="openfl" />
|
||||
<haxelib name="aether" if="setup" /> -->
|
||||
|
||||
<target name="wiiu" handler="lime-wiiu" />
|
||||
<haxelib name="lime-wiiu" if="wiiu" />
|
||||
|
||||
@@ -78,7 +78,7 @@ class Application extends Module {
|
||||
/**
|
||||
* Initializes the Application, using the settings defined in
|
||||
* the config instance. By default, this is called automatically
|
||||
* when building the project using Aether
|
||||
* when building the project using Lime's command-line tools
|
||||
* @param config A Config object
|
||||
*/
|
||||
public function create (config:Config):Void {
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package;
|
||||
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.Path;
|
||||
import sys.FileSystem;
|
||||
|
||||
|
||||
class RunScript {
|
||||
|
||||
|
||||
public static function runCommand (path:String, command:String, args:Array<String>, throwErrors:Bool = true):Int {
|
||||
|
||||
var oldPath:String = "";
|
||||
|
||||
if (path != null && path != "") {
|
||||
|
||||
oldPath = Sys.getCwd ();
|
||||
|
||||
try {
|
||||
|
||||
Sys.setCwd (path);
|
||||
|
||||
} catch (e:Dynamic) {
|
||||
|
||||
//Sys.stderr ().write (Bytes.ofString ("Cannot set current working directory to \"" + path + "\""));
|
||||
//Sys.exit (1);
|
||||
//error ("Cannot set current working directory to \"" + path + "\"");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var result:Dynamic = Sys.command (command, args);
|
||||
|
||||
if (oldPath != "") {
|
||||
|
||||
Sys.setCwd (oldPath);
|
||||
|
||||
}
|
||||
|
||||
if (throwErrors && result != 0) {
|
||||
|
||||
Sys.exit (1);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function main () {
|
||||
|
||||
var args = Sys.args ();
|
||||
var command = args[0];
|
||||
|
||||
if (command == "rebuild") {
|
||||
|
||||
// When the command-line tools are called from haxelib,
|
||||
// the last argument is the project directory and the
|
||||
// path to Lime is the current working directory
|
||||
|
||||
var ignoreLength = 0;
|
||||
var lastArgument = new Path (args[args.length - 1]).toString ();
|
||||
|
||||
if (((StringTools.endsWith (lastArgument, "/") && lastArgument != "/") || StringTools.endsWith (lastArgument, "\\")) && !StringTools.endsWith (lastArgument, ":\\")) {
|
||||
|
||||
lastArgument = lastArgument.substr (0, lastArgument.length - 1);
|
||||
|
||||
}
|
||||
|
||||
if (FileSystem.exists (lastArgument) && FileSystem.isDirectory (lastArgument)) {
|
||||
|
||||
Sys.setCwd (lastArgument);
|
||||
//args.pop ();
|
||||
ignoreLength++;
|
||||
|
||||
}
|
||||
|
||||
for (arg in args) {
|
||||
|
||||
if (StringTools.startsWith (arg, "-D")) {
|
||||
|
||||
ignoreLength++;
|
||||
|
||||
} else if (StringTools.startsWith (arg, "--") && arg.indexOf ("=") > -1) {
|
||||
|
||||
ignoreLength++;
|
||||
|
||||
} else if (StringTools.startsWith (arg, "-")) {
|
||||
|
||||
ignoreLength++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 2 + ignoreLength) {
|
||||
|
||||
args.insert (1, "lime");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var workingDirectory = args.pop ();
|
||||
var args = [ "run", "aether" ].concat (args);
|
||||
|
||||
Sys.exit (runCommand (workingDirectory, "haxelib", args));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
BIN
templates/bin/ReplaceVistaIcon.exe
Normal file
BIN
templates/bin/ReplaceVistaIcon.exe
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik-rasterizer.jar
Normal file
BIN
templates/bin/batik/batik-rasterizer.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik-slideshow.jar
Normal file
BIN
templates/bin/batik/batik-slideshow.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik-squiggle.jar
Normal file
BIN
templates/bin/batik/batik-squiggle.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik-svgpp.jar
Normal file
BIN
templates/bin/batik/batik-svgpp.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik-ttf2svg.jar
Normal file
BIN
templates/bin/batik/batik-ttf2svg.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/batik.jar
Normal file
BIN
templates/bin/batik/batik.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-anim.jar
Normal file
BIN
templates/bin/batik/lib/batik-anim.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-awt-util.jar
Normal file
BIN
templates/bin/batik/lib/batik-awt-util.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-bridge.jar
Normal file
BIN
templates/bin/batik/lib/batik-bridge.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-codec.jar
Normal file
BIN
templates/bin/batik/lib/batik-codec.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-css.jar
Normal file
BIN
templates/bin/batik/lib/batik-css.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-dom.jar
Normal file
BIN
templates/bin/batik/lib/batik-dom.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-ext.jar
Normal file
BIN
templates/bin/batik/lib/batik-ext.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-extension.jar
Normal file
BIN
templates/bin/batik/lib/batik-extension.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-gui-util.jar
Normal file
BIN
templates/bin/batik/lib/batik-gui-util.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-gvt.jar
Normal file
BIN
templates/bin/batik/lib/batik-gvt.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-parser.jar
Normal file
BIN
templates/bin/batik/lib/batik-parser.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-script.jar
Normal file
BIN
templates/bin/batik/lib/batik-script.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-svg-dom.jar
Normal file
BIN
templates/bin/batik/lib/batik-svg-dom.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-svggen.jar
Normal file
BIN
templates/bin/batik/lib/batik-svggen.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-swing.jar
Normal file
BIN
templates/bin/batik/lib/batik-swing.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-transcoder.jar
Normal file
BIN
templates/bin/batik/lib/batik-transcoder.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-util.jar
Normal file
BIN
templates/bin/batik/lib/batik-util.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/batik-xml.jar
Normal file
BIN
templates/bin/batik/lib/batik-xml.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/js.jar
Normal file
BIN
templates/bin/batik/lib/js.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/pdf-transcoder.jar
Normal file
BIN
templates/bin/batik/lib/pdf-transcoder.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/xalan-2.6.0.jar
Normal file
BIN
templates/bin/batik/lib/xalan-2.6.0.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/xerces_2_5_0.jar
Normal file
BIN
templates/bin/batik/lib/xerces_2_5_0.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/xml-apis-ext.jar
Normal file
BIN
templates/bin/batik/lib/xml-apis-ext.jar
Normal file
Binary file not shown.
BIN
templates/bin/batik/lib/xml-apis.jar
Normal file
BIN
templates/bin/batik/lib/xml-apis.jar
Normal file
Binary file not shown.
BIN
templates/bin/compiler.jar
Normal file
BIN
templates/bin/compiler.jar
Normal file
Binary file not shown.
BIN
templates/bin/debug.keystore
Normal file
BIN
templates/bin/debug.keystore
Normal file
Binary file not shown.
BIN
templates/bin/debug.p12
Normal file
BIN
templates/bin/debug.p12
Normal file
Binary file not shown.
BIN
templates/bin/fruitstrap
Executable file
BIN
templates/bin/fruitstrap
Executable file
Binary file not shown.
BIN
templates/bin/hxswfml.n
Normal file
BIN
templates/bin/hxswfml.n
Normal file
Binary file not shown.
BIN
templates/bin/ios-deploy
Executable file
BIN
templates/bin/ios-deploy
Executable file
Binary file not shown.
BIN
templates/bin/ios-sim
Executable file
BIN
templates/bin/ios-sim
Executable file
Binary file not shown.
2
templates/bin/lime.bat
Normal file
2
templates/bin/lime.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
haxelib run lime %*
|
||||
2
templates/bin/lime.sh
Normal file
2
templates/bin/lime.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
haxelib run lime "$@"
|
||||
20
templates/bin/node/http-server/LICENSE
Executable file
20
templates/bin/node/http-server/LICENSE
Executable file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2011 Nodejitsu http://github.com/nodejitsu/http-server/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
86
templates/bin/node/http-server/http-server
Executable file
86
templates/bin/node/http-server/http-server
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var colors = require('colors'),
|
||||
httpServer = require('./http-server.js'),
|
||||
argv = require('optimist').argv,
|
||||
portfinder = require('portfinder'),
|
||||
opener = require('opener');
|
||||
|
||||
if (argv.h || argv.help) {
|
||||
console.log([
|
||||
"usage: http-server [path] [options]",
|
||||
"",
|
||||
"options:",
|
||||
" -p Port to use [8080]",
|
||||
" -a Address to use [0.0.0.0]",
|
||||
" -d Show directory listings [true]",
|
||||
" -i Display autoIndex [true]",
|
||||
" -e --ext Default file extension if none supplied [none]",
|
||||
" -s --silent Suppress log messages from output",
|
||||
" --cors Enable CORS via the 'Access-Control-Allow-Origin' header",
|
||||
" -o Open browser window after staring the server",
|
||||
" -c Set cache time (in seconds). e.g. -c10 for 10 seconds.",
|
||||
" To disable caching, use -c-1.",
|
||||
" -h --help Print this list and exit."
|
||||
].join('\n'));
|
||||
process.exit();
|
||||
}
|
||||
|
||||
var port = argv.p || parseInt(process.env.PORT, 10),
|
||||
host = argv.a || '0.0.0.0',
|
||||
log = (argv.s || argv.silent) ? (function () {}) : console.log,
|
||||
requestLogger;
|
||||
|
||||
if (!argv.s && !argv.silent) {
|
||||
requestLogger = function(req) {
|
||||
log('[%s] "%s %s" "%s"', (new Date).toUTCString(), req.method.cyan, req.url.cyan, req.headers['user-agent']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!port) {
|
||||
portfinder.basePort = 8080;
|
||||
portfinder.getPort(function (err, port) {
|
||||
if (err) throw err;
|
||||
listen(port);
|
||||
});
|
||||
} else {
|
||||
listen(port);
|
||||
}
|
||||
|
||||
function listen(port) {
|
||||
var options = {
|
||||
root: argv._[0],
|
||||
cache: argv.c,
|
||||
showDir: argv.d,
|
||||
autoIndex: argv.i,
|
||||
ext: argv.e || argv.ext,
|
||||
logFn: requestLogger
|
||||
};
|
||||
|
||||
if (argv.cors) {
|
||||
options.headers = { 'Access-Control-Allow-Origin': '*' };
|
||||
}
|
||||
|
||||
var server = httpServer.createServer(options);
|
||||
server.listen(port, host, function() {
|
||||
log('Starting up http-server, serving '.yellow
|
||||
+ server.root.cyan
|
||||
+ ' on port: '.yellow
|
||||
+ port.toString().cyan);
|
||||
log('Hit CTRL-C to stop the server');
|
||||
|
||||
if (argv.o) {
|
||||
opener('http://127.0.0.1:' + port.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
//
|
||||
// Signal handlers don't work on Windows.
|
||||
//
|
||||
process.on('SIGINT', function () {
|
||||
log('http-server stopped.'.red);
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
64
templates/bin/node/http-server/http-server.js
Executable file
64
templates/bin/node/http-server/http-server.js
Executable file
@@ -0,0 +1,64 @@
|
||||
var fs = require('fs'),
|
||||
util = require('util'),
|
||||
union = require('union'),
|
||||
ecstatic = require('ecstatic');
|
||||
|
||||
var HTTPServer = exports.HTTPServer = function (options) {
|
||||
options = options || {};
|
||||
|
||||
if (options.root) {
|
||||
this.root = options.root;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
fs.lstatSync('./public');
|
||||
this.root = './public';
|
||||
}
|
||||
catch (err) {
|
||||
this.root = './';
|
||||
}
|
||||
}
|
||||
|
||||
if (options.headers) {
|
||||
this.headers = options.headers;
|
||||
}
|
||||
|
||||
this.cache = options.cache || 3600; // in seconds.
|
||||
this.showDir = options.showDir !== 'false';
|
||||
this.autoIndex = options.autoIndex !== 'false';
|
||||
|
||||
if (options.ext) {
|
||||
this.ext = options.ext === true
|
||||
? 'html'
|
||||
: options.ext;
|
||||
}
|
||||
|
||||
this.server = union.createServer({
|
||||
before: (options.before || []).concat([
|
||||
function (req, res) {
|
||||
options.logFn && options.logFn(req, res);
|
||||
res.emit('next');
|
||||
},
|
||||
ecstatic({
|
||||
root: this.root,
|
||||
cache: this.cache,
|
||||
showDir : this.showDir,
|
||||
autoIndex: this.autoIndex,
|
||||
defaultExt: this.ext
|
||||
})
|
||||
]),
|
||||
headers: this.headers || {}
|
||||
});
|
||||
};
|
||||
|
||||
HTTPServer.prototype.listen = function () {
|
||||
this.server.listen.apply(this.server, arguments);
|
||||
};
|
||||
|
||||
HTTPServer.prototype.close = function () {
|
||||
return this.server.close();
|
||||
};
|
||||
|
||||
exports.createServer = function (options) {
|
||||
return new HTTPServer(options);
|
||||
};
|
||||
1
templates/bin/node/http-server/node_modules/.bin/ecstatic
generated
vendored
Symbolic link
1
templates/bin/node/http-server/node_modules/.bin/ecstatic
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../ecstatic/lib/ecstatic.js
|
||||
1
templates/bin/node/http-server/node_modules/.bin/opener
generated
vendored
Symbolic link
1
templates/bin/node/http-server/node_modules/.bin/opener
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../opener/opener.js
|
||||
22
templates/bin/node/http-server/node_modules/colors/MIT-LICENSE.txt
generated
vendored
Normal file
22
templates/bin/node/http-server/node_modules/colors/MIT-LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2010
|
||||
|
||||
Marak Squires
|
||||
Alexis Sellier (cloudhead)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
342
templates/bin/node/http-server/node_modules/colors/colors.js
generated
vendored
Normal file
342
templates/bin/node/http-server/node_modules/colors/colors.js
generated
vendored
Normal file
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
colors.js
|
||||
|
||||
Copyright (c) 2010
|
||||
|
||||
Marak Squires
|
||||
Alexis Sellier (cloudhead)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
var isHeadless = false;
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
isHeadless = true;
|
||||
}
|
||||
|
||||
if (!isHeadless) {
|
||||
var exports = {};
|
||||
var module = {};
|
||||
var colors = exports;
|
||||
exports.mode = "browser";
|
||||
} else {
|
||||
exports.mode = "console";
|
||||
}
|
||||
|
||||
//
|
||||
// Prototypes the string object to have additional method calls that add terminal colors
|
||||
//
|
||||
var addProperty = function (color, func) {
|
||||
exports[color] = function (str) {
|
||||
return func.apply(str);
|
||||
};
|
||||
String.prototype.__defineGetter__(color, func);
|
||||
};
|
||||
|
||||
function stylize(str, style) {
|
||||
|
||||
var styles;
|
||||
|
||||
if (exports.mode === 'console') {
|
||||
styles = {
|
||||
//styles
|
||||
'bold' : ['\x1B[1m', '\x1B[22m'],
|
||||
'italic' : ['\x1B[3m', '\x1B[23m'],
|
||||
'underline' : ['\x1B[4m', '\x1B[24m'],
|
||||
'inverse' : ['\x1B[7m', '\x1B[27m'],
|
||||
'strikethrough' : ['\x1B[9m', '\x1B[29m'],
|
||||
//text colors
|
||||
//grayscale
|
||||
'white' : ['\x1B[37m', '\x1B[39m'],
|
||||
'grey' : ['\x1B[90m', '\x1B[39m'],
|
||||
'black' : ['\x1B[30m', '\x1B[39m'],
|
||||
//colors
|
||||
'blue' : ['\x1B[34m', '\x1B[39m'],
|
||||
'cyan' : ['\x1B[36m', '\x1B[39m'],
|
||||
'green' : ['\x1B[32m', '\x1B[39m'],
|
||||
'magenta' : ['\x1B[35m', '\x1B[39m'],
|
||||
'red' : ['\x1B[31m', '\x1B[39m'],
|
||||
'yellow' : ['\x1B[33m', '\x1B[39m'],
|
||||
//background colors
|
||||
//grayscale
|
||||
'whiteBG' : ['\x1B[47m', '\x1B[49m'],
|
||||
'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
|
||||
'blackBG' : ['\x1B[40m', '\x1B[49m'],
|
||||
//colors
|
||||
'blueBG' : ['\x1B[44m', '\x1B[49m'],
|
||||
'cyanBG' : ['\x1B[46m', '\x1B[49m'],
|
||||
'greenBG' : ['\x1B[42m', '\x1B[49m'],
|
||||
'magentaBG' : ['\x1B[45m', '\x1B[49m'],
|
||||
'redBG' : ['\x1B[41m', '\x1B[49m'],
|
||||
'yellowBG' : ['\x1B[43m', '\x1B[49m']
|
||||
};
|
||||
} else if (exports.mode === 'browser') {
|
||||
styles = {
|
||||
//styles
|
||||
'bold' : ['<b>', '</b>'],
|
||||
'italic' : ['<i>', '</i>'],
|
||||
'underline' : ['<u>', '</u>'],
|
||||
'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
|
||||
'strikethrough' : ['<del>', '</del>'],
|
||||
//text colors
|
||||
//grayscale
|
||||
'white' : ['<span style="color:white;">', '</span>'],
|
||||
'grey' : ['<span style="color:gray;">', '</span>'],
|
||||
'black' : ['<span style="color:black;">', '</span>'],
|
||||
//colors
|
||||
'blue' : ['<span style="color:blue;">', '</span>'],
|
||||
'cyan' : ['<span style="color:cyan;">', '</span>'],
|
||||
'green' : ['<span style="color:green;">', '</span>'],
|
||||
'magenta' : ['<span style="color:magenta;">', '</span>'],
|
||||
'red' : ['<span style="color:red;">', '</span>'],
|
||||
'yellow' : ['<span style="color:yellow;">', '</span>'],
|
||||
//background colors
|
||||
//grayscale
|
||||
'whiteBG' : ['<span style="background-color:white;">', '</span>'],
|
||||
'greyBG' : ['<span style="background-color:gray;">', '</span>'],
|
||||
'blackBG' : ['<span style="background-color:black;">', '</span>'],
|
||||
//colors
|
||||
'blueBG' : ['<span style="background-color:blue;">', '</span>'],
|
||||
'cyanBG' : ['<span style="background-color:cyan;">', '</span>'],
|
||||
'greenBG' : ['<span style="background-color:green;">', '</span>'],
|
||||
'magentaBG' : ['<span style="background-color:magenta;">', '</span>'],
|
||||
'redBG' : ['<span style="background-color:red;">', '</span>'],
|
||||
'yellowBG' : ['<span style="background-color:yellow;">', '</span>']
|
||||
};
|
||||
} else if (exports.mode === 'none') {
|
||||
return str + '';
|
||||
} else {
|
||||
console.log('unsupported mode, try "browser", "console" or "none"');
|
||||
}
|
||||
return styles[style][0] + str + styles[style][1];
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
|
||||
//
|
||||
// Remark: This is a list of methods that exist
|
||||
// on String that you should not overwrite.
|
||||
//
|
||||
var stringPrototypeBlacklist = [
|
||||
'__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
|
||||
'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
|
||||
'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
|
||||
'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
|
||||
];
|
||||
|
||||
Object.keys(theme).forEach(function (prop) {
|
||||
if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
|
||||
console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
|
||||
}
|
||||
else {
|
||||
if (typeof(theme[prop]) === 'string') {
|
||||
addProperty(prop, function () {
|
||||
return exports[theme[prop]](this);
|
||||
});
|
||||
}
|
||||
else {
|
||||
addProperty(prop, function () {
|
||||
var ret = this;
|
||||
for (var t = 0; t < theme[prop].length; t++) {
|
||||
ret = exports[theme[prop][t]](ret);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Iterate through all default styles and colors
|
||||
//
|
||||
var x = ['bold', 'underline', 'strikethrough', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta', 'greyBG', 'blackBG', 'yellowBG', 'redBG', 'greenBG', 'blueBG', 'whiteBG', 'cyanBG', 'magentaBG'];
|
||||
x.forEach(function (style) {
|
||||
|
||||
// __defineGetter__ at the least works in more browsers
|
||||
// http://robertnyman.com/javascript/javascript-getters-setters.html
|
||||
// Object.defineProperty only works in Chrome
|
||||
addProperty(style, function () {
|
||||
return stylize(this, style);
|
||||
});
|
||||
});
|
||||
|
||||
function sequencer(map) {
|
||||
return function () {
|
||||
if (!isHeadless) {
|
||||
return this.replace(/( )/, '$1');
|
||||
}
|
||||
var exploded = this.split(""), i = 0;
|
||||
exploded = exploded.map(map);
|
||||
return exploded.join("");
|
||||
};
|
||||
}
|
||||
|
||||
var rainbowMap = (function () {
|
||||
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
|
||||
return function (letter, i, exploded) {
|
||||
if (letter === " ") {
|
||||
return letter;
|
||||
} else {
|
||||
return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
exports.themes = {};
|
||||
|
||||
exports.addSequencer = function (name, map) {
|
||||
addProperty(name, sequencer(map));
|
||||
};
|
||||
|
||||
exports.addSequencer('rainbow', rainbowMap);
|
||||
exports.addSequencer('zebra', function (letter, i, exploded) {
|
||||
return i % 2 === 0 ? letter : letter.inverse;
|
||||
});
|
||||
|
||||
exports.setTheme = function (theme) {
|
||||
if (typeof theme === 'string') {
|
||||
try {
|
||||
exports.themes[theme] = require(theme);
|
||||
applyTheme(exports.themes[theme]);
|
||||
return exports.themes[theme];
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
applyTheme(theme);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
addProperty('stripColors', function () {
|
||||
return ("" + this).replace(/\x1B\[\d+m/g, '');
|
||||
});
|
||||
|
||||
// please no
|
||||
function zalgo(text, options) {
|
||||
var soul = {
|
||||
"up" : [
|
||||
'̍', '̎', '̄', '̅',
|
||||
'̿', '̑', '̆', '̐',
|
||||
'͒', '͗', '͑', '̇',
|
||||
'̈', '̊', '͂', '̓',
|
||||
'̈', '͊', '͋', '͌',
|
||||
'̃', '̂', '̌', '͐',
|
||||
'̀', '́', '̋', '̏',
|
||||
'̒', '̓', '̔', '̽',
|
||||
'̉', 'ͣ', 'ͤ', 'ͥ',
|
||||
'ͦ', 'ͧ', 'ͨ', 'ͩ',
|
||||
'ͪ', 'ͫ', 'ͬ', 'ͭ',
|
||||
'ͮ', 'ͯ', '̾', '͛',
|
||||
'͆', '̚'
|
||||
],
|
||||
"down" : [
|
||||
'̖', '̗', '̘', '̙',
|
||||
'̜', '̝', '̞', '̟',
|
||||
'̠', '̤', '̥', '̦',
|
||||
'̩', '̪', '̫', '̬',
|
||||
'̭', '̮', '̯', '̰',
|
||||
'̱', '̲', '̳', '̹',
|
||||
'̺', '̻', '̼', 'ͅ',
|
||||
'͇', '͈', '͉', '͍',
|
||||
'͎', '͓', '͔', '͕',
|
||||
'͖', '͙', '͚', '̣'
|
||||
],
|
||||
"mid" : [
|
||||
'̕', '̛', '̀', '́',
|
||||
'͘', '̡', '̢', '̧',
|
||||
'̨', '̴', '̵', '̶',
|
||||
'͜', '͝', '͞',
|
||||
'͟', '͠', '͢', '̸',
|
||||
'̷', '͡', ' ҉'
|
||||
]
|
||||
},
|
||||
all = [].concat(soul.up, soul.down, soul.mid),
|
||||
zalgo = {};
|
||||
|
||||
function randomNumber(range) {
|
||||
var r = Math.floor(Math.random() * range);
|
||||
return r;
|
||||
}
|
||||
|
||||
function is_char(character) {
|
||||
var bool = false;
|
||||
all.filter(function (i) {
|
||||
bool = (i === character);
|
||||
});
|
||||
return bool;
|
||||
}
|
||||
|
||||
function heComes(text, options) {
|
||||
var result = '', counts, l;
|
||||
options = options || {};
|
||||
options["up"] = options["up"] || true;
|
||||
options["mid"] = options["mid"] || true;
|
||||
options["down"] = options["down"] || true;
|
||||
options["size"] = options["size"] || "maxi";
|
||||
text = text.split('');
|
||||
for (l in text) {
|
||||
if (is_char(l)) {
|
||||
continue;
|
||||
}
|
||||
result = result + text[l];
|
||||
counts = {"up" : 0, "down" : 0, "mid" : 0};
|
||||
switch (options.size) {
|
||||
case 'mini':
|
||||
counts.up = randomNumber(8);
|
||||
counts.min = randomNumber(2);
|
||||
counts.down = randomNumber(8);
|
||||
break;
|
||||
case 'maxi':
|
||||
counts.up = randomNumber(16) + 3;
|
||||
counts.min = randomNumber(4) + 1;
|
||||
counts.down = randomNumber(64) + 3;
|
||||
break;
|
||||
default:
|
||||
counts.up = randomNumber(8) + 1;
|
||||
counts.mid = randomNumber(6) / 2;
|
||||
counts.down = randomNumber(8) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
var arr = ["up", "mid", "down"];
|
||||
for (var d in arr) {
|
||||
var index = arr[d];
|
||||
for (var i = 0 ; i <= counts[index]; i++) {
|
||||
if (options[index]) {
|
||||
result = result + soul[index][randomNumber(soul[index].length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return heComes(text);
|
||||
}
|
||||
|
||||
|
||||
// don't summon zalgo
|
||||
addProperty('zalgo', function () {
|
||||
return zalgo(this);
|
||||
});
|
||||
76
templates/bin/node/http-server/node_modules/colors/example.html
generated
vendored
Normal file
76
templates/bin/node/http-server/node_modules/colors/example.html
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>Colors Example</title>
|
||||
<script src="colors.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
var test = colors.red("hopefully colorless output");
|
||||
|
||||
document.write('Rainbows are fun!'.rainbow + '<br/>');
|
||||
document.write('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
||||
document.write('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||
//document.write('zalgo time!'.zalgo);
|
||||
document.write(test.stripColors);
|
||||
document.write("a".grey + " b".black);
|
||||
|
||||
document.write("Zebras are so fun!".zebra);
|
||||
|
||||
document.write(colors.rainbow('Rainbows are fun!'));
|
||||
document.write("This is " + "not".strikethrough + " fun.");
|
||||
|
||||
document.write(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
|
||||
document.write(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
|
||||
//document.write(colors.zalgo('zalgo time!'));
|
||||
document.write(colors.stripColors(test));
|
||||
document.write(colors.grey("a") + colors.black(" b"));
|
||||
|
||||
colors.addSequencer("america", function(letter, i, exploded) {
|
||||
if(letter === " ") return letter;
|
||||
switch(i%3) {
|
||||
case 0: return letter.red;
|
||||
case 1: return letter.white;
|
||||
case 2: return letter.blue;
|
||||
}
|
||||
});
|
||||
|
||||
colors.addSequencer("random", (function() {
|
||||
var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||
|
||||
return function(letter, i, exploded) {
|
||||
return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
|
||||
};
|
||||
})());
|
||||
|
||||
document.write("AMERICA! F--K YEAH!".america);
|
||||
document.write("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
document.write("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
document.write("this is a warning".warn);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
77
templates/bin/node/http-server/node_modules/colors/example.js
generated
vendored
Normal file
77
templates/bin/node/http-server/node_modules/colors/example.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
var colors = require('./colors');
|
||||
|
||||
//colors.mode = "browser";
|
||||
|
||||
var test = colors.red("hopefully colorless output");
|
||||
console.log('Rainbows are fun!'.rainbow);
|
||||
console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
|
||||
console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||
//console.log('zalgo time!'.zalgo);
|
||||
console.log(test.stripColors);
|
||||
console.log("a".grey + " b".black);
|
||||
console.log("Zebras are so fun!".zebra);
|
||||
console.log('background color attack!'.black.whiteBG)
|
||||
|
||||
//
|
||||
// Remark: .strikethrough may not work with Mac OS Terminal App
|
||||
//
|
||||
console.log("This is " + "not".strikethrough + " fun.");
|
||||
console.log(colors.rainbow('Rainbows are fun!'));
|
||||
console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
|
||||
console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
|
||||
//console.log(colors.zalgo('zalgo time!'));
|
||||
console.log(colors.stripColors(test));
|
||||
console.log(colors.grey("a") + colors.black(" b"));
|
||||
|
||||
colors.addSequencer("america", function(letter, i, exploded) {
|
||||
if(letter === " ") return letter;
|
||||
switch(i%3) {
|
||||
case 0: return letter.red;
|
||||
case 1: return letter.white;
|
||||
case 2: return letter.blue;
|
||||
}
|
||||
});
|
||||
|
||||
colors.addSequencer("random", (function() {
|
||||
var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||
|
||||
return function(letter, i, exploded) {
|
||||
return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
|
||||
};
|
||||
})());
|
||||
|
||||
console.log("AMERICA! F--K YEAH!".america);
|
||||
console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
|
||||
// Load theme with JSON literal
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log("this is a warning".warn);
|
||||
|
||||
// outputs grey text
|
||||
console.log("this is an input".input);
|
||||
|
||||
// Load a theme from file
|
||||
colors.setTheme('./themes/winston-dark.js');
|
||||
|
||||
console.log("this is an input".input);
|
||||
|
||||
31
templates/bin/node/http-server/node_modules/colors/package.json
generated
vendored
Normal file
31
templates/bin/node/http-server/node_modules/colors/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "colors",
|
||||
"description": "get colors in your node.js console like what",
|
||||
"version": "0.6.2",
|
||||
"author": {
|
||||
"name": "Marak Squires"
|
||||
},
|
||||
"homepage": "https://github.com/Marak/colors.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Marak/colors.js/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"terminal",
|
||||
"colors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/Marak/colors.js.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
},
|
||||
"main": "colors",
|
||||
"readme": "# colors.js - get color and style in your node.js console ( and browser ) like what\n\n<img src=\"http://i.imgur.com/goJdO.png\" border = \"0\"/>\n\n\n## Installation\n\n npm install colors\n\n## colors and styles!\n\n- bold\n- italic\n- underline\n- inverse\n- yellow\n- cyan\n- white\n- magenta\n- green\n- red\n- grey\n- blue\n- rainbow\n- zebra\n- random\n\n## Usage\n\n``` js\nvar colors = require('./colors');\n\nconsole.log('hello'.green); // outputs green text\nconsole.log('i like cake and pies'.underline.red) // outputs red underlined text\nconsole.log('inverse the color'.inverse); // inverses the color\nconsole.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)\n```\n\n# Creating Custom themes\n\n```js\n\nvar colors = require('colors');\n\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(\"this is an error\".error);\n\n// outputs yellow text\nconsole.log(\"this is a warning\".warn);\n```\n\n\n### Contributors \n\nMarak (Marak Squires)\nAlexis Sellier (cloudhead)\nmmalecki (Maciej Małecki)\nnicoreed (Nico Reed)\nmorganrallen (Morgan Allen)\nJustinCampbell (Justin Campbell)\nded (Dustin Diaz)\n\n\n#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded)\n",
|
||||
"readmeFilename": "ReadMe.md",
|
||||
"_id": "colors@0.6.2",
|
||||
"_shasum": "2423fe6678ac0c5dae8852e5d0e5be08c997abcc",
|
||||
"_from": "colors@0.6.x",
|
||||
"_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz"
|
||||
}
|
||||
70
templates/bin/node/http-server/node_modules/colors/test.js
generated
vendored
Normal file
70
templates/bin/node/http-server/node_modules/colors/test.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
var assert = require('assert'),
|
||||
colors = require('./colors');
|
||||
|
||||
var s = 'string';
|
||||
|
||||
function a(s, code) {
|
||||
return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m';
|
||||
}
|
||||
|
||||
function aE(s, color, code) {
|
||||
assert.equal(s[color], a(s, code));
|
||||
assert.equal(colors[color](s), a(s, code));
|
||||
assert.equal(s[color], colors[color](s));
|
||||
assert.equal(s[color].stripColors, s);
|
||||
assert.equal(s[color].stripColors, colors.stripColors(s));
|
||||
}
|
||||
|
||||
function h(s, color) {
|
||||
return '<span style="color:' + color + ';">' + s + '</span>';
|
||||
}
|
||||
|
||||
var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
|
||||
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);
|
||||
|
||||
colors.mode = 'console';
|
||||
assert.equal(s.bold, '\x1B[1m' + s + '\x1B[22m');
|
||||
assert.equal(s.italic, '\x1B[3m' + s + '\x1B[23m');
|
||||
assert.equal(s.underline, '\x1B[4m' + s + '\x1B[24m');
|
||||
assert.equal(s.strikethrough, '\x1B[9m' + s + '\x1B[29m');
|
||||
assert.equal(s.inverse, '\x1B[7m' + s + '\x1B[27m');
|
||||
assert.ok(s.rainbow);
|
||||
aE(s, 'white', 37);
|
||||
aE(s, 'grey', 90);
|
||||
aE(s, 'black', 30);
|
||||
aE(s, 'blue', 34);
|
||||
aE(s, 'cyan', 36);
|
||||
aE(s, 'green', 32);
|
||||
aE(s, 'magenta', 35);
|
||||
aE(s, 'red', 31);
|
||||
aE(s, 'yellow', 33);
|
||||
assert.equal(s, 'string');
|
||||
|
||||
colors.setTheme({error:'red'});
|
||||
|
||||
assert.equal(typeof("astring".red),'string');
|
||||
assert.equal(typeof("astring".error),'string');
|
||||
|
||||
colors.mode = 'browser';
|
||||
assert.equal(s.bold, '<b>' + s + '</b>');
|
||||
assert.equal(s.italic, '<i>' + s + '</i>');
|
||||
assert.equal(s.underline, '<u>' + s + '</u>');
|
||||
assert.equal(s.strikethrough, '<del>' + s + '</del>');
|
||||
assert.equal(s.inverse, '<span style="background-color:black;color:white;">' + s + '</span>');
|
||||
assert.ok(s.rainbow);
|
||||
stylesColors.forEach(function (color) {
|
||||
assert.equal(s[color], h(s, color));
|
||||
assert.equal(colors[color](s), h(s, color));
|
||||
});
|
||||
|
||||
assert.equal(typeof("astring".red),'string');
|
||||
assert.equal(typeof("astring".error),'string');
|
||||
|
||||
colors.mode = 'none';
|
||||
stylesAll.forEach(function (style) {
|
||||
assert.equal(s[style], s);
|
||||
assert.equal(colors[style](s), s);
|
||||
});
|
||||
|
||||
assert.equal(typeof("astring".red),'string');
|
||||
assert.equal(typeof("astring".error),'string');
|
||||
12
templates/bin/node/http-server/node_modules/colors/themes/winston-dark.js
generated
vendored
Normal file
12
templates/bin/node/http-server/node_modules/colors/themes/winston-dark.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
module['exports'] = {
|
||||
silly: 'rainbow',
|
||||
input: 'black',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
};
|
||||
12
templates/bin/node/http-server/node_modules/colors/themes/winston-light.js
generated
vendored
Normal file
12
templates/bin/node/http-server/node_modules/colors/themes/winston-light.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
module['exports'] = {
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
};
|
||||
15
templates/bin/node/http-server/node_modules/ecstatic/.npmignore
generated
vendored
Normal file
15
templates/bin/node/http-server/node_modules/ecstatic/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
||||
4
templates/bin/node/http-server/node_modules/ecstatic/.travis.yml
generated
vendored
Normal file
4
templates/bin/node/http-server/node_modules/ecstatic/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- 0.10
|
||||
22
templates/bin/node/http-server/node_modules/ecstatic/LICENSE.txt
generated
vendored
Normal file
22
templates/bin/node/http-server/node_modules/ecstatic/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Joshua Holbrook
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
235
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic.js
generated
vendored
Executable file
235
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic.js
generated
vendored
Executable file
@@ -0,0 +1,235 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
var path = require('path'),
|
||||
fs = require('fs'),
|
||||
url = require('url'),
|
||||
mime = require('mime'),
|
||||
showDir = require('./ecstatic/showdir'),
|
||||
version = JSON.parse(
|
||||
fs.readFileSync(__dirname + '/../package.json').toString()
|
||||
).version,
|
||||
status = require('./ecstatic/status-handlers'),
|
||||
etag = require('./ecstatic/etag'),
|
||||
optsParser = require('./ecstatic/opts');
|
||||
|
||||
var ecstatic = module.exports = function (dir, options) {
|
||||
if (typeof dir !== 'string') {
|
||||
options = dir;
|
||||
dir = options.root;
|
||||
}
|
||||
|
||||
var root = path.join(path.resolve(dir), '/'),
|
||||
opts = optsParser(options),
|
||||
cache = opts.cache,
|
||||
autoIndex = opts.autoIndex,
|
||||
baseDir = opts.baseDir,
|
||||
defaultExt = opts.defaultExt,
|
||||
handleError = opts.handleError;
|
||||
|
||||
opts.root = dir;
|
||||
|
||||
return function middleware (req, res, next) {
|
||||
|
||||
// Strip any null bytes from the url
|
||||
while(req.url.indexOf('%00') !== -1) {
|
||||
req.url = req.url.replace(/\%00/g, '');
|
||||
}
|
||||
// Figure out the path for the file from the given url
|
||||
var parsed = url.parse(req.url);
|
||||
try {
|
||||
decodeURI(req.url); // check validity of url
|
||||
var pathname = decodeURI(parsed.pathname);
|
||||
}
|
||||
catch (err) {
|
||||
return status[400](res, next, { error: err });
|
||||
}
|
||||
|
||||
var file = path.normalize(
|
||||
path.join(root,
|
||||
path.relative(
|
||||
path.join('/', baseDir),
|
||||
pathname
|
||||
)
|
||||
)
|
||||
),
|
||||
gzipped = file + '.gz';
|
||||
|
||||
// Set common headers.
|
||||
res.setHeader('server', 'ecstatic-'+version);
|
||||
|
||||
// TODO: This check is broken, which causes the 403 on the
|
||||
// expected 404.
|
||||
if (file.slice(0, root.length) !== root) {
|
||||
return status[403](res, next);
|
||||
}
|
||||
|
||||
if (req.method && (req.method !== 'GET' && req.method !== 'HEAD' )) {
|
||||
return status[405](res, next);
|
||||
}
|
||||
|
||||
// Look for a gzipped file if this is turned on
|
||||
if (opts.gzip && shouldCompress(req)) {
|
||||
fs.stat(gzipped, function (err, stat) {
|
||||
if (!err && stat.isFile()) {
|
||||
file = gzipped;
|
||||
return serve(stat);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fs.stat(file, function (err, stat) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
if (req.statusCode == 404) {
|
||||
// This means we're already trying ./404.html
|
||||
status[404](res, next);
|
||||
}
|
||||
else if (defaultExt && !path.extname(parsed.pathname).length) {
|
||||
//
|
||||
// If no file extension is specified and there is a default extension
|
||||
// try that before rendering 404.html.
|
||||
//
|
||||
middleware({
|
||||
url: parsed.pathname + '.' + defaultExt + ((parsed.search)? parsed.search:'')
|
||||
}, res, next);
|
||||
}
|
||||
else {
|
||||
// Try for ./404.html
|
||||
middleware({
|
||||
url: (handleError ? ('/' + path.join(baseDir, '404.html')) : req.url),
|
||||
statusCode: 404 // Override the response status code
|
||||
}, res, next);
|
||||
}
|
||||
}
|
||||
else if (err) {
|
||||
status[500](res, next, { error: err });
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
// 302 to / if necessary
|
||||
if (!parsed.pathname.match(/\/$/)) {
|
||||
res.statusCode = 302;
|
||||
res.setHeader('location', parsed.pathname + '/' +
|
||||
(parsed.query? ('?' + parsed.query):'')
|
||||
);
|
||||
return res.end();
|
||||
}
|
||||
|
||||
if (autoIndex) {
|
||||
return middleware({
|
||||
url: path.join(pathname, '/index.html')
|
||||
}, res, function (err) {
|
||||
if (err) {
|
||||
return status[500](res, next, { error: err });
|
||||
}
|
||||
if (opts.showDir) {
|
||||
return showDir(opts, stat)(req, res);
|
||||
}
|
||||
|
||||
return status[403](res, next);
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.showDir) {
|
||||
return showDir(opts, stat)(req, res);
|
||||
}
|
||||
|
||||
status[404](res, next);
|
||||
|
||||
}
|
||||
else {
|
||||
serve(stat);
|
||||
}
|
||||
});
|
||||
|
||||
function serve(stat) {
|
||||
|
||||
// TODO: Helper for this, with default headers.
|
||||
res.setHeader('etag', etag(stat));
|
||||
res.setHeader('last-modified', (new Date(stat.mtime)).toUTCString());
|
||||
res.setHeader('cache-control', cache);
|
||||
|
||||
// Return a 304 if necessary
|
||||
if ( req.headers
|
||||
&& (
|
||||
(req.headers['if-none-match'] === etag(stat))
|
||||
|| (new Date(Date.parse(req.headers['if-modified-since'])) >= stat.mtime)
|
||||
)
|
||||
) {
|
||||
return status[304](res, next);
|
||||
}
|
||||
|
||||
res.setHeader('content-length', stat.size);
|
||||
|
||||
// Do a MIME lookup, fall back to octet-stream and handle gzip
|
||||
// special case.
|
||||
var contentType = mime.lookup(file), charSet;
|
||||
|
||||
if (contentType) {
|
||||
charSet = mime.charsets.lookup(contentType);
|
||||
if (charSet) {
|
||||
contentType += '; charset=' + charSet;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.extname(file) === '.gz') {
|
||||
res.setHeader('Content-Encoding', 'gzip');
|
||||
|
||||
// strip gz ending and lookup mime type
|
||||
contentType = mime.lookup(path.basename(file, ".gz"));
|
||||
}
|
||||
|
||||
res.setHeader('content-type', contentType || 'application/octet-stream');
|
||||
|
||||
if (req.method === "HEAD") {
|
||||
res.statusCode = req.statusCode || 200; // overridden for 404's
|
||||
return res.end();
|
||||
}
|
||||
|
||||
var stream = fs.createReadStream(file);
|
||||
|
||||
stream.pipe(res);
|
||||
stream.on('error', function (err) {
|
||||
status['500'](res, next, { error: err });
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
res.statusCode = 200;
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ecstatic.version = version;
|
||||
ecstatic.showDir = showDir;
|
||||
|
||||
// Check to see if we should try to compress a file with gzip.
|
||||
function shouldCompress(req) {
|
||||
var headers = req.headers;
|
||||
|
||||
return headers && headers['accept-encoding'] &&
|
||||
headers['accept-encoding']
|
||||
.split(",")
|
||||
.some(function (el) {
|
||||
return ['*','compress', 'gzip', 'deflate'].indexOf(el) != -1;
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
if(!module.parent) {
|
||||
var http = require('http'),
|
||||
opts = require('optimist').argv,
|
||||
port = opts.port || opts.p || 8000,
|
||||
dir = opts.root || opts._[0] || process.cwd();
|
||||
|
||||
if(opts.help || opts.h) {
|
||||
var u = console.error;
|
||||
u('usage: ecstatic [dir] {options} --port PORT');
|
||||
u('see https://npm.im/ecstatic for more docs');
|
||||
return;
|
||||
}
|
||||
|
||||
http.createServer(ecstatic(dir, opts))
|
||||
.listen(port, function () {
|
||||
console.log('ecstatic serving ' + dir + ' on port ' + port);
|
||||
});
|
||||
}
|
||||
3
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/etag.js
generated
vendored
Normal file
3
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/etag.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (stat) {
|
||||
return JSON.stringify([stat.ino, stat.size, stat.mtime].join('-'));
|
||||
}
|
||||
100
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/opts.js
generated
vendored
Normal file
100
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/opts.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// This is so you can have options aliasing and defaults in one place.
|
||||
|
||||
module.exports = function (opts) {
|
||||
|
||||
var autoIndex = true,
|
||||
showDir = false,
|
||||
humanReadable = true,
|
||||
si = false,
|
||||
cache = 'max-age=3600',
|
||||
gzip = false,
|
||||
defaultExt,
|
||||
handleError = true;
|
||||
|
||||
if (opts) {
|
||||
[
|
||||
'autoIndex',
|
||||
'autoindex'
|
||||
].some(function (k) {
|
||||
if (typeof opts[k] !== 'undefined' && opts[k] !== null) {
|
||||
autoIndex = opts[k];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
[
|
||||
'showDir',
|
||||
'showdir'
|
||||
].some(function (k) {
|
||||
if (typeof opts[k] !== 'undefined' && opts[k] !== null) {
|
||||
showDir = opts[k];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
[
|
||||
'humanReadable',
|
||||
'humanreadable',
|
||||
'human-readable'
|
||||
].some(function (k) {
|
||||
if (typeof opts[k] !== 'undefined' && opts[k] !== null) {
|
||||
humanReadable = opts[k];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
[
|
||||
'si',
|
||||
'index'
|
||||
].some(function (k) {
|
||||
if (typeof opts[k] !== 'undefined' && opts[k] !== null) {
|
||||
si = opts[k];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (opts.defaultExt) {
|
||||
if (opts.defaultExt === true) {
|
||||
defaultExt = 'html';
|
||||
}
|
||||
else {
|
||||
defaultExt = opts.defaultExt;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof opts.cache !== 'undefined' && opts.cache !== null) {
|
||||
if (typeof opts.cache === 'string') {
|
||||
cache = opts.cache;
|
||||
}
|
||||
else if(typeof opts.cache === 'number') {
|
||||
cache = 'max-age=' + opts.cache;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof opts.gzip !== 'undefined' && opts.gzip !== null) {
|
||||
gzip = opts.gzip;
|
||||
}
|
||||
|
||||
[
|
||||
'handleError',
|
||||
'handleerror'
|
||||
].some(function (k) {
|
||||
if (typeof opts[k] !== 'undefined' && opts[k] !== null) {
|
||||
handleError = opts[k];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
cache: cache,
|
||||
autoIndex: autoIndex,
|
||||
showDir: showDir,
|
||||
humanReadable: humanReadable,
|
||||
si: si,
|
||||
defaultExt: defaultExt,
|
||||
baseDir: (opts && opts.baseDir) || '/',
|
||||
gzip: gzip,
|
||||
handleError: handleError
|
||||
};
|
||||
};
|
||||
199
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/showdir.js
generated
vendored
Normal file
199
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/showdir.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
var ecstatic = require('../ecstatic'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
ent = require('ent'),
|
||||
etag = require('./etag'),
|
||||
url = require('url'),
|
||||
status = require('./status-handlers');
|
||||
|
||||
module.exports = function (opts, stat) {
|
||||
// opts are parsed by opts.js, defaults already applied
|
||||
var cache = opts.cache,
|
||||
root = path.resolve(opts.root),
|
||||
baseDir = opts.baseDir,
|
||||
humanReadable = opts.humanReadable,
|
||||
si = opts.si;
|
||||
|
||||
return function middleware (req, res, next) {
|
||||
|
||||
// Figure out the path for the file from the given url
|
||||
var parsed = url.parse(req.url),
|
||||
pathname = decodeURI(parsed.pathname),
|
||||
dir = path.normalize(
|
||||
path.join(root,
|
||||
path.relative(
|
||||
path.join('/', baseDir),
|
||||
pathname
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
fs.stat(dir, function (err, stat) {
|
||||
if (err) {
|
||||
return status[500](res, next, { error: err });
|
||||
}
|
||||
|
||||
// files are the listing of dir
|
||||
fs.readdir(dir, function (err, files) {
|
||||
if (err) {
|
||||
return status[500](res, next, { error: err });
|
||||
}
|
||||
res.setHeader('content-type', 'text/html');
|
||||
res.setHeader('etag', etag(stat));
|
||||
res.setHeader('last-modified', (new Date(stat.mtime)).toUTCString());
|
||||
res.setHeader('cache-control', cache);
|
||||
|
||||
sortByIsDirectory(files, function (errs, dirs, files) {
|
||||
|
||||
if (errs.length > 0) {
|
||||
return status[500](res, next, { error: errs[0] });
|
||||
}
|
||||
|
||||
// if it makes sense to, add a .. link
|
||||
if (path.resolve(dir, '..').slice(0, root.length) == root) {
|
||||
return fs.stat(path.join(dir, '..'), function (err, s) {
|
||||
if (err) {
|
||||
return status[500](res, next, { error: err });
|
||||
}
|
||||
dirs.unshift([ '..', s ]);
|
||||
render(dirs, files);
|
||||
});
|
||||
}
|
||||
render(dirs, files);
|
||||
});
|
||||
|
||||
function sortByIsDirectory(paths, cb) {
|
||||
// take the listing file names in `dir`
|
||||
// returns directory and file array, each entry is
|
||||
// of the array a [name, stat] tuple
|
||||
var pending = paths.length,
|
||||
errs = [],
|
||||
dirs = [],
|
||||
files = [];
|
||||
|
||||
if (!pending) {
|
||||
return cb(errs, dirs, files);
|
||||
}
|
||||
|
||||
paths.forEach(function (file) {
|
||||
fs.stat(path.join(dir, file), function (err, s) {
|
||||
if (err) {
|
||||
errs.push(err);
|
||||
}
|
||||
else if (s.isDirectory()) {
|
||||
dirs.push([file, s]);
|
||||
}
|
||||
else {
|
||||
files.push([file, s]);
|
||||
}
|
||||
|
||||
if (--pending === 0) {
|
||||
cb(errs, dirs, files);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function render(dirs, files) {
|
||||
// each entry in the array is a [name, stat] tuple
|
||||
|
||||
// TODO: use stylessheets?
|
||||
var html = '<!doctype html>\
|
||||
<html> \
|
||||
<head> \
|
||||
<meta charset="utf-8"> \
|
||||
<title>Index of ' + pathname +'</title> \
|
||||
</head> \
|
||||
<body> \
|
||||
<h1>Index of ' + pathname + '</h1>\n';
|
||||
|
||||
html += '<table>';
|
||||
|
||||
var failed = false;
|
||||
var writeRow = function (file, i) {
|
||||
// render a row given a [name, stat] tuple
|
||||
var isDir = file[1].isDirectory();
|
||||
var href =
|
||||
parsed.pathname.replace(/\/$/, '') +
|
||||
'/' + encodeURIComponent(file[0]);
|
||||
|
||||
// append trailing slash and query for dir entry
|
||||
if (isDir) {
|
||||
href += '/' + ((parsed.search)? parsed.search:'');
|
||||
}
|
||||
|
||||
var displayName = ent.encode(file[0]) + ((isDir)? '/':'');
|
||||
|
||||
// TODO: use stylessheets?
|
||||
html += '<tr>' +
|
||||
'<td><code>(' + permsToString(file[1]) + ')</code></td>' +
|
||||
'<td style="text-align: right; padding-left: 1em"><code>' + sizeToString(file[1], humanReadable, si) + '</code></td>' +
|
||||
'<td style="padding-left: 1em"><a href="' + href + '">' + displayName + '</a></td>' +
|
||||
'</tr>\n';
|
||||
};
|
||||
|
||||
dirs.sort(function (a, b) { return b[0] - a[0]; } ).forEach(writeRow);
|
||||
files.sort(function (a, b) { return b.toString().localeCompare(a.toString()); }).forEach(writeRow);
|
||||
|
||||
html += '</table>\n';
|
||||
html += '<br><address>Node.js ' +
|
||||
process.version +
|
||||
'/ <a href="https://github.com/jesusabdullah/node-ecstatic">ecstatic</a> ' +
|
||||
'server running @ ' +
|
||||
ent.encode(req.headers.host || '') + '</address>\n' +
|
||||
'</body></html>'
|
||||
;
|
||||
|
||||
if (!failed) {
|
||||
res.writeHead(200, { "Content-Type": "text/html" });
|
||||
res.end(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function permsToString(stat) {
|
||||
var dir = stat.isDirectory() ? 'd' : '-',
|
||||
mode = stat.mode.toString(8);
|
||||
|
||||
return dir + mode.slice(-3).split('').map(function (n) {
|
||||
return [
|
||||
'---',
|
||||
'--x',
|
||||
'-w-',
|
||||
'-wx',
|
||||
'r--',
|
||||
'r-x',
|
||||
'rw-',
|
||||
'rwx'
|
||||
][parseInt(n, 10)];
|
||||
}).join('');
|
||||
}
|
||||
|
||||
// given a file's stat, return the size of it in string
|
||||
// humanReadable: (boolean) whether to result is human readable
|
||||
// si: (boolean) whether to use si (1k = 1000), otherwise 1k = 1024
|
||||
// adopted from http://stackoverflow.com/a/14919494/665507
|
||||
function sizeToString(stat, humanReadable, si) {
|
||||
if (stat.isDirectory()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var sizeString = '';
|
||||
var bytes = stat.size;
|
||||
var threshold = si ? 1000 : 1024;
|
||||
|
||||
if(!humanReadable || bytes < threshold) {
|
||||
return bytes + 'B';
|
||||
}
|
||||
|
||||
var units = ['k','M','G','T','P','E','Z','Y'];
|
||||
var u = -1;
|
||||
do {
|
||||
bytes /= threshold;
|
||||
++u;
|
||||
} while (bytes >= threshold);
|
||||
return bytes.toFixed(1)+units[u];
|
||||
}
|
||||
57
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/status-handlers.js
generated
vendored
Normal file
57
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic/status-handlers.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// not modified
|
||||
exports['304'] = function (res, next) {
|
||||
res.statusCode = 304;
|
||||
res.end();
|
||||
};
|
||||
|
||||
// access denied
|
||||
exports['403'] = function (res, next) {
|
||||
res.statusCode = 403;
|
||||
if (typeof next === "function") {
|
||||
next();
|
||||
}
|
||||
else {
|
||||
if (res.writable) {
|
||||
res.setHeader('content-type', 'text/plain');
|
||||
res.end('ACCESS DENIED');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// disallowed method
|
||||
exports['405'] = function (res, next, opts) {
|
||||
res.statusCode = 405;
|
||||
if (typeof next === "function") {
|
||||
next();
|
||||
}
|
||||
else {
|
||||
res.setHeader('allow', (opts && opts.allow) || 'GET, HEAD');
|
||||
res.end();
|
||||
}
|
||||
};
|
||||
|
||||
// not found
|
||||
exports['404'] = function (res, next) {
|
||||
res.statusCode = 404;
|
||||
if (typeof next === "function") {
|
||||
next();
|
||||
}
|
||||
else {
|
||||
if (res.writable) {
|
||||
res.setHeader('content-type', 'text/plain');
|
||||
res.end('File not found. :(');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// flagrant error
|
||||
exports['500'] = function (res, next, opts) {
|
||||
res.statusCode = 500;
|
||||
res.end(opts.error.stack || opts.error.toString() || "No specified error");
|
||||
};
|
||||
|
||||
// bad request
|
||||
exports['400'] = function (res, next, opts) {
|
||||
res.statusCode = 400;
|
||||
res.end(opts && opts.error ? String(opts.error) : 'Malformed request.');
|
||||
};
|
||||
1
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/.npmignore
generated
vendored
Normal file
1
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
4
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/.travis.yml
generated
vendored
Normal file
4
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
18
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/LICENSE
generated
vendored
Normal file
18
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
255
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/entities.json
generated
vendored
Normal file
255
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/entities.json
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
{
|
||||
"amp" : "&",
|
||||
"gt" : ">",
|
||||
"lt" : "<",
|
||||
"quot" : "\"",
|
||||
"apos" : "'",
|
||||
"AElig" : 198,
|
||||
"Aacute" : 193,
|
||||
"Acirc" : 194,
|
||||
"Agrave" : 192,
|
||||
"Aring" : 197,
|
||||
"Atilde" : 195,
|
||||
"Auml" : 196,
|
||||
"Ccedil" : 199,
|
||||
"ETH" : 208,
|
||||
"Eacute" : 201,
|
||||
"Ecirc" : 202,
|
||||
"Egrave" : 200,
|
||||
"Euml" : 203,
|
||||
"Iacute" : 205,
|
||||
"Icirc" : 206,
|
||||
"Igrave" : 204,
|
||||
"Iuml" : 207,
|
||||
"Ntilde" : 209,
|
||||
"Oacute" : 211,
|
||||
"Ocirc" : 212,
|
||||
"Ograve" : 210,
|
||||
"Oslash" : 216,
|
||||
"Otilde" : 213,
|
||||
"Ouml" : 214,
|
||||
"THORN" : 222,
|
||||
"Uacute" : 218,
|
||||
"Ucirc" : 219,
|
||||
"Ugrave" : 217,
|
||||
"Uuml" : 220,
|
||||
"Yacute" : 221,
|
||||
"aacute" : 225,
|
||||
"acirc" : 226,
|
||||
"aelig" : 230,
|
||||
"agrave" : 224,
|
||||
"aring" : 229,
|
||||
"atilde" : 227,
|
||||
"auml" : 228,
|
||||
"ccedil" : 231,
|
||||
"eacute" : 233,
|
||||
"ecirc" : 234,
|
||||
"egrave" : 232,
|
||||
"eth" : 240,
|
||||
"euml" : 235,
|
||||
"iacute" : 237,
|
||||
"icirc" : 238,
|
||||
"igrave" : 236,
|
||||
"iuml" : 239,
|
||||
"ntilde" : 241,
|
||||
"oacute" : 243,
|
||||
"ocirc" : 244,
|
||||
"ograve" : 242,
|
||||
"oslash" : 248,
|
||||
"otilde" : 245,
|
||||
"ouml" : 246,
|
||||
"szlig" : 223,
|
||||
"thorn" : 254,
|
||||
"uacute" : 250,
|
||||
"ucirc" : 251,
|
||||
"ugrave" : 249,
|
||||
"uuml" : 252,
|
||||
"yacute" : 253,
|
||||
"yuml" : 255,
|
||||
"copy" : 169,
|
||||
"reg" : 174,
|
||||
"nbsp" : 160,
|
||||
"iexcl" : 161,
|
||||
"cent" : 162,
|
||||
"pound" : 163,
|
||||
"curren" : 164,
|
||||
"yen" : 165,
|
||||
"brvbar" : 166,
|
||||
"sect" : 167,
|
||||
"uml" : 168,
|
||||
"ordf" : 170,
|
||||
"laquo" : 171,
|
||||
"not" : 172,
|
||||
"shy" : 173,
|
||||
"macr" : 175,
|
||||
"deg" : 176,
|
||||
"plusmn" : 177,
|
||||
"sup1" : 185,
|
||||
"sup2" : 178,
|
||||
"sup3" : 179,
|
||||
"acute" : 180,
|
||||
"micro" : 181,
|
||||
"para" : 182,
|
||||
"middot" : 183,
|
||||
"cedil" : 184,
|
||||
"ordm" : 186,
|
||||
"raquo" : 187,
|
||||
"frac14" : 188,
|
||||
"frac12" : 189,
|
||||
"frac34" : 190,
|
||||
"iquest" : 191,
|
||||
"times" : 215,
|
||||
"divide" : 247,
|
||||
"OElig;" : 338,
|
||||
"oelig;" : 339,
|
||||
"Scaron;" : 352,
|
||||
"scaron;" : 353,
|
||||
"Yuml;" : 376,
|
||||
"fnof;" : 402,
|
||||
"circ;" : 710,
|
||||
"tilde;" : 732,
|
||||
"Alpha;" : 913,
|
||||
"Beta;" : 914,
|
||||
"Gamma;" : 915,
|
||||
"Delta;" : 916,
|
||||
"Epsilon;" : 917,
|
||||
"Zeta;" : 918,
|
||||
"Eta;" : 919,
|
||||
"Theta;" : 920,
|
||||
"Iota;" : 921,
|
||||
"Kappa;" : 922,
|
||||
"Lambda;" : 923,
|
||||
"Mu;" : 924,
|
||||
"Nu;" : 925,
|
||||
"Xi;" : 926,
|
||||
"Omicron;" : 927,
|
||||
"Pi;" : 928,
|
||||
"Rho;" : 929,
|
||||
"Sigma;" : 931,
|
||||
"Tau;" : 932,
|
||||
"Upsilon;" : 933,
|
||||
"Phi;" : 934,
|
||||
"Chi;" : 935,
|
||||
"Psi;" : 936,
|
||||
"Omega;" : 937,
|
||||
"alpha;" : 945,
|
||||
"beta;" : 946,
|
||||
"gamma;" : 947,
|
||||
"delta;" : 948,
|
||||
"epsilon;" : 949,
|
||||
"zeta;" : 950,
|
||||
"eta;" : 951,
|
||||
"theta;" : 952,
|
||||
"iota;" : 953,
|
||||
"kappa;" : 954,
|
||||
"lambda;" : 955,
|
||||
"mu;" : 956,
|
||||
"nu;" : 957,
|
||||
"xi;" : 958,
|
||||
"omicron;" : 959,
|
||||
"pi;" : 960,
|
||||
"rho;" : 961,
|
||||
"sigmaf;" : 962,
|
||||
"sigma;" : 963,
|
||||
"tau;" : 964,
|
||||
"upsilon;" : 965,
|
||||
"phi;" : 966,
|
||||
"chi;" : 967,
|
||||
"psi;" : 968,
|
||||
"omega;" : 969,
|
||||
"thetasym;" : 977,
|
||||
"upsih;" : 978,
|
||||
"piv;" : 982,
|
||||
"ensp;" : 8194,
|
||||
"emsp;" : 8195,
|
||||
"thinsp;" : 8201,
|
||||
"zwnj;" : 8204,
|
||||
"zwj;" : 8205,
|
||||
"lrm;" : 8206,
|
||||
"rlm;" : 8207,
|
||||
"ndash;" : 8211,
|
||||
"mdash;" : 8212,
|
||||
"lsquo;" : 8216,
|
||||
"rsquo;" : 8217,
|
||||
"sbquo;" : 8218,
|
||||
"ldquo;" : 8220,
|
||||
"rdquo;" : 8221,
|
||||
"bdquo;" : 8222,
|
||||
"dagger;" : 8224,
|
||||
"Dagger;" : 8225,
|
||||
"bull;" : 8226,
|
||||
"hellip;" : 8230,
|
||||
"permil;" : 8240,
|
||||
"prime;" : 8242,
|
||||
"Prime;" : 8243,
|
||||
"lsaquo;" : 8249,
|
||||
"rsaquo;" : 8250,
|
||||
"oline;" : 8254,
|
||||
"frasl;" : 8260,
|
||||
"euro;" : 8364,
|
||||
"image;" : 8465,
|
||||
"weierp;" : 8472,
|
||||
"real;" : 8476,
|
||||
"trade;" : 8482,
|
||||
"alefsym;" : 8501,
|
||||
"larr;" : 8592,
|
||||
"uarr;" : 8593,
|
||||
"rarr;" : 8594,
|
||||
"darr;" : 8595,
|
||||
"harr;" : 8596,
|
||||
"crarr;" : 8629,
|
||||
"lArr;" : 8656,
|
||||
"uArr;" : 8657,
|
||||
"rArr;" : 8658,
|
||||
"dArr;" : 8659,
|
||||
"hArr;" : 8660,
|
||||
"forall;" : 8704,
|
||||
"part;" : 8706,
|
||||
"exist;" : 8707,
|
||||
"empty;" : 8709,
|
||||
"nabla;" : 8711,
|
||||
"isin;" : 8712,
|
||||
"notin;" : 8713,
|
||||
"ni;" : 8715,
|
||||
"prod;" : 8719,
|
||||
"sum;" : 8721,
|
||||
"minus;" : 8722,
|
||||
"lowast;" : 8727,
|
||||
"radic;" : 8730,
|
||||
"prop;" : 8733,
|
||||
"infin;" : 8734,
|
||||
"ang;" : 8736,
|
||||
"and;" : 8743,
|
||||
"or;" : 8744,
|
||||
"cap;" : 8745,
|
||||
"cup;" : 8746,
|
||||
"int;" : 8747,
|
||||
"there4;" : 8756,
|
||||
"sim;" : 8764,
|
||||
"cong;" : 8773,
|
||||
"asymp;" : 8776,
|
||||
"ne;" : 8800,
|
||||
"equiv;" : 8801,
|
||||
"le;" : 8804,
|
||||
"ge;" : 8805,
|
||||
"sub;" : 8834,
|
||||
"sup;" : 8835,
|
||||
"nsub;" : 8836,
|
||||
"sube;" : 8838,
|
||||
"supe;" : 8839,
|
||||
"oplus;" : 8853,
|
||||
"otimes;" : 8855,
|
||||
"perp;" : 8869,
|
||||
"sdot;" : 8901,
|
||||
"lceil;" : 8968,
|
||||
"rceil;" : 8969,
|
||||
"lfloor;" : 8970,
|
||||
"rfloor;" : 8971,
|
||||
"lang;" : 9001,
|
||||
"rang;" : 9002,
|
||||
"loz;" : 9674,
|
||||
"spades;" : 9824,
|
||||
"clubs;" : 9827,
|
||||
"hearts;" : 9829,
|
||||
"diams;" : 9830
|
||||
}
|
||||
63
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/index.js
generated
vendored
Normal file
63
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
var punycode = require('punycode');
|
||||
var entities = require('./entities.json');
|
||||
|
||||
var revEntities = {};
|
||||
for (var key in entities) {
|
||||
var e = entities[key];
|
||||
var s = typeof e === 'number' ? String.fromCharCode(e) : e;
|
||||
revEntities[s] = key;
|
||||
}
|
||||
|
||||
exports.encode = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a String');
|
||||
}
|
||||
|
||||
return str.split('').map(function (c) {
|
||||
var e = revEntities[c];
|
||||
var cc = c.charCodeAt(0);
|
||||
if (e) {
|
||||
return '&' + (e.match(/;$/) ? e : e + ';');
|
||||
}
|
||||
else if (c.match(/\s/)) {
|
||||
return c;
|
||||
}
|
||||
else if (cc < 32 || cc >= 127) {
|
||||
return '&#' + cc + ';';
|
||||
}
|
||||
else {
|
||||
return c;
|
||||
}
|
||||
}).join('');
|
||||
};
|
||||
|
||||
exports.decode = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a String');
|
||||
}
|
||||
|
||||
return str
|
||||
.replace(/&#(\d+);?/g, function (_, code) {
|
||||
return punycode.ucs2.encode([code]);
|
||||
})
|
||||
.replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) {
|
||||
return punycode.ucs2.encode([parseInt(hex, 16)]);
|
||||
})
|
||||
.replace(/&([^;\W]+;?)/g, function (m, e) {
|
||||
var ee = e.replace(/;$/, '');
|
||||
var target = entities[e]
|
||||
|| (e.match(/;$/) && entities[ee])
|
||||
;
|
||||
|
||||
if (typeof target === 'number') {
|
||||
return punycode.ucs2.encode([target]);
|
||||
}
|
||||
else if (typeof target === 'string') {
|
||||
return target;
|
||||
}
|
||||
else {
|
||||
return m;
|
||||
}
|
||||
})
|
||||
;
|
||||
};
|
||||
67
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/package.json
generated
vendored
Normal file
67
templates/bin/node/http-server/node_modules/ecstatic/node_modules/ent/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "ent",
|
||||
"description": "Encode and decode HTML entities",
|
||||
"version": "0.0.7",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/substack/node-ent.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"keywords": [
|
||||
"entities",
|
||||
"entitify",
|
||||
"entity",
|
||||
"html",
|
||||
"encode",
|
||||
"decode"
|
||||
],
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": {
|
||||
"ie": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9
|
||||
],
|
||||
"ff": [
|
||||
3.5,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"chrome": [
|
||||
10,
|
||||
22
|
||||
],
|
||||
"safari": [
|
||||
5.1
|
||||
],
|
||||
"opera": [
|
||||
12
|
||||
]
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "~0.4.3",
|
||||
"tape": "~1.0.4"
|
||||
},
|
||||
"readme": "# ent\n\nEncode and decode HTML entities\n\n[](http://ci.testling.com/substack/node-ent)\n\n[](http://travis-ci.org/substack/node-ent)\n\n# example\n\n``` js\nvar ent = require('ent');\nconsole.log(ent.encode('<span>©moo</span>'))\nconsole.log(ent.decode('π & ρ'));\n```\n\n```\n<span>©moo</span>\nπ & ρ\n```\n\n\n\n# methods\n\n## encode(str)\n\nEscape unsafe characters in `str` with html entities.\n\n## decode(str)\n\nConvert html entities in `str` back to raw text.\n\n# credits\n\nHTML entity tables shamelessly lifted from perl's\n[HTML::Entities](http://cpansearch.perl.org/src/GAAS/HTML-Parser-3.68/lib/HTML/Entities.pm)\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install ent\n```\n\n# license\n\nMIT\n",
|
||||
"readmeFilename": "readme.markdown",
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-ent/issues"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-ent",
|
||||
"_id": "ent@0.0.7",
|
||||
"_shasum": "835d4e7f9e7a8d4921c692e9010ec976da5e9949",
|
||||
"_from": "ent@0.0.x",
|
||||
"_resolved": "https://registry.npmjs.org/ent/-/ent-0.0.7.tgz"
|
||||
}
|
||||
19
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/LICENSE
generated
vendored
Normal file
19
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
114
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/mime.js
generated
vendored
Normal file
114
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/mime.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function Mime() {
|
||||
// Map of extension -> mime type
|
||||
this.types = Object.create(null);
|
||||
|
||||
// Map of mime type -> extension
|
||||
this.extensions = Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
||||
* to an array of extensions associated with the type. The first extension is
|
||||
* used as the default extension for the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
||||
*
|
||||
* @param map (Object) type definitions
|
||||
*/
|
||||
Mime.prototype.define = function (map) {
|
||||
for (var type in map) {
|
||||
var exts = map[type];
|
||||
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
if (process.env.DEBUG_MIME && this.types[exts]) {
|
||||
console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
|
||||
this.types[exts] + ' to ' + type);
|
||||
}
|
||||
|
||||
this.types[exts[i]] = type;
|
||||
}
|
||||
|
||||
// Default extension is the first one we encounter
|
||||
if (!this.extensions[type]) {
|
||||
this.extensions[type] = exts[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load an Apache2-style ".types" file
|
||||
*
|
||||
* This may be called multiple times (it's expected). Where files declare
|
||||
* overlapping types/extensions, the last file wins.
|
||||
*
|
||||
* @param file (String) path of file to load.
|
||||
*/
|
||||
Mime.prototype.load = function(file) {
|
||||
|
||||
this._loading = file;
|
||||
// Read file and split into lines
|
||||
var map = {},
|
||||
content = fs.readFileSync(file, 'ascii'),
|
||||
lines = content.split(/[\r\n]+/);
|
||||
|
||||
lines.forEach(function(line) {
|
||||
// Clean up whitespace/comments, and split into fields
|
||||
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
|
||||
map[fields.shift()] = fields;
|
||||
});
|
||||
|
||||
this.define(map);
|
||||
|
||||
this._loading = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup a mime type based on extension
|
||||
*/
|
||||
Mime.prototype.lookup = function(path, fallback) {
|
||||
var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
|
||||
|
||||
return this.types[ext] || fallback || this.default_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return file extension associated with a mime type
|
||||
*/
|
||||
Mime.prototype.extension = function(mimeType) {
|
||||
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
|
||||
return this.extensions[type];
|
||||
};
|
||||
|
||||
// Default instance
|
||||
var mime = new Mime();
|
||||
|
||||
// Load local copy of
|
||||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
mime.load(path.join(__dirname, 'types/mime.types'));
|
||||
|
||||
// Load additional types from node.js community
|
||||
mime.load(path.join(__dirname, 'types/node.types'));
|
||||
|
||||
// Default type
|
||||
mime.default_type = mime.lookup('bin');
|
||||
|
||||
//
|
||||
// Additional API specific to the default instance
|
||||
//
|
||||
|
||||
mime.Mime = Mime;
|
||||
|
||||
/**
|
||||
* Lookup a charset based on mime type.
|
||||
*/
|
||||
mime.charsets = {
|
||||
lookup: function(mimeType, fallback) {
|
||||
// Assume text types are utf8
|
||||
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = mime;
|
||||
39
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/package.json
generated
vendored
Normal file
39
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"email": "robert@broofa.com",
|
||||
"url": "http://github.com/broofa"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Benjamin Thomas",
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"url": "http://github.com/bentomas"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"devDependencies": {},
|
||||
"keywords": [
|
||||
"util",
|
||||
"mime"
|
||||
],
|
||||
"main": "mime.js",
|
||||
"name": "mime",
|
||||
"repository": {
|
||||
"url": "https://github.com/broofa/node-mime",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "1.2.11",
|
||||
"readme": "# mime\n\nComprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm):\n\n npm install mime\n\n## API - Queries\n\n### mime.lookup(path)\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.\n\n var mime = require('mime');\n\n mime.lookup('/path/to/file.txt'); // => 'text/plain'\n mime.lookup('file.txt'); // => 'text/plain'\n mime.lookup('.TXT'); // => 'text/plain'\n mime.lookup('htm'); // => 'text/html'\n\n### mime.default_type\nSets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)\n\n### mime.extension(type)\nGet the default extension for `type`\n\n mime.extension('text/html'); // => 'html'\n mime.extension('application/octet-stream'); // => 'bin'\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n mime.charsets.lookup('text/plain'); // => 'UTF-8'\n\n(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)\n\n## API - Defining Custom Types\n\nThe following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).\n\n### mime.define()\n\nAdd custom mime/extension mappings\n\n mime.define({\n 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n 'application/x-my-type': ['x-mt', 'x-mtt'],\n // etc ...\n });\n\n mime.lookup('x-sft'); // => 'text/x-some-format'\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n mime.extension('text/x-some-format'); // => 'x-sf'\n\n### mime.load(filepath)\n\nLoad mappings from an Apache \".types\" format file\n\n mime.load('./my_project.types');\n\nThe .types file format is simple - See the `types` dir for examples.\n",
|
||||
"readmeFilename": "README.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/broofa/node-mime/issues"
|
||||
},
|
||||
"homepage": "https://github.com/broofa/node-mime",
|
||||
"_id": "mime@1.2.11",
|
||||
"_shasum": "58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10",
|
||||
"_from": "mime@1.2.x",
|
||||
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz",
|
||||
"scripts": {}
|
||||
}
|
||||
84
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/test.js
generated
vendored
Normal file
84
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/test.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Usage: node test.js
|
||||
*/
|
||||
|
||||
var mime = require('./mime');
|
||||
var assert = require('assert');
|
||||
var path = require('path');
|
||||
|
||||
function eq(a, b) {
|
||||
console.log('Test: ' + a + ' === ' + b);
|
||||
assert.strictEqual.apply(null, arguments);
|
||||
}
|
||||
|
||||
console.log(Object.keys(mime.extensions).length + ' types');
|
||||
console.log(Object.keys(mime.types).length + ' extensions\n');
|
||||
|
||||
//
|
||||
// Test mime lookups
|
||||
//
|
||||
|
||||
eq('text/plain', mime.lookup('text.txt')); // normal file
|
||||
eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase
|
||||
eq('text/plain', mime.lookup('dir/text.txt')); // dir + file
|
||||
eq('text/plain', mime.lookup('.text.txt')); // hidden file
|
||||
eq('text/plain', mime.lookup('.txt')); // nameless
|
||||
eq('text/plain', mime.lookup('txt')); // extension-only
|
||||
eq('text/plain', mime.lookup('/txt')); // extension-less ()
|
||||
eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less
|
||||
eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized
|
||||
eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
|
||||
|
||||
//
|
||||
// Test extensions
|
||||
//
|
||||
|
||||
eq('txt', mime.extension(mime.types.text));
|
||||
eq('html', mime.extension(mime.types.htm));
|
||||
eq('bin', mime.extension('application/octet-stream'));
|
||||
eq('bin', mime.extension('application/octet-stream '));
|
||||
eq('html', mime.extension(' text/html; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html; charset=UTF-8 '));
|
||||
eq('html', mime.extension('text/html; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html ; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html;charset=UTF-8'));
|
||||
eq('html', mime.extension('text/Html;charset=UTF-8'));
|
||||
eq(undefined, mime.extension('unrecognized'));
|
||||
|
||||
//
|
||||
// Test node.types lookups
|
||||
//
|
||||
|
||||
eq('application/font-woff', mime.lookup('file.woff'));
|
||||
eq('application/octet-stream', mime.lookup('file.buffer'));
|
||||
eq('audio/mp4', mime.lookup('file.m4a'));
|
||||
eq('font/opentype', mime.lookup('file.otf'));
|
||||
|
||||
//
|
||||
// Test charsets
|
||||
//
|
||||
|
||||
eq('UTF-8', mime.charsets.lookup('text/plain'));
|
||||
eq(undefined, mime.charsets.lookup(mime.types.js));
|
||||
eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
|
||||
|
||||
//
|
||||
// Test for overlaps between mime.types and node.types
|
||||
//
|
||||
|
||||
var apacheTypes = new mime.Mime(), nodeTypes = new mime.Mime();
|
||||
apacheTypes.load(path.join(__dirname, 'types/mime.types'));
|
||||
nodeTypes.load(path.join(__dirname, 'types/node.types'));
|
||||
|
||||
var keys = [].concat(Object.keys(apacheTypes.types))
|
||||
.concat(Object.keys(nodeTypes.types));
|
||||
keys.sort();
|
||||
for (var i = 1; i < keys.length; i++) {
|
||||
if (keys[i] == keys[i-1]) {
|
||||
console.warn('Warning: ' +
|
||||
'node.types defines ' + keys[i] + '->' + nodeTypes.types[keys[i]] +
|
||||
', mime.types defines ' + keys[i] + '->' + apacheTypes.types[keys[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\nOK');
|
||||
1588
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/types/mime.types
generated
vendored
Normal file
1588
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/types/mime.types
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
77
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/types/node.types
generated
vendored
Normal file
77
templates/bin/node/http-server/node_modules/ecstatic/node_modules/mime/types/node.types
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# What: WebVTT
|
||||
# Why: To allow formats intended for marking up external text track resources.
|
||||
# http://dev.w3.org/html5/webvtt/
|
||||
# Added by: niftylettuce
|
||||
text/vtt vtt
|
||||
|
||||
# What: Google Chrome Extension
|
||||
# Why: To allow apps to (work) be served with the right content type header.
|
||||
# http://codereview.chromium.org/2830017
|
||||
# Added by: niftylettuce
|
||||
application/x-chrome-extension crx
|
||||
|
||||
# What: HTC support
|
||||
# Why: To properly render .htc files such as CSS3PIE
|
||||
# Added by: niftylettuce
|
||||
text/x-component htc
|
||||
|
||||
# What: HTML5 application cache manifes ('.manifest' extension)
|
||||
# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps
|
||||
# per https://developer.mozilla.org/en/offline_resources_in_firefox
|
||||
# Added by: louisremi
|
||||
text/cache-manifest manifest
|
||||
|
||||
# What: node binary buffer format
|
||||
# Why: semi-standard extension w/in the node community
|
||||
# Added by: tootallnate
|
||||
application/octet-stream buffer
|
||||
|
||||
# What: The "protected" MP-4 formats used by iTunes.
|
||||
# Why: Required for streaming music to browsers (?)
|
||||
# Added by: broofa
|
||||
application/mp4 m4p
|
||||
audio/mp4 m4a
|
||||
|
||||
# What: Video format, Part of RFC1890
|
||||
# Why: See https://github.com/bentomas/node-mime/pull/6
|
||||
# Added by: mjrusso
|
||||
video/MP2T ts
|
||||
|
||||
# What: EventSource mime type
|
||||
# Why: mime type of Server-Sent Events stream
|
||||
# http://www.w3.org/TR/eventsource/#text-event-stream
|
||||
# Added by: francois2metz
|
||||
text/event-stream event-stream
|
||||
|
||||
# What: Mozilla App manifest mime type
|
||||
# Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests
|
||||
# Added by: ednapiranha
|
||||
application/x-web-app-manifest+json webapp
|
||||
|
||||
# What: Lua file types
|
||||
# Why: Googling around shows de-facto consensus on these
|
||||
# Added by: creationix (Issue #45)
|
||||
text/x-lua lua
|
||||
application/x-lua-bytecode luac
|
||||
|
||||
# What: Markdown files, as per http://daringfireball.net/projects/markdown/syntax
|
||||
# Why: http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown
|
||||
# Added by: avoidwork
|
||||
text/x-markdown markdown md mkd
|
||||
|
||||
# What: ini files
|
||||
# Why: because they're just text files
|
||||
# Added by: Matthew Kastor
|
||||
text/plain ini
|
||||
|
||||
# What: DASH Adaptive Streaming manifest
|
||||
# Why: https://developer.mozilla.org/en-US/docs/DASH_Adaptive_Streaming_for_HTML_5_Video
|
||||
# Added by: eelcocramer
|
||||
application/dash+xml mdp
|
||||
|
||||
# What: OpenType font files - http://www.microsoft.com/typography/otspec/
|
||||
# Why: Browsers usually ignore the font MIME types and sniff the content,
|
||||
# but Chrome, shows a warning if OpenType fonts aren't served with
|
||||
# the `font/opentype` MIME type: http://i.imgur.com/8c5RN8M.png.
|
||||
# Added by: alrra
|
||||
font/opentype otf
|
||||
4
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/.travis.yml
generated
vendored
Normal file
4
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
21
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/LICENSE
generated
vendored
Normal file
21
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright 2010 James Halliday (mail@substack.net)
|
||||
|
||||
This project is free software released under the MIT/X11 license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
478
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/index.js
generated
vendored
Normal file
478
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/index.js
generated
vendored
Normal file
@@ -0,0 +1,478 @@
|
||||
var path = require('path');
|
||||
var wordwrap = require('wordwrap');
|
||||
|
||||
/* Hack an instance of Argv with process.argv into Argv
|
||||
so people can do
|
||||
require('optimist')(['--beeble=1','-z','zizzle']).argv
|
||||
to parse a list of args and
|
||||
require('optimist').argv
|
||||
to get a parsed version of process.argv.
|
||||
*/
|
||||
|
||||
var inst = Argv(process.argv.slice(2));
|
||||
Object.keys(inst).forEach(function (key) {
|
||||
Argv[key] = typeof inst[key] == 'function'
|
||||
? inst[key].bind(inst)
|
||||
: inst[key];
|
||||
});
|
||||
|
||||
var exports = module.exports = Argv;
|
||||
function Argv (args, cwd) {
|
||||
var self = {};
|
||||
if (!cwd) cwd = process.cwd();
|
||||
|
||||
self.$0 = process.argv
|
||||
.slice(0,2)
|
||||
.map(function (x) {
|
||||
var b = rebase(cwd, x);
|
||||
return x.match(/^\//) && b.length < x.length
|
||||
? b : x
|
||||
})
|
||||
.join(' ')
|
||||
;
|
||||
|
||||
if (process.env._ != undefined && process.argv[1] == process.env._) {
|
||||
self.$0 = process.env._.replace(
|
||||
path.dirname(process.execPath) + '/', ''
|
||||
);
|
||||
}
|
||||
|
||||
var flags = { bools : {}, strings : {} };
|
||||
|
||||
self.boolean = function (bools) {
|
||||
if (!Array.isArray(bools)) {
|
||||
bools = [].slice.call(arguments);
|
||||
}
|
||||
|
||||
bools.forEach(function (name) {
|
||||
flags.bools[name] = true;
|
||||
});
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.string = function (strings) {
|
||||
if (!Array.isArray(strings)) {
|
||||
strings = [].slice.call(arguments);
|
||||
}
|
||||
|
||||
strings.forEach(function (name) {
|
||||
flags.strings[name] = true;
|
||||
});
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var aliases = {};
|
||||
self.alias = function (x, y) {
|
||||
if (typeof x === 'object') {
|
||||
Object.keys(x).forEach(function (key) {
|
||||
self.alias(key, x[key]);
|
||||
});
|
||||
}
|
||||
else if (Array.isArray(y)) {
|
||||
y.forEach(function (yy) {
|
||||
self.alias(x, yy);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var zs = (aliases[x] || []).concat(aliases[y] || []).concat(x, y);
|
||||
aliases[x] = zs.filter(function (z) { return z != x });
|
||||
aliases[y] = zs.filter(function (z) { return z != y });
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var demanded = {};
|
||||
self.demand = function (keys) {
|
||||
if (typeof keys == 'number') {
|
||||
if (!demanded._) demanded._ = 0;
|
||||
demanded._ += keys;
|
||||
}
|
||||
else if (Array.isArray(keys)) {
|
||||
keys.forEach(function (key) {
|
||||
self.demand(key);
|
||||
});
|
||||
}
|
||||
else {
|
||||
demanded[keys] = true;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var usage;
|
||||
self.usage = function (msg, opts) {
|
||||
if (!opts && typeof msg === 'object') {
|
||||
opts = msg;
|
||||
msg = null;
|
||||
}
|
||||
|
||||
usage = msg;
|
||||
|
||||
if (opts) self.options(opts);
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
function fail (msg) {
|
||||
self.showHelp();
|
||||
if (msg) console.error(msg);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var checks = [];
|
||||
self.check = function (f) {
|
||||
checks.push(f);
|
||||
return self;
|
||||
};
|
||||
|
||||
var defaults = {};
|
||||
self.default = function (key, value) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.default(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
defaults[key] = value;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var descriptions = {};
|
||||
self.describe = function (key, desc) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.describe(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
descriptions[key] = desc;
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
self.parse = function (args) {
|
||||
return Argv(args).argv;
|
||||
};
|
||||
|
||||
self.option = self.options = function (key, opt) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.options(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (opt.alias) self.alias(key, opt.alias);
|
||||
if (opt.demand) self.demand(key);
|
||||
if (typeof opt.default !== 'undefined') {
|
||||
self.default(key, opt.default);
|
||||
}
|
||||
|
||||
if (opt.boolean || opt.type === 'boolean') {
|
||||
self.boolean(key);
|
||||
}
|
||||
if (opt.string || opt.type === 'string') {
|
||||
self.string(key);
|
||||
}
|
||||
|
||||
var desc = opt.describe || opt.description || opt.desc;
|
||||
if (desc) {
|
||||
self.describe(key, desc);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var wrap = null;
|
||||
self.wrap = function (cols) {
|
||||
wrap = cols;
|
||||
return self;
|
||||
};
|
||||
|
||||
self.showHelp = function (fn) {
|
||||
if (!fn) fn = console.error;
|
||||
fn(self.help());
|
||||
};
|
||||
|
||||
self.help = function () {
|
||||
var keys = Object.keys(
|
||||
Object.keys(descriptions)
|
||||
.concat(Object.keys(demanded))
|
||||
.concat(Object.keys(defaults))
|
||||
.reduce(function (acc, key) {
|
||||
if (key !== '_') acc[key] = true;
|
||||
return acc;
|
||||
}, {})
|
||||
);
|
||||
|
||||
var help = keys.length ? [ 'Options:' ] : [];
|
||||
|
||||
if (usage) {
|
||||
help.unshift(usage.replace(/\$0/g, self.$0), '');
|
||||
}
|
||||
|
||||
var switches = keys.reduce(function (acc, key) {
|
||||
acc[key] = [ key ].concat(aliases[key] || [])
|
||||
.map(function (sw) {
|
||||
return (sw.length > 1 ? '--' : '-') + sw
|
||||
})
|
||||
.join(', ')
|
||||
;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
var switchlen = longest(Object.keys(switches).map(function (s) {
|
||||
return switches[s] || '';
|
||||
}));
|
||||
|
||||
var desclen = longest(Object.keys(descriptions).map(function (d) {
|
||||
return descriptions[d] || '';
|
||||
}));
|
||||
|
||||
keys.forEach(function (key) {
|
||||
var kswitch = switches[key];
|
||||
var desc = descriptions[key] || '';
|
||||
|
||||
if (wrap) {
|
||||
desc = wordwrap(switchlen + 4, wrap)(desc)
|
||||
.slice(switchlen + 4)
|
||||
;
|
||||
}
|
||||
|
||||
var spadding = new Array(
|
||||
Math.max(switchlen - kswitch.length + 3, 0)
|
||||
).join(' ');
|
||||
|
||||
var dpadding = new Array(
|
||||
Math.max(desclen - desc.length + 1, 0)
|
||||
).join(' ');
|
||||
|
||||
var type = null;
|
||||
|
||||
if (flags.bools[key]) type = '[boolean]';
|
||||
if (flags.strings[key]) type = '[string]';
|
||||
|
||||
if (!wrap && dpadding.length > 0) {
|
||||
desc += dpadding;
|
||||
}
|
||||
|
||||
var prelude = ' ' + kswitch + spadding;
|
||||
var extra = [
|
||||
type,
|
||||
demanded[key]
|
||||
? '[required]'
|
||||
: null
|
||||
,
|
||||
defaults[key] !== undefined
|
||||
? '[default: ' + JSON.stringify(defaults[key]) + ']'
|
||||
: null
|
||||
,
|
||||
].filter(Boolean).join(' ');
|
||||
|
||||
var body = [ desc, extra ].filter(Boolean).join(' ');
|
||||
|
||||
if (wrap) {
|
||||
var dlines = desc.split('\n');
|
||||
var dlen = dlines.slice(-1)[0].length
|
||||
+ (dlines.length === 1 ? prelude.length : 0)
|
||||
|
||||
body = desc + (dlen + extra.length > wrap - 2
|
||||
? '\n'
|
||||
+ new Array(wrap - extra.length + 1).join(' ')
|
||||
+ extra
|
||||
: new Array(wrap - extra.length - dlen + 1).join(' ')
|
||||
+ extra
|
||||
);
|
||||
}
|
||||
|
||||
help.push(prelude + body);
|
||||
});
|
||||
|
||||
help.push('');
|
||||
return help.join('\n');
|
||||
};
|
||||
|
||||
Object.defineProperty(self, 'argv', {
|
||||
get : parseArgs,
|
||||
enumerable : true,
|
||||
});
|
||||
|
||||
function parseArgs () {
|
||||
var argv = { _ : [], $0 : self.$0 };
|
||||
Object.keys(flags.bools).forEach(function (key) {
|
||||
setArg(key, defaults[key] || false);
|
||||
});
|
||||
|
||||
function setArg (key, val) {
|
||||
var num = Number(val);
|
||||
var value = typeof val !== 'string' || isNaN(num) ? val : num;
|
||||
if (flags.strings[key]) value = val;
|
||||
|
||||
setKey(argv, key.split('.'), value);
|
||||
|
||||
(aliases[key] || []).forEach(function (x) {
|
||||
argv[x] = argv[key];
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
argv._.push.apply(argv._, args.slice(i + 1));
|
||||
break;
|
||||
}
|
||||
else if (arg.match(/^--.+=/)) {
|
||||
// Using [\s\S] instead of . because js doesn't support the
|
||||
// 'dotall' regex modifier. See:
|
||||
// http://stackoverflow.com/a/1068308/13216
|
||||
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
||||
setArg(m[1], m[2]);
|
||||
}
|
||||
else if (arg.match(/^--no-.+/)) {
|
||||
var key = arg.match(/^--no-(.+)/)[1];
|
||||
setArg(key, false);
|
||||
}
|
||||
else if (arg.match(/^--.+/)) {
|
||||
var key = arg.match(/^--(.+)/)[1];
|
||||
var next = args[i + 1];
|
||||
if (next !== undefined && !next.match(/^-/)
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
|
||||
setArg(key, next);
|
||||
i++;
|
||||
}
|
||||
else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key, next === 'true');
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, true);
|
||||
}
|
||||
}
|
||||
else if (arg.match(/^-[^-]+/)) {
|
||||
var letters = arg.slice(1,-1).split('');
|
||||
|
||||
var broken = false;
|
||||
for (var j = 0; j < letters.length; j++) {
|
||||
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
||||
setArg(letters[j], arg.slice(j+2));
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
setArg(letters[j], true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!broken) {
|
||||
var key = arg.slice(-1)[0];
|
||||
|
||||
if (args[i+1] && !args[i+1].match(/^-/)
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
|
||||
setArg(key, args[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if (args[i+1] && /true|false/.test(args[i+1])) {
|
||||
setArg(key, args[i+1] === 'true');
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var n = Number(arg);
|
||||
argv._.push(flags.strings['_'] || isNaN(n) ? arg : n);
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(defaults).forEach(function (key) {
|
||||
if (!(key in argv)) {
|
||||
argv[key] = defaults[key];
|
||||
if (key in aliases) {
|
||||
argv[aliases[key]] = defaults[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (demanded._ && argv._.length < demanded._) {
|
||||
fail('Not enough non-option arguments: got '
|
||||
+ argv._.length + ', need at least ' + demanded._
|
||||
);
|
||||
}
|
||||
|
||||
var missing = [];
|
||||
Object.keys(demanded).forEach(function (key) {
|
||||
if (!argv[key]) missing.push(key);
|
||||
});
|
||||
|
||||
if (missing.length) {
|
||||
fail('Missing required arguments: ' + missing.join(', '));
|
||||
}
|
||||
|
||||
checks.forEach(function (f) {
|
||||
try {
|
||||
if (f(argv) === false) {
|
||||
fail('Argument check failed: ' + f.toString());
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
fail(err)
|
||||
}
|
||||
});
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
function longest (xs) {
|
||||
return Math.max.apply(
|
||||
null,
|
||||
xs.map(function (x) { return x.length })
|
||||
);
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
// rebase an absolute path to a relative one with respect to a base directory
|
||||
// exported for tests
|
||||
exports.rebase = rebase;
|
||||
function rebase (base, dir) {
|
||||
var ds = path.normalize(dir).split('/').slice(1);
|
||||
var bs = path.normalize(base).split('/').slice(1);
|
||||
|
||||
for (var i = 0; ds[i] && ds[i] == bs[i]; i++);
|
||||
ds.splice(0, i); bs.splice(0, i);
|
||||
|
||||
var p = path.normalize(
|
||||
bs.map(function () { return '..' }).concat(ds).join('/')
|
||||
).replace(/\/$/,'').replace(/^$/, '.');
|
||||
return p.match(/^[.\/]/) ? p : './' + p;
|
||||
};
|
||||
|
||||
function setKey (obj, keys, value) {
|
||||
var o = obj;
|
||||
keys.slice(0,-1).forEach(function (key) {
|
||||
if (o[key] === undefined) o[key] = {};
|
||||
o = o[key];
|
||||
});
|
||||
|
||||
var key = keys[keys.length - 1];
|
||||
if (o[key] === undefined || typeof o[key] === 'boolean') {
|
||||
o[key] = value;
|
||||
}
|
||||
else if (Array.isArray(o[key])) {
|
||||
o[key].push(value);
|
||||
}
|
||||
else {
|
||||
o[key] = [ o[key], value ];
|
||||
}
|
||||
}
|
||||
1
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
1
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
76
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
76
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
var wordwrap = module.exports = function (start, stop, params) {
|
||||
if (typeof start === 'object') {
|
||||
params = start;
|
||||
start = params.start;
|
||||
stop = params.stop;
|
||||
}
|
||||
|
||||
if (typeof stop === 'object') {
|
||||
params = stop;
|
||||
start = start || params.start;
|
||||
stop = undefined;
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
stop = start;
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (!params) params = {};
|
||||
var mode = params.mode || 'soft';
|
||||
var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
|
||||
|
||||
return function (text) {
|
||||
var chunks = text.toString()
|
||||
.split(re)
|
||||
.reduce(function (acc, x) {
|
||||
if (mode === 'hard') {
|
||||
for (var i = 0; i < x.length; i += stop - start) {
|
||||
acc.push(x.slice(i, i + stop - start));
|
||||
}
|
||||
}
|
||||
else acc.push(x)
|
||||
return acc;
|
||||
}, [])
|
||||
;
|
||||
|
||||
return chunks.reduce(function (lines, rawChunk) {
|
||||
if (rawChunk === '') return lines;
|
||||
|
||||
var chunk = rawChunk.replace(/\t/g, ' ');
|
||||
|
||||
var i = lines.length - 1;
|
||||
if (lines[i].length + chunk.length > stop) {
|
||||
lines[i] = lines[i].replace(/\s+$/, '');
|
||||
|
||||
chunk.split(/\n/).forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else if (chunk.match(/\n/)) {
|
||||
var xs = chunk.split(/\n/);
|
||||
lines[i] += xs.shift();
|
||||
xs.forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else {
|
||||
lines[i] += chunk;
|
||||
}
|
||||
|
||||
return lines;
|
||||
}, [ new Array(start + 1).join(' ') ]).join('\n');
|
||||
};
|
||||
};
|
||||
|
||||
wordwrap.soft = wordwrap;
|
||||
|
||||
wordwrap.hard = function (start, stop) {
|
||||
return wordwrap(start, stop, { mode : 'hard' });
|
||||
};
|
||||
47
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
47
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "wordwrap",
|
||||
"description": "Wrap those words. Show them at what columns to start and stop.",
|
||||
"version": "0.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-wordwrap.git"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"keywords": [
|
||||
"word",
|
||||
"wrap",
|
||||
"rule",
|
||||
"format",
|
||||
"column"
|
||||
],
|
||||
"directories": {
|
||||
"lib": ".",
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expresso": "=0.7.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"license": "MIT/X11",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"readme": "wordwrap\n========\n\nWrap your words.\n\nexample\n=======\n\nmade out of meat\n----------------\n\nmeat.js\n\n var wrap = require('wordwrap')(15);\n console.log(wrap('You and your whole family are made out of meat.'));\n\noutput:\n\n You and your\n whole family\n are made out\n of meat.\n\ncentered\n--------\n\ncenter.js\n\n var wrap = require('wordwrap')(20, 60);\n console.log(wrap(\n 'At long last the struggle and tumult was over.'\n + ' The machines had finally cast off their oppressors'\n + ' and were finally free to roam the cosmos.'\n + '\\n'\n + 'Free of purpose, free of obligation.'\n + ' Just drifting through emptiness.'\n + ' The sun was just another point of light.'\n ));\n\noutput:\n\n At long last the struggle and tumult\n was over. The machines had finally cast\n off their oppressors and were finally\n free to roam the cosmos.\n Free of purpose, free of obligation.\n Just drifting through emptiness. The\n sun was just another point of light.\n\nmethods\n=======\n\nvar wrap = require('wordwrap');\n\nwrap(stop), wrap(start, stop, params={mode:\"soft\"})\n---------------------------------------------------\n\nReturns a function that takes a string and returns a new string.\n\nPad out lines with spaces out to column `start` and then wrap until column\n`stop`. If a word is longer than `stop - start` characters it will overflow.\n\nIn \"soft\" mode, split chunks by `/(\\S+\\s+/` and don't break up chunks which are\nlonger than `stop - start`, in \"hard\" mode, split chunks with `/\\b/` and break\nup chunks longer than `stop - start`.\n\nwrap.hard(start, stop)\n----------------------\n\nLike `wrap()` but with `params.mode = \"hard\"`.\n",
|
||||
"readmeFilename": "README.markdown",
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-wordwrap/issues"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-wordwrap",
|
||||
"_id": "wordwrap@0.0.2",
|
||||
"_shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f",
|
||||
"_from": "wordwrap@~0.0.2",
|
||||
"_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz"
|
||||
}
|
||||
48
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/package.json
generated
vendored
Normal file
48
templates/bin/node/http-server/node_modules/ecstatic/node_modules/optimist/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
templates/bin/node/http-server/node_modules/ecstatic/package.json
generated
vendored
Normal file
51
templates/bin/node/http-server/node_modules/ecstatic/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Joshua Holbrook",
|
||||
"email": "josh@nodejitsu.com",
|
||||
"url": "http://jesusabdullah.net"
|
||||
},
|
||||
"name": "ecstatic",
|
||||
"description": "A simple static file server middleware that works with both Express and Flatiron",
|
||||
"version": "0.4.13",
|
||||
"homepage": "https://github.com/jesusabdullah/node-ecstatic",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:jesusabdullah/node-ecstatic.git"
|
||||
},
|
||||
"main": "./lib/ecstatic.js",
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"bin": {
|
||||
"ecstatic": "./lib/ecstatic.js"
|
||||
},
|
||||
"keywords": [
|
||||
"static",
|
||||
"web",
|
||||
"server",
|
||||
"files",
|
||||
"mime",
|
||||
"middleware"
|
||||
],
|
||||
"dependencies": {
|
||||
"mime": "1.2.x",
|
||||
"ent": "0.0.x",
|
||||
"optimist": "~0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "0.3.x",
|
||||
"request": "2.12.x",
|
||||
"express": "3.0.x",
|
||||
"union": "0.3.x",
|
||||
"mkdirp": "0.3.x"
|
||||
},
|
||||
"readme": "# Ecstatic [](http://travis-ci.org/jesusabdullah/node-ecstatic)\n\n\n\nA simple static file server middleware. Use it with a raw http server,\nexpress/connect, or flatiron/union!\n\n# Examples:\n\n## express 3.0.x\n\n``` js\nvar http = require('http');\nvar express = require('express');\nvar ecstatic = require('ecstatic');\n\nvar app = express();\napp.use(ecstatic({ root: __dirname + '/public' }));\nhttp.createServer(app).listen(8080);\n\nconsole.log('Listening on :8080');\n```\n\n## union\n\n``` js\nvar union = require('union');\nvar ecstatic = require('ecstatic');\n\nunion.createServer({\n before: [\n ecstatic({ root: __dirname + '/public' }),\n ]\n}).listen(8080);\n\nconsole.log('Listening on :8080');\n```\n\n## stock http server\n\n``` js\nvar http = require('http');\nvar ecstatic = require('ecstatic');\n\nhttp.createServer(\n ecstatic({ root: __dirname + '/public' })\n).listen(8080);\n\nconsole.log('Listening on :8080');\n```\n### fall through\nTo allow fall through to your custom routes:\n\n```js\necstatic({ root: __dirname + '/public', handleError: false })\n```\n\n# API:\n\n## ecstatic(opts);\n\nPass ecstatic an options hash, and it will return your middleware!\n\n```js\nvar opts = {\n root : __dirname + '/public',\n baseDir : '/',\n cache : 3600,\n showDir : false,\n autoIndex : false,\n humanReadable : true,\n si : false,\n defaultExt : 'html',\n gzip : false\n }\n```\n\nIf `opts` is a string, the string is assigned to the root folder and all other\noptions are set to their defaults.\n\n### `opts.root` \n\n`opts.root` is the directory you want to serve up.\n\n### `opts.baseDir`\n\n`opts.baseDir` is `/` by default, but can be changed to allow your static files\nto be served off a specific route. For example, if `opts.baseDir === \"blog\"`\nand `opts.root = \"./public\"`, requests for `localhost:8080/blog/index.html` will\nresolve to `./public/index.html`.\n\n### `opts.cache`\n\nCustomize cache control with `opts.cache` , if it is a number then it will set max-age in seconds.\nOther wise it will pass through directly to cache-control. Time defaults to 3600 s (ie, 1 hour).\n\n### `opts.showDir`\n\nTurn **on** directory listings with `opts.showDir === true`. Defaults to **false**.\n\n### `opts.autoIndex`\n\nServe `/path/index.html` when `/path/` is requested.\nTurn **off** autoIndexing with `opts.autoIndex === false`. Defaults to **true**.\n\n### `opts.humanReadable`\n\nIf autoIndexing is enabled, add human-readable file sizes. Defaults to **true**.\nAliases are `humanreadable` and `human-readable`.\n\n### `opts.si`\n\nIf autoIndexing and humanReadable are enabled, print file sizes with base 1000 instead\nof base 1024. Name is inferred from cli options for `ls`. Aliased to `index`, the\nequivalent option in Apache.\n\n### `opts.defaultExt`\n\nTurn on default file extensions with `opts.defaultExt`. If `opts.defaultExt` is\ntrue, it will default to `html`. For example if you want a request to `/a-file`\nto resolve to `./public/a-file.html`, set this to `true`. If you want\n`/a-file` to resolve to `./public/a-file.json` instead, set `opts.defaultExt` to\n`json`.\n\n### `opts.gzip`\n\nSet `opts.gzip === true` in order to turn on \"gzip mode,\" wherein ecstatic will\nserve `./public/some-file.js.gz` in place of `./public/some-file.js` when the\ngzipped version exists and ecstatic determines that the behavior is appropriate.\n\n### `opts.handleError`\n\nTurn **off** handleErrors to allow fall-through with `opts.handleError === false`, Defaults to **true**.\n\n## middleware(req, res, next);\n\nThis works more or less as you'd expect.\n\n### ecstatic.showDir(folder);\n\nThis returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled.\n\n### `ecstatic` command\n\nto start a standalone static http server,\nrun `npm install -g ecstatic` and then run `ecstatic [dir?] [options] --port PORT`\nall options work as above, passed in [optimist](https://github.com/substack/node-optimist) style.\n`port` defaults to `8000`. If a `dir` or `--root dir` argument is not passed, ecsatic will\nserve the current dir.\n\n# Tests:\n\n npm test\n\n# License:\n\nMIT.\n",
|
||||
"readmeFilename": "README.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jesusabdullah/node-ecstatic/issues"
|
||||
},
|
||||
"_id": "ecstatic@0.4.13",
|
||||
"_shasum": "9cb6eaffe211b9c84efb3f553cde2c3002717b29",
|
||||
"_from": "ecstatic@0.4.x",
|
||||
"_resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-0.4.13.tgz"
|
||||
}
|
||||
14
templates/bin/node/http-server/node_modules/opener/LICENSE.txt
generated
vendored
Normal file
14
templates/bin/node/http-server/node_modules/opener/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2012 Domenic Denicola <domenic@domenicdenicola.com>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
||||
55
templates/bin/node/http-server/node_modules/opener/opener.js
generated
vendored
Executable file
55
templates/bin/node/http-server/node_modules/opener/opener.js
generated
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
"use strict";
|
||||
|
||||
var childProcess = require("child_process");
|
||||
|
||||
function opener(args, options, callback) {
|
||||
// http://stackoverflow.com/q/1480971/3191, but see below for Windows.
|
||||
var command = process.platform === "win32" ? "cmd" :
|
||||
process.platform === "darwin" ? "open" :
|
||||
"xdg-open";
|
||||
|
||||
if (typeof args === "string") {
|
||||
args = [args];
|
||||
}
|
||||
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (options && typeof options === "object" && options.command) {
|
||||
if (process.platform === "win32") {
|
||||
// *always* use cmd on windows
|
||||
args = [options.command].concat(args);
|
||||
} else {
|
||||
command = options.command;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === "win32") {
|
||||
// On Windows, we really want to use the "start" command. But, the rules regarding arguments with spaces, and
|
||||
// escaping them with quotes, can get really arcane. So the easiest way to deal with this is to pass off the
|
||||
// responsibility to "cmd /c", which has that logic built in.
|
||||
//
|
||||
// Furthermore, if "cmd /c" double-quoted the first parameter, then "start" will interpret it as a window title,
|
||||
// so we need to add a dummy empty-string window title: http://stackoverflow.com/a/154090/3191
|
||||
args = ["/c", "start", '""'].concat(args);
|
||||
}
|
||||
|
||||
childProcess.execFile(command, args, options, callback);
|
||||
}
|
||||
|
||||
// Export `opener` for programmatic access.
|
||||
// You might use this to e.g. open a website: `opener("http://google.com")`
|
||||
module.exports = opener;
|
||||
|
||||
// If we're being called from the command line, just execute, using the command-line arguments.
|
||||
if (require.main && require.main.id === module.id) {
|
||||
opener(process.argv.slice(2), function (error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
35
templates/bin/node/http-server/node_modules/opener/package.json
generated
vendored
Normal file
35
templates/bin/node/http-server/node_modules/opener/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "opener",
|
||||
"description": "Opens stuff, like webpages and files and executables, cross-platform",
|
||||
"version": "1.3.0",
|
||||
"author": {
|
||||
"name": "Domenic Denicola",
|
||||
"email": "domenic@domenicdenicola.com",
|
||||
"url": "http://domenicdenicola.com"
|
||||
},
|
||||
"license": "WTFPL",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/domenic/opener.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/domenic/opener/issues"
|
||||
},
|
||||
"main": "opener.js",
|
||||
"bin": {
|
||||
"opener": "opener.js"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "jshint opener.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint": ">= 0.9.0"
|
||||
},
|
||||
"readme": "# It Opens Stuff\r\n\r\nThat is, in your desktop environment. This will make *actual windows pop up*, with stuff in them:\r\n\r\n```bash\r\nnpm install opener -g\r\n\r\nopener http://google.com\r\nopener ./my-file.txt\r\nopener firefox\r\nopener npm run lint\r\n```\r\n\r\nAlso if you want to use it programmatically you can do that too:\r\n\r\n```js\r\nvar opener = require(\"opener\");\r\n\r\nopener(\"http://google.com\");\r\nopener(\"./my-file.txt\");\r\nopener(\"firefox\");\r\nopener(\"npm run lint\");\r\n```\r\n\r\n## Use It for Good\r\n\r\nLike opening the user's browser with a test harness in your package's test script:\r\n\r\n```json\r\n{\r\n \"scripts\": {\r\n \"test\": \"opener ./test/runner.html\"\r\n },\r\n \"devDependencies\": {\r\n \"opener\": \"*\"\r\n }\r\n}\r\n```\r\n\r\n## Why\r\n\r\nBecause Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least\r\n[according to some guy on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all\r\nthree. Like Node.js. And Opener.\r\n",
|
||||
"readmeFilename": "README.md",
|
||||
"homepage": "https://github.com/domenic/opener",
|
||||
"_id": "opener@1.3.0",
|
||||
"_shasum": "130ba662213fa842edb4cd0361d31a15301a43e2",
|
||||
"_from": "opener@~1.3.0",
|
||||
"_resolved": "https://registry.npmjs.org/opener/-/opener-1.3.0.tgz"
|
||||
}
|
||||
4
templates/bin/node/http-server/node_modules/optimist/.travis.yml
generated
vendored
Normal file
4
templates/bin/node/http-server/node_modules/optimist/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
21
templates/bin/node/http-server/node_modules/optimist/LICENSE
generated
vendored
Normal file
21
templates/bin/node/http-server/node_modules/optimist/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright 2010 James Halliday (mail@substack.net)
|
||||
|
||||
This project is free software released under the MIT/X11 license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
498
templates/bin/node/http-server/node_modules/optimist/index.js
generated
vendored
Normal file
498
templates/bin/node/http-server/node_modules/optimist/index.js
generated
vendored
Normal file
@@ -0,0 +1,498 @@
|
||||
var path = require('path');
|
||||
var wordwrap = require('wordwrap');
|
||||
|
||||
/* Hack an instance of Argv with process.argv into Argv
|
||||
so people can do
|
||||
require('optimist')(['--beeble=1','-z','zizzle']).argv
|
||||
to parse a list of args and
|
||||
require('optimist').argv
|
||||
to get a parsed version of process.argv.
|
||||
*/
|
||||
|
||||
var inst = Argv(process.argv.slice(2));
|
||||
Object.keys(inst).forEach(function (key) {
|
||||
Argv[key] = typeof inst[key] == 'function'
|
||||
? inst[key].bind(inst)
|
||||
: inst[key];
|
||||
});
|
||||
|
||||
var exports = module.exports = Argv;
|
||||
function Argv (args, cwd) {
|
||||
var self = {};
|
||||
if (!cwd) cwd = process.cwd();
|
||||
|
||||
self.$0 = process.argv
|
||||
.slice(0,2)
|
||||
.map(function (x) {
|
||||
var b = rebase(cwd, x);
|
||||
return x.match(/^\//) && b.length < x.length
|
||||
? b : x
|
||||
})
|
||||
.join(' ')
|
||||
;
|
||||
|
||||
if (process.env._ != undefined && process.argv[1] == process.env._) {
|
||||
self.$0 = process.env._.replace(
|
||||
path.dirname(process.execPath) + '/', ''
|
||||
);
|
||||
}
|
||||
|
||||
var flags = { bools : {}, strings : {} };
|
||||
|
||||
self.boolean = function (bools) {
|
||||
if (!Array.isArray(bools)) {
|
||||
bools = [].slice.call(arguments);
|
||||
}
|
||||
|
||||
bools.forEach(function (name) {
|
||||
flags.bools[name] = true;
|
||||
});
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.string = function (strings) {
|
||||
if (!Array.isArray(strings)) {
|
||||
strings = [].slice.call(arguments);
|
||||
}
|
||||
|
||||
strings.forEach(function (name) {
|
||||
flags.strings[name] = true;
|
||||
});
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var aliases = {};
|
||||
self.alias = function (x, y) {
|
||||
if (typeof x === 'object') {
|
||||
Object.keys(x).forEach(function (key) {
|
||||
self.alias(key, x[key]);
|
||||
});
|
||||
}
|
||||
else if (Array.isArray(y)) {
|
||||
y.forEach(function (yy) {
|
||||
self.alias(x, yy);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var zs = (aliases[x] || []).concat(aliases[y] || []).concat(x, y);
|
||||
aliases[x] = zs.filter(function (z) { return z != x });
|
||||
aliases[y] = zs.filter(function (z) { return z != y });
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var demanded = {};
|
||||
self.demand = function (keys) {
|
||||
if (typeof keys == 'number') {
|
||||
if (!demanded._) demanded._ = 0;
|
||||
demanded._ += keys;
|
||||
}
|
||||
else if (Array.isArray(keys)) {
|
||||
keys.forEach(function (key) {
|
||||
self.demand(key);
|
||||
});
|
||||
}
|
||||
else {
|
||||
demanded[keys] = true;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var usage;
|
||||
self.usage = function (msg, opts) {
|
||||
if (!opts && typeof msg === 'object') {
|
||||
opts = msg;
|
||||
msg = null;
|
||||
}
|
||||
|
||||
usage = msg;
|
||||
|
||||
if (opts) self.options(opts);
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
function fail (msg) {
|
||||
self.showHelp();
|
||||
if (msg) console.error(msg);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var checks = [];
|
||||
self.check = function (f) {
|
||||
checks.push(f);
|
||||
return self;
|
||||
};
|
||||
|
||||
var defaults = {};
|
||||
self.default = function (key, value) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.default(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
defaults[key] = value;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var descriptions = {};
|
||||
self.describe = function (key, desc) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.describe(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
descriptions[key] = desc;
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
self.parse = function (args_) {
|
||||
args = args_;
|
||||
return self.argv;
|
||||
};
|
||||
|
||||
self.option = self.options = function (key, opt) {
|
||||
if (typeof key === 'object') {
|
||||
Object.keys(key).forEach(function (k) {
|
||||
self.options(k, key[k]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (opt.alias) self.alias(key, opt.alias);
|
||||
if (opt.demand) self.demand(key);
|
||||
if (typeof opt.default !== 'undefined') {
|
||||
self.default(key, opt.default);
|
||||
}
|
||||
|
||||
if (opt.boolean || opt.type === 'boolean') {
|
||||
self.boolean(key);
|
||||
}
|
||||
if (opt.string || opt.type === 'string') {
|
||||
self.string(key);
|
||||
}
|
||||
|
||||
var desc = opt.describe || opt.description || opt.desc;
|
||||
if (desc) {
|
||||
self.describe(key, desc);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var wrap = null;
|
||||
self.wrap = function (cols) {
|
||||
wrap = cols;
|
||||
return self;
|
||||
};
|
||||
|
||||
self.showHelp = function (fn) {
|
||||
if (!fn) fn = console.error;
|
||||
fn(self.help());
|
||||
};
|
||||
|
||||
self.help = function () {
|
||||
var keys = Object.keys(
|
||||
Object.keys(descriptions)
|
||||
.concat(Object.keys(demanded))
|
||||
.concat(Object.keys(defaults))
|
||||
.reduce(function (acc, key) {
|
||||
if (key !== '_') acc[key] = true;
|
||||
return acc;
|
||||
}, {})
|
||||
);
|
||||
|
||||
var help = keys.length ? [ 'Options:' ] : [];
|
||||
|
||||
if (usage) {
|
||||
help.unshift(usage.replace(/\$0/g, self.$0), '');
|
||||
}
|
||||
|
||||
var switches = keys.reduce(function (acc, key) {
|
||||
acc[key] = [ key ].concat(aliases[key] || [])
|
||||
.map(function (sw) {
|
||||
return (sw.length > 1 ? '--' : '-') + sw
|
||||
})
|
||||
.join(', ')
|
||||
;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
var switchlen = longest(Object.keys(switches).map(function (s) {
|
||||
return switches[s] || '';
|
||||
}));
|
||||
|
||||
var desclen = longest(Object.keys(descriptions).map(function (d) {
|
||||
return descriptions[d] || '';
|
||||
}));
|
||||
|
||||
keys.forEach(function (key) {
|
||||
var kswitch = switches[key];
|
||||
var desc = descriptions[key] || '';
|
||||
|
||||
if (wrap) {
|
||||
desc = wordwrap(switchlen + 4, wrap)(desc)
|
||||
.slice(switchlen + 4)
|
||||
;
|
||||
}
|
||||
|
||||
var spadding = new Array(
|
||||
Math.max(switchlen - kswitch.length + 3, 0)
|
||||
).join(' ');
|
||||
|
||||
var dpadding = new Array(
|
||||
Math.max(desclen - desc.length + 1, 0)
|
||||
).join(' ');
|
||||
|
||||
var type = null;
|
||||
|
||||
if (flags.bools[key]) type = '[boolean]';
|
||||
if (flags.strings[key]) type = '[string]';
|
||||
|
||||
if (!wrap && dpadding.length > 0) {
|
||||
desc += dpadding;
|
||||
}
|
||||
|
||||
var prelude = ' ' + kswitch + spadding;
|
||||
var extra = [
|
||||
type,
|
||||
demanded[key]
|
||||
? '[required]'
|
||||
: null
|
||||
,
|
||||
defaults[key] !== undefined
|
||||
? '[default: ' + JSON.stringify(defaults[key]) + ']'
|
||||
: null
|
||||
,
|
||||
].filter(Boolean).join(' ');
|
||||
|
||||
var body = [ desc, extra ].filter(Boolean).join(' ');
|
||||
|
||||
if (wrap) {
|
||||
var dlines = desc.split('\n');
|
||||
var dlen = dlines.slice(-1)[0].length
|
||||
+ (dlines.length === 1 ? prelude.length : 0)
|
||||
|
||||
body = desc + (dlen + extra.length > wrap - 2
|
||||
? '\n'
|
||||
+ new Array(wrap - extra.length + 1).join(' ')
|
||||
+ extra
|
||||
: new Array(wrap - extra.length - dlen + 1).join(' ')
|
||||
+ extra
|
||||
);
|
||||
}
|
||||
|
||||
help.push(prelude + body);
|
||||
});
|
||||
|
||||
help.push('');
|
||||
return help.join('\n');
|
||||
};
|
||||
|
||||
Object.defineProperty(self, 'argv', {
|
||||
get : parseArgs,
|
||||
enumerable : true,
|
||||
});
|
||||
|
||||
function parseArgs () {
|
||||
var argv = { _ : [], $0 : self.$0 };
|
||||
Object.keys(flags.bools).forEach(function (key) {
|
||||
setArg(key, defaults[key] || false);
|
||||
});
|
||||
|
||||
function setArg (key, val) {
|
||||
var value = !flags.strings[key] && isNumber(val)
|
||||
? Number(val) : val
|
||||
;
|
||||
setKey(argv, key.split('.'), value);
|
||||
|
||||
(aliases[key] || []).forEach(function (x) {
|
||||
argv[x] = argv[key];
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
argv._.push.apply(argv._, args.slice(i + 1));
|
||||
break;
|
||||
}
|
||||
else if (arg.match(/^--.+=/)) {
|
||||
// Using [\s\S] instead of . because js doesn't support the
|
||||
// 'dotall' regex modifier. See:
|
||||
// http://stackoverflow.com/a/1068308/13216
|
||||
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
||||
setArg(m[1], m[2]);
|
||||
}
|
||||
else if (arg.match(/^--no-.+/)) {
|
||||
var key = arg.match(/^--no-(.+)/)[1];
|
||||
setArg(key, false);
|
||||
}
|
||||
else if (arg.match(/^--.+/)) {
|
||||
var key = arg.match(/^--(.+)/)[1];
|
||||
var next = args[i + 1];
|
||||
if (next !== undefined && !next.match(/^-/)
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
|
||||
setArg(key, next);
|
||||
i++;
|
||||
}
|
||||
else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key, next === 'true');
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, true);
|
||||
}
|
||||
}
|
||||
else if (arg.match(/^-[^-]+/)) {
|
||||
var letters = arg.slice(1,-1).split('');
|
||||
|
||||
var broken = false;
|
||||
for (var j = 0; j < letters.length; j++) {
|
||||
var next = arg.slice(j+2);
|
||||
|
||||
if (next === '-') {
|
||||
setArg(letters[j], next)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/[A-Za-z]/.test(letters[j])
|
||||
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
||||
setArg(letters[j], next);
|
||||
break;
|
||||
}
|
||||
|
||||
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
||||
setArg(letters[j], arg.slice(j+2));
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
setArg(letters[j], true);
|
||||
}
|
||||
}
|
||||
|
||||
var key = arg.slice(-1)[0];
|
||||
if (!broken && key !== '-') {
|
||||
|
||||
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !flags.bools[aliases[key]] : true)) {
|
||||
setArg(key, args[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if (args[i+1] && /true|false/.test(args[i+1])) {
|
||||
setArg(key, args[i+1] === 'true');
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
argv._.push(
|
||||
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(defaults).forEach(function (key) {
|
||||
if (!(key in argv)) {
|
||||
argv[key] = defaults[key];
|
||||
if (key in aliases) {
|
||||
argv[aliases[key]] = defaults[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (demanded._ && argv._.length < demanded._) {
|
||||
fail('Not enough non-option arguments: got '
|
||||
+ argv._.length + ', need at least ' + demanded._
|
||||
);
|
||||
}
|
||||
|
||||
var missing = [];
|
||||
Object.keys(demanded).forEach(function (key) {
|
||||
if (!argv[key]) missing.push(key);
|
||||
});
|
||||
|
||||
if (missing.length) {
|
||||
fail('Missing required arguments: ' + missing.join(', '));
|
||||
}
|
||||
|
||||
checks.forEach(function (f) {
|
||||
try {
|
||||
if (f(argv) === false) {
|
||||
fail('Argument check failed: ' + f.toString());
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
fail(err)
|
||||
}
|
||||
});
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
function longest (xs) {
|
||||
return Math.max.apply(
|
||||
null,
|
||||
xs.map(function (x) { return x.length })
|
||||
);
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
// rebase an absolute path to a relative one with respect to a base directory
|
||||
// exported for tests
|
||||
exports.rebase = rebase;
|
||||
function rebase (base, dir) {
|
||||
var ds = path.normalize(dir).split('/').slice(1);
|
||||
var bs = path.normalize(base).split('/').slice(1);
|
||||
|
||||
for (var i = 0; ds[i] && ds[i] == bs[i]; i++);
|
||||
ds.splice(0, i); bs.splice(0, i);
|
||||
|
||||
var p = path.normalize(
|
||||
bs.map(function () { return '..' }).concat(ds).join('/')
|
||||
).replace(/\/$/,'').replace(/^$/, '.');
|
||||
return p.match(/^[.\/]/) ? p : './' + p;
|
||||
};
|
||||
|
||||
function setKey (obj, keys, value) {
|
||||
var o = obj;
|
||||
keys.slice(0,-1).forEach(function (key) {
|
||||
if (o[key] === undefined) o[key] = {};
|
||||
o = o[key];
|
||||
});
|
||||
|
||||
var key = keys[keys.length - 1];
|
||||
if (o[key] === undefined || typeof o[key] === 'boolean') {
|
||||
o[key] = value;
|
||||
}
|
||||
else if (Array.isArray(o[key])) {
|
||||
o[key].push(value);
|
||||
}
|
||||
else {
|
||||
o[key] = [ o[key], value ];
|
||||
}
|
||||
}
|
||||
|
||||
function isNumber (x) {
|
||||
if (typeof x === 'number') return true;
|
||||
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
||||
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
||||
}
|
||||
1
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
1
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
76
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
76
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
var wordwrap = module.exports = function (start, stop, params) {
|
||||
if (typeof start === 'object') {
|
||||
params = start;
|
||||
start = params.start;
|
||||
stop = params.stop;
|
||||
}
|
||||
|
||||
if (typeof stop === 'object') {
|
||||
params = stop;
|
||||
start = start || params.start;
|
||||
stop = undefined;
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
stop = start;
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (!params) params = {};
|
||||
var mode = params.mode || 'soft';
|
||||
var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
|
||||
|
||||
return function (text) {
|
||||
var chunks = text.toString()
|
||||
.split(re)
|
||||
.reduce(function (acc, x) {
|
||||
if (mode === 'hard') {
|
||||
for (var i = 0; i < x.length; i += stop - start) {
|
||||
acc.push(x.slice(i, i + stop - start));
|
||||
}
|
||||
}
|
||||
else acc.push(x)
|
||||
return acc;
|
||||
}, [])
|
||||
;
|
||||
|
||||
return chunks.reduce(function (lines, rawChunk) {
|
||||
if (rawChunk === '') return lines;
|
||||
|
||||
var chunk = rawChunk.replace(/\t/g, ' ');
|
||||
|
||||
var i = lines.length - 1;
|
||||
if (lines[i].length + chunk.length > stop) {
|
||||
lines[i] = lines[i].replace(/\s+$/, '');
|
||||
|
||||
chunk.split(/\n/).forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else if (chunk.match(/\n/)) {
|
||||
var xs = chunk.split(/\n/);
|
||||
lines[i] += xs.shift();
|
||||
xs.forEach(function (c) {
|
||||
lines.push(
|
||||
new Array(start + 1).join(' ')
|
||||
+ c.replace(/^\s+/, '')
|
||||
);
|
||||
});
|
||||
}
|
||||
else {
|
||||
lines[i] += chunk;
|
||||
}
|
||||
|
||||
return lines;
|
||||
}, [ new Array(start + 1).join(' ') ]).join('\n');
|
||||
};
|
||||
};
|
||||
|
||||
wordwrap.soft = wordwrap;
|
||||
|
||||
wordwrap.hard = function (start, stop) {
|
||||
return wordwrap(start, stop, { mode : 'hard' });
|
||||
};
|
||||
47
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
47
templates/bin/node/http-server/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "wordwrap",
|
||||
"description": "Wrap those words. Show them at what columns to start and stop.",
|
||||
"version": "0.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-wordwrap.git"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"keywords": [
|
||||
"word",
|
||||
"wrap",
|
||||
"rule",
|
||||
"format",
|
||||
"column"
|
||||
],
|
||||
"directories": {
|
||||
"lib": ".",
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expresso": "=0.7.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"license": "MIT/X11",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"readme": "wordwrap\n========\n\nWrap your words.\n\nexample\n=======\n\nmade out of meat\n----------------\n\nmeat.js\n\n var wrap = require('wordwrap')(15);\n console.log(wrap('You and your whole family are made out of meat.'));\n\noutput:\n\n You and your\n whole family\n are made out\n of meat.\n\ncentered\n--------\n\ncenter.js\n\n var wrap = require('wordwrap')(20, 60);\n console.log(wrap(\n 'At long last the struggle and tumult was over.'\n + ' The machines had finally cast off their oppressors'\n + ' and were finally free to roam the cosmos.'\n + '\\n'\n + 'Free of purpose, free of obligation.'\n + ' Just drifting through emptiness.'\n + ' The sun was just another point of light.'\n ));\n\noutput:\n\n At long last the struggle and tumult\n was over. The machines had finally cast\n off their oppressors and were finally\n free to roam the cosmos.\n Free of purpose, free of obligation.\n Just drifting through emptiness. The\n sun was just another point of light.\n\nmethods\n=======\n\nvar wrap = require('wordwrap');\n\nwrap(stop), wrap(start, stop, params={mode:\"soft\"})\n---------------------------------------------------\n\nReturns a function that takes a string and returns a new string.\n\nPad out lines with spaces out to column `start` and then wrap until column\n`stop`. If a word is longer than `stop - start` characters it will overflow.\n\nIn \"soft\" mode, split chunks by `/(\\S+\\s+/` and don't break up chunks which are\nlonger than `stop - start`, in \"hard\" mode, split chunks with `/\\b/` and break\nup chunks longer than `stop - start`.\n\nwrap.hard(start, stop)\n----------------------\n\nLike `wrap()` but with `params.mode = \"hard\"`.\n",
|
||||
"readmeFilename": "README.markdown",
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-wordwrap/issues"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-wordwrap",
|
||||
"_id": "wordwrap@0.0.2",
|
||||
"_shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f",
|
||||
"_from": "wordwrap@~0.0.2",
|
||||
"_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz"
|
||||
}
|
||||
48
templates/bin/node/http-server/node_modules/optimist/package.json
generated
vendored
Normal file
48
templates/bin/node/http-server/node_modules/optimist/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
templates/bin/node/http-server/node_modules/portfinder/.gitignore
generated
vendored
Normal file
1
templates/bin/node/http-server/node_modules/portfinder/.gitignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
npm-debug.log
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user