-
Notifications
You must be signed in to change notification settings - Fork 37
feat(create): fetch remote manifest after linking app during create #585
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
base: main
Are you sure you want to change the base?
Changes from all commits
0d8bfd3
da2eb75
e57f7d5
aceb7a4
906346a
8128d5e
315c9bb
3177aa1
6d6749a
42782a3
3d642ca
f984c33
3396d78
bdbf756
1538faf
040a3c8
1092da0
aecb626
c289a09
19c2fac
2283fbc
236702a
8639a29
2939882
19cfb59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
|
|
||
| "github.com/slackapi/slack-cli/cmd/app" | ||
| "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" | ||
|
|
@@ -229,10 +230,28 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args [] | |
| defer func() { | ||
| _ = os.Chdir(originalDir) | ||
| }() | ||
|
|
||
| linkedApp := &types.App{} | ||
| if err := app.LinkExistingApp(ctx, clients, linkedApp); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if linkedApp.AppID != "" { | ||
| auth, err := clients.Auth().AuthWithTeamID(ctx, linkedApp.TeamID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| fetchErr := manifest.FetchAndWriteRemoteManifest(ctx, clients, auth.Token, linkedApp.AppID, absProjectPath) | ||
| if fetchErr != nil { | ||
| clients.IO.PrintWarning(ctx, "%s", style.Sectionf(style.TextSection{ | ||
| Text: "Could not fetch the remote app manifest", | ||
| Secondary: []string{ | ||
| fetchErr.Error(), | ||
| "The template manifest was kept unchanged", | ||
| }, | ||
| })) | ||
|
Comment on lines
+246
to
+252
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.
Contributor
Author
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. hmm I'm hesitant because the
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: I'm worried I'd miss warnings in CI and overwrite an existing app manifest for "A001" with these commands if the manifest step of "create" fails: $ slack create my-app -t slack-samples/bolt-js-blank-template -a A001 -E deployed
$ slack deployRecommending to save the outputs of |
||
| } | ||
| } | ||
| clients.IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{ | ||
| Emoji: "house", | ||
| Text: "App", | ||
|
|
||
|
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. 🧪 todo: Let's add unit tests alongside internal packages for more strict checks! |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||||||||||||||||||||||||
| // Copyright 2022-2026 Salesforce, Inc. | ||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||
| // you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||
| // You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||
| // Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| // See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| // limitations under the License. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| package manifest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||
| "bytes" | ||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| "github.com/slackapi/slack-cli/internal/shared" | ||||||||||||||||||||||||||||
| "github.com/spf13/afero" | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // FetchAndWriteRemoteManifest fetches the app manifest from remote settings and writes it to the project. | ||||||||||||||||||||||||||||
| func FetchAndWriteRemoteManifest(ctx context.Context, clients *shared.ClientFactory, token, appID, projectPath string) error { | ||||||||||||||||||||||||||||
|
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.
Suggested change
🧮 thought: This might be nice to pair with other app manifest methods although a best file structure isn't clear to me right now:
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. 📝 note: This suggestion might go well with the idea to extend |
||||||||||||||||||||||||||||
| slackYaml, err := clients.AppClient().Manifest.GetManifestRemote(ctx, token, appID) | ||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| var buf bytes.Buffer | ||||||||||||||||||||||||||||
| encoder := json.NewEncoder(&buf) | ||||||||||||||||||||||||||||
| encoder.SetEscapeHTML(false) | ||||||||||||||||||||||||||||
| encoder.SetIndent("", " ") | ||||||||||||||||||||||||||||
| if err := encoder.Encode(slackYaml.AppManifest); err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+39
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. 🔭 question: Can we reuse the stringifier in adjacent package? slack-cli/internal/goutils/json.go Lines 62 to 74 in 19cfb59
|
||||||||||||||||||||||||||||
| manifestPath := filepath.Join(projectPath, "manifest.json") | ||||||||||||||||||||||||||||
| if err := afero.WriteFile(clients.Fs, manifestPath, buf.Bytes(), 0644); err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| hash, err := clients.Config.ProjectConfig.Cache().NewManifestHash(ctx, slackYaml.AppManifest) | ||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| return clients.Config.ProjectConfig.Cache().SetManifestHash(ctx, appID, hash) | ||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+48
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. 🏆 praise: Thanks for including this! 🦔 thought: I'm now curious if this would be better as part of the |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
left a comment about this silent fail 🪂 #585 (comment) @zimeg