Merge pull request #1636 from shykes/yarn-run

yarn: split #Run and #Build
This commit is contained in:
Solomon Hykes 2022-02-17 13:12:31 -08:00 committed by GitHub
commit 18e778c894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,8 +11,13 @@ import (
"universe.dagger.io/docker" "universe.dagger.io/docker"
) )
#Build: #Run & {
buildDir: *"build" | string
script: *"build" | string
}
// Build a Yarn package // Build a Yarn package
#Build: { #Run: {
// Custom name for the build. // Custom name for the build.
// When building different apps in the same plan, assign // When building different apps in the same plan, assign
// different names for optimal caching. // different names for optimal caching.
@ -30,10 +35,10 @@ import (
// Read build output from this directory // Read build output from this directory
// (path must be relative to working directory) // (path must be relative to working directory)
buildDir: string | *"build" buildDir?: string
// Run this yarn script // Run this yarn script
script: string | *"build" script: string
// Fix for shadowing issues // Fix for shadowing issues
let yarnScript = script let yarnScript = script
@ -70,7 +75,11 @@ import (
opts=( $(echo $YARN_ARGS) ) opts=( $(echo $YARN_ARGS) )
yarn --cwd "$YARN_CWD" run "$YARN_BUILD_SCRIPT" ${opts[@]} yarn --cwd "$YARN_CWD" run "$YARN_BUILD_SCRIPT" ${opts[@]}
if [ ! -z "${YARN_BUILD_DIRECTORY:-}" ]; then
mv "$YARN_BUILD_DIRECTORY" /build mv "$YARN_BUILD_DIRECTORY" /build
else
mkdir /build
fi
"""# """#
mounts: { mounts: {
@ -94,7 +103,9 @@ import (
YARN_ARGS: strings.Join(args, "\n") YARN_ARGS: strings.Join(args, "\n")
YARN_CACHE_FOLDER: "/cache/yarn" YARN_CACHE_FOLDER: "/cache/yarn"
YARN_CWD: cwd YARN_CWD: cwd
if buildDir != _|_ {
YARN_BUILD_DIRECTORY: buildDir YARN_BUILD_DIRECTORY: buildDir
}
if writeEnvFile != "" { if writeEnvFile != "" {
ENVFILE_NAME: writeEnvFile ENVFILE_NAME: writeEnvFile
ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n") ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n")