mirror of
https://github.com/pesde-pkg/tooling.git
synced 2024-12-12 07:10:36 +00:00
feat: dynamically fetch tool version from manifest
This commit is contained in:
parent
7e78d73854
commit
50f665bb08
2 changed files with 43 additions and 18 deletions
|
@ -3,8 +3,8 @@ version = "0.1.0"
|
|||
target = "lune"
|
||||
|
||||
[graph."0x5eal/semver"."0.1.1 luau"]
|
||||
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }]
|
||||
ty = "standard"
|
||||
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }, "standard"]
|
||||
resolved_ty = "standard"
|
||||
|
||||
[graph."0x5eal/semver"."0.1.1 luau".target]
|
||||
environment = "luau"
|
||||
|
@ -30,8 +30,8 @@ environment = "luau"
|
|||
lib = "lib/init.luau"
|
||||
|
||||
[graph."jiwonz/dirs"."0.1.2 lune"]
|
||||
direct = ["dirs", { name = "jiwonz/dirs", version = "^0.1.1" }]
|
||||
ty = "standard"
|
||||
direct = ["dirs", { name = "jiwonz/dirs", version = "^0.1.1" }, "standard"]
|
||||
resolved_ty = "standard"
|
||||
|
||||
[graph."jiwonz/dirs"."0.1.2 lune".target]
|
||||
environment = "lune"
|
||||
|
@ -54,8 +54,8 @@ environment = "lune"
|
|||
lib = "src/init.luau"
|
||||
|
||||
[graph."jiwonz/pathfs"."0.1.0 lune"]
|
||||
direct = ["pathfs", { name = "jiwonz/pathfs", version = "^0.1.0" }]
|
||||
ty = "standard"
|
||||
direct = ["pathfs", { name = "jiwonz/pathfs", version = "^0.1.0" }, "standard"]
|
||||
resolved_ty = "standard"
|
||||
|
||||
[graph."jiwonz/pathfs"."0.1.0 lune".target]
|
||||
environment = "lune"
|
||||
|
@ -72,8 +72,8 @@ environment = "lune"
|
|||
lib = "init.luau"
|
||||
|
||||
[graph."lukadev_0/option"."1.2.0 lune"]
|
||||
direct = ["option", { name = "lukadev_0/option", version = "^1.2.0" }]
|
||||
ty = "standard"
|
||||
direct = ["option", { name = "lukadev_0/option", version = "^1.2.0" }, "peer"]
|
||||
resolved_ty = "standard"
|
||||
|
||||
[graph."lukadev_0/option"."1.2.0 lune".target]
|
||||
environment = "lune"
|
||||
|
@ -90,7 +90,7 @@ environment = "lune"
|
|||
lib = "lib/init.luau"
|
||||
|
||||
[graph."lukadev_0/option"."1.2.0 luau"]
|
||||
ty = "peer"
|
||||
resolved_ty = "peer"
|
||||
|
||||
[graph."lukadev_0/option"."1.2.0 luau".target]
|
||||
environment = "luau"
|
||||
|
@ -107,8 +107,8 @@ environment = "luau"
|
|||
lib = "lib/init.luau"
|
||||
|
||||
[graph."lukadev_0/result"."1.2.0 lune"]
|
||||
direct = ["result", { name = "lukadev_0/result", version = "^1.2.0" }]
|
||||
ty = "standard"
|
||||
direct = ["result", { name = "lukadev_0/result", version = "^1.2.0" }, "peer"]
|
||||
resolved_ty = "standard"
|
||||
|
||||
[graph."lukadev_0/result"."1.2.0 lune".target]
|
||||
environment = "lune"
|
||||
|
@ -125,7 +125,7 @@ environment = "lune"
|
|||
lib = "lib/init.luau"
|
||||
|
||||
[graph."lukadev_0/result"."1.2.0 luau"]
|
||||
ty = "peer"
|
||||
resolved_ty = "peer"
|
||||
|
||||
[graph."lukadev_0/result"."1.2.0 luau".target]
|
||||
environment = "luau"
|
||||
|
|
|
@ -1,12 +1,37 @@
|
|||
local stdio = require("@lune/stdio")
|
||||
local process = require("@lune/process")
|
||||
local fs = require("@lune/fs")
|
||||
local serde = require("@lune/serde")
|
||||
|
||||
local core = require("./lune_packages/core")
|
||||
local Semver = require("./luau_packages/semver")
|
||||
local Option = require("./lune_packages/option")
|
||||
type Option<T> = Option.Option<T>
|
||||
|
||||
-- TODO: Use _G.PESDE_ROOT to get the install directory, then decode the
|
||||
-- Use _G.PESDE_ROOT to get the install directory, then decode the
|
||||
-- pesde manifest to get the version of the tool dynamically
|
||||
core.installTool({
|
||||
alias = Option.Some("lune"),
|
||||
repo = "lune-org/lune",
|
||||
version = Option.Some(Semver.parse("0.8.9"):unwrap()) :: Option<Semver.SemverImpl>,
|
||||
} :: core.ToolId)
|
||||
local PLATFORM_SEP = if process.platform == "windows" then "\\" else "/"
|
||||
local ERROR_PREFIX = `{stdio.color("red")}{stdio.style("bold")}error{stdio.color("reset")}:`
|
||||
|
||||
local manifestContents = fs.readFile(`{_G.PESDE_ROOT}{PLATFORM_SEP}pesde.toml`)
|
||||
|
||||
-- TODO: Create a pesde manifest type in binlib, and use that here
|
||||
local ok, manifest = pcall(serde.decode, "toml", manifestContents)
|
||||
if not ok then
|
||||
stdio.ewrite(`{ERROR_PREFIX} Failed to decode bundled manifest. This is probably a bug.\n\n{manifest}`)
|
||||
process.exit(1)
|
||||
end
|
||||
|
||||
local ok, err = pcall(
|
||||
core.installTool,
|
||||
{
|
||||
alias = Option.None,
|
||||
repo = "lune-org/lune",
|
||||
version = Option.Some(Semver.parse(manifest.version):unwrap()) :: Option<Semver.SemverImpl>,
|
||||
} :: core.ToolId
|
||||
)
|
||||
|
||||
if not ok then
|
||||
stdio.ewrite(`{ERROR_PREFIX} Failed to install {manifest.name}@{manifest.version}`)
|
||||
stdio.ewrite(` - {err}`)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue