feat(create): fetch remote manifest after linking app during create#585
feat(create): fetch remote manifest after linking app during create#585srtaalej wants to merge 12 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #585 +/- ##
==========================================
+ Coverage 71.64% 71.70% +0.05%
==========================================
Files 226 226
Lines 19176 19198 +22
==========================================
+ Hits 13739 13765 +26
+ Misses 4222 4221 -1
+ Partials 1215 1212 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Resolve conflicts by integrating main's stricter --app/--environment validation with the remote manifest fetch feature. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej Thanks for sharing these changes 👾 ✨
I'm leaving a few comments on a first run experience around prompts and earlier errors. Other comments are on code organization with thoughts around the difference between create and link logic that might be interesting to clear up ✂️ 📠
Testing is solid for me too but I leave a note around escaped values that are unsettling to me. I'm unsure what caused that 👻
| // fetchAndWriteRemoteManifest fetches the app manifest from remote settings and writes it to the project. | ||
| func fetchAndWriteRemoteManifest(ctx context.Context, clients *shared.ClientFactory, token, appID, projectPath string) error { | ||
| slackYaml, err := clients.AppClient().Manifest.GetManifestRemote(ctx, token, appID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| data, err := json.MarshalIndent(slackYaml.AppManifest, "", " ") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| data = append(data, '\n') | ||
| manifestPath := filepath.Join(projectPath, "manifest.json") | ||
| return afero.WriteFile(clients.Fs, manifestPath, data, 0644) | ||
| } | ||
|
|
There was a problem hiding this comment.
📠 suggestion: We might find a new file better for this? It might be shared in other commands or PRs #591!
internal/manifest/export.go
| clients.IO.PrintWarning(ctx, "%s", style.Sectionf(style.TextSection{ | ||
| Text: "Could not fetch the remote app manifest", | ||
| Secondary: []string{ | ||
| fetchErr.Error(), | ||
| "The template manifest was kept unchanged", | ||
| }, | ||
| })) |
There was a problem hiding this comment.
| LinkAppFooterSection(ctx, clients, app) | ||
|
|
||
| return nil | ||
| return auth, nil |
There was a problem hiding this comment.
🔗 question: Instead of returning an auth to calling functions that's often ignored, would setting up the manifest as part of the link command if no apps are saved make sense?
👾 ramble: I'm wanting to avoid mixing concepts with the create command which should be from a project template I think while link is seeming more app specific.
| if err != nil { | ||
| return err | ||
| } | ||
| data, err := json.MarshalIndent(slackYaml.AppManifest, "", " ") |
There was a problem hiding this comment.
🔬 note: I'm finding some values are escaped but this hasn't caused an error when testing the custom step template:
- "type": "slack#/types/user_id",
+ "type": "slack#\/types\/user_id",| } | ||
| data = append(data, '\n') | ||
| manifestPath := filepath.Join(projectPath, "manifest.json") | ||
| return afero.WriteFile(clients.Fs, manifestPath, data, 0644) |
There was a problem hiding this comment.
🏁 suggestion: We should save the hash alongside this to avoid a confusing prompt of a changed manifest on the first "run" command:
slack-cli/internal/pkg/apps/install.go
Lines 167 to 176 in f984c33
$ cd my-test
$ slack run
📚 App Manifest
Manifest values for this app are overwritten on reinstall
┃ Overwrite manifest on app settings with the project's manifest file?
┃ Yes
┃ ❱ No
Changelog
slack create --appnow fetches the app's manifest from remote settings and writes it to the project'smanifest.json, replacing the template's generic manifest with the actual app configuration.Summary
Follow-up to #565. After linking an existing app during
slack create --app --template, the CLI now fetches the remote manifest from App Settings and overwrites the template'smanifest.jsonwith it.This also updates
LinkExistingAppto return (*types.SlackAuth, error) so callers can use the auth token for subsequent API calls (like manifest fetching).Design decisions:
.slack/config.json— the remote content is written locallymanifest.jsonis overwritten (notmanifest.ts/.jswhich are code files in Deno projects)Testing
Manual:
make build./bin/slack create my-test -t slack-samples/bolt-js-starter-template --app <real-app-id> --environment localmy-test/manifest.jsoncontains the remote app's manifestNotes 🔴
.slack/config.jsonafter writing the fetched manifest? Currently left as local so the user "owns" the file going forward.manifest.ts/.js(Deno SDK) projects are not supportedRequirements