Skip to content

Commit

Permalink
Aligns file structure to top-level package with run command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Moran authored and arjun024 committed Jun 8, 2020
1 parent 9d6fe38 commit 378fbff
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 51 deletions.
2 changes: 1 addition & 1 deletion yarn/build.go → build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn
package yarninstall

import (
"os"
Expand Down
8 changes: 4 additions & 4 deletions yarn/build_test.go → build_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn_test
package yarninstall_test

import (
"bytes"
Expand All @@ -13,8 +13,8 @@ import (
"github.com/paketo-buildpacks/packit/chronos"
"github.com/paketo-buildpacks/packit/postal"
"github.com/paketo-buildpacks/packit/scribe"
"github.com/paketo-buildpacks/yarn-install/yarn"
"github.com/paketo-buildpacks/yarn-install/yarn/fakes"
yarninstall "github.com/paketo-buildpacks/yarn-install"
"github.com/paketo-buildpacks/yarn-install/fakes"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -78,7 +78,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {

buffer = bytes.NewBuffer(nil)

build = yarn.Build(dependencyService, cacheMatcher, installProcess, clock, scribe.NewLogger(buffer))
build = yarninstall.Build(dependencyService, cacheMatcher, installProcess, clock, scribe.NewLogger(buffer))
})

it.After(func() {
Expand Down
2 changes: 1 addition & 1 deletion buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ api = "0.2"
homepage = "https://github.com/paketo-buildpacks/yarn-install"

[metadata]
include_files = ["bin/build", "bin/detect", "buildpack.toml"]
include_files = ["bin/build", "bin/detect", "bin/run", "buildpack.toml"]
pre_package = "./scripts/build.sh"
[metadata.default_versions]
yarn = "1.*"
Expand Down
2 changes: 1 addition & 1 deletion yarn/cache_handler.go → cache_handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn
package yarninstall

type CacheHandler struct{}

Expand Down
8 changes: 4 additions & 4 deletions yarn/cache_handler_test.go → cache_handler_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package yarn_test
package yarninstall_test

import (
"testing"

"github.com/paketo-buildpacks/yarn-install/yarn"
yarninstall "github.com/paketo-buildpacks/yarn-install"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
Expand All @@ -13,11 +13,11 @@ func testCacheHandler(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect

cacheHandler yarn.CacheHandler
cacheHandler yarninstall.CacheHandler
)

it.Before(func() {
cacheHandler = yarn.NewCacheHandler()
cacheHandler = yarninstall.NewCacheHandler()
})

context("Match", func() {
Expand Down
12 changes: 0 additions & 12 deletions cmd/detect/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion yarn/detect.go → detect.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn
package yarninstall

import (
"errors"
Expand Down
16 changes: 8 additions & 8 deletions yarn/detect_test.go → detect_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn_test
package yarninstall_test

import (
"errors"
Expand All @@ -8,8 +8,8 @@ import (
"testing"

"github.com/paketo-buildpacks/packit"
"github.com/paketo-buildpacks/yarn-install/yarn"
"github.com/paketo-buildpacks/yarn-install/yarn/fakes"
yarninstall "github.com/paketo-buildpacks/yarn-install"
"github.com/paketo-buildpacks/yarn-install/fakes"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
Expand All @@ -35,7 +35,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
versionParser = &fakes.VersionParser{}
versionParser.ParseVersionCall.Returns.Version = "some-version"

detect = yarn.Detect(versionParser)
detect = yarninstall.Detect(versionParser)
})

it("returns a plan that provides node_modules", func() {
Expand All @@ -50,14 +50,14 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Requires: []packit.BuildPlanRequirement{
{
Name: "node_modules",
Metadata: yarn.BuildPlanMetadata{
Metadata: yarninstall.BuildPlanMetadata{
Launch: true,
},
},
{
Name: "node",
Version: "some-version",
Metadata: yarn.BuildPlanMetadata{
Metadata: yarninstall.BuildPlanMetadata{
VersionSource: "package.json",
Build: true,
Launch: true,
Expand Down Expand Up @@ -86,13 +86,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Requires: []packit.BuildPlanRequirement{
{
Name: "node_modules",
Metadata: yarn.BuildPlanMetadata{
Metadata: yarninstall.BuildPlanMetadata{
Launch: true,
},
},
{
Name: "node",
Metadata: yarn.BuildPlanMetadata{
Metadata: yarninstall.BuildPlanMetadata{
Build: true,
Launch: true,
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion yarn/init_test.go → init_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn_test
package yarninstall_test

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion yarn/install_process.go → install_process.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn
package yarninstall

import (
"bytes"
Expand Down
14 changes: 7 additions & 7 deletions yarn/install_process_test.go → install_process_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn_test
package yarninstall_test

import (
"bytes"
Expand All @@ -12,8 +12,8 @@ import (

"github.com/paketo-buildpacks/packit/pexec"
"github.com/paketo-buildpacks/packit/scribe"
"github.com/paketo-buildpacks/yarn-install/yarn"
"github.com/paketo-buildpacks/yarn-install/yarn/fakes"
yarninstall "github.com/paketo-buildpacks/yarn-install"
"github.com/paketo-buildpacks/yarn-install/fakes"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
Expand All @@ -26,7 +26,7 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) {
var (
workingDir string
executable *fakes.Executable
installProcess yarn.YarnInstallProcess
installProcess yarninstall.YarnInstallProcess
summer *fakes.Summer
)

Expand All @@ -38,7 +38,7 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) {
executable = &fakes.Executable{}
summer = &fakes.Summer{}

installProcess = yarn.NewYarnInstallProcess(executable, summer, scribe.NewLogger(bytes.NewBuffer(nil)))
installProcess = yarninstall.NewYarnInstallProcess(executable, summer, scribe.NewLogger(bytes.NewBuffer(nil)))
})

context("we should run yarn install when", func() {
Expand Down Expand Up @@ -127,7 +127,7 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) {
executable *fakes.Executable
summer *fakes.Summer

installProcess yarn.YarnInstallProcess
installProcess yarninstall.YarnInstallProcess
)

it.Before(func() {
Expand Down Expand Up @@ -159,7 +159,7 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) {
path = os.Getenv("PATH")
os.Setenv("PATH", "/some/bin")

installProcess = yarn.NewYarnInstallProcess(executable, summer, scribe.NewLogger(buffer))
installProcess = yarninstall.NewYarnInstallProcess(executable, summer, scribe.NewLogger(buffer))
})

it.After(func() {
Expand Down
2 changes: 1 addition & 1 deletion yarn/package_json_parser.go → package_json_parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package yarn
package yarninstall

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package yarn_test
package yarninstall_test

import (
"io/ioutil"
"os"
"testing"

"github.com/paketo-buildpacks/yarn-install/yarn"
yarninstall "github.com/paketo-buildpacks/yarn-install"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
Expand All @@ -17,7 +17,7 @@ func testPackageJSONParser(t *testing.T, context spec.G, it spec.S) {
context("ParseVersion", func() {
var (
path string
parser yarn.PackageJSONParser
parser yarninstall.PackageJSONParser
)

it.Before(func() {
Expand All @@ -34,7 +34,7 @@ func testPackageJSONParser(t *testing.T, context spec.G, it spec.S) {

path = file.Name()

parser = yarn.NewPackageJSONParser()
parser = yarninstall.NewPackageJSONParser()
})

it.After(func() {
Expand Down
19 changes: 14 additions & 5 deletions cmd/build/main.go → run/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@ import (
"github.com/paketo-buildpacks/packit/pexec"
"github.com/paketo-buildpacks/packit/postal"
"github.com/paketo-buildpacks/packit/scribe"
"github.com/paketo-buildpacks/yarn-install/yarn"
yarninstall "github.com/paketo-buildpacks/yarn-install"
)

func main() {
packageJSONParser := yarninstall.NewPackageJSONParser()
logger := scribe.NewLogger(os.Stdout)

transport := cargo.NewTransport()
executable := pexec.NewExecutable("yarn")
summer := fs.NewChecksumCalculator()
installProcess := yarn.NewYarnInstallProcess(executable, summer, logger)
installProcess := yarninstall.NewYarnInstallProcess(executable, summer, logger)
dependencyService := postal.NewService(transport)
cacheHandler := yarn.NewCacheHandler()
cacheHandler := yarninstall.NewCacheHandler()

packit.Build(yarn.Build(dependencyService, cacheHandler, installProcess, chronos.DefaultClock, logger))
packit.Run(
yarninstall.Detect(packageJSONParser),
yarninstall.Build(
dependencyService,
cacheHandler,
installProcess,
chronos.DefaultClock,
logger,
),
)
}

0 comments on commit 378fbff

Please sign in to comment.