Skip to content
Merged

1.3.3 #157

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
88 changes: 80 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on:
- 'README.md'
- '.github/**'
- '.dockerignore'
- 'docs/**'
- 'etl/**'
- '.gitignore'
- 'demo**'
- 'go.mod'
Expand All @@ -26,7 +28,7 @@ on:
- main

env:
VERSION_NUMBER: 'v1.3.2'
VERSION_NUMBER: 'v1.3.3'
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
AWS_REGION: 'us-west-2'

Expand All @@ -53,7 +55,77 @@ jobs:
with:
sarif_file: results.sarif

build-docker-image:
build-docs-docker-image:
runs-on: ubuntu-22.04
needs: [ gosec ]
if: needs.gosec.result == 'success'

steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
docs

- name: Set up Docker Buildx
uses: 'docker/[email protected]'

- name: Prepare Docker Build Context
run: |
mkdir docker-context
rsync -av --exclude=docker-context . docker-context/

- name: Build and Export
uses: 'docker/[email protected]'
with:
context: ./docker-context
file: ./docker-context/docs/Dockerfile
tags: docs:latest
outputs: type=docker,dest=/tmp/docs.tar

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: /tmp/docs.tar

upload-docs-to-ecr:
runs-on: ubuntu-22.04
needs: [build-docs-docker-image]
if: needs.build-docs-docker-image.result == 'success'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: docs
path: /tmp

- name: Load Image
run: docker load -i /tmp/docs.tar

- name: Tag and Push
run: |
docker tag docs:latest ${{ secrets.AWS_DOCS_ECR_NAME }}:latest
docker push ${{ secrets.AWS_DOCS_ECR_NAME }}:latest

# AWS will then take care of updating App Runner with the latest version

build-cli-docker-image:
runs-on: ubuntu-22.04
needs: [gosec]
if: needs.gosec.result == 'success'
Expand Down Expand Up @@ -83,11 +155,11 @@ jobs:
name: poke-cli
path: /tmp/poke-cli.tar

# Uploading to Elastic Container Registry has a backup method.
upload-to-ecr:
# Uploading to Elastic Container Registry as a backup method.
upload-cli-to-ecr:
runs-on: ubuntu-22.04
needs: [build-docker-image]
if: needs.build-docker-image.result == 'success'
needs: [build-cli-docker-image]
if: needs.build-cli-docker-image.result == 'success'

steps:
- name: Checkout
Expand Down Expand Up @@ -116,8 +188,8 @@ jobs:
id-token: 'write'

runs-on: ubuntu-22.04
needs: [build-docker-image]
if: needs.build-docker-image.result == 'success'
needs: [build-cli-docker-image]
if: needs.build-cli-docker-image.result == 'success'

steps:
- name: Checkout
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ go.work
go.work.sum

# env file
.env
.env

# Python
etl/.venv
21 changes: 15 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X main.version=v1.3.2
- -s -w -X main.version=v1.3.3

archives:
- format: tar.gz
- formats: [ 'zip' ]
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
Expand All @@ -28,7 +28,7 @@ archives:
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
- formats: [ 'zip' ]

changelog:
sort: asc
Expand All @@ -37,11 +37,20 @@ changelog:
- "^docs:"
- "^test:"

brews:
- repository:
homebrew_casks:
- name: poke-cli
conflicts:
- formula: poke-cli
repository:
owner: digitalghost-dev
name: homebrew-poke-cli
token: "{{.Env.GITHUB_TOKEN}}"
homepage: "https://github.com/digitalghost-dev/poke-cli"
description: "A CLI tool written in Go that allows you to view data about Pokémon from the terminal."
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
license: "Apache License 2.0"
hooks:
post:
install: |
if system_command("/usr/bin/xattr", args: ["-h"]).exit_status == 0
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/poke-cli"]
end
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# build 1
FROM golang:1.24.4-alpine3.21 AS build
# Stage 1: Dependencies
FROM golang:1.24.4-alpine3.21 AS deps

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download
RUN go mod tidy

# Stage 2: Build
FROM deps AS build-stage
COPY . .

RUN go build -ldflags "-X main.version=v1.3.2" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.3.3" -o poke-cli .

# build 2
# Stage 3: Production
FROM --platform=$BUILDPLATFORM alpine:latest

# Install only necessary packages and remove them after use
Expand All @@ -19,7 +21,7 @@ RUN apk add --no-cache shadow && \
sed -i 's/^root:.*/root:!*:0:0:root:\/root:\/sbin\/nologin/' /etc/passwd && \
apk del shadow

COPY --from=build /app/poke-cli /app/poke-cli
COPY --from=build-stage /app/poke-cli /app/poke-cli

