Skip to content

fix: honor --json and --api-url after subcommands, and report the real version - #10

Merged
kotapeter merged 1 commit into
mainfrom
fix/global-options-version
Oct 18, 2026
Merged

kotapeter merged 1 commit into
mainfrom
fix/global-options-version

Conversation

@kotapeter

Copy link
Copy Markdown
Member

Summary

Fixes three bugs in 1.10.1:

  • --json had no effect in a terminal. sevalla apps list --json printed the spinner and a table when stdout was a TTY. Piped output was JSON either way.
  • --api-url was ignored by every command except login. Requests went to SEVALLA_API_URL, or the default URL, whether the flag came before or after the subcommand.
  • sevalla --version printed 0.0.0-dev for npm installs.

Cause and fix

--json and --api-url are defined on the root program. Commander parses root options anywhere in argv, so the root consumed them and the subcommand's own options never received the values. A preAction hook on the root now passes both to the command that runs. This covers every command, generated or hand-written, without changing each one.

__CLI_VERSION__ was only defined for the standalone binaries (bun build --define). The npm build never defined it and fell back to 0.0.0-dev.

  • tsup.config.ts now defines it from package.json.
  • The release job built the package before semantic-release bumped the version, so that build would have embedded the previous version. The build now runs on prepack: npm publish triggers it after the bump. The standalone pre-release build step is removed.

Tests

  • Unit (tests/unit/program.test.ts): --json and --api-url given before and after the subcommand reach the action; json stays off by default.
  • E2E (tests/e2e/tests/common.test.ts):
    • sevalla --version matches the package.json version.
    • apps list --json prints JSON when stdout is a terminal.
    • --api-url, in either position, routes requests to the given URL even when SEVALLA_API_URL points elsewhere.
  • The new e2e tests fail on the previous code and pass with this change.

…l version

The root program parses --json and --api-url wherever they appear, so the
subcommand never saw them: --json was ignored in a terminal and --api-url was
ignored by every command except login. A preAction hook now passes both to
the command that runs.

The npm build never defined __CLI_VERSION__, so `sevalla --version` printed
0.0.0-dev. tsup now defines it from package.json, and the release builds on
prepack so the published bundle carries the bumped version.
@kotapeter
kotapeter merged commit 7c54c89 into main Oct 18, 2026
3 checks passed
@kotapeter
kotapeter deleted the fix/global-options-version branch October 18, 2026 14:42
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.

2 participants