diff --git a/docs/reference/experiments.md b/docs/reference/experiments.md index 8d2a97be..06f6e934 100644 --- a/docs/reference/experiments.md +++ b/docs/reference/experiments.md @@ -7,4 +7,5 @@ The Slack CLI has an experiment flag, behind which we put features under develop The following is a list of currently available experiments. We may remove an experiment once the feature is released. * `bolt-install`: enables creating, installing, and running Bolt projects that manage their app manifest on app settings (remote manifest). + * `slack create` and `slack init` now set manifest source to "app settings" (remote) for Bolt JS & Bolt Python projects ([PR#96](https://github.com/slackapi/slack-cli/pull/96)). * `read-only-collaborators`: enables creating and modifying collaborator permissions via the `slack collaborator` commands. diff --git a/internal/pkg/create/create.go b/internal/pkg/create/create.go index f334aa5c..74c029c3 100644 --- a/internal/pkg/create/create.go +++ b/internal/pkg/create/create.go @@ -457,11 +457,21 @@ func InstallProjectDependencies( } } - // Set "manifest.source" in .slack/config.json + // Default manifest source to ManifestSourceLocal if !manifestSource.Exists() { manifestSource = config.ManifestSourceLocal } + // When the BoltInstall experiment is enabled, set non-ROSI projects to ManifestSourceRemote. + if clients.Config.WithExperimentOn(experiment.BoltInstall) { + // TODO: should check if Slack hosted project, but the SDKConfig has not been initialized yet. + isDenoProject := strings.Contains(strings.ToLower(clients.Runtime.Name()), "deno") + if !isDenoProject { + manifestSource = config.ManifestSourceRemote + } + } + + // Set "manifest.source" in .slack/config.json if err := clients.Config.ProjectConfig.SetManifestSource(ctx, manifestSource); err != nil { clients.IO.PrintDebug(ctx, "Error setting manifest source in project-level config: %s", err) } else { diff --git a/internal/pkg/create/create_test.go b/internal/pkg/create/create_test.go index 97e28bc2..1daf8b69 100644 --- a/internal/pkg/create/create_test.go +++ b/internal/pkg/create/create_test.go @@ -113,6 +113,7 @@ func TestCreateGitArgs(t *testing.T) { func Test_Create_installProjectDependencies(t *testing.T) { tests := map[string]struct { experiments []string + runtime string manifestSource config.ManifestSource existingFiles map[string]string expectedOutputs []string @@ -208,6 +209,19 @@ func Test_Create_installProjectDependencies(t *testing.T) { `Updated config.json manifest source to "app settings" (remote)`, }, }, + "When bolt + bolt-install experiment and Deno project, should set manifest source to project (local)": { + experiments: []string{"bolt", "bolt-install"}, + expectedOutputs: []string{ + `Updated config.json manifest source to "project" (local)`, + }, + }, + "When bolt + bolt-install experiment and non-Deno project, should set manifest source to app settings (remote)": { + experiments: []string{"bolt", "bolt-install"}, + runtime: "node", + expectedOutputs: []string{ + `Updated config.json manifest source to "app settings" (remote)`, + }, + }, } for name, tt := range tests { t.Run(name, func(t *testing.T) { @@ -226,6 +240,7 @@ func Test_Create_installProjectDependencies(t *testing.T) { ctx := slackcontext.MockContext(t.Context()) clientsMock := shared.NewClientsMock() clientsMock.Os.On("Getwd").Return(projectDirPath, nil) + clientsMock.HookExecutor.On("Execute", mock.Anything, mock.Anything).Return(`{}`, nil) clientsMock.AddDefaultMocks() // Set experiment flag @@ -237,6 +252,9 @@ func Test_Create_installProjectDependencies(t *testing.T) { // Set runtime to be Deno (or node or whatever) clients.SDKConfig.Runtime = "deno" + if tt.runtime != "" { + clients.SDKConfig.Runtime = tt.runtime + } // Create project directory if err := clients.Fs.MkdirAll(filepath.Dir(projectDirPath), 0755); err != nil {