Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist/
schema.min.json
schema.jsonl
upstream.min.json

# Logs
logs
Expand Down
45 changes: 45 additions & 0 deletions bin/diff-dat-schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR/.." || exit

BOLD="$(tput bold)"
NORM="$(tput sgr0)"

TMPD=$(mktemp -d .dat-schema-XXX)
trap 'rm -rf -- "$TMPD"' EXIT

filter() {
jq '.tables | sort_by(.name)[] | select(.validFor == '"$1"' or .validFor == 3) | del(.validFor)' "$2" > "$3"
}

UPSTREAM="upstream.min.json"
NEW="schema.min.json"

# -c won't download unless upstream is newer
wget -O "$UPSTREAM" -q -c https://github.com/poe-tool-dev/dat-schema/releases/download/latest/schema.min.json

CHANGES=no

for V in 1 2
do
UPSTREAMV="$TMPD/upstream.$V.json"
NEWV="$TMPD/schema.$V.json"
TMPV="$TMPD/schema.$V.diff"
filter "$V" "$UPSTREAM" "$UPSTREAMV"
filter "$V" "$NEW" "$NEWV"
if ! diff -u "$UPSTREAMV" "$NEWV" > "$TMPV"
then
CHANGES=yes
echo "${BOLD}Changes for Version $V:${NORM}"
tail -n +3 < "$TMPV"
echo
fi
done

if [ "$CHANGES" == "yes" ]
then
echo "Note: The above diff is against the published schema which may be behind the main branch"
else
echo "No changes detected"
fi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"exports": "./dist/index.js",
"scripts": {
"generate": "tsc --noCheck && node dist/cli.js",
"generate:watch": "tsc --noCheck && node dist/cli.js --watch"
"generate:watch": "tsc --noCheck && node dist/cli.js --watch",
"diff": "./bin/diff-dat-schema"
},
"files": [
"dist/index.*",
Expand Down