Skip to content

Commit 99fbbb4

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/modelcontextprotocol/registry-1.7.7
2 parents f1e8f43 + 59d720d commit 99fbbb4

8 files changed

Lines changed: 135 additions & 164 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![tests](https://github.com/slackapi/slack-cli/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/slackapi/slack-cli/actions/workflows/tests.yml)
44
[![codecov](https://codecov.io/gh/slackapi/slack-cli/branch/main/graph/badge.svg?token=G5TU59IV9I)](https://codecov.io/gh/slackapi/slack-cli)
5-
[![circleci](https://dl.circleci.com/status-badge/img/gh/slackapi/slack-cli/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/slackapi/slack-cli/tree/main)
5+
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/slackapi/slack-cli/tree/main.svg?style=shield&circle-token=CCIPRJ_K7pGxh2PtW5AurUdJTKWpb_2845116e5a6f641726a73654f618e450b0c4e95b)](https://dl.circleci.com/status-badge/redirect/gh/slackapi/slack-cli/tree/main)
66

77
> Command-line interface for building apps on the Slack Platform.
88

internal/icon/icon.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2022-2026 Salesforce, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package icon
16+
17+
import (
18+
"path/filepath"
19+
20+
"github.com/spf13/afero"
21+
)
22+
23+
func ResolveIconPath(fs afero.Fs, manifestIcon string) string {
24+
if manifestIcon != "" {
25+
return manifestIcon
26+
}
27+
supportedExtensions := []string{".png", ".jpg", ".jpeg", ".gif"}
28+
for _, dir := range []string{"assets", "."} {
29+
for _, ext := range supportedExtensions {
30+
candidate := filepath.Join(dir, "icon"+ext)
31+
if _, err := fs.Stat(candidate); err == nil {
32+
return candidate
33+
}
34+
}
35+
}
36+
return ""
37+
}

internal/icon/icon_test.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright 2022-2026 Salesforce, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package icon
16+
17+
import (
18+
"testing"
19+
20+
"github.com/spf13/afero"
21+
"github.com/stretchr/testify/assert"
22+
"github.com/stretchr/testify/require"
23+
)
24+
25+
func Test_ResolveIconPath(t *testing.T) {
26+
tests := map[string]struct {
27+
manifestIcon string
28+
files []string
29+
expected string
30+
}{
31+
"manifest icon set returns it directly": {
32+
manifestIcon: "custom/my-icon.png",
33+
expected: "custom/my-icon.png",
34+
},
35+
"manifest icon preferred over magic icon files": {
36+
manifestIcon: "custom/my-icon.png",
37+
files: []string{"assets/icon.png", "icon.png"},
38+
expected: "custom/my-icon.png",
39+
},
40+
"assets/icon.png found": {
41+
files: []string{"assets/icon.png"},
42+
expected: "assets/icon.png",
43+
},
44+
"assets/icon.jpg found": {
45+
files: []string{"assets/icon.jpg"},
46+
expected: "assets/icon.jpg",
47+
},
48+
"assets/icon.jpeg found": {
49+
files: []string{"assets/icon.jpeg"},
50+
expected: "assets/icon.jpeg",
51+
},
52+
"assets/icon.gif found": {
53+
files: []string{"assets/icon.gif"},
54+
expected: "assets/icon.gif",
55+
},
56+
"png wins over other extensions": {
57+
files: []string{"assets/icon.jpg", "assets/icon.jpeg", "assets/icon.gif", "assets/icon.png"},
58+
expected: "assets/icon.png",
59+
},
60+
"jpg wins over gif in assets": {
61+
files: []string{"assets/icon.jpg", "assets/icon.gif"},
62+
expected: "assets/icon.jpg",
63+
},
64+
"root icon.png found when no assets": {
65+
files: []string{"icon.png"},
66+
expected: "icon.png",
67+
},
68+
"root icon.jpg found when no assets": {
69+
files: []string{"icon.jpg"},
70+
expected: "icon.jpg",
71+
},
72+
"assets takes priority over root": {
73+
files: []string{"assets/icon.gif", "icon.png"},
74+
expected: "assets/icon.gif",
75+
},
76+
"no icon files returns empty": {
77+
files: []string{},
78+
expected: "",
79+
},
80+
}
81+
for name, tc := range tests {
82+
t.Run(name, func(t *testing.T) {
83+
fs := afero.NewMemMapFs()
84+
for _, f := range tc.files {
85+
require.NoError(t, afero.WriteFile(fs, f, []byte("img"), 0o644))
86+
}
87+
result := ResolveIconPath(fs, tc.manifestIcon)
88+
assert.Equal(t, tc.expected, result)
89+
})
90+
}
91+
}

internal/pkg/apps/install.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ package apps
1717
import (
1818
"context"
1919
"fmt"
20-
"os"
2120
"strings"
2221
"time"
2322

2423
"github.com/opentracing/opentracing-go"
2524
"github.com/slackapi/slack-cli/internal/api"
2625
"github.com/slackapi/slack-cli/internal/config"
2726
"github.com/slackapi/slack-cli/internal/experiment"
27+
"github.com/slackapi/slack-cli/internal/icon"
2828
"github.com/slackapi/slack-cli/internal/pkg/manifest"
2929
"github.com/slackapi/slack-cli/internal/shared"
3030
"github.com/slackapi/slack-cli/internal/shared/types"
@@ -218,13 +218,8 @@ func Install(ctx context.Context, clients *shared.ClientFactory, auth types.Slac
218218
}
219219
}
220220

221-
// upload icon, default to icon.png
222-
var iconPath = slackManifest.Icon
223-
if iconPath == "" {
224-
if _, err := os.Stat("icon.png"); !os.IsNotExist(err) {
225-
iconPath = "icon.png"
226-
}
227-
}
221+
// upload icon, default to assets/icon.{png,jpg,jpeg,gif} or icon.{png,jpg,jpeg,gif}
222+
iconPath := icon.ResolveIconPath(clients.Fs, slackManifest.Icon)
228223
if iconPath != "" {
229224
err = updateIcon(ctx, clients, iconPath, app.AppID, token, manifest.IsFunctionRuntimeSlackHosted())
230225
if err != nil {
@@ -524,12 +519,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
524519

525520
// upload icon for non-hosted apps (gated behind set-icon experiment)
526521
if clients.Config.WithExperimentOn(experiment.SetIcon) {
527-
var iconPath = slackManifest.Icon
528-
if iconPath == "" {
529-
if _, err := os.Stat("icon.png"); !os.IsNotExist(err) {
530-
iconPath = "icon.png"
531-
}
532-
}
522+
iconPath := icon.ResolveIconPath(clients.Fs, slackManifest.Icon)
533523
if iconPath != "" {
534524
_, iconErr := clients.API().IconSet(ctx, clients.Fs, token, app.AppID, iconPath)
535525
if iconErr != nil {

internal/shared/types/slack_yaml.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,8 @@
1414

1515
package types
1616

17-
import (
18-
"os"
19-
"path/filepath"
20-
21-
"github.com/slackapi/slack-cli/internal/slackerror"
22-
)
23-
2417
type SlackYaml struct {
2518
AppManifest `yaml:",inline"`
2619
Icon string `yaml:"icon"`
2720
Hash string
2821
}
29-
30-
// hasValidIconPath returns false if icon path is provided but is not valid and true otherwise
31-
func (sy *SlackYaml) hasValidIconPath() bool {
32-
// verify icon path is valid if exists
33-
var wd, err = os.Getwd()
34-
if err == nil {
35-
if sy.Icon == "" { // icon was not provided. Let's check if the default one exists
36-
var defaultIconPath = "assets/icon.png"
37-
if _, err := os.Stat(filepath.Join(wd, defaultIconPath)); !os.IsNotExist(err) {
38-
sy.Icon = defaultIconPath
39-
}
40-
} else {
41-
if _, err := os.Stat(filepath.Join(wd, sy.Icon)); os.IsNotExist(err) {
42-
return false
43-
}
44-
}
45-
}
46-
47-
return true
48-
}
49-
50-
// Verify checks that the app manifest meets some basic requirements
51-
func (sy *SlackYaml) Verify() error {
52-
if !sy.hasValidIconPath() {
53-
return slackerror.New("Please specify a valid icon path in app manifest")
54-
}
55-
return nil
56-
}

internal/shared/types/slack_yaml_test.go

Lines changed: 0 additions & 112 deletions
This file was deleted.

scripts/install-dev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ install_slack_cli() {
166166
if [ "$SLACK_CLI_DEV_VERSION" == "dev" ]; then
167167
delay 0.2 "💾 Successfully downloaded the latest build to $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
168168
else
169-
delay 0.2 "💾 Successfully downloaded Slack CLI v$LATEST_SLACK_CLI_VERSION to $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
169+
delay 0.2 "💾 Successfully downloaded Slack CLI v$SLACK_CLI_DEV_VERSION to $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
170170
fi
171171

172172
delay 0.3 "📦 Extracting the Slack CLI command binary to $(home_path "$slack_cli_bin_path")"

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ install_slack_cli() {
165165
echo -e "\x1b[2m\n$slack_cli_url"
166166
curl -# -fLo "$slack_cli_install_dir/slack-cli.tar.gz" "$slack_cli_url"
167167
echo -e "\x1b[0m"
168-
delay 0.2 "💾 Successfully downloaded Slack CLI v$LATEST_SLACK_CLI_VERSION to $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
168+
delay 0.2 "💾 Successfully downloaded Slack CLI v$SLACK_CLI_VERSION to $(home_path "$slack_cli_install_dir/slack-cli.tar.gz")"
169169

170170
delay 0.3 "📦 Extracting the Slack CLI command binary to $(home_path "$slack_cli_bin_path")"
171171
tar -xf "$slack_cli_install_dir/slack-cli.tar.gz" -C "$slack_cli_install_dir"

0 commit comments

Comments
 (0)