fix: full JSON output for analyze/status/list/check - #7
Merged
Merged
Conversation
This was referenced Sep 13, 2026
The --json branches were placeholders:
- list --json never called detect_nginx_instances, so .instances was
always []
- analyze --json never ran registry detection, so features had no
detected key and applied was read straight from state
- check --json ignored the backup dir, the feature registry and issue
counting; ready meant only "nginx -t passed"
Now, all four build their payloads with jq (-n/--arg/--argjson) so
display names and paths cannot break the document:
- list --json: .instances is the same {type,name,path} set the human
list shows (detection runs silenced to keep stdout pure JSON)
- analyze --json: .features.<id> = {display, applied, detected};
detected runs the registry (custom detector on the primary file,
declared pattern/template bulk-grepped across every relevant file);
.instances is included so callers don't need a second call; an
unknown site returns a JSON error instead of a text line + exit
- check --json: mirrors the human checks — prerequisites, nginx -t
(system or wp-test-proxy), registry loaded, backup dir writable —
with an .issues array; .ready is true iff .issues is empty, and the
exit code matches the human command
- status --json: same payload as before, built with jq and hardened
against a missing/corrupt state file
Helpers live next to json_output: _json_instances, _json_feature_list,
_json_detect_files (http-context files are global; server-context files
scope to the target site), _json_primary_file, _json_feature_detected,
_json_feature_applied.
New "JSON Output Tests" section asserts stdout of list/analyze/status/ check --json and --json --version parses with jq and carries the real schema: instances/features arrays for list, display+applied+detected booleans per feature for analyze, issues/ready/backup_writable/ nginx_valid for check (with ready == issues-empty consistency), and .applied array for status. The list instance-count assertion compares against the human `list` count on the same machine and skips with a reason when detection truly finds zero (e.g. CI without nginx). These assertions fail on the placeholder implementation.
--json for analyze/status/list/check now emits real detection data instead of placeholders; the --help line lists the commands it covers.
MarcinDudekDev
force-pushed
the
feat/json-output
branch
from
September 13, 2026 18:47
046b7f7 to
4b32696
Compare
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.
Fixes #6
--jsonforanalyze,status,list, andchecknow emits real data instead of placeholders.list --jsonrunsdetect_nginx_instances;.instancesis{type,name,path}[](36 on this machine, was always[]).analyze --jsonruns detection. Each feature is{display, applied, detected}—appliedfrom state,detectedfrom the registry. The two are allowed to differ.check --jsonmirrors the human checks: prerequisites,nginx -t, registry, backup dir,.issues[],.readyiff issues empty.jq -n/--argso display names cannot break JSON.--helpdocuments the four commands.Tests: new JSON section in
tests/run-tests.sh(assertions fail on main). 123/123. shellcheck --severity=warning clean.