From edae447c6697ae2cff4e1384ca16b3b803cd4583 Mon Sep 17 00:00:00 2001 From: 1024x2 Date: Sun, 1 Jul 2018 15:46:00 +0100 Subject: wa --- pkg93.js | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/pkg93.js b/pkg93.js index b9e9b37..3f241ab 100644 --- a/pkg93.js +++ b/pkg93.js @@ -53,20 +53,33 @@ console.log("%c[pkg93]%c Injecting packages...", "font-weight:bold", "font-weigh try { if (localStorage[".pkg93/config.json"] === undefined) { console.log("%c[pkg93]%c You seem new. Creating config...", "font-weight:bold", "font-weight:normal"); - localStorage[".pkg93/config.json"] = `{"repos": ["//codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}`; + localStorage[".pkg93/config.json"] = `{"repos": ["https://codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}`; } var config = JSON.parse(localStorage[".pkg93/config.json"]); for (let pkg of config.installed) { eval(localStorage[".pkg93/packages/" + pkg + ".js"]); } } catch (err) { - console.error("%c[pkg93]%c Couldn't load package information.", "font-weight:bold", "font-weight:normal"); + console.error("%c[pkg93]%c Couldn't load pkg93!", "font-weight:bold", "font-weight:normal"); + console.error("%c[pkg93]%c %o", "font-weight:bold", "font-weight:normal", err); + $alert({ + title: "Couldn't load pkg93!", + msg: "
" + (err.stack || err.toString()) + "
", + btnOk: "Send a bug report", btnCancel: "OK" + }, function(ok) { + if (ok) { + window.open("https://github.com/pkg93/pkg93/issues/new" + + "?title=" + encodeURIComponent(err.toString()) + + "&body=Type what you were doing here...%0A%0A```%0A" + encodeURIComponent(err.stack) + "%0A```", + "_blank"); + } + }); } console.log("%c[pkg93]%c Done!", "font-weight:bold", "font-weight:normal"); console.groupEnd(); // thanks robbie! sauce: https://gist.github.com/robbie0630/e1386fb10676598e7d60d4f406a41042 -// note: this is a modified version +// NOTE: this is a modified version var _abarpkg93uses = (width, percent) => { if (percent > 1) percent = 1; let barwidth = width - 9; @@ -108,7 +121,7 @@ var pkg93 = { config.pkglist = []; return new Promise(async (res, rej) => { for (let source of config.repos) { - await new Promise(async (reso, reje) => { + await new Promise(async (reso) => { try { cli.log("GET " + source + "/repo.json"); var bardiv = cli.log(_abarpkg93uses(60, 0)); @@ -137,7 +150,7 @@ var pkg93 = { } catch (err) { console.error(err); cli.log("ERR " + err.message); - reje(); + rej(); } }; xhr.send(); @@ -336,10 +349,10 @@ async function _pkg93execdonotcallplsusetheapi(cli) { Color meanings Executing OK Error Warning Info -If you find my software useful, consider donating here. +If you find my software useful, consider donating here. `; if (localStorage[".pkg93/config.json"] === undefined) { - localStorage[".pkg93/config.json"] = "{\"repos\": [\"//codinggamerhd.com/main-repo\"], \"installed\": [], \"pkglist\": []}"; + localStorage[".pkg93/config.json"] = "{\"repos\": [\"https://codinggamerhd.com/main-repo\"], \"installed\": [], \"pkglist\": []}"; } if (localStorage[".pkg93/packages/"] === undefined) { localStorage[".pkg93/packages/"] = ""; @@ -408,15 +421,23 @@ If you find my software useful, consider donating ERR No package specified."); } else { - var pkgInfo = await pkg93.pkgInfo(args[1]); - if (!pkgInfo) { - cli.log("ERR Either the package doesn't exist, or an error occoured."); - } else { - var depends = pkgInfo.dependencies ? pkgInfo.dependencies.join(" , ") : "None!"; - var description = pkgInfo.description ? pkgInfo.description : "None!"; - cli.log(`${pkgInfo.name} -Description: ${description} -Dependencies: ${depends}`); + try { + var pkgInfo = await pkg93.pkgInfo(args[1]); + if (pkgInfo instanceof Error) { + // There's a Error in my pkgInfo! + throw pkgInfo; + } + if (!pkgInfo) { + cli.log("ERR Package not found."); + } else { + var depends = pkgInfo.dependencies ? pkgInfo.dependencies.join(" , ") : "None!"; + var description = pkgInfo.description ? pkgInfo.description : "None!"; + cli.log(`${pkgInfo.name} + Description: ${description} + Dependencies: ${depends}`); + } + } catch (err) { + cli.log("ERR Error while getting package info.\n" + err.stack); } } } else if (args[0] == "help") { -- cgit v1.2.3