Repository navigation
feat(cmd): auto-sync manifest from remote when creating with --app #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srtaalej
wants to merge
17
commits into
main
Choose a base branch
from
ale-consolidate-create-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+386
−4
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a9c0963
feat: auto-sync manifest from remote when creating with --app
srtaalej 7b981e9
fix: reinitialize SDK config before manifest sync in create
srtaalej 90d2c6d
feat: add quiet mode to manifest sync for create flow
srtaalej 5d4217d
fix: show warning with remediation when manifest sync fails during cr…
srtaalej 944e498
refactor: inline remote manifest fetch in create instead of calling Sync
srtaalej 6ee329d
test: add coverage for manifest fetch failure during create with --app
srtaalej 573a108
refactor: consolidate create link test helpers into parameterized setup
srtaalej d7c7816
refactor: simplify setupCreateLinkMocks to use explicit error param
srtaalej 1dd8ed6
refactor: scope changes to create command only, use AuthWithTeamID fo…
srtaalej e3eeae4
Merge branch 'main' into ale-consolidate-create-sync
mwbrooks a607b52
fix: address review feedback for create --app manifest sync
srtaalej ae612be
fix: hash exported manifest and avoid mutating it when stripping loca…
srtaalej 629f7eb
fix: show create --app manifest result in an App Manifest section
srtaalej 0b5068a
Merge branch 'main' into ale-consolidate-create-sync
srtaalej 691efd0
test: cover remote-source skip, deployed apps, remedy output and app …
srtaalej 72a9fe9
Merge branch 'main' into ale-consolidate-create-sync
srtaalej 6c82c8c
Merge branch 'main' into ale-consolidate-create-sync
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,9 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/slackapi/slack-cli/cmd/app" | ||
| "github.com/slackapi/slack-cli/internal/config" | ||
| "github.com/slackapi/slack-cli/internal/iostreams" | ||
| "github.com/slackapi/slack-cli/internal/manifest" | ||
| "github.com/slackapi/slack-cli/internal/pkg/create" | ||
| "github.com/slackapi/slack-cli/internal/shared" | ||
| "github.com/slackapi/slack-cli/internal/shared/types" | ||
|
|
@@ -238,12 +240,61 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args [] | |
| Text: "App", | ||
| Secondary: app.FormatListSuccess([]types.App{*linkedApp}), | ||
| })) | ||
|
|
||
| // Fetch remote manifest and write it to the local project. | ||
| // Skip for remote-source projects where manifest.json is not used. | ||
| manifestSource, _ := clients.Config.ProjectConfig.GetManifestSource(ctx) | ||
| if !manifestSource.Equals(config.ManifestSourceRemote) { | ||
| syncRemedy := " Run %s to sync manually" | ||
| syncRemedyCmd := style.Commandf("manifest sync --manifest-source=remote", false) | ||
| if auth, err := clients.Auth().AuthWithTeamID(ctx, linkedApp.TeamID); err != nil { | ||
| clients.IO.PrintWarning(ctx, "Failed to resolve auth for manifest sync: %s", err) | ||
| clients.IO.PrintInfo(ctx, false, syncRemedy, syncRemedyCmd) | ||
| } else if remoteManifest, err := clients.AppClient().Manifest.GetManifestRemote(ctx, auth.Token, linkedApp.AppID); err != nil { | ||
| clients.IO.PrintWarning(ctx, "Failed to fetch manifest from app settings: %s", err) | ||
| clients.IO.PrintInfo(ctx, false, syncRemedy, syncRemedyCmd) | ||
| } else { | ||
| appManifest := remoteManifest.AppManifest | ||
| if linkedApp.IsDev { | ||
| appManifest = manifest.StripDevLocalSuffix(appManifest) | ||
| } | ||
| writeResult, err := manifest.WriteManifestLocal(clients.Fs, absProjectPath, appManifest) | ||
| if err != nil { | ||
| clients.IO.PrintWarning(ctx, "Failed to write manifest to project: %s", err) | ||
| clients.IO.PrintInfo(ctx, false, syncRemedy, syncRemedyCmd) | ||
| } else if writeResult.Written { | ||
| lines := []string{fmt.Sprintf("%s Updated manifest.json from app settings", style.Green("✓"))} | ||
| if writeResult.Warning != "" { | ||
| lines = append(lines, fmt.Sprintf("%s %s", style.Yellow("!"), writeResult.Warning)) | ||
| } | ||
| printCreateManifestSection(ctx, clients, lines...) | ||
| // Hash the remote manifest as exported, since install compares against the export. | ||
| hash, err := clients.Config.ProjectConfig.Cache().NewManifestHash(ctx, remoteManifest.AppManifest) | ||
| if err == nil { | ||
| _ = clients.Config.ProjectConfig.Cache().SetManifestHash(ctx, linkedApp.AppID, hash) | ||
| } | ||
|
Comment on lines
+271
to
+275
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👁️🗨️ thought: A debug log for these errors might make later troubleshooting more simple? |
||
| } else { | ||
| printCreateManifestSection(ctx, clients, | ||
| "Skipped copying app settings to the project: no manifest.json found in the project root", | ||
| "Your project manifest is managed elsewhere (e.g. manifest.ts), so no changes were made", | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| printCreateSuccess(ctx, clients, appDirPath) | ||
| return nil | ||
| } | ||
|
|
||
| func printCreateManifestSection(ctx context.Context, clients *shared.ClientFactory, lines ...string) { | ||
| clients.IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{ | ||
| Emoji: "books", | ||
| Text: "App Manifest", | ||
| Secondary: lines, | ||
| })) | ||
| } | ||
|
|
||
| // printCreateSuccess outputs an informative message after creating a new app | ||
| func printCreateSuccess(ctx context.Context, clients *shared.ClientFactory, appPath string) { | ||
| // Check if this is a Deno project to conditionally enable some features | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔬 question: Can we reverse this for more confidence in this case? IIRC we want to update local manifest sources in particular as part of the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦠 note: I'm cautious that no source might be possible but testing seems to set the default configurations before we get to this point.