@@ -16,13 +16,11 @@ package app
1616
1717import (
1818 "context"
19- "fmt"
2019
2120 "github.com/slackapi/slack-cli/internal/app"
2221 "github.com/slackapi/slack-cli/internal/cmdutil"
2322 "github.com/slackapi/slack-cli/internal/config"
2423 "github.com/slackapi/slack-cli/internal/experiment"
25- "github.com/slackapi/slack-cli/internal/logger"
2624 "github.com/slackapi/slack-cli/internal/pkg/apps"
2725 "github.com/slackapi/slack-cli/internal/prompts"
2826 "github.com/slackapi/slack-cli/internal/shared"
@@ -186,11 +184,8 @@ func RunAddCommand(ctx context.Context, clients *shared.ClientFactory, selection
186184
187185 clients .Config .ManifestEnv = app .SetManifestEnvTeamVars (clients .Config .ManifestEnv , selection .App .TeamDomain , selection .App .IsDev )
188186
189- // Set up event logger
190- log := newAddLogger (clients , selection .Auth .TeamDomain )
191-
192187 // Install dev app or prod app to a workspace
193- installedApp , installState , err := appInstall (ctx , clients , log , selection , orgGrantWorkspaceID )
188+ installedApp , installState , err := appInstall (ctx , clients , selection , orgGrantWorkspaceID )
194189 if err != nil {
195190 return ctx , installState , types.App {}, err // pass the installState because some callers may use it to handle the error
196191 }
@@ -201,74 +196,19 @@ func RunAddCommand(ctx context.Context, clients *shared.ClientFactory, selection
201196 return ctx , installState , installedApp , nil
202197}
203198
204- // newAddLogger creates a logger instance to receive event notifications
205- func newAddLogger (clients * shared.ClientFactory , envName string ) * logger.Logger {
206- return logger .New (
207- // OnEvent
208- func (event * logger.LogEvent ) {
209- teamName := event .DataToString ("teamName" )
210- appName := event .DataToString ("appName" )
211- switch event .Name {
212- case "app_install_manifest" :
213- // Ignore this event and format manifest outputs in create/update events
214- case "app_install_manifest_create" :
215- _ , _ = clients .IO .WriteOut ().Write ([]byte (style .Sectionf (style.TextSection {
216- Emoji : "books" ,
217- Text : "App Manifest" ,
218- Secondary : []string {
219- fmt .Sprintf (`Creating app manifest for "%s" in "%s"` , appName , teamName ),
220- },
221- })))
222- case "app_install_manifest_update" :
223- _ , _ = clients .IO .WriteOut ().Write ([]byte ("\n " + style .Sectionf (style.TextSection {
224- Emoji : "books" ,
225- Text : "App Manifest" ,
226- Secondary : []string {
227- fmt .Sprintf (`Updated app manifest for "%s" in "%s"` , appName , teamName ),
228- },
229- })))
230- case "app_install_start" :
231- _ , _ = clients .IO .WriteOut ().Write ([]byte ("\n " + style .Sectionf (style.TextSection {
232- Emoji : "house" ,
233- Text : "App Install" ,
234- Secondary : []string {
235- fmt .Sprintf (`Installing "%s" app to "%s"` , appName , teamName ),
236- },
237- })))
238- case "app_install_icon_success" :
239- iconPath := event .DataToString ("iconPath" )
240- _ , _ = clients .IO .WriteOut ().Write ([]byte (
241- style .SectionSecondaryf ("Updated app icon: %s" , iconPath ),
242- ))
243- case "app_install_icon_error" :
244- iconError := event .DataToString ("iconError" )
245- _ , _ = clients .IO .WriteOut ().Write ([]byte (
246- style .SectionSecondaryf ("Error updating app icon: %s" , iconError ),
247- ))
248- case "app_install_complete" :
249- _ , _ = clients .IO .WriteOut ().Write ([]byte (
250- style .SectionSecondaryf ("Finished in %s" , event .DataToString ("installTime" )),
251- ))
252- default :
253- // Ignore the event
254- }
255- },
256- )
257- }
258-
259199// printAddSuccess will print a list of the environments
260200func printAddSuccess (clients * shared.ClientFactory , cmd * cobra.Command , appInstance types.App ) error {
261201 return runListCommand (cmd , clients )
262202}
263203
264204// appInstall will install an app to a team. It supports both local and deployed app types.
265- func appInstall (ctx context.Context , clients * shared.ClientFactory , log * logger. Logger , selection * prompts.SelectedApp , orgGrantWorkspaceID string ) (types.App , types.InstallState , error ) {
205+ func appInstall (ctx context.Context , clients * shared.ClientFactory , selection * prompts.SelectedApp , orgGrantWorkspaceID string ) (types.App , types.InstallState , error ) {
266206 if selection != nil && selection .App .IsDev {
267207 // Install local dev app to a team
268- installedApp , _ , installState , err := appInstallDevAppFunc (ctx , clients , "" , log , selection .Auth , selection .App )
208+ installedApp , _ , installState , err := appInstallDevAppFunc (ctx , clients , "" , selection .Auth , selection .App )
269209 return installedApp , installState , err
270210 } else {
271- installState , installedApp , err := appInstallProdAppFunc (ctx , clients , log , selection .Auth , selection .App , orgGrantWorkspaceID )
211+ installState , installedApp , err := appInstallProdAppFunc (ctx , clients , selection .Auth , selection .App , orgGrantWorkspaceID )
272212 return installedApp , installState , err
273213 }
274214}
0 commit comments