8fb5ef18e7
* Ensure caniuse-lite data is external for nccing * lint * ensure assetBuilds config is set * update compiled
17 lines
No EOL
34 KiB
JavaScript
17 lines
No EOL
34 KiB
JavaScript
(()=>{var e={254:(e,t,r)=>{var n=r(361).EventEmitter;var o=r(81).spawn;var i=r(17);var s=i.dirname;var a=i.basename;var u=r(147);r(837).inherits(Command,n);t=e.exports=new Command;t.Command=Command;t.Option=Option;function Option(e,t){this.flags=e;this.required=~e.indexOf("<");this.optional=~e.indexOf("[");this.bool=!~e.indexOf("-no-");e=e.split(/[ ,|]+/);if(e.length>1&&!/^[[<]/.test(e[1]))this.short=e.shift();this.long=e.shift();this.description=t||""}Option.prototype.name=function(){return this.long.replace("--","").replace("no-","")};Option.prototype.attributeName=function(){return camelcase(this.name())};Option.prototype.is=function(e){return this.short===e||this.long===e};function Command(e){this.commands=[];this.options=[];this._execs={};this._allowUnknownOption=false;this._args=[];this._name=e||""}Command.prototype.command=function(e,t,r){if(typeof t==="object"&&t!==null){r=t;t=null}r=r||{};var n=e.split(/ +/);var o=new Command(n.shift());if(t){o.description(t);this.executables=true;this._execs[o._name]=true;if(r.isDefault)this.defaultExecutable=o._name}o._noHelp=!!r.noHelp;this.commands.push(o);o.parseExpectedArgs(n);o.parent=this;if(t)return this;return o};Command.prototype.arguments=function(e){return this.parseExpectedArgs(e.split(/ +/))};Command.prototype.addImplicitHelpCommand=function(){this.command("help [cmd]","display help for [cmd]")};Command.prototype.parseExpectedArgs=function(e){if(!e.length)return;var t=this;e.forEach((function(e){var r={required:false,name:"",variadic:false};switch(e[0]){case"<":r.required=true;r.name=e.slice(1,-1);break;case"[":r.name=e.slice(1,-1);break}if(r.name.length>3&&r.name.slice(-3)==="..."){r.variadic=true;r.name=r.name.slice(0,-3)}if(r.name){t._args.push(r)}}));return this};Command.prototype.action=function(e){var t=this;var listener=function(r,n){r=r||[];n=n||[];var o=t.parseOptions(n);outputHelpIfNecessary(t,o.unknown);if(o.unknown.length>0){t.unknownOption(o.unknown[0])}if(o.args.length)r=o.args.concat(r);t._args.forEach((function(e,n){if(e.required&&r[n]==null){t.missingArgument(e.name)}else if(e.variadic){if(n!==t._args.length-1){t.variadicArgNotLast(e.name)}r[n]=r.splice(n)}}));if(t._args.length){r[t._args.length]=t}else{r.push(t)}e.apply(t,r)};var r=this.parent||this;var n=r===this?"*":this._name;r.on("command:"+n,listener);if(this._alias)r.on("command:"+this._alias,listener);return this};Command.prototype.option=function(e,t,r,n){var o=this,i=new Option(e,t),s=i.name(),a=i.attributeName();if(typeof r!=="function"){if(r instanceof RegExp){var u=r;r=function(e,t){var r=u.exec(e);return r?r[0]:t}}else{n=r;r=null}}if(!i.bool||i.optional||i.required){if(!i.bool)n=true;if(n!==undefined){o[a]=n;i.defaultValue=n}}this.options.push(i);this.on("option:"+s,(function(e){if(e!==null&&r){e=r(e,o[a]===undefined?n:o[a])}if(typeof o[a]==="boolean"||typeof o[a]==="undefined"){if(e==null){o[a]=i.bool?n||true:false}else{o[a]=e}}else if(e!==null){o[a]=e}}));return this};Command.prototype.allowUnknownOption=function(e){this._allowUnknownOption=arguments.length===0||e;return this};Command.prototype.parse=function(e){if(this.executables)this.addImplicitHelpCommand();this.rawArgs=e;this._name=this._name||a(e[1],".js");if(this.executables&&e.length<3&&!this.defaultExecutable){e.push("--help")}var t=this.parseOptions(this.normalize(e.slice(2)));var r=this.args=t.args;var n=this.parseArgs(this.args,t.unknown);var o=n.args[0];var i=null;if(o){i=this.commands.filter((function(e){return e.alias()===o}))[0]}if(this._execs[o]&&typeof this._execs[o]!=="function"){return this.executeSubCommand(e,r,t.unknown)}else if(i){r[0]=i._name;return this.executeSubCommand(e,r,t.unknown)}else if(this.defaultExecutable){r.unshift(this.defaultExecutable);return this.executeSubCommand(e,r,t.unknown)}return n};Command.prototype.executeSubCommand=function(e,t,r){t=t.concat(r);if(!t.length)this.help();if(t[0]==="help"&&t.length===1)this.help();if(t[0]==="help"){t[0]=t[1];t[1]="--help"}var n=e[1];var l=a(n,".js")+"-"+t[0];var c,f=u.lstatSync(n).isSymbolicLink()?u.readlinkSync(n):n;if(f!==n&&f.charAt(0)!=="/"){f=i.join(s(n),f)}c=s(f);var p=i.join(c,l);var h=false;if(exists(p+".js")){l=p+".js";h=true}else if(exists(p)){l=p}t=t.slice(1);var m;if(process.platform!=="win32"){if(h){t.unshift(l);t=(process.execArgv||[]).concat(t);m=o(process.argv[0],t,{stdio:"inherit",customFds:[0,1,2]})}else{m=o(l,t,{stdio:"inherit",customFds:[0,1,2]})}}else{t.unshift(l);m=o(process.execPath,t,{stdio:"inherit"})}var d=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];d.forEach((function(e){process.on(e,(function(){if(m.killed===false&&m.exitCode===null){m.kill(e)}}))}));m.on("close",process.exit.bind(process));m.on("error",(function(e){if(e.code==="ENOENT"){console.error("\n %s(1) does not exist, try --help\n",l)}else if(e.code==="EACCES"){console.error("\n %s(1) not executable. try chmod or run with root\n",l)}process.exit(1)}));this.runningCommand=m};Command.prototype.normalize=function(e){var t=[],r,n,o;for(var i=0,s=e.length;i<s;++i){r=e[i];if(i>0){n=this.optionFor(e[i-1])}if(r==="--"){t=t.concat(e.slice(i));break}else if(n&&n.required){t.push(r)}else if(r.length>1&&r[0]==="-"&&r[1]!=="-"){r.slice(1).split("").forEach((function(e){t.push("-"+e)}))}else if(/^--/.test(r)&&~(o=r.indexOf("="))){t.push(r.slice(0,o),r.slice(o+1))}else{t.push(r)}}return t};Command.prototype.parseArgs=function(e,t){var r;if(e.length){r=e[0];if(this.listeners("command:"+r).length){this.emit("command:"+e.shift(),e,t)}else{this.emit("command:*",e)}}else{outputHelpIfNecessary(this,t);if(t.length>0){this.unknownOption(t[0])}}return this};Command.prototype.optionFor=function(e){for(var t=0,r=this.options.length;t<r;++t){if(this.options[t].is(e)){return this.options[t]}}};Command.prototype.parseOptions=function(e){var t=[],r=e.length,n,o,i;var s=[];for(var a=0;a<r;++a){i=e[a];if(n){t.push(i);continue}if(i==="--"){n=true;continue}o=this.optionFor(i);if(o){if(o.required){i=e[++a];if(i==null)return this.optionMissingArgument(o);this.emit("option:"+o.name(),i)}else if(o.optional){i=e[a+1];if(i==null||i[0]==="-"&&i!=="-"){i=null}else{++a}this.emit("option:"+o.name(),i)}else{this.emit("option:"+o.name())}continue}if(i.length>1&&i[0]==="-"){s.push(i);if(a+1<e.length&&e[a+1][0]!=="-"){s.push(e[++a])}continue}t.push(i)}return{args:t,unknown:s}};Command.prototype.opts=function(){var e={},t=this.options.length;for(var r=0;r<t;r++){var n=this.options[r].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e};Command.prototype.missingArgument=function(e){console.error();console.error(" error: missing required argument `%s'",e);console.error();process.exit(1)};Command.prototype.optionMissingArgument=function(e,t){console.error();if(t){console.error(" error: option `%s' argument missing, got `%s'",e.flags,t)}else{console.error(" error: option `%s' argument missing",e.flags)}console.error();process.exit(1)};Command.prototype.unknownOption=function(e){if(this._allowUnknownOption)return;console.error();console.error(" error: unknown option `%s'",e);console.error();process.exit(1)};Command.prototype.variadicArgNotLast=function(e){console.error();console.error(" error: variadic arguments must be last `%s'",e);console.error();process.exit(1)};Command.prototype.version=function(e,t){if(arguments.length===0)return this._version;this._version=e;t=t||"-V, --version";var r=new Option(t,"output the version number");this._versionOptionName=r.long.substr(2)||"version";this.options.push(r);this.on("option:"+this._versionOptionName,(function(){process.stdout.write(e+"\n");process.exit(0)}));return this};Command.prototype.description=function(e,t){if(arguments.length===0)return this._description;this._description=e;this._argsDescription=t;return this};Command.prototype.alias=function(e){var t=this;if(this.commands.length!==0){t=this.commands[this.commands.length-1]}if(arguments.length===0)return t._alias;if(e===t._name)throw new Error("Command alias can't be the same as its name");t._alias=e;return this};Command.prototype.usage=function(e){var t=this._args.map((function(e){return humanReadableArgName(e)}));var r="[options]"+(this.commands.length?" [command]":"")+(this._args.length?" "+t.join(" "):"");if(arguments.length===0)return this._usage||r;this._usage=e;return this};Command.prototype.name=function(e){if(arguments.length===0)return this._name;this._name=e;return this};Command.prototype.prepareCommands=function(){return this.commands.filter((function(e){return!e._noHelp})).map((function(e){var t=e._args.map((function(e){return humanReadableArgName(e)})).join(" ");return[e._name+(e._alias?"|"+e._alias:"")+(e.options.length?" [options]":"")+(t?" "+t:""),e._description]}))};Command.prototype.largestCommandLength=function(){var e=this.prepareCommands();return e.reduce((function(e,t){return Math.max(e,t[0].length)}),0)};Command.prototype.largestOptionLength=function(){var e=[].slice.call(this.options);e.push({flags:"-h, --help"});return e.reduce((function(e,t){return Math.max(e,t.flags.length)}),0)};Command.prototype.largestArgLength=function(){return this._args.reduce((function(e,t){return Math.max(e,t.name.length)}),0)};Command.prototype.padWidth=function(){var e=this.largestOptionLength();if(this._argsDescription&&this._args.length){if(this.largestArgLength()>e){e=this.largestArgLength()}}if(this.commands&&this.commands.length){if(this.largestCommandLength()>e){e=this.largestCommandLength()}}return e};Command.prototype.optionHelp=function(){var e=this.padWidth();return this.options.map((function(t){return pad(t.flags,e)+" "+t.description+(t.bool&&t.defaultValue!==undefined?" (default: "+t.defaultValue+")":"")})).concat([pad("-h, --help",e)+" "+"output usage information"]).join("\n")};Command.prototype.commandHelp=function(){if(!this.commands.length)return"";var e=this.prepareCommands();var t=this.padWidth();return[" Commands:","",e.map((function(e){var r=e[1]?" "+e[1]:"";return(r?pad(e[0],t):e[0])+r})).join("\n").replace(/^/gm," "),""].join("\n")};Command.prototype.helpInformation=function(){var e=[];if(this._description){e=[" "+this._description,""];var t=this._argsDescription;if(t&&this._args.length){var r=this.padWidth();e.push(" Arguments:");e.push("");this._args.forEach((function(n){e.push(" "+pad(n.name,r)+" "+t[n.name])}));e.push("")}}var n=this._name;if(this._alias){n=n+"|"+this._alias}var o=[""," Usage: "+n+" "+this.usage(),""];var i=[];var s=this.commandHelp();if(s)i=[s];var a=[" Options:","",""+this.optionHelp().replace(/^/gm," "),""];return o.concat(e).concat(a).concat(i).join("\n")};Command.prototype.outputHelp=function(e){if(!e){e=function(e){return e}}process.stdout.write(e(this.helpInformation()));this.emit("--help")};Command.prototype.help=function(e){this.outputHelp(e);process.exit()};function camelcase(e){return e.split("-").reduce((function(e,t){return e+t[0].toUpperCase()+t.slice(1)}))}function pad(e,t){var r=Math.max(0,t-e.length);return e+Array(r+1).join(" ")}function outputHelpIfNecessary(e,t){t=t||[];for(var r=0;r<t.length;r++){if(t[r]==="--help"||t[r]==="-h"){e.outputHelp();process.exit(0)}}}function humanReadableArgName(e){var t=e.name+(e.variadic===true?"...":"");return e.required?"<"+t+">":"["+t+"]"}function exists(e){try{if(u.statSync(e).isFile()){return true}}catch(e){return false}}},130:(e,t,r)=>{"use strict";var n=r(666);var o=[];e.exports=asap;function asap(e){var t;if(o.length){t=o.pop()}else{t=new RawTask}t.task=e;t.domain=process.domain;n(t)}function RawTask(){this.task=null;this.domain=null}RawTask.prototype.call=function(){if(this.domain){this.domain.enter()}var e=true;try{this.task.call();e=false;if(this.domain){this.domain.exit()}}finally{if(e){n.requestFlush()}this.task=null;this.domain=null;o.push(this)}}},666:(e,t,r)=>{"use strict";var n;var o=typeof setImmediate==="function";e.exports=rawAsap;function rawAsap(e){if(!i.length){requestFlush();s=true}i[i.length]=e}var i=[];var s=false;var a=0;var u=1024;function flush(){while(a<i.length){var e=a;a=a+1;i[e].call();if(a>u){for(var t=0,r=i.length-a;t<r;t++){i[t]=i[t+a]}i.length-=a;a=0}}i.length=0;a=0;s=false}rawAsap.requestFlush=requestFlush;function requestFlush(){var e=process.domain;if(e){if(!n){n=r(639)}n.active=process.domain=null}if(s&&o){setImmediate(flush)}else{process.nextTick(flush)}if(e){n.active=process.domain=e}}},160:(e,t,r)=>{var n={};e["exports"]=n;n.themes={};var o=r(837);var i=n.styles=r(537);var s=Object.defineProperties;var a=new RegExp(/[\r\n]+/g);n.supportsColor=r(863).supportsColor;if(typeof n.enabled==="undefined"){n.enabled=n.supportsColor()!==false}n.enable=function(){n.enabled=true};n.disable=function(){n.enabled=false};n.stripColors=n.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var u=n.stylize=function stylize(e,t){if(!n.enabled){return e+""}return i[t].open+e+i[t].close};var l=/[|\\{}()[\]^$+*?.]/g;var escapeStringRegexp=function(e){if(typeof e!=="string"){throw new TypeError("Expected a string")}return e.replace(l,"\\$&")};function build(e){var t=function builder(){return applyStyle.apply(builder,arguments)};t._styles=e;t.__proto__=f;return t}var c=function(){var e={};i.grey=i.gray;Object.keys(i).forEach((function(t){i[t].closeRe=new RegExp(escapeStringRegexp(i[t].close),"g");e[t]={get:function(){return build(this._styles.concat(t))}}}));return e}();var f=s((function colors(){}),c);function applyStyle(){var e=Array.prototype.slice.call(arguments);var t=e.map((function(e){if(e!==undefined&&e.constructor===String){return e}else{return o.inspect(e)}})).join(" ");if(!n.enabled||!t){return t}var r=t.indexOf("\n")!=-1;var s=this._styles;var u=s.length;while(u--){var l=i[s[u]];t=l.open+t.replace(l.closeRe,l.open)+l.close;if(r){t=t.replace(a,l.close+"\n"+l.open)}}return t}n.setTheme=function(e){if(typeof e==="string"){console.log("colors.setTheme now only accepts an object, not a string. "+"If you are trying to set a theme from a file, it is now your (the "+"caller's) responsibility to require the file. The old syntax "+"looked like colors.setTheme(__dirname + "+"'/../themes/generic-logging.js'); The new syntax looks like "+"colors.setTheme(require(__dirname + "+"'/../themes/generic-logging.js'));");return}for(var t in e){(function(t){n[t]=function(r){if(typeof e[t]==="object"){var o=r;for(var i in e[t]){o=n[e[t][i]](o)}return o}return n[e[t]](r)}})(t)}};function init(){var e={};Object.keys(c).forEach((function(t){e[t]={get:function(){return build([t])}}}));return e}var p=function sequencer(e,t){var r=t.split("");r=r.map(e);return r.join("")};n.trap=r(152);n.zalgo=r(565);n.maps={};n.maps.america=r(637);n.maps.zebra=r(590);n.maps.rainbow=r(297);n.maps.random=r(843);for(var h in n.maps){(function(e){n[e]=function(t){return p(n.maps[e],t)}})(h)}s(n,init())},152:e=>{e["exports"]=function runTheTrap(e,t){var r="";e=e||"Run the trap, drop the bass";e=e.split("");var n={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};e.forEach((function(e){e=e.toLowerCase();var t=n[e]||[" "];var o=Math.floor(Math.random()*t.length);if(typeof n[e]!=="undefined"){r+=n[e][o]}else{r+=e}}));return r}},565:e=>{e["exports"]=function zalgo(e,t){e=e||" he is here ";var r={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]};var n=[].concat(r.up,r.down,r.mid);function randomNumber(e){var t=Math.floor(Math.random()*e);return t}function isChar(e){var t=false;n.filter((function(r){t=r===e}));return t}function heComes(e,t){var n="";var o;var i;t=t||{};t["up"]=typeof t["up"]!=="undefined"?t["up"]:true;t["mid"]=typeof t["mid"]!=="undefined"?t["mid"]:true;t["down"]=typeof t["down"]!=="undefined"?t["down"]:true;t["size"]=typeof t["size"]!=="undefined"?t["size"]:"maxi";e=e.split("");for(i in e){if(isChar(i)){continue}n=n+e[i];o={up:0,down:0,mid:0};switch(t.size){case"mini":o.up=randomNumber(8);o.mid=randomNumber(2);o.down=randomNumber(8);break;case"maxi":o.up=randomNumber(16)+3;o.mid=randomNumber(4)+1;o.down=randomNumber(64)+3;break;default:o.up=randomNumber(8)+1;o.mid=randomNumber(6)/2;o.down=randomNumber(8)+1;break}var s=["up","mid","down"];for(var a in s){var u=s[a];for(var l=0;l<=o[u];l++){if(t[u]){n=n+r[u][randomNumber(r[u].length)]}}}}return n}return heComes(e,t)}},637:(e,t,r)=>{var n=r(160);e["exports"]=function(){return function(e,t,r){if(e===" ")return e;switch(t%3){case 0:return n.red(e);case 1:return n.white(e);case 2:return n.blue(e)}}}()},297:(e,t,r)=>{var n=r(160);e["exports"]=function(){var e=["red","yellow","green","blue","magenta"];return function(t,r,o){if(t===" "){return t}else{return n[e[r++%e.length]](t)}}}()},843:(e,t,r)=>{var n=r(160);e["exports"]=function(){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"];return function(t,r,o){return t===" "?t:n[e[Math.round(Math.random()*(e.length-2))]](t)}}()},590:(e,t,r)=>{var n=r(160);e["exports"]=function(e,t,r){return t%2===0?e:n.inverse(e)}},537:e=>{var t={};e["exports"]=t;var r={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(r).forEach((function(e){var n=r[e];var o=t[e]=[];o.open="["+n[0]+"m";o.close="["+n[1]+"m"}))},490:e=>{"use strict";e.exports=function(e,t){t=t||process.argv;var r=t.indexOf("--");var n=/^-{1,2}/.test(e)?"":"--";var o=t.indexOf(n+e);return o!==-1&&(r===-1?true:o<r)}},863:(e,t,r)=>{"use strict";var n=r(37);var o=r(490);var i=process.env;var s=void 0;if(o("no-color")||o("no-colors")||o("color=false")){s=false}else if(o("color")||o("colors")||o("color=true")||o("color=always")){s=true}if("FORCE_COLOR"in i){s=i.FORCE_COLOR.length===0||parseInt(i.FORCE_COLOR,10)!==0}function translateLevel(e){if(e===0){return false}return{level:e,hasBasic:true,has256:e>=2,has16m:e>=3}}function supportsColor(e){if(s===false){return 0}if(o("color=16m")||o("color=full")||o("color=truecolor")){return 3}if(o("color=256")){return 2}if(e&&!e.isTTY&&s!==true){return 0}var t=s?1:0;if(process.platform==="win32"){var r=n.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586){return Number(r[2])>=14931?3:2}return 1}if("CI"in i){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some((function(e){return e in i}))||i.CI_NAME==="codeship"){return 1}return t}if("TEAMCITY_VERSION"in i){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0}if("TERM_PROGRAM"in i){var a=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(i.TERM)){return 2}if(/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)){return 1}if("COLORTERM"in i){return 1}if(i.TERM==="dumb"){return t}return t}function getSupportLevel(e){var t=supportsColor(e);return translateLevel(t)}e.exports={supportsColor:getSupportLevel,stdout:getSupportLevel(process.stdout),stderr:getSupportLevel(process.stderr)}},671:(e,t,r)=>{var n=r(160);e["exports"]=n},544:(e,t,r)=>{"use strict";e.exports=r(717)},594:(e,t,r)=>{"use strict";var n=r(666);function noop(){}var o=null;var i={};function getThen(e){try{return e.then}catch(e){o=e;return i}}function tryCallOne(e,t){try{return e(t)}catch(e){o=e;return i}}function tryCallTwo(e,t,r){try{e(t,r)}catch(e){o=e;return i}}e.exports=Promise;function Promise(e){if(typeof this!=="object"){throw new TypeError("Promises must be constructed via new")}if(typeof e!=="function"){throw new TypeError("Promise constructor's argument is not a function")}this._75=0;this._83=0;this._18=null;this._38=null;if(e===noop)return;doResolve(e,this)}Promise._47=null;Promise._71=null;Promise._44=noop;Promise.prototype.then=function(e,t){if(this.constructor!==Promise){return safeThen(this,e,t)}var r=new Promise(noop);handle(this,new Handler(e,t,r));return r};function safeThen(e,t,r){return new e.constructor((function(n,o){var i=new Promise(noop);i.then(n,o);handle(e,new Handler(t,r,i))}))}function handle(e,t){while(e._83===3){e=e._18}if(Promise._47){Promise._47(e)}if(e._83===0){if(e._75===0){e._75=1;e._38=t;return}if(e._75===1){e._75=2;e._38=[e._38,t];return}e._38.push(t);return}handleResolved(e,t)}function handleResolved(e,t){n((function(){var r=e._83===1?t.onFulfilled:t.onRejected;if(r===null){if(e._83===1){resolve(t.promise,e._18)}else{reject(t.promise,e._18)}return}var n=tryCallOne(r,e._18);if(n===i){reject(t.promise,o)}else{resolve(t.promise,n)}}))}function resolve(e,t){if(t===e){return reject(e,new TypeError("A promise cannot be resolved with itself."))}if(t&&(typeof t==="object"||typeof t==="function")){var r=getThen(t);if(r===i){return reject(e,o)}if(r===e.then&&t instanceof Promise){e._83=3;e._18=t;finale(e);return}else if(typeof r==="function"){doResolve(r.bind(t),e);return}}e._83=1;e._18=t;finale(e)}function reject(e,t){e._83=2;e._18=t;if(Promise._71){Promise._71(e,t)}finale(e)}function finale(e){if(e._75===1){handle(e,e._38);e._38=null}if(e._75===2){for(var t=0;t<e._38.length;t++){handle(e,e._38[t])}e._38=null}}function Handler(e,t,r){this.onFulfilled=typeof e==="function"?e:null;this.onRejected=typeof t==="function"?t:null;this.promise=r}function doResolve(e,t){var r=false;var n=tryCallTwo(e,(function(e){if(r)return;r=true;resolve(t,e)}),(function(e){if(r)return;r=true;reject(t,e)}));if(!r&&n===i){r=true;reject(t,o)}}},188:(e,t,r)=>{"use strict";var n=r(594);e.exports=n;n.prototype.done=function(e,t){var r=arguments.length?this.then.apply(this,arguments):this;r.then(null,(function(e){setTimeout((function(){throw e}),0)}))}},889:(e,t,r)=>{"use strict";var n=r(594);e.exports=n;var o=valuePromise(true);var i=valuePromise(false);var s=valuePromise(null);var a=valuePromise(undefined);var u=valuePromise(0);var l=valuePromise("");function valuePromise(e){var t=new n(n._44);t._83=1;t._18=e;return t}n.resolve=function(e){if(e instanceof n)return e;if(e===null)return s;if(e===undefined)return a;if(e===true)return o;if(e===false)return i;if(e===0)return u;if(e==="")return l;if(typeof e==="object"||typeof e==="function"){try{var t=e.then;if(typeof t==="function"){return new n(t.bind(e))}}catch(e){return new n((function(t,r){r(e)}))}}return valuePromise(e)};n.all=function(e){var t=Array.prototype.slice.call(e);return new n((function(e,r){if(t.length===0)return e([]);var o=t.length;function res(i,s){if(s&&(typeof s==="object"||typeof s==="function")){if(s instanceof n&&s.then===n.prototype.then){while(s._83===3){s=s._18}if(s._83===1)return res(i,s._18);if(s._83===2)r(s._18);s.then((function(e){res(i,e)}),r);return}else{var a=s.then;if(typeof a==="function"){var u=new n(a.bind(s));u.then((function(e){res(i,e)}),r);return}}}t[i]=s;if(--o===0){e(t)}}for(var i=0;i<t.length;i++){res(i,t[i])}}))};n.reject=function(e){return new n((function(t,r){r(e)}))};n.race=function(e){return new n((function(t,r){e.forEach((function(e){n.resolve(e).then(t,r)}))}))};n.prototype["catch"]=function(e){return this.then(null,e)}},409:(e,t,r)=>{"use strict";var n=r(594);e.exports=n;n.prototype["finally"]=function(e){return this.then((function(t){return n.resolve(e()).then((function(){return t}))}),(function(t){return n.resolve(e()).then((function(){throw t}))}))}},717:(e,t,r)=>{"use strict";e.exports=r(594);r(188);r(409);r(889);r(445);r(959)},445:(e,t,r)=>{"use strict";var n=r(594);var o=r(130);e.exports=n;n.denodeify=function(e,t){if(typeof t==="number"&&t!==Infinity){return denodeifyWithCount(e,t)}else{return denodeifyWithoutCount(e)}};var i="function (err, res) {"+"if (err) { rj(err); } else { rs(res); }"+"}";function denodeifyWithCount(e,t){var r=[];for(var o=0;o<t;o++){r.push("a"+o)}var s=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([i]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}function denodeifyWithoutCount(e){var t=Math.max(e.length-1,3);var r=[];for(var o=0;o<t;o++){r.push("a"+o)}var s=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+i+";","var res;","switch (argLength) {",r.concat(["extra"]).map((function(e,t){return"case "+t+":"+"res = fn.call("+["self"].concat(r.slice(0,t)).concat("cb").join(",")+");"+"break;"})).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments);var r=typeof t[t.length-1]==="function"?t.pop():null;var i=this;try{return e.apply(this,arguments).nodeify(r,i)}catch(e){if(r===null||typeof r=="undefined"){return new n((function(t,r){r(e)}))}else{o((function(){r.call(i,e)}))}}}};n.prototype.nodeify=function(e,t){if(typeof e!="function")return this;this.then((function(r){o((function(){e.call(t,null,r)}))}),(function(r){o((function(){e.call(t,r)}))}))}},959:(e,t,r)=>{"use strict";var n=r(594);e.exports=n;n.enableSynchronous=function(){n.prototype.isPending=function(){return this.getState()==0};n.prototype.isFulfilled=function(){return this.getState()==1};n.prototype.isRejected=function(){return this.getState()==2};n.prototype.getValue=function(){if(this._83===3){return this._18.getValue()}if(!this.isFulfilled()){throw new Error("Cannot get a value of an unfulfilled promise.")}return this._18};n.prototype.getReason=function(){if(this._83===3){return this._18.getReason()}if(!this.isRejected()){throw new Error("Cannot get a rejection reason of a non-rejected promise.")}return this._18};n.prototype.getState=function(){if(this._83===3){return this._18.getState()}if(this._83===-1||this._83===-2){return 0}return this._83}};n.disableSynchronous=function(){n.prototype.isPending=undefined;n.prototype.isFulfilled=undefined;n.prototype.isRejected=undefined;n.prototype.getValue=undefined;n.prototype.getReason=undefined;n.prototype.getState=undefined}},81:e=>{"use strict";e.exports=require("child_process")},639:e=>{"use strict";e.exports=require("domain")},361:e=>{"use strict";e.exports=require("events")},147:e=>{"use strict";e.exports=require("fs")},685:e=>{"use strict";e.exports=require("http")},687:e=>{"use strict";e.exports=require("https")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")},477:e=>{"use strict";e.exports=require("querystring")},310:e=>{"use strict";e.exports=require("url")},837:e=>{"use strict";e.exports=require("util")},144:e=>{"use strict";e.exports=require("vm")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var o=t[r]={exports:{}};var i=true;try{e[r](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[r]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{"use strict";var e=r;
|
||
/**
|
||
* @license
|
||
* Copyright 2016 The AMP HTML Authors. All Rights Reserved.
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http://www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS-IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the license.
|
||
*/const t=__nccwpck_require__(671);const n=__nccwpck_require__(147);const o=__nccwpck_require__(685);const i=__nccwpck_require__(687);const s=__nccwpck_require__(17);const a=__nccwpck_require__(254);const u=__nccwpck_require__(544);const l=__nccwpck_require__(477);const c=__nccwpck_require__(310);const f=__nccwpck_require__(837);const p=__nccwpck_require__(144);const h="amphtml-validator";function hasPrefix(e,t){return e.indexOf(t)==0}function isHttpOrHttpsUrl(e){return hasPrefix(e,"http://")||hasPrefix(e,"https://")}function readFromFile(e){return new u((function(t,r){n.readFile(e,"utf8",(function(e,n){if(e){r(e)}else{t(n.trim())}}))}))}function readFromReadable(e,t){return new u((function(r,n){const o=[];t.setEncoding("utf8");t.on("data",(function(e){o.push(e)}));t.on("end",(function(){r(o.join(""))}));t.on("error",(function(t){n(new Error("Could not read from "+e+" - "+t.message))}))}))}function readFromStdin(){return readFromReadable("stdin",process.stdin).then((function(e){process.stdin.resume();return e}))}function readFromUrl(e,t){return new u((function(r,n){const s=hasPrefix(e,"http://")?o:i;const a=s.request(e,(function(t){if(t.statusCode!==200){t.resume();n(new Error("Unable to fetch "+e+" - HTTP Status "+t.statusCode))}else{r(t)}}));a.setHeader("User-Agent",t);a.on("error",(function(t){n(new Error("Unable to fetch "+e+" - "+t.message))}));a.end()})).then(readFromReadable.bind(null,e))}function ValidationResult(){this.status="UNKNOWN";this.errors=[]}function ValidationError(){this.severity="UNKNOWN_SEVERITY";this.line=1;this.col=0;this.message="";this.specUrl=null;this.code="UNKNOWN_CODE";this.params=[]}function Validator(e){this.sandbox=p.createContext();try{new p.Script(e).runInContext(this.sandbox)}catch(e){throw new Error("Could not instantiate validator.js - "+e.message)}}Validator.prototype.validateString=function(e,t){const r=this.sandbox.amp.validator.validateString(e,t);const n=new ValidationResult;n.status=r.status;for(let e=0;e<r.errors.length;e++){const t=r.errors[e];const o=new ValidationError;o.severity=t.severity;o.line=t.line;o.col=t.col;o.message=this.sandbox.amp.validator.renderErrorMessage(t);o.specUrl=t.specUrl;o.code=t.code;o.params=t.params;n.errors.push(o)}return n};const m={};function getInstance(e,t){const r=e||"https://cdn.ampproject.org/v0/validator.js";const n=t||h;if(m.hasOwnProperty(r)){return u.resolve(m[r])}const o=isHttpOrHttpsUrl(r)?readFromUrl(r,n):readFromFile(r);return o.then((function(e){let t;try{t=new Validator(e)}catch(e){throw e}m[r]=t;return t}))}e.getInstance=getInstance;function newInstance(e){return new Validator(e)}e.newInstance=newInstance;function logValidationResult(e,r,n){if(r.status==="PASS"){process.stdout.write(e+": "+(n?t.green("PASS"):"PASS")+"\n")}for(let o=0;o<r.errors.length;o++){const i=r.errors[o];let s=e+":"+i.line+":"+i.col+" ";if(n){s+=(i.severity==="ERROR"?t.red:t.magenta)(i.message)}else{s+=i.message}if(i.specUrl){s+=" (see "+i.specUrl+")"}process.stderr.write(s+"\n")}}function main(){a.usage("[options] <fileOrUrlOrMinus...>\n\n"+' Validates the files or urls provided as arguments. If "-" is\n'+" specified, reads from stdin instead.").option("--validator_js <fileOrUrl>","The Validator Javascript.\n"+" Latest published version by default, or\n"+" dist/validator_minified.js (built with build.py)\n"+" for development.","https://cdn.ampproject.org/v0/validator.js").option("--user-agent <userAgent>","User agent string to use in requests.",h).option("--html_format <AMP|AMP4ADS|AMP4EMAIL>","The input format to be validated.\n"+" AMP by default.","AMP").option("--format <color|text|json>","How to format the output.\n"+' "color" displays errors/warnings/success in\n'+" red/orange/green.\n"+' "text" avoids color (e.g., useful in terminals not\n'+" supporting color).\n"+' "json" emits json corresponding to the ValidationResult\n'+" message in validator.proto.","color").parse(process.argv);if(a.args.length===0){a.outputHelp();process.exit(1)}if(a.html_format!=="AMP"&&a.html_format!=="AMP4ADS"&&a.html_format!=="AMP4EMAIL"){process.stderr.write('--html_format must be set to "AMP", "AMP4ADS", or "AMP4EMAIL".\n',(function(){process.exit(1)}))}if(a.format!=="color"&&a.format!=="text"&&a.format!=="json"){process.stderr.write('--format must be set to "color", "text", or "json".\n',(function(){process.exit(1)}))}const e=[];for(let t=0;t<a.args.length;t++){const r=a.args[t];if(r==="-"){e.push(readFromStdin())}else if(isHttpOrHttpsUrl(r)){e.push(readFromUrl(r,a.userAgent))}else{e.push(readFromFile(r))}}getInstance(a.validator_js,a.userAgent).then((function(r){u.all(e).then((function(e){const t={};let n=false;for(let o=0;o<e.length;o++){const i=r.validateString(e[o],a.html_format);if(a.format==="json"){t[a.args[o]]=i}else{logValidationResult(a.args[o],i,a.format==="color"?true:false)}if(i.status!=="PASS"){n=true}}if(a.format==="json"){process.stdout.write(JSON.stringify(t)+"\n",(function(){process.exit(n?1:0)}))}else if(n){process.stderr.write("",(function(){process.exit(1)}))}else{process.stdout.write("",(function(){process.exit(0)}))}})).catch((function(e){process.stderr.write((a.format=="color"?t.red(e.message):e.message)+"\n",(function(){process.exit(1)}))}))})).catch((function(e){process.stderr.write((a.format=="color"?t.red(e.message):e.message)+"\n",(function(){process.exit(1)}))}))}e.main=main})();module.exports=r})(); |