Skip to content

Commit 3db7b97

Browse files
zimegmwbrooks
andauthored
chore: default to bolt experiment behavior for the 'project' subcommands (#141)
Co-authored-by: Michael Brooks <[email protected]>
1 parent 2484046 commit 3db7b97

File tree

8 files changed

+173
-324
lines changed

8 files changed

+173
-324
lines changed

cmd/project/create.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"path/filepath"
2121
"strings"
2222

23-
"github.com/slackapi/slack-cli/internal/experiment"
2423
"github.com/slackapi/slack-cli/internal/logger"
2524
"github.com/slackapi/slack-cli/internal/pkg/create"
2625
"github.com/slackapi/slack-cli/internal/shared"
@@ -193,9 +192,8 @@ func printCreateSuccess(ctx context.Context, clients *shared.ClientFactory, appP
193192
isDenoProject = strings.Contains(strings.ToLower(clients.Runtime.Name()), "deno")
194193
}
195194

196-
// Display the original next steps section when the Bolt Experiment is OFF
197-
// or when the Bolt Experiment is ON and a Deno SDK project is created
198-
if !clients.Config.WithExperimentOn(experiment.BoltFrameworks) || isDenoProject {
195+
// Include documentation and information about ROSI for deno apps
196+
if isDenoProject {
199197
clients.IO.PrintInfo(ctx, false, style.Sectionf(style.TextSection{
200198
Emoji: "compass",
201199
Text: "Explore the documentation to learn more",

cmd/project/create_template.go

Lines changed: 54 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"time"
2121

2222
"github.com/slackapi/slack-cli/internal/api"
23-
"github.com/slackapi/slack-cli/internal/experiment"
2423
"github.com/slackapi/slack-cli/internal/iostreams"
2524
"github.com/slackapi/slack-cli/internal/pkg/create"
2625
"github.com/slackapi/slack-cli/internal/shared"
@@ -30,88 +29,50 @@ import (
3029
"github.com/spf13/cobra"
3130
)
3231

33-
func getSelectionPrompt(clients *shared.ClientFactory) string {
34-
switch clients.Config.WithExperimentOn(experiment.BoltFrameworks) {
35-
case true:
36-
return "Select a language:"
37-
default:
38-
return "Select a template to build from:"
39-
}
40-
}
41-
42-
func getSelectionPromptForCategory(clients *shared.ClientFactory) string {
43-
return "Select an app:"
44-
}
45-
4632
func getSelectionOptions(clients *shared.ClientFactory, categoryID string) []promptObject {
4733
if strings.TrimSpace(categoryID) == "" {
4834
categoryID = "slack-cli#getting-started"
4935
}
5036

51-
switch clients.Config.WithExperimentOn(experiment.BoltFrameworks) {
52-
case true:
53-
// App categories and templates
54-
templatePromptObjects := map[string]([]promptObject){
55-
"slack-cli#getting-started": []promptObject{
56-
{
57-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
58-
Repository: "slack-samples/bolt-js-starter-template",
59-
},
60-
{
61-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
62-
Repository: "slack-samples/bolt-python-starter-template",
63-
},
37+
// App categories and templates
38+
templatePromptObjects := map[string]([]promptObject){
39+
"slack-cli#getting-started": []promptObject{
40+
{
41+
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
42+
Repository: "slack-samples/bolt-js-starter-template",
6443
},
65-
"slack-cli#automation-apps": {
66-
{
67-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
68-
Repository: "slack-samples/bolt-js-custom-function-template",
69-
},
70-
{
71-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
72-
Repository: "slack-samples/bolt-python-custom-function-template",
73-
},
74-
{
75-
Title: fmt.Sprintf("Deno Slack SDK %s", style.Secondary("Deno")),
76-
Repository: "slack-samples/deno-starter-template",
77-
},
44+
{
45+
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
46+
Repository: "slack-samples/bolt-python-starter-template",
7847
},
79-
"slack-cli#ai-apps": {
80-
{
81-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
82-
Repository: "slack-samples/bolt-js-assistant-template",
83-
},
84-
{
85-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
86-
Repository: "slack-samples/bolt-python-assistant-template",
87-
},
48+
},
49+
"slack-cli#automation-apps": {
50+
{
51+
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
52+
Repository: "slack-samples/bolt-js-custom-function-template",
8853
},
89-
}
90-
91-
return templatePromptObjects[categoryID]
92-
default:
93-
return []promptObject{
9454
{
95-
Title: "Issue submission (default sample)",
96-
Repository: "slack-samples/deno-issue-submission",
97-
Description: "Basic app that demonstrates an issue submission workflow",
55+
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
56+
Repository: "slack-samples/bolt-python-custom-function-template",
9857
},
9958
{
100-
Title: "Scaffolded template",
101-
Repository: "slack-samples/deno-starter-template",
102-
Description: "Solid foundation that includes a Slack datastore",
59+
Title: fmt.Sprintf("Deno Slack SDK %s", style.Secondary("Deno")),
60+
Repository: "slack-samples/deno-starter-template",
10361
},
62+
},
63+
"slack-cli#ai-apps": {
10464
{
105-
Title: "Blank template",
106-
Repository: "slack-samples/deno-blank-template",
107-
Description: "A, well.. blank project",
65+
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
66+
Repository: "slack-samples/bolt-js-assistant-template",
10867
},
10968
{
110-
Title: "View more samples",
111-
Repository: viewMoreSamples,
69+
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
70+
Repository: "slack-samples/bolt-python-assistant-template",
11271
},
113-
}
72+
},
11473
}
74+
75+
return templatePromptObjects[categoryID]
11576
}
11677

11778
func getSelectionOptionsForCategory(clients *shared.ClientFactory) []promptObject {
@@ -142,34 +103,32 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory)
142103
var selectedTemplate string
143104

144105
// Prompt for the category
145-
if clients.Config.WithExperimentOn(experiment.BoltFrameworks) {
146-
promptForCategory := getSelectionPromptForCategory(clients)
147-
optionsForCategory := getSelectionOptionsForCategory(clients)
148-
titlesForCategory := make([]string, len(optionsForCategory))
149-
for i, m := range optionsForCategory {
150-
titlesForCategory[i] = m.Title
151-
}
152-
templateForCategory := getSelectionTemplate(clients)
106+
promptForCategory := "Select an app:"
107+
optionsForCategory := getSelectionOptionsForCategory(clients)
108+
titlesForCategory := make([]string, len(optionsForCategory))
109+
for i, m := range optionsForCategory {
110+
titlesForCategory[i] = m.Title
111+
}
112+
templateForCategory := getSelectionTemplate(clients)
153113

154-
// Print a trace with info about the category title options provided by CLI
155-
clients.IO.PrintTrace(ctx, slacktrace.CreateCategoryOptions, strings.Join(titlesForCategory, ", "))
114+
// Print a trace with info about the category title options provided by CLI
115+
clients.IO.PrintTrace(ctx, slacktrace.CreateCategoryOptions, strings.Join(titlesForCategory, ", "))
156116

157-
// Prompt to choose a category
158-
selection, err := clients.IO.SelectPrompt(ctx, promptForCategory, titlesForCategory, iostreams.SelectPromptConfig{
159-
Description: func(value string, index int) string {
160-
return optionsForCategory[index].Description
161-
},
162-
Flag: clients.Config.Flags.Lookup("template"),
163-
Required: true,
164-
Template: templateForCategory,
165-
})
166-
if err != nil {
167-
return create.Template{}, slackerror.ToSlackError(err)
168-
} else if selection.Flag {
169-
selectedTemplate = selection.Option
170-
} else if selection.Prompt {
171-
categoryID = optionsForCategory[selection.Index].Repository
172-
}
117+
// Prompt to choose a category
118+
selection, err := clients.IO.SelectPrompt(ctx, promptForCategory, titlesForCategory, iostreams.SelectPromptConfig{
119+
Description: func(value string, index int) string {
120+
return optionsForCategory[index].Description
121+
},
122+
Flag: clients.Config.Flags.Lookup("template"),
123+
Required: true,
124+
Template: templateForCategory,
125+
})
126+
if err != nil {
127+
return create.Template{}, slackerror.ToSlackError(err)
128+
} else if selection.Flag {
129+
selectedTemplate = selection.Option
130+
} else if selection.Prompt {
131+
categoryID = optionsForCategory[selection.Index].Repository
173132
}
174133

175134
// Set template to view more samples, so the sample prompt is triggered
@@ -179,7 +138,7 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory)
179138

180139
// Prompt for the template
181140
if selectedTemplate == "" {
182-
prompt := getSelectionPrompt(clients)
141+
prompt := "Select a language:"
183142
options := getSelectionOptions(clients, categoryID)
184143
titles := make([]string, len(options))
185144
for i, m := range options {
@@ -276,9 +235,7 @@ func confirmExternalTemplateSelection(cmd *cobra.Command, clients *shared.Client
276235
// project template during creation
277236
func getSelectionTemplate(clients *shared.ClientFactory) string {
278237
samplesURL := style.LinkText("https://docs.slack.dev/samples")
279-
switch clients.Config.WithExperimentOn(experiment.BoltFrameworks) {
280-
case true:
281-
return fmt.Sprintf(`
238+
return fmt.Sprintf(`
282239
{{- define "option"}}
283240
{{- if eq .SelectedIndex .CurrentIndex }}{{color .Config.Icons.SelectFocus.Format }}{{ .Config.Icons.SelectFocus.Text }} {{else}}{{color "default+hb"}} {{end}}
284241
{{- .CurrentOpt.Value}}{{color "reset"}}{{ if ne ($.GetDescription .CurrentOpt) "" }}{{"\n "}}{{color "250"}}{{ $.GetDescription .CurrentOpt }}{{"\n"}}{{end}}
@@ -297,27 +254,5 @@ func getSelectionTemplate(clients *shared.ClientFactory) string {
297254
{{- "Guided tutorials can be found at %s"}}{{color "reset"}}
298255
{{end}}
299256
`,
300-
samplesURL)
301-
default:
302-
return fmt.Sprintf(`
303-
{{- define "option"}}
304-
{{- if eq .SelectedIndex .CurrentIndex }}{{color .Config.Icons.SelectFocus.Format }}{{ .Config.Icons.SelectFocus.Text }} {{else}}{{color "default+hb"}} {{end}}
305-
{{- .CurrentOpt.Value}}{{color "reset"}}{{ if ne ($.GetDescription .CurrentOpt) "" }}{{"\n "}}{{color "250"}}{{ $.GetDescription .CurrentOpt }}{{"\n"}}{{end}}
306-
{{- color "reset"}}
307-
{{end}}
308-
{{- if .ShowHelp }}{{- color .Config.Icons.Help.Format }}{{ .Config.Icons.Help.Text }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}}
309-
{{- color .Config.Icons.Question.Format }}{{ .Config.Icons.Question.Text }} {{color "reset"}}
310-
{{- color "default+hb"}}{{ .Message }}{{color "reset"}}
311-
{{- if .ShowAnswer}}{{color "39+b"}} {{.Answer}}{{color "reset"}}
312-
{{- else}}
313-
{{- " "}}{{- color "39+b"}}[Use arrows to move]{{color "reset"}}
314-
{{- "\n\n"}}
315-
{{- range $ix, $option := .PageEntries}}
316-
{{- template "option" $.IterateOption $ix $option}}
317-
{{- end}}
318-
{{"Guided tutorials can be found at %s"}}{{color "reset"}}
319-
{{end}}
320-
`,
321-
samplesURL)
322-
}
257+
samplesURL)
323258
}

0 commit comments

Comments
 (0)