Fix import analysis failures for glob imports into local package deps (#1992)

This commit is contained in:
Jen Basch authored and Jen Basch committed 2026-11-17 11:07:05 -08:00
1 parent 246e01b55c
commit 83e47694ef
12 files changed
+94 -1

No files matched your search

@@ -102,7 +102,8 @@ public class VmImportAnalyzer {
try {
if (entry.isGlob()) {
var theModuleKey =
moduleResolver.resolve(moduleKey.resolveUri(IoUtils.toUri(entry.stringValue())));
moduleResolver.resolve(
IoUtils.resolve(securityManager, moduleKey, IoUtils.toUri(entry.stringValue())));
var elements =
GlobResolver.resolveGlob(
securityManager,
@@ -0,0 +1,8 @@
amends "pkl:Project"
package {
name = "a"
baseUri = "package://example.com/a"
version = "1.0.0"
packageZipUrl = "https://example.com/a.zip"
}
@@ -0,0 +1,3 @@
amends "pkl:Project"
dependencies { ["a"] = import(".../input-helper/projects/analyzeLocalPackageGlob/PklProject") }
@@ -0,0 +1,10 @@
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://example.com/a@1": {
"type": "local",
"uri": "projectpackage://example.com/a@1.0.0",
"path": "../../../input-helper/projects/analyzeLocalPackageGlob"
}
}
}
@@ -0,0 +1,26 @@
amends ".../snippetTest.pkl"
import "pkl:analyze"
import "pkl:reflect"
import "glob.pkl"
import "single.pkl"
examples {
["single"] {
analyze.importGraph(Set(reflect.Module(single).uri))
}
["glob"] {
analyze.importGraph(Set(reflect.Module(glob).uri))
}
}
output {
renderer {
// mimick result of `pkl analyze imports` CLI command
converters {
[Map] = (it) -> it.toMapping()
[Set] = (it) -> it.toListing()
}
}
}
@@ -0,0 +1 @@
res = import*("@a/mods/*.pkl").toMap().mapValues((_, m) -> m.x)
@@ -0,0 +1 @@
res = import("@a/mods/one.pkl").x
@@ -0,0 +1,39 @@
examples {
["single"] {
new {
imports {
["file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/single.pkl"] {
new {
uri = "projectpackage://example.com/a@1.0.0#/mods/one.pkl"
}
}
["projectpackage://example.com/a@1.0.0#/mods/one.pkl"] {}
}
resolvedImports {
["file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/single.pkl"] = "file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/single.pkl"
["projectpackage://example.com/a@1.0.0#/mods/one.pkl"] = "file:///$snippetsDir/input-helper/projects/analyzeLocalPackageGlob/mods/one.pkl"
}
}
}
["glob"] {
new {
imports {
["file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/glob.pkl"] {
new {
uri = "projectpackage://example.com/a@1.0.0#/mods/one.pkl"
}
new {
uri = "projectpackage://example.com/a@1.0.0#/mods/two.pkl"
}
}
["projectpackage://example.com/a@1.0.0#/mods/one.pkl"] {}
["projectpackage://example.com/a@1.0.0#/mods/two.pkl"] {}
}
resolvedImports {
["file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/glob.pkl"] = "file:///$snippetsDir/input/projects/analyzeLocalPackageGlob/glob.pkl"
["projectpackage://example.com/a@1.0.0#/mods/one.pkl"] = "file:///$snippetsDir/input-helper/projects/analyzeLocalPackageGlob/mods/one.pkl"
["projectpackage://example.com/a@1.0.0#/mods/two.pkl"] = "file:///$snippetsDir/input-helper/projects/analyzeLocalPackageGlob/mods/two.pkl"
}
}
}
}
@@ -0,0 +1 @@
res = Map("@a/mods/one.pkl", 1, "@a/mods/two.pkl", 2)