Skip to content
Merged

1.8.1 #211

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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ on:
- main

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

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X main.version=v1.8.0
- -s -w -X main.version=v1.8.1

archives:
- formats: [ 'zip' ]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go mod download

COPY . .

RUN go build -ldflags "-X main.version=v1.8.0" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.8.1" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.22
Expand Down
6 changes: 3 additions & 3 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.8.0?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.8.1?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 Down Expand Up @@ -95,11 +95,11 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
3. Choose how to interact with the container:
* Run a single command and exit:
```bash
docker run --rm -it digitalghostdev/poke-cli:v1.8.0 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.8.1 <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.8.0 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.1 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down
21 changes: 20 additions & 1 deletion card_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@
This directory stores all the code for all backend data processing related to Pokémon TCG data.

Instead of calling directly to the PokéAPI for data from the video game, I took this a step further
and decided to process all the data myself, load it into Supabase, and read from that API.
and decided to process all the data myself, load it into Supabase, and read from that API.

## Data Architecture
Runs at 2:00PM PST daily.
![data_diagram](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/data_infrastructure.png)


1. TCGPlayer pricing data and TCGDex card data are called and processed through a data pipeline orchestrated by Dagster and hosted on AWS.

2. When the pipeline starts, Pydantic validates the incoming API data against a pre-defined schema, ensuring the data types match the expected structure.

3. Polars is used to create DataFrames.

4. The data is loaded into a Supabase staging schema.

5. Soda data quality checks are performed.

6. `dbt` runs and builds the final tables in a Supabase production schema.

7. Users are then able to query the `pokeapi.co` or supabase APIs for either video game or trading card data, respectively.
2 changes: 1 addition & 1 deletion card_data/pipelines/poke_cli_dbt/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'poke_cli_dbt'
version: '1.8.0'
version: '1.8.1'

profile: 'poke_cli_dbt'

Expand Down
23 changes: 9 additions & 14 deletions cmd/ability/ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package ability
import (
"flag"
"fmt"
"os"
"strings"

"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/connections"
"github.com/digitalghost-dev/poke-cli/flags"
"github.com/digitalghost-dev/poke-cli/styling"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"os"
"strings"
)

func AbilityCommand() (string, error) {
Expand Down Expand Up @@ -52,19 +53,14 @@ func AbilityCommand() (string, error) {
if err := abilityFlags.Parse(args[3:]); err != nil {
output.WriteString(fmt.Sprintf("error parsing flags: %v\n", err))
abilityFlags.Usage()
if os.Getenv("GO_TESTING") != "1" {
os.Exit(1)
}

return output.String(), err
}

abilitiesStruct, abilityName, err := connections.AbilityApiCall(endpoint, abilityName, connections.APIURL)
if err != nil {
if os.Getenv("GO_TESTING") != "1" {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
return err.Error(), nil
output.WriteString(err.Error())
return output.String(), err
}

// Extract English short_effect
Expand All @@ -88,7 +84,6 @@ func AbilityCommand() (string, error) {
capitalizedAbility := cases.Title(language.English).String(strings.ReplaceAll(abilityName, "-", " "))
output.WriteString(styling.StyleBold.Render(capitalizedAbility) + "\n")

// Print the generation where the ability was first introduced.
generationParts := strings.Split(abilitiesStruct.Generation.Name, "-")
if len(generationParts) > 1 {
generationUpper := strings.ToUpper(generationParts[1])
Expand All @@ -100,15 +95,15 @@ func AbilityCommand() (string, error) {
// 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))
output.WriteString(fmt.Sprintf("%s Effect: %s", styling.ColoredBullet, englishFlavorEntry))
} else {
output.WriteString(fmt.Sprintf("%s Effect: "+englishShortEffect, styling.ColoredBullet))
output.WriteString(fmt.Sprintf("%s Effect: %s", styling.ColoredBullet, englishShortEffect))
}

if *pokemonFlag || *shortPokemonFlag {
if err := flags.PokemonAbilitiesFlag(&output, endpoint, abilityName); err != nil {
output.WriteString(fmt.Sprintf("error parsing flags: %v\n", err))
return "", fmt.Errorf("error parsing flags: %w", err)
return output.String(), fmt.Errorf("error parsing flags: %w", err)
}
}

Expand Down
22 changes: 8 additions & 14 deletions cmd/ability/ability_test.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
package ability

import (
"os"
"testing"

"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/styling"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

func TestAbilityCommand(t *testing.T) {
err := os.Setenv("GO_TESTING", "1")
if err != nil {
t.Fatalf("Failed to set GO_TESTING env var: %v", err)
}

defer func() {
err := os.Unsetenv("GO_TESTING")
if err != nil {
t.Logf("Warning: failed to unset GO_TESTING: %v", err)
}
}()

tests := []struct {
name string
args []string
Expand Down Expand Up @@ -53,6 +42,11 @@ func TestAbilityCommand(t *testing.T) {
args: []string{"ability", "anger-point", "--pokemon"},
expectedOutput: utils.LoadGolden(t, "ability_flag_pokemon.golden"),
},
{
name: "Ability command: special character in API call",
args: []string{"ability", "poison-point"},
expectedOutput: utils.LoadGolden(t, "ability_poison_point.golden"),
},
}

for _, tt := range tests {
Expand Down
66 changes: 58 additions & 8 deletions cmd/card/imageviewer.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,60 @@
package card

import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/digitalghost-dev/poke-cli/styling"
)

type ImageModel struct {
CardName string
ImageURL string
Error error
CardName string
ImageURL string
Error error
Loading bool
Spinner spinner.Model
ImageData string
}

type imageReadyMsg struct {
sixelData string
err error
}

// fetchImageCmd downloads and renders the image asynchronously
func fetchImageCmd(imageURL string) tea.Cmd {
return func() tea.Msg {
sixelData, err := CardImage(imageURL)
if err != nil {
return imageReadyMsg{err: err}
}
return imageReadyMsg{sixelData: sixelData}
}
}

func (m ImageModel) Init() tea.Cmd {
return nil
return tea.Batch(
m.Spinner.Tick,
fetchImageCmd(m.ImageURL),
)
}

func (m ImageModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case imageReadyMsg:
m.Loading = false
if msg.err != nil {
m.Error = msg.err
m.ImageData = ""
} else {
m.Error = nil
m.ImageData = msg.sixelData
}
return m, nil
case spinner.TickMsg:
var cmd tea.Cmd
m.Spinner, cmd = m.Spinner.Update(msg)
return m, cmd
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "esc":
Expand All @@ -26,15 +65,26 @@ func (m ImageModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

func (m ImageModel) View() string {
return m.ImageURL
if m.Loading {
return lipgloss.NewStyle().Padding(2).Render(
m.Spinner.View() + "Loading image for \n" + m.CardName,
)
}
if m.Error != nil {
return styling.Red.Render(m.Error.Error())
}
return m.ImageData
}

func ImageRenderer(cardName string, imageURL string) ImageModel {
imageData, err := CardImage(imageURL)
s := spinner.New()
s.Spinner = spinner.Dot
s.Style = styling.Yellow

return ImageModel{
CardName: cardName,
ImageURL: imageData,
Error: err,
ImageURL: imageURL,
Loading: true,
Spinner: s,
}
}
Loading
Loading