#!/bin/bash

cd "$(dirname "$0")"

cp -R ../packages .
if [[ "$OSTYPE" == "darwin"* ]]; then
    sed -i '' -E 's/(file:)\.\.\/(packages\/)/\1.\/\2/g' package.json
    sed -i '' -E 's/(file:)\.\.\/(packages\/)/\1.\/\2/g' package-lock.json
else
    sed -i -E 's/(file:)\.\.\/(packages\/)/\1.\/\2/g' package.json
    sed -i -E 's/(file:)\.\.\/(packages\/)/\1.\/\2/g' package-lock.json
fi

cp -R ../packages ./server
cd ./server
if [[ "$OSTYPE" == "darwin"* ]]; then
    sed -i '' -E 's/(file:)\.\.\/\.\.\/(packages\/)/\1.\/\2/g' package.json
    sed -i '' -E 's/(file:)\.\.\/\.\.\/(packages\/)/\1.\/\2/g' package-lock.json
else
    sed -i -E 's/(file:)\.\.\/\.\.\/(packages\/)/\1.\/\2/g' package.json
    sed -i -E 's/(file:)\.\.\/\.\.\/(packages\/)/\1.\/\2/g' package-lock.json
fi
