#Yarn package extension

1 messages ยท Page 1 of 1 (latest)

umbral egret
pine leaf
#

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.

umbral egret
#

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 ๐Ÿ˜„

pine leaf
#

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"
  }
}
umbral egret
#

ah, to create a new mount?

umbral egret
#

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

pine leaf
umbral egret
#

ah!

pine leaf
umbral egret
#

got it. We're also working on the explicit dependencies bit.

pine leaf
#

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.