feat: support SLACK_CLI_APP_ICON_PATH env var for icon override#519
feat: support SLACK_CLI_APP_ICON_PATH env var for icon override#519
Conversation
Allow users to override the app icon path via the SLACK_CLI_APP_ICON_PATH environment variable, enabling different icons per environment without changing project files. Priority chain: env var > manifest icon > icon.png in project root. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #519 +/- ##
==========================================
+ Coverage 71.26% 71.28% +0.01%
==========================================
Files 222 222
Lines 18682 18695 +13
==========================================
+ Hits 13314 13326 +12
+ Misses 4188 4187 -1
- Partials 1180 1182 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| return envIconPath | ||
| } | ||
| clients.IO.PrintDebug(ctx, "SLACK_CLI_APP_ICON_PATH file not found: %s", envIconPath) | ||
| _, _ = clients.IO.WriteOut().Write([]byte(style.SectionSecondaryf("Warning: icon path from SLACK_CLI_APP_ICON_PATH not found: %s", envIconPath))) |
There was a problem hiding this comment.
SLACK_CLI_APP_ICON_PATH is set. IMHO we should print the warning and return no value instead?
| if _, err := os.Stat(envIconPath); !os.IsNotExist(err) { | ||
| return envIconPath | ||
| } |
There was a problem hiding this comment.
🪬 question: Is this a check we should also include for manifestIcon values?
| // upload icon, default to icon.png | ||
| var iconPath = slackManifest.Icon | ||
| if iconPath == "" { | ||
| if _, err := os.Stat("icon.png"); !os.IsNotExist(err) { | ||
| iconPath = "icon.png" | ||
| } | ||
| } |
There was a problem hiding this comment.
📸 thought: Keeping this inline might be alright to avoided redirected logic?
⛈️ ramble: I might suggest we instead also extract the "upload" logic that follows this since it's duplicated too, but I'd much prefer the Install and InstallLocalApp functions be merged because the logic is almost identical if this is changing-
| } | ||
|
|
||
| // Load app icon path from environment variables | ||
| var appIconPath = strings.TrimSpace(c.os.Getenv(slackAppIconPathEnv)) |
There was a problem hiding this comment.
📠 issue: This might not capture values from the .env file also. I'm wondering if this extends to other values in this file so perhaps not a blocker?
There was a problem hiding this comment.
yup all other env vars are read from system !
| APIHostFlag string | ||
| APIHostResolved string | ||
| AppFlag string | ||
| AppIconPathFlag string |
There was a problem hiding this comment.
👾 thought: Interesting to find "app icon path" reads more clear than "CLI app icon path" but this ought not block decision on:
- SLACK_APP_ICON_PATH
+ SLACK_CLI_APP_ICON_PATH🌲 ramble: I'm curious now again if "file" path needs to be specified in these values? Curious if path is clear enough on it's own...
There was a problem hiding this comment.
i can change it to CLIAppIconPath! i was matching it to the other vars here but it doesnt have to
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
- Update constant reference to slackCLIAppIconPathEnv - Stop falling through to manifest/icon.png when env var file is missing - Add file existence check for manifest icon values - Update tests for new behavior
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
zimeg
left a comment
There was a problem hiding this comment.
- Baseline — default icon via
slack run./bin/slack run -e set-iconConfirm output shows Updated app icon: assets/icon.png
$ slack create --branch add-app-icon -t slack-samples/bolt-js-starter-template
$ slack version
Using slack v4.0.1-ale-icon-env-var-15-g2778c01Would this be a change for this PR or can I test this with another pattern? 💡
|
📚 suggestion: Would be good to note this as |
Summary
SLACK_CLI_APP_ICON_PATHenvironment variable support to override the app icon path at install/deploy timeSLACK_CLI_APP_ICON_PATHenv var > manifesticonfield >icon.pngin project rootresolveIconPathhelper used by bothInstall()(hosted) andInstallLocalApp()(non-hosted) flowsTest plan
Unit tests
go test ./internal/config/ -run Test_DotEnv— env var loading (set, empty, whitespace trimming)go test ./internal/pkg/apps/ -run Test_resolveIconPath— all 8 priority chain scenariosManual testing
From a Slack app project directory with
assets/icon.png:Baseline — default icon via
slack runConfirm output shows
Updated app icon: assets/icon.pngOverride via env var
export SLACK_CLI_APP_ICON_PATH=icon.png ./bin/slack run -e set-iconConfirm output shows
Updated app icon: icon.pngInvalid env var path falls back
export SLACK_CLI_APP_ICON_PATH=/nonexistent/icon.png ./bin/slack run -e set-iconConfirm warning about file not found and fallback to manifest/default icon
Unset env var restores default
unset SLACK_CLI_APP_ICON_PATH ./bin/slack run -e set-iconConfirm output shows
Updated app icon: assets/icon.png🤖 Generated with Claude Code