diff --git a/cmd/app/link.go b/cmd/app/link.go index 4defb31b..69dae262 100644 --- a/cmd/app/link.go +++ b/cmd/app/link.go @@ -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 managed by", + fmt.Sprintf("%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()), fmt.Sprintf("- %s: uses manifest from app settings for each app", config.ManifestSourceRemote.String()), " ", + fmt.Sprintf(style.Highlight(`Your manifest source is set to %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()), " ", diff --git a/cmd/project/init_test.go b/cmd/project/init_test.go index 5c8e9033..4fcea41c 100644 --- a/cmd/project/init_test.go +++ b/cmd/project/init_test.go @@ -80,7 +80,7 @@ func Test_Project_InitCommand(t *testing.T) { require.Contains(t, output, "Added "+filepath.Join("project-name", ".slack")) require.Contains(t, output, "Added "+filepath.Join("project-name", ".slack", ".gitignore")) require.Contains(t, output, "Added "+filepath.Join("project-name", ".slack", "hooks.json")) - require.Contains(t, output, "Updated config.json manifest source to local") + require.Contains(t, output, `Updated config.json manifest source to "project" (local)`) // Assert prompt to add existing apps was called cm.IO.AssertCalled( t, diff --git a/internal/config/manifest.go b/internal/config/manifest.go index e5a4e8e2..8f5c2f5f 100644 --- a/internal/config/manifest.go +++ b/internal/config/manifest.go @@ -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 ms.String() +} + type ManifestConfig struct { // Source of the manifest using either "local" or "remote" values Source string `json:"source,omitempty"` diff --git a/internal/config/manifest_test.go b/internal/config/manifest_test.go index a2942d68..2e2651b3 100644 --- a/internal/config/manifest_test.go +++ b/internal/config/manifest_test.go @@ -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": { + "remote manifest source": { a: ManifestSourceRemote, expected: "remote", }, @@ -100,3 +100,29 @@ 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)`, + }, + "unknown manifest source uses String()": { + a: "unknown", + expected: "unknown", + }, + } + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + actual := tt.a.Human() + assert.Equal(t, tt.expected, actual) + }) + } +} diff --git a/internal/pkg/create/create.go b/internal/pkg/create/create.go index 449ae3d9..f334aa5c 100644 --- a/internal/pkg/create/create.go +++ b/internal/pkg/create/create.go @@ -466,7 +466,7 @@ func InstallProjectDependencies( clients.IO.PrintDebug(ctx, "Error setting manifest source in project-level config: %s", err) } else { configJSONFilename := config.ProjectConfigJSONFilename - manifestSourceStyled := style.Highlight(manifestSource.String()) + manifestSourceStyled := style.Highlight(manifestSource.Human()) outputs = append(outputs, fmt.Sprintf( "Updated %s manifest source to %s", diff --git a/internal/pkg/create/create_test.go b/internal/pkg/create/create_test.go index 6c2e552e..97e28bc2 100644 --- a/internal/pkg/create/create_test.go +++ b/internal/pkg/create/create_test.go @@ -195,17 +195,17 @@ func Test_Create_installProjectDependencies(t *testing.T) { "Detected a project using Deno", }, }, - "When no manifest source, default to local": { + "When no manifest source, default to project (local)": { experiments: []string{"bolt"}, expectedOutputs: []string{ - "Updated config.json manifest source to local", + `Updated config.json manifest source to "project" (local)`, }, }, "When manifest source is provided, should set it": { experiments: []string{"bolt"}, manifestSource: config.ManifestSourceRemote, expectedOutputs: []string{ - "Updated config.json manifest source to remote", + `Updated config.json manifest source to "app settings" (remote)`, }, }, }