Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [master]

jobs:
build:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,12 +19,22 @@ jobs:
- name: Build
run: go build ./...

- name: Test
run: go test ./... -v -race -coverprofile=coverage.txt

- name: Vet
run: go vet ./...

- name: Test with coverage
run: go test ./... -race -coverprofile=coverage.out -covermode=atomic

- name: Coverage summary
run: go tool cover -func=coverage.out

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out
if-no-files-found: ignore

lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -34,8 +44,18 @@ jobs:
with:
go-version-file: go.mod

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: gofumpt
run: |
go install mvdan.cc/gofumpt@latest
unformatted="$("$(go env GOPATH)"/bin/gofumpt -l .)"
if [ -n "$unformatted" ]; then
echo "The following files are not gofumpt-formatted:"
echo "$unformatted"
echo "Run 'make fmt' to fix."
exit 1
fi

- name: golangci-lint
run: golangci-lint run
uses: golangci/golangci-lint-action@v6
with:
version: v2.12.2
25 changes: 18 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches: [master]
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'website/**'
- '.github/workflows/docs.yml'
workflow_dispatch:

permissions:
Expand All @@ -20,20 +20,31 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
- uses: pnpm/action-setup@v4
with:
python-version: '3.12'
version: 9

- run: pip install mkdocs-material
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: website/pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile

- run: mkdocs build
- name: Build static site
run: pnpm build

- uses: actions/upload-pages-artifact@v3
with:
path: site
path: website/out

deploy:
needs: build
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ coverage.html
Thumbs.db

# Docs build
site/
website/node_modules/
website/.next/
website/out/

# Config (don't commit user configs)
.rc.yaml
55 changes: 54 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
# golangci-lint configuration for revenuecat-cli
# Docs: https://golangci-lint.run/usage/configuration/
version: "2"

run:
timeout: 5m
tests: true

linters:
disable-all: true
default: none
enable:
# Core vet + correctness
- govet
- staticcheck
- errcheck
- ineffassign
- unused
# Bug-prone patterns
- bodyclose
- noctx
- nilerr
- errorlint
- gocritic
- prealloc
- whitespace
- misspell
- unconvert
- revive
settings:
errcheck:
check-type-assertions: true
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
revive:
rules:
- name: exported
disabled: true
exclusions:
rules:
# Test files: relax some checks
- path: _test\.go
linters:
- errcheck
- bodyclose
- noctx

formatters:
enable:
- gofumpt
- goimports
settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes:
- github.com/AndroidPoet/revenuecat-cli
60 changes: 49 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# revenuecat-cli - RevenueCat CLI
# Makefile for building, testing, and releasing
# Makefile for building, testing, linting, coverage, docs, and releasing

BINARY_NAME=revenuecat-cli
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"

.PHONY: all build install clean test lint fmt deps help
COVERAGE_OUT=coverage.out
COVERAGE_HTML=coverage.html

.PHONY: all build build-all install deps fmt fmt-check lint lint-fix test test-race cover cover-func tools docs-dev docs-build release release-snapshot clean version help

all: build

Expand All @@ -32,18 +35,53 @@ deps: ## Download dependencies
go mod download
go mod tidy

fmt: ## Format code
go fmt ./...
tools: ## Install dev tooling (gofumpt, golangci-lint)
go install mvdan.cc/gofumpt@latest
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest

fmt: ## Format code with gofumpt
gofumpt -w .

fmt-check: ## Fail if any file is not gofumpt-formatted
@unformatted=$$(gofumpt -l .); \
if [ -n "$$unformatted" ]; then \
echo "The following files are not gofumpt-formatted:"; \
echo "$$unformatted"; \
echo "Run 'make fmt' to fix."; \
exit 1; \
fi

lint: ## Run golangci-lint
golangci-lint run ./...

lint-fix: ## Run golangci-lint with auto-fix
golangci-lint run --fix ./...

lint: ## Run linter
golangci-lint run
## Testing & Coverage

test: ## Run tests
go test -v ./...
go test ./...

test-race: ## Run tests with the race detector
go test ./... -race

cover: ## Run tests with coverage and produce HTML + func reports
go test ./... -coverprofile=$(COVERAGE_OUT) -covermode=atomic
go tool cover -html=$(COVERAGE_OUT) -o $(COVERAGE_HTML)
go tool cover -func=$(COVERAGE_OUT)
@echo "HTML coverage report written to $(COVERAGE_HTML)"

