leagueoflegends
Version:
League of Legends CLI.
3 lines • 9.47 kB
JavaScript
(()=>{var e={756:(e,t,o)=>{const s=o(242),n=o(990),{left:a,right:l,center:r}=o(708),c=o(786),i={weekday:"long",month:"long",day:"numeric"},g={month:"long",day:"numeric"},d={day:"numeric"},u={weekday:"long"},p={hour:"2-digit",minute:"2-digit"},h=(e,t,o)=>7===o.length?s.bold.hex(e).bgHex(t)(l(`${o} `,12)):s.bold.hex(e).bgHex(t)(r(o,12)),m=(e,t)=>{const o=e.name.length>=21||"lcs-academy"===t?e.abbreviatedName:e.name,n=e.hasOwnProperty("color")?e.color:"#a0a0a0";return s.bold.whiteBright.bgHex(n)(` ${o} `)},f=(e,t)=>{const{team1:o,team2:n}=t,c=`${o.score} vs ${n.score}`;let i=h("#5a5a5a","#fff",c),g=m(o,e),d=m(n,e);return"NOT STARTED"===t.status?i=h("#5a5a5a","#fff",t.time):"LIVE"===t.status?i=h("#fff","#e50e47","LIVE"):"CONCLUDED"===t.status&&(g=o.score>n.score?s.underline(g):g,d=o.score<n.score?s.underline(d):d),g=l(g,22),d=a(d,22),`${g+r(i,20)+d}\n`};function b(e,t,o){const s=new Date,n=new Date(s),a=new Date(s);let l="";return n.setDate(n.getDate()-1),a.setDate(a.getDate()+1),t===e.date&&0!==o||(l=s.toLocaleString("en-US",i)===e.date?`Today, ${s.toLocaleString("en-US",g)}`:n.toLocaleString("en-US",i)===e.date?`Yesterday, ${n.toLocaleString("en-US",g)}`:a.toLocaleString("en-US",i)===e.date?`Tomorrow, ${a.toLocaleString("en-US",g)}`:e.date),l}e.exports={matches(e){const t=n("Loading matches").start();c(`http://lolesports.s3-accelerate.amazonaws.com/${e}/schedule`).catch((()=>{console.error("\nHost is inaccessible -- are you offline?"),process.exit(1)})).then((e=>e.json())).then((o=>{const{schedule:n}=o;if(t.stop(),n.length>0){console.log(`\n${r(e.toUpperCase(),64)}\n`);let t=new Date(n[0].matchID).toLocaleString("en-US",i);for(let o=0;o<n.length;o+=1){const a=n[o].matchID,l={status:n[o].status,date:new Date(a).toLocaleString("en-US",i),day:new Date(a).toLocaleString("en-US",d),weekday:new Date(a).toLocaleString("en-US",u),time:new Date(a).toLocaleString("en-US",p),team1:n[o].team1,team2:n[o].team2},c=b(l,t,o);""!==c&&console.log(`${s.hex("#fff").bgHex("#1e1e1e")(r(c,64))}\n`),t=l.date,console.log(f(e,l))}}else console.log(`\n There are no ${e.toUpperCase()} matches this week.\n`)}))},getDate:b,getDateSuffix:function(e){if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},getMatchResult:function(e){return"CONCLUDED"!==e.status?"":e.team1.score>e.team2.score?e.team1.name:e.team1.score<e.team2.score?e.team2.name:void 0}}},74:(e,t,o)=>{const s=o(242),n=o(990),{left:a,center:l}=o(708),r=o(786),c=e=>{const t=l(s.bold(`${e.rank}`),8),o=s.bold.whiteBright.bgHex(e.color)(` ${e.name} `);return`${a(t+o,30)}${l(s.bold(e.record),14)}\n`},i=(e,t)=>`\n${s.hex("#fff").bgHex("#1e1e1e")(l(e[t/4],44))}\n`;e.exports={standings(e){const t=n("Loading standings").start();r(`http://lolesports.s3-accelerate.amazonaws.com/${e}/standings`).catch((()=>{console.error("\nHost is inaccessible -- are you offline?"),process.exit(1)})).then((e=>e.json())).then((o=>{t.stop();const{standings:n}=o,r=["Group A","Group B","Group C","Group D"],g="worlds"===e;if(n.length>0){g||console.log((()=>{const e=a(l("",8)+l("TEAM"),30),t=l("RECORD",14);return s.hex("#fff").bgHex("#1e1e1e")(`\n${e}${t}\n`)})());for(let t=0;t<n.length;t+=1){let o=n[t];o={name:o.name.length>=21||"lcs-academy"===e?o.abbreviatedName:o.name,color:o.hasOwnProperty("color")?o.color:"#a0a0a0",rank:o.ranking,record:o.record},g&&t%4==0&&console.log(i(r,t)),console.log(c(o))}}else t.stop(),console.log(`\n There are no ${e} standings.\n`)}))},getDiffColor:function(e){return e>0?"#28b455":e<0?"#cc4939":"#e2e2e2"}}},306:e=>{"use strict";e.exports=JSON.parse('{"name":"leagueoflegends","version":"4.0.1","description":"League of Legends CLI.","license":"MIT","author":"Luke Al-Saba","homepage":"https://al-saba.com","repository":{"type":"git","url":"git+https://github.com/lukealsaba/leagueoflegends.git"},"bugs":{"url":"https://github.com/lukealsaba/leagueoflegends/issues"},"main":"lib/cli.js","bin":{"leagueoflegends":"lib/cli.js"},"dependencies":{"chalk":"^4.1.0","commander":"^7.0.0","node-fetch":"^2.6.1","ora":"^5.3.0","update-notifier":"^5.0.1","wide-align":"^1.1.3"},"devDependencies":{"@babel/cli":"^7.12.10","@babel/core":"^7.12.10","@babel/plugin-proposal-class-properties":"^7.12.1","@babel/plugin-proposal-object-rest-spread":"^7.12.1","@babel/plugin-transform-runtime":"^7.12.10","@babel/preset-env":"^7.12.11","@babel/register":"^7.12.10","babel-eslint":"^10.1.0","babel-jest":"^26.6.3","babel-loader":"^8.2.2","eslint":"^7.18.0","eslint-config-airbnb":"^18.2.1","eslint-config-prettier":"^7.2.0","eslint-plugin-babel":"^5.3.1","eslint-plugin-import":"^2.22.1","eslint-plugin-jsx-a11y":"^6.4.1","eslint-plugin-prettier":"^3.3.1","eslint-plugin-react":"^7.22.0","husky":"^4.3.8","jest":"^26.6.3","lint-staged":"^10.5.3","path":"^0.12.7","pkg":"^4.4.9","prettier":"^2.2.1","prettier-package-json":"^2.1.3","rimraf":"^3.0.2","terser-webpack-plugin":"^5.1.1","webpack":"^5.18.0","webpack-cli":"^4.4.0","webpack-node-externals":"^2.5.2"},"keywords":["league of legends","lol","riot games","esports","cli","worlds","lcs","lec","lck","lpl"],"engines":{"node":">=10.0.0"},"jest":{"collectCoverageFrom":["src/**/*.js"],"coveragePathIgnorePatterns":["/node_modules/","/__tests__/"],"testPathIgnorePatterns":["node_modules/"]},"lint-staged":{"package.json":["prettier-package-json --write","git add"],"*.js":["eslint --fix","git add"]},"pkg":{"scripts":["lib/*.js"],"targets":["node10-macos","node10-linux","node10-win"]},"directories":{"lib":"lib"},"scripts":{"build":"npm run clean && webpack --config webpack.config.js --mode=production","clean":"rimraf lib packed","dev":"webpack --config webpack.config.js -d -w","lint":"eslint src","lint:fix":"npm run lint -- --fix","pack":"pkg . --out-path packed","prepublishOnly":"npm run build && echo \'#!/usr/bin/env node\' | cat - lib/cli.js > temp && mv temp lib/cli.js","test":"npm run lint:fix && npm run testonly:cov","testonly":"NODE_ENV=test jest","testonly:cov":"jest --coverage --runInBand --forceExit --no-cache","testonly:watch":"jest --watch"}}')},113:e=>{"use strict";e.exports=JSON.parse('[{"worlds":"worlds"},{"lcs":"lcs"},{"lec":"lec"},{"lck":"lck"},{"lpl":"lpl"},{"lcsacademy":"lcs-academy"}]')},242:e=>{"use strict";e.exports=require("chalk")},647:e=>{"use strict";e.exports=require("commander")},786:e=>{"use strict";e.exports=require("node-fetch")},990:e=>{"use strict";e.exports=require("ora")},734:e=>{"use strict";e.exports=require("update-notifier")},708:e=>{"use strict";e.exports=require("wide-align")}},t={};function o(s){if(t[s])return t[s].exports;var n=t[s]={exports:{}};return e[s](n,n.exports,o),n.exports}(()=>{const e=o(647),t=o(242),s=o(734),n=o(306),a=[o(756),o(74)],l=o(113);function r(e,t,o){for(const s of l){const n=Object.keys(s)[0],l=Object.values(s)[0];if(t[n])return a[e][o](l),!0}return!1}s({pkg:n}).notify(),e.name("leagueoflegends").usage("[command] [options]"),e.command("matches").alias("m").usage("[options]").option("-w, --worlds","Show this weeks Worlds schedule").option("-n, --lcs","Show this weeks LCS schedule").option("-e, --lec","Show this weeks LEC schedule").option("-k, --lck","Show this weeks LCK schedule").option("-p, --lpl","Show this weeks LPL schedule").option("-a, --lcsacademy","Show this weeks LCS-Academy schedule").on("--help",(()=>{console.log("\n See the current weeks LoL matches!\n"),console.log(" Example:"),console.log(` ${t`{hex('#218ffe') leagueoflegends matches --lcs} List all of this weeks LCS matches`}\n`),console.log(` Visit the GitHub page for more detailed information: ${t`{hex('#218ffe') https://github.com/LukeAlSaba/LeagueofLegends}`}\n`)})).action((e=>{r(0,e,"matches")||console.log("\nError: Please choose a league, by using one of these options (--worlds | --lcs | --lec | --lck | --lpl | --lcsacademy).\n")})),e.command("standings").alias("s").usage("[options]").option("-w, --worlds","Show this weeks Worlds standings").option("-n, --lcs","Show this weeks LCS standings").option("-e, --lec","Show this weeks LEC standings").option("-k, --lck","Show this weeks LCK standings").option("-p, --lpl","Show this weeks LPL standings").option("-a, --lcsacademy","Show this weeks LCS-Academy standings").on("--help",(()=>{console.log("\n See the current standings for a specific LoL league!\n"),console.log(" Example:"),console.log(` ${t`{hex('#218ffe') leagueoflegends standings --lcs} List the current LCS standings`}\n`),console.log(` Visit the GitHub page for more detailed information: ${t`{hex('#218ffe') https://github.com/LukeAlSaba/leagueoflegends}`}\n`)})).action((e=>{r(1,e,"standings")||console.log("\nError: Please choose a league, by using one of these options (--worlds | --lcs | --lec | --lck | --lpl | --lcsacademy).\n")})),e.on("--help",(()=>{console.log(`\n Welcome to the ${t`{bold.hex('#f99e1a') League of Legends Esports} CLI`}!\n`),console.log(` Check out this weeks schedule by entering ${t`{hex('#218ffe') leagueoflegends matches --league_name}`}`),console.log(` See the current standings by entering ${t`{hex('#218ffe') leagueoflegends standings --league_name}`}\n`),console.log(` Visit the GitHub page for more detailed information: ${t`{hex('#218ffe') https://github.com/LukeAlSaba/LeagueofLegends}`}\n`)})),e.command("*").action((e=>{console.log(`\n error: unknown command \`${e}'\n`),process.exit(1)})),e.version(n.version,"-v, --version"),e.parse(process.argv)})()})();
//# sourceMappingURL=cli.js.map