-
Notifications
You must be signed in to change notification settings - Fork 26
feat: display manifest source in human-friendly format #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
31559f0
5c27011
acd2a00
3913b13
4eaea06
9329993
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -173,14 +173,15 @@ func LinkExistingApp(ctx context.Context, clients *shared.ClientFactory, app *ty | |||||||||
| Emoji: "warning", | ||||||||||
| Text: "Warning", | ||||||||||
| Secondary: []string{ | ||||||||||
| "Existing apps have manifests configured by app settings", | ||||||||||
| "Linking existing apps requires the manifest source to be " + config.ManifestSourceRemote.String(), | ||||||||||
| fmt.Sprintf(`Manifest source can be "%s" or "%s"`, config.ManifestSourceLocal.String(), config.ManifestSourceRemote.String()), | ||||||||||
| "Linking an existing app requires the app manifest source to be", | ||||||||||
| fmt.Sprintf("managed by %s.", config.ManifestSourceRemote.Human()), | ||||||||||
| " ", | ||||||||||
| fmt.Sprintf(style.Highlight(`Your manifest source is "%s"`), manifestSource.String()), | ||||||||||
| fmt.Sprintf(`App manifest source can be "%s" or "%s":`, config.ManifestSourceLocal.Human(), config.ManifestSourceRemote.Human()), | ||||||||||
|
||||||||||
| fmt.Sprintf("- %s: uses manifest from your project's source code for all apps", config.ManifestSourceLocal.String()), | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
📚 This might not be a good suggestion, but confusion could arise with when these updates are. Perhaps this is alright though! Another command might make this difference more obvious in later iteration? $ slack manifest update
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit: This comment makes me think "on update" is better wording, but again no blocker!
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this can be confusing. Unfortunately, the project-level manifest is used in many places and not just updates/re-installs. For example, Looking ahead, this warning is probably going to be removed or reduced to a single line such as: 🤖 Some Title
Reading app manifest from app settings
Reading app manifest from projectSo, we probably don't need to overthink the current warning too much.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mwbrooks 🧠 ✨ Of course, how could I forget!
I will celebrate this learning with good a fortune 👾 |
||||||||||
| fmt.Sprintf("- %s: uses manifest from app settings for each app", config.ManifestSourceRemote.String()), | ||||||||||
| " ", | ||||||||||
| fmt.Sprintf(style.Highlight(`Your manifest source is "%s"`), manifestSource.Human()), | ||||||||||
| " ", | ||||||||||
|
||||||||||
| fmt.Sprintf("Current manifest source in %s:", style.Highlight(filepath.Join(config.ProjectConfigDirName, config.ProjectConfigJSONFilename))), | ||||||||||
| fmt.Sprintf(style.Highlight(` %s: "%s"`), "manifest.source", manifestSource.String()), | ||||||||||
| " ", | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |||||
|
|
||||||
| package config | ||||||
|
|
||||||
| import "fmt" | ||||||
|
|
||||||
| type ManifestSource string | ||||||
|
|
||||||
| const ( | ||||||
|
|
@@ -35,6 +37,17 @@ func (ms ManifestSource) String() string { | |||||
| return string(ms) | ||||||
| } | ||||||
|
|
||||||
| // Human returns the string value as a human-friendly name | ||||||
| func (ms ManifestSource) Human() string { | ||||||
| switch ms { | ||||||
| case ManifestSourceLocal: | ||||||
| return fmt.Sprintf("project (%s)", ms.String()) | ||||||
|
||||||
| case ManifestSourceRemote: | ||||||
| return fmt.Sprintf("app settings (%s)", ms.String()) | ||||||
| } | ||||||
| return "" | ||||||
|
||||||
| return "" | |
| return ms.String() |
Ought not we find a confusing blank output here in some strange case 😉
Edit: A test for this too would be superb but is also no blocker for me 🤖 ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great eye! Commit 3913b13 handles unknown manifest sources with your suggestion above and adds a test case 👌🏻
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,11 +84,11 @@ func Test_Config_ManifestSource_String(t *testing.T) { | |
| a ManifestSource | ||
| expected string | ||
| }{ | ||
| "project manifest source is local": { | ||
| "local manifest source": { | ||
| a: ManifestSourceLocal, | ||
| expected: "local", | ||
| }, | ||
| "remote manifest source is remote": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪓 🪓 |
||
| "remote manifest source": { | ||
| a: ManifestSourceRemote, | ||
| expected: "remote", | ||
| }, | ||
|
|
@@ -100,3 +100,25 @@ func Test_Config_ManifestSource_String(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func Test_Config_ManifestSource_Human(t *testing.T) { | ||
| tests := map[string]struct { | ||
| a ManifestSource | ||
| expected string | ||
| }{ | ||
| "local manifest source is the project (local)": { | ||
| a: ManifestSourceLocal, | ||
| expected: "project (local)", | ||
| }, | ||
| "remote manifest source is app settings (remote)": { | ||
| a: ManifestSourceRemote, | ||
| expected: "app settings (remote)", | ||
| }, | ||
| } | ||
| for name, tt := range tests { | ||
| t.Run(name, func(t *testing.T) { | ||
| actual := tt.a.Human() | ||
| assert.Equal(t, tt.expected, actual) | ||
| }) | ||
| } | ||
| } | ||



Uh oh!
There was an error while loading. Please reload this page.