Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: address review feedback on icon resolution
- Move supportedExtensions to local var inside ResolveIconPath
- Add test for manifest icon taking priority over magic files
- Remove unused hasValidIconPath and Verify methods from SlackYaml
- Remove corresponding slack_yaml_test.go (coverage lives in icon pkg)

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
  • Loading branch information
srtaalej and Claude committed May 8, 2026
commit af619c93578bdcae4b0ebea9517b449e2fccc33f
4 changes: 2 additions & 2 deletions internal/icon/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"github.com/spf13/afero"
)


func ResolveIconPath(fs afero.Fs, manifestIcon string) string {
if manifestIcon != "" {
return manifestIcon
}
supportedExtensions := []string{".png", ".jpg", ".jpeg", ".gif"}
for _, dir := range []string{"assets", "."} {
for _, ext := range SupportedExtensions {
for _, ext := range supportedExtensions {
candidate := filepath.Join(dir, "icon"+ext)
if _, err := fs.Stat(candidate); err == nil {
return candidate
Expand Down
5 changes: 5 additions & 0 deletions internal/icon/icon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func Test_ResolveIconPath(t *testing.T) {
manifestIcon: "custom/my-icon.png",
expected: "custom/my-icon.png",
},
Comment on lines +31 to +34
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 suggestion: Can we include a test that manifest icon is found before magic icons too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good catch!

"manifest icon preferred over magic icon files": {
manifestIcon: "custom/my-icon.png",
files: []string{"assets/icon.png", "icon.png"},
expected: "custom/my-icon.png",
},
"assets/icon.png found": {
files: []string{"assets/icon.png"},
expected: "assets/icon.png",
Expand Down
31 changes: 0 additions & 31 deletions internal/shared/types/slack_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,8 @@

package types

import (
"os"
"path/filepath"

"github.com/slackapi/slack-cli/internal/icon"
"github.com/slackapi/slack-cli/internal/slackerror"
"github.com/spf13/afero"
)

type SlackYaml struct {
AppManifest `yaml:",inline"`
Icon string `yaml:"icon"`
Hash string
}

// hasValidIconPath returns false if icon path is provided but is not valid and true otherwise
wd, err := os.Getwd()
if err != nil {
return true
}
if sy.Icon == "" {
sy.Icon = icon.ResolveIconPath(afero.NewBasePathFs(fs, wd), "")
} else {
if _, err := fs.Stat(filepath.Join(wd, sy.Icon)); os.IsNotExist(err) {
return false
}
}
return true
}

// Verify checks that the app manifest meets some basic requirements
if !sy.hasValidIconPath(fs) {
return slackerror.New("Please specify a valid icon path in app manifest")
}
return nil
}
138 changes: 0 additions & 138 deletions internal/shared/types/slack_yaml_test.go

This file was deleted.

Loading