From b7a5bb5b621335084aeb23cd0e20c332cfd89c68 Mon Sep 17 00:00:00 2001
From: Unknown
Date: Wed, 6 Jun 2018 13:32:41 +0100
Subject: is this how you travis ci and lint
---
.eslintrc.js | 21 +++++++++++++++
.gitignore | 2 ++
.travis.yml | 4 +++
install.js | 4 +--
pkg93.js | 88 +++++++++++++++++++++++++-----------------------------------
5 files changed, 66 insertions(+), 53 deletions(-)
create mode 100644 .eslintrc.js
create mode 100644 .gitignore
create mode 100644 .travis.yml
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..585551a
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,21 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "es6": true
+ },
+ "extends": "eslint:recommended",
+ "rules": {
+ "indent": ["error", 2],
+ "linebreak-style": ["error", "unix"],
+ "quotes": ["error", "double", {"allowTemplateLiterals": true}],
+ "semi": ["error", "always"],
+ "no-console": 0
+ },
+ "parserOptions": {
+ "ecmaVersion": 2017
+ },
+ globals: {
+ "$log": function(a){},
+ "le": {apps: {}}
+ }
+};
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae58223
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# eslint is saved here, don't commit plz
+node_modules/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..e8f89db
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js: "node"
+install: npm install eslint --no-save
+script: ./node_modules/.bin/eslint .
\ No newline at end of file
diff --git a/install.js b/install.js
index edc4ef4..3dd03ae 100644
--- a/install.js
+++ b/install.js
@@ -8,6 +8,6 @@ var _main = `var interval = setInterval(function () {
} catch (err) {
console.error(err);
}
-}, 5000);`
+}, 5000);`;
localStorage["boot/pkg93.js"] = _main;
-eval(_main);
+eval(_main); // jshint ignore:line
\ No newline at end of file
diff --git a/pkg93.js b/pkg93.js
index 187e69a..7783d51 100644
--- a/pkg93.js
+++ b/pkg93.js
@@ -1,21 +1,21 @@
async function wrap(f) {
- var originalPrompt = this.cli.prompt.innerHTML
- var originalOnenter = this.cli.onenter
+ var originalPrompt = this.cli.prompt.innerHTML;
+ var originalOnenter = this.cli.onenter;
try {
- this.cli.prompt.innerHTML = ''
- this.cli.onenter = l => false
- var lastLog = $log('')
+ this.cli.prompt.innerHTML = "";
+ this.cli.onenter = () => false;
+ var lastLog = $log("");
await f({
- log: (...args) => {
- var newLog = $log(...args)
- newLog.parentElement.insertBefore(newLog, lastLog.nextSibling)
- lastLog = newLog
- },
- arg: this.arg
- })
+ log: (...args) => {
+ var newLog = $log(...args);
+ newLog.parentElement.insertBefore(newLog, lastLog.nextSibling);
+ lastLog = newLog;
+ },
+ arg: this.arg
+ });
} finally {
- this.cli.prompt.innerHTML = originalPrompt
- this.cli.onenter = originalOnenter
+ this.cli.prompt.innerHTML = originalPrompt;
+ this.cli.onenter = originalOnenter;
}
}
@@ -24,11 +24,11 @@ console.log("[pkg93] Injecting packages...");
try {
if (localStorage[".pkg93/config.json"] === undefined) {
console.log("[pkg93] You seem new. Creating config...");
- localStorage[".pkg93/config.json"] = '{"repos": ["//codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}';
+ localStorage[".pkg93/config.json"] = `{"repos": ["//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"]);
+ eval(localStorage[".pkg93/packages/" + pkg + ".js"]); // jshint ignore:line
}
} catch (err) {
console.error("[pkg93] Couldn't load package information.");
@@ -45,14 +45,14 @@ var pkg93 = {
}
},
pull: async function(cli) {
- cli = cli || {log: (i) => {$log(i)}};
+ cli = cli || {log: (i) => {$log(i);}};
var config = pkg93.getConfig();
cli.log("WARN Windows93 may lag while getting packages.\n This is a normal thing.");
config.pkglist = [];
for (let source of config.repos) {
cli.log("GET " + source);
try {
- var json = await (await (fetch(source + "/repo.json"))).json()
+ var json = await (await (fetch(source + "/repo.json"))).json();
cli.log("NAME " + json.name);
cli.log("MSG " + json.msg);
for (let item of json.packages) {
@@ -65,26 +65,12 @@ var pkg93 = {
}
} catch (err) {
cli.log("ERR " + err.message);
- if (request.status !== 200) {
- cli.log("ERR Got HTTP Status Code " + request.status + " from the server.");
- if (request.status === 404) {
- cli.log(" Are you trying to load a non-existant repo?");
- }
- }
- if (!request.responseText.toLowerCase().includes("")) {
- cli.log("INFO Response is HTML, not displaying...");
- } else {
- cli.log(request.responseText);
- }
- if (location.protocol == "https:") {
- cli.log("WARN pkg93 doesn't work on HTTPS connections.\n Click here to load Windows93 over HTTP.");
- }
}
}
localStorage[".pkg93/config.json"] = JSON.stringify(config);
},
get: async function(pkg, cli) {
- cli = cli || {log: (i) => {$log(i)}};
+ cli = cli || {log: (i) => {$log(i);}};
var config = pkg93.getConfig();
cli.log("SRCH " + pkg);
var index = config.pkglist.findIndex(function(string) {
@@ -98,13 +84,13 @@ var pkg93 = {
var pkgname = config.pkglist[index].split("@")[0];
var pkgsource = config.pkglist[index].split("@")[1];
try {
- var json = await (await (fetch(pkgsource + "/" + pkgname + "/package.json"))).json()
+ var json = await (await (fetch(pkgsource + "/" + pkgname + "/package.json"))).json();
localStorage[".pkg93/packages/" + pkgname + ".json"] = JSON.stringify(json);
if (json.dependencies) {
for (let pkg of json.dependencies) {
try {
cli.log("DPND Getting dependency \"" + pkg + "\"");
- output = await pkg93.get(pkg, cli);
+ var output = await pkg93.get(pkg, cli);
if (!output) {
throw new Error("Dependency \"" + pkg + "\" failed to install. Current package may not work!");
}
@@ -113,11 +99,11 @@ var pkg93 = {
}
}
}
- var script = await (await (fetch(pkgsource + "/" + pkgname + "/" + json.inject))).text()
+ var script = await (await (fetch(pkgsource + "/" + pkgname + "/" + json.inject))).text();
localStorage[".pkg93/packages/" + pkgname + ".js"] = script;
eval(script);
if (json.uninstall) {
- var uninst = await (await (fetch(pkgsource + "/" + pkgname + "/" + json.uninstall))).text()
+ var uninst = await (await (fetch(pkgsource + "/" + pkgname + "/" + json.uninstall))).text();
localStorage[".pkg93/packages/" + pkgname + ".rm.js"] = uninst;
}
cli.log("OK Injected package!");
@@ -133,18 +119,18 @@ var pkg93 = {
}
},
rm: function(pkg, cli) {
- cli = cli || {log: (i) => {$log(i)}};
+ cli = cli || {log: (i) => {$log(i);}};
var config = pkg93.getConfig();
var index = config.installed.indexOf(pkg);
if (index < 0) {
cli.log("ERR Not found.");
return false;
- } else if (!!localStorage[".pkg93/packages/" + pkg + ".rm.js"]) {
+ } else if (localStorage[".pkg93/packages/" + pkg + ".rm.js"]) {
eval(localStorage[".pkg93/packages/" + pkg + ".rm.js"]); // Typing eval makes me feel dirty.
delete le._apps[config.installed[index]];
- delete localStorage[".pkg93/packages/" + pkg + ".rm.js"]
- delete localStorage[".pkg93/packages/" + pkg + ".js"]
- delete localStorage[".pkg93/packages/" + pkg + ".json"]
+ delete localStorage[".pkg93/packages/" + pkg + ".rm.js"];
+ delete localStorage[".pkg93/packages/" + pkg + ".js"];
+ delete localStorage[".pkg93/packages/" + pkg + ".json"];
config.installed.splice(index, 1);
cli.log("OK Removed!");
} else {
@@ -181,7 +167,7 @@ var pkg93 = {
} else {
var pkgname = config.pkglist[index].split("@")[0];
var pkgsource = config.pkglist[index].split("@")[1];
- var json = await (await (fetch(pkgsource + "/" + pkgname + "/package.json"))).json()
+ var json = await (await (fetch(pkgsource + "/" + pkgname + "/package.json"))).json();
localStorage[".pkg93/packages/" + pkgname + ".json"] = JSON.stringify(json); // save it for later
return json;
}
@@ -196,7 +182,7 @@ var pkg93 = {
arg: {arguments:[]}
},
version: "v2.0.0"
-}
+};
async function _pkg93execdonotcallplsusetheapi(cli) {
pkg93.version = "v2.0.0";
@@ -224,7 +210,7 @@ pkg93 rm kebab
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\": [\"//codinggamerhd.com/main-repo\"], \"installed\": [], \"pkglist\": []}";
}
if (localStorage[".pkg93/packages/"] === undefined) {
localStorage[".pkg93/packages/"] = "";
@@ -281,7 +267,7 @@ If you find my software useful, consider donating ";
}
@@ -295,10 +281,10 @@ If you find my software useful, consider donating ERR Either the package doesn't exist, or an error occoured.")
+ cli.log("ERR Either the package doesn't exist, or an error occoured.");
} else {
- depends = pkgInfo.dependencies ? pkgInfo.dependencies.join(" , ") : "None!";
- description = pkgInfo.description ? pkgInfo.description : "None!";
+ var depends = pkgInfo.dependencies ? pkgInfo.dependencies.join(" , ") : "None!";
+ var description = pkgInfo.description ? pkgInfo.description : "None!";
console.log(pkgInfo);
cli.log(`${pkgInfo.name}
Description: ${description}
@@ -310,7 +296,7 @@ Dependencies: ${depends}`);
} else if (args[0] == "wtf") {
// for teh lulz
new Audio("/c/sys/sounds/QUACK.ogg").play();
- wtf = ["mudkipz", "pkg93", "memes", "linux", "javascript", "git", "cpu", "windows93", "discord", "kirb", "apt93", "delays", /* those last 2 go well together */ "trash", "kernel panic", "bash", "package manager", "recusion"];
+ var wtf = ["mudkipz", "pkg93", "memes", "linux", "javascript", "git", "cpu", "windows93", "discord", "kirb", "apt93", "delays", /* those last 2 go well together */ "trash", "kernel panic", "bash", "package manager", "recusion"];
cli.log("WTF? " + wtf[Math.floor(Math.random() * wtf.length)] + " + " + wtf[Math.floor(Math.random() * wtf.length)] + " = " + wtf[Math.floor(Math.random() * wtf.length)]);
} else {
cli.log("ERR Invalid command. Type \"pkg93\" without any arguments for help.");
@@ -318,7 +304,7 @@ Dependencies: ${depends}`);
}
le._apps.pkg93 = {
- exec: function() { wrap.call(this, _pkg93execdonotcallplsusetheapi) },
+ exec: function() { wrap.call(this, _pkg93execdonotcallplsusetheapi); },
icon: "//cdn.rawgit.com/1024x2/pkg93/70039c02/pkg.png",
terminal: true,
hascli: true,
--
cgit v1.2.3