Skip to content

v0.3.3

Choose a tag to compare

@oscarhugopaz oscarhugopaz released this 05 Jun 00:45
· 23 commits to main since this release

Patch release. Fixes three latent bugs that only surface against
a real MainWP Dashboard that returns typical-sized JSON. All three
were uncovered by pointing the CLI at a production dashboard for
the first time.

  1. Connectivity check was always failing (lib/commands/init.sh)
    mainwp_api_get /sites/basic per_page=1 passed per_page=1 as
    the request body, not as a query parameter, so curl ended up
    doing GET /sites/basic with body='per_page=1'. MainWP rejected
    it with HTTP 400 and the init wizard reported
    "Connectivity check failed" even with a perfectly valid URL and
    key. Fix: pass an empty body and per_page=1 as an extra arg.
    mainwp_api_get /sites/basic "" "per_page=1"

  2. sites count always showed 0 (lib/commands/sites.sh)
    The MainWP /sites/count endpoint returns {"count":N} rather
    than the {total} / {data:{total}} shapes the CLI was
    looking for. The jq path fell through to the 0 fallback. Add
    .count (and .data.count) to the lookup chain.

  3. SIGPIPE killed the script on any list endpoint (lib/output.sh)
    mainwp_render_table used a pipe to read the first byte of the
    payload:
    first="$(printf '%s' "$input" | head -c 1)"
    With multi-KB JSON, head exits after one byte and printf gets
    SIGPIPE on the next write. With set -o pipefail that aborted
    the whole script with exit 141 and no output. Switch to
    parameter expansion: ${input:0:1}. No pipe, no signal, no race.

After the fixes the full flow works against a real dashboard:
```
$ mainwp init
✓ Profile 'default' saved.
✓ Connected to https://main.carnaval.studio
==> Dashboard reports 3 site(s) (showing first page only).

$ mainwp sites count
==> Connected sites: 3

$ mainwp --plain sites list
ID,Name,URL,Status
45 cusconatureadventure.com https://cusconatureadventure.com/ connected
44 dynamicdutch.com/ https://dynamicdutch.com/ connected
41 jazmingonzalez.pe https://jazmingonzalez.pe/ connected
```

61 smoke tests, all passing. Upgrade with
`brew update && brew upgrade mainwp`.