ENV TERM=xterm-256color
ENV COLOR_OUTPUT=true
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
<h1>Pokémon CLI</h1>
<img src="https://img.shields.io/github/v/release/digitalghost-dev/poke-cli?style=flat-square&logo=git&logoColor=FFCC00&label=Release%20Version&labelColor=EEE&color=FFCC00" alt="version-label">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.3.2?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.3.3?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<img src="https://img.shields.io/github/actions/workflow/status/digitalghost-dev/poke-cli/ci.yml?branch=main&style=flat-square&logo=github&logoColor=FFCC00&label=CI&labelColor=EEE&color=FFCC00" alt="ci-status-badge">
</div>
<div align="center">
Expand All @@ -13,6 +13,7 @@

## Overview
`poke-cli` is a hybrid of a classic CLI and a modern TUI tool for viewing data about Pokémon! This is my first Go project.
View the [documentation](https://docs.poke-cli.com)!

The architecture behind how the tool works is straight forward:
1. Each command indicates which [API](https://pokeapi.co/) endpoint to use.
Expand All @@ -23,7 +24,7 @@ View future plans in the [Roadmap](#roadmap) section.

---
## Demo
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v1.2.1.gif)
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v1.3.3.gif)

---
## Installation
Expand Down Expand Up @@ -76,11 +77,11 @@ View future plans in the [Roadmap](#roadmap) section.
3. Choose how to interact with the container:
* Run a single command and exit:
```bash
docker run --rm -it digitalghostdev/poke-cli:v1.3.2 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.3.3 <command> [subcommand] flag]
```
* Enter the container and use its shell:
```bash
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.3.2 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.3.3 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down
1 change: 1 addition & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func runCLI(args []string) int {
"\n\n", styling.StyleItalic.Render("hint: when calling a resource with a space, use a hyphen"),
"\n", styling.StyleItalic.Render("example: poke-cli ability strong-jaw"),
"\n", styling.StyleItalic.Render("example: poke-cli pokemon flutter-mane"),
"\n\n", fmt.Sprintf("%s %s", "↓ ctrl/cmd + click for docs/guides\n", styling.DocsLink),
)
fmt.Println(helpMessage)
}
Expand Down
22 changes: 11 additions & 11 deletions cmd/ability/ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@
capitalizedAbility := cases.Title(language.English).String(strings.ReplaceAll(abilityName, "-", " "))
output.WriteString(styling.StyleBold.Render(capitalizedAbility) + "\n")

// API is missing some data for the short_effect for abilities from Generation 9.
// If short_effect is empty, fallback to the move's flavor_text_entry.
if englishShortEffect == "" {
output.WriteString("Effect: " + englishFlavorEntry + "\n")
} else {
output.WriteString("Effect: " + englishShortEffect + "\n")
}

// Print the generation where the move was first introduced.
// Print the generation where the ability was first introduced.
generationParts := strings.Split(abilitiesStruct.Generation.Name, "-")
if len(generationParts) > 1 {
generationUpper := strings.ToUpper(generationParts[1])
output.WriteString("Generation: " + generationUpper + "\n")
output.WriteString(fmt.Sprintf("%s First introduced in generation "+generationUpper+"\n", styling.ColoredBullet))
} else {
output.WriteString(fmt.Sprintf("%s Generation: Unknown\n", styling.ColoredBullet))
}

Check warning on line 98 in cmd/ability/ability.go

View check run for this annotation

Codecov / codecov/patch

cmd/ability/ability.go#L97-L98

Added lines #L97 - L98 were not covered by tests

// API is missing some data for the short_effect for abilities from Generation 9.
// If short_effect is empty, fallback to the move's flavor_text_entry.
if englishShortEffect == "" {
output.WriteString(fmt.Sprintf("%s Effect: "+englishFlavorEntry, styling.ColoredBullet))

Check warning on line 103 in cmd/ability/ability.go

View check run for this annotation

Codecov / codecov/patch

cmd/ability/ability.go#L103

Added line #L103 was not covered by tests
} else {
output.WriteString("Generation: Unknown\n")
output.WriteString(fmt.Sprintf("%s Effect: "+englishShortEffect, styling.ColoredBullet))
}

if *pokemonFlag || *shortPokemonFlag {
Expand Down
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Set Shell "bash"
Set FontSize 32
Set Width 2100
Set Height 1300
Set TypingSpeed 85ms
Set TypingSpeed 100ms
Set Theme "tokyonight-storm"

Type "poke-cli pokemon charizard --abilities --stats --types"

Expand Down
3 changes: 3 additions & 0 deletions docs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Environments
.env
.venv
23 changes: 23 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dockerfile.prod
FROM python:3.12-slim AS builder

WORKDIR /build

RUN pip install mkdocs mkdocs-material

COPY mkdocs.yml /build/mkdocs.yml

COPY docs/ /build/docs/

RUN mkdocs build

# --- Serve with lightweight HTTP server ---
FROM python:3.12-slim

WORKDIR /site

COPY --from=builder /build/site /site

EXPOSE 8080

CMD ["python3", "-m", "http.server", "8080"]
Binary file added docs/assets/DigitalGhostLogo-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ability.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/move.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/natures.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/pokemon_abilities_moves.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/pokemon_image.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/pokemon_stats_types.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/types.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading