refactor: restructure repo

* Restructures monorepo packages
* Updated pesde manifests with scope and other metadata
* Consolidated all interactive install logic into __call metamethod for
  one liner bin re-exports
* Renamed binlib->toolchainlib
* Introduced first real world package - stylua (!!)
This commit is contained in:
Erica Marigold 2024-11-23 14:35:23 +00:00
parent 50f665bb08
commit 94706f8a9d
26 changed files with 102 additions and 92 deletions

1
bins/stylua/init.luau Normal file
View file

@ -0,0 +1 @@
require("./lune_packages/core")("JohnnyMorganz/stylua", _G.PESDE_ROOT)

View file

@ -1,10 +1,9 @@
name = "compeydev/lune"
version = "0.8.9"
name = "pesde/stylua"
version = "2.0.1"
target = "lune"
[graph."0x5eal/semver"."0.1.1 luau"]
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }, "standard"]
resolved_ty = "standard"
resolved_ty = "peer"
[graph."0x5eal/semver"."0.1.1 luau".target]
environment = "luau"
@ -29,36 +28,6 @@ result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://gith
environment = "luau"
lib = "lib/init.luau"
[graph."compeydev/binlib"."0.1.0 lune"]
direct = ["core", { workspace = "compeydev/binlib", version = "^" }, "standard"]
resolved_ty = "standard"
[graph."compeydev/binlib"."0.1.0 lune".target]
environment = "lune"
lib = "src/init.luau"
[graph."compeydev/binlib"."0.1.0 lune".dependencies]
"0x5eal/semver" = ["0.1.1 luau", "semver"]
"jiwonz/dirs" = ["0.1.2 lune", "dirs"]
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
"lukadev_0/option" = ["1.2.0 lune", "option"]
"lukadev_0/result" = ["1.2.0 lune", "result"]
[graph."compeydev/binlib"."0.1.0 lune".pkg_ref]
ref_ty = "workspace"
path = "core"
[graph."compeydev/binlib"."0.1.0 lune".pkg_ref.dependencies]
dirs = [{ name = "jiwonz/dirs", version = "^0.1.1", index = "https://github.com/daimond113/pesde-index" }, "standard"]
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
pathfs = [{ name = "jiwonz/pathfs", version = "^0.1.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
semver = [{ name = "0x5eal/semver", version = "^0.1.1", index = "https://github.com/daimond113/pesde-index", target = "luau" }, "standard"]
[graph."compeydev/binlib"."0.1.0 lune".pkg_ref.target]
environment = "lune"
lib = "src/init.luau"
[graph."jiwonz/dirs"."0.1.2 lune"]
resolved_ty = "standard"
@ -168,3 +137,33 @@ index_url = "https://github.com/daimond113/pesde-index"
[graph."lukadev_0/result"."1.2.0 luau".pkg_ref.target]
environment = "luau"
lib = "lib/init.luau"
[graph."pesde/toolchainlib"."0.1.0 lune"]
direct = ["core", { workspace = "pesde/toolchainlib", version = "^" }, "standard"]
resolved_ty = "standard"
[graph."pesde/toolchainlib"."0.1.0 lune".target]
environment = "lune"
lib = "src/init.luau"
[graph."pesde/toolchainlib"."0.1.0 lune".dependencies]
"0x5eal/semver" = ["0.1.1 luau", "semver"]
"jiwonz/dirs" = ["0.1.2 lune", "dirs"]
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
"lukadev_0/option" = ["1.2.0 lune", "option"]
"lukadev_0/result" = ["1.2.0 lune", "result"]
[graph."pesde/toolchainlib"."0.1.0 lune".pkg_ref]
ref_ty = "workspace"
path = "toolchainlib"
[graph."pesde/toolchainlib"."0.1.0 lune".pkg_ref.dependencies]
dirs = [{ name = "jiwonz/dirs", version = "^0.1.1", index = "https://github.com/daimond113/pesde-index" }, "standard"]
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
pathfs = [{ name = "jiwonz/pathfs", version = "^0.1.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
semver = [{ name = "0x5eal/semver", version = "^0.1.1", index = "https://github.com/daimond113/pesde-index", target = "luau" }, "peer"]
[graph."pesde/toolchainlib"."0.1.0 lune".pkg_ref.target]
environment = "lune"
lib = "src/init.luau"

View file

@ -1,11 +1,11 @@
name = "compeydev/lune"
version = "0.8.9"
name = "pesde/stylua"
version = "2.0.1"
description = "A standalone Luau runtime"
authors = [
"CompeyDev <hi@devcomp.xyz>",
"Filip Tibell <filip.tibell@gmail.com>",
"Johnny Morganz <johnnymorganz@outlook.com>",
]
repository = "https://github.com/CompeyDev/pesde-tooling/blob/main/lune"
repository = "https://github.com/pesde-dev/tooling"
license = "MIT"
[target]
@ -15,8 +15,7 @@ bin = "init.luau"
[dependencies]
result = { name = "lukadev_0/result", version = "^1.2.0" }
option = { name = "lukadev_0/option", version = "^1.2.0" }
semver = { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }
core = { workspace = "compeydev/binlib", version = "^" }
core = { workspace = "pesde/toolchainlib", version = "^" }
[indices]
default = "https://github.com/daimond113/pesde-index"

View file

@ -1,37 +0,0 @@
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>
-- Use _G.PESDE_ROOT to get the install directory, then decode the
-- pesde manifest to get the version of the tool dynamically
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

View file

@ -1,9 +1,9 @@
name = "compeydev/pesde_bins"
name = "pesde/tooling"
version = "0.1.0"
target = "lune"
[workspace."compeydev/binlib"]
lune = "core"
[workspace."pesde/stylua"]
lune = "bins/stylua"
[workspace."compeydev/lune"]
lune = "lune"
[workspace."pesde/toolchainlib"]
lune = "toolchainlib"

View file

@ -1,13 +1,11 @@
name = "compeydev/pesde_bins"
name = "pesde/tooling"
version = "0.1.0"
private = true
workspace_members = ["lune", "core"]
workspace_members = ["toolchainlib", "bins/*"]
[target]
environment = "lune"
[indices]
default = "https://github.com/daimond113/pesde-index"

View file

@ -1,9 +1,9 @@
name = "compeydev/binlib"
name = "pesde/toolchainlib"
version = "0.1.0"
target = "lune"
[graph."0x5eal/semver"."0.1.1 luau"]
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }, "standard"]
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }, "peer"]
resolved_ty = "standard"
[graph."0x5eal/semver"."0.1.1 luau".target]

