Skip to content

refactor: merge Install and InstallLocalApp into a single function - #626

Draft
zimeg wants to merge 9 commits into
mainfrom
merge-install-functions
Draft

refactor: merge Install and InstallLocalApp into a single function#626
zimeg wants to merge 9 commits into
mainfrom
merge-install-functions

Conversation

@zimeg

@zimeg zimeg commented Aug 8, 2026

Copy link
Copy Markdown
Member

Changelog

No user-facing change. Internal refactor merging two near-identical app-install functions. (One subtle improvement: newly created deployed apps now record their EnterpriseID/UserID in the project's apps file, matching the local path.)

Summary

This pull request merges the Install (slack deploy) and InstallLocalApp (slack run) functions in internal/pkg/apps into a single Install driven by a dev bool toggle.

  • The two functions were ~90% identical; the divergences all line up on a single "is this a local/dev install?" axis.
  • dev switches the display name ((local) suffix), hosted manifest defaults (configureLocalManifest vs configureHostedManifest), persistence (SaveLocal vs SaveDeployed), IsDev, and environment-token handling.
  • Drops the dead onlyCreateUpdateAppManifest parameter and its CreateAppManifestOnly/CreateAppManifestAndInstall constants — nothing passed CreateAppManifestOnly, so its early-return branch was unreachable.
  • Unifies 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 now also correctly propagated on the context for the deploy path (the old code discarded the returned ctx).
  • Returns the superset (App, DeveloperAppInstallResult, InstallState, error); only the dev path consumes the result (socket-mode token wiring in run.go).
  • Updates the three callers (add.go, run.go, localserver.go) and the cmd/app test func var to the merged signature.

Preview

n/a — no user-visible output changes.

Testing

  • slack run a local app and confirm it installs, appends (local) to the display name, and connects over socket mode.
  • slack deploy an app and confirm it installs to the workspace as before.
  • Create a brand-new app via slack deploy and confirm the entry in the project's apps file now includes the user and enterprise IDs.

Notes

  • Argument order is (ctx, clients, auth, app, orgGrantWorkspaceID, dev) — chosen for readability, since the two original functions disagreed on parameter order.
  • The TestInstallLocalApp test was renamed to TestInstallDevApp and now calls the merged Install with dev=true.

Requirements

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.31%. Comparing base (b2ad402) to head (3fa5a61).

Files with missing lines Patch % Lines
internal/pkg/apps/install.go 56.41% 16 Missing and 1 partial ⚠️
internal/pkg/platform/run.go 0.00% 4 Missing ⚠️
internal/pkg/apps/add.go 0.00% 1 Missing ⚠️
internal/pkg/platform/localserver.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
+ Coverage   72.24%   72.31%   +0.06%     
==========================================
  Files         238      238              
  Lines       20072    19958     -114     
==========================================
- Hits        14502    14433      -69     
+ Misses       4299     4275      -24     
+ Partials     1271     1250      -21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@zimeg
zimeg force-pushed the merge-install-functions branch from 627824d to aab16fa Compare August 8, 2026 19:43
zimeg added 8 commits August 8, 2026 12:58
Replace the trailing (orgGrantWorkspaceID string, dev bool) parameters
with an apps.InstallOptions struct so call sites read clearly instead of
passing an opaque trailing bool:

  apps.Install(ctx, clients, auth, app, apps.InstallOptions{Dev: true})

Also rename the cmd/app appInstallDevAppFunc test var to appInstallFunc
and note that appInstallProdAppFunc points at apps.Add.
apps.Add creates, installs, and adds the app to the project, not just
adds it to the project.
The return type already documents the DeveloperAppInstallResult; the note
about which caller consumes it would go stale.
The merged auth-failure early return now returns types.App{} like the
other pre-install error returns, matching the original deploy-path
Install behavior rather than the InstallLocalApp form.
Drop the redundant opts.Dev prefix. A dev run of a hosted app already has
its runtime rewritten to local by configureLocalManifest, so it is never
SlackHosted at this point; the runtime check alone is sufficient.
The merged manifestUpdates error branch carried a "failed updating app"
PrintDebug from the old InstallLocalApp, which the deploy-path Install
never had. The error is already returned to the caller, so drop the log
to keep the merge faithful to the original deploy behavior.
Collapse the two near-identical install test suites into a single
TestInstall table driven by a dev bool per case, sharing one runner. Case
names are prefixed deploy:/dev:. The runner sources one manifest for both
local and remote on dev installs, and distinguishes them on deploy.
Wire GetManifestLocal/GetManifestRemote directly to the per-case
mockManifestAppLocal/mockManifestAppRemote fields instead of branching on
tc.dev; dev cases now set both fields. Drop the redundant dev: false from
deploy cases since false is the zero value. The exported manifest is inert
in these tests (NewManifestHash is mocked), so ExportAppManifest returns an
empty result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant