Skip to content

Commit df28b19

Browse files
Merge pull request #180 from digitalghost-dev/v1.6.1
V1.6.1
2 parents 999f800 + be78f30 commit df28b19

25 files changed

+607
-172
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on:
3030
- main
3131

3232
env:
33-
VERSION_NUMBER: 'v1.6.0'
33+
VERSION_NUMBER: 'v1.6.1'
3434
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
3535
AWS_REGION: 'us-west-2'
3636

.goreleaser.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ builds:
1414
- windows
1515
- darwin
1616
ldflags:
17-
- -s -w -X main.version=v1.6.0
17+
- -s -w -X main.version=v1.6.1
1818

1919
archives:
2020
- formats: [ 'zip' ]
@@ -39,37 +39,28 @@ changelog:
3939

4040
homebrew_casks:
4141
- name: poke-cli
42+
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
43+
homepage: "https://docs.poke-cli.com/"
44+
license: MIT
4245
conflicts:
4346
- formula: poke-cli
4447
repository:
4548
owner: digitalghost-dev
4649
name: homebrew-tap
4750
token: "{{.Env.GITHUB_TOKEN}}"
48-
homepage: "https://docs.poke-cli.com/"
49-
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
50-
license: "Apache License 2.0"
5151
hooks:
5252
post:
5353
install: |
5454
if OS.mac? && system_command("/usr/bin/xattr", args: ["-h"]).exit_status == 0
5555
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/poke-cli"]
5656
end
5757
58-
winget:
58+
scoops:
5959
- name: poke-cli
60-
publisher: digitalghost-dev
61-
license: MIT
60+
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
6261
homepage: "https://docs.poke-cli.com/"
63-
short_description: "Pokémon CLI/TUI terminal tool."
62+
license: MIT
6463
repository:
6564
owner: digitalghost-dev
66-
name: winget-pkgs
67-
token: "{{.Env.GITHUB_TOKEN}}"
68-
branch: "poke-cli-{{.Version}}"
69-
pull_request:
70-
enabled: true
71-
base:
72-
owner: microsoft
73-
name: winget-pkgs
74-
branch: master
75-
description: "A hybrid CLI/TUI tool written in Go for viewing Pokémon data from the terminal!"
65+
name: scoop-bucket
66+
token: "{{ .Env.GITHUB_TOKEN }}"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN go mod download
88

99
COPY . .
1010

11-
RUN go build -ldflags "-X main.version=v1.6.0" -o poke-cli .
11+
RUN go build -ldflags "-X main.version=v1.6.1" -o poke-cli .
1212

