feat: Add modifyJSON for atomic operations in legacy utils.js#1587
Conversation
🦋 Changeset detectedLatest commit: 048d71b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughAdds an atomic JSON modification utility Changes
Sequence Diagram(s)(omitted — changes do not meet criteria for sequence diagram generation) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Crunchyman-ralph
left a comment
There was a problem hiding this comment.
some small change, please rebase and make sure the CI is passing.
Thanks for the awesome contribs!!!!
.changeset/add-modifyjson-utils.md
Outdated
| "task-master-ai": patch | ||
| --- | ||
|
|
||
| Add modifyJSON function to legacy utils.js for atomic read-modify-write operations |
There was a problem hiding this comment.
Too verbose, changelog should be client-facing
There was a problem hiding this comment.
Done - simplified to: "Add modifyJSON function for safer file updates"
There was a problem hiding this comment.
you can import the typescript modifyJson into the javascript, so do that instead :D
There was a problem hiding this comment.
Done - now imports FileOperations from @tm/core and delegates to fileOps.modifyJson()
5e5c3bb to
2832374
Compare
|
I've addressed the feedback:
The branch is rebased on latest main. Ready for re-review. |
|
I've addressed the feedback:
The branch is rebased on latest main. Ready for re-review. |
Crunchyman-ralph
left a comment
There was a problem hiding this comment.
@bjcoombs rebase onto next and then lets merge!
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Adds a new modifyJSON() function that performs atomic read-modify-write operations using a callback pattern. This prevents race conditions from stale reads that can occur with the current readJSON/writeJSON pattern. - modifyJSON reads, modifies, and writes all within a single file lock - Marks writeJSON as deprecated with guidance to use modifyJSON - Allows incremental migration of callers Partial fix for eyaltoledano#1585 (part 2: legacy utils.js pattern)
- Import TypeScript modifyJson via FileOperations instead of creating a separate JavaScript implementation - Export FileOperations from @tm/core for use in legacy codebase - Simplify changeset to be client-facing
2832374 to
048d71b
Compare
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com> fix for #1585 (part 2: legacy utils.js pattern)
Summary
modifyJSON()function for atomic read-modify-write operationswriteJSON()as deprecated with migration guidanceChanges Made
scripts/modules/utils.js:
modifyJSON(filepath, modifier, options)function that:writeJSON()as@deprecatedwith guidance to usemodifyJSON()modifyJSONfor use by callersTechnical Details
The new
modifyJSONfunction follows the same pattern as@tm/core's TypeScriptmodifyJson:Test plan
Related
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.