From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/coa/coverage/base.css | 212 +++ node_modules/coa/coverage/coa/index.html | 93 ++ node_modules/coa/coverage/coa/index.js.html | 68 + node_modules/coa/coverage/coa/lib/arg.js.html | 239 +++ node_modules/coa/coverage/coa/lib/cmd.js.html | 1556 ++++++++++++++++++++ .../coa/coverage/coa/lib/coaobject.js.html | 365 +++++ node_modules/coa/coverage/coa/lib/coaparam.js.html | 440 ++++++ node_modules/coa/coverage/coa/lib/color.js.html | 131 ++ .../coa/coverage/coa/lib/completion.js.html | 593 ++++++++ node_modules/coa/coverage/coa/lib/index.html | 197 +++ node_modules/coa/coverage/coa/lib/index.js.html | 107 ++ node_modules/coa/coverage/coa/lib/opt.js.html | 524 +++++++ node_modules/coa/coverage/coa/lib/shell.js.html | 107 ++ node_modules/coa/coverage/index.html | 106 ++ node_modules/coa/coverage/prettify.css | 1 + node_modules/coa/coverage/prettify.js | 1 + node_modules/coa/coverage/sort-arrow-sprite.png | Bin 0 -> 209 bytes node_modules/coa/coverage/sorter.js | 158 ++ 18 files changed, 4898 insertions(+) create mode 100644 node_modules/coa/coverage/base.css create mode 100644 node_modules/coa/coverage/coa/index.html create mode 100644 node_modules/coa/coverage/coa/index.js.html create mode 100644 node_modules/coa/coverage/coa/lib/arg.js.html create mode 100644 node_modules/coa/coverage/coa/lib/cmd.js.html create mode 100644 node_modules/coa/coverage/coa/lib/coaobject.js.html create mode 100644 node_modules/coa/coverage/coa/lib/coaparam.js.html create mode 100644 node_modules/coa/coverage/coa/lib/color.js.html create mode 100644 node_modules/coa/coverage/coa/lib/completion.js.html create mode 100644 node_modules/coa/coverage/coa/lib/index.html create mode 100644 node_modules/coa/coverage/coa/lib/index.js.html create mode 100644 node_modules/coa/coverage/coa/lib/opt.js.html create mode 100644 node_modules/coa/coverage/coa/lib/shell.js.html create mode 100644 node_modules/coa/coverage/index.html create mode 100644 node_modules/coa/coverage/prettify.css create mode 100644 node_modules/coa/coverage/prettify.js create mode 100644 node_modules/coa/coverage/sort-arrow-sprite.png create mode 100644 node_modules/coa/coverage/sorter.js (limited to 'node_modules/coa/coverage') diff --git a/node_modules/coa/coverage/base.css b/node_modules/coa/coverage/base.css new file mode 100644 index 00000000..417c7adc --- /dev/null +++ b/node_modules/coa/coverage/base.css @@ -0,0 +1,212 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } + + +.medium .chart { border:1px solid #666; } +.medium .cover-fill { background: #666; } + +.cbranch-no { background: yellow !important; color: #111; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } +.medium { background: #eaeaea; } + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/node_modules/coa/coverage/coa/index.html b/node_modules/coa/coverage/coa/index.html new file mode 100644 index 00000000..1c0b7106 --- /dev/null +++ b/node_modules/coa/coverage/coa/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for coa + + + + + + + +
+
+

+ All files coa +

+
+
+ 100% + Statements + 1/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 1/1 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.js
100%1/1100%0/0100%0/0100%1/1
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/index.js.html b/node_modules/coa/coverage/coa/index.js.html new file mode 100644 index 00000000..a5da1dd3 --- /dev/null +++ b/node_modules/coa/coverage/coa/index.js.html @@ -0,0 +1,68 @@ + + + + Code coverage report for coa/index.js + + + + + + + +
+
+

+ All files / coa index.js +

+
+
+ 100% + Statements + 1/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 1/1 +
+
+
+
+

+
+
1 +21x + 
module.exports = require('./lib');
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/arg.js.html b/node_modules/coa/coverage/coa/lib/arg.js.html new file mode 100644 index 00000000..85b03aec --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/arg.js.html @@ -0,0 +1,239 @@ + + + + Code coverage report for coa/lib/arg.js + + + + + + + +
+
+

+ All files / coa/lib arg.js +

+
+
+ 100% + Statements + 16/16 +
+
+ 87.5% + Branches + 7/8 +
+
+ 100% + Functions + 6/6 +
+
+ 100% + Lines + 16/16 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +16x +  +16x +  +  +  +31x +  +31x +31x +  +  +  +31x +  +  +  +28x +  +  +  +2x +  +  +  +1x +  +1x +  +1x +  +1x +  +  +  +1x +  +  + 
'use strict';
+ 
+const
+    CoaParam = require('./coaparam'),
+    Color = require('./color');
+ 
+/**
+ * Argument
+ *
+ * Unnamed entity. From command line arguments passed as list of unnamed values.
+ *
+ * @class Arg
+ * @extends CoaParam
+ */
+module.exports = class Arg extends CoaParam {
+    /**
+     * @constructs
+     * @param {COA.Cmd} cmd - parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._cmd._args.push(this);
+    }
+ 
+    _saveVal(args, val) {
+        this._val && (val = this._val(val));
+ 
+        const name = this._name;
+        this._arr
+            ? (args[name] || (args[name] = [])).push(val)
+            : (args[name] = val);
+ 
+        return val;
+    }
+ 
+    _parse(arg, args) {
+        return this._saveVal(args, arg);
+    }
+ 
+    _checkParsed(opts, args) {
+        return !args.hasOwnProperty(this._name);
+    }
+ 
+    _usage() {
+        const res = [];
+ 
+        res.push(Color('lpurple', this._name.toUpperCase()), ' : ', this._title);
+ 
+        this._req && res.push(' ', Color('lred', '(required)'));
+ 
+        return res.join('');
+    }
+ 
+    _requiredText() {
+        return `Missing required argument:\n  ${this._usage()}`;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/cmd.js.html b/node_modules/coa/coverage/coa/lib/cmd.js.html new file mode 100644 index 00000000..03a50aca --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/cmd.js.html @@ -0,0 +1,1556 @@ + + + + Code coverage report for coa/lib/cmd.js + + + + + + + +
+
+

+ All files / coa/lib cmd.js +

+
+
+ 81.22% + Statements + 147/181 +
+
+ 71.64% + Branches + 96/134 +
+
+ 68.75% + Functions + 33/48 +
+
+ 82.53% + Lines + 137/166 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498  +  +  +1x +1x +1x +  +1x +  +1x +1x +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +26x +  +26x +26x +26x +26x +26x +26x +26x +26x +  +  +  +21x +  +  +  +  +  +  +  +  +  +  +2x +2x +1x +  +  +2x +2x +1x +  +2x +  +  +  +28x +  +28x +  +  +  +  +28x +  +  +  +44x +  +  +  +  +  +  +  +  +  +12x +  +12x +  +  +12x +  +  +  +  +  +  +  +  +  +7x +  +  +  +  +  +  +  +  +  +  +16x +  +  +  +  +  +  +  +  +16x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +16x +  +16x +16x +  +16x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +5x +5x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +19x +19x +1x +  +18x +  +  +  +  +  +22x +  +21x +  +21x +41x +2x +  +  +  +35x +  +  +35x +35x +75x +  +75x +62x +62x +  +  +13x +13x +5x +2x +  +  +  +3x +3x +3x +3x +4x +4x +1x +  +  +  +5x +5x +5x +3x +  +2x +2x +2x +  +  +  +  +5x +  +  +  +13x +  +5x +  +  +27x +  +  +  +24x +24x +24x +24x +  +  +24x +47x +19x +19x +1x +1x +  +  +19x +19x +  +18x +  +17x +  +  +28x +28x +  +  +28x +30x +30x +  +28x +28x +  +  +  +20x +  +  +  +  +  +  +44x +14x +  +  +  +44x +  +  +  +4x +  +4x +3x +  +3x +  +  +  +  +3x +3x +  +  +3x +4x +  +  +  +4x +  +  +  +24x +24x +  +  +  +  +  +  +  +26x +22x +  +  +44x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +3x +3x +3x +  +3x +1x +1x +1x +  +  +3x +3x +1x +  +2x +  +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +24x +  +  +  +5x +5x +  +  +  +  +  +1x + 
'use strict';
+ 
+const
+    UTIL = require('util'),
+    PATH = require('path'),
+    EOL = require('os').EOL,
+ 
+    Q = require('q'),
+ 
+    CoaObject = require('./coaobject'),
+    Color = require('./color'),
+    Opt = require('./opt'),
+    Arg = require('./arg'),
+    completion = require('./completion');
+ 
+/**
+ * Command
+ *
+ * Top level entity. Commands may have options and arguments.
+ *
+ * @namespace
+ * @class Cmd
+ * @extends CoaObject
+ */
+class Cmd extends CoaObject {
+    /**
+     * @constructs
+     * @param {COA.Cmd} [cmd] parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._parent(cmd);
+        this._cmds = [];
+        this._cmdsByName = {};
+        this._opts = [];
+        this._optsByKey = {};
+        this._args = [];
+        this._api = null;
+        this._ext = false;
+    }
+ 
+    static create(cmd) {
+        return new Cmd(cmd);
+    }
+ 
+    /**
+     * Returns object containing all its subcommands as methods
+     * to use from other programs.
+     *
+     * @returns {Object}
+     */
+    get api() {
+        // Need _this here because of passed arguments into _api
+        const _this = this;
+        this._api || (this._api = function () {
+            return _this.invoke.apply(_this, arguments);
+        });
+ 
+        const cmds = this._cmdsByName;
+        Object.keys(cmds).forEach((c) => {
+            this._api[c] = cmds[c].api;
+        });
+        return this._api;
+    }
+ 
+    _parent(cmd) {
+        this._cmd = cmd || this;
+ 
+        this.isRootCmd
+            || cmd._cmds.push(this)
+            && this._name
+            && (this._cmd._cmdsByName[this._name] = this);
+ 
+        return this;
+    }
+ 
+    get isRootCmd() {
+        return this._cmd === this;
+    }
+ 
+    /**
+     * Set a canonical command identifier to be used anywhere in the API.
+     *
+     * @param {String} name - command name
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    name(name) {
+        super.name(name);
+ 
+        this.isRootCmd
+            || (this._cmd._cmdsByName[name] = this);
+ 
+        return this;
+    }
+ 
+    /**
+     * Create new or add existing subcommand for current command.
+     *
+     * @param {COA.Cmd} [cmd] existing command instance
+     * @returns {COA.Cmd} new subcommand instance
+     */
+    cmd(cmd) {
+        return cmd?
+            cmd._parent(this)
+            : new Cmd(this);
+    }
+ 
+    /**
+     * Create option for current command.
+     *
+     * @returns {COA.Opt} new option instance
+     */
+    opt() {
+        return new Opt(this);
+    }
+ 
+    /**
+     * Create argument for current command.
+     *
+     * @returns {COA.Opt} new argument instance
+     */
+    arg() {
+        return new Arg(this);
+    }
+ 
+    /**
+     * Add (or set) action for current command.
+     *
+     * @param {Function} act - action function,
+     *         invoked in the context of command instance
+     *         and has the parameters:
+     *                 - {Object} opts - parsed options
+     *                 - {String[]} args - parsed arguments
+     *                 - {Object} res - actions result accumulator
+     *         It can return rejected promise by Cmd.reject (in case of error)
+     *         or any other value treated as result.
+     * @param {Boolean} [force=false] flag for set action instead add to existings
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    act(act, force) {
+        Iif(!act) return this;
+ 
+        (!this._act || force) && (this._act = []);
+        this._act.push(act);
+ 
+        return this;
+    }
+ 
+    /**
+     * Make command "helpful", i.e. add -h --help flags for print usage.
+     *
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    helpful() {
+        return this.opt()
+            .name('help')
+            .title('Help')
+            .short('h')
+            .long('help')
+            .flag()
+            .only()
+            .act(function() {
+                return this.usage();
+            })
+            .end();
+    }
+ 
+    /**
+     * Adds shell completion to command, adds "completion" subcommand,
+     * that makes all the magic.
+     * Must be called only on root command.
+     *
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    completable() {
+        return this.cmd()
+            .name('completion')
+            .apply(completion)
+            .end();
+    }
+ 
+    /**
+     * Allow command to be extendable by external node.js modules.
+     *
+     * @param {String} [pattern]  Pattern of node.js module to find subcommands at.
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    extendable(pattern) {
+        this._ext = pattern || true;
+        return this;
+    }
+ 
+    _exit(msg, code) {
+        return process.once('exit', function() {
+            msg && console.error(msg);
+            return process.exit(code || 0);
+        });
+    }
+ 
+    /**
+     * Build full usage text for current command instance.
+     *
+     * @returns {String} usage text
+     */
+    usage() {
+        const res = [];
+ 
+        this._title && res.push(this._fullTitle());
+ 
+        res.push('', 'Usage:');
+ 
+        this._cmds.length
+            && res.push([
+                '', '', Color('lred', this._fullName()), Color('lblue', 'COMMAND'),
+                Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
+            ].join(' '));
+ 
+        (this._opts.length + this._args.length)
+            && res.push([
+                '', '', Color('lred', this._fullName()),
+                Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')
+            ].join(' '));
+ 
+        res.push(
+            this._usages(this._cmds, 'Commands'),
+            this._usages(this._opts, 'Options'),
+            this._usages(this._args, 'Arguments')
+        );
+ 
+        return res.join(EOL);
+    }
+ 
+    _usage() {
+        return Color('lblue', this._name) + ' : ' + this._title;
+    }
+ 
+    _usages(os, title) {
+        if(!os.length) return;
+ 
+        return ['', title + ':']
+            .concat(os.map(o => `  ${o._usage()}`))
+            .join(EOL);
+    }
+ 
+    _fullTitle() {
+        return `${this.isRootCmd? '' : this._cmd._fullTitle() + EOL}${this._title}`;
+    }
+ 
+    _fullName() {
+        return `${this.isRootCmd? '' : this._cmd._fullName() + ' '}${PATH.basename(this._name)}`;
+    }
+ 
+    _ejectOpt(opts, opt) {
+        const pos = opts.indexOf(opt);
+        if(pos === -1)
+            return;
+ 
+        return opts[pos]._arr?
+            opts[pos]
+            : opts.splice(pos, 1)[0];
+    }
+ 
+    _checkRequired(opts, args) {
+        if(this._opts.some(opt => opt._only && opt._name in opts)) return;
+ 
+        const all = this._opts.concat(this._args);
+        let i;
+        while(i = all.shift())
+            if(i._req && i._checkParsed(opts, args))
+                return this.reject(i._requiredText());
+    }
+ 
+    _parseCmd(argv, unparsed) {
+        unparsed || (unparsed = []);
+ 
+        let i,
+            optSeen = false;
+        while(i = argv.shift()) {
+            i.indexOf('-') || (optSeen = true);
+ 
+            if(optSeen || !/^\w[\w-_]*$/.test(i)) {
+                unparsed.push(i);
+                continue;
+            }
+ 
+            let pkg, cmd = this._cmdsByName[i];
+            if(!cmd && this._ext) {
+                if(typeof this._ext === 'string') {
+                    pkg = ~this._ext.indexOf('%s')?
+                        UTIL.format(this._ext, i)
+                        : this._ext + i;
+ 
+                } else Eif(this._ext === true) {
+                    pkg = i;
+                    let c = this;
+                    while(true) { // eslint-disable-line
+                        pkg = c._name + '-' + pkg;
+                        if(c.isRootCmd) break;
+                        c = c._cmd;
+                    }
+                }
+ 
+                const cmdDesc = tryCatch(() => require(pkg));
+                Eif(cmdDesc) {
+                    if(typeof cmdDesc === 'function') {
+                        this.cmd().name(i).apply(cmdDesc).end();
+ 
+                    } else Eif(typeof cmdDesc === 'object') {
+                        this.cmd(cmdDesc);
+                        cmdDesc.name(i);
+ 
+                    } else throw new Error('Error: Unsupported command declaration type, '
+                        + 'should be a function or COA.Cmd() object');
+ 
+                    cmd = this._cmdsByName[i];
+                }
+            }
+ 
+            if(cmd) return cmd._parseCmd(argv, unparsed);
+ 
+            unparsed.push(i);
+        }
+ 
+        return { cmd : this, argv : unparsed };
+    }
+ 
+    _parseOptsAndArgs(argv) {
+        const opts = {},
+            args = {},
+            nonParsedOpts = this._opts.concat(),
+            nonParsedArgs = this._args.concat();
+ 
+        let res, i;
+        while(i = argv.shift()) {
+            if(i !== '--' && i[0] === '-') {
+                const m = i.match(/^(--\w[\w-_]*)=(.*)$/);
+                if(m) {
+                    i = m[1];
+                    this._optsByKey[i]._flag || argv.unshift(m[2]);
+                }
+ 
+                const opt = this._ejectOpt(nonParsedOpts, this._optsByKey[i]);
+                if(!opt) return this.reject(`Unknown option: ${i}`);
+ 
+                if(Q.isRejected(res = opt._parse(argv, opts))) return res;
+ 
+                continue;
+            }
+ 
+            i === '--' && (i = argv.splice(0));
+            Array.isArray(i) || (i = [i]);
+ 
+            let a;
+            while(a = i.shift()) {
+                let arg = nonParsedArgs.shift();
+                if(!arg) return this.reject(`Unknown argument: ${a}`);
+ 
+                arg._arr && nonParsedArgs.unshift(arg);
+                Iif(Q.isRejected(res = arg._parse(a, args))) return res;
+            }
+        }
+ 
+        return {
+            opts : this._setDefaults(opts, nonParsedOpts),
+            args : this._setDefaults(args, nonParsedArgs)
+        };
+    }
+ 
+    _setDefaults(params, desc) {
+        for(const item of desc)
+            item._def
+                && !(item._name in params)
+                && item._saveVal(params, item._def);
+ 
+        return params;
+    }
+ 
+    _processParams(params, desc) {
+        const notExists = [];
+ 
+        for(const item of desc) {
+            const n = item._name;
+ 
+            Iif(!(n in params)) {
+                notExists.push(item);
+                continue;
+            }
+ 
+            const vals = [].concat(params[n]);
+            delete params[n];
+ 
+            let res;
+            for(const v of vals)
+                Iif(Q.isRejected(res = item._saveVal(params, v)))
+                    return res;
+        }
+ 
+        return this._setDefaults(params, notExists);
+    }
+ 
+    _parseArr(argv) {
+        return Q.when(this._parseCmd(argv), (p) =>
+            Q.when(p.cmd._parseOptsAndArgs(p.argv), (r) => ({
+                cmd : p.cmd,
+                opts : r.opts,
+                args : r.args
+            })));
+    }
+ 
+    _do(inputPromise) {
+        return Q.when(inputPromise, (input) => {
+            return [this._checkRequired]
+                .concat(input.cmd._act || [])
+                .reduce((res, act) =>
+                    Q.when(res, (prev) => act.call(input.cmd, input.opts, input.args, prev)),
+                    void 0);
+        });
+    }
+ 
+    /**
+     * Parse arguments from simple format like NodeJS process.argv
+     * and run ahead current program, i.e. call process.exit when all actions done.
+     *
+     * @param {String[]} argv - arguments
+     * @returns {COA.Cmd} - this instance (for chainability)
+     */
+    run(argv) {
+        argv || (argv = process.argv.slice(2));
+ 
+        const cb = (code) => (res) => res?
+            this._exit(res.stack || res.toString(), res.exitCode || code)
+            : this._exit();
+ 
+        Q.when(this.do(argv), cb(0), cb(1)).done();
+ 
+        return this;
+    }
+ 
+    /**
+     * Invoke specified (or current) command using provided
+     * options and arguments.
+     *
+     * @param {String|String[]} [cmds] - subcommand to invoke (optional)
+     * @param {Object} [opts] - command options (optional)
+     * @param {Object} [args] - command arguments (optional)
+     * @returns {Q.Promise}
+     */
+    invoke(cmds, opts, args) {
+        cmds || (cmds = []);
+        opts || (opts = {});
+        args || (args = {});
+        typeof cmds === 'string' && (cmds = cmds.split(' '));
+ 
+        if(arguments.length < 3 && !Array.isArray(cmds)) {
+            args = opts;
+            opts = cmds;
+            cmds = [];
+        }
+ 
+        return Q.when(this._parseCmd(cmds), (p) => {
+            if(p.argv.length)
+                return this.reject(`Unknown command: ${cmds.join(' ')}`);
+ 
+            return Q.all([this._processParams(opts, this._opts), this._processParams(args, this._args)])
+                .spread((_opts, _args) =>
+                    this._do({
+                        cmd : p.cmd,
+                        opts : _opts,
+                        args : _args
+                    })
+                    .fail((res) => (res && res.exitCode === 0)?
+                        res.toString()
+                        : this.reject(res)));
+        });
+    }
+}
+ 
+/**
+ * Convenient function to run command from tests.
+ *
+ * @param {String[]} argv - arguments
+ * @returns {Q.Promise}
+ */
+Cmd.prototype.do = function(argv) {
+    return this._do(this._parseArr(argv || []));
+};
+ 
+function tryCatch(fn, cb) {
+    try {
+        return fn();
+    } catch(e) {
+        return cb(e);
+    }
+}
+ 
+module.exports = Cmd;
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/coaobject.js.html b/node_modules/coa/coverage/coa/lib/coaobject.js.html new file mode 100644 index 00000000..32dfc7f5 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/coaobject.js.html @@ -0,0 +1,365 @@ + + + + Code coverage report for coa/lib/coaobject.js + + + + + + + +
+
+

+ All files / coa/lib coaobject.js +

+
+
+ 75% + Statements + 12/16 +
+
+ 50% + Branches + 1/2 +
+
+ 71.43% + Functions + 5/7 +
+
+ 75% + Lines + 12/16 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +58x +58x +58x +58x +  +  +  +  +  +  +  +  +  +44x +44x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +  +  +  +3x +  +  +  +  +  +  +  +  +  +  +  +8x +  +  +  +  +  +  +  +38x +  +  + 
'use strict';
+ 
+const Q = require('q');
+ 
+/**
+ * COA Object
+ *
+ * Base class for all COA-related objects
+ *
+ * --------|-----|-----|-----
+ *         | Cmd | Opt | Arg
+ * --------|-----|-----|-----
+ *  name   | ✓   | ✓   | ✓
+ *  title  | ✓   | ✓   | ✓
+ *  comp   | ✓   | ✓   | ✓
+ *  reject | ✓   | ✓   | ✓
+ *  end    | ✓   | ✓   | ✓
+ *  apply  | ✓   | ✓   | ✓
+ *
+ * @class CoaObject
+ */
+module.exports = class CoaObject {
+    constructor(cmd) {
+        this._cmd = cmd;
+        this._name = null;
+        this._title = null;
+        this._comp = null;
+    }
+ 
+    /**
+     * Set a canonical identifier to be used anywhere in the API.
+     *
+     * @param {String} name - command, option or argument name
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    name(name) {
+        this._name = name;
+        return this;
+    }
+ 
+    /**
+     * Set a long description to be used anywhere in text messages.
+     * @param {String} title - human readable entity title
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    title(title) {
+        this._title = title;
+        return this;
+    }
+ 
+    /**
+     * Set custom additional completion for current object.
+     *
+     * @param {Function} comp - completion generation function,
+     *         invoked in the context of object instance.
+     *         Accepts parameters:
+     *                 - {Object} opts - completion options
+     *         It can return promise or any other value threated as a result.
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    comp(comp) {
+        this._comp = comp;
+        return this;
+    }
+ 
+    /**
+     * Apply function with arguments in a context of object instance.
+     *
+     * @param {Function} fn - body
+     * @param {Array.<*>} args... - arguments
+     * @returns {COA.CoaObject} - this instance (for chainability)
+     */
+    apply(fn) {
+        arguments.length > 1?
+            fn.apply(this, [].slice.call(arguments, 1))
+            : fn.call(this);
+ 
+        return this;
+    }
+ 
+    /**
+     * Return reject of actions results promise with error code.
+     * Use in .act() for return with error.
+     * @param {Object} reason - reject reason
+     *         You can customize toString() method and exitCode property
+     *         of reason object.
+     * @returns {Q.promise} rejected promise
+     */
+    reject(reason) {
+        return Q.reject(reason);
+    }
+ 
+    /**
+     * Finish chain for current subcommand and return parent command instance.
+     * @returns {COA.Cmd} parent command
+     */
+    end() {
+        return this._cmd;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/coaparam.js.html b/node_modules/coa/coverage/coa/lib/coaparam.js.html new file mode 100644 index 00000000..b8bc9bd8 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/coaparam.js.html @@ -0,0 +1,440 @@ + + + + Code coverage report for coa/lib/coaparam.js + + + + + + + +
+
+

+ All files / coa/lib coaparam.js +

+
+
+ 51.61% + Statements + 16/31 +
+
+ 0% + Branches + 0/8 +
+
+ 55.56% + Functions + 5/9 +
+
+ 51.61% + Lines + 16/31 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126  +  +1x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +32x +  +32x +32x +32x +32x +  +  +  +  +  +  +  +  +  +9x +9x +  +  +  +  +  +  +  +  +3x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
'use strict';
+ 
+const fs = require('fs');
+ 
+const CoaObject = require('./coaobject');
+ 
+/**
+ * COA Parameter
+ *
+ * Base class for options and arguments
+ *
+ * --------|-----|-----|-----
+ *         | Cmd | Opt | Arg
+ * --------|-----|-----|-----
+ *  arr    |     | ✓   | ✓
+ *  req    |     | ✓   | ✓
+ *  val    |     | ✓   | ✓
+ *  def    |     | ✓   | ✓
+ *  input  |     | ✓   | ✓
+ *  output |     | ✓   | ✓
+ *
+ * @class CoaParam
+ * @extends CoaObject
+ */
+module.exports = class CoaParam extends CoaObject {
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._arr = false;
+        this._req = false;
+        this._val = undefined;
+        this._def = undefined;
+    }
+ 
+    /**
+     * Makes a param accepts multiple values.
+     * Otherwise, the value will be used by the latter passed.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    arr() {
+        this._arr = true;
+        return this;
+    }
+ 
+    /**
+     * Makes a param required.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    req() {
+        this._req = true;
+        return this;
+    }
+ 
+    /**
+     * Set a validation (or value) function for param.
+     * Value from command line passes through before becoming available from API.
+     * Using for validation and convertion simple types to any values.
+     *
+     * @param {Function} val - validating function,
+     *         invoked in the context of option instance
+     *         and has one parameter with value from command line.
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    val(val) {
+        this._val = val;
+        return this;
+    }
+ 
+    /**
+     * Set a default value for param.
+     * Default value passed through validation function as ordinary value.
+     *
+     * @param {*} def - default value of function generator
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    def(def) {
+        this._def = def;
+        return this;
+    }
+ 
+    /**
+     * Make option value inputting stream.
+     * It's add useful validation and shortcut for STDIN.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    input() {
+        process.stdin.pause();
+        return this
+            .def(process.stdin)
+            .val(function(v) {
+                if(typeof v !== 'string')
+                    return v;
+ 
+                if(v === '-')
+                    return process.stdin;
+ 
+                const s = fs.createReadStream(v, { encoding : 'utf8' });
+                s.pause();
+                return s;
+            });
+    }
+ 
+    /**
+     * Make option value outputing stream.
+     * It's add useful validation and shortcut for STDOUT.
+     *
+     * @returns {COA.CoaParam} - this instance (for chainability)
+     */
+    output() {
+        return this
+            .def(process.stdout)
+            .val(function(v) {
+                if(typeof v !== 'string')
+                    return v;
+ 
+                if(v === '-')
+                    return process.stdout;
+ 
+                return fs.createWriteStream(v, { encoding : 'utf8' });
+            });
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/color.js.html b/node_modules/coa/coverage/coa/lib/color.js.html new file mode 100644 index 00000000..14531caf --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/color.js.html @@ -0,0 +1,131 @@ + + + + Code coverage report for coa/lib/color.js + + + + + + + +
+
+

+ All files / coa/lib color.js +

+
+
+ 100% + Statements + 3/3 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x + 
'use strict';
+ 
+const colors = {
+    black : '30',
+    dgray : '1;30',
+    red : '31',
+    lred : '1;31',
+    green : '32',
+    lgreen : '1;32',
+    brown : '33',
+    yellow : '1;33',
+    blue : '34',
+    lblue : '1;34',
+    purple : '35',
+    lpurple : '1;35',
+    cyan : '36',
+    lcyan : '1;36',
+    lgray : '37',
+    white : '1;37'
+};
+ 
+module.exports = (c, str) => `\x1B[${colors[c]}m${str}\x1B[m`;
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/completion.js.html b/node_modules/coa/coverage/coa/lib/completion.js.html new file mode 100644 index 00000000..fb042e25 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/completion.js.html @@ -0,0 +1,593 @@ + + + + Code coverage report for coa/lib/completion.js + + + + + + + +
+
+

+ All files / coa/lib completion.js +

+
+
+ 11.27% + Statements + 8/71 +
+
+ 0% + Branches + 0/32 +
+
+ 0% + Functions + 0/14 +
+
+ 12.5% + Lines + 8/64 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177  +  +1x +1x +1x +  +1x +  +1x +1x +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
'use strict';
+ 
+const constants = require('constants');
+const fs = require('fs');
+const path = require('path');
+ 
+const Q = require('q');
+ 
+const shell = require('./shell');
+const escape = shell.escape;
+const unescape = shell.unescape;
+ 
+/**
+ * Most of the code adopted from the npm package shell completion code.
+ * See https://github.com/isaacs/npm/blob/master/lib/completion.js
+ *
+ * @returns {COA.CoaObject}
+ */
+module.exports = function completion() {
+    return this
+        .title('Shell completion')
+        .helpful()
+        .arg()
+            .name('raw')
+            .title('Completion words')
+            .arr()
+            .end()
+        .act((opts, args) => {
+            if(process.platform === 'win32') {
+                const e = new Error('shell completion not supported on windows');
+                e.code = 'ENOTSUP';
+                e.errno = constants.ENOTSUP;
+                return this.reject(e);
+            }
+ 
+            // if the COMP_* isn't in the env, then just dump the script
+            if((process.env.COMP_CWORD == null)
+                || (process.env.COMP_LINE == null)
+                || (process.env.COMP_POINT == null)) {
+                return dumpScript(this._cmd._name);
+            }
+ 
+            console.error('COMP_LINE:  %s', process.env.COMP_LINE);
+            console.error('COMP_CWORD: %s', process.env.COMP_CWORD);
+            console.error('COMP_POINT: %s', process.env.COMP_POINT);
+            console.error('args: %j', args.raw);
+ 
+            // completion opts
+            opts = getOpts(args.raw);
+ 
+            // cmd
+            const parsed = this._cmd._parseCmd(opts.partialWords);
+            return Q.when(complete(parsed.cmd, parsed.opts), (compls) => {
+                console.error('filtered: %j', compls);
+                return console.log(compls.map(escape).join('\n'));
+            });
+        });
+};
+ 
+function dumpScript(name) {
+    const defer = Q.defer();
+ 
+    fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', function(err, d) {
+        if(err) return defer.reject(err);
+        d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, '');
+ 
+        process.stdout.on('error', onError);
+        process.stdout.write(d, () => defer.resolve());
+    });
+ 
+    return defer.promise;
+ 
+    function onError(err) {
+        // Darwin is a real dick sometimes.
+        //
+        // This is necessary because the "source" or "." program in
+        // bash on OS X closes its file argument before reading
+        // from it, meaning that you get exactly 1 write, which will
+        // work most of the time, and will always raise an EPIPE.
+        //
+        // Really, one should not be tossing away EPIPE errors, or any
+        // errors, so casually. But, without this, `. <(cmd completion)`
+        // can never ever work on OS X.
+        if(err.errno !== constants.EPIPE) return defer.reject(err);
+        process.stdout.removeListener('error', onError);
+        return defer.resolve();
+    }
+}
+ 
+function getOpts(argv) {
+    // get the partial line and partial word, if the point isn't at the end
+    // ie, tabbing at: cmd foo b|ar
+    const line = process.env.COMP_LINE;
+    const w = +process.env.COMP_CWORD;
+    const point = +process.env.COMP_POINT;
+    const words = argv.map(unescape);
+    const word = words[w];
+    const partialLine = line.substr(0, point);
+    const partialWords = words.slice(0, w);
+ 
+    // figure out where in that last word the point is
+    let partialWord = argv[w] || '';
+    let i = partialWord.length;
+    while(partialWord.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) i--;
+ 
+    partialWord = unescape(partialWord.substr(0, i));
+    partialWord && partialWords.push(partialWord);
+ 
+    return {
+        line,
+        w,
+        point,
+        words,
+        word,
+        partialLine,
+        partialWords,
+        partialWord
+    };
+}
+ 
+function complete(cmd, opts) {
+    let optWord, optPrefix,
+        compls = [];
+ 
+    // Complete on cmds
+    if(opts.partialWord.indexOf('-'))
+        compls = Object.keys(cmd._cmdsByName);
+        // Complete on required opts without '-' in last partial word
+        // (if required not already specified)
+        //
+        // Commented out because of uselessness:
+        // -b, --block suggest results in '-' on cmd line;
+        // next completion suggest all options, because of '-'
+        //.concat Object.keys(cmd._optsByKey).filter (v) -> cmd._optsByKey[v]._req
+    else {
+        // complete on opt values: --opt=| case
+        const m = opts.partialWord.match(/^(--\w[\w-_]*)=(.*)$/);
+        if(m) {
+            optWord = m[1];
+            optPrefix = optWord + '=';
+        } else
+            // complete on opts
+            // don't complete on opts in case of --opt=val completion
+            // TODO: don't complete on opts in case of unknown arg after commands
+            // TODO: complete only on opts with arr() or not already used
+            // TODO: complete only on full opts?
+            compls = Object.keys(cmd._optsByKey);
+    }
+ 
+    // complete on opt values: next arg case
+    opts.partialWords[opts.w - 1].indexOf('-') || (optWord = opts.partialWords[opts.w - 1]);
+ 
+    // complete on opt values: completion
+    let opt;
+    optWord
+        && (opt = cmd._optsByKey[optWord])
+        && !opt._flag
+        && opt._comp
+        && (compls = Q.join(compls,
+            Q.when(opt._comp(opts),
+                (c, o) => c.concat(o.map(v => (optPrefix || '') + v)))));
+ 
+    // TODO: complete on args values (context aware, custom completion?)
+ 
+    // custom completion on cmds
+    cmd._comp && (compls = Q.join(compls, Q.when(cmd._comp(opts)), (c, o) => c.concat(o)));
+ 
+    // TODO: context aware custom completion on cmds, opts and args
+    // (can depend on already entered values, especially options)
+ 
+    return Q.when(compls, complitions => {
+        console.error('partialWord: %s', opts.partialWord);
+        console.error('compls: %j', complitions);
+        return compls.filter((c) => c.indexOf(opts.partialWord) === 0);
+    });
+}
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/index.html b/node_modules/coa/coverage/coa/lib/index.html new file mode 100644 index 00000000..a9301282 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/index.html @@ -0,0 +1,197 @@ + + + + Code coverage report for coa/lib + + + + + + + +
+
+

+ All files coa/lib +

+
+
+ 68.17% + Statements + 257/377 +
+
+ 59.05% + Branches + 124/210 +
+
+ 65.35% + Functions + 66/101 +
+
+ 69.8% + Lines + 245/351 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
arg.js
100%16/1687.5%7/8100%6/6100%16/16
cmd.js
81.22%147/18171.64%96/13468.75%33/4882.53%137/166
coaobject.js
75%12/1650%1/271.43%5/775%12/16
coaparam.js
51.61%16/310%0/855.56%5/951.61%16/31
color.js
100%3/3100%0/0100%1/1100%2/2
completion.js
11.27%8/710%0/320%0/1412.5%8/64
index.js
100%5/5100%0/0100%0/0100%5/5
opt.js
91.84%45/4972.73%16/22100%14/1495.65%44/46
shell.js
100%5/5100%4/4100%2/2100%5/5
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/index.js.html b/node_modules/coa/coverage/coa/lib/index.js.html new file mode 100644 index 00000000..cfc7c0f0 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/index.js.html @@ -0,0 +1,107 @@ + + + + Code coverage report for coa/lib/index.js + + + + + + + +
+
+

+ All files / coa/lib index.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15  +1x +1x +1x +1x +  +1x +  +  +  +  +  +  +  + 
const
+    Cmd = require('./cmd'),
+    Opt = require('./opt'),
+    Arg = require('./arg'),
+    shell = require('./shell');
+ 
+module.exports = {
+    Cmd : Cmd.create,
+    Opt : Opt.create,
+    Arg : Arg.create,
+    classes : { Cmd, Opt, Arg },
+    shell,
+    require
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/opt.js.html b/node_modules/coa/coverage/coa/lib/opt.js.html new file mode 100644 index 00000000..74e05c28 --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/opt.js.html @@ -0,0 +1,524 @@ + + + + Code coverage report for coa/lib/opt.js + + + + + + + +
+
+

+ All files / coa/lib opt.js +

+
+
+ 91.84% + Statements + 45/49 +
+
+ 72.73% + Branches + 16/22 +
+
+ 100% + Functions + 14/14 +
+
+ 95.65% + Lines + 44/46 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154  +  +  +1x +  +1x +1x +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +16x +  +16x +16x +16x +16x +16x +  +  +  +  +  +  +  +  +  +7x +7x +7x +  +  +  +  +  +  +  +  +  +9x +9x +9x +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +1x +1x +  +1x +2x +  +  +  +  +1x +  +  +  +20x +  +20x +20x +  +  +  +20x +  +  +  +18x +  +  +  +2x +  +  +  +1x +1x +  +1x +1x +1x +1x +  +  +1x +  +  +  +  +1x +  +1x +  +1x +  +  +  +1x +  +  + 
'use strict';
+ 
+const
+    Q = require('q'),
+ 
+    CoaParam = require('./coaparam'),
+    Color = require('./color');
+ 
+/**
+ * Option
+ *
+ * Named entity. Options may have short and long keys for use from command line.
+ *
+ * @namespace
+ * @class Opt
+ * @extends CoaParam
+ */
+module.exports = class Opt extends CoaParam {
+    /**
+     * @constructs
+     * @param {COA.Cmd} cmd - parent command
+     */
+    constructor(cmd) {
+        super(cmd);
+ 
+        this._short = null;
+        this._long = null;
+        this._flag = false;
+        this._only = false;
+        this._cmd._opts.push(this);
+    }
+ 
+    /**
+     * Set a short key for option to be used with one hyphen from command line.
+     *
+     * @param {String} short - short name
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    short(short) {
+        this._short = short;
+        this._cmd._optsByKey[`-${short}`] = this;
+        return this;
+    }
+ 
+    /**
+     * Set a short key for option to be used with double hyphens from command line.
+     *
+     * @param {String} long - long name
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    long(long) {
+        this._long = long;
+        this._cmd._optsByKey[`--${long}`] = this;
+        return this;
+    }
+ 
+    /**
+     * Make an option boolean, i.e. option without value.
+     *
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    flag() {
+        this._flag = true;
+        return this;
+    }
+ 
+    /**
+     * Makes an option to act as a command,
+     * i.e. program will exit just after option action.
+     *
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    only() {
+        this._only = true;
+        return this;
+    }
+ 
+    /**
+     * Add action for current option command.
+     * This action is performed if the current option
+     * is present in parsed options (with any value).
+     *
+     * @param {Function} act - action function,
+     *         invoked in the context of command instance
+     *         and has the parameters:
+     *                 - {Object} opts - parsed options
+     *                 - {Array} args - parsed arguments
+     *                 - {Object} res - actions result accumulator
+     *         It can return rejected promise by Cmd.reject (in case of error)
+     *         or any other value treated as result.
+     * @returns {COA.Opt} - this instance (for chainability)
+     */
+    act(act) {
+        this._cmd.act((opts) => {
+            Iif(!opts.hasOwnProperty(this._name)) return;
+ 
+            const res = act.apply(this._cmd, arguments);
+            Iif(!this._only) return res;
+ 
+            return Q.when(res, (out) => this._cmd.reject({
+                toString : () => out.toString(),
+                exitCode : 0
+            }));
+        });
+ 
+        return this;
+    }
+ 
+    _saveVal(opts, val) {
+        this._val && (val = this._val(val));
+ 
+        const name = this._name;
+        this._arr
+            ? (opts[name] || (opts[name] = [])).push(val)
+            : (opts[name] = val);
+ 
+        return val;
+    }
+ 
+    _parse(argv, opts) {
+        return this._saveVal(opts, this._flag ? true : argv.shift());
+    }
+ 
+    _checkParsed(opts) {
+        return !opts.hasOwnProperty(this._name);
+    }
+ 
+    _usage() {
+        const res = [],
+            nameStr = this._name.toUpperCase();
+ 
+        Eif(this._short) {
+            res.push('-', Color('lgreen', this._short));
+            this._flag || res.push(' ' + nameStr);
+            res.push(', ');
+        }
+ 
+        Iif(this._long) {
+            res.push('--', Color('green', this._long));
+            this._flag || res.push('=' + nameStr);
+        }
+ 
+        res.push(' : ', this._title);
+ 
+        this._req && res.push(' ', Color('lred', '(required)'));
+ 
+        return res.join('');
+    }
+ 
+    _requiredText() {
+        return `Missing required option:\n  ${this._usage()}`;
+    }
+};
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/coa/lib/shell.js.html b/node_modules/coa/coverage/coa/lib/shell.js.html new file mode 100644 index 00000000..b98935af --- /dev/null +++ b/node_modules/coa/coverage/coa/lib/shell.js.html @@ -0,0 +1,107 @@ + + + + Code coverage report for coa/lib/shell.js + + + + + + + +
+
+

+ All files / coa/lib shell.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 4/4 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +151x +  +  +2x +  +  +  +2x +  +  +  +6x +6x +  + 
module.exports = { escape, unescape };
+ 
+function unescape(w) {
+    w = w.charAt(0) === '"'
+        ? w.replace(/^"|([^\\])"$/g, '$1')
+        : w.replace(/\\ /g, ' ');
+ 
+    return w.replace(/\\("|'|\$|`|\\)/g, '$1');
+}
+ 
+function escape(w) {
+    w = w.replace(/(["'$`\\])/g,'\\$1');
+    return w.match(/\s+/) ? `"${w}"` : w;
+}
+ 
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/index.html b/node_modules/coa/coverage/index.html new file mode 100644 index 00000000..ee3d492f --- /dev/null +++ b/node_modules/coa/coverage/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for All files + + + + + + + +
+
+

+ All files +

+
+
+ 68.25% + Statements + 258/378 +
+
+ 59.05% + Branches + 124/210 +
+
+ 65.35% + Functions + 66/101 +
+
+ 69.89% + Lines + 246/352 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
coa
100%1/1100%0/0100%0/0100%1/1
coa/lib
68.17%257/37759.05%124/21065.35%66/10169.8%245/351
+
+
+ + + + + + + diff --git a/node_modules/coa/coverage/prettify.css b/node_modules/coa/coverage/prettify.css new file mode 100644 index 00000000..b317a7cd --- /dev/null +++ b/node_modules/coa/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/node_modules/coa/coverage/prettify.js b/node_modules/coa/coverage/prettify.js new file mode 100644 index 00000000..ef51e038 --- /dev/null +++ b/node_modules/coa/coverage/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/node_modules/coa/coverage/sort-arrow-sprite.png b/node_modules/coa/coverage/sort-arrow-sprite.png new file mode 100644 index 00000000..03f704a6 Binary files /dev/null and b/node_modules/coa/coverage/sort-arrow-sprite.png differ diff --git a/node_modules/coa/coverage/sorter.js b/node_modules/coa/coverage/sorter.js new file mode 100644 index 00000000..6c5034e4 --- /dev/null +++ b/node_modules/coa/coverage/sorter.js @@ -0,0 +1,158 @@ +var addSorting = (function () { + "use strict"; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { return document.querySelector('.coverage-summary'); } + // returns the thead element of the summary table + function getTableHeader() { return getTable().querySelector('thead tr'); } + // returns the tbody element of the summary table + function getTableBody() { return getTable().querySelector('tbody'); } + // returns the th element for nth column + function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i =0 ; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); -- cgit v1.2.3