Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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.6.0'
VERSION_NUMBER: 'v1.6.1'
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
AWS_REGION: 'us-west-2'

Expand Down
27 changes: 9 additions & 18 deletions .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.6.0
- -s -w -X main.version=v1.6.1

archives:
- formats: [ 'zip' ]
Expand All @@ -39,37 +39,28 @@ changelog:

homebrew_casks:
- name: poke-cli
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
homepage: "https://docs.poke-cli.com/"
license: MIT
conflicts:
- formula: poke-cli
repository:
owner: digitalghost-dev
name: homebrew-tap
token: "{{.Env.GITHUB_TOKEN}}"
homepage: "https://docs.poke-cli.com/"
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 OS.mac? && 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

winget:
scoops:
- name: poke-cli
publisher: digitalghost-dev
license: MIT
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
homepage: "https://docs.poke-cli.com/"
short_description: "Pokémon CLI/TUI terminal tool."
license: MIT
repository:
owner: digitalghost-dev
name: winget-pkgs
token: "{{.Env.GITHUB_TOKEN}}"
branch: "poke-cli-{{.Version}}"
pull_request:
enabled: true
base:
owner: microsoft
name: winget-pkgs
branch: master
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
name: scoop-bucket
token: "{{ .Env.GITHUB_TOKEN }}"
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.6.0" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.6.1" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.22
Expand Down
25 changes: 15 additions & 10 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.6.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.6.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 @@ -30,7 +30,7 @@ View future plans in the [Roadmap](#roadmap) section.
## Installation

* [Homebrew](#homebrew)
* [Winget](#winget)
* [Scoop](#scoop)
* [Linux Packages](#linux-packages)
* [Docker Image](#docker-image)
* [Binary](#binary)
Expand All @@ -42,19 +42,24 @@ View future plans in the [Roadmap](#roadmap) section.
```bash
brew install --cask digitalghost-dev/tap/poke-cli
````
2. Verify install:
2. Verify installation:
```bash
poke-cli -v
```

### Winget
1. Install the package:
### Scoop
1. Add the bucket:
```powershell
winget install poke-cli
scoop bucket add digitalghost https://github.com/digitalghost-dev/scoop-bucket.git
```

2. Verify install:
```bash
2. Install poke-cli:
```powershell
scoop install poke-cli
```

3. Verify installation:
```powershell
poke-cli -v
```

Expand Down Expand Up @@ -86,11 +91,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.6.0 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.6.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.6.0 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.6.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
22 changes: 15 additions & 7 deletions card_data/infrastructure/aws/rds/provider.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
provider "aws" {
profile = "terraform-user"
region = "us-west-2"
region = "us-west-2"
}

terraform {
required_providers {
aws = {
version = "~> 6.7.0"
}
cloud {
organization = "digitalghost-dev"

workspaces {
project = "poke-cli"
name = "poke-cli"
}
}
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.7.0"
}
}
}
7 changes: 7 additions & 0 deletions card_data/pipelines/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pathlib import Path
from dagster import definitions, load_from_defs_folder


@definitions
def defs():
return load_from_defs_folder(project_root=Path(__file__).parent.parent)
177 changes: 177 additions & 0 deletions card_data/pipelines/defs/extract/extract_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import time
import json

import dagster as dg
import polars as pl

from pydantic import BaseModel, HttpUrl, ValidationError
from typing import Optional
from termcolor import colored

import requests

class Series(BaseModel):
id: str
name: str
logo: Optional[HttpUrl] = None


class Set(BaseModel):
series_id: str
set_id: str
set_name: str
official_card_count: int | None
total_card_count: int | None
logo: Optional[str] = None
symbol: Optional[str] = None


@dg.asset(kinds={"API", "Polars", "Pydantic"})
def extract_series_data() -> pl.DataFrame:
url: str = "https://api.tcgdex.net/v2/en/series"
data = requests.get(url).json()

# Pydantic validation
try:
validated: list[Series] = [Series(**item) for item in data]
print(
colored(" ✓", "green"), "Pydantic validation passed for all series entries."
)
except ValidationError as e:
print(colored(" ✖", "red"), "Pydantic validation failed.")
print(e)
raise

filtered = [s.model_dump(mode="json") for s in validated if s.id in ["swsh", "sv"]]
return pl.DataFrame(filtered)


@dg.asset(kinds={"API", "Polars", "Pydantic"})
def extract_set_data() -> pl.DataFrame:
url_list = [
"https://api.tcgdex.net/v2/en/series/swsh",
"https://api.tcgdex.net/v2/en/series/sv"
]

flat: list[dict] = []

for url in url_list:
data = requests.get(url).json()
series_id = data.get("id")

for s in data.get("sets", []):
entry = {
"series_id": series_id,
"set_id": s.get("id"),
"set_name": s.get("name"),
"official_card_count": s.get("cardCount", {}).get("official"),
"total_card_count": s.get("cardCount", {}).get("total"),
"logo": s.get("logo"),
"symbol": s.get("symbol")
}
flat.append(entry)

# Pydantic validation
try:
validated: list[Set] = [Set(**item) for item in flat]
print(
colored(" ✓", "green"),
"Pydantic validation passed for all set entries."
)
except ValidationError as e:
print(colored(" ✖", "red"), "Pydantic validation failed.")
print(e)
raise

return pl.DataFrame([s.model_dump(mode="json") for s in validated])


@dg.asset(kinds={"API"})
def extract_card_url_from_set() -> list:
urls = [
"https://api.tcgdex.net/v2/en/sets/sv01",
"https://api.tcgdex.net/v2/en/sets/sv02",
]

all_card_urls = [] # Initialize empty list to collect all URLs

for url in urls:
try:
r = requests.get(url)
r.raise_for_status()

data = r.json()["cards"]

set_card_urls = [f"https://api.tcgdex.net/v2/en/cards/{card['id']}" for card in data]
all_card_urls.extend(set_card_urls) # Add all URLs from this set

time.sleep(0.1)

except requests.RequestException as e:
print(f"Failed to fetch set {url}: {e}")

return all_card_urls


@dg.asset(deps=[extract_card_url_from_set], kinds={"API"})
def extract_card_info() -> list:
card_url_list = extract_card_url_from_set()
cards_list = []

for url in card_url_list:
try:
r = requests.get(url)
r.raise_for_status()
data = r.json()
cards_list.append(data)
time.sleep(0.1)
except requests.RequestException as e:
print(f"Failed to fetch {url}: {e}")

return cards_list


@dg.asset(deps=[extract_card_info], kinds={"Polars"})
def create_card_dataframe() -> pl.DataFrame:
cards_list = extract_card_info()

all_flat_cards = []

for card in cards_list:
flat = {}

# Copy top-level scalar values
scalar_keys = ['category', 'hp', 'id', 'illustrator', 'image', 'localId',
'name', 'rarity', 'regulationMark', 'retreat', 'stage']
for key in scalar_keys:
flat[key] = card.get(key)

# Flatten nested dicts with prefixes
for key, value in card.get("legal", {}).items():
flat[f"legal_{key}"] = value

for key, value in card.get("set", {}).items():
if isinstance(value, dict):
for sub_key, sub_val in value.items():
flat[f"set_{key}_{sub_key}"] = sub_val
else:
flat[f"set_{key}"] = value

# Flatten types (list of strings)
flat["types"] = ", ".join(card.get("types", []))

flat["attacks_json"] = json.dumps(card.get("attacks", []), ensure_ascii=False)

attacks = card.get("attacks", [])
for i, atk in enumerate(attacks):
prefix = f"attack_{i+1}"
flat[f"{prefix}_name"] = atk.get("name")
flat[f"{prefix}_damage"] = atk.get("damage")
flat[f"{prefix}_effect"] = atk.get("effect")
flat[f"{prefix}_cost"] = ", ".join(atk.get("cost", []))

all_flat_cards.append(flat)

df = pl.DataFrame(all_flat_cards)

return df
Loading
Loading