Skip to content

Commit aab16fa

Browse files
committed
refactor: merge Install and InstallLocalApp into a single function
The Install (slack deploy) and InstallLocalApp (slack run) functions in internal/pkg/apps were ~90% identical. Collapse them into one Install function driven by a dev bool toggle. - dev switches display name, hosted manifest defaults, persistence (SaveLocal vs SaveDeployed), IsDev, and env-token handling. - Drop the dead onlyCreateUpdateAppManifest parameter and its CreateAppManifestOnly/CreateAppManifestAndInstall constants; nothing passed CreateAppManifestOnly, so the early-return branch was unreachable. - Unify accidental gaps: both paths now set EnterpriseID and UserID on new-app creation inside nil guards (deploy previously left these as TODOs; local dereferenced UserID unconditionally). Enterprise ID is also now correctly propagated on the context for the deploy path. - Return the superset (App, DeveloperAppInstallResult, InstallState, error); only the dev path consumes the result (socket-mode wiring). Update the three callers (add.go, run.go, localserver.go) and the cmd/app func var to the merged signature.
1 parent b2ad402 commit aab16fa

6 files changed

Lines changed: 72 additions & 245 deletions

File tree

cmd/app/add.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
// Handle to client's function used for testing
3333
var runAddCommandFunc = RunAddCommand
3434
var appInstallProdAppFunc = apps.Add
35-
var appInstallDevAppFunc = apps.InstallLocalApp
35+
var appInstallDevAppFunc = apps.Install
3636
var appSelectPromptFunc = prompts.AppSelectPrompt
3737

3838
// Flags
@@ -201,7 +201,7 @@ func printAddSuccess(clients *shared.ClientFactory, cmd *cobra.Command, appInsta
201201
func appInstall(ctx context.Context, clients *shared.ClientFactory, selection *prompts.SelectedApp, orgGrantWorkspaceID string) (types.App, types.InstallState, error) {
202202
if selection != nil && selection.App.IsDev {
203203
// Install local dev app to a team
204-
installedApp, _, installState, err := appInstallDevAppFunc(ctx, clients, "", selection.Auth, selection.App)
204+
installedApp, _, installState, err := appInstallDevAppFunc(ctx, clients, selection.Auth, selection.App, "", true)
205205
return installedApp, installState, err
206206
} else {
207207
installState, installedApp, err := appInstallProdAppFunc(ctx, clients, selection.Auth, selection.App, orgGrantWorkspaceID)

internal/pkg/apps/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func addAppRemotely(ctx context.Context, clients *shared.ClientFactory, auth typ
7070
app.TeamID = auth.TeamID
7171
}
7272

73-
app, installState, err := Install(ctx, clients, auth, CreateAppManifestAndInstall, app, orgGrantWorkspaceID)
73+
app, _, installState, err := Install(ctx, clients, auth, app, orgGrantWorkspaceID, false)
7474
if err != nil {
7575
return installState, types.App{}, slackerror.Wrap(err, slackerror.ErrAppAdd)
7676
}

0 commit comments

Comments
 (0)