Skip to content

Commit 6a3b9df

Browse files
committed
re-add name conflict checking
1 parent 6b4e8e3 commit 6a3b9df

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

lute/cli/commands/pkg/loom-core/src/packageresolution.luau

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,37 @@ local function resolve(rootDirectory: string): ResolvedGraph
8080

8181
table.freeze(packages)
8282

83+
local nameIndex: { [string]: string } = {}
84+
8385
for _, spec in queue do
8486
local key = getKey(spec)
8587

8688
if dependencies[key] then
8789
if hasConflict(dependencies[key], spec) then
8890
error(
89-
`Version conflict for package '{spec.name}':\n`
90-
.. ` but {key} is already resolved\n`
91-
.. `Resolve by pinning both to the same revision.`
91+
`Source mismatch for package '{spec.name}':\n`
92+
.. ` resolved: {dependencies[key].source} ({dependencies[key].sourceKind})\n`
93+
.. ` incoming: {spec.source} ({spec.sourceKind})\n`
94+
.. `Both resolve to '{key}' but from different sources.`
9295
)
9396
else
9497
-- Already resolved at this exact version — deduplicate
9598
continue
9699
end
97100
end
98101

102+
local conflictKey = nameIndex[spec.name]
103+
if conflictKey then
104+
error(
105+
`Version conflict for package '{spec.name}':\n`
106+
.. ` resolved: {conflictKey}\n`
107+
.. ` incoming: {key}\n`
108+
.. `Resolve by pinning both to the same revision.`
109+
)
110+
end
111+
99112
-- New package — resolve it
113+
nameIndex[spec.name] = key
100114
dependencies[key] = spec
101115
graph[key] = {}
102116

lute/cli/commands/pkg/loom-core/src/projectmanifest.luau

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type DependencySpec = {
1111
export type PackageManifest = {
1212
read name: string,
1313
read version: string,
14-
read dependencies: { [string]: DependencySpec },
14+
read dependencies: { [string]: DependencySpec }, -- maps alias to dependency spec
1515
}
1616

1717
export type ProjectManifest = {
@@ -32,6 +32,10 @@ local function parseManifest(t: any): ProjectManifest
3232
local dependencies: { [string]: DependencySpec } = {}
3333
if pkg.dependencies ~= nil then
3434
for name, spec in pkg.dependencies do
35+
assert(
36+
spec.name == nil or type(spec.name) == "string",
37+
`Optional 'name' field in dependency spec for '{name}' expected to be a string`
38+
)
3539
assert(
3640
spec.rev ~= nil and type(spec.rev) == "string",
3741
`Expected 'rev' field in dependency spec for '{name}'`
@@ -45,7 +49,7 @@ local function parseManifest(t: any): ProjectManifest
4549
`Expected 'source' field in dependency spec for '{name}'`
4650
)
4751
dependencies[name] = table.freeze({
48-
name = name,
52+
name = spec.name or name, -- use the optional name if provided, otherwise use the alias
4953
rev = spec.rev,
5054
sourceKind = spec.sourceKind,
5155
source = spec.source,

0 commit comments

Comments
 (0)