@@ -24,6 +24,7 @@ import (
2424 "github.com/opentracing/opentracing-go"
2525 "github.com/slackapi/slack-cli/internal/api"
2626 "github.com/slackapi/slack-cli/internal/config"
27+ "github.com/slackapi/slack-cli/internal/experiment"
2728 "github.com/slackapi/slack-cli/internal/pkg/manifest"
2829 "github.com/slackapi/slack-cli/internal/shared"
2930 "github.com/slackapi/slack-cli/internal/shared/types"
@@ -521,30 +522,25 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
521522 return app , result , installState , err
522523 }
523524
524- //
525- // TODO: Currently, cannot update the icon if app is not hosted.
526- //
527- // upload icon, default to icon.png
528- // var iconPath = slackYaml.Icon
529- // if iconPath == "" {
530- // if _, err := os.Stat("icon.png"); !os.IsNotExist(err) {
531- // iconPath = "icon.png"
532- // }
533- // }
534- // if iconPath != "" {
535- // clients.IO.PrintDebug(ctx, "uploading icon")
536- // err = updateIcon(ctx, clients, iconPath, env.AppID, token)
537- // if err != nil {
538- // clients.IO.PrintError(ctx, "An error occurred updating the Icon", err)
539- // }
540- // // Save a md5 hash of the icon in environments.yaml
541- // var iconHash string
542- // iconHash, err = getIconHash(iconPath)
543- // if err != nil {
544- // return env, api.DeveloperAppInstallResult{}, err
545- // }
546- // env.IconHash = iconHash
547- // }
525+ // upload icon for non-hosted apps (gated behind set-icon experiment)
526+ 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+ }
533+ if iconPath != "" {
534+ clients .IO .PrintDebug (ctx , "uploading icon" )
535+ _ , iconErr := clients .API ().IconSet (ctx , clients .Fs , token , app .AppID , iconPath )
536+ if iconErr != nil {
537+ clients .IO .PrintDebug (ctx , "icon error: %s" , iconErr )
538+ _ , _ = clients .IO .WriteOut ().Write ([]byte (style .SectionSecondaryf ("Error updating app icon: %s" , iconErr )))
539+ } else {
540+ _ , _ = clients .IO .WriteOut ().Write ([]byte (style .SectionSecondaryf ("Updated app icon: %s" , iconPath )))
541+ }
542+ }
543+ }
548544
549545 // update config with latest yaml hash
550546 // env.Hash = slackYaml.Hash
0 commit comments