Skip to content

Commit 11ef1dc

Browse files
authored
feat(bolt-install): support using 'run' command with remote manifests (#111)
* feat(bolt-install): added --experiment=bolt-install * feat(bolt-install): run command supports manifest source app setting * feat(bolt-install): enable run with remote manifests * feat(bolt-install): apply updates to Install * feat(bolt-install): use local or remote manifest during local install * feat(bolt-install): add bolt-install check to start of local install * feat(bolt-install): revert changes to remote install * feat(bolt-install): add test coverage * feat(bolt-install): add docs * feat(bolt-install): clarify why we get the manifest from the local file or app settings
1 parent debfc8c commit 11ef1dc

6 files changed

Lines changed: 478 additions & 48 deletions

File tree

docs/reference/experiments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The following is a list of currently available experiments. We'll remove experim
88

99
* `bolt-install`: enables creating, installing, and running Bolt projects that manage their app manifest on app settings (remote manifest).
1010
* `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)).
11+
* `slack run` supports creating and installing Bolt Framework apps that have the manifest source set to "app settings (remote)" ([PR#111](https://github.com/slackapi/slack-cli/pull/111)).
1112
* `read-only-collaborators`: enables creating and modifying collaborator permissions via the `slack collaborator` commands.
1213

1314
## Experiments changelog

internal/pkg/apps/install.go

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,11 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
340340
if err != nil {
341341
return types.App{}, api.DeveloperAppInstallResult{}, "", err
342342
}
343-
if !manifestUpdates && !manifestCreates {
344-
return app, api.DeveloperAppInstallResult{}, "", nil
343+
344+
if !clients.Config.WithExperimentOn(experiment.BoltInstall) {
345+
if !manifestUpdates && !manifestCreates {
346+
return app, api.DeveloperAppInstallResult{}, "", nil
347+
}
345348
}
346349

347350
apiInterface := clients.API()
@@ -365,17 +368,42 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
365368
clients.EventTracker.SetAuthEnterpriseID(*authSession.EnterpriseID)
366369
}
367370

368-
slackYaml, err := clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor)
369-
if err != nil {
370-
return app, api.DeveloperAppInstallResult{}, "", err
371+
// When the BoltInstall experiment is enabled, we need to get the manifest from the local file
372+
// if the manifest source is local or if we are creating a new app. After an app is created,
373+
// app settings becomes the source of truth for remote manifests, so updates and installs always
374+
// get the latest manifest from app settings.
375+
// When the BoltInstall experiment is disabled, we get the manifest from the local file because
376+
// this is how the original implementation worked.
377+
var slackManifest types.SlackYaml
378+
if clients.Config.WithExperimentOn(experiment.BoltInstall) {
379+
manifestSource, err := clients.Config.ProjectConfig.GetManifestSource(ctx)
380+
if err != nil {
381+
return app, api.DeveloperAppInstallResult{}, "", err
382+
}
383+
if manifestSource.Equals(config.ManifestSourceLocal) || manifestCreates {
384+
slackManifest, err = clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor)
385+
if err != nil {
386+
return app, api.DeveloperAppInstallResult{}, "", err
387+
}
388+
} else {
389+
slackManifest, err = clients.AppClient().Manifest.GetManifestRemote(ctx, auth.Token, app.AppID)
390+
if err != nil {
391+
return app, api.DeveloperAppInstallResult{}, "", err
392+
}
393+
}
394+
} else {
395+
slackManifest, err = clients.AppClient().Manifest.GetManifestLocal(ctx, clients.SDKConfig, clients.HookExecutor)
396+
if err != nil {
397+
return app, api.DeveloperAppInstallResult{}, "", err
398+
}
371399
}
372400

373-
log.Data["appName"] = slackYaml.DisplayInformation.Name
401+
log.Data["appName"] = slackManifest.DisplayInformation.Name
374402
log.Data["isUpdate"] = app.AppID != ""
375403
log.Data["teamName"] = *authSession.TeamName
376404
log.Log("INFO", "app_install_manifest")
377405

378-
manifest := slackYaml.AppManifest
406+
manifest := slackManifest.AppManifest
379407
appendLocalToDisplayName(&manifest)
380408
if manifest.IsFunctionRuntimeSlackHosted() {
381409
configureLocalManifest(ctx, clients, &manifest)
@@ -468,6 +496,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
468496
log.Info("app_install_start")
469497
var installState types.InstallState
470498
result, installState, err := apiInterface.DeveloperAppInstall(ctx, clients.IO, token, app, botScopes, outgoingDomains, orgGrantWorkspaceID, clients.Config.AutoRequestAAAFlag)
499+
471500
if err != nil {
472501
err = slackerror.Wrap(err, slackerror.ErrAppInstall)
473502
return app, api.DeveloperAppInstallResult{}, "", err
@@ -483,7 +512,7 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
483512
}
484513

485514
//
486-
// TODO(@mbrevoort) - Currently, cannot update the icon if app is not hosted
515+
// TODO: Currently, cannot update the icon if app is not hosted.
487516
//
488517
// upload icon, default to icon.png
489518
// var iconPath = slackYaml.Icon
@@ -644,6 +673,12 @@ func shouldCreateManifest(ctx context.Context, clients *shared.ClientFactory, ap
644673
if !clients.Config.WithExperimentOn(experiment.BoltFrameworks) {
645674
return app.AppID == "", nil
646675
}
676+
677+
// When the BoltInstall experiment is enabled, apps can always be created with any manifest source.
678+
if clients.Config.WithExperimentOn(experiment.BoltInstall) {
679+
return app.AppID == "", nil
680+
}
681+
647682
manifestSource, err := clients.Config.ProjectConfig.GetManifestSource(ctx)
648683
if err != nil {
649684
return false, err

0 commit comments

Comments
 (0)