diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b40bd0b..a49b07c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -78,9 +78,6 @@ You should see one error about there not being a git tag, and that's fine. To actually release, run: ```bash -# use `git tag -l | grep cli` to find the latest version and what you want to bump it to -export VERSION=0.1.1 -git tag -a v$VERSION -m "Bugfixes" -git push origin v$VERSION -make release +# use `git describe --abbrev=0` to find the latest version and then bump it following https://semver.org/ +./scripts/release.sh [description] ``` diff --git a/cmd/browsers.go b/cmd/browsers.go index 3a5d5b1..0d3500e 100644 --- a/cmd/browsers.go +++ b/cmd/browsers.go @@ -219,10 +219,13 @@ func (b BrowsersCmd) List(ctx context.Context, in BrowsersListInput) error { return util.CleanedUpSdkError{Err: err} } - browsers := page.Items + var browsers []kernel.BrowserListResponse + if page != nil { + browsers = page.Items + } if in.Output == "json" { - if browsers == nil { + if len(browsers) == 0 { fmt.Println("[]") return nil } diff --git a/cmd/browsers_test.go b/cmd/browsers_test.go index d3c2ec0..b422b37 100644 --- a/cmd/browsers_test.go +++ b/cmd/browsers_test.go @@ -120,6 +120,21 @@ func TestBrowsersList_PrintsEmptyMessage(t *testing.T) { assert.Contains(t, out, "No running browsers found") } +func TestBrowsersList_PrintsEmptyMessagePageIsNil(t *testing.T) { + setupStdoutCapture(t) + + fake := &FakeBrowsersService{ + ListFunc: func(ctx context.Context, query kernel.BrowserListParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.BrowserListResponse], error) { + return nil, nil + }, + } + b := BrowsersCmd{browsers: fake} + _ = b.List(context.Background(), BrowsersListInput{}) + + out := outBuf.String() + assert.Contains(t, out, "No running browsers found") +} + func TestBrowsersList_PrintsTableWithRows(t *testing.T) { setupStdoutCapture(t) diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..d970d01 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +if [ -z "$1" ]; then + echo "Error: VERSION is required" + echo "Usage: $0 [DESCRIPTION]" + exit 1 +fi + +VERSION=$1 +if [[ ! "$VERSION" =~ ^[0-9.]+$ ]]; then + echo "Error: VERSION must contain only numbers and periods" + echo "Usage: $0 [DESCRIPTION]" + exit 1 +fi +DESCRIPTION=${2:-"Version $VERSION"} + +git tag -a v$VERSION -m "$DESCRIPTION" +git push origin v$VERSION +make release \ No newline at end of file