Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Scripts/CheckWallyFormat.exec.luau
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
CheckWallyFormat.exec

Validates that wally.toml follows the project format guidelines. Specifically checks that
all repository strings (package name and dependency values) are lowercase.
registry package names and dependency references are lowercase, preserving local paths.

[Usage] ./Scripts/CheckWallyFormat.exec.luau [filename]
> filename → Optional path to the file to check. Defaults to "wally.toml".
Expand Down Expand Up @@ -62,7 +62,11 @@ function CheckWallyFormat.exec()
end
table.sort(keys)
for _, key in keys do
checkLowercase(dependencies[key], `Dependency "{key}"`)
const value = dependencies[key]
assert(type(value) == "string", `Expected Dependency "{key}" to be a string in "{filename}".`)
if string.sub(value, 1, 1) ~= "^" then
checkLowercase(value, `Dependency "{key}"`)
end
end
end
end
Expand Down
37 changes: 37 additions & 0 deletions Tests/CheckWallyFormatTest.spec.luau
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,39 @@ return function()
end
end)

it("should preserve mixed-case local paths in every dependency table", function()
for _, section in { "dependencies", "dev-dependencies", "server-dependencies" } do
env.WriteFile(
"test-wally.toml",
`[{section}]\nFusion = "^Source/ForkedPackages/fusion"\nRegistry = "owner/package@1.0.0"\n`
)

const result = env.RunScript("CheckWallyFormat", { "test-wally.toml" })

expect(result.ok).to.equal(true)
expect(string.find(result.stdout, '"test-wally.toml" format is valid.', 1, true)).to.be.ok()
expect(env.ReadFile("test-wally.toml")).to.equal(
`[{section}]\nFusion = "^Source/ForkedPackages/fusion"\nRegistry = "owner/package@1.0.0"\n`
)
end
end)

it("should reject uppercase registry references alongside local paths in every dependency table", function()
for _, section in { "dependencies", "dev-dependencies", "server-dependencies" } do
env.WriteFile(
"test-wally.toml",
`[{section}]\nFusion = "^Source/ForkedPackages/fusion"\nRegistry = "Owner/Package@1.0.0"\n`
)

const result = env.RunScript("CheckWallyFormat", { "test-wally.toml" })

expect(result.ok).to.equal(false)
expect(string.find(result.stdout, "1 format error", 1, true)).to.be.ok()
expect(string.find(result.stdout, 'Dependency "Registry"', 1, true)).to.be.ok()
expect(string.find(result.stdout, 'Dependency "Fusion"', 1, true)).to.equal(nil)
end
end)

it("should ignore commented assignments and unrelated sections", function()
env.WriteFile(
"test-wally.toml",
Expand All @@ -193,6 +226,10 @@ return function()
{ Content = 'package = "invalid"\n', Message = 'Expected "package" to be a table' },
{ Content = "[package]\nname = 123\n", Message = "Expected Package name to be a string" },
{ Content = 'dependencies = "invalid"\n', Message = 'Expected "dependencies" to be a table' },
{
Content = "[dependencies]\nDependency = 123\n",
Message = 'Expected Dependency "Dependency" to be a string',
},
{
Content = "[dev-dependencies]\nDependency = false\n",
Message = 'Expected Dependency "Dependency" to be a string',
Expand Down
Loading