Skip to content
Merged

1.8.6 #232

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 @@ -31,7 +31,7 @@ on:
- main

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

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ card_data/storage/
CLAUDE.md
REFACTORING.md
/card_data/.codspeed/
/.ai/
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.5
- -s -w -X main.version=v1.8.6

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.5" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.8.6" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.23
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 width="425" src="poke-cli.png" alt="pokemon-logo"/>
<h4></h4>
<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.5?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.6?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 @@ -96,11 +96,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.5 <command> [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v1.8.6 <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.5 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.6 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down
2 changes: 1 addition & 1 deletion card_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and decided to process all the data myself, load it into Supabase, and read from

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


1. TCGPlayer pricing data and TCGDex card data are called and processed through a data pipeline orchestrated by Dagster and hosted on AWS.
Expand Down
Binary file added card_data/data_infrastructure_v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.5'
version: '1.8.6'

profile: 'poke_cli_dbt'

Expand Down
6 changes: 4 additions & 2 deletions card_data/pipelines/poke_cli_dbt/macros/create_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"localId",
"set_cardCount_official",
CONCAT(name, ' - ', LPAD("localId", 3, '0'), '/', LPAD("set_cardCount_official"::text, 3, '0')) AS card_combined_name,
set_name
set_name,
regulation_mark
FROM public.cards
),
cards_pricing_cte AS (
Expand All @@ -30,7 +31,8 @@
LPAD(c."localId", 3, '0') AS "localId",
p."market_price",
COALESCE(p."card_number", LPAD(c."localId", 3, '0')) AS card_number,
c.illustrator
c.illustrator,
c.regulation_mark
FROM
cards_cte AS c
LEFT JOIN
Expand Down
5 changes: 3 additions & 2 deletions card_data/pipelines/poke_cli_dbt/models/cards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
post_hook="{{ enable_rls() }}"
) }}

