feat: dynamically fetch tool version from manifest

This commit is contained in:
Erica Marigold 2024-11-23 13:41:12 +00:00
parent 7e78d73854
commit 50f665bb08
2 changed files with 43 additions and 18 deletions

View file

@ -3,8 +3,8 @@ version = "0.1.0"
target = "lune" target = "lune"
[graph."0x5eal/semver"."0.1.1 luau"] [graph."0x5eal/semver"."0.1.1 luau"]
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }] direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }, "standard"]
ty = "standard" resolved_ty = "standard"
[graph."0x5eal/semver"."0.1.1 luau".target] [graph."0x5eal/semver"."0.1.1 luau".target]
environment = "luau" environment = "luau"
@ -30,8 +30,8 @@ environment = "luau"
lib = "lib/init.luau" lib = "lib/init.luau"
[graph."jiwonz/dirs"."0.1.2 lune"] [graph."jiwonz/dirs"."0.1.2 lune"]
direct = ["dirs", { name = "jiwonz/dirs", version = "^0.1.1" }] direct = ["dirs", { name = "jiwonz/dirs", version = "^0.1.1" }, "standard"]
ty = "standard" resolved_ty = "standard"
[graph."jiwonz/dirs"."0.1.2 lune".target] [graph."jiwonz/dirs"."0.1.2 lune".target]
environment = "lune" environment = "lune"
@ -54,8 +54,8 @@ environment = "lune"
lib = "src/init.luau" lib = "src/init.luau"
[graph."jiwonz/pathfs"."0.1.0 lune"] [graph."jiwonz/pathfs"."0.1.0 lune"]
direct = ["pathfs", { name = "jiwonz/pathfs", version = "^0.1.0" }] direct = ["pathfs", { name = "jiwonz/pathfs", version = "^0.1.0" }, "standard"]
ty = "standard" resolved_ty = "standard"
[graph."jiwonz/pathfs"."0.1.0 lune".target] [graph."jiwonz/pathfs"."0.1.0 lune".target]
environment = "lune" environment = "lune"
@ -72,8 +72,8 @@ environment = "lune"
lib = "init.luau" lib = "init.luau"
[graph."lukadev_0/option"."1.2.0 lune"] [graph."lukadev_0/option"."1.2.0 lune"]
direct = ["option", { name = "lukadev_0/option", version = "^1.2.0" }] direct = ["option", { name = "lukadev_0/option", version = "^1.2.0" }, "peer"]
ty = "standard" resolved_ty = "standard"
[graph."lukadev_0/option"."1.2.0 lune".target] [graph."lukadev_0/option"."1.2.0 lune".target]
environment = "lune" environment = "lune"
@ -90,7 +90,7 @@ environment = "lune"
lib = "lib/init.luau" lib = "lib/init.luau"
[graph."lukadev_0/option"."1.2.0 luau"] [graph."lukadev_0/option"."1.2.0 luau"]
ty = "peer" resolved_ty = "peer"
[graph."lukadev_0/option"."1.2.0 luau".target] [graph."lukadev_0/option"."1.2.0 luau".target]
environment = "luau" environment = "luau"
@ -107,8 +107,8 @@ environment = "luau"
lib = "lib/init.luau" lib = "lib/init.luau"
[graph."lukadev_0/result"."1.2.0 lune"] [graph."lukadev_0/result"."1.2.0 lune"]
direct = ["result", { name = "lukadev_0/result", version = "^1.2.0" }] direct = ["result", { name = "lukadev_0/result", version = "^1.2.0" }, "peer"]
ty = "standard" resolved_ty = "standard"
[graph."lukadev_0/result"."1.2.0 lune".target] [graph."lukadev_0/result"."1.2.0 lune".target]
environment = "lune" environment = "lune"
@ -125,7 +125,7 @@ environment = "lune"
lib = "lib/init.luau" lib = "lib/init.luau"
[graph."lukadev_0/result"."1.2.0 luau"] [graph."lukadev_0/result"."1.2.0 luau"]
ty = "peer" resolved_ty = "peer"
[graph."lukadev_0/result"."1.2.0 luau".target] [graph."lukadev_0/result"."1.2.0 luau".target]
environment = "luau" environment = "luau"

View file

@ -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 core = require("./lune_packages/core")
local Semver = require("./luau_packages/semver") local Semver = require("./luau_packages/semver")
local Option = require("./lune_packages/option") local Option = require("./lune_packages/option")
type Option<T> = Option.Option<T> 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 -- pesde manifest to get the version of the tool dynamically
core.installTool({ local PLATFORM_SEP = if process.platform == "windows" then "\\" else "/"
alias = Option.Some("lune"), 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", repo = "lune-org/lune",
version = Option.Some(Semver.parse("0.8.9"):unwrap()) :: Option<Semver.SemverImpl>, version = Option.Some(Semver.parse(manifest.version):unwrap()) :: Option<Semver.SemverImpl>,
} :: core.ToolId) } :: core.ToolId
)
if not ok then
stdio.ewrite(`{ERROR_PREFIX} Failed to install {manifest.name}@{manifest.version}`)
stdio.ewrite(` - {err}`)
end