stdlib: rename js/react.#App to js/yarn.#Package

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2021-05-12 23:32:02 +00:00 committed by Solomon Hykes
parent 56ef4c1928
commit 16edfc4fec
6 changed files with 23 additions and 27 deletions

View File

@ -3,7 +3,7 @@ package main
import (
"dagger.io/dagger"
"dagger.io/netlify"
"dagger.io/js/react"
"dagger.io/js/yarn"
"dagger.io/git"
)
@ -30,7 +30,7 @@ frontend: {
}
frontend: {
app: react.#App & {
app: yarn.#Package & {
source: frontend.source
env: frontend.environment
@ -38,10 +38,8 @@ frontend: {
writeEnvFile: frontend.writeEnvFile
}
yarn: {
script: frontend.yarn.script
buildDir: frontend.yarn.buildDir
}
script: frontend.yarn.script
buildDir: frontend.yarn.buildDir
}
// Host the application with Netlify

View File

@ -2,7 +2,7 @@ package main
import (
"dagger.io/netlify"
"dagger.io/js/react"
"dagger.io/js/yarn"
"dagger.io/git"
)
@ -22,6 +22,6 @@ www: netlify.#Site & {
contents: app.build
}
app: react.#App & {
app: yarn.#Package & {
source: repo
}

View File

@ -1,4 +1,6 @@
package react
// Yarn is a package manager for Javascript applications
// https://yarnpkg.com
package yarn
import (
"strings"
@ -8,9 +10,8 @@ import (
"dagger.io/os"
)
// A ReactJS application
// FIXME: move this to a 'yarn' package for clarity
#App: {
// A Yarn package.
#Package: {
// Application source code
source: dagger.#Artifact
@ -21,15 +22,12 @@ import (
// in the "envfile" format.
writeEnvFile: string | *""
// Yarn-specific settings
yarn: {
// Read build output from this directory
// (path must be relative to working directory).
buildDir: string | *"build"
// Read build output from this directory
// (path must be relative to working directory).
buildDir: string | *"build"
// Run this yarn script
script: string | *"build"
}
// Run this yarn script
script: string | *"build"
build: os.#Dir & {
from: ctr
@ -51,9 +49,9 @@ import (
mv "$YARN_BUILD_DIRECTORY" /build
"""
"env": env & {
YARN_BUILD_SCRIPT: yarn.script
YARN_BUILD_SCRIPT: script
YARN_CACHE_FOLDER: "/cache/yarn"
YARN_BUILD_DIRECTORY: yarn.buildDir
YARN_BUILD_DIRECTORY: buildDir
if writeEnvFile != "" {
ENVFILE_NAME: writeEnvFile
ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n")

View File

@ -8,8 +8,8 @@ setup() {
"$DAGGER" compute "$TESTDIR"/stdlib/alpine
}
@test "stdlib: react" {
"$DAGGER" compute "$TESTDIR"/stdlib/js/react --input-dir TestData="$TESTDIR"/stdlib/js/react/testdata
@test "stdlib: yarn" {
"$DAGGER" compute "$TESTDIR"/stdlib/js/yarn --input-dir TestData="$TESTDIR"/stdlib/js/yarn/testdata
}
@test "stdlib: go" {

View File

@ -2,7 +2,7 @@ package react
import (
"dagger.io/dagger"
"dagger.io/js/react"
"dagger.io/js/yarn"
"dagger.io/alpine"
"dagger.io/os"
)
@ -10,7 +10,7 @@ import (
TestData: dagger.#Artifact
TestReact: {
app: react.#App & {
pkg: yarn.#Package & {
source: TestData
}
@ -18,7 +18,7 @@ TestReact: {
image: alpine.#Image & {
package: bash: "=5.1.0-r0"
}
mount: "/build": from: app.build
mount: "/build": from: pkg.build
command: """
test "$(cat /build/test)" = "output"
"""