1313
# build 2
1414
FROM --platform=$BUILDPLATFORM alpine:3.22

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
33
<h1>Pokémon CLI</h1>
44
<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">
5-
<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">
5+
<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">
66
<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">
77
</div>
88
<div align="center">
@@ -30,7 +30,7 @@ View future plans in the [Roadmap](#roadmap) section.
3030
## Installation
3131

3232
* [Homebrew](#homebrew)
33-
* [Winget](#winget)
33+
* [Scoop](#scoop)
3434
* [Linux Packages](#linux-packages)
3535
* [Docker Image](#docker-image)
3636
* [Binary](#binary)
@@ -42,19 +42,24 @@ View future plans in the [Roadmap](#roadmap) section.
4242
```bash
4343
brew install --cask digitalghost-dev/tap/poke-cli
4444
````
45-
2. Verify install:
45+
2. Verify installation:
4646
```bash
4747
poke-cli -v
4848
```
4949

50-
### Winget
51-
1. Install the package:
50+
### Scoop
51+
1. Add the bucket:
5252
```powershell
53-
winget install poke-cli
53+
scoop bucket add digitalghost https://github.com/digitalghost-dev/scoop-bucket.git
5454
```
5555

56-
2. Verify install:
57-
```bash
56+
2. Install poke-cli:
57+
```powershell
58+
scoop install poke-cli
59+
```
60+
61+
3. Verify installation:
62+
```powershell
5863
poke-cli -v
5964
```
6065

@@ -86,11 +91,11 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
8691
3. Choose how to interact with the container:
8792
* Run a single command and exit:
8893
```bash
89-
docker run --rm -it digitalghostdev/poke-cli:v1.6.0 <command> [subcommand] flag]
94+
docker run --rm -it digitalghostdev/poke-cli:v1.6.1 <command> [subcommand] flag]
9095
```
9196
* Enter the container and use its shell:
9297
```bash
93-
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.6.0 -c "cd /app && exec sh"
98+
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.6.1 -c "cd /app && exec sh"
9499
# placed into the /app directory, run the program with './poke-cli'
95100
# example: ./poke-cli ability swift-swim
96101
```
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
provider "aws" {
2-
profile = "terraform-user"
3-
region = "us-west-2"
2+
region = "us-west-2"
43
}
54

65
terraform {
7-
required_providers {
8-
aws = {
9-
version = "~> 6.7.0"
10-
}
6+
cloud {
7+
organization = "digitalghost-dev"
8+
9+
workspaces {
10+
project = "poke-cli"
11+
name = "poke-cli"
12+
}
1113
}
12-
}
14+
required_providers {
15+
aws = {
16+
source = "hashicorp/aws"
17+
version = "~> 6.7.0"
18+
}
19+
}
20+
}

card_data/pipelines/definitions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from pathlib import Path
2+
from dagster import definitions, load_from_defs_folder
3+
4+
5+
@definitions
6+
def defs():
7+
return load_from_defs_folder(project_root=Path(__file__).parent.parent)
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import time
2+
import json
3+
4+
import dagster as dg
5+
import polars as pl
6+
7+
from pydantic import BaseModel, HttpUrl, ValidationError
8+
from typing import Optional
9+
from termcolor import colored
10+
11+
import requests
12+
13+
class Series(BaseModel):
14+
id: str
15+
name: str
16+
logo: Optional[HttpUrl] = None
17+
18+
19+
class Set(BaseModel):
20+
series_id: str
21+
set_id: str
22+
set_name: str
23+
official_card_count: int | None
24+
total_card_count: int | None
25+
logo: Optional[str] = None
26+
symbol: Optional[str] = None
27+
28+
29+
@dg.asset(kinds={"API", "Polars", "Pydantic"})
30+
def extract_series_data() -> pl.DataFrame:
31+
url: str = "https://api.tcgdex.net/v2/en/series"
32+
data = requests.get(url).json()
33+
34+
# Pydantic validation
35+
try:
36+
validated: list[Series] = [Series(**item) for item in data]
37+
print(
38+
colored(" ✓", "green"), "Pydantic validation passed for all series entries."
39+
)
40+
except ValidationError as e:
41+
print(colored(" ✖", "red"), "Pydantic validation failed.")
42+
print(e)
43+
raise
44+
45+
filtered = [s.model_dump(mode="json") for s in validated if s.id in ["swsh", "sv"]]
46+
return pl.DataFrame(filtered)
47+
48+
49+
@dg.asset(kinds={"API", "Polars", "Pydantic"})
50+
def extract_set_data() -> pl.DataFrame:
51+
url_list = [
52+
"https://api.tcgdex.net/v2/en/series/swsh",
53+
"https://api.tcgdex.net/v2/en/series/sv"
54+
]
55+
56+
flat: list[dict] = []
57+
58+
for url in url_list:
59+
data = requests.get(url).json()
60+
series_id = data.get("id")
61+
62+
for s in data.get("sets", []):
63+
entry = {
64+
"series_id": series_id,
65+
"set_id": s.get("id"),
66+
"set_name": s.get("name"),
67+
"official_card_count": s.get("cardCount", {}).get("official"),
68+
"total_card_count": s.get("cardCount", {}).get("total"),
69+
"logo": s.get("logo"),
70+
"symbol": s.get("symbol")
71+
}
72+
flat.append(entry)
73+
74+
# Pydantic validation
75+
try:
76+
validated: list[Set] = [Set(**item) for item in flat]
77+
print(
78+
colored(" ✓", "green"),
79+
"Pydantic validation passed for all set entries."
80+
)
81+
except ValidationError as e:
82+
print(colored(" ✖", "red"), "Pydantic validation failed.")
83+
print(e)
84+
raise
85+
86+
return pl.DataFrame([s.model_dump(mode="json") for s in validated])
87+
88+
89+
@dg.asset(kinds={"API"})
90+
def extract_card_url_from_set() -> list:
91+
urls = [
92+
"https://api.tcgdex.net/v2/en/sets/sv01",
93+
"https://api.tcgdex.net/v2/en/sets/sv02",
94+
]
95+
96+
all_card_urls = [] # Initialize empty list to collect all URLs
97+
98+
for url in urls:
99+
try:
100+
r = requests.get(url)
101+
r.raise_for_status()
102+
103+
data = r.json()["cards"]
104+
105+
set_card_urls = [f"https://api.tcgdex.net/v2/en/cards/{card['id']}" for card in data]
106+
all_card_urls.extend(set_card_urls) # Add all URLs from this set
107+
108+
time.sleep(0.1)
109+
110+
except requests.RequestException as e:
111+
print(f"Failed to fetch set {url}: {e}")
112+
113+
return all_card_urls
114+
115+
116+
@dg.asset(deps=[extract_card_url_from_set], kinds={"API"})
117+
def extract_card_info() -> list:
118+
card_url_list = extract_card_url_from_set()
119+
cards_list = []
120+
121+
for url in card_url_list:
122+
try:
123+
r = requests.get(url)
124+
r.raise_for_status()
125+
data = r.json()
126+
cards_list.append(data)
127+
time.sleep(0.1)
128+
except requests.RequestException as e:
129+
print(f"Failed to fetch {url}: {e}")
130+
131+
return cards_list
132+
133+
134+
@dg.asset(deps=[extract_card_info], kinds={"Polars"})
135+
def create_card_dataframe() -> pl.DataFrame:
136+
cards_list = extract_card_info()
137+
138+
all_flat_cards = []
139+
140+
for card in cards_list:
141+
flat = {}
142+
143+
# Copy top-level scalar values
144+
scalar_keys = ['category', 'hp', 'id', 'illustrator', 'image', 'localId',
145+
'name', 'rarity', 'regulationMark', 'retreat', 'stage']
146+
for key in scalar_keys:
147+
flat[key] = card.get(key)
148+
149+
# Flatten nested dicts with prefixes
150+
for key, value in card.get("legal", {}).items():
151+
flat[f"legal_{key}"] = value
152+
153+
for key, value in card.get("set", {}).items():
154+
if isinstance(value, dict):
155+
for sub_key, sub_val in value.items():
156+
flat[f"set_{key}_{sub_key}"] = sub_val
157+
else:
158+
flat[f"set_{key}"] = value
159+
160+
# Flatten types (list of strings)
161+
flat["types"] = ", ".join(card.get("types", []))
162+
163+
flat["attacks_json"] = json.dumps(card.get("attacks", []), ensure_ascii=False)
164+
165+
attacks = card.get("attacks", [])
166+
for i, atk in enumerate(attacks):
167+
prefix = f"attack_{i+1}"
168+
flat[f"{prefix}_name"] = atk.get("name")
169+
flat[f"{prefix}_damage"] = atk.get("damage")
170+
flat[f"{prefix}_effect"] = atk.get("effect")
171+
flat[f"{prefix}_cost"] = ", ".join(atk.get("cost", []))
172+
173+
all_flat_cards.append(flat)
174+
175+
df = pl.DataFrame(all_flat_cards)
176+
177+
return df

0 commit comments

Comments
 (0)