Skip to content

Conversation

@jdalton
Copy link
Contributor

@jdalton jdalton commented Dec 22, 2025

Summary

Port of commit 3eace89 to v1.x. Use EditableJson for preserving existing properties and key order when updating config values.

Details

  • Add standalone EditableJson implementation (v1.x doesn't have @socketsecurity/lib)
  • Update config.mts to use EditableJson for config file writes
  • Fix socketAppDataPath usage to include config.json filename
  • Add resetConfigForTesting() helper

Note

Introduces non-destructive config writes and corrects file handling.

  • Persist config to .../config.json (base64-encoded) and preserve formatting/key order via EditableJson
  • Read existing config, merge updates, and explicitly delete removed keys; capture state at write time to include same-tick updates
  • Fix directory creation and file path usage (socketAppDataPath/config.json); improve debug/log paths
  • Add resetConfigForTesting() and update tests (use rmSync, minor import adjustments)
  • New src/utils/editable-json.mts: standalone EditableJson implementation (format detection, non-destructive updates)

Written by Cursor Bugbot for commit 67afc9b. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment @cursor review or bugbot run to trigger another review on this PR

@jdalton
Copy link
Contributor Author

jdalton commented Dec 22, 2025

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


Comment @cursor review or bugbot run to trigger another review on this PR

Use EditableJson for preserving existing properties and key order when
updating config values. This prevents overwriting unrelated config
properties during partial updates.

- Add standalone EditableJson implementation in src/utils/editable-json.mts
- Update config.mts to use EditableJson for config file writes
- Fix socketAppDataPath usage to include config.json filename
- Add resetConfigForTesting() helper for test isolation
- Update tests to use Node.js built-in fs functions
- Preserve JSON formatting by using editor's indent/newline symbols
- Handle deleted config keys explicitly (editor.update only merges)
- Capture config snapshot at write time, not schedule time
- Fix load method create parameter to actually create empty state
- Fix symbol index type errors with type assertions
- Remove unused getDefaultFormatting function
- Add null check for match[1] in detectIndent
- Remove unused contentWithoutImport variable
- Fix import sort order in config.test.mts (promises as fs sorted by alias name)
- Add no-await-in-loop eslint-disable comments for retry loops in editable-json.mts
- Remove unused eslint-disable directive
@jdalton jdalton force-pushed the jdalton/1-json-editable branch from 841193a to ed75ea2 Compare December 22, 2025 20:03
jdalton

This comment was marked as outdated.

@jdalton jdalton merged commit c3659cf into v1.x Dec 23, 2025
7 checks passed
@jdalton jdalton deleted the jdalton/1-json-editable branch December 23, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants