mirror of
https://github.com/pesde-pkg/tooling.git
synced 2024-12-12 07:10:36 +00:00
feat(binlib): maintain versioned tool_storage
This commit is contained in:
parent
5eb2dd1a22
commit
6fb2bb1dba
6 changed files with 41 additions and 31 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -3,5 +3,6 @@
|
||||||
"luau-lsp.require.directoryAliases": {
|
"luau-lsp.require.directoryAliases": {
|
||||||
"@lune/": "~/.lune/.typedefs/0.8.9/"
|
"@lune/": "~/.lune/.typedefs/0.8.9/"
|
||||||
},
|
},
|
||||||
"stylua.targetReleaseVersion": "latest"
|
"stylua.targetReleaseVersion": "latest",
|
||||||
|
"editor.formatOnSave": true
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ lib = "src/init.luau"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pathfs = { name = "jiwonz/pathfs", version = "^0.1.0" }
|
pathfs = { name = "jiwonz/pathfs", version = "^0.1.0" }
|
||||||
dirs = { name = "jiwonz/dirs", version = "^0.1.1" }
|
dirs = { name = "jiwonz/dirs", version = "^0.1.1" }
|
||||||
semver = { name = "0x5eal/semver", version = "^0.1.0", target = "luau" }
|
semver = { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }
|
||||||
|
|
||||||
[peer_dependencies]
|
[peer_dependencies]
|
||||||
result = { name = "lukadev_0/result", version = "^1.2.0" }
|
result = { name = "lukadev_0/result", version = "^1.2.0" }
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
local net = require("@lune/net")
|
local net = require("@lune/net")
|
||||||
local process = require("@lune/process")
|
local process = require("@lune/process")
|
||||||
|
|
||||||
|
local Semver = require("../luau_packages/semver")
|
||||||
local pathfs = require("../lune_packages/pathfs")
|
local pathfs = require("../lune_packages/pathfs")
|
||||||
local dirs = require("../lune_packages/dirs")
|
local dirs = require("../lune_packages/dirs")
|
||||||
local semver = require("../luau_packages/semver")
|
|
||||||
|
|
||||||
local types = require("./utils/result_option_conv")
|
local types = require("./utils/result_option_conv")
|
||||||
local Option = types.Option
|
local Option = types.Option
|
||||||
|
@ -26,7 +26,7 @@ local eq = require("./utils/eq")
|
||||||
export type ToolId = {
|
export type ToolId = {
|
||||||
alias: Option<string>,
|
alias: Option<string>,
|
||||||
repo: string,
|
repo: string,
|
||||||
version: Option<semver.SemverImpl>,
|
version: Option<Semver.SemverImpl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GithubReleases = {
|
export type GithubReleases = {
|
||||||
|
@ -71,16 +71,20 @@ local function runTool(path: pathfs.Path)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local TOOL_INSTALL_DIR = (dirs.homeDir() or error("Couldn't get home dir :(")):join(".pesde"):join("bin")
|
local TOOL_INSTALL_DIR = (dirs.homeDir() or error("Couldn't get home dir :("))
|
||||||
|
:join(".pesde")
|
||||||
|
:join("bin")
|
||||||
|
:join("tool_storage")
|
||||||
|
|
||||||
|
-- if not pathfs.isDir(TOOL_INSTALL_DIR) then
|
||||||
|
-- pathfs.writeDir(TOOL_INSTALL_DIR)
|
||||||
|
-- end
|
||||||
|
|
||||||
function installTool(tool: ToolId)
|
function installTool(tool: ToolId)
|
||||||
local toolStart = os.clock()
|
|
||||||
local toolAlias = tool.alias:unwrapOr(string.split(tool.repo, "/")[2])
|
local toolAlias = tool.alias:unwrapOr(string.split(tool.repo, "/")[2])
|
||||||
print("toolAlias defaulting took", os.clock() - toolStart)
|
local toolId = string.gsub(tool.repo, "/", "+")
|
||||||
|
local toolInstallPath = TOOL_INSTALL_DIR:join(toolId)
|
||||||
local installStart = os.clock()
|
:join(`{toolAlias}-` .. tostring(tool.version:map(tostring):unwrapOr("latest")))
|
||||||
local toolInstallPath = TOOL_INSTALL_DIR:join(toolAlias)
|
|
||||||
print("toolInstallPath joining took", os.clock() - installStart)
|
|
||||||
|
|
||||||
-- TODO: In order to eliminate fs read overhead on startup and to disallow
|
-- TODO: In order to eliminate fs read overhead on startup and to disallow
|
||||||
-- the use of the tool binary when outside a package where it is installed,
|
-- the use of the tool binary when outside a package where it is installed,
|
||||||
|
@ -118,9 +122,9 @@ function installTool(tool: ToolId)
|
||||||
|
|
||||||
local releases = client:queueTransactions({ "FetchReleases" })[1]:unwrap() :: GithubReleases
|
local releases = client:queueTransactions({ "FetchReleases" })[1]:unwrap() :: GithubReleases
|
||||||
local assets = tool.version:match({
|
local assets = tool.version:match({
|
||||||
Some = function(version: semver.SemverImpl)
|
Some = function(version: Semver.SemverImpl)
|
||||||
for _, release in releases do
|
for _, release in releases do
|
||||||
if semver.parse(release.tag_name):unwrap() :: semver.SemverImpl == version then
|
if Semver.parse(release.tag_name):unwrap() :: Semver.SemverImpl == version then
|
||||||
return release.assets
|
return release.assets
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -175,13 +179,18 @@ function installTool(tool: ToolId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: Maintain multiple versions of a tool, and avoid downloading
|
-- Maintain multiple versions of a tool, and avoid downloading
|
||||||
-- the binary for a version again if it's already there
|
-- the binary for a version again if it's already there
|
||||||
|
local toolDir = Option.from(toolInstallPath:parent()):unwrap()
|
||||||
|
if not pathfs.isFile(toolDir) then
|
||||||
|
pathfs.writeDir(toolDir)
|
||||||
|
end
|
||||||
|
|
||||||
pathfs.move(binaryPath, toolInstallPath)
|
pathfs.move(binaryPath, toolInstallPath)
|
||||||
runTool(toolInstallPath)
|
runTool(toolInstallPath)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
installTool = installTool,
|
installTool = installTool,
|
||||||
runTool = runTool
|
runTool = runTool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
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
|
-- TODO: 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({
|
core.installTool({
|
||||||
alias = Option.Some("lune"),
|
alias = Option.Some("lune"),
|
||||||
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("0.8.9"):unwrap()) :: Option<Semver.SemverImpl>,
|
||||||
} :: core.ToolId)
|
} :: core.ToolId)
|
||||||
|
|
|
@ -2,30 +2,30 @@ name = "compeydev/lune"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
target = "lune"
|
target = "lune"
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau"]
|
[graph."0x5eal/semver"."0.1.1 luau"]
|
||||||
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.0", target = "luau" }]
|
direct = ["semver", { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }]
|
||||||
ty = "standard"
|
ty = "standard"
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau".target]
|
[graph."0x5eal/semver"."0.1.1 luau".target]
|
||||||
environment = "luau"
|
environment = "luau"
|
||||||
lib = "lib/init.luau"
|
lib = "lib/init.luau"
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau".dependencies]
|
[graph."0x5eal/semver"."0.1.1 luau".dependencies]
|
||||||
"lukadev_0/option" = ["1.2.0 luau", "option"]
|
"lukadev_0/option" = ["1.2.0 luau", "option"]
|
||||||
"lukadev_0/result" = ["1.2.0 luau", "result"]
|
"lukadev_0/result" = ["1.2.0 luau", "result"]
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau".pkg_ref]
|
[graph."0x5eal/semver"."0.1.1 luau".pkg_ref]
|
||||||
ref_ty = "pesde"
|
ref_ty = "pesde"
|
||||||
name = "0x5eal/semver"
|
name = "0x5eal/semver"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
index_url = "https://github.com/daimond113/pesde-index"
|
index_url = "https://github.com/daimond113/pesde-index"
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau".pkg_ref.dependencies]
|
[graph."0x5eal/semver"."0.1.1 luau".pkg_ref.dependencies]
|
||||||
frktest = [{ name = "itsfrank/frktest", version = "^0.0.2", index = "https://github.com/daimond113/pesde-index", target = "lune" }, "dev"]
|
frktest = [{ name = "itsfrank/frktest", version = "^0.0.2", index = "https://github.com/daimond113/pesde-index", target = "lune" }, "dev"]
|
||||||
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
||||||
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
||||||
|
|
||||||
[graph."0x5eal/semver"."0.1.0 luau".pkg_ref.target]
|
[graph."0x5eal/semver"."0.1.1 luau".pkg_ref.target]
|
||||||
environment = "luau"
|
environment = "luau"
|
||||||
lib = "lib/init.luau"
|
lib = "lib/init.luau"
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ environment = "lune"
|
||||||
lib = "src/init.luau"
|
lib = "src/init.luau"
|
||||||
|
|
||||||
[graph."compeydev/binlib"."0.1.0 lune".dependencies]
|
[graph."compeydev/binlib"."0.1.0 lune".dependencies]
|
||||||
"0x5eal/semver" = ["0.1.0 luau", "semver"]
|
"0x5eal/semver" = ["0.1.1 luau", "semver"]
|
||||||
"jiwonz/dirs" = ["0.1.2 lune", "dirs"]
|
"jiwonz/dirs" = ["0.1.2 lune", "dirs"]
|
||||||
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
|
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
|
||||||
"lukadev_0/option" = ["1.2.0 lune", "option"]
|
"lukadev_0/option" = ["1.2.0 lune", "option"]
|
||||||
|
@ -53,7 +53,7 @@ dirs = [{ name = "jiwonz/dirs", version = "^0.1.1", index = "https://github.com/
|
||||||
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
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"]
|
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"]
|
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
|
||||||
semver = [{ name = "0x5eal/semver", version = "^0.1.0", index = "https://github.com/daimond113/pesde-index", target = "luau" }, "standard"]
|
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]
|
[graph."compeydev/binlib"."0.1.0 lune".pkg_ref.target]
|
||||||
environment = "lune"
|
environment = "lune"
|
||||||
|
|
|
@ -12,7 +12,7 @@ bin = "init.luau"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
result = { name = "lukadev_0/result", version = "^1.2.0" }
|
result = { name = "lukadev_0/result", version = "^1.2.0" }
|
||||||
option = { name = "lukadev_0/option", version = "^1.2.0" }
|
option = { name = "lukadev_0/option", version = "^1.2.0" }
|
||||||
semver = { name = "0x5eal/semver", version = "^0.1.0", target = "luau" }
|
semver = { name = "0x5eal/semver", version = "^0.1.1", target = "luau" }
|
||||||
core = { workspace = "compeydev/binlib", version = "^" }
|
core = { workspace = "compeydev/binlib", version = "^" }
|
||||||
|
|
||||||
[indices]
|
[indices]
|
||||||
|
|
Loading…
Reference in a new issue