View file

@ -1,4 +1,4 @@
name = "compeydev/binlib"
name = "pesde/toolchainlib"
version = "0.1.0"
includes = ["src/", "pesde.toml", "LICENSE", "README.md"]
@ -9,11 +9,11 @@ lib = "src/init.luau"
[dependencies]
pathfs = { name = "jiwonz/pathfs", version = "^0.1.0" }
dirs = { name = "jiwonz/dirs", version = "^0.1.1" }
semver = { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }
[peer_dependencies]
result = { name = "lukadev_0/result", version = "^1.2.0" }
option = { name = "lukadev_0/option", version = "^1.2.0" }
semver = { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }
[indices]
default = "https://github.com/daimond113/pesde-index"

View file

@ -9,6 +9,8 @@
local net = require("@lune/net")
local process = require("@lune/process")
local stdio = require("@lune/stdio")
local serde = require("@lune/serde")
local Semver = require("../luau_packages/semver")
local pathfs = require("../lune_packages/pathfs")
@ -254,10 +256,58 @@ function installTool(tool: ToolId)
toolInstallPath:toString()
)
)
chmod(linkPath, 0b111101101)
runTool(toolinstallPath)
end
return {
return setmetatable({
runTool = runTool,
installTool = installTool,
}
}, {
__call = function(lib, tool: string, pesdeRoot: string?)
-- TODO: Progress bar maybe? :D
local ERROR_PREFIX = `{stdio.color("red")}{stdio.style("bold")}error{stdio.color("reset")}:`
local repo, version = string.match(tool, "([^@]+)@?(.*)")
if repo == nil then
stdio.ewrite(`{ERROR_PREFIX} Invalid tool provided\n`)
process.exit(1)
end
local function manifestVersion(): string
if pesdeRoot == nil then
stdio.ewrite(`{ERROR_PREFIX} Failed to discover pesde package root\n`)
process.exit(1)
end
-- Use _G.PESDE_ROOT to get the install directory, then decode the
-- pesde manifest to get the version of the tool dynamically
local manifestContents = pathfs.readFile(pathfs.Path.from(pesdeRoot):join("pesde.toml"))
-- TODO: Create a pesde manifest type in toolchainlib, 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
return manifest.version
end
local ok, err = pcall(
lib.installTool,
{
-- TODO: Use alias within pesde.toml in linker script
alias = Option.None,
repo = repo,
version = Option.Some(Semver.parse(if version ~= "" then version else manifestVersion()):unwrap()) :: Option<Semver.SemverImpl>,
} :: core.ToolId
)
if not ok then
stdio.ewrite(`{ERROR_PREFIX} Failed to install {tool}\n`)
stdio.ewrite(` - {err}\n`)
end
end,
})