feat: fall back to manifest.json when get-manifest hook is unavailable - #629
feat: fall back to manifest.json when get-manifest hook is unavailable#629srtaalej wants to merge 12 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #629 +/- ##
==========================================
- Coverage 72.26% 72.22% -0.04%
==========================================
Files 238 238
Lines 20072 20090 +18
==========================================
+ Hits 14505 14510 +5
- Misses 4298 4305 +7
- Partials 1269 1275 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
@srtaalej Super appreciate the changes toward this 🌟
I left a comment on precedence of manifestations and am thinking that the fallback manifest.json file allows us to consider the manifest "CLI-managed" while with a hook ought mean not.
This pattern has a slow rollout with hooks needing to be updated too, but I'm most optimistic for the changes it'll unlock with confidence in changing a project manifest.
| if exists, _ := afero.Exists(c.fs, manifestPath); exists { | ||
| return c.readManifestFile(manifestPath) | ||
| } | ||
| return c.getManifestFromHook(ctx, sdkConfig, hookExecutor) |
There was a problem hiding this comment.
🔭 thought: We should reverse this order to check if a get-manifest hook exists and fallback to reading "manifest.json" file. Deprecating the hook might happen at the hook package while the CLI continues to support it.
zimeg
left a comment
There was a problem hiding this comment.
🔍 Before testing more I want to cut scope on this change. I think other PRs can follow to ensure we're not clobbering an SDK managed manifest!
| if !exists { | ||
| return WriteBackResult{ | ||
| Warning: fmt.Sprintf("No %s found in project root — merged manifest was not written locally", manifestFileName), | ||
| }, nil | ||
| fresh, err := marshalFresh(manifest) | ||
| if err != nil { | ||
| return WriteBackResult{}, fmt.Errorf("failed to serialize merged manifest: %w", err) | ||
| } | ||
| if err := atomicWriteFile(fs, manifestPath, fresh, 0644); err != nil { | ||
| return WriteBackResult{}, fmt.Errorf("failed to write %s: %w", manifestFileName, err) | ||
| } | ||
| return WriteBackResult{Written: true, FilePath: manifestPath}, nil | ||
| } |
There was a problem hiding this comment.
🦠 suggestion: Let's keep this change for a separate PR!
| return c.readManifestFile(manifestPath) | ||
| } | ||
|
|
||
| func (c *ManifestClient) readManifestFile(path string) (types.SlackYaml, error) { |
There was a problem hiding this comment.
| func (c *ManifestClient) readManifestFile(path string) (types.SlackYaml, error) { | |
| func (c *ManifestClient) getManifestFromFile(sdkConfig hooks.SDKCLIConfig) (types.SlackYaml, error) { |
🌵 thought: I think we should match the function name convention here and also keep path specific logic contained within this function. I'm less confident of the second thought FWIW!
Summary
GetManifestLocalnow falls back to readingmanifest.jsondirectly from the project root when noget-manifesthook is availablereadManifestFiletogetManifestFromFileto match thegetManifestFromHooknaming conventionCloses #627
Context
Projects without a
get-manifesthook but with a staticmanifest.jsonhad no way to read the local manifest. This addsmanifest.jsonas a fallback source when the hook isn't defined, allowing the CLI to manage the manifest directly for projects that don't use the hook.The hook remains the preferred source when available — a hook means the SDK manages the manifest, while a bare
manifest.jsonmeans it's CLI-managed.Test plan
make testpassesManual testing
Create a Bolt JS app using
slack createwith thebolt-js-starter-template:slack create my-test-app --template bolt-js-starter-template cd my-test-appTest 1: Hook path still works (existing behavior)
Should display the manifest via the
get-manifesthook.Test 2: Fallback to manifest.json when no hook is defined
Should display the manifest read from
manifest.json.