cover-func: ## Print per-function coverage to stdout
go test ./... -coverprofile=$(COVERAGE_OUT) -covermode=atomic
go tool cover -func=$(COVERAGE_OUT)

## Docs (Nextra site under website/)

docs-dev: ## Run the docs site locally
cd website && pnpm install && pnpm dev

test-coverage: ## Run tests with coverage
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
docs-build: ## Build the static docs site
cd website && pnpm install && pnpm build

## Release

Expand All @@ -58,7 +96,7 @@ release: ## Create a release (requires GITHUB_TOKEN)
clean: ## Remove build artifacts
rm -rf bin/
rm -rf dist/
rm -f coverage.out coverage.html
rm -f $(COVERAGE_OUT) $(COVERAGE_HTML)

version: ## Print version
@echo $(VERSION)
Expand Down
20 changes: 10 additions & 10 deletions cmd/revenuecat-cli/commands/apps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,34 @@ func init() {

// Get flags
getCmd.Flags().StringVar(&appID, "app-id", "", "app ID")
getCmd.MarkFlagRequired("app-id")
getCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())
_ = getCmd.MarkFlagRequired("app-id")
_ = getCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())

// Create flags
createCmd.Flags().StringVar(&appName, "name", "", "app name")
createCmd.Flags().StringVar(&appType, "type", "", "app type (app_store, play_store, stripe, amazon, mac_app_store, roku, web)")
createCmd.Flags().StringVar(&bundleID, "bundle-id", "", "iOS bundle ID")
createCmd.Flags().StringVar(&packageName, "package-name", "", "Android package name")
createCmd.MarkFlagRequired("name")
createCmd.MarkFlagRequired("type")
_ = createCmd.MarkFlagRequired("name")
_ = createCmd.MarkFlagRequired("type")

// Update flags
updateCmd.Flags().StringVar(&appID, "app-id", "", "app ID")
updateCmd.Flags().StringVar(&appName, "name", "", "new app name")
updateCmd.MarkFlagRequired("app-id")
updateCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())
_ = updateCmd.MarkFlagRequired("app-id")
_ = updateCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())

// Delete flags
var confirm bool
deleteCmd.Flags().StringVar(&appID, "app-id", "", "app ID")
deleteCmd.Flags().BoolVar(&confirm, "confirm", false, "confirm deletion")
deleteCmd.MarkFlagRequired("app-id")
deleteCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())
_ = deleteCmd.MarkFlagRequired("app-id")
_ = deleteCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())

// API keys flags
apiKeysCmd.Flags().StringVar(&appID, "app-id", "", "app ID")
apiKeysCmd.MarkFlagRequired("app-id")
apiKeysCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())
_ = apiKeysCmd.MarkFlagRequired("app-id")
_ = apiKeysCmd.RegisterFlagCompletionFunc("app-id", completion.AppIDs())

AppsCmd.AddCommand(listCmd)
AppsCmd.AddCommand(getCmd)
Expand Down
6 changes: 3 additions & 3 deletions cmd/revenuecat-cli/commands/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ func init() {
loginCmd.Flags().StringVar(&profileName, "name", "default", "profile name")
loginCmd.Flags().StringVar(&apiKey, "api-key", "", "RevenueCat API v2 secret key")
loginCmd.Flags().StringVar(&defaultProject, "default-project", "", "default project ID for this profile")
loginCmd.MarkFlagRequired("api-key")
_ = loginCmd.MarkFlagRequired("api-key")

// Switch flags
switchCmd.Flags().StringVar(&profileName, "name", "", "profile name to switch to")
switchCmd.MarkFlagRequired("name")
_ = switchCmd.MarkFlagRequired("name")

// Delete flags
var confirm bool
deleteCmd.Flags().StringVar(&profileName, "name", "", "profile name to delete")
deleteCmd.Flags().BoolVar(&confirm, "confirm", false, "confirm deletion")
deleteCmd.MarkFlagRequired("name")
_ = deleteCmd.MarkFlagRequired("name")

AuthCmd.AddCommand(loginCmd)
AuthCmd.AddCommand(switchCmd)
Expand Down
Loading
Loading