Skip to content

feat: add a configuration editor for JSON settings files - #3

Merged
autoantohaki merged 3 commits into
mainfrom
feat/config-editor
Oct 22, 2026
Merged

autoantohaki merged 3 commits into
mainfrom
feat/config-editor

Conversation

@autoantohaki

@autoantohaki autoantohaki commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Requested by mau

Before: a tool that wanted people to change its settings after setup had to send them to a text editor, with no validation and no protection against a half-written file.

After: editConfig('./service.json', fields) shows every setting as a row (current value, (default), not set, or (invalid) for a stored value that no longer fits), edits one at a time with the same prompts and validation as a setup flow, marks unsaved changes, and writes the file only on s. q asks before discarding changes. npm run demo -- config shows it on an in-memory sample.

Targets main. Until #4 merges, the diff also shows the wizard and prompt fix from #4; merge #4 first and this PR shows only the configuration editor.

How: fields use dotted names (server.port) read and written through getValue/setValue/unsetValue, which reject __proto__-style keys. Keys no field describes are preserved. diffValues reports {name, before, after} per changed field. saveConfig writes two-space JSON to a temp file beside the target and renames it into place, keeping the replaced file's permissions unless mode is given (e.g. 0o600 for secrets). loadConfig treats a missing or empty file as {} and refuses non-object JSON instead of overwriting it. Guide in docs/config-editor.md.

@autoantohaki
autoantohaki changed the base branch from feat/wizard to main October 22, 2026 00:12
@autoantohaki
autoantohaki merged commit 177f06b into main Oct 22, 2026
12 checks passed
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.

1 participant