#!/bin/sh -eu

echo '
WARNING:

    This script aggressively updates all packages to the latest version.
    Be sure to run tests & check the application after this!

'

cd "$RUN_DIR"

[ -z "${DEBUG:-}" ] || set -x


# Uv

uv sync --upgrade

uv tree --outdated --no-dev \
| sed -nE 's/.*─ ([^ ]+) (v[^ ]+) \(latest: v([^)]+)\)/\1>=\3/p' \
| xargs uv add

uv tree --outdated --only-dev \
| sed -nE 's/.*─ ([^ ]+) (v[^ ]+) \(latest: v([^)]+)\)/\1>=\3/p' \
| xargs uv add --dev


# Npm

cd unwind-ui
npm update

npm outdated --json --silent \
| jq -r 'keys|map(@sh"\(.)@latest")|join("\n")' \
| xargs npm install