SELECT id, set_id, image, name, "localId", category, hp, "set_cardCount_official", set_name, illustrator
FROM {{ source('staging', 'cards') }}
SELECT id, set_id, image, name, "localId", category, hp, "set_cardCount_official", set_name, illustrator, "regulationMark" AS regulation_mark
FROM {{ source('staging', 'cards') }}
WHERE "localId" ~ '^[0-9]+$'
8 changes: 4 additions & 4 deletions card_data/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ dependencies = [
"dagster>=1.11.3",
"dagster-dbt>=0.27.3",
"dagster-dg-cli>=1.11.3",
"dagster-postgres>=0.27.3",
"dagster-webserver>=1.11.3",
"dagster-postgres==0.28.7",
"dagster-webserver==1.12.7",
"dbt-core>=1.10.8",
"dbt-postgres>=1.9.0",
"pandas>=2.3.1",
Expand All @@ -27,10 +27,10 @@ dependencies = [

[dependency-groups]
dev = [
"dagster-webserver",
"dagster-webserver==1.12.7",
"dagster-dg-cli",
"dagster-dbt>=0.27.3",
"dagster-postgres>=0.27.3",
"dagster-postgres==0.28.7",
"pytest>=9.0.2",
"pytest-codspeed>=4.2.0",
"responses>=0.25.8",
Expand Down
4 changes: 2 additions & 2 deletions card_data/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 26 additions & 20 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ import (

var version = "(devel)"

var commandDescriptions = []struct {
name string
desc string
}{
{"ability", "Get details about an ability"},
{"berry", "Get details about a berry"},
{"card", "Get details about a TCG card"},
{"item", "Get details about an item"},
{"move", "Get details about a move"},
{"natures", "Get details about all natures"},
{"pokemon", "Get details about a Pokémon"},
{"search", "Search for a resource"},
{"speed", "Calculate the speed of a Pokémon in battle"},
{"types", "Get details about a typing"},
}

func renderCommandList() string {
var sb strings.Builder
for _, cmd := range commandDescriptions {
sb.WriteString(fmt.Sprintf("\n\t%-15s %s", cmd.name, cmd.desc))
}
return sb.String()
}

func currentVersion() {
if version != "(devel)" {
// Use version injected by -ldflags
Expand Down Expand Up @@ -70,16 +94,7 @@ func runCLI(args []string) int {
fmt.Sprintf("\n\t%-15s %s", "-l, --latest", "Prints the latest version available"),
fmt.Sprintf("\n\t%-15s %s", "-v, --version", "Prints the current version"),
"\n\n", styling.StyleBold.Render("COMMANDS:"),
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
fmt.Sprintf("\n\t%-15s %s", "berry", "Get details about a berry"),
fmt.Sprintf("\n\t%-15s %s", "card", "Get details about a TCG card"),
fmt.Sprintf("\n\t%-15s %s", "item", "Get details about an item"),
fmt.Sprintf("\n\t%-15s %s", "move", "Get details about a move"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "search", "Search for a resource"),
fmt.Sprintf("\n\t%-15s %s", "speed", "Calculate the speed of a Pokémon in battle"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a typing"),
renderCommandList(),
"\n\n", styling.StyleItalic.Render(styling.HyphenHint),
"\n", styling.StyleItalic.Render("example: poke-cli ability strong-jaw"),
"\n", styling.StyleItalic.Render("example: poke-cli pokemon flutter-mane"),
Expand Down Expand Up @@ -151,16 +166,7 @@ func runCLI(args []string) int {
styling.ErrorColor.Render("✖ Error!"),
fmt.Sprintf("\n\t%-15s", fmt.Sprintf("'%s' is not a valid command.\n", cmdArg)),
styling.StyleBold.Render("\nCommands:"),
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
fmt.Sprintf("\n\t%-15s %s", "berry", "Get details about a berry"),
fmt.Sprintf("\n\t%-15s %s", "card", "Get details about a TCG card"),
fmt.Sprintf("\n\t%-15s %s", "item", "Get details about an item"),
fmt.Sprintf("\n\t%-15s %s", "move", "Get details about a move"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "search", "Search for a resource"),
fmt.Sprintf("\n\t%-15s %s", "speed", "Calculate the speed of a Pokémon in battle"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a typing"),
renderCommandList(),
fmt.Sprintf("\n\nAlso run %s for more info!", styling.StyleBold.Render("poke-cli -h")),
)
output.WriteString(errMessage)
Expand Down
3 changes: 1 addition & 2 deletions cmd/ability/ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ func AbilityCommand() (string, error) {

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

Expand Down
33 changes: 22 additions & 11 deletions cmd/card/cardlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (
)

type CardsModel struct {
Choice string
IllustratorMap map[string]string
ImageMap map[string]string
PriceMap map[string]string
Quitting bool
SelectedOption string
SeriesName string
Table table.Model
ViewImage bool
Choice string
IllustratorMap map[string]string
ImageMap map[string]string
PriceMap map[string]string
RegulationMarkMap map[string]string
Quitting bool
SelectedOption string
SeriesName string
Table table.Model
ViewImage bool
}

func (m CardsModel) Init() tea.Cmd {
Expand Down Expand Up @@ -70,7 +71,8 @@ func (m CardsModel) View() string {
price = "Price: Not available"
}
illustrator := m.IllustratorMap[cardName]
selectedCard = cardName + "\n---\n" + price + "\n---\n" + illustrator
regulationMark := m.RegulationMarkMap[cardName]
selectedCard = cardName + "\n---\n" + price + "\n---\n" + illustrator + "\n---\n" + regulationMark
}

leftPanel := styling.TypesTableBorder.Render(m.Table.View())
Expand All @@ -96,11 +98,12 @@ type cardData struct {
MarketPrice float64 `json:"market_price"`
Name string `json:"name"`
NumberPlusName string `json:"number_plus_name"`
RegulationMark string `json:"regulation_mark"`
}

// CardsList creates and returns a new CardsModel with cards from a specific set
func CardsList(setID string) (CardsModel, error) {
url := fmt.Sprintf("https://uoddayfnfkebrijlpfbh.supabase.co/rest/v1/card_pricing_view?set_id=eq.%s&select=number_plus_name,market_price,image_url,illustrator&order=localId", setID)
url := fmt.Sprintf("https://uoddayfnfkebrijlpfbh.supabase.co/rest/v1/card_pricing_view?set_id=eq.%s&select=number_plus_name,market_price,image_url,illustrator,regulation_mark&order=localId", setID)
body, err := getCardData(url)
if err != nil {
return CardsModel{}, fmt.Errorf("failed to fetch card data: %w", err)
Expand All @@ -117,6 +120,7 @@ func CardsList(setID string) (CardsModel, error) {
priceMap := make(map[string]string)
imageMap := make(map[string]string)
illustratorMap := make(map[string]string)
regulationMarkMap := make(map[string]string)
for i, card := range allCards {
rows[i] = []string{card.NumberPlusName}
if card.MarketPrice != 0 {
Expand All @@ -131,6 +135,12 @@ func CardsList(setID string) (CardsModel, error) {
illustratorMap[card.NumberPlusName] = "Illustrator not available"
}

if card.RegulationMark != "" {
regulationMarkMap[card.NumberPlusName] = "Regulation: " + card.RegulationMark
} else {
regulationMarkMap[card.NumberPlusName] = "Regulation not available"
}

imageMap[card.NumberPlusName] = card.ImageURL
}

Expand All @@ -155,6 +165,7 @@ func CardsList(setID string) (CardsModel, error) {
IllustratorMap: illustratorMap,
ImageMap: imageMap,
PriceMap: priceMap,
RegulationMarkMap: regulationMarkMap,
Table: t,
}, nil
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/card/cardlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
tea "github.com/charmbracelet/bubbletea"
)

// testSupabaseKey is the publishable API key used in tests.
// Extracted to a constant for easier maintenance if the key changes.
const testSupabaseKey = "sb_publishable_oondaaAIQC-wafhEiNgpSQ_reRiEp7j"

func TestCardsModel_Init(t *testing.T) {
model := CardsModel{
SeriesName: "sv",
Expand Down Expand Up @@ -305,10 +309,10 @@ func TestCardsList_EmptyResult(t *testing.T) {
func TestCallCardData_SendsHeadersAndReturnsBody(t *testing.T) {
// Start a test HTTP server that validates headers and returns a body
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if got := r.Header.Get("apikey"); got != "sb_publishable_oondaaAIQC-wafhEiNgpSQ_reRiEp7j" {
if got := r.Header.Get("apikey"); got != testSupabaseKey {
t.Fatalf("missing or wrong apikey header: %q", got)
}
if got := r.Header.Get("Authorization"); got != "Bearer sb_publishable_oondaaAIQC-wafhEiNgpSQ_reRiEp7j" {
if got := r.Header.Get("Authorization"); got != "Bearer "+testSupabaseKey {
t.Fatalf("missing or wrong Authorization header: %q", got)
}
if got := r.Header.Get("Content-Type"); got != "application/json" {
Expand Down
4 changes: 2 additions & 2 deletions cmd/card/setslist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ func TestSetsModel_Update_EnterKey(t *testing.T) {

func TestCallSetsData_SendsHeadersAndReturnsBody(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if got := r.Header.Get("apikey"); got != "sb_publishable_oondaaAIQC-wafhEiNgpSQ_reRiEp7j" {
if got := r.Header.Get("apikey"); got != testSupabaseKey {
t.Fatalf("missing or wrong apikey header: %q", got)
}
if got := r.Header.Get("Authorization"); got != "Bearer sb_publishable_oondaaAIQC-wafhEiNgpSQ_reRiEp7j" {
if got := r.Header.Get("Authorization"); got != "Bearer "+testSupabaseKey {
t.Fatalf("missing or wrong Authorization header: %q", got)
}
if got := r.Header.Get("Content-Type"); got != "application/json" {
Expand Down
Loading