mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-04-13 15:20:55 +01:00
feat(lib): make manifest decoding and access type-safe
Includes types to describe the shape of a pesde manifest and its components.
This commit is contained in:
parent
606f9dcf13
commit
e46bb0f3ca
2 changed files with 65 additions and 1 deletions
toolchainlib/src
|
@ -24,6 +24,7 @@ local Github = require("./github")
|
||||||
local PlatformDescriptor = require("./platform/descriptor")
|
local PlatformDescriptor = require("./platform/descriptor")
|
||||||
local compression = require("./compression")
|
local compression = require("./compression")
|
||||||
local eq = require("./utils/eq")
|
local eq = require("./utils/eq")
|
||||||
|
local manifest = require("./manifest")
|
||||||
|
|
||||||
export type ToolId = {
|
export type ToolId = {
|
||||||
alias: Option<string>,
|
alias: Option<string>,
|
||||||
|
@ -245,7 +246,7 @@ return setmetatable(
|
||||||
-- pesde manifest to get the version of the tool dynamically
|
-- pesde manifest to get the version of the tool dynamically
|
||||||
local manifestContents = pathfs.readFile(pathfs.Path.from(pesdeRoot :: string):join("pesde.toml"))
|
local manifestContents = pathfs.readFile(pathfs.Path.from(pesdeRoot :: string):join("pesde.toml"))
|
||||||
-- TODO: Create a pesde manifest type in toolchainlib, and use that here
|
-- TODO: Create a pesde manifest type in toolchainlib, and use that here
|
||||||
local ok, manifest = pcall(serde.decode, "toml" :: "toml", manifestContents)
|
local ok, manifest: manifest.PesdeManifest = pcall(serde.decode, "toml" :: "toml", manifestContents)
|
||||||
if not ok then
|
if not ok then
|
||||||
stdio.ewrite(
|
stdio.ewrite(
|
||||||
`{ERROR_PREFIX} Failed to decode bundled manifest. This is probably a bug.\n\n{manifest}`
|
`{ERROR_PREFIX} Failed to decode bundled manifest. This is probably a bug.\n\n{manifest}`
|
||||||
|
@ -278,6 +279,7 @@ return setmetatable(
|
||||||
{
|
{
|
||||||
alias = Option.None,
|
alias = Option.None,
|
||||||
repo = repo,
|
repo = repo,
|
||||||
|
-- FIXME: Not all tools may necessarily follow semver, might this in the future
|
||||||
version = Option.Some(Semver.parse(versionOrDefault):unwrap()) :: Option<Semver.SemverImpl>,
|
version = Option.Some(Semver.parse(versionOrDefault):unwrap()) :: Option<Semver.SemverImpl>,
|
||||||
} :: ToolId,
|
} :: ToolId,
|
||||||
toolInstallPath
|
toolInstallPath
|
||||||
|
|
62
toolchainlib/src/manifest.luau
Normal file
62
toolchainlib/src/manifest.luau
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
export type SPDXLicense =
|
||||||
|
"MIT"
|
||||||
|
| "Apache-2.0"
|
||||||
|
| "BSD-2-Clause"
|
||||||
|
| "BSD-3-Clause"
|
||||||
|
| "GPL-2.0"
|
||||||
|
| "GPL-3.0"
|
||||||
|
| "LGPL-2.1"
|
||||||
|
| "LGPL-3.0"
|
||||||
|
| "MPL-2.0"
|
||||||
|
| "ISC"
|
||||||
|
| "Unlicense"
|
||||||
|
| "WTFPL"
|
||||||
|
| "Zlib"
|
||||||
|
| "CC0-1.0"
|
||||||
|
| "CC-BY-4.0"
|
||||||
|
| "CC-BY-SA-4.0"
|
||||||
|
| "BSL-1.0"
|
||||||
|
| "EPL-2.0"
|
||||||
|
| "AGPL-3.0"
|
||||||
|
|
||||||
|
export type DependencySpecifier = ((
|
||||||
|
{ name: string, version: string, index: string? }
|
||||||
|
| { workspace: string, version: string }
|
||||||
|
| { repo: string, rev: string, path: string? }
|
||||||
|
) & {
|
||||||
|
target: string?,
|
||||||
|
}) | { wally: string, version: string, index: string? }
|
||||||
|
|
||||||
|
export type PackageTarget = {
|
||||||
|
environment: "luau" | "lune" | "roblox" | "roblox_server",
|
||||||
|
lib: string,
|
||||||
|
} | {
|
||||||
|
environment: "luau" | "lune",
|
||||||
|
bin: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PesdeManifest = {
|
||||||
|
name: string,
|
||||||
|
version: string,
|
||||||
|
description: string?,
|
||||||
|
license: SPDXLicense?,
|
||||||
|
authors: { string }?,
|
||||||
|
repository: string?,
|
||||||
|
private: boolean?,
|
||||||
|
includes: { string }?,
|
||||||
|
pesde_version: string?,
|
||||||
|
workspace_members: { string }?,
|
||||||
|
target: PackageTarget,
|
||||||
|
build_files: { string }?,
|
||||||
|
scripts: { [string]: string }?,
|
||||||
|
indices: { [string]: string },
|
||||||
|
wally_indices: { [string]: string }?,
|
||||||
|
overrides: { [string]: DependencySpecifier }?,
|
||||||
|
patches: { [string]: { [string]: string } }?,
|
||||||
|
place: { [string]: string }?,
|
||||||
|
dependencies: { [string]: DependencySpecifier }?,
|
||||||
|
peer_dependencies: { [string]: DependencySpecifier }?,
|
||||||
|
dev_dependencies: { [string]: DependencySpecifier }?,
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<manifest>"
|
Loading…
Add table
Reference in a new issue