@pietrovich/wot-utils 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "private": false,
7
7
  "repository": "github:pietrovich/wot-utils",
8
- "version": "0.2.0",
8
+ "version": "0.2.3",
9
9
  "description": "CLI utilities for World of Tanks data and assets",
10
10
  "type": "module",
11
11
  "bin": {
@@ -13,8 +13,7 @@
13
13
  },
14
14
  "files": [
15
15
  "./.env.example",
16
- "./dist",
17
- "./scripts"
16
+ "./dist"
18
17
  ],
19
18
  "scripts": {
20
19
  "build": "tsup",
@@ -36,6 +35,7 @@
36
35
  "commander": "^13.1.0",
37
36
  "dotenv": "^16.5.0",
38
37
  "fast-xml-parser": "^5.8.0",
38
+ "fflate": "^0.8.3",
39
39
  "json5": "^2.2.3",
40
40
  "maxrects-packer": "^2.7.3",
41
41
  "pino": "^10.3.1",
@@ -1,81 +0,0 @@
1
- SCRIPT_DIR="$(dirname "$0")"
2
- BASE_DIR="$SCRIPT_DIR/.."
3
- cd "$BASE_DIR"
4
-
5
- CLEAN=0
6
- SOURCE_DIR=""
7
-
8
- for arg in "$@"; do
9
- case "$arg" in
10
- --clean) CLEAN=1 ;;
11
- *) SOURCE_DIR="${arg##/}" ;;
12
- esac
13
- done
14
-
15
- if [ -z "$SOURCE_DIR" ]; then
16
- echo "Usage: $0 [--clean] <source-dir>" >&2
17
- exit 1
18
- fi
19
-
20
- if [ ! -d "$SOURCE_DIR" ]; then
21
- echo "Error: source directory not found: $SOURCE_DIR" >&2
22
- exit 1
23
- fi
24
-
25
- if [ "$CLEAN" -eq 1 ]; then
26
- rm -rf ./out/atlases ./out/icons
27
- find ./out -maxdepth 1 \( -name '*.png' -o -name '*.xml' -o -name '*.dds' \) -delete
28
- fi
29
-
30
- if [ ! -f "$SOURCE_DIR/battleAtlas.png" ] && [ -f "$SOURCE_DIR/battleAtlas.dds" ]; then
31
- npm -s start -- dds decode "$SOURCE_DIR/battleAtlas.dds"
32
- fi
33
-
34
- if [ ! -f "$SOURCE_DIR/vehicleMarkerAtlas.png" ] && [ -f "$SOURCE_DIR/vehicleMarkerAtlas.dds" ]; then
35
- npm -s start -- dds decode "$SOURCE_DIR/vehicleMarkerAtlas.dds"
36
- fi
37
-
38
- if [ -d ./out/atlases/battleAtlas ]; then
39
- echo "skipping battleAtlas extraction — ./out/atlases/battleAtlas already exists"
40
- else
41
- npm -s start -- atlas extract --from "$SOURCE_DIR/battleAtlas" --to ./out/atlases/battleAtlas
42
- cp -f "$SOURCE_DIR/battleAtlas.png" "$SOURCE_DIR/battleAtlas.xml" ./out/atlases/
43
- fi
44
-
45
- if [ -d ./out/atlases/vehicleMarkerAtlas ]; then
46
- echo "skipping vehicleMarkerAtlas extraction — ./out/atlases/vehicleMarkerAtlas already exists"
47
- else
48
- npm -s start -- atlas extract --from "$SOURCE_DIR/vehicleMarkerAtlas" --to ./out/atlases/vehicleMarkerAtlas
49
- cp -f "$SOURCE_DIR/vehicleMarkerAtlas.png" "$SOURCE_DIR/vehicleMarkerAtlas.xml" ./out/atlases/
50
- fi
51
-
52
- echo "warm up vehicle data cache"
53
- VEHICLES_COUNT="$(npm -s start -- vehicle list --all --json 2>/dev/null | jq length)"
54
- echo " $VEHICLES_COUNT vehicles processed"
55
-
56
- echo "warm up vehicle profile cache"
57
- PROFILES_COUNT="$(npm -s start -- vehicle stats --all --quiet --json | jq length)"
58
- echo " $PROFILES_COUNT vehicles processed"
59
-
60
- ICONS_COUNT="$(find ./out/icons -maxdepth 1 -name '*.png' 2>/dev/null | wc -l)"
61
-
62
- if [ "$ICONS_COUNT" -ge "$VEHICLES_COUNT" ]; then
63
- echo "skipping icons render — ./out/icons already has $ICONS_COUNT icons"
64
- else
65
- echo "generating icons"
66
- npm -s start -- icon render --all --color --to ./out/icons --bg v1 --create
67
- fi
68
-
69
- echo "overlaying generated icons into atlas directories"
70
- rsync -a --include='*.png' --exclude='*' ./out/icons/ ./out/atlases/battleAtlas/
71
- rsync -a --include='*.png' --exclude='*' ./out/icons/ ./out/atlases/vehicleMarkerAtlas/
72
-
73
- echo "replacing suffixed variants with base icons"
74
- "$SCRIPT_DIR/replace-suffixed-with-base.sh" ./out/atlases/battleAtlas "$BASE_DIR/out/icons"
75
- "$SCRIPT_DIR/replace-suffixed-with-base.sh" ./out/atlases/vehicleMarkerAtlas "$BASE_DIR/out/icons"
76
-
77
- npm -s start -- atlas pack --src ./out/atlases/vehicleMarkerAtlas --to ./out/vehicleMarkerAtlas
78
- npm -s start -- atlas pack --src ./out/atlases/battleAtlas --to ./out/battleAtlas
79
-
80
- mv ./out/battleAtlas.png ./out/battleAtlas.dds
81
- mv ./out/vehicleMarkerAtlas.png ./out/vehicleMarkerAtlas.dds
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- # shellcheck source=baker-lib.sh
4
- source "$(cd "$(dirname "$0")" && pwd)/baker-lib.sh"
5
-
6
- parse_args "$(basename "$0")" "$@" || exit 1
7
- pogs_pipeline --clear
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- # shellcheck source=baker-lib.sh
4
- source "$(cd "$(dirname "$0")" && pwd)/baker-lib.sh"
5
-
6
- parse_args "$(basename "$0")" "$@" || exit 1
7
- pogs_pipeline --color --bg v1
@@ -1,165 +0,0 @@
1
- #!/usr/bin/env bash
2
- # baker-lib.sh — shared build step functions for icon bake scripts.
3
- # Source this file; do not execute it directly.
4
-
5
- _CWD=$(pwd)
6
- _LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
- _BASE_DIR="$_LIB_DIR/.."
8
-
9
- # Load .env from cwd if present (picks up LOCAL_DEV and similar vars).
10
- if [ -f "$_CWD/.env" ]; then
11
- set -a
12
- # shellcheck source=/dev/null
13
- source "$_CWD/.env"
14
- set +a
15
- fi
16
-
17
- # Resolve CLI: LOCAL_DEV forces npm-start (dev clone), otherwise use installed binary.
18
- if [ -n "${LOCAL_DEV:-}" ] || ! command -v pie-wot >/dev/null 2>&1; then
19
- PIE_WOT=(npm -s start --prefix="$_BASE_DIR" --)
20
- else
21
- PIE_WOT=(pie-wot)
22
- fi
23
-
24
- # Shared state — set by parse_args, consumed by step functions.
25
- CLEAN=0
26
- SRC=""
27
- OUT=""
28
- BUILD=""
29
- VEHICLES_COUNT=0
30
-
31
- parse_args() {
32
- local script_name="$1"
33
- shift
34
- CLEAN=0
35
- SRC=""
36
- OUT=""
37
-
38
- while [ $# -gt 0 ]; do
39
- case "$1" in
40
- --src) SRC="$2"; shift 2 ;;
41
- --out) OUT="$2"; shift 2 ;;
42
- --clean) CLEAN=1; shift ;;
43
- *)
44
- if [ -z "$SRC" ]; then SRC="$1"
45
- elif [ -z "$OUT" ]; then OUT="$1"
46
- else echo "Error: unexpected argument: $1" >&2; return 1
47
- fi
48
- shift ;;
49
- esac
50
- done
51
-
52
- if [ -z "$SRC" ] || [ -z "$OUT" ]; then
53
- echo "Usage: $script_name [--clean] [--src] <src-dir> [--out] <out-dir>" >&2
54
- return 1
55
- fi
56
-
57
- if [ ! -d "$SRC" ]; then
58
- echo "Error: source directory not found: $SRC" >&2
59
- return 1
60
- fi
61
-
62
- SRC="$(cd "$SRC" && pwd)"
63
- mkdir -p "$OUT"
64
- OUT="$(cd "$OUT" && pwd)"
65
- BUILD="$OUT/.build"
66
- }
67
-
68
- clean_build() {
69
- rm -rf "$OUT/.build" "$OUT/gui"
70
- find "$OUT" -maxdepth 1 \( -name '*.png' -o -name '*.xml' -o -name '*.dds' \) -delete
71
- }
72
-
73
- decode_dds() {
74
- if [ ! -f "$SRC/battleAtlas.png" ] && [ -f "$SRC/battleAtlas.dds" ]; then
75
- "${PIE_WOT[@]}" dds decode "$SRC/battleAtlas.dds"
76
- fi
77
- if [ ! -f "$SRC/vehicleMarkerAtlas.png" ] && [ -f "$SRC/vehicleMarkerAtlas.dds" ]; then
78
- "${PIE_WOT[@]}" dds decode "$SRC/vehicleMarkerAtlas.dds"
79
- fi
80
- }
81
-
82
- extract_atlases() {
83
- if [ -d "$BUILD/atlases/battleAtlas" ]; then
84
- echo "skipping battleAtlas extraction — $BUILD/atlases/battleAtlas already exists"
85
- else
86
- "${PIE_WOT[@]}" atlas extract --from "$SRC/battleAtlas" --to "$BUILD/atlases/battleAtlas"
87
- cp -f "$SRC/battleAtlas.png" "$SRC/battleAtlas.xml" "$BUILD/atlases/"
88
- fi
89
-
90
- if [ -d "$BUILD/atlases/vehicleMarkerAtlas" ]; then
91
- echo "skipping vehicleMarkerAtlas extraction — $BUILD/atlases/vehicleMarkerAtlas already exists"
92
- else
93
- "${PIE_WOT[@]}" atlas extract --from "$SRC/vehicleMarkerAtlas" --to "$BUILD/atlases/vehicleMarkerAtlas"
94
- cp -f "$SRC/vehicleMarkerAtlas.png" "$SRC/vehicleMarkerAtlas.xml" "$BUILD/atlases/"
95
- fi
96
- }
97
-
98
- warm_cache() {
99
- echo "warm up vehicle data cache"
100
- VEHICLES_COUNT="$("${PIE_WOT[@]}" vehicle list --all --json 2>/dev/null | jq length)"
101
- echo " $VEHICLES_COUNT vehicles processed"
102
-
103
- echo "warm up vehicle profile cache"
104
- local profiles_count
105
- profiles_count="$("${PIE_WOT[@]}" vehicle stats --all --quiet --json | jq length)"
106
- echo " $profiles_count vehicles processed"
107
- }
108
-
109
- # render_icons <icon-render-flags...>
110
- # Skips if $BUILD/icons already contains at least $VEHICLES_COUNT PNGs.
111
- render_icons() {
112
- local icons_count
113
- icons_count="$(find "$BUILD/icons" -maxdepth 1 -name '*.png' 2>/dev/null | wc -l)"
114
-
115
- if [ "$icons_count" -ge "$VEHICLES_COUNT" ]; then
116
- echo "skipping icons render — $BUILD/icons already has $icons_count icons"
117
- return 0
118
- fi
119
-
120
- echo "generating icons"
121
- mkdir -p "$BUILD/icons"
122
- "${PIE_WOT[@]}" icon render --all --to "$BUILD/icons" "$@" || return 1
123
- }
124
-
125
- overlay_icons() {
126
- echo "overlaying generated icons into atlas directories"
127
- rsync -a --include='*.png' --exclude='*' "$BUILD/icons/" "$BUILD/atlases/battleAtlas/"
128
- rsync -a --include='*.png' --exclude='*' "$BUILD/icons/" "$BUILD/atlases/vehicleMarkerAtlas/"
129
- }
130
-
131
- replace_suffixed() {
132
- echo "replacing suffixed variants with base icons"
133
- "$_LIB_DIR/replace-suffixed-with-base.sh" "$BUILD/atlases/battleAtlas" "$BUILD/icons"
134
- "$_LIB_DIR/replace-suffixed-with-base.sh" "$BUILD/atlases/vehicleMarkerAtlas" "$BUILD/icons"
135
- }
136
-
137
- pack_atlases() {
138
- mkdir -p "$OUT/gui/flash/atlases"
139
- "${PIE_WOT[@]}" atlas pack --src "$BUILD/atlases/vehicleMarkerAtlas" --to "$OUT/gui/flash/atlases/vehicleMarkerAtlas"
140
- "${PIE_WOT[@]}" atlas pack --src "$BUILD/atlases/battleAtlas" --to "$OUT/gui/flash/atlases/battleAtlas"
141
- mv "$OUT/gui/flash/atlases/battleAtlas.png" "$OUT/gui/flash/atlases/battleAtlas.dds"
142
- mv "$OUT/gui/flash/atlases/vehicleMarkerAtlas.png" "$OUT/gui/flash/atlases/vehicleMarkerAtlas.dds"
143
- }
144
-
145
- copy_contour() {
146
- mkdir -p "$OUT/gui/flash/maps/icons/vehicle/contour/"
147
- rsync -a --include='*.png' --exclude='*' "$BUILD/icons/" "$OUT/gui/flash/maps/icons/vehicle/contour/"
148
- }
149
-
150
- # pogs_pipeline <icon-render-flags...>
151
- # Full pogs icon bake: decode → extract → warm cache → render → overlay → replace → pack → copy.
152
- pogs_pipeline() {
153
- cd "$_BASE_DIR" || return 1
154
-
155
- [ "$CLEAN" -eq 1 ] && clean_build
156
-
157
- decode_dds
158
- extract_atlases
159
- warm_cache
160
- render_icons "$@" || return 1
161
- overlay_icons
162
- replace_suffixed
163
- pack_atlases
164
- copy_contour
165
- }
@@ -1,120 +0,0 @@
1
- #Requires -Version 5.1
2
- param(
3
- [Parameter(Position = 0)]
4
- [string]$Src,
5
-
6
- [Parameter(Position = 1)]
7
- [string]$Out,
8
-
9
- [switch]$Help
10
- )
11
-
12
- $TargetFiles = @(
13
- "gui/flash/atlases/battleAtlas.dds"
14
- "gui/flash/atlases/battleAtlas.xml"
15
- "gui/flash/atlases/vehicleMarkerAtlas.dds"
16
- "gui/flash/atlases/vehicleMarkerAtlas.xml"
17
- )
18
-
19
- function Show-Usage {
20
- Write-Host @"
21
- Usage: extract-atlas-assets.ps1 [-Src] <src-dir> [-Out] <out-dir>
22
-
23
- Extract battle and vehicle marker atlas files from a World of Tanks installation.
24
-
25
- Arguments:
26
- <src-dir> Path to the WoT game directory. The script searches it recursively
27
- for gui-partN.pkg files (zip archives) and scans their index for
28
- the target atlas files.
29
-
30
- <out-dir> Directory where extracted files are dropped (flat, no subdirs).
31
- Created automatically if it does not exist.
32
-
33
- Extracted files:
34
- battleAtlas.dds
35
- battleAtlas.xml
36
- vehicleMarkerAtlas.dds
37
- vehicleMarkerAtlas.xml
38
-
39
- Options:
40
- -Src <dir> Explicit form for <src-dir>
41
- -Out <dir> Explicit form for <out-dir>
42
- -Help Show this message and exit
43
-
44
- Both positional and named forms may be mixed freely.
45
- "@
46
- }
47
-
48
- if ($Help) {
49
- Show-Usage
50
- exit 0
51
- }
52
-
53
- if (-not $Src -or -not $Out) {
54
- Show-Usage
55
- exit 1
56
- }
57
-
58
- if (-not (Test-Path -LiteralPath $Src -PathType Container)) {
59
- Write-Error "Source directory does not exist: $Src"
60
- exit 1
61
- }
62
-
63
- if (-not (Test-Path -LiteralPath $Out)) {
64
- New-Item -ItemType Directory -Path $Out | Out-Null
65
- }
66
-
67
- Add-Type -AssemblyName System.IO.Compression.FileSystem
68
-
69
- $pkgFiles = Get-ChildItem -Path $Src -Recurse -File |
70
- Where-Object { $_.Name -match '^gui-part\d+\.pkg$' }
71
-
72
- if (-not $pkgFiles) {
73
- Write-Error "No gui-partN.pkg files found in: $Src"
74
- exit 1
75
- }
76
-
77
- foreach ($pkgFile in $pkgFiles) {
78
- Write-Host "Checking: $($pkgFile.FullName)"
79
-
80
- try {
81
- $zip = [System.IO.Compression.ZipFile]::OpenRead($pkgFile.FullName)
82
- } catch {
83
- Write-Warning " Failed to read archive, skipping: $_"
84
- continue
85
- }
86
-
87
- try {
88
- $entryNames = $zip.Entries | ForEach-Object { $_.FullName }
89
- $toExtract = @($TargetFiles | Where-Object { $entryNames -contains $_ })
90
-
91
- if ($toExtract.Count -eq 0) {
92
- Write-Host " No target files."
93
- continue
94
- }
95
-
96
- Write-Host " Extracting $($toExtract.Count) file(s): $($toExtract -join ', ')"
97
-
98
- foreach ($target in $toExtract) {
99
- $entry = $zip.GetEntry($target)
100
- $leafName = $target.Split('/')[-1]
101
- $destPath = Join-Path $Out $leafName
102
-
103
- $srcStream = $entry.Open()
104
- try {
105
- $destStream = [System.IO.File]::Create($destPath)
106
- try {
107
- $srcStream.CopyTo($destStream)
108
- } finally {
109
- $destStream.Dispose()
110
- }
111
- } finally {
112
- $srcStream.Dispose()
113
- }
114
-
115
- Write-Host " -> $leafName"
116
- }
117
- } finally {
118
- $zip.Dispose()
119
- }
120
- }
@@ -1,116 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- TARGET_FILES=(
5
- "gui/flash/atlases/battleAtlas.dds"
6
- "gui/flash/atlases/battleAtlas.xml"
7
- "gui/flash/atlases/vehicleMarkerAtlas.dds"
8
- "gui/flash/atlases/vehicleMarkerAtlas.xml"
9
- )
10
-
11
- usage() {
12
- cat <<EOF
13
- Usage: $(basename "$0") [--src] <src-dir> [--out] <out-dir>
14
-
15
- Extract battle and vehicle marker atlas files from a World of Tanks installation.
16
-
17
- Arguments:
18
- <src-dir> Path to the WoT game directory. The script searches it recursively
19
- for gui-partN.pkg files (zip archives) and scans their index for
20
- the target atlas files.
21
-
22
- <out-dir> Directory where extracted files are dropped (flat, no subdirs).
23
- Created automatically if it does not exist.
24
-
25
- Extracted files:
26
- battleAtlas.dds
27
- battleAtlas.xml
28
- vehicleMarkerAtlas.dds
29
- vehicleMarkerAtlas.xml
30
-
31
- Options:
32
- --src <dir> Explicit form for <src-dir>
33
- --out <dir> Explicit form for <out-dir>
34
- --help Show this message and exit
35
-
36
- Both positional and named forms may be mixed freely.
37
- EOF
38
- }
39
-
40
- SRC=""
41
- OUT=""
42
-
43
- while [[ $# -gt 0 ]]; do
44
- case "$1" in
45
- --src)
46
- SRC="$2"
47
- shift 2
48
- ;;
49
- --out)
50
- OUT="$2"
51
- shift 2
52
- ;;
53
- --help|-h)
54
- usage
55
- exit 0
56
- ;;
57
- -*)
58
- echo "Error: unknown option: $1" >&2
59
- exit 1
60
- ;;
61
- *)
62
- if [[ -z "$SRC" ]]; then
63
- SRC="$1"
64
- elif [[ -z "$OUT" ]]; then
65
- OUT="$1"
66
- else
67
- echo "Error: unexpected argument: $1" >&2
68
- exit 1
69
- fi
70
- shift
71
- ;;
72
- esac
73
- done
74
-
75
- if [[ -z "$SRC" || -z "$OUT" ]]; then
76
- usage >&2
77
- exit 1
78
- fi
79
-
80
- if [[ ! -d "$SRC" ]]; then
81
- echo "Error: source directory does not exist: $SRC" >&2
82
- exit 1
83
- fi
84
-
85
- mkdir -p "$OUT"
86
-
87
- found_any=0
88
- while IFS= read -r -d '' pkg_file; do
89
- found_any=1
90
- echo "Checking: $pkg_file"
91
-
92
- # Read only the central directory (TOC) — no decompression
93
- archive_index=$(zipinfo -1 "$pkg_file" 2>/dev/null) || {
94
- echo " Warning: failed to read archive index, skipping." >&2
95
- continue
96
- }
97
-
98
- files_to_extract=()
99
- for target in "${TARGET_FILES[@]}"; do
100
- if grep -qxF "$target" <<< "$archive_index"; then
101
- files_to_extract+=("$target")
102
- fi
103
- done
104
-
105
- if [[ ${#files_to_extract[@]} -gt 0 ]]; then
106
- echo " Extracting ${#files_to_extract[@]} file(s): ${files_to_extract[*]}"
107
- unzip -oj "$pkg_file" "${files_to_extract[@]}" -d "$OUT"
108
- else
109
- echo " No target files."
110
- fi
111
- done < <(find "$SRC" -regextype posix-extended -regex ".*/gui-part[0-9]+\.pkg" -print0)
112
-
113
- if [[ $found_any -eq 0 ]]; then
114
- echo "No gui-partN.pkg files found in: $SRC" >&2
115
- exit 1
116
- fi
@@ -1,44 +0,0 @@
1
- ATLAS_DIR="$1"
2
- ICONS_DIR="$2"
3
-
4
- if [ -z "$ATLAS_DIR" ]; then
5
- echo "Usage: $0 <atlas-dir> [icons-dir]" >&2
6
- exit 1
7
- fi
8
-
9
- if [ ! -d "$ATLAS_DIR" ]; then
10
- echo "Error: directory not found: $ATLAS_DIR" >&2
11
- exit 1
12
- fi
13
-
14
- EXCLUDED=(
15
- "battleLoadingFormBgTips.png"
16
- "battleLoadingFormBgTips_7x7.png"
17
- )
18
-
19
- is_excluded() {
20
- local name="$1"
21
- for ex in "${EXCLUDED[@]}"; do
22
- if [ "$name" = "$ex" ]; then
23
- return 0
24
- fi
25
- done
26
- return 1
27
- }
28
-
29
- find "$ATLAS_DIR" -maxdepth 1 -name '*_7x7.png' -o -name '*_bob.png' -o -name '*_IGR.png' | while read -r suffixed; do
30
- filename="$(basename "$suffixed")"
31
- if is_excluded "$filename"; then
32
- continue
33
- fi
34
- base="${suffixed%_*.png}.png"
35
- if is_excluded "$(basename "$base")"; then
36
- continue
37
- fi
38
- if [ -f "$base" ]; then
39
- cp "$base" "$suffixed"
40
- if [ -d "$ICONS_DIR" ]; then
41
- cp "$suffixed" "$ICONS_DIR/"
42
- fi
43
- fi
44
- done