#Yarn package extension
1 messages ยท Page 1 of 1 (latest)
Hi @pine leaf ๐ , and welcome!
You could either just use yarn commands run in bash and skip the Universe Yarn package like this:
https://github.com/jpadams/nodetestyarn/blob/main/node-yarn.cue
or you could use yarn.#Command to run your command: https://github.com/dagger/dagger/blob/main/pkg/universe.dagger.io/yarn/yarn.cue#L70-L75
Hey @umbral egret - thank you!
Oh sweet- thanks for the link. Yeah that looks like more what I am used to.
I did end up getting it to work (or at least complete without errors) using yarn.#Script with a container mount to an output from another action that used yarn.#Command to set the registry.
I guess I was wondering what the standard or best practice was to date or if it's a mixed bag. Some use purely Universe packages whereas others go bare-bones with the bash package and do it all on their own?
Probably ideal to "extend' the yarn universe package where you find things that don't work out of the box but still a bit early to figure all that out and contribute back.
Right. The Yarn package has some extra caching and other conveniences that are nice to take advantage of, if possible.
since yarn.#Script is composed of yarn.#Command which is composed of bash.#Run which is itself composed of docker.#Run (and turtles all the way down to core.#Exec next), you can access fields in all of those other structs as needed, as well as thankfully ignore them most of the time ๐
I guess to that point... how do I reference yarn.#Commands property of container from a yarn.#Script action?
Is it simply:
build: yarn.#Script & {
name: "build"
source: actions.source.output
container: mounts: setregistry_output: {
contents: setregistry.output
dest: "/tmp/yarn_setregistry_output"
}
}
ah, to create a new mount?
yep, should be good
could also do something like this:
package main
import (
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/yarn"
"universe.dagger.io/docker"
)
dagger.#Plan & {
actions: {
mybuild: {
checkoutCode: core.#Source & {
path: "."
}
setregistry: yarn.#Command & {
source: checkoutCode.output
args: ["config", "set", "registry", "xyz.com"]
}
afterset: docker.#Run & {
input: setregistry.container.output
command: {
name: "echo"
args: [(setregistry.logs)]
}
}
}
}
}
dagger do mybuild --log-format plain
Yeah I was trying to mimic this here: https://github.com/dagger/dagger/blob/main/pkg/universe.dagger.io/yarn/yarn.cue#L53-L59
ah!
https://docs.dagger.io/1232/chain-actions - since I couldn't quite get this to work originally.
got it. We're also working on the explicit dependencies bit.
As the yarn actions didn't have an input parameter so it errored out. But cool - just wanted to get something working and got stuck immediately on that due to being on a proxy and needing a custom registry. Appreciate the help / links / pointers. Will keep digging.