diff options
-rw-r--r-- | .DS_Store | bin | 0 -> 6148 bytes | |||
-rw-r--r-- | .idea/.gitignore | 10 | ||||
-rw-r--r-- | .idea/Twilight.iml | 22 | ||||
-rw-r--r-- | .idea/deployment.xml | 26 | ||||
-rw-r--r-- | .idea/jsLibraryMappings.xml | 10 | ||||
-rw-r--r-- | .idea/modules.xml | 14 | ||||
-rw-r--r-- | .idea/vcs.xml | 10 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | commands/aliases.json | 22 | ||||
-rw-r--r-- | commands/info.js | 288 | ||||
-rw-r--r-- | commands/install.js | 400 | ||||
-rw-r--r-- | commands/installable.js | 200 | ||||
-rw-r--r-- | commands/installed.js | 184 | ||||
-rw-r--r-- | commands/list.js | 196 | ||||
-rw-r--r-- | commands/purge.js | 156 | ||||
-rw-r--r-- | commands/reinstall.js | 58 | ||||
-rw-r--r-- | commands/remove.js | 238 | ||||
-rw-r--r-- | commands/update.js | 54 | ||||
-rw-r--r-- | commands/upgrade.js | 470 | ||||
-rw-r--r-- | hooks/apply_update.js | 112 | ||||
-rw-r--r-- | hooks/clone.js | 104 | ||||
-rw-r--r-- | hooks/diff.js | 132 | ||||
-rw-r--r-- | hooks/files.js | 90 | ||||
-rw-r--r-- | hooks/size.js | 110 | ||||
-rw-r--r-- | hooks/update.js | 222 | ||||
-rw-r--r-- | index.js | 288 | ||||
-rw-r--r-- | node_modules/color-name/LICENSE | 14 | ||||
-rw-r--r-- | node_modules/color-name/README.md | 22 | ||||
-rw-r--r-- | node_modules/color-name/index.js | 304 | ||||
-rw-r--r-- | node_modules/color-name/package.json | 56 |
30 files changed, 1918 insertions, 1897 deletions
diff --git a/.DS_Store b/.DS_Store Binary files differnew file mode 100644 index 0000000..b99ae0f --- /dev/null +++ b/.DS_Store diff --git a/.idea/.gitignore b/.idea/.gitignore index b58b603..ea7ed09 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,5 +1,5 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ +# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/Twilight.iml b/.idea/Twilight.iml index 0c8867d..ff88395 100644 --- a/.idea/Twilight.iml +++ b/.idea/Twilight.iml @@ -1,12 +1,12 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="WEB_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$"> - <excludeFolder url="file://$MODULE_DIR$/temp" /> - <excludeFolder url="file://$MODULE_DIR$/.tmp" /> - <excludeFolder url="file://$MODULE_DIR$/tmp" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> +<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
</module>
\ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml index 1436779..d17d44e 100644 --- a/.idea/deployment.xml +++ b/.idea/deployment.xml @@ -1,14 +1,14 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false"> - <serverData> - <paths name="Familine"> - <serverdata> - <mappings> - <mapping local="$PROJECT_DIR$" web="/" /> - </mappings> - </serverdata> - </paths> - </serverData> - </component> +<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
+ <serverData>
+ <paths name="Familine">
+ <serverdata>
+ <mappings>
+ <mapping local="$PROJECT_DIR$" web="/" />
+ </mappings>
+ </serverdata>
+ </paths>
+ </serverData>
+ </component>
</project>
\ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml index d23208f..63326a8 100644 --- a/.idea/jsLibraryMappings.xml +++ b/.idea/jsLibraryMappings.xml @@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="JavaScriptLibraryMappings"> - <includedPredefinedLibrary name="Node.js Core" /> - </component> +<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="JavaScriptLibraryMappings">
+ <includedPredefinedLibrary name="Node.js Core" />
+ </component>
</project>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 9dbadc8..dd4efc1 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -1,8 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/Twilight.iml" filepath="$PROJECT_DIR$/.idea/Twilight.iml" /> - </modules> - </component> +<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/Twilight.iml" filepath="$PROJECT_DIR$/.idea/Twilight.iml" />
+ </modules>
+ </component>
</project>
\ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..9661ac7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$" vcs="Git" /> - </component> +<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
</project>
\ No newline at end of file @@ -1,3 +1,4 @@ + # Twilight A Git-based package manager made for Minteck's infrastructure and other things @@ -17,4 +18,4 @@ Install on macOS (Intel x86 or Apple Silicon): bash -c "$(curl https://twipkg.cdn.minteck.org/~installer/twipkg-onlineinstall-darwin-$(uname -p).sh)" ``` -> **Notice:** Twilight Package Manager is experimental on macOS, use with caution. +> **Notice:** Twilight Package Manager is experimental on macOS, use with caution.
\ No newline at end of file diff --git a/commands/aliases.json b/commands/aliases.json index 9a5754c..667eca9 100644 --- a/commands/aliases.json +++ b/commands/aliases.json @@ -1,12 +1,12 @@ -{ - "install": [ "i", "a", "add" ], - "reinstall": [ "ri", "reset", "rs" ], - "remove": [ "r", "del", "rm", "delete", "uninstall", "u" ], - "update": [ "ud", "fetch", "refresh", "reload", "rl" ], - "upgrade": [ "ug" ], - "purge": [ "p", "ori", "ors", "oreset", "oreinstall" ], - "info": [ "inf", "view", "v", "if" ], - "list": [ "l", "ls", "all" ], - "installed": [ "il", "lil", "lsil", "allil" ], - "installable": [ "ia", "lia", "lsia", "allia" ] +{
+ "install": [ "i", "a", "add" ],
+ "reinstall": [ "ri", "reset", "rs" ],
+ "remove": [ "r", "del", "rm", "delete", "uninstall", "u" ],
+ "update": [ "ud", "fetch", "refresh", "reload", "rl" ],
+ "upgrade": [ "ug" ],
+ "purge": [ "p", "ori", "ors", "oreset", "oreinstall" ],
+ "info": [ "inf", "view", "v", "if" ],
+ "list": [ "l", "ls", "all" ],
+ "installed": [ "il", "lil", "lsil", "allil" ],
+ "installable": [ "ia", "lia", "lsia", "allia" ]
}
\ No newline at end of file diff --git a/commands/info.js b/commands/info.js index 49b3162..b88e2b3 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,145 +1,145 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv) => { - const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - let pkgInstalled = false - if (installed.map(i => i.id).includes(argv.package)) { - pkgInstalled = true; - } - - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()); - - if (!packages.includes(argv.package)) { - die(c.red("error: ") + "package '" + argv.package + "' not in repository"); - } - - let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()); - - let compatible = true; - let replacement = null; - if (os.platform() === "win32" && pkg.platforms.windows === 0) { - compatible = false; - if (typeof pkg.replaced.windows === "string") { - replacement = pkg.replaced.windows - } - } else if (os.platform() === "linux" && pkg.platforms.linux === 0) { - compatible = false; - if (typeof pkg.replaced.linux === "string") { - replacement = pkg.replaced.linux - } - } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) { - compatible = false; - if (typeof pkg.replaced.mac === "string") { - replacement = pkg.replaced.mac - } - } - - let experimental = false; - if (os.platform() === "win32" && pkg.platforms.windows === 1) { - experimental = true; - } else if (os.platform() === "linux" && pkg.platforms.linux === 1) { - experimental = true; - } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) { - experimental = true; - } - - let version = pkg.verdata.latest; - let publisher = pkg.verdata.publisher.name; - let publisherMail = pkg.verdata.publisher.email; - let date = moment(pkg.verdata.date).fromNow(); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pkg.sign.signed) { - signed = true; - verified = pkg.sign.verified; - if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.name && pkg.sign.key) { - signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - console.log(c.bold(pkg.name + ": " + pkg.description)) - console.log(" " + c.magentaBright("version:") + " " + version); - console.log(" " + c.magentaBright("last update:") + " " + date); - console.log(" " + c.magentaBright("publisher:") + " " + publisher + " <" + publisherMail + ">"); - - if (signed) { - if (verified) { - console.log(" " + c.magentaBright("security:") + " " + c.green("verified") + "\n " + signInfo); - } else { - console.log(" " + c.magentaBright("security:") + " " + c.yellow("unverified") + "\n " + signInfo); - } - } else { - console.log(" " + c.magentaBright("security:") + " " + c.red.inverse("unsafe")); - } - - if (pkgInstalled) { - if (experimental) { - console.log(" " + c.magentaBright("state:") + " " + c.cyan("installed") + " (" + moment(installed.filter(i => i.id === pkg.id)[0].date).fromNow() + "), " + c.yellow("experimental")) - } else { - console.log(" " + c.magentaBright("state:") + " " + c.cyan("installed") + " (" + moment(installed.filter(i => i.id === pkg.id)[0].date).fromNow() + ")") - } - } else { - if (compatible) { - if (experimental) { - console.log(" " + c.magentaBright("state:") + " " + c.green("compatible") + ", " + c.yellow("experimental")); - } else { - console.log(" " + c.magentaBright("state:") + " " + c.green("compatible")); - } - } else { - if (typeof replacement === "string") { - console.log(" " + c.magentaBright("state:") + " " + c.red("incompatible") + " (replaced by: " + replacement + ")"); - } else { - console.log(" " + c.magentaBright("state:") + " " + c.red("incompatible") + " (no replacement)"); - } - } - } - - if (typeof pkg.deprecated === "string") { - if (pkg.deprecated.toString().trim() !== "") { - console.log(" " + c.magentaBright("support:") + " " + c.red("unsupported") + " (" + pkg.deprecated + ")"); - } else { - console.log(" " + c.magentaBright("support:") + " " + c.red("unsupported")); - } - } else if (typeof pkg.extended === "string") { - if (pkg.extended.toString().trim() !== "") { - console.log(" " + c.magentaBright("support:") + " " + c.yellow("extended") + " (" + pkg.extended + ")"); - } else { - console.log(" " + c.magentaBright("support:") + " " + c.yellow("extended")); - } - } else { - console.log(" " + c.magentaBright("support:") + " " + c.green("supported")); - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv) => {
+ const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+ let pkgInstalled = false
+ if (installed.map(i => i.id).includes(argv.package)) {
+ pkgInstalled = true;
+ }
+
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString());
+
+ if (!packages.includes(argv.package)) {
+ die(c.red("error: ") + "package '" + argv.package + "' not in repository");
+ }
+
+ let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString());
+
+ let compatible = true;
+ let replacement = null;
+ if (os.platform() === "win32" && pkg.platforms.windows === 0) {
+ compatible = false;
+ if (typeof pkg.replaced.windows === "string") {
+ replacement = pkg.replaced.windows
+ }
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 0) {
+ compatible = false;
+ if (typeof pkg.replaced.linux === "string") {
+ replacement = pkg.replaced.linux
+ }
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) {
+ compatible = false;
+ if (typeof pkg.replaced.mac === "string") {
+ replacement = pkg.replaced.mac
+ }
+ }
+
+ let experimental = false;
+ if (os.platform() === "win32" && pkg.platforms.windows === 1) {
+ experimental = true;
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 1) {
+ experimental = true;
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) {
+ experimental = true;
+ }
+
+ let version = pkg.verdata.latest;
+ let publisher = pkg.verdata.publisher.name;
+ let publisherMail = pkg.verdata.publisher.email;
+ let date = moment(pkg.verdata.date).fromNow();
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pkg.sign.signed) {
+ signed = true;
+ verified = pkg.sign.verified;
+ if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.name && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ console.log(c.bold(pkg.name + ": " + pkg.description))
+ console.log(" " + c.magentaBright("version:") + " " + version);
+ console.log(" " + c.magentaBright("last update:") + " " + date);
+ console.log(" " + c.magentaBright("publisher:") + " " + publisher + " <" + publisherMail + ">");
+
+ if (signed) {
+ if (verified) {
+ console.log(" " + c.magentaBright("security:") + " " + c.green("verified") + "\n " + signInfo);
+ } else {
+ console.log(" " + c.magentaBright("security:") + " " + c.yellow("unverified") + "\n " + signInfo);
+ }
+ } else {
+ console.log(" " + c.magentaBright("security:") + " " + c.red.inverse("unsafe"));
+ }
+
+ if (pkgInstalled) {
+ if (experimental) {
+ console.log(" " + c.magentaBright("state:") + " " + c.cyan("installed") + " (" + moment(installed.filter(i => i.id === pkg.id)[0].date).fromNow() + "), " + c.yellow("experimental"))
+ } else {
+ console.log(" " + c.magentaBright("state:") + " " + c.cyan("installed") + " (" + moment(installed.filter(i => i.id === pkg.id)[0].date).fromNow() + ")")
+ }
+ } else {
+ if (compatible) {
+ if (experimental) {
+ console.log(" " + c.magentaBright("state:") + " " + c.green("compatible") + ", " + c.yellow("experimental"));
+ } else {
+ console.log(" " + c.magentaBright("state:") + " " + c.green("compatible"));
+ }
+ } else {
+ if (typeof replacement === "string") {
+ console.log(" " + c.magentaBright("state:") + " " + c.red("incompatible") + " (replaced by: " + replacement + ")");
+ } else {
+ console.log(" " + c.magentaBright("state:") + " " + c.red("incompatible") + " (no replacement)");
+ }
+ }
+ }
+
+ if (typeof pkg.deprecated === "string") {
+ if (pkg.deprecated.toString().trim() !== "") {
+ console.log(" " + c.magentaBright("support:") + " " + c.red("unsupported") + " (" + pkg.deprecated + ")");
+ } else {
+ console.log(" " + c.magentaBright("support:") + " " + c.red("unsupported"));
+ }
+ } else if (typeof pkg.extended === "string") {
+ if (pkg.extended.toString().trim() !== "") {
+ console.log(" " + c.magentaBright("support:") + " " + c.yellow("extended") + " (" + pkg.extended + ")");
+ } else {
+ console.log(" " + c.magentaBright("support:") + " " + c.yellow("extended"));
+ }
+ } else {
+ console.log(" " + c.magentaBright("support:") + " " + c.green("supported"));
+ }
}
\ No newline at end of file diff --git a/commands/install.js b/commands/install.js index 0448f59..837f9ef 100644 --- a/commands/install.js +++ b/commands/install.js @@ -1,201 +1,201 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv) => { - const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - if (installed.map(i => i.id).includes(argv.package)) { - die(c.red("error: ") + "package '" + argv.package + "' is already installed (version " + installed.filter(i => i.id === argv.package)[0].version + ", installed " + moment(installed.filter(i => i.id === argv.package)[0].date).fromNow() + ")"); - } - - let spinner = ora("Reading package lists...").start(); - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()); - spinner.succeed("Reading packages lists... done"); - - if (!packages.includes(argv.package)) { - die(c.red("error: ") + "package '" + argv.package + "' not in repository"); - } - - let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()); - - let replacement = null; - if (os.platform() === "win32" && pkg.platforms.windows === 0) { - if (typeof pkg.replaced.windows === "string") { - replacement = pkg.replaced.windows - } - } else if (os.platform() === "linux" && pkg.platforms.linux === 0) { - if (typeof pkg.replaced.linux === "string") { - replacement = pkg.replaced.linux - } - } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) { - if (typeof pkg.replaced.mac === "string") { - replacement = pkg.replaced.mac - } - } - - if (os.platform() === "win32" && pkg.platforms.windows === 0) { - if (typeof replacement === "string") { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'win32', replaced by '" + replacement + "'"); - } else { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'win32', no replacement available"); - } - } else if (os.platform() === "linux" && pkg.platforms.linux === 0) { - if (typeof replacement === "string") { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'linux', replaced by '" + replacement + "'"); - } else { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'linux', no replacement available"); - } - } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) { - if (typeof replacement === "string") { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'macos', replaced by '" + replacement + "'"); - } else { - die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'macos', no replacement available"); - } - } - - if (os.platform() === "win32" && pkg.platforms.windows === 1) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'win32'"); - } else if (os.platform() === "linux" && pkg.platforms.linux === 1) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'linux'"); - } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'macos'"); - } - - spinner = ora("Checking dependencies...").start(); - for (let dependency of pkg.depends) { - let cmd = "which"; - if (os.platform() === "win32") { cmd = "where"; } - try { - if (require('child_process').spawnSync(cmd, [dependency]).status !== 0) { - spinner.fail("Checking dependencies... failed") - die(c.red("error: ") + "package '" + argv.package + "' depends on '" + dependency + "' which is not installed"); - } - } catch (e) { - spinner.fail("Checking dependencies... failed") - die(c.red("error: ") + "unable to check for '" + dependency + "'"); - } - } - spinner.succeed("Checking dependencies... done") - - let version = pkg.verdata.latest; - let publisher = pkg.verdata.publisher.name; - let publisherMail = pkg.verdata.publisher.email; - let date = moment(pkg.verdata.date).fromNow(); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pkg.sign.signed) { - signed = true; - verified = pkg.sign.verified; - if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.name && pkg.sign.key) { - signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - console.log(" Installing '" + pkg.name + "'...") - console.log(" version: " + version); - console.log(" release: " + date); - console.log(" publisher: " + publisher + " <" + publisherMail + ">"); - - if (signed) { - if (verified) { - console.log(" security: " + c.green("verified") + " " + signInfo); - } else { - console.log(" security: " + c.yellow("unverified") + " " + signInfo); - } - } else { - console.log(" security: " + c.red.inverse("unsafe")); - } - - if (typeof pkg.deprecated === "string") { - if (pkg.deprecated.toString().trim() !== "") { - console.log(c.yellow("warn: ") + "package '" + pkg.id + "' has been marked as deprecated: " + pkg.deprecated); - } else { - console.log(c.yellow("warn: ") + "package '" + pkg.id + "' has been marked as deprecated"); - } - } - - try { - if (!signed && !(await prompts.confirm({ - message: "This package is unsafe, installing it may damage your system. Are you sure you want to continue?", - initial: false - }))) { - die(); - } - } catch (e) { - die(); - } - - if (fs.existsSync(home + "/buildroot")) { fs.rmSync(home + "/buildroot", { recursive: true }) } - require('../hooks/clone')(pkg.repo, pkg.branch, () => { - spinner = ora("Extracting package...").start(); - fs.renameSync(home + "/buildroot", home + "/packages/" + pkg.id); - installed.push({ - id: pkg.id, - date: new Date().toISOString(), - version, - files: require('../hooks/files')(pkg.id) - }) - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed)); - spinner.succeed("Extracting package... done"); - console.log(" Size change: +" + require('../hooks/size')(pkg.id)); - - let exec = argv.package; - if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname === "string") { - exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname; - } - - if (os.platform() === "win32" && typeof pkg.executable.windows === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat", pkg.executable.windows); - } else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.linux); - require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) - } else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.mac); - require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) - } - - let postinstall = []; - if (os.platform() === "win32") postinstall = pkg.postinstall.windows; - if (os.platform() === "linux") postinstall = pkg.postinstall.linux; - if (os.platform() === "darwin") postinstall = pkg.postinstall.mac; - - if (postinstall.length > 0) { - spinner = ora("Running post-install hooks...").start(); - for (let hook of postinstall) { - require('child_process').execSync(hook, { stdio: "inherit" }) - } - spinner.succeed("Running post-install hooks... done"); - } - }) +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv) => {
+ const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+ if (installed.map(i => i.id).includes(argv.package)) {
+ die(c.red("error: ") + "package '" + argv.package + "' is already installed (version " + installed.filter(i => i.id === argv.package)[0].version + ", installed " + moment(installed.filter(i => i.id === argv.package)[0].date).fromNow() + ")");
+ }
+
+ let spinner = ora("Reading package lists...").start();
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString());
+ spinner.succeed("Reading packages lists... done");
+
+ if (!packages.includes(argv.package)) {
+ die(c.red("error: ") + "package '" + argv.package + "' not in repository");
+ }
+
+ let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString());
+
+ let replacement = null;
+ if (os.platform() === "win32" && pkg.platforms.windows === 0) {
+ if (typeof pkg.replaced.windows === "string") {
+ replacement = pkg.replaced.windows
+ }
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 0) {
+ if (typeof pkg.replaced.linux === "string") {
+ replacement = pkg.replaced.linux
+ }
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) {
+ if (typeof pkg.replaced.mac === "string") {
+ replacement = pkg.replaced.mac
+ }
+ }
+
+ if (os.platform() === "win32" && pkg.platforms.windows === 0) {
+ if (typeof replacement === "string") {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'win32', replaced by '" + replacement + "'");
+ } else {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'win32', no replacement available");
+ }
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 0) {
+ if (typeof replacement === "string") {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'linux', replaced by '" + replacement + "'");
+ } else {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'linux', no replacement available");
+ }
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) {
+ if (typeof replacement === "string") {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'macos', replaced by '" + replacement + "'");
+ } else {
+ die(c.red("error: ") + "package '" + argv.package + "' not available on platform 'macos', no replacement available");
+ }
+ }
+
+ if (os.platform() === "win32" && pkg.platforms.windows === 1) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'win32'");
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 1) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'linux'");
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' is experimental on platform 'macos'");
+ }
+
+ spinner = ora("Checking dependencies...").start();
+ for (let dependency of pkg.depends) {
+ let cmd = "which";
+ if (os.platform() === "win32") { cmd = "where"; }
+ try {
+ if (require('child_process').spawnSync(cmd, [dependency]).status !== 0) {
+ spinner.fail("Checking dependencies... failed")
+ die(c.red("error: ") + "package '" + argv.package + "' depends on '" + dependency + "' which is not installed");
+ }
+ } catch (e) {
+ spinner.fail("Checking dependencies... failed")
+ die(c.red("error: ") + "unable to check for '" + dependency + "'");
+ }
+ }
+ spinner.succeed("Checking dependencies... done")
+
+ let version = pkg.verdata.latest;
+ let publisher = pkg.verdata.publisher.name;
+ let publisherMail = pkg.verdata.publisher.email;
+ let date = moment(pkg.verdata.date).fromNow();
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pkg.sign.signed) {
+ signed = true;
+ verified = pkg.sign.verified;
+ if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.name && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ console.log(" Installing '" + pkg.name + "'...")
+ console.log(" version: " + version);
+ console.log(" release: " + date);
+ console.log(" publisher: " + publisher + " <" + publisherMail + ">");
+
+ if (signed) {
+ if (verified) {
+ console.log(" security: " + c.green("verified") + " " + signInfo);
+ } else {
+ console.log(" security: " + c.yellow("unverified") + " " + signInfo);
+ }
+ } else {
+ console.log(" security: " + c.red.inverse("unsafe"));
+ }
+
+ if (typeof pkg.deprecated === "string") {
+ if (pkg.deprecated.toString().trim() !== "") {
+ console.log(c.yellow("warn: ") + "package '" + pkg.id + "' has been marked as deprecated: " + pkg.deprecated);
+ } else {
+ console.log(c.yellow("warn: ") + "package '" + pkg.id + "' has been marked as deprecated");
+ }
+ }
+
+ try {
+ if (!signed && !(await prompts.confirm({
+ message: "This package is unsafe, installing it may damage your system. Are you sure you want to continue?",
+ initial: false
+ }))) {
+ die();
+ }
+ } catch (e) {
+ die();
+ }
+
+ if (fs.existsSync(home + "/buildroot")) { fs.rmSync(home + "/buildroot", { recursive: true }) }
+ require('../hooks/clone')(pkg.repo, pkg.branch, () => {
+ spinner = ora("Extracting package...").start();
+ fs.renameSync(home + "/buildroot", home + "/packages/" + pkg.id);
+ installed.push({
+ id: pkg.id,
+ date: new Date().toISOString(),
+ version,
+ files: require('../hooks/files')(pkg.id)
+ })
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed));
+ spinner.succeed("Extracting package... done");
+ console.log(" Size change: +" + require('../hooks/size')(pkg.id));
+
+ let exec = argv.package;
+ if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname === "string") {
+ exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname;
+ }
+
+ if (os.platform() === "win32" && typeof pkg.executable.windows === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat", pkg.executable.windows);
+ } else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.linux);
+ require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ])
+ } else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.mac);
+ require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ])
+ }
+
+ let postinstall = [];
+ if (os.platform() === "win32") postinstall = pkg.postinstall.windows;
+ if (os.platform() === "linux") postinstall = pkg.postinstall.linux;
+ if (os.platform() === "darwin") postinstall = pkg.postinstall.mac;
+
+ if (postinstall.length > 0) {
+ spinner = ora("Running post-install hooks...").start();
+ for (let hook of postinstall) {
+ require('child_process').execSync(hook, { stdio: "inherit" })
+ }
+ spinner.succeed("Running post-install hooks... done");
+ }
+ })
}
\ No newline at end of file diff --git a/commands/installable.js b/commands/installable.js index 00d1ecb..2c80d58 100644 --- a/commands/installable.js +++ b/commands/installable.js @@ -1,101 +1,101 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async () => { - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort(); - let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id); - let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - - let signs = {}; - let dates = {}; - let platforms = {}; - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pack.sign.signed) { - signed = true; - verified = pack.sign.verified; - if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) { - signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")"); - } else if (pack.sign.signer.name && pack.sign.key) { - signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - if (signed) { - if (verified) { - signs[pack.id] = c.green("verified"); - } else { - signs[pack.id] = c.yellow("unverified"); - } - } else { - signs[pack.id] = c.red("unsafe"); - } - - if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) { - platforms[pack.id] = c.cyan("all"); - } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) { - platforms[pack.id] = c.yellow("all"); - } else { - platforms[pack.id] = ""; - if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," } - if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," } - if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," } - if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," } - if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," } - if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," } - - if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) } - } - } - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - installable = true; - if (os.platform() === "win32" && pack.platforms.windows === 0) { - installable = false; - } else if (os.platform() === "linux" && pack.platforms.linux === 0) { - installable = false; - } else if (os.platform() === "darwin" && pack.platforms.mac === 0) { - installable = false; - } - - if (installable) { - console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id]) - } - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async () => {
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort();
+ let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id);
+ let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+
+ let signs = {};
+ let dates = {};
+ let platforms = {};
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pack.sign.signed) {
+ signed = true;
+ verified = pack.sign.verified;
+ if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) {
+ signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")");
+ } else if (pack.sign.signer.name && pack.sign.key) {
+ signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ if (signed) {
+ if (verified) {
+ signs[pack.id] = c.green("verified");
+ } else {
+ signs[pack.id] = c.yellow("unverified");
+ }
+ } else {
+ signs[pack.id] = c.red("unsafe");
+ }
+
+ if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) {
+ platforms[pack.id] = c.cyan("all");
+ } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) {
+ platforms[pack.id] = c.yellow("all");
+ } else {
+ platforms[pack.id] = "";
+ if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," }
+ if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," }
+ if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," }
+ if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," }
+ if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," }
+ if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," }
+
+ if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) }
+ }
+ }
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ installable = true;
+ if (os.platform() === "win32" && pack.platforms.windows === 0) {
+ installable = false;
+ } else if (os.platform() === "linux" && pack.platforms.linux === 0) {
+ installable = false;
+ } else if (os.platform() === "darwin" && pack.platforms.mac === 0) {
+ installable = false;
+ }
+
+ if (installable) {
+ console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id])
+ }
+ }
}
\ No newline at end of file diff --git a/commands/installed.js b/commands/installed.js index 11a7616..c22e538 100644 --- a/commands/installed.js +++ b/commands/installed.js @@ -1,93 +1,93 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async () => { - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort(); - let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id); - let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - - let signs = {}; - let dates = {}; - let platforms = {}; - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pack.sign.signed) { - signed = true; - verified = pack.sign.verified; - if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) { - signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")"); - } else if (pack.sign.signer.name && pack.sign.key) { - signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - if (signed) { - if (verified) { - signs[pack.id] = c.green("verified"); - } else { - signs[pack.id] = c.yellow("unverified"); - } - } else { - signs[pack.id] = c.red("unsafe"); - } - - if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) { - platforms[pack.id] = c.cyan("all"); - } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) { - platforms[pack.id] = c.yellow("all"); - } else { - platforms[pack.id] = ""; - if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," } - if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," } - if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," } - if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," } - if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," } - if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," } - - if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) } - } - } - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - let add = ""; - if (installed.includes(pack.id)) { - console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id] + add) - } - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async () => {
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort();
+ let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id);
+ let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+
+ let signs = {};
+ let dates = {};
+ let platforms = {};
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pack.sign.signed) {
+ signed = true;
+ verified = pack.sign.verified;
+ if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) {
+ signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")");
+ } else if (pack.sign.signer.name && pack.sign.key) {
+ signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ if (signed) {
+ if (verified) {
+ signs[pack.id] = c.green("verified");
+ } else {
+ signs[pack.id] = c.yellow("unverified");
+ }
+ } else {
+ signs[pack.id] = c.red("unsafe");
+ }
+
+ if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) {
+ platforms[pack.id] = c.cyan("all");
+ } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) {
+ platforms[pack.id] = c.yellow("all");
+ } else {
+ platforms[pack.id] = "";
+ if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," }
+ if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," }
+ if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," }
+ if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," }
+ if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," }
+ if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," }
+
+ if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) }
+ }
+ }
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ let add = "";
+ if (installed.includes(pack.id)) {
+ console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id] + add)
+ }
+ }
}
\ No newline at end of file diff --git a/commands/list.js b/commands/list.js index 40f5b65..871f821 100644 --- a/commands/list.js +++ b/commands/list.js @@ -1,99 +1,99 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async () => { - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort(); - let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id); - let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - - let signs = {}; - let dates = {}; - let platforms = {}; - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pack.sign.signed) { - signed = true; - verified = pack.sign.verified; - if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) { - signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")"); - } else if (pack.sign.signer.name && pack.sign.key) { - signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - if (signed) { - if (verified) { - signs[pack.id] = c.green("verified"); - } else { - signs[pack.id] = c.yellow("unverified"); - } - } else { - signs[pack.id] = c.red("unsafe"); - } - - if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) { - platforms[pack.id] = c.cyan("all"); - } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) { - platforms[pack.id] = c.yellow("all"); - } else { - platforms[pack.id] = ""; - if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," } - if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," } - if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," } - if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," } - if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," } - if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," } - - if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) } - } - } - - for (let pkg of packages) { - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString()); - - let add = ""; - if (installed.includes(pack.id)) { - if (installs.filter(i => i.id === pack.id)[0].version !== pack.verdata.latest) { - add = c.gray(" [upgradable]"); - } else { - add = c.gray(" [installed]"); - } - } - - console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id] + add) - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async () => {
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()).sort();
+ let installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()).map(i => i.id);
+ let installs = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+
+ let signs = {};
+ let dates = {};
+ let platforms = {};
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pack.sign.signed) {
+ signed = true;
+ verified = pack.sign.verified;
+ if (pack.sign.signer.name && pack.sign.signer.email && pack.sign.key) {
+ signInfo = pack.sign.signer.name + " <" + pack.sign.signer.email + "> " + c.gray("(" + pack.sign.key + ")");
+ } else if (pack.sign.signer.name && pack.sign.key) {
+ signInfo = pack.sign.signer.name + c.gray(" (" + pack.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ if (signed) {
+ if (verified) {
+ signs[pack.id] = c.green("verified");
+ } else {
+ signs[pack.id] = c.yellow("unverified");
+ }
+ } else {
+ signs[pack.id] = c.red("unsafe");
+ }
+
+ if (pack.platforms.windows === 2 && pack.platforms.linux === 2 && pack.platforms.mac === 2) {
+ platforms[pack.id] = c.cyan("all");
+ } else if (pack.platforms.windows === 1 && pack.platforms.linux === 1 && pack.platforms.mac === 1) {
+ platforms[pack.id] = c.yellow("all");
+ } else {
+ platforms[pack.id] = "";
+ if (pack.platforms.windows === 1) { platforms[pack.id] += c.yellow("win32") + "," }
+ if (pack.platforms.windows === 2) { platforms[pack.id] += c.cyan("win32") + "," }
+ if (pack.platforms.linux === 1) { platforms[pack.id] += c.yellow("linux") + "," }
+ if (pack.platforms.linux === 2) { platforms[pack.id] += c.cyan("linux") + "," }
+ if (pack.platforms.mac === 1) { platforms[pack.id] += c.yellow("macos") + "," }
+ if (pack.platforms.mac === 2) { platforms[pack.id] += c.cyan("macos") + "," }
+
+ if (platforms[pack.id].endsWith(",")) { platforms[pack.id] = platforms[pack.id].substring(0, platforms[pack.id].length - 1) }
+ }
+ }
+
+ for (let pkg of packages) {
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pack = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg + ".json").toString());
+
+ let add = "";
+ if (installed.includes(pack.id)) {
+ if (installs.filter(i => i.id === pack.id)[0].version !== pack.verdata.latest) {
+ add = c.gray(" [upgradable]");
+ } else {
+ add = c.gray(" [installed]");
+ }
+ }
+
+ console.log(c.green(pack.id) + "/" + signs[pack.id] + " " + pack.verdata.latest + " " + platforms[pack.id] + add)
+ }
}
\ No newline at end of file diff --git a/commands/purge.js b/commands/purge.js index 96f8b75..f698bdc 100644 --- a/commands/purge.js +++ b/commands/purge.js @@ -1,79 +1,79 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv) => { - const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - if (!installed.map(i => i.id).includes(argv.package)) { - die(c.red("error: ") + "package '" + argv.package + "' is not installed"); - } - - let spinner = ora("Reading package lists...").start(); - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()); - spinner.succeed("Reading packages lists... done"); - - let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - - if (!packages.includes(argv.package)) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore"); - name = argv.package; - } else { - name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name; - } - - instInfo = installed.filter(i => i.id === argv.package)[0]; - - console.log(" Purging '" + name + "'...") - console.log(" version: " + instInfo.version); - console.log(" installed: " + moment(instInfo.date).fromNow()); - - try { - if (!(await prompts.confirm({ - message: "Purging this package will delete all associated data. Are you sure you want to continue?", - initial: false - }))) { - die(); - } - } catch (e) { - die(); - } - - spinner = ora("Reading files list...").start(); - files1 = instInfo.files; - files2 = require('../hooks/files')(instInfo.id); - filesR = files2.filter(f => !files1.includes(f)); - spinner.succeed("Reading files list... done"); - if (filesR.length === 0) { - die(c.red("error: ") + "this installation of package '" + argv.package + "' cannot be purged, use 'twi reinstall' instead"); - } - - spinner = ora("Removing user files...").start(); - let index = 0 - for (let file of filesR) { - spinner.text = "Removing user files... " + Math.round((index / filesR.length) * 100) + "%"; - fs.rmSync(home + "/packages/" + argv.package + "/" + file); - index++; - } - spinner.succeed("Removing user files... done"); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv) => {
+ const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+ if (!installed.map(i => i.id).includes(argv.package)) {
+ die(c.red("error: ") + "package '" + argv.package + "' is not installed");
+ }
+
+ let spinner = ora("Reading package lists...").start();
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString());
+ spinner.succeed("Reading packages lists... done");
+
+ let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+
+ if (!packages.includes(argv.package)) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore");
+ name = argv.package;
+ } else {
+ name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name;
+ }
+
+ instInfo = installed.filter(i => i.id === argv.package)[0];
+
+ console.log(" Purging '" + name + "'...")
+ console.log(" version: " + instInfo.version);
+ console.log(" installed: " + moment(instInfo.date).fromNow());
+
+ try {
+ if (!(await prompts.confirm({
+ message: "Purging this package will delete all associated data. Are you sure you want to continue?",
+ initial: false
+ }))) {
+ die();
+ }
+ } catch (e) {
+ die();
+ }
+
+ spinner = ora("Reading files list...").start();
+ files1 = instInfo.files;
+ files2 = require('../hooks/files')(instInfo.id);
+ filesR = files2.filter(f => !files1.includes(f));
+ spinner.succeed("Reading files list... done");
+ if (filesR.length === 0) {
+ die(c.red("error: ") + "this installation of package '" + argv.package + "' cannot be purged, use 'twi reinstall' instead");
+ }
+
+ spinner = ora("Removing user files...").start();
+ let index = 0
+ for (let file of filesR) {
+ spinner.text = "Removing user files... " + Math.round((index / filesR.length) * 100) + "%";
+ fs.rmSync(home + "/packages/" + argv.package + "/" + file);
+ index++;
+ }
+ spinner.succeed("Removing user files... done");
}
\ No newline at end of file diff --git a/commands/reinstall.js b/commands/reinstall.js index 497979f..dbadf8a 100644 --- a/commands/reinstall.js +++ b/commands/reinstall.js @@ -1,30 +1,30 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv) => { - await require('./remove')(argv, true); - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(JSON.parse(fs.readFileSync(os.homedir() + "/.twilight/installed.json").toString()).filter(i => i !== null))); - await require('./install')(argv); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv) => {
+ await require('./remove')(argv, true);
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(JSON.parse(fs.readFileSync(os.homedir() + "/.twilight/installed.json").toString()).filter(i => i !== null)));
+ await require('./install')(argv);
}
\ No newline at end of file diff --git a/commands/remove.js b/commands/remove.js index bde1e81..dc26eae 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -1,120 +1,120 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv, reinstalling) => { - if (reinstalling === undefined) { - reinstalling = false; - } - - const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - if (!installed.map(i => i.id).includes(argv.package)) { - die(c.red("error: ") + "package '" + argv.package + "' is not installed"); - } - - let spinner = ora("Reading package lists...").start(); - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()); - spinner.succeed("Reading packages lists... done"); - let updated = false; - - let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - - if (!packages.includes(argv.package)) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for name"); - name = argv.package; - } else { - name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name; - } - - if (argv.package === "twilight") { - die(c.red("error: ") + "package 'twilight' is system package and cannot be uninstalled, use 'twilight-setup' instead"); - } - - instInfo = installed.filter(i => i.id === argv.package)[0]; - - console.log(" Uninstalling '" + name + "'...") - console.log(" version: " + instInfo.version); - console.log(" installed: " + moment(instInfo.date).fromNow()); - console.log(" size: " + require('../hooks/size.js')(argv.package)); - - if (reinstalling) { - try { - if (!(await prompts.confirm({ - message: "Reinstalling this package will delete all associated data. Are you sure you want to continue?", - initial: false - }))) { - die(); - } - } catch (e) { - die(); - } - } else { - try { - if (!(await prompts.confirm({ - message: "Uninstalling this package will also delete all associated data. Are you sure you want to continue?", - initial: false - }))) { - die(); - } - } catch (e) { - die(); - } - } - - spinner = ora("Removing package...").start(); - fs.rmSync(home + "/packages/" + argv.package, { recursive: true }); - delete installed[installed.map(i => i.id).indexOf(argv.package)]; - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed)); - - let exec = argv.package; - if (!packages.includes(argv.package)) { - exec = argv.package; - } else if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname === "string") { - exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname; - } - if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat"); - if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh"); - if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec)) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec); - - spinner.succeed("Removing package... done"); - - if (!packages.includes(argv.package)) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for post-remove hooks"); - } else { - ppr = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).postremove; - - let postremove = []; - if (os.platform() === "win32") postremove = ppr.windows; - if (os.platform() === "linux") postremove = ppr.linux; - if (os.platform() === "darwin") postremove = ppr.mac; - - if (postremove.length > 0) { - spinner = ora("Running post-remove hooks...").start(); - for (let hook of postremove) { - require('child_process').execSync(hook, { stdio: "inherit" }) - } - spinner.succeed("Running post-remove hooks... done"); - } - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv, reinstalling) => {
+ if (reinstalling === undefined) {
+ reinstalling = false;
+ }
+
+ const installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+ if (!installed.map(i => i.id).includes(argv.package)) {
+ die(c.red("error: ") + "package '" + argv.package + "' is not installed");
+ }
+
+ let spinner = ora("Reading package lists...").start();
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString());
+ spinner.succeed("Reading packages lists... done");
+ let updated = false;
+
+ let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+
+ if (!packages.includes(argv.package)) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for name");
+ name = argv.package;
+ } else {
+ name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name;
+ }
+
+ if (argv.package === "twilight") {
+ die(c.red("error: ") + "package 'twilight' is system package and cannot be uninstalled, use 'twilight-setup' instead");
+ }
+
+ instInfo = installed.filter(i => i.id === argv.package)[0];
+
+ console.log(" Uninstalling '" + name + "'...")
+ console.log(" version: " + instInfo.version);
+ console.log(" installed: " + moment(instInfo.date).fromNow());
+ console.log(" size: " + require('../hooks/size.js')(argv.package));
+
+ if (reinstalling) {
+ try {
+ if (!(await prompts.confirm({
+ message: "Reinstalling this package will delete all associated data. Are you sure you want to continue?",
+ initial: false
+ }))) {
+ die();
+ }
+ } catch (e) {
+ die();
+ }
+ } else {
+ try {
+ if (!(await prompts.confirm({
+ message: "Uninstalling this package will also delete all associated data. Are you sure you want to continue?",
+ initial: false
+ }))) {
+ die();
+ }
+ } catch (e) {
+ die();
+ }
+ }
+
+ spinner = ora("Removing package...").start();
+ fs.rmSync(home + "/packages/" + argv.package, { recursive: true });
+ delete installed[installed.map(i => i.id).indexOf(argv.package)];
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed));
+
+ let exec = argv.package;
+ if (!packages.includes(argv.package)) {
+ exec = argv.package;
+ } else if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname === "string") {
+ exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname;
+ }
+ if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat");
+ if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh");
+ if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec)) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec);
+
+ spinner.succeed("Removing package... done");
+
+ if (!packages.includes(argv.package)) {
+ console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for post-remove hooks");
+ } else {
+ ppr = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).postremove;
+
+ let postremove = [];
+ if (os.platform() === "win32") postremove = ppr.windows;
+ if (os.platform() === "linux") postremove = ppr.linux;
+ if (os.platform() === "darwin") postremove = ppr.mac;
+
+ if (postremove.length > 0) {
+ spinner = ora("Running post-remove hooks...").start();
+ for (let hook of postremove) {
+ require('child_process').execSync(hook, { stdio: "inherit" })
+ }
+ spinner.succeed("Running post-remove hooks... done");
+ }
+ }
}
\ No newline at end of file diff --git a/commands/update.js b/commands/update.js index 3b1bae8..ad34165 100644 --- a/commands/update.js +++ b/commands/update.js @@ -1,28 +1,28 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async (argv) => { - await require('../hooks/update')(); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async (argv) => {
+ await require('../hooks/update')();
}
\ No newline at end of file diff --git a/commands/upgrade.js b/commands/upgrade.js index 60f47fc..ac36fd9 100644 --- a/commands/upgrade.js +++ b/commands/upgrade.js @@ -1,236 +1,236 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -async function processQueue() { - let pack = installed.filter(i => i.id === queue[0])[0]; - let dir = pack.id.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pack.id + ".json").toString()); - let installable = true; - - let version = pkg.verdata.latest; - let publisher = pkg.verdata.publisher.name; - let publisherMail = pkg.verdata.publisher.email; - let date = moment(pkg.verdata.date).fromNow(); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pkg.sign.signed) { - signed = true; - verified = pkg.sign.verified; - if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.name && pkg.sign.key) { - signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - spinner = ora("Checking dependencies...").start(); - for (let dependency of pkg.depends) { - let cmd = "which"; - if (os.platform() === "win32") { cmd = "where"; } - try { - if (require('child_process').spawnSync(cmd, [dependency]).status !== 0) { - spinner.fail("Checking dependencies... failed") - die(c.red("error: ") + "package '" + pack.id + "' depends on '" + dependency + "' which is not installed"); - } - } catch (e) { - spinner.fail("Checking dependencies... failed") - die(c.red("error: ") + "unable to check for '" + dependency + "'"); - } - } - spinner.succeed("Checking dependencies... done") - - console.log(" Installing '" + pkg.name + "'...") - console.log(" version: " + pack.version + " -> " + version); - console.log(" release: " + date); - console.log(" publisher: " + publisher + " <" + publisherMail + ">"); - - if (signed) { - if (verified) { - console.log(" security: " + c.green("verified") + " " + signInfo); - } else { - console.log(" security: " + c.yellow("unverified") + " " + signInfo); - } - } else { - console.log(" security: " + c.red.inverse("unsafe")); - } - - try { - if (!signed && !(await prompts.confirm({ - message: "This package is unsafe, installing it may damage your system. Are you sure you want to continue?", - initial: false - }))) { - installable = false; - } - } catch (e) { - installable = false; - } - - if (installable) { - if (fs.existsSync(home + "/buildroot")) { fs.rmSync(home + "/buildroot", { recursive: true }) } - require('../hooks/clone')(pkg.repo, pkg.branch, async () => { - spinner = ora("Extracting package...").start(); - if (fs.existsSync(home + "/packages/" + pkg.id + "--update-" + version)) fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true }) - fs.renameSync(home + "/buildroot", home + "/packages/" + pkg.id + "--update-" + version); - let change = require('../hooks/diff')(pkg.id, pkg.id + "--update-" + version); - require('../hooks/apply_update')(pkg.id, pkg.id + "--update-" + version); - fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true }); - delete installed[installed.map(i => i.id).indexOf(pkg.id)]; - installed.push({ - id: pkg.id, - date: new Date().toISOString(), - version, - files: require('../hooks/files')(pkg.id) - }) - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed)); - spinner.succeed("Extracting package... done"); - console.log(" Size change: " + change); - - let exec = pkg.id; - if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg.id + ".json").toString()).execname === "string") { - exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg.id + ".json").toString()).execname; - } - - if (os.platform() === "win32" && typeof pkg.executable.windows === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".bat", pkg.executable.windows); - } else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.linux); - require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) - } else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") { - fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.mac); - require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) - } - - let postinstall = []; - if (os.platform() === "win32") postinstall = pkg.postinstall.windows; - if (os.platform() === "linux") postinstall = pkg.postinstall.linux; - if (os.platform() === "darwin") postinstall = pkg.postinstall.mac; - - if (postinstall.length > 0) { - spinner = ora("Running post-install hooks...").start(); - for (let hook of postinstall) { - require('child_process').execSync(hook, { stdio: "inherit" }) - } - spinner.succeed("Running post-install hooks... done"); - } - - queue.shift(); - if (queue.length > 0) await processQueue(); - }) - } -} - -module.exports = async (argv) => { - global.installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString()); - - let spinner = ora("Reading package lists...").start(); - let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString()); - spinner.succeed("Reading packages lists... done"); - let updated = false; - let affected = false; - global.queue = []; - - for (let pack of installed) { - if (!packages.includes(pack.id)) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' not in repository anymore"); - } else { - let installable = true; - let dir = pack.id.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pack.id + ".json").toString()); - if ((argv.package !== undefined && argv.package === pack.id) || argv.package === undefined) { - updated = true; - - if (os.platform() === "win32" && pkg.platforms.windows === 0) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'win32' anymore"); - installable = false; - } else if (os.platform() === "linux" && pkg.platforms.linux === 0) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'linux' anymore"); - installable = false; - } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'macos' anymore"); - installable = false; - } - - if (os.platform() === "win32" && pkg.platforms.windows === 1) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'win32'"); - } else if (os.platform() === "linux" && pkg.platforms.linux === 1) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'linux'"); - } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) { - console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'macos'"); - } - - if (installable) { - let version = pkg.verdata.latest; - let publisher = pkg.verdata.publisher.name; - let publisherMail = pkg.verdata.publisher.email; - let date = moment(pkg.verdata.date).fromNow(); - - let signed = false; - let signInfo = ""; - let verified = false; - - if (pkg.sign.signed) { - signed = true; - verified = pkg.sign.verified; - if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.name && pkg.sign.key) { - signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.signer.email && pkg.sign.key) { - signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")"); - } else if (pkg.sign.key) { - signInfo = pkg.sign.key; - } - } - - if (pack.version !== version) { - queue.push(pack.id); - affected = true; - } else if (argv.package !== undefined && argv.package === pack.id) { - die(c.red("error: ") + "package '" + argv.package + "' is up to date"); - } - } else if (argv.package !== undefined && argv.package === pack.id) { - die(c.red("error: ") + "package '" + argv.package + "' cannot be updated"); - } - } - } - } - - if (!updated) { - die(c.red("error: ") + "package '" + argv.package + "' not installed"); - } - - if (!affected) { - die("All packages are up to date"); - } - - await processQueue(); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+async function processQueue() {
+ let pack = installed.filter(i => i.id === queue[0])[0];
+ let dir = pack.id.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pack.id + ".json").toString());
+ let installable = true;
+
+ let version = pkg.verdata.latest;
+ let publisher = pkg.verdata.publisher.name;
+ let publisherMail = pkg.verdata.publisher.email;
+ let date = moment(pkg.verdata.date).fromNow();
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pkg.sign.signed) {
+ signed = true;
+ verified = pkg.sign.verified;
+ if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.name && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ spinner = ora("Checking dependencies...").start();
+ for (let dependency of pkg.depends) {
+ let cmd = "which";
+ if (os.platform() === "win32") { cmd = "where"; }
+ try {
+ if (require('child_process').spawnSync(cmd, [dependency]).status !== 0) {
+ spinner.fail("Checking dependencies... failed")
+ die(c.red("error: ") + "package '" + pack.id + "' depends on '" + dependency + "' which is not installed");
+ }
+ } catch (e) {
+ spinner.fail("Checking dependencies... failed")
+ die(c.red("error: ") + "unable to check for '" + dependency + "'");
+ }
+ }
+ spinner.succeed("Checking dependencies... done")
+
+ console.log(" Installing '" + pkg.name + "'...")
+ console.log(" version: " + pack.version + " -> " + version);
+ console.log(" release: " + date);
+ console.log(" publisher: " + publisher + " <" + publisherMail + ">");
+
+ if (signed) {
+ if (verified) {
+ console.log(" security: " + c.green("verified") + " " + signInfo);
+ } else {
+ console.log(" security: " + c.yellow("unverified") + " " + signInfo);
+ }
+ } else {
+ console.log(" security: " + c.red.inverse("unsafe"));
+ }
+
+ try {
+ if (!signed && !(await prompts.confirm({
+ message: "This package is unsafe, installing it may damage your system. Are you sure you want to continue?",
+ initial: false
+ }))) {
+ installable = false;
+ }
+ } catch (e) {
+ installable = false;
+ }
+
+ if (installable) {
+ if (fs.existsSync(home + "/buildroot")) { fs.rmSync(home + "/buildroot", { recursive: true }) }
+ require('../hooks/clone')(pkg.repo, pkg.branch, async () => {
+ spinner = ora("Extracting package...").start();
+ if (fs.existsSync(home + "/packages/" + pkg.id + "--update-" + version)) fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true })
+ fs.renameSync(home + "/buildroot", home + "/packages/" + pkg.id + "--update-" + version);
+ let change = require('../hooks/diff')(pkg.id, pkg.id + "--update-" + version);
+ require('../hooks/apply_update')(pkg.id, pkg.id + "--update-" + version);
+ fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true });
+ delete installed[installed.map(i => i.id).indexOf(pkg.id)];
+ installed.push({
+ id: pkg.id,
+ date: new Date().toISOString(),
+ version,
+ files: require('../hooks/files')(pkg.id)
+ })
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed));
+ spinner.succeed("Extracting package... done");
+ console.log(" Size change: " + change);
+
+ let exec = pkg.id;
+ if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg.id + ".json").toString()).execname === "string") {
+ exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg.id + ".json").toString()).execname;
+ }
+
+ if (os.platform() === "win32" && typeof pkg.executable.windows === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".bat", pkg.executable.windows);
+ } else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.linux);
+ require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ])
+ } else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") {
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.mac);
+ require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ])
+ }
+
+ let postinstall = [];
+ if (os.platform() === "win32") postinstall = pkg.postinstall.windows;
+ if (os.platform() === "linux") postinstall = pkg.postinstall.linux;
+ if (os.platform() === "darwin") postinstall = pkg.postinstall.mac;
+
+ if (postinstall.length > 0) {
+ spinner = ora("Running post-install hooks...").start();
+ for (let hook of postinstall) {
+ require('child_process').execSync(hook, { stdio: "inherit" })
+ }
+ spinner.succeed("Running post-install hooks... done");
+ }
+
+ queue.shift();
+ if (queue.length > 0) await processQueue();
+ })
+ }
+}
+
+module.exports = async (argv) => {
+ global.installed = JSON.parse(fs.readFileSync(home + "/installed.json").toString());
+
+ let spinner = ora("Reading package lists...").start();
+ let packages = JSON.parse(fs.readFileSync(home + "/repository/list.json").toString());
+ spinner.succeed("Reading packages lists... done");
+ let updated = false;
+ let affected = false;
+ global.queue = [];
+
+ for (let pack of installed) {
+ if (!packages.includes(pack.id)) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' not in repository anymore");
+ } else {
+ let installable = true;
+ let dir = pack.id.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ let pkg = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pack.id + ".json").toString());
+ if ((argv.package !== undefined && argv.package === pack.id) || argv.package === undefined) {
+ updated = true;
+
+ if (os.platform() === "win32" && pkg.platforms.windows === 0) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'win32' anymore");
+ installable = false;
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 0) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'linux' anymore");
+ installable = false;
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'macos' anymore");
+ installable = false;
+ }
+
+ if (os.platform() === "win32" && pkg.platforms.windows === 1) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'win32'");
+ } else if (os.platform() === "linux" && pkg.platforms.linux === 1) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'linux'");
+ } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) {
+ console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'macos'");
+ }
+
+ if (installable) {
+ let version = pkg.verdata.latest;
+ let publisher = pkg.verdata.publisher.name;
+ let publisherMail = pkg.verdata.publisher.email;
+ let date = moment(pkg.verdata.date).fromNow();
+
+ let signed = false;
+ let signInfo = "";
+ let verified = false;
+
+ if (pkg.sign.signed) {
+ signed = true;
+ verified = pkg.sign.verified;
+ if (pkg.sign.signer.name && pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + " <" + pkg.sign.signer.email + "> " + c.gray("(" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.name && pkg.sign.key) {
+ signInfo = pkg.sign.signer.name + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.signer.email && pkg.sign.key) {
+ signInfo = pkg.sign.signer.email + c.gray(" (" + pkg.sign.key + ")");
+ } else if (pkg.sign.key) {
+ signInfo = pkg.sign.key;
+ }
+ }
+
+ if (pack.version !== version) {
+ queue.push(pack.id);
+ affected = true;
+ } else if (argv.package !== undefined && argv.package === pack.id) {
+ die(c.red("error: ") + "package '" + argv.package + "' is up to date");
+ }
+ } else if (argv.package !== undefined && argv.package === pack.id) {
+ die(c.red("error: ") + "package '" + argv.package + "' cannot be updated");
+ }
+ }
+ }
+ }
+
+ if (!updated) {
+ die(c.red("error: ") + "package '" + argv.package + "' not installed");
+ }
+
+ if (!affected) {
+ die("All packages are up to date");
+ }
+
+ await processQueue();
}
\ No newline at end of file diff --git a/hooks/apply_update.js b/hooks/apply_update.js index 4afef0a..aa7496c 100644 --- a/hooks/apply_update.js +++ b/hooks/apply_update.js @@ -1,57 +1,57 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = (pkg, tempDir) => { - const getAllDirs = function(dirPath, arrayOfFiles) { - files = fs.readdirSync(dirPath) - - arrayOfFiles = arrayOfFiles || [] - - files.forEach(function(file) { - if (file !== ".git") { - if (fs.statSync(dirPath + "/" + file).isDirectory()) { - arrayOfFiles.push(dirPath + "/" + file) - arrayOfFiles = getAllDirs(dirPath + "/" + file, arrayOfFiles) - } - } - }) - - return arrayOfFiles - } - - dirs = getAllDirs((home + "/packages/" + tempDir).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + tempDir).replaceAll("\\", "/") + "/", "")); - for (let dir of dirs) { - if (!fs.existsSync(home + "/packages/" + pkg + "/" + dir)) { - fs.mkdirSync(home + "/packages/" + pkg + "/" + dir); - } - } - - files = require('./files')(tempDir); - for (let file of files) { - if (file.trim() !== "") { - fs.copyFileSync(home + "/packages/" + tempDir + "/" + file, home + "/packages/" + pkg + "/" + file); - } - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = (pkg, tempDir) => {
+ const getAllDirs = function(dirPath, arrayOfFiles) {
+ files = fs.readdirSync(dirPath)
+
+ arrayOfFiles = arrayOfFiles || []
+
+ files.forEach(function(file) {
+ if (file !== ".git") {
+ if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+ arrayOfFiles.push(dirPath + "/" + file)
+ arrayOfFiles = getAllDirs(dirPath + "/" + file, arrayOfFiles)
+ }
+ }
+ })
+
+ return arrayOfFiles
+ }
+
+ dirs = getAllDirs((home + "/packages/" + tempDir).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + tempDir).replaceAll("\\", "/") + "/", ""));
+ for (let dir of dirs) {
+ if (!fs.existsSync(home + "/packages/" + pkg + "/" + dir)) {
+ fs.mkdirSync(home + "/packages/" + pkg + "/" + dir);
+ }
+ }
+
+ files = require('./files')(tempDir);
+ for (let file of files) {
+ if (file.trim() !== "") {
+ fs.copyFileSync(home + "/packages/" + tempDir + "/" + file, home + "/packages/" + pkg + "/" + file);
+ }
+ }
}
\ No newline at end of file diff --git a/hooks/clone.js b/hooks/clone.js index c68922e..315a6e5 100644 --- a/hooks/clone.js +++ b/hooks/clone.js @@ -1,53 +1,53 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = (repo, branch, callback) => { - const spinner = ora("Downloading package...").start(); - - if (os.platform() === "win32") { - git = require('child_process').execSync("where git").toString().trim(); - } else { - git = require('child_process').execSync("which git").toString().trim(); - } - - cp = require('child_process').spawn(git, ["clone", "--progress", "-b", branch, "--", repo, home + "/buildroot"], {/*stdio: "inherit"*/}); - - cp.stdout.on('data', (data) => { - spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1]; - }) - - cp.stderr.on('data', (data) => { - spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1].replace(/[^0-9a-zA-z: -,.!? \/\(\)]*/gm, ""); - }) - - cp.on('close', (code) => { - if (code !== 0) { - throw new Error("Process exited with code " + code); - } else { - spinner.succeed("Downloading package... done"); - callback(); - } - }) +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = (repo, branch, callback) => {
+ const spinner = ora("Downloading package...").start();
+
+ if (os.platform() === "win32") {
+ git = require('child_process').execSync("where git").toString().trim();
+ } else {
+ git = require('child_process').execSync("which git").toString().trim();
+ }
+
+ cp = require('child_process').spawn(git, ["clone", "--progress", "-b", branch, "--", repo, home + "/buildroot"], {/*stdio: "inherit"*/});
+
+ cp.stdout.on('data', (data) => {
+ spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1];
+ })
+
+ cp.stderr.on('data', (data) => {
+ spinner.text = data.toString().trim().split("\n")[data.toString().trim().split("\n").length - 1].replace(/[^0-9a-zA-z: -,.!? \/\(\)]*/gm, "");
+ })
+
+ cp.on('close', (code) => {
+ if (code !== 0) {
+ throw new Error("Process exited with code " + code);
+ } else {
+ spinner.succeed("Downloading package... done");
+ callback();
+ }
+ })
}
\ No newline at end of file diff --git a/hooks/diff.js b/hooks/diff.js index c3cb161..616634e 100644 --- a/hooks/diff.js +++ b/hooks/diff.js @@ -1,67 +1,67 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -const getAllFiles = function(dirPath, arrayOfFiles) { - files = fs.readdirSync(dirPath) - - arrayOfFiles = arrayOfFiles || [] - - files.forEach(function(file) { - if (file !== ".git") { - if (fs.statSync(dirPath + "/" + file).isDirectory()) { - arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles) - } else { - arrayOfFiles.push(dirPath + "/" + file) - } - } - }) - - return arrayOfFiles -} - -module.exports = (pkg1, pkg2) => { - asize1 = getAllFiles((home + "/packages/" + pkg1).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg1).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg1 + "/" + i).length).reduce((a, b) => a + b); - asize2 = getAllFiles((home + "/packages/" + pkg2).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg2).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg2 + "/" + i).length).reduce((a, b) => a + b); - - asize = asize2 - asize1; - if (asize > 0) { - s = "+"; - } else if (asize < 0) { - s = "-"; - } else { - s = "±"; - } - asize = Math.abs(asize); - - if (asize > 1024) { - if (asize > 1048576) { - return s + (asize / 1048576).toFixed(1) + "M"; - } else { - return s + (asize / 1024).toFixed(1) + "K"; - } - } else { - return s + asize + "B"; - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+const getAllFiles = function(dirPath, arrayOfFiles) {
+ files = fs.readdirSync(dirPath)
+
+ arrayOfFiles = arrayOfFiles || []
+
+ files.forEach(function(file) {
+ if (file !== ".git") {
+ if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+ arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
+ } else {
+ arrayOfFiles.push(dirPath + "/" + file)
+ }
+ }
+ })
+
+ return arrayOfFiles
+}
+
+module.exports = (pkg1, pkg2) => {
+ asize1 = getAllFiles((home + "/packages/" + pkg1).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg1).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg1 + "/" + i).length).reduce((a, b) => a + b);
+ asize2 = getAllFiles((home + "/packages/" + pkg2).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg2).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg2 + "/" + i).length).reduce((a, b) => a + b);
+
+ asize = asize2 - asize1;
+ if (asize > 0) {
+ s = "+";
+ } else if (asize < 0) {
+ s = "-";
+ } else {
+ s = "±";
+ }
+ asize = Math.abs(asize);
+
+ if (asize > 1024) {
+ if (asize > 1048576) {
+ return s + (asize / 1048576).toFixed(1) + "M";
+ } else {
+ return s + (asize / 1024).toFixed(1) + "K";
+ }
+ } else {
+ return s + asize + "B";
+ }
}
\ No newline at end of file diff --git a/hooks/files.js b/hooks/files.js index f1bdd1a..8e26dee 100644 --- a/hooks/files.js +++ b/hooks/files.js @@ -1,46 +1,46 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -const getAllFiles = function(dirPath, arrayOfFiles) { - files = fs.readdirSync(dirPath) - - arrayOfFiles = arrayOfFiles || [] - - files.forEach(function(file) { - if (file !== ".git") { - if (fs.statSync(dirPath + "/" + file).isDirectory()) { - arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles) - } else { - arrayOfFiles.push(dirPath + "/" + file) - } - } - }) - - return arrayOfFiles -} - -module.exports = (pkg) => { - return getAllFiles((home + "/packages/" + pkg).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg).replaceAll("\\", "/") + "/", "")); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+const getAllFiles = function(dirPath, arrayOfFiles) {
+ files = fs.readdirSync(dirPath)
+
+ arrayOfFiles = arrayOfFiles || []
+
+ files.forEach(function(file) {
+ if (file !== ".git") {
+ if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+ arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
+ } else {
+ arrayOfFiles.push(dirPath + "/" + file)
+ }
+ }
+ })
+
+ return arrayOfFiles
+}
+
+module.exports = (pkg) => {
+ return getAllFiles((home + "/packages/" + pkg).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg).replaceAll("\\", "/") + "/", ""));
}
\ No newline at end of file diff --git a/hooks/size.js b/hooks/size.js index 63320e1..84d9d3e 100644 --- a/hooks/size.js +++ b/hooks/size.js @@ -1,56 +1,56 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -const getAllFiles = function(dirPath, arrayOfFiles) { - files = fs.readdirSync(dirPath) - - arrayOfFiles = arrayOfFiles || [] - - files.forEach(function(file) { - if (file !== ".git") { - if (fs.statSync(dirPath + "/" + file).isDirectory()) { - arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles) - } else { - arrayOfFiles.push(dirPath + "/" + file) - } - } - }) - - return arrayOfFiles -} - -module.exports = (pkg) => { - asize = getAllFiles((home + "/packages/" + pkg).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg + "/" + i).length).reduce((a, b) => a + b); - - if (asize > 1024) { - if (asize > 1048576) { - return (asize / 1048576).toFixed(1) + "M"; - } else { - return (asize / 1024).toFixed(1) + "K"; - } - } else { - return asize + "B"; - } +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+const getAllFiles = function(dirPath, arrayOfFiles) {
+ files = fs.readdirSync(dirPath)
+
+ arrayOfFiles = arrayOfFiles || []
+
+ files.forEach(function(file) {
+ if (file !== ".git") {
+ if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+ arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
+ } else {
+ arrayOfFiles.push(dirPath + "/" + file)
+ }
+ }
+ })
+
+ return arrayOfFiles
+}
+
+module.exports = (pkg) => {
+ asize = getAllFiles((home + "/packages/" + pkg).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + pkg).replaceAll("\\", "/") + "/", "")).map(i => fs.readFileSync(home + "/packages/" + pkg + "/" + i).length).reduce((a, b) => a + b);
+
+ if (asize > 1024) {
+ if (asize > 1048576) {
+ return (asize / 1048576).toFixed(1) + "M";
+ } else {
+ return (asize / 1024).toFixed(1) + "K";
+ }
+ } else {
+ return asize + "B";
+ }
}
\ No newline at end of file diff --git a/hooks/update.js b/hooks/update.js index d049d13..e2d4b8a 100644 --- a/hooks/update.js +++ b/hooks/update.js @@ -1,102 +1,122 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -module.exports = async () => { - const spinner = ora("Fetching package lists...").start(); - let list = (await axios.get("https://twipkg.cdn.minteck.org/packages.json")).data; - - if (fs.existsSync(home + "/repository")) { - fs.rmSync(home + "/repository", { recursive: true }); - } - fs.mkdirSync(home + "/repository"); - - fs.writeFileSync(home + "/repository/list.json", JSON.stringify(list)); - - let index = 0; - for (let pkg of list) { - spinner.text = "Fetching package lists... " + Math.round((index / list.length) * 100) + "%"; - let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); - try { - let pack = (await axios.get("https://twipkg.cdn.minteck.org/" + dir + "/" + pkg + ".json")).data; - - let verdata = (await axios.get(pack.version)).data; - pack.verdata = { - latest: verdata.commit.short_id, - publisher: { - name: verdata.commit.author_name, - email: verdata.commit.author_email - }, - date: verdata.commit.created_at - } - - if (typeof pack.pointrelease === "string") { - pack.verdata.latest = pack.pointrelease; - } - - let signRaw = { error: "404 Not Found" }; - try { - signRaw = (await axios.get(pack.signature.replace("{version}", verdata.commit.id))).data; - } catch (e) {} - pack.sign = { - signed: false, - verified: false, - key: null, - signer: { - name: null, - email: null - } - } - if (signRaw.error !== "404 Not Found") { - pack.sign.signed = true; - if (signRaw.verification_status === "verified") { - pack.sign.verified = true; - } else { - pack.sign.verified = false; - } - if (signRaw.gpg_key_user_name) { - pack.sign.signer.name = signRaw.gpg_key_user_name; - } - if (signRaw.gpg_key_user_email) { - pack.sign.signer.email = signRaw.gpg_key_user_email; - } - if (signRaw.gpg_key_primary_keyid) { - pack.sign.key = signRaw.gpg_key_primary_keyid; - } - } - - if (!fs.existsSync(home + "/repository/" + dir)) { - fs.mkdirSync(home + "/repository/" + dir); - } - fs.writeFileSync(home + "/repository/" + dir + "/" + pkg + ".json", JSON.stringify(pack)); - } catch (e) { - console.log("\n" + c.yellow("warn:") + " package '" + pkg + "' is not available on the repository yet"); - } - - index++; - } - - spinner.succeed("Fetching package lists... done"); - //process.exit(); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+module.exports = async () => {
+ let oldPercentage = -1;
+ let oldPercTime = new Date();
+ let timePerPerc = -1;
+ let timePerPercData = [];
+ let eta = -1;
+
+ const spinner = ora("Fetching package lists...").start();
+ let list = (await axios.get("https://twipkg.cdn.minteck.org/packages.json")).data;
+
+ if (fs.existsSync(home + "/repository")) {
+ fs.rmSync(home + "/repository", { recursive: true });
+ }
+ fs.mkdirSync(home + "/repository");
+
+ fs.writeFileSync(home + "/repository/list.json", JSON.stringify(list));
+
+ let index = 0;
+ for (let pkg of list) {
+ if ((index / list.length) * 100 !== oldPercentage) {
+ timePerPercData.push(oldPercTime - new Date());
+ timePerPerc = timePerPercData.reduce((x, y) => x + y) / timePerPercData.length;
+ eta = -((timePerPerc * (100 - ((index / list.length) * 100))) / 1000);
+ oldPercTime = new Date();
+ }
+ if (eta > 1) {
+ if (eta > 60) {
+ spinner.text = "Fetching package lists... " + Math.round((index / list.length) * 100) + "%, " + Math.round(eta / 60) + " minute" + (Math.round(eta / 60) > 1 ? "s" : "");
+ } else {
+ spinner.text = "Fetching package lists... " + Math.round((index / list.length) * 100) + "%, " + Math.round(eta) + " second" + (Math.round(eta) > 1 ? "s" : "");
+ }
+ } else {
+ spinner.text = "Fetching package lists... " + Math.round((index / list.length) * 100) + "%";
+ }
+ let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
+ try {
+ let pack = (await axios.get("https://twipkg.cdn.minteck.org/" + dir + "/" + pkg + ".json")).data;
+
+ let verdata = (await axios.get(pack.version)).data;
+ pack.verdata = {
+ latest: verdata.commit.short_id,
+ publisher: {
+ name: verdata.commit.author_name,
+ email: verdata.commit.author_email
+ },
+ date: verdata.commit.created_at
+ }
+
+ if (typeof pack.pointrelease === "string") {
+ pack.verdata.latest = pack.pointrelease;
+ }
+
+ let signRaw = { error: "404 Not Found" };
+ try {
+ signRaw = (await axios.get(pack.signature.replace("{version}", verdata.commit.id))).data;
+ } catch (e) {}
+ pack.sign = {
+ signed: false,
+ verified: false,
+ key: null,
+ signer: {
+ name: null,
+ email: null
+ }
+ }
+ if (signRaw.error !== "404 Not Found") {
+ pack.sign.signed = true;
+ if (signRaw.verification_status === "verified") {
+ pack.sign.verified = true;
+ } else {
+ pack.sign.verified = false;
+ }
+ if (signRaw.gpg_key_user_name) {
+ pack.sign.signer.name = signRaw.gpg_key_user_name;
+ }
+ if (signRaw.gpg_key_user_email) {
+ pack.sign.signer.email = signRaw.gpg_key_user_email;
+ }
+ if (signRaw.gpg_key_primary_keyid) {
+ pack.sign.key = signRaw.gpg_key_primary_keyid;
+ }
+ }
+
+ if (!fs.existsSync(home + "/repository/" + dir)) {
+ fs.mkdirSync(home + "/repository/" + dir);
+ }
+ fs.writeFileSync(home + "/repository/" + dir + "/" + pkg + ".json", JSON.stringify(pack));
+ } catch (e) {
+ console.log("\n" + c.yellow("warn:") + " package '" + pkg + "' is not available on the repository yet");
+ }
+
+ index++;
+ }
+
+ spinner.succeed("Fetching package lists... done");
+ //process.exit();
}
\ No newline at end of file @@ -1,145 +1,145 @@ -/* - * MIT License - * - * Copyright (c) 2022- Minteck - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -process.on('uncaughtException', async (e) => { - global.c = (await import('chalk')).default; - - if (!fs.existsSync(os.homedir() + "/.twilight/crashes")) { - fs.mkdirSync(os.homedir() + "/.twilight/crashes") - } - - let date = new Date().toISOString().replace(/[^a-zA-Z0-9-]/gm, "-"); - fs.writeFileSync(require('os').homedir() + "/.twilight/crashes/" + date + ".txt", e.stack); - - console.log(c.red("error:") + " an internal error occurred, did you forget to run 'twi update'?"); - console.log(" additionally, a crash report has been saved to:\n " + require('os').homedir() + (require('os').platform() === "win32" ? "\\" : "/") + ".twilight" + (require('os').platform() === "win32" ? "\\" : "/") + "crashes" + (require('os').platform() === "win32" ? "\\" : "/") + date + ".txt") - process.exit(2); -}) - -try { - (async () => { - global.yargs = require('yargs/yargs'); - const { hideBin } = require('yargs/helpers'); - global.git = require('simple-git'); - global.ora = (await import('ora')).default; - global.c = (await import('chalk')).default; - global.fs = require('fs'); - global.os = require('os'); - global.axios = require('axios'); - global.moment = require('moment'); - global.prompts = require('prompts').prompts; - - - if (!fs.existsSync(os.homedir() + "/.twilight")) { - fs.mkdirSync(os.homedir() + "/.twilight") - } - - if (!fs.existsSync(os.homedir() + "/.twilight/packages")) { - fs.mkdirSync(os.homedir() + "/.twilight/packages") - } - - if (!fs.existsSync(os.homedir() + "/.twilight/crashes")) { - fs.mkdirSync(os.homedir() + "/.twilight/crashes") - } - - if (!fs.existsSync(os.homedir() + "/.twilight/binaries")) { - fs.mkdirSync(os.homedir() + "/.twilight/binaries") - } - - if (!fs.existsSync(os.homedir() + "/.twilight/installed.json")) { - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", "[]"); - } else { - fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(JSON.parse(fs.readFileSync(os.homedir() + "/.twilight/installed.json").toString()).filter(i => i !== null))); - } - - global.home = os.homedir() + "/.twilight"; - - global.die = (text, code) => { - fs.rmSync(home + "/runtime.pid"); - if (text) { - console.log(text); - if (code) { - process.exit(code); - } else { - process.exit(); - } - } else { - if (code) { - process.exit(code); - } else { - process.exit(); - } - } - } - let pargv = process.argv; - pargv[1] = "twi"; - - global.argv = yargs(pargv.slice(2)) - .command(["install <package>", "i <package>", "a <package>", "add <package>"], "Install a package") - .command(["reinstall <package>", "ri <package>", "reset <package>", "rs <package>"], "Online reinstall an installed package") - .command(["remove <package>", "r <package>", "del <package>", "rm <package>", "delete <package>", "uninstall <package>", "u <package>"], "Delete a package") - .command(["update", "ud", "fetch", "refresh", "reload", "rl"], "Fetches the repository") - .command(["upgrade [package]", "ug [package]"], "Update one or all package(s)") - .command(["purge <package>", "p <package>", "ori <package>", "ors <package>", "oreset <package>", "oreinstall <package>"], "Offline reinstall an installed package") - .command(["info <package>", "inf <package>", "view <package>", "v <package>", "if <package>"], "Get info about a package") - .command(["list", "l", "ls", "all"], "List all packages in the repository") - .command(["installed", "il", "lil", "lsil", "allil"], "List all installed packages") - .command(["installable", "ia", "lia", "lsia", "allia"], "List all compatible packages") - .help() - .alias("help", "h") - .alias("version", "V") - .example("twi install neutron", "Install Neutron") - .example("twi update", "Update all packages") - .example("twi info ponyfind", "Show info about Ponyfind") - .strictCommands() - .demandCommand(1) - .epilog("Twilight Package Manager v" + require('./package.json').version) - .usage('Usage: twi <command> [arguments...]') - .argv; - - if (fs.existsSync(home + "/runtime.pid")) { - let pid = fs.readFileSync(home + "/runtime.pid") - 1 + 1; - try { - process.kill(pid, 0); - die(c.red("error:") + " another instance is running (" + pid + ")"); - } catch (e) { - console.log(c.yellow("warn:") + " process was stopped unexpectedly"); - } - } - - fs.writeFileSync(home + "/runtime.pid", process.pid.toString()); - let command = argv._[0]; - let aliases = require('./commands/aliases.json'); - if ([].concat(Object.keys(aliases).map(i => aliases[i])).flat(1).includes(command)) { - command = Object.keys(aliases).map(i => { if (aliases[i].includes(command)) { return i; } else { return null; } }).filter(i => i !== null)[0]; - } - await require('./commands/' + command)(argv); - - fs.rmSync(home + "/runtime.pid"); - })() -} catch (e) { - console.log("error: an internal error occurred, did you forget to run 'twi update'?"); - process.exit(2); +/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+process.on('uncaughtException', async (e) => {
+ global.c = (await import('chalk')).default;
+
+ if (!fs.existsSync(os.homedir() + "/.twilight/crashes")) {
+ fs.mkdirSync(os.homedir() + "/.twilight/crashes")
+ }
+
+ let date = new Date().toISOString().replace(/[^a-zA-Z0-9-]/gm, "-");
+ fs.writeFileSync(require('os').homedir() + "/.twilight/crashes/" + date + ".txt", e.stack);
+
+ console.log(c.red("error:") + " an internal error occurred, did you forget to run 'twi update'?");
+ console.log(" additionally, a crash report has been saved to:\n " + require('os').homedir() + (require('os').platform() === "win32" ? "\\" : "/") + ".twilight" + (require('os').platform() === "win32" ? "\\" : "/") + "crashes" + (require('os').platform() === "win32" ? "\\" : "/") + date + ".txt")
+ process.exit(2);
+})
+
+try {
+ (async () => {
+ global.yargs = require('yargs/yargs');
+ const { hideBin } = require('yargs/helpers');
+ global.git = require('simple-git');
+ global.ora = (await import('ora')).default;
+ global.c = (await import('chalk')).default;
+ global.fs = require('fs');
+ global.os = require('os');
+ global.axios = require('axios');
+ global.moment = require('moment');
+ global.prompts = require('prompts').prompts;
+
+
+ if (!fs.existsSync(os.homedir() + "/.twilight")) {
+ fs.mkdirSync(os.homedir() + "/.twilight")
+ }
+
+ if (!fs.existsSync(os.homedir() + "/.twilight/packages")) {
+ fs.mkdirSync(os.homedir() + "/.twilight/packages")
+ }
+
+ if (!fs.existsSync(os.homedir() + "/.twilight/crashes")) {
+ fs.mkdirSync(os.homedir() + "/.twilight/crashes")
+ }
+
+ if (!fs.existsSync(os.homedir() + "/.twilight/binaries")) {
+ fs.mkdirSync(os.homedir() + "/.twilight/binaries")
+ }
+
+ if (!fs.existsSync(os.homedir() + "/.twilight/installed.json")) {
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", "[]");
+ } else {
+ fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(JSON.parse(fs.readFileSync(os.homedir() + "/.twilight/installed.json").toString()).filter(i => i !== null)));
+ }
+
+ global.home = os.homedir() + "/.twilight";
+
+ global.die = (text, code) => {
+ fs.rmSync(home + "/runtime.pid");
+ if (text) {
+ console.log(text);
+ if (code) {
+ process.exit(code);
+ } else {
+ process.exit();
+ }
+ } else {
+ if (code) {
+ process.exit(code);
+ } else {
+ process.exit();
+ }
+ }
+ }
+ let pargv = process.argv;
+ pargv[1] = "twi";
+
+ global.argv = yargs(pargv.slice(2))
+ .command(["install <package>", "i <package>", "a <package>", "add <package>"], "Install a package")
+ .command(["reinstall <package>", "ri <package>", "reset <package>", "rs <package>"], "Online reinstall an installed package")
+ .command(["remove <package>", "r <package>", "del <package>", "rm <package>", "delete <package>", "uninstall <package>", "u <package>"], "Delete a package")
+ .command(["update", "ud", "fetch", "refresh", "reload", "rl"], "Fetches the repository")
+ .command(["upgrade [package]", "ug [package]"], "Update one or all package(s)")
+ .command(["purge <package>", "p <package>", "ori <package>", "ors <package>", "oreset <package>", "oreinstall <package>"], "Offline reinstall an installed package")
+ .command(["info <package>", "inf <package>", "view <package>", "v <package>", "if <package>"], "Get info about a package")
+ .command(["list", "l", "ls", "all"], "List all packages in the repository")
+ .command(["installed", "il", "lil", "lsil", "allil"], "List all installed packages")
+ .command(["installable", "ia", "lia", "lsia", "allia"], "List all compatible packages")
+ .help()
+ .alias("help", "h")
+ .alias("version", "V")
+ .example("twi install neutron", "Install Neutron")
+ .example("twi update", "Update all packages")
+ .example("twi info ponyfind", "Show info about Ponyfind")
+ .strictCommands()
+ .demandCommand(1)
+ .epilog("Twilight Package Manager v" + require('./package.json').version)
+ .usage('Usage: twi <command> [arguments...]')
+ .argv;
+
+ if (fs.existsSync(home + "/runtime.pid")) {
+ let pid = fs.readFileSync(home + "/runtime.pid") - 1 + 1;
+ try {
+ process.kill(pid, 0);
+ die(c.red("error:") + " another instance is running (" + pid + ")");
+ } catch (e) {
+ console.log(c.yellow("warn:") + " process was stopped unexpectedly");
+ }
+ }
+
+ fs.writeFileSync(home + "/runtime.pid", process.pid.toString());
+ let command = argv._[0];
+ let aliases = require('./commands/aliases.json');
+ if ([].concat(Object.keys(aliases).map(i => aliases[i])).flat(1).includes(command)) {
+ command = Object.keys(aliases).map(i => { if (aliases[i].includes(command)) { return i; } else { return null; } }).filter(i => i !== null)[0];
+ }
+ await require('./commands/' + command)(argv);
+
+ fs.rmSync(home + "/runtime.pid");
+ })()
+} catch (e) {
+ console.log("error: an internal error occurred, did you forget to run 'twi update'?");
+ process.exit(2);
}
\ No newline at end of file diff --git a/node_modules/color-name/LICENSE b/node_modules/color-name/LICENSE index 4d9802a..c6b1001 100644 --- a/node_modules/color-name/LICENSE +++ b/node_modules/color-name/LICENSE @@ -1,8 +1,8 @@ -The MIT License (MIT) -Copyright (c) 2015 Dmitry Ivanov - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - +The MIT License (MIT)
+Copyright (c) 2015 Dmitry Ivanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/color-name/README.md b/node_modules/color-name/README.md index 3611a6b..932b979 100644 --- a/node_modules/color-name/README.md +++ b/node_modules/color-name/README.md @@ -1,11 +1,11 @@ -A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors. - -[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/) - - -```js -var colors = require('color-name'); -colors.red //[255,0,0] -``` - -<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a> +A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
+
+[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/)
+
+
+```js
+var colors = require('color-name');
+colors.red //[255,0,0]
+```
+
+<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>
diff --git a/node_modules/color-name/index.js b/node_modules/color-name/index.js index e42aa68..b7c198a 100644 --- a/node_modules/color-name/index.js +++ b/node_modules/color-name/index.js @@ -1,152 +1,152 @@ -'use strict' - -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; +'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
diff --git a/node_modules/color-name/package.json b/node_modules/color-name/package.json index 7acc902..782dd82 100644 --- a/node_modules/color-name/package.json +++ b/node_modules/color-name/package.json @@ -1,28 +1,28 @@ -{ - "name": "color-name", - "version": "1.1.4", - "description": "A list of color names and its values", - "main": "index.js", - "files": [ - "index.js" - ], - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "git@github.com:colorjs/color-name.git" - }, - "keywords": [ - "color-name", - "color", - "color-keyword", - "keyword" - ], - "author": "DY <dfcreative@gmail.com>", - "license": "MIT", - "bugs": { - "url": "https://github.com/colorjs/color-name/issues" - }, - "homepage": "https://github.com/colorjs/color-name" -} +{
+ "name": "color-name",
+ "version": "1.1.4",
+ "description": "A list of color names and its values",
+ "main": "index.js",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:colorjs/color-name.git"
+ },
+ "keywords": [
+ "color-name",
+ "color",
+ "color-keyword",
+ "keyword"
+ ],
+ "author": "DY <dfcreative@gmail.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/colorjs/color-name/issues"
+ },
+ "homepage": "https://github.com/colorjs/color-name"
+}
|