From fb048cac19ecd400773931053556d1514da45d09 Mon Sep 17 00:00:00 2001 From: Taras Pashkevych Date: Tue, 31 Mar 2026 20:11:37 +0200 Subject: [PATCH] fix(cli): Readme, changelog and pipeline nits --- .github/workflows/release.yml | 27 ++++++++++++------ CHANGELOG.md | 1 - README.md | 52 +++++++++++++++++++++++++++++++---- install.sh | 11 ++++---- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc26ea0..4656fc1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,6 +58,7 @@ jobs: update-tap: needs: upload runs-on: ubuntu-latest + if: ${{ secrets.HOMEBREW_TAP_TOKEN != '' }} steps: - name: Update Homebrew tap env: @@ -70,25 +71,25 @@ jobs: SHA_X86_64=$(curl -sL "$BASE_URL/dualentry-macos-x86_64" | shasum -a 256 | cut -d' ' -f1) SHA_LINUX=$(curl -sL "$BASE_URL/dualentry-linux-x86_64" | shasum -a 256 | cut -d' ' -f1) - cat > /tmp/dualentry.rb << FORMULA + cat > /tmp/dualentry.rb <<'FORMULA' class Dualentry < Formula desc "DualEntry accounting CLI" - homepage "https://github.com/${{ github.repository }}" - version "$VERSION" + homepage "https://github.com/dualentry/dualentry-cli" + version "VERSION_PLACEHOLDER" on_macos do if Hardware::CPU.arm? - url "$BASE_URL/dualentry-macos-arm64" - sha256 "$SHA_ARM64" + url "URL_PLACEHOLDER/dualentry-macos-arm64" + sha256 "SHA_ARM64_PLACEHOLDER" else - url "$BASE_URL/dualentry-macos-x86_64" - sha256 "$SHA_X86_64" + url "URL_PLACEHOLDER/dualentry-macos-x86_64" + sha256 "SHA_X86_64_PLACEHOLDER" end end on_linux do - url "$BASE_URL/dualentry-linux-x86_64" - sha256 "$SHA_LINUX" + url "URL_PLACEHOLDER/dualentry-linux-x86_64" + sha256 "SHA_LINUX_PLACEHOLDER" end def install @@ -102,6 +103,14 @@ jobs: end FORMULA + # Substitute placeholders and strip leading whitespace + sed -i "s|VERSION_PLACEHOLDER|$VERSION|g" /tmp/dualentry.rb + sed -i "s|URL_PLACEHOLDER|$BASE_URL|g" /tmp/dualentry.rb + sed -i "s|SHA_ARM64_PLACEHOLDER|$SHA_ARM64|g" /tmp/dualentry.rb + sed -i "s|SHA_X86_64_PLACEHOLDER|$SHA_X86_64|g" /tmp/dualentry.rb + sed -i "s|SHA_LINUX_PLACEHOLDER|$SHA_LINUX|g" /tmp/dualentry.rb + sed -i 's/^ //' /tmp/dualentry.rb + git clone "https://x-access-token:${TAP_TOKEN}@github.com/dualentry/homebrew-tap.git" /tmp/tap mkdir -p /tmp/tap/Formula cp /tmp/dualentry.rb /tmp/tap/Formula/dualentry.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 2657924..19111a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,3 @@ - Table and JSON output formats - Pagination, search, and date/status filtering - Homebrew tap and install script distribution -- Auto-update checker diff --git a/README.md b/README.md index d0fe576..759a617 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,22 @@ The DualEntry CLI brings the full power of the DualEntry API to your terminal. C ### Install +```bash +brew install dualentry/tap/dualentry +``` + +Or with uv: + ```bash uv tool install git+https://github.com/dualentry/dualentry-cli.git ``` +Or via the install script: + +```bash +curl -fsSL https://raw.githubusercontent.com/dualentry/dualentry-cli/main/install.sh | sh +``` + ### Authenticate ```bash @@ -84,14 +96,16 @@ dualentry invoices list --all ## Configuration ```bash -# View current settings dualentry config show - -# Switch environments -dualentry config set-env dev # Development -dualentry config set-env prod # Production ``` +**Environment variables** (override config file): + +| Variable | Description | +|----------|-------------| +| `DUALENTRY_API_URL` | API base URL (overrides config) | +| `X_API_KEY` | API key (skips OAuth) | + ## Requirements - Python 3.11+ @@ -103,6 +117,34 @@ dualentry config set-env prod # Production uv tool upgrade dualentry-cli ``` +## Development + +### Setup + +```bash +uv sync --dev +uv run pre-commit install +``` + +### Linting + +```bash +uv run ruff check . +uv run ruff format --check . +``` + +### Tests + +```bash +uv run pytest +``` + +With coverage: + +```bash +uv run pytest --cov=dualentry_cli --cov-report=term-missing +``` + ## Documentation - [API Reference](https://docs.dualentry.com/api) diff --git a/install.sh b/install.sh index fa69220..99d0288 100755 --- a/install.sh +++ b/install.sh @@ -30,7 +30,7 @@ if [ "$OS" = "linux" ] && [ "$ARCH" = "arm64" ]; then fi echo "Detecting latest release..." -LATEST=$(curl -sI "https://github.com/${REPO}/releases/latest" | grep -i "^location:" | sed 's/.*tag\///' | tr -d '\r') +LATEST=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed 's/.*: "//;s/".*//') if [ -z "$LATEST" ]; then echo "Failed to detect latest release." >&2 @@ -38,18 +38,19 @@ if [ -z "$LATEST" ]; then fi URL="https://github.com/${REPO}/releases/download/${LATEST}/dualentry-${TARGET}" +TMPFILE=$(mktemp) echo "Downloading dualentry ${LATEST} for ${TARGET}..." -curl -fSL "$URL" -o /tmp/dualentry +curl -fSL "$URL" -o "$TMPFILE" -chmod +x /tmp/dualentry +chmod +x "$TMPFILE" mkdir -p "$INSTALL_DIR" if [ -w "$INSTALL_DIR" ]; then - mv /tmp/dualentry "$INSTALL_DIR/dualentry" + mv "$TMPFILE" "$INSTALL_DIR/dualentry" else echo "Installing to ${INSTALL_DIR} (requires sudo)..." - sudo mv /tmp/dualentry "$INSTALL_DIR/dualentry" + sudo mv "$TMPFILE" "$INSTALL_DIR/dualentry" fi echo "Installed dualentry to ${INSTALL_DIR}/dualentry"