mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 01:29:15 +02:00
Support scheme-agnostic projects (#486)
This adds changes to support loading project dependencies in non-file based projects. The design for this feature can be found in SPICE-0005: https://github.com/apple/pkl-evolution/pull/6 Changes: * Consider all imports prefixed with `@` as dependency notation. * Bugfix: fix resolution of glob expressions in a local dependency. * Adjust pkl.Project: - Allow local dependencies from a scheme-local paths. - Disallow certain evaluator settings if not loaded as a file-based module. * Breaking API change: `ProjectDependenciesManager` constructor now requires `ModuleResolver` and `SecurityManager`.
This commit is contained in:
+1
@@ -11,4 +11,5 @@ dependencies {
|
||||
uri = "package://localhost:0/badImportsWithinPackage@1.0.0"
|
||||
}
|
||||
["project2"] = import("../project2/PklProject")
|
||||
["project6"] = import("../project6/PklProject")
|
||||
}
|
||||
|
||||
+5
@@ -20,6 +20,11 @@
|
||||
"uri": "projectpackage://localhost:0/project2@1.0.0",
|
||||
"path": "../project2/"
|
||||
},
|
||||
"package://localhost:12110/project6@1": {
|
||||
"type": "local",
|
||||
"uri": "projectpackage://localhost:12110/project6@1.0.0",
|
||||
"path": "../project6/"
|
||||
},
|
||||
"package://localhost:0/badImportsWithinPackage@1": {
|
||||
"type": "remote",
|
||||
"uri": "projectpackage://localhost:0/badImportsWithinPackage@1.0.0",
|
||||
|
||||
+4
@@ -34,4 +34,8 @@ examples {
|
||||
["glob-read absolute package uri"] {
|
||||
read*("package://localhost:0/birds@0.5.0#/catalog/*.pkl")
|
||||
}
|
||||
|
||||
["glob-import behind local project import"] {
|
||||
import("@project6/children.pkl")
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -20,6 +20,11 @@
|
||||
"uri": "projectpackage://localhost:0/project2@1.0.0",
|
||||
"path": "../project2/"
|
||||
},
|
||||
"package://localhost:12110/project6@1": {
|
||||
"type": "local",
|
||||
"uri": "projectpackage://localhost:12110/project6@1.0.0",
|
||||
"path": "../project6/"
|
||||
},
|
||||
"package://localhost:0/badImportsWithinPackage@1": {
|
||||
"type": "remote",
|
||||
"uri": "projectpackage://localhost:0/badImportsWithinPackage@1.0.0",
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
amends "pkl:Project"
|
||||
|
||||
package {
|
||||
name = "project6"
|
||||
baseUri = "package://localhost:12110/project6"
|
||||
version = "1.0.0"
|
||||
packageZipUrl = "https://localhost:12110/project6/project6-\(version).zip"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"resolvedDependencies": {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
children = import*("children/*.pkl")
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "a"
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "b"
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "c"
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
–– Pkl Error ––
|
||||
Expected value of type `*RemoteDependency|LocalDependency`, but got a different `pkl.Project`.
|
||||
Expected value of type `*RemoteDependency|Project(isValidLoadDependency)`, but got a different `pkl.Project`.
|
||||
Value: new ModuleClass { package = null; tests {}; dependencies {}; evaluatorSetting...
|
||||
|
||||
xxx | dependencies: Mapping<String(!contains("/")), *RemoteDependency|LocalDependency>
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
xxx | dependencies: Mapping<String(!contains("/")), *RemoteDependency|Project(isValidLoadDependency)>
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at pkl.Project#dependencies (pkl:Project)
|
||||
|
||||
* Value is not of type `LocalDependency` because:
|
||||
Type constraint `this.package != null` violated.
|
||||
* Value is not of type `Project(isValidLoadDependency)` because:
|
||||
Type constraint `isValidLoadDependency` violated.
|
||||
Value: new ModuleClass { package = null; tests {}; dependencies {}; evaluatorSetti...
|
||||
|
||||
x | dependencies {
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
–– Pkl Error ––
|
||||
Cannot resolve dependency because file `PklProject.deps.json` is missing in project directory `file:///$snippetsDir/input/projects/missingProjectDeps/`.
|
||||
Encountered an error when attempting to load `PklProject.deps.json` at `file:///$snippetsDir/input/projects/missingProjectDeps/PklProject.deps.json`.
|
||||
NoSuchFileException: /$snippetsDir/input/projects/missingProjectDeps/PklProject.deps.json
|
||||
|
||||
x | import "@birds/Bird.pkl"
|
||||
^^^^^^^^^^^^^^^^^
|
||||
at bug (file:///$snippetsDir/input/projects/missingProjectDeps/bug.pkl)
|
||||
|
||||
Run `pkl project resolve` to create a new set of dependencies.
|
||||
Try running `pkl project resolve` within the project directory to create a new set of dependencies.
|
||||
|
||||
+15
@@ -262,4 +262,19 @@ examples {
|
||||
}
|
||||
}
|
||||
}
|
||||
["glob-import behind local project import"] {
|
||||
new {
|
||||
children {
|
||||
["children/a.pkl"] {
|
||||
name = "a"
|
||||
}
|
||||
["children/b.pkl"] {
|
||||
name = "b"
|
||||
}
|
||||
["children/c.pkl"] {
|
||||
name = "c"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
children {
|
||||
["children/a.pkl"] {
|
||||
name = "a"
|
||||
}
|
||||
["children/b.pkl"] {
|
||||
name = "b"
|
||||
}
|
||||
["children/c.pkl"] {
|
||||
name = "c"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "a"
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "b"
|
||||
+1
@@ -0,0 +1 @@
|
||||
name = "c"
|
||||
Reference in New Issue
Block a user