#!/bin/bash

# exit on any error
set -e

echo Building…
npm run build

echo Cleaning example app…
cd ./examples/example-app
rm -rf node_modules package.json package-lock.json

echo Installing deps…
npm init -y
npm i next@latest typescript@latest react@latest react-dom@latest @types/react@latest ../../

echo Building example app…
npx next build

echo Testing that the preval worked…
../../scripts/download-from-next-server . / | grep hello_world
../../scripts/download-from-next-server . /api/hello | grep hello_world
