yarn.#Build: simpler API, better tests

* Remove mandatory 'cache' field
* New 'name' field to customize cache IDs instead
* Simplify and expand tests

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes
2022-02-07 05:57:06 +00:00
parent 73ea958eca
commit e6b5fd3de9
2 changed files with 50 additions and 57 deletions

View File

@@ -13,6 +13,11 @@ import (
// Build a Yarn package
#Build: {
// Custom name for the build.
// When building different apps in the same plan, assign
// different names for optimal caching.
name: string | *""
// Application source code
source: dagger.#FS
@@ -33,9 +38,6 @@ import (
// Fix for shadowing issues
let yarnScript = script
// Cache to use, passed by the caller
cache: engine.#CacheDir
// Optional arguments for the script
args: [...string] | *[]
@@ -74,7 +76,10 @@ import (
mounts: {
"yarn cache": {
dest: "/cache/yarn"
contents: cache
contents: engine.#CacheDir & {
// FIXME: are there character limitations in cache ID?
id: "universe.dagger.io/yarn.#Build \(name)"
}
}
"package source": {
dest: "/src"