From c8ec21a79aaa7159026c40a964470d16753a1988 Mon Sep 17 00:00:00 2001 From: Montoya Edu Date: Mon, 18 May 2026 15:46:15 +0200 Subject: [PATCH] fix: easy --version and proxy help work without runtime env vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `easy` validated EASY_LETSENCRYPT_DIR and EASY_DOMAINS_DIR at top level, unconditionally — so even `easy --version` and `easy proxy help` failed with `... is not set!` until those env vars were exported. The first command anyone runs after `npm install -g` is `easy --version`, so this was a poor first impression. Found by the pre-publish clean-room test. Skip the dir validation for the two informational invocations (`--version`, `proxy help`); every operational command still validates. - easy: guard the easy_verify_dir calls with a case on "$1:$2" - test/dispatcher.bats: `easy --version` works with the env vars unset - test/proxy.bats: `easy proxy help` works with the env vars unset - CHANGELOG.md: note the fix `npm run lint` exits 0; the bats suite passes 22/22. Co-Authored-By: Claude Opus 4.7 --- CHANGELOG.md | 3 +++ easy | 12 ++++++++++-- test/dispatcher.bats | 7 +++++++ test/proxy.bats | 7 +++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bde69f..a657d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ A major release: automatic Let's Encrypt SSL with multi-DNS-provider support. - `easy proxy create` no longer writes a state file into the install directory. After `npm install -g` that directory is root-owned, so non-root users got `Permission denied` ([#5]). +- `easy --version` and `easy proxy help` now work before the runtime env vars + (`EASY_LETSENCRYPT_DIR`, `EASY_DOMAINS_DIR`) are set — they no longer fail + with `... is not set!`, so a freshly installed CLI can be inspected. - Argument quoting hardened across the `easy` dispatcher and `commands/proxy.sh` (ShellCheck cleanup). diff --git a/easy b/easy index 1a3a5c4..ed49a45 100755 --- a/easy +++ b/easy @@ -34,8 +34,16 @@ function easy_verify_dir { fi } -easy_verify_dir EASY_LETSENCRYPT_DIR "$EASY_LETSENCRYPT_DIR" -easy_verify_dir EASY_DOMAINS_DIR "$EASY_DOMAINS_DIR" +# `easy --version` and `easy proxy help` are informational — they need +# neither EASY_LETSENCRYPT_DIR nor EASY_DOMAINS_DIR. Skip the check for them +# so a freshly installed CLI can be inspected before those env vars are set. +case "$1:$2" in + --version:* | proxy:help) : ;; + *) + easy_verify_dir EASY_LETSENCRYPT_DIR "$EASY_LETSENCRYPT_DIR" + easy_verify_dir EASY_DOMAINS_DIR "$EASY_DOMAINS_DIR" + ;; +esac D="${EASY_DIR}/commands" function __private_easy_usage { diff --git a/test/dispatcher.bats b/test/dispatcher.bats index d583494..607c38d 100644 --- a/test/dispatcher.bats +++ b/test/dispatcher.bats @@ -11,6 +11,13 @@ setup() { easy_setup; } [ "$output" = "2.0.0" ] } +@test "easy --version works without the runtime env vars set" { + unset EASY_LETSENCRYPT_DIR EASY_DOMAINS_DIR + run easy --version + [ "$status" -eq 0 ] + [ "$output" = "2.0.0" ] +} + @test "easy with no command prints usage and fails" { run easy [ "$status" -eq 1 ] diff --git a/test/proxy.bats b/test/proxy.bats index 6c5ea85..9f05ffc 100644 --- a/test/proxy.bats +++ b/test/proxy.bats @@ -18,6 +18,13 @@ setup() { easy_setup; } [[ "$output" == *"easy proxy certbot-ionos "* ]] } +@test "easy proxy help works without the runtime env vars set" { + unset EASY_LETSENCRYPT_DIR EASY_DOMAINS_DIR + run easy proxy help + [ "$status" -eq 0 ] + [[ "$output" == *"easy proxy create"* ]] +} + @test "easy proxy with an unknown subcommand prints usage and fails" { run easy proxy not-a-real-subcommand [ "$status" -eq 1 ]