diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7924a3f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright © 2024 pesde-pkg + +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/bins/stylua/init.luau b/bins/stylua/init.luau index be769a9..29c47e3 100644 --- a/bins/stylua/init.luau +++ b/bins/stylua/init.luau @@ -1 +1,2 @@ -require("./lune_packages/core")("JohnnyMorganz/stylua", _G.PESDE_ROOT) +local process = require("@lune/process") +process.exit(require("./lune_packages/core")("JohnnyMorganz/stylua", _G.PESDE_ROOT)) diff --git a/toolchainlib/LICENSE.md b/toolchainlib/LICENSE.md new file mode 120000 index 0000000..7eabdb1 --- /dev/null +++ b/toolchainlib/LICENSE.md @@ -0,0 +1 @@ +../LICENSE.md \ No newline at end of file diff --git a/toolchainlib/src/init.luau b/toolchainlib/src/init.luau index 51c7daa..286d980 100644 --- a/toolchainlib/src/init.luau +++ b/toolchainlib/src/init.luau @@ -203,7 +203,7 @@ return setmetatable( installTool = installTool, } :: LibExports, { - __call = function(lib: LibExportsImpl, tool: string, pesdeRoot: string?) + __call = function(lib: LibExportsImpl, tool: string, pesdeRoot: string?): number -- TODO: Progress bar maybe? :D local ERROR_PREFIX = `{stdio.color("red")}{stdio.style("bold")}error{stdio.color("reset")}:` @@ -211,13 +211,13 @@ return setmetatable( local repo, version = string.match(tool, "([^@]+)@?(.*)") if repo == nil then stdio.ewrite(`{ERROR_PREFIX} Invalid tool provided\n`) - process.exit(1) + return 1 end - local function manifestVersion(): string + local function manifestVersion(): (number, string?) if pesdeRoot == nil then stdio.ewrite(`{ERROR_PREFIX} Failed to discover pesde package root\n`) - process.exit(1) + return 1, nil end -- Use _G.PESDE_ROOT to get the install directory, then decode the @@ -229,10 +229,10 @@ return setmetatable( stdio.ewrite( `{ERROR_PREFIX} Failed to decode bundled manifest. This is probably a bug.\n\n{manifest}` ) - process.exit(1) + return 1, nil end - return manifest.version + return 0, manifest.version end local toolId = string.gsub(repo :: string, "/", "+") @@ -241,9 +241,17 @@ return setmetatable( `{toolAlias}-` .. if version ~= "" then version :: string else manifestVersion() ) - print(toolInstallPath) if pathfs.isFile(toolInstallPath) then - process.exit(lib.runTool(toolInstallPath)) + return lib.runTool(toolInstallPath) + end + + local versionOrDefault: string = version :: string + if versionOrDefault == "" then + local code, ver = manifestVersion() + if code ~= 0 then + return code + end + versionOrDefault = ver :: string end local ok, err = pcall( @@ -251,9 +259,7 @@ return setmetatable( { alias = Option.None, repo = repo, - version = Option.Some( - Semver.parse(if version ~= "" then version :: string else manifestVersion()):unwrap() - ) :: Option, + version = Option.Some(Semver.parse(versionOrDefault):unwrap()) :: Option, } :: ToolId, toolInstallPath ) @@ -261,7 +267,10 @@ return setmetatable( if not ok then stdio.ewrite(`{ERROR_PREFIX} Failed to install {tool}\n`) stdio.ewrite(` - {err}\n`) + return 1 end + + return 0 end, } )