Minify JSON on read and pretty-print on write in init local ops#396
Merged
MathurAditya724 merged 3 commits intomainfrom Mar 11, 2026
Merged
Minify JSON on read and pretty-print on write in init local ops#396MathurAditya724 merged 3 commits intomainfrom
MathurAditya724 merged 3 commits intomainfrom
Conversation
Parse and re-serialize .json file contents via JSON.stringify to strip unnecessary whitespace and formatting before sending to the remote wizard workflow. Falls back to raw content if parsing fails (truncated files, JSONC, etc.).
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Other
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 900 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.50% 95.50% —%
==========================================
Files 142 142 —
Lines 19999 20021 +22
Branches 0 0 —
==========================================
+ Hits 19100 19121 +21
- Misses 899 900 +1
- Partials 0 0 —Generated by Codecov Action |
Since read-files minifies JSON before sending to the remote workflow, the patchset content comes back without formatting. This restores readable indentation when writing JSON files back to disk. For modify actions, the existing file's indentation style (tabs vs spaces, indent width) is detected and preserved. For create actions, a default of 2-space indentation is used. Falls back to raw content if JSON parsing fails.
Instead of passing path, patch content, and action as separate args, pass the whole patch object and let the function destructure what it needs.
betegon
approved these changes
Mar 11, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
.jsonfile contents viaJSON.stringify()to strip unnecessary whitespace before sending to the remote wizard workflow. Falls back to raw content if parsing fails (truncated files, JSONC, etc.)..jsonfiles when writing back to disk, restoring readable indentation that was lost during minification. Formodifyactions, the existing file's indentation style (tabs vs spaces, indent width) is detected and preserved. Forcreateactions, a default of 2-space indentation is used.Implementation details
Indenterconstant withSPACEandTABwhitespace charactersJsonIndenttype withreplacerandlengthfields for structured indent descriptiondetectJsonIndent()inspects the first indented line of existing file content to determine the indent styleprettyPrintJson()re-serializes JSON with the detected (or default) indentation, with safe fallback if parsing failsresolvePatchContent()extracted fromapplyPatchsetto keep complexity under the lint threshold