From 6b7328cece2b8aa832add58a2057156fd250b195 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 14 Apr 2018 16:54:58 +0100 Subject: add dependencies --- README.md | 9 +++++++-- pkg93.js | 13 ++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 07e5fdf..b95514f 100644 --- a/README.md +++ b/README.md @@ -47,15 +47,20 @@ example-repo Firstly, you want to make a new folder called the name of the package. Then, you want to make a file called package.json in the folder. In it, there should be 4 keys. -- `name`: **Must be the same as the folder name and command name!** +- `name`: **Must be the same as the folder name and command name!** (unless you've provided a uninstaller) - `inject`: It should be the name of the injection script. - `uninstall`: Optional, It should be the name of the uninstaller script, if it doesn't exist pkg93 will simply delete the command for you. +- `dependencies`: Optional, Packages this package depends on. These will be automatically installed. Here's a example: ```json { "name": "examplepkg", "inject": "installer.js", - "uninstall": "optionaluninstaller.js" + "uninstall": "optionaluninstaller.js", + "dependencies": [ + "anoptionaldependency", + "anotherone" + ] } ``` And the directory structure: diff --git a/pkg93.js b/pkg93.js index 237bdb8..f44153a 100644 --- a/pkg93.js +++ b/pkg93.js @@ -86,6 +86,17 @@ var pkg93 = { request.send(null); var json = JSON.parse(request.responseText); localStorage[".pkg93/packages/" + pkgname + ".json"] = request.responseText; + if (json.dependencies) { + json.dependencies.forEach(function (pkg) { + try { + $log("DPND Getting dependency \"" + pkg + "\""); + output = pkg93.get(pkg); + if (output) {throw new Error("Dependency \"" + pkg + "\" failed to install. Current package may not work!");} + } catch (err) { + $log("ERR " + err.message); + } + }); + } request.open('GET', pkgsource + "/" + pkgname + "/" + json.inject, false); request.send(null); localStorage[".pkg93/packages/" + pkgname + ".js"] = request.responseText; @@ -148,7 +159,7 @@ le._apps.pkg93 = { exec: function() { const protected = ["3d","acid","acidbox","ansi","anthology","arena93","bananamp","base64","bytebeat","calc","castlegafa","catex","cd","clear","clearhist","clippy","code","contact","crazy","defrag","dmg","do a barrel roll","doctor","download","find","font","format","fullscreen","fx","gameoflife","glitch","global thermonuclear war","gravity","hampster","hello","help","hexed","history","hl3","hydra","ie6","iframe","img","info","js","key","killall","layer","lenna","lisa","ls","manifesto","marburg","messenger","mines","necronomicoin","pd","piskel","pkg93","pony","potato","progressquest","pwd","reboot","robby","rotate","shutdown","skifree","solitude","speech","starwars","superplayer","takethis","terminal","textarea","tree","trollbox","vega","virtualpc","vm","wat","whatif","whois","win","zkype"]; const args = this.arg.arguments; - const version = "v1.1.2"; + const version = "v1.2.0"; const help = `pkg93 ${version} Usage: pkg93 [command] -- cgit v1.2.3