From 16edfc4fec19549df0472996aa52c292bfb7c83a Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Wed, 12 May 2021 23:32:02 +0000 Subject: [PATCH] stdlib: rename js/react.#App to js/yarn.#Package Signed-off-by: Solomon Hykes --- examples/jamstack/frontend.cue | 10 +++---- examples/react/main.cue | 4 +-- stdlib/js/{react/react.cue => yarn/yarn.cue} | 26 +++++++++---------- tests/stdlib.bats | 4 +-- .../js/{react => yarn}/testdata/package.json | 0 .../js/{react/react.cue => yarn/yarn.cue} | 6 ++--- 6 files changed, 23 insertions(+), 27 deletions(-) rename stdlib/js/{react/react.cue => yarn/yarn.cue} (70%) rename tests/stdlib/js/{react => yarn}/testdata/package.json (100%) rename tests/stdlib/js/{react/react.cue => yarn/yarn.cue} (78%) diff --git a/examples/jamstack/frontend.cue b/examples/jamstack/frontend.cue index 034f7c1d..fe96e014 100644 --- a/examples/jamstack/frontend.cue +++ b/examples/jamstack/frontend.cue @@ -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 diff --git a/examples/react/main.cue b/examples/react/main.cue index 25c3b554..1e4cb1df 100644 --- a/examples/react/main.cue +++ b/examples/react/main.cue @@ -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 } diff --git a/stdlib/js/react/react.cue b/stdlib/js/yarn/yarn.cue similarity index 70% rename from stdlib/js/react/react.cue rename to stdlib/js/yarn/yarn.cue index 03c58475..09e020e1 100644 --- a/stdlib/js/react/react.cue +++ b/stdlib/js/yarn/yarn.cue @@ -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") diff --git a/tests/stdlib.bats b/tests/stdlib.bats index 9007b5c2..16be89de 100644 --- a/tests/stdlib.bats +++ b/tests/stdlib.bats @@ -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" { diff --git a/tests/stdlib/js/react/testdata/package.json b/tests/stdlib/js/yarn/testdata/package.json similarity index 100% rename from tests/stdlib/js/react/testdata/package.json rename to tests/stdlib/js/yarn/testdata/package.json diff --git a/tests/stdlib/js/react/react.cue b/tests/stdlib/js/yarn/yarn.cue similarity index 78% rename from tests/stdlib/js/react/react.cue rename to tests/stdlib/js/yarn/yarn.cue index 60244b01..15539e9e 100644 --- a/tests/stdlib/js/react/react.cue +++ b/tests/stdlib/js/yarn/yarn.cue @@ -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" """