#!/usr/bin/env bash
set -euo pipefail

root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
vendor="${root}/vendor/mtranserver"

test -f "${vendor}/package.json"
test -f "${vendor}/bun.lock"
test -f "${vendor}/scripts/build.ts"
test -f "${vendor}/src/main.ts"
test -f "${vendor}/ui/package.json"
test -f "${vendor}/PROVENANCE.md"
grep -Fq '"version": "4.0.33"' "${vendor}/package.json"
grep -Fq 'Source commit: f5672a9' "${vendor}/PROVENANCE.md"

for generated in .git dist node_modules release migrate_ws; do
  if test -e "${vendor}/${generated}"; then
    echo "vendored source contains generated path: ${generated}" >&2
    exit 1
  fi
done
