diff --git a/build.go b/build.go index 49ed21b..00e0af3 100644 --- a/build.go +++ b/build.go @@ -7,30 +7,27 @@ import ( "github.com/paketo-buildpacks/packit" "github.com/paketo-buildpacks/packit/chronos" "github.com/paketo-buildpacks/packit/postal" + "github.com/paketo-buildpacks/packit/scribe" ) //go:generate faux --interface EntryResolver --output fakes/entry_resolver.go type EntryResolver interface { - Resolve([]packit.BuildpackPlanEntry) packit.BuildpackPlanEntry + Resolve(name string, entries []packit.BuildpackPlanEntry, priorites []interface{}) (packit.BuildpackPlanEntry, []packit.BuildpackPlanEntry) + MergeLayerTypes(name string, entries []packit.BuildpackPlanEntry) (launch, build bool) } //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go type DependencyManager interface { Resolve(path, id, version, stack string) (postal.Dependency, error) - Install(dependency postal.Dependency, cnbPath, layerPath string) error -} - -//go:generate faux --interface BuildPlanRefinery --output fakes/build_plan_refinery.go -type BuildPlanRefinery interface { - BillOfMaterials(postal.Dependency) packit.BuildpackPlanEntry + Deliver(dependency postal.Dependency, cnbPath, layerPath, platformPath string) error + GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry } func Build( - entries EntryResolver, - dependencies DependencyManager, - planRefinery BuildPlanRefinery, + entryResolver EntryResolver, + dependencyManager DependencyManager, clock chronos.Clock, - logger LogEmitter, + logger scribe.Emitter, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { logger.Title("%s %s", context.BuildpackInfo.Name, context.BuildpackInfo.Version) @@ -40,30 +37,46 @@ func Build( return packit.BuildResult{}, err } - entry := entries.Resolve(context.Plan.Entries) - entryVersion, _ := entry.Metadata["version"].(string) + entry, _ := entryResolver.Resolve("yarn", context.Plan.Entries, nil) + version, ok := entry.Metadata["version"].(string) + if !ok { + version = "default" + } - dependency, err := dependencies.Resolve( + dependency, err := dependencyManager.Resolve( filepath.Join(context.CNBPath, "buildpack.toml"), entry.Name, - entryVersion, + version, context.Stack) if err != nil { return packit.BuildResult{}, err } - bom := planRefinery.BillOfMaterials(dependency) + bom := dependencyManager.GenerateBillOfMaterials(dependency) + + launch, build := entryResolver.MergeLayerTypes("yarn", context.Plan.Entries) + + var buildMetadata = packit.BuildMetadata{} + var launchMetadata = packit.LaunchMetadata{} + if build { + buildMetadata = packit.BuildMetadata{BOM: bom} + } + + if launch { + launchMetadata = packit.LaunchMetadata{BOM: bom} + } cachedSHA, ok := yarnLayer.Metadata[DependencyCacheKey].(string) if ok && cachedSHA == dependency.SHA256 { logger.Process("Reusing cached layer %s", yarnLayer.Path) logger.Break() + yarnLayer.Launch, yarnLayer.Build, yarnLayer.Cache = launch, build, build + return packit.BuildResult{ - Plan: packit.BuildpackPlan{ - Entries: []packit.BuildpackPlanEntry{bom}, - }, Layers: []packit.Layer{yarnLayer}, + Build: buildMetadata, + Launch: launchMetadata, }, nil } @@ -74,14 +87,12 @@ func Build( return packit.BuildResult{}, err } - yarnLayer.Build = entry.Metadata["build"] == true - yarnLayer.Cache = entry.Metadata["build"] == true - yarnLayer.Launch = entry.Metadata["launch"] == true + yarnLayer.Launch, yarnLayer.Build, yarnLayer.Cache = launch, build, build logger.Subprocess("Installing Yarn") duration, err := clock.Measure(func() error { - return dependencies.Install(dependency, context.CNBPath, yarnLayer.Path) + return dependencyManager.Deliver(dependency, context.CNBPath, yarnLayer.Path, context.Platform.Path) }) if err != nil { return packit.BuildResult{}, err @@ -96,10 +107,9 @@ func Build( } return packit.BuildResult{ - Plan: packit.BuildpackPlan{ - Entries: []packit.BuildpackPlanEntry{bom}, - }, Layers: []packit.Layer{yarnLayer}, + Build: buildMetadata, + Launch: launchMetadata, }, nil } } diff --git a/build_test.go b/build_test.go index d8a5f72..6e44513 100644 --- a/build_test.go +++ b/build_test.go @@ -12,6 +12,7 @@ import ( "github.com/paketo-buildpacks/packit" "github.com/paketo-buildpacks/packit/chronos" "github.com/paketo-buildpacks/packit/postal" + "github.com/paketo-buildpacks/packit/scribe" "github.com/paketo-buildpacks/yarn" "github.com/paketo-buildpacks/yarn/fakes" "github.com/sclevine/spec" @@ -28,7 +29,6 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { cnbDir string timestamp time.Time entryResolver *fakes.EntryResolver - planRefinery *fakes.BuildPlanRefinery dependencyManager *fakes.DependencyManager buffer *bytes.Buffer @@ -46,9 +46,6 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { workingDir, err = ioutil.TempDir("", "working-dir") Expect(err).NotTo(HaveOccurred()) - buffer = bytes.NewBuffer(nil) - logEmitter := yarn.NewLogEmitter(buffer) - timestamp = time.Now() clock := chronos.NewClock(func() time.Time { return timestamp @@ -68,19 +65,20 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { URI: "yarn-dependency-uri", Version: "yarn-dependency-version", } - - planRefinery = &fakes.BuildPlanRefinery{} - planRefinery.BillOfMaterialsCall.Returns.BuildpackPlanEntry = packit.BuildpackPlanEntry{ - Name: "yarn", - Metadata: map[string]interface{}{ - "name": "yarn-dependency-name", - "sha256": "yarn-dependency-sha", - "stacks": []string{"some-stack"}, - "uri": "yarn-dependency-uri", + dependencyManager.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice = []packit.BOMEntry{ + { + Name: "yarn", + Metadata: map[string]interface{}{ + "name": "yarn-dependency-name", + "sha256": "yarn-dependency-sha", + "stacks": []string{"some-stack"}, + "uri": "yarn-dependency-uri", + }, }, } - build = yarn.Build(entryResolver, dependencyManager, planRefinery, clock, logEmitter) + buffer = bytes.NewBuffer(nil) + build = yarn.Build(entryResolver, dependencyManager, clock, scribe.NewEmitter(buffer)) }) it.After(func() { @@ -105,24 +103,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }, }, }, - Layers: packit.Layers{Path: layersDir}, + Platform: packit.Platform{Path: "platform"}, + Layers: packit.Layers{Path: layersDir}, }) Expect(err).NotTo(HaveOccurred()) Expect(result).To(Equal(packit.BuildResult{ - Plan: packit.BuildpackPlan{ - Entries: []packit.BuildpackPlanEntry{ - { - Name: "yarn", - Metadata: map[string]interface{}{ - "name": "yarn-dependency-name", - "sha256": "yarn-dependency-sha", - "stacks": []string{"some-stack"}, - "uri": "yarn-dependency-uri", - }, - }, - }, - }, Layers: []packit.Layer{ { Name: "yarn", @@ -142,7 +128,13 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }, })) - Expect(entryResolver.ResolveCall.Receives.BuildpackPlanEntrySlice).To(Equal([]packit.BuildpackPlanEntry{ + Expect(entryResolver.ResolveCall.Receives.Name).To(Equal("yarn")) + Expect(entryResolver.ResolveCall.Receives.Entries).To(Equal([]packit.BuildpackPlanEntry{ + {Name: "yarn"}, + })) + + Expect(entryResolver.MergeLayerTypesCall.Receives.Name).To(Equal("yarn")) + Expect(entryResolver.MergeLayerTypesCall.Receives.Entries).To(Equal([]packit.BuildpackPlanEntry{ {Name: "yarn"}, })) @@ -150,7 +142,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { Expect(dependencyManager.ResolveCall.Receives.Id).To(Equal("yarn")) Expect(dependencyManager.ResolveCall.Receives.Stack).To(Equal("some-stack")) - Expect(dependencyManager.InstallCall.Receives.Dependency).To(Equal(postal.Dependency{ + Expect(dependencyManager.DeliverCall.Receives.Dependency).To(Equal(postal.Dependency{ ID: "yarn", Name: "yarn-dependency-name", SHA256: "yarn-dependency-sha", @@ -158,16 +150,18 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { URI: "yarn-dependency-uri", Version: "yarn-dependency-version", })) - Expect(dependencyManager.InstallCall.Receives.CnbPath).To(Equal(cnbDir)) - Expect(dependencyManager.InstallCall.Receives.LayerPath).To(Equal(filepath.Join(layersDir, "yarn"))) + Expect(dependencyManager.DeliverCall.Receives.CnbPath).To(Equal(cnbDir)) + Expect(dependencyManager.DeliverCall.Receives.LayerPath).To(Equal(filepath.Join(layersDir, "yarn"))) + Expect(dependencyManager.DeliverCall.Receives.PlatformPath).To(Equal("platform")) - Expect(planRefinery.BillOfMaterialsCall.Receives.Dependency).To(Equal(postal.Dependency{ + Expect(dependencyManager.GenerateBillOfMaterialsCall.Receives.Dependencies).To(Equal([]postal.Dependency{{ ID: "yarn", Name: "yarn-dependency-name", SHA256: "yarn-dependency-sha", Stacks: []string{"some-stack"}, URI: "yarn-dependency-uri", Version: "yarn-dependency-version", + }, })) Expect(buffer.String()).To(ContainSubstring("Some Buildpack some-version")) @@ -177,14 +171,10 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { context("when the plan entry requires the dependency during the build an launch phases", func() { it.Before(func() { - entryResolver.ResolveCall.Returns.BuildpackPlanEntry = packit.BuildpackPlanEntry{ - Name: "yarn", - Metadata: map[string]interface{}{ - "build": true, - "launch": true, - }, - } + entryResolver.MergeLayerTypesCall.Returns.Launch = true + entryResolver.MergeLayerTypesCall.Returns.Build = true }) + it("makes the layer available in those phases", func() { result, err := build(packit.BuildContext{ CNBPath: cnbDir, @@ -205,19 +195,6 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { Expect(err).NotTo(HaveOccurred()) Expect(result).To(Equal(packit.BuildResult{ - Plan: packit.BuildpackPlan{ - Entries: []packit.BuildpackPlanEntry{ - { - Name: "yarn", - Metadata: map[string]interface{}{ - "name": "yarn-dependency-name", - "sha256": "yarn-dependency-sha", - "stacks": []string{"some-stack"}, - "uri": "yarn-dependency-uri", - }, - }, - }, - }, Layers: []packit.Layer{ { Name: "yarn", @@ -235,6 +212,32 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }, }, }, + Build: packit.BuildMetadata{ + BOM: []packit.BOMEntry{ + { + Name: "yarn", + Metadata: map[string]interface{}{ + "name": "yarn-dependency-name", + "sha256": "yarn-dependency-sha", + "stacks": []string{"some-stack"}, + "uri": "yarn-dependency-uri", + }, + }, + }, + }, + Launch: packit.LaunchMetadata{ + BOM: []packit.BOMEntry{ + { + Name: "yarn", + Metadata: map[string]interface{}{ + "name": "yarn-dependency-name", + "sha256": "yarn-dependency-sha", + "stacks": []string{"some-stack"}, + "uri": "yarn-dependency-uri", + }, + }, + }, + }, })) }) }) @@ -306,7 +309,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { context("when the dependency cannot be installed", func() { it.Before(func() { - dependencyManager.InstallCall.Returns.Error = errors.New("failed to install dependency") + dependencyManager.DeliverCall.Returns.Error = errors.New("failed to install dependency") }) it("returns an error", func() { diff --git a/buildpack.toml b/buildpack.toml index 37f788a..9714913 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -1,4 +1,4 @@ -api = "0.4" +api = "0.5" [buildpack] homepage = "https://github.com/paketo-buildpacks/yarn" diff --git a/fakes/build_plan_refinery.go b/fakes/build_plan_refinery.go deleted file mode 100644 index 571a45d..0000000 --- a/fakes/build_plan_refinery.go +++ /dev/null @@ -1,33 +0,0 @@ -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit" - "github.com/paketo-buildpacks/packit/postal" -) - -type BuildPlanRefinery struct { - BillOfMaterialsCall struct { - sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - } - Returns struct { - BuildpackPlanEntry packit.BuildpackPlanEntry - } - Stub func(postal.Dependency) packit.BuildpackPlanEntry - } -} - -func (f *BuildPlanRefinery) BillOfMaterials(param1 postal.Dependency) packit.BuildpackPlanEntry { - f.BillOfMaterialsCall.Lock() - defer f.BillOfMaterialsCall.Unlock() - f.BillOfMaterialsCall.CallCount++ - f.BillOfMaterialsCall.Receives.Dependency = param1 - if f.BillOfMaterialsCall.Stub != nil { - return f.BillOfMaterialsCall.Stub(param1) - } - return f.BillOfMaterialsCall.Returns.BuildpackPlanEntry -} diff --git a/fakes/dependency_manager.go b/fakes/dependency_manager.go index 86449d5..7298e43 100644 --- a/fakes/dependency_manager.go +++ b/fakes/dependency_manager.go @@ -3,22 +3,35 @@ package fakes import ( "sync" + "github.com/paketo-buildpacks/packit" "github.com/paketo-buildpacks/packit/postal" ) type DependencyManager struct { - InstallCall struct { + DeliverCall struct { sync.Mutex CallCount int Receives struct { - Dependency postal.Dependency - CnbPath string - LayerPath string + Dependency postal.Dependency + CnbPath string + LayerPath string + PlatformPath string } Returns struct { Error error } - Stub func(postal.Dependency, string, string) error + Stub func(postal.Dependency, string, string, string) error + } + GenerateBillOfMaterialsCall struct { + sync.Mutex + CallCount int + Receives struct { + Dependencies []postal.Dependency + } + Returns struct { + BOMEntrySlice []packit.BOMEntry + } + Stub func(...postal.Dependency) []packit.BOMEntry } ResolveCall struct { sync.Mutex @@ -37,17 +50,28 @@ type DependencyManager struct { } } -func (f *DependencyManager) Install(param1 postal.Dependency, param2 string, param3 string) error { - f.InstallCall.Lock() - defer f.InstallCall.Unlock() - f.InstallCall.CallCount++ - f.InstallCall.Receives.Dependency = param1 - f.InstallCall.Receives.CnbPath = param2 - f.InstallCall.Receives.LayerPath = param3 - if f.InstallCall.Stub != nil { - return f.InstallCall.Stub(param1, param2, param3) +func (f *DependencyManager) Deliver(param1 postal.Dependency, param2 string, param3 string, param4 string) error { + f.DeliverCall.Lock() + defer f.DeliverCall.Unlock() + f.DeliverCall.CallCount++ + f.DeliverCall.Receives.Dependency = param1 + f.DeliverCall.Receives.CnbPath = param2 + f.DeliverCall.Receives.LayerPath = param3 + f.DeliverCall.Receives.PlatformPath = param4 + if f.DeliverCall.Stub != nil { + return f.DeliverCall.Stub(param1, param2, param3, param4) + } + return f.DeliverCall.Returns.Error +} +func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { + f.GenerateBillOfMaterialsCall.Lock() + defer f.GenerateBillOfMaterialsCall.Unlock() + f.GenerateBillOfMaterialsCall.CallCount++ + f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 + if f.GenerateBillOfMaterialsCall.Stub != nil { + return f.GenerateBillOfMaterialsCall.Stub(param1...) } - return f.InstallCall.Returns.Error + return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice } func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { f.ResolveCall.Lock() diff --git a/fakes/entry_resolver.go b/fakes/entry_resolver.go index 42e5602..cf457ed 100644 --- a/fakes/entry_resolver.go +++ b/fakes/entry_resolver.go @@ -7,26 +7,58 @@ import ( ) type EntryResolver struct { + MergeLayerTypesCall struct { + sync.Mutex + CallCount int + Receives struct { + Name string + Entries []packit.BuildpackPlanEntry + } + Returns struct { + Launch bool + Build bool + } + Stub func(string, []packit.BuildpackPlanEntry) (bool, bool) + } ResolveCall struct { sync.Mutex CallCount int Receives struct { - BuildpackPlanEntrySlice []packit.BuildpackPlanEntry + Name string + Entries []packit.BuildpackPlanEntry + Priorites []interface { + } } Returns struct { - BuildpackPlanEntry packit.BuildpackPlanEntry + BuildpackPlanEntry packit.BuildpackPlanEntry + BuildpackPlanEntrySlice []packit.BuildpackPlanEntry } - Stub func([]packit.BuildpackPlanEntry) packit.BuildpackPlanEntry + Stub func(string, []packit.BuildpackPlanEntry, []interface { + }) (packit.BuildpackPlanEntry, []packit.BuildpackPlanEntry) } } -func (f *EntryResolver) Resolve(param1 []packit.BuildpackPlanEntry) packit.BuildpackPlanEntry { +func (f *EntryResolver) MergeLayerTypes(param1 string, param2 []packit.BuildpackPlanEntry) (bool, bool) { + f.MergeLayerTypesCall.Lock() + defer f.MergeLayerTypesCall.Unlock() + f.MergeLayerTypesCall.CallCount++ + f.MergeLayerTypesCall.Receives.Name = param1 + f.MergeLayerTypesCall.Receives.Entries = param2 + if f.MergeLayerTypesCall.Stub != nil { + return f.MergeLayerTypesCall.Stub(param1, param2) + } + return f.MergeLayerTypesCall.Returns.Launch, f.MergeLayerTypesCall.Returns.Build +} +func (f *EntryResolver) Resolve(param1 string, param2 []packit.BuildpackPlanEntry, param3 []interface { +}) (packit.BuildpackPlanEntry, []packit.BuildpackPlanEntry) { f.ResolveCall.Lock() defer f.ResolveCall.Unlock() f.ResolveCall.CallCount++ - f.ResolveCall.Receives.BuildpackPlanEntrySlice = param1 + f.ResolveCall.Receives.Name = param1 + f.ResolveCall.Receives.Entries = param2 + f.ResolveCall.Receives.Priorites = param3 if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1) + return f.ResolveCall.Stub(param1, param2, param3) } - return f.ResolveCall.Returns.BuildpackPlanEntry + return f.ResolveCall.Returns.BuildpackPlanEntry, f.ResolveCall.Returns.BuildpackPlanEntrySlice } diff --git a/init_test.go b/init_test.go index 86f2880..c2ff1f1 100644 --- a/init_test.go +++ b/init_test.go @@ -11,7 +11,5 @@ func TestUnitYarn(t *testing.T) { suite := spec.New("yarn", spec.Report(report.Terminal{}), spec.Parallel()) suite("Build", testBuild) suite("Detect", testDetect) - suite("PlanEntryResolver", testPlanEntryResolver) - suite("PlanRefinery", testPlanRefinery) suite.Run(t) } diff --git a/log_emitter.go b/log_emitter.go deleted file mode 100644 index 00842ac..0000000 --- a/log_emitter.go +++ /dev/null @@ -1,19 +0,0 @@ -package yarn - -import ( - "io" - - "github.com/paketo-buildpacks/packit/scribe" -) - -type LogEmitter struct { - // Logger is embedded and therefore delegates all of its functions to the - // LogEmitter. - scribe.Logger -} - -func NewLogEmitter(output io.Writer) LogEmitter { - return LogEmitter{ - Logger: scribe.NewLogger(output), - } -} diff --git a/plan_entry_resolver.go b/plan_entry_resolver.go deleted file mode 100644 index 79dfb80..0000000 --- a/plan_entry_resolver.go +++ /dev/null @@ -1,28 +0,0 @@ -package yarn - -import ( - "github.com/paketo-buildpacks/packit" -) - -type PlanEntryResolver struct{} - -func NewPlanEntryResolver() PlanEntryResolver { - return PlanEntryResolver{} -} - -func (r PlanEntryResolver) Resolve(entries []packit.BuildpackPlanEntry) packit.BuildpackPlanEntry { - entry := entries[0] - if entry.Metadata == nil { - entry.Metadata = map[string]interface{}{} - } - - for _, e := range entries { - for _, phase := range []string{"build", "launch"} { - if e.Metadata[phase] == true { - entry.Metadata[phase] = true - } - } - } - - return entry -} diff --git a/plan_entry_resolver_test.go b/plan_entry_resolver_test.go deleted file mode 100644 index 395f13d..0000000 --- a/plan_entry_resolver_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package yarn_test - -import ( - "testing" - - "github.com/paketo-buildpacks/packit" - "github.com/paketo-buildpacks/yarn" - "github.com/sclevine/spec" - - . "github.com/onsi/gomega" -) - -func testPlanEntryResolver(t *testing.T, context spec.G, it spec.S) { - var ( - Expect = NewWithT(t).Expect - - resolver yarn.PlanEntryResolver - ) - - it.Before(func() { - resolver = yarn.NewPlanEntryResolver() - }) - - context("when entry flags differ", func() { - context("OR's them together on best plan entry", func() { - it("has all flags", func() { - entry := resolver.Resolve([]packit.BuildpackPlanEntry{ - { - Name: "yarn", - Metadata: map[string]interface{}{ - "launch": true, - }, - }, - { - Name: "yarn", - Metadata: map[string]interface{}{ - "build": true, - }, - }, - }) - Expect(entry).To(Equal(packit.BuildpackPlanEntry{ - Name: "yarn", - Metadata: map[string]interface{}{ - "build": true, - "launch": true, - }, - })) - }) - }) - }) -} diff --git a/plan_refinery.go b/plan_refinery.go deleted file mode 100644 index 4721ee2..0000000 --- a/plan_refinery.go +++ /dev/null @@ -1,26 +0,0 @@ -package yarn - -import ( - "github.com/paketo-buildpacks/packit" - "github.com/paketo-buildpacks/packit/postal" -) - -type PlanRefinery struct{} - -func NewPlanRefinery() PlanRefinery { - return PlanRefinery{} -} - -func (r PlanRefinery) BillOfMaterials(dependency postal.Dependency) packit.BuildpackPlanEntry { - return packit.BuildpackPlanEntry{ - Name: dependency.ID, - Metadata: map[string]interface{}{ - "licenses": []string{}, - "name": dependency.Name, - "sha256": dependency.SHA256, - "stacks": dependency.Stacks, - "uri": dependency.URI, - "version": dependency.Version, - }, - } -} diff --git a/plan_refinery_test.go b/plan_refinery_test.go deleted file mode 100644 index df82f1b..0000000 --- a/plan_refinery_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package yarn_test - -import ( - "testing" - - "github.com/paketo-buildpacks/packit" - "github.com/paketo-buildpacks/packit/postal" - yarn "github.com/paketo-buildpacks/yarn" - "github.com/sclevine/spec" - - . "github.com/onsi/gomega" -) - -func testPlanRefinery(t *testing.T, context spec.G, it spec.S) { - var ( - Expect = NewWithT(t).Expect - - refinery yarn.PlanRefinery - ) - - it.Before(func() { - refinery = yarn.NewPlanRefinery() - }) - - context("BillOfMaterials", func() { - it("returns a refined build plan entry", func() { - entry := refinery.BillOfMaterials(postal.Dependency{ - ID: "some-id", - Name: "some-name", - Stacks: []string{"some-stack"}, - URI: "some-uri", - SHA256: "some-sha", - Version: "some-version", - }) - Expect(entry).To(Equal(packit.BuildpackPlanEntry{ - Name: "some-id", - Metadata: map[string]interface{}{ - "licenses": []string{}, - "name": "some-name", - "sha256": "some-sha", - "stacks": []string{"some-stack"}, - "uri": "some-uri", - "version": "some-version", - }, - })) - }) - }) -} diff --git a/run/main.go b/run/main.go index 0b90f2c..f7aed5d 100644 --- a/run/main.go +++ b/run/main.go @@ -6,22 +6,22 @@ import ( "github.com/paketo-buildpacks/packit" "github.com/paketo-buildpacks/packit/cargo" "github.com/paketo-buildpacks/packit/chronos" + "github.com/paketo-buildpacks/packit/draft" "github.com/paketo-buildpacks/packit/postal" + "github.com/paketo-buildpacks/packit/scribe" "github.com/paketo-buildpacks/yarn" ) func main() { - entryResolver := yarn.NewPlanEntryResolver() + entryResolver := draft.NewPlanner() dependencyManager := postal.NewService(cargo.NewTransport()) - planRefinery := yarn.NewPlanRefinery() - logEmitter := yarn.NewLogEmitter(os.Stdout) + logEmitter := scribe.NewEmitter(os.Stdout) packit.Run( yarn.Detect(), yarn.Build( entryResolver, dependencyManager, - planRefinery, chronos.DefaultClock, logEmitter, ),