From df1797b76274e6f607d825abcd1d6f1dcb8cf161 Mon Sep 17 00:00:00 2001 From: jon-stewart Date: Thu, 22 Feb 2024 14:38:56 +0000 Subject: [PATCH 1/4] fix: lint error --- lwcomponent/catalog.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lwcomponent/catalog.go b/lwcomponent/catalog.go index a136d5644..a3ad95761 100644 --- a/lwcomponent/catalog.go +++ b/lwcomponent/catalog.go @@ -210,7 +210,10 @@ func (c *Catalog) Install(component *CDKComponent) (err error) { return } - CreateHostInfo(componentDir, component.Description, component.Type) + component.HostInfo, err = CreateHostInfo(componentDir, component.Description, component.Type) + if err != nil { + return + } if component.ApiInfo != nil && (component.ApiInfo.ComponentType == BinaryType || component.ApiInfo.ComponentType == CommandType) { @@ -219,8 +222,6 @@ func (c *Catalog) Install(component *CDKComponent) (err error) { } } - component.HostInfo, err = NewHostInfo(componentDir) - return } From ee47772e8c280057ed6c758b4f9ae9f374509d24 Mon Sep 17 00:00:00 2001 From: jon-stewart Date: Thu, 22 Feb 2024 14:42:56 +0000 Subject: [PATCH 2/4] fix: lint --- lwcomponent/catalog.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lwcomponent/catalog.go b/lwcomponent/catalog.go index a3ad95761..821243c5e 100644 --- a/lwcomponent/catalog.go +++ b/lwcomponent/catalog.go @@ -381,7 +381,12 @@ func LoadLocalComponents() (components map[string]CDKComponent, err error) { } components[hostInfo.Name()] = NewCDKComponent(hostInfo.Name(), devInfo.Desc, devInfo.ComponentType, nil, hostInfo) } else { - components[hostInfo.Name()] = NewCDKComponent(hostInfo.Name(), hostInfo.Description, hostInfo.ComponentType, nil, hostInfo) + components[hostInfo.Name()] = NewCDKComponent( + hostInfo.Name(), + hostInfo.Description, + hostInfo.ComponentType, + nil, + hostInfo) } } From d45e984f814217dad58c1cc925f6002c24852497 Mon Sep 17 00:00:00 2001 From: jon-stewart Date: Thu, 22 Feb 2024 15:08:40 +0000 Subject: [PATCH 3/4] fix: missing state file --- lwcomponent/catalog.go | 4 ++++ lwcomponent/catalog_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lwcomponent/catalog.go b/lwcomponent/catalog.go index 821243c5e..9a4ae7717 100644 --- a/lwcomponent/catalog.go +++ b/lwcomponent/catalog.go @@ -350,6 +350,10 @@ func LoadLocalComponents() (components map[string]CDKComponent, err error) { // Prototype backwards compatibility prototypeState, err := LocalState() + if err != nil { + prototypeState = new(State) + err = nil + } prototypeComponents := make(map[string]Component, len(prototypeState.Components)) for _, component := range prototypeState.Components { prototypeComponents[component.Name] = component diff --git a/lwcomponent/catalog_test.go b/lwcomponent/catalog_test.go index 1bfa480ab..e735fe2e1 100644 --- a/lwcomponent/catalog_test.go +++ b/lwcomponent/catalog_test.go @@ -999,6 +999,16 @@ func CreateLocalComponent(componentName string, version string, development bool panic(err) } + info := lwcomponent.HostInfo{Dir: "", Description: "", ComponentType: lwcomponent.BinaryType} + data, err := json.Marshal(info) + if err != nil { + panic(err) + } + + if err := os.WriteFile(filepath.Join(path, lwcomponent.InfoFile), []byte(data), 0666); err != nil { + panic(err) + } + if err := os.WriteFile(filepath.Join(path, lwcomponent.SignatureFile), []byte(version), 0666); err != nil { panic(err) } From 45f265070356cd60de44f7a7304d2fdf4e568277 Mon Sep 17 00:00:00 2001 From: jon-stewart Date: Thu, 22 Feb 2024 15:15:51 +0000 Subject: [PATCH 4/4] fix: test --- lwcomponent/component_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lwcomponent/component_test.go b/lwcomponent/component_test.go index 2a6253d68..591a1c35a 100644 --- a/lwcomponent/component_test.go +++ b/lwcomponent/component_test.go @@ -231,13 +231,6 @@ var currentSignatureTests = []currentSignatureTest{ Component: mockComponent2, Error: errors.New("component signature file does not exist"), }, - { - Name: "bad", - Component: mockComponent, - Signature: "-", - Expected: []byte{}, - Error: errors.New("unable to decode component signature"), - }, { Name: "ok", Component: mockComponent,