Files
2026-10-04 00:30:09 +07:00

57 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# Real Modrinth integration in a disposable Git clone. Never changes runtime.
set -euo pipefail
task_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$task_root"
task_check=$(mktemp -d "$task_root/.tools/phase3-check.XXXXXX")
printf '%s\n' "$task_check" > .tools/phase3-check-path
mkdir "$task_check/source"
git ls-files --cached --others --exclude-standard -z > "$task_check/files.list"
tar --null -T "$task_check/files.list" -cf "$task_check/source.tar"
tar --no-same-owner -xf "$task_check/source.tar" -C "$task_check/source"
git -C "$task_check/source" init -q
git -C "$task_check/source" add -A
git -C "$task_check/source" -c user.name='Phase 3 verification' -c user.email='phase3@localhost' commit -qm 'Temporary integration snapshot'
git clone -q "$task_check/source" "$task_check/clone"
cd "$task_check/clone"
ln -s "$task_root/node_modules" node_modules
mkdir -p .tools/packwiz
cp "$task_root/.tools/packwiz/packwiz" .tools/packwiz/packwiz
cp "$task_root/.tools/docker-compose" .tools/docker-compose
task_version() {
sed -i "s/^version = \".*\"$/version = \"$1\"/" pack/pack.toml
(cd pack && ../.tools/packwiz/packwiz --cache ../.tools/packwiz/cache --config ../.tools/packwiz/config.toml refresh)
}
./mcpack remove sophisticated-backpacks --yes
test ! -e pack/mods/sophisticated-backpacks.pw.toml
task_version phase3-remove
./mcpack build
./mcpack add https://modrinth.com/mod/sophisticated-backpacks/version/pJxNzk4X --yes
rg -q 'version = "pJxNzk4X"' pack/mods/sophisticated-backpacks.pw.toml
task_version phase3-add
./mcpack build
./mcpack update sophisticated-backpacks --yes
if rg -q 'version = "pJxNzk4X"' pack/mods/sophisticated-backpacks.pw.toml; then
echo 'Expected update away from older Backpacks version' >&2
exit 1
fi
task_version phase3-update
./mcpack build
# Seed the older version again so --all proves an actual update, not just no-op.
./mcpack add https://modrinth.com/mod/sophisticated-backpacks/version/pJxNzk4X --yes
rg -q 'version = "pJxNzk4X"' pack/mods/sophisticated-backpacks.pw.toml
./mcpack update --all --yes
if rg -q 'version = "pJxNzk4X"' pack/mods/sophisticated-backpacks.pw.toml; then
echo 'Expected update --all to replace older Backpacks version' >&2
exit 1
fi
task_version phase3-all
./mcpack build
git diff -- pack > "$task_check/source-changes.diff"
printf 'PASS: remove, add pinned version, update one, update all; four full builds.\nClone: %s\n' "$task_check/clone"