From ae2c5fe141a11e598032d1b3ac26aafc4d961799 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 2 Apr 2018 14:08:43 +0100 Subject: add documentation and main repo --- README.md | 61 +++++++++++++++++++++++++++++++++++++- index.js | 29 ------------------ main-repo/helloworld/helloworld.js | 8 +++++ main-repo/helloworld/package.json | 5 ++++ main-repo/helloworld/uninstall.js | 1 + main-repo/pkg93/package.json | 5 ++++ main-repo/pkg93/pkg93.js | 1 + main-repo/repo.json | 8 +++++ main-repo/wget93/package.json | 6 ++++ main-repo/wget93/unwget93.js | 3 ++ main-repo/wget93/wget93.js | 52 ++++++++++++++++++++++++++++++++ pkg93.js | 37 +++++++++++++++++++++++ 12 files changed, 186 insertions(+), 30 deletions(-) delete mode 100644 index.js create mode 100644 main-repo/helloworld/helloworld.js create mode 100644 main-repo/helloworld/package.json create mode 100644 main-repo/helloworld/uninstall.js create mode 100644 main-repo/pkg93/package.json create mode 120000 main-repo/pkg93/pkg93.js create mode 100644 main-repo/repo.json create mode 100644 main-repo/wget93/package.json create mode 100644 main-repo/wget93/unwget93.js create mode 100644 main-repo/wget93/wget93.js create mode 100644 pkg93.js diff --git a/README.md b/README.md index 09691dd..89a9d76 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ # pkg93 -soon + +## Installation +Unfinished! + +## Making a repository +Firstly, make sure that [CORS is enabled on your webserver](https://enable-cors.org/server.html). +If it isn't on, your users will be unable to download packages! +Secondly you need to create a repo.json in the folder where you want your repository to be in. +Here's an example: +```json +{ + "name": "Example of a repo.json", + "motd": "This is an example repo.json", + "packages": [ + "examplepkg1", + "examplepkg2", + "examplepkg3" + ] +} +``` +Finally put all the packages in seperate folders named after the package. +The end result should look like this: +``` +example-repo +├── repo.json +├── examplepkg1 +│ │ (package files go here) +│   └── package.json +├── examplepkg2 +│ │ (package files go here) +│   └── package.json +└── examplepkg3 +│ │ (package files go here) +    └── package.json +``` + +## Making a package +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!** +- `"version"`: An array of 3 numbers, 1st number is major, 2nd number is minor, 3rd number is patch. +- `"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. +Here's a example: +```json +{ + "name": "examplepkg", + "version": [1, 3, 7], + "inject": "installer.js", + "uninstall": "mypointlessuninstaller.js" +} +``` +And the directory structure: +``` +examplepkg +├── package.json +├── installer.js +└── mypointlessuninstaller.js +``` diff --git a/index.js b/index.js deleted file mode 100644 index fb357e8..0000000 --- a/index.js +++ /dev/null @@ -1,29 +0,0 @@ -le._apps.pkg93 = { - exec: function() { - // if ur reading this can u don't hack into my pc - // kthx - const args = this.arg.arguments; - const version = "le private beta"; - if (args.length == 0) { - $log.info(`pkg93 ${version} help`); - $log(`Usage: pkg93 [command] -Command can be one of the below: -update Updates package listing -get [package] Installs a package -rm [package] Uninstalls a package -add-repo [url] Adds a repository -rm-repo [id] Removes a repository -ls [pkgs|installed|repos] Lists all packages, installed - packages or repositories. -help Gets help for a command - -Examples: -pkg93 get gud -pkg93 rm kebab -pkg93 help ivefallenandicantgetup -`); - } - }, - icon: "/c/", - terminal: true -} diff --git a/main-repo/helloworld/helloworld.js b/main-repo/helloworld/helloworld.js new file mode 100644 index 0000000..40cd8bd --- /dev/null +++ b/main-repo/helloworld/helloworld.js @@ -0,0 +1,8 @@ +le._apps.helloworld = { + exec: function () { + $log("Hello, World!"); + }, + icon: "/c/sys/skins/w93/apps/terminal.png", + terminal: true, + hascli: true +} diff --git a/main-repo/helloworld/package.json b/main-repo/helloworld/package.json new file mode 100644 index 0000000..f5c7625 --- /dev/null +++ b/main-repo/helloworld/package.json @@ -0,0 +1,5 @@ +{ + "name": "helloworld", + "version": [1, 0, 0], + "inject": "helloworld.js" +} diff --git a/main-repo/helloworld/uninstall.js b/main-repo/helloworld/uninstall.js new file mode 100644 index 0000000..43bc525 --- /dev/null +++ b/main-repo/helloworld/uninstall.js @@ -0,0 +1 @@ +le._apps.helloworld = null; diff --git a/main-repo/pkg93/package.json b/main-repo/pkg93/package.json new file mode 100644 index 0000000..dbe1030 --- /dev/null +++ b/main-repo/pkg93/package.json @@ -0,0 +1,5 @@ +{ + "name": "pkg93", + "version": [0, 1, 0], + "inject": "pkg93.js" +} diff --git a/main-repo/pkg93/pkg93.js b/main-repo/pkg93/pkg93.js new file mode 120000 index 0000000..58d2fb8 --- /dev/null +++ b/main-repo/pkg93/pkg93.js @@ -0,0 +1 @@ +../../pkg93.js \ No newline at end of file diff --git a/main-repo/repo.json b/main-repo/repo.json new file mode 100644 index 0000000..c066956 --- /dev/null +++ b/main-repo/repo.json @@ -0,0 +1,8 @@ +{ + "name": "pkg93 Default Repo", + "motd": "Hello, World!", + "packages": [ + "wget93", + "helloworld" + ] +} diff --git a/main-repo/wget93/package.json b/main-repo/wget93/package.json new file mode 100644 index 0000000..d96a422 --- /dev/null +++ b/main-repo/wget93/package.json @@ -0,0 +1,6 @@ +{ + "name": "wget93", + "version": [0, 1, 0], + "inject": "wget93.js", + "uninstall": "unwget93.js" +} diff --git a/main-repo/wget93/unwget93.js b/main-repo/wget93/unwget93.js new file mode 100644 index 0000000..11e0e00 --- /dev/null +++ b/main-repo/wget93/unwget93.js @@ -0,0 +1,3 @@ +$log.succes("Uninstalling wget93..."); +le._apps.wget93 = null; +$log.succes("✔️ Uninstalled wget93."); \ No newline at end of file diff --git a/main-repo/wget93/wget93.js b/main-repo/wget93/wget93.js new file mode 100644 index 0000000..8734730 --- /dev/null +++ b/main-repo/wget93/wget93.js @@ -0,0 +1,52 @@ +le._apps.wget93 = { + exec: function() + { + try { + if (this.arg.arguments.length == 0) { + $log(`wget93 v0.1.0 by 1024x2 +wget93 [url] [output] +example: wget93 http://tobefa.ir/youhavetoha.ve /a/veryhightounderstand/rickandmor.ty + +NOTE: Downloading binary files doesn't work, only text.`); + } else if (this.arg.arguments.length != 2) { + throw new Error("missing url/destination"); + } else { + $log.info("Downloading..."); + var url = this.arg.arguments[0]; + if (this.arg.arguments[1].startsWith("/a/")) { + var output = this.arg.arguments[1].substring(3); + } else { + var output = this.arg.arguments[1]; + } + var request = new XMLHttpRequest(); + request.addEventListener("load", function () { + if (request.status != 200) { + $log.error("❌ wget93: " + request.statusText); + } else { + $log.succes("✔️ Downloaded!"); + $log.info("Saving..."); + $store.set(output, request.responseText); + $log.succes("✔️ Saved!"); + $explorer.refresh(); + } + }); + request.addEventListener("error", function () { + $log.error("❌ wget93: couldn't download file"); + if (!!window.chrome) { + $log.info("This may be caused by \"Allow-Control-Allow-Origin\" garbage. Click here to download an extension that fixes this."); + } else if (navigator.userAgent.indexOf("Firefox") > 0) { + $log.info("This may be caused by \"Allow-Control-Allow-Origin\" garbage. Click here to download an addon that fixes this."); + } else { + $log.info("This may be caused by \"Allow-Control-Allow-Origin\" garbage."); + } + }); + request.open("GET", url); + request.send(); + } + } catch(error) { + $log.error("❌ wget93: " + error.message); + } + }, + hascli: true, + terminal: true +}; \ No newline at end of file diff --git a/pkg93.js b/pkg93.js new file mode 100644 index 0000000..fd94a0e --- /dev/null +++ b/pkg93.js @@ -0,0 +1,37 @@ +le._apps.pkg93 = { + exec: function() { + const args = this.arg.arguments; + const version = "v0.1.0"; + if (localStorage[".config/pkg93.json"] == undefined) { + localStorage[".config/pkg93.json"] = '{"sources": [], "pkgs": [], "cache": []}'; + } + if (args.length == 0) { + $log.info(`pkg93 ${version} help`); + $log(`Usage: pkg93 [command] +Command can be one of the below: +update Updates package listing +get [package] Installs a package +rm [package] Uninstalls a package +add-repo [url] Adds a repository +rm-repo [id] Removes a repository +ls [pkgs|installed|repos] Lists all packages, installed + packages or repositories. +help Gets help for a command + +Examples: +pkg93 get gud +pkg93 rm kebab +pkg93 help ivefallenandicantgetup`); + } else { + if (args[0] == "update") { + var config = JSON.parse(localStorage[".config/pkg93.json"]); + config.sources.forEach((value) => { + + }); + } + } + }, + icon: "/c/sys/skins/w93/install.png", + terminal: true, + hascli: true +} -- cgit v1.2.3