#!/bin/sh -e
# see discussion at https://lists.debian.org/debian-r/2022/08/msg00009.html

rm -rf scatterD3
git clone https://github.com/juba/scatterD3
cd scatterD3
if ! apt-cache npm > /dev/null 2>/dev/null ; then
    sudo apt install npm
fi
if ! apt-cache packer > /dev/null 2>/dev/null ; then
    sudo apt install packer
fi
if ! apt-cache libcurl4-openssl-dev > /dev/null 2>/dev/null ; then
    sudo apt install libcurl4-openssl-dev
fi
if ! apt-cache libxml2-dev > /dev/null 2>/dev/null ; then
    sudo apt install libxml2-dev
fi

# rather trust npm to install webpack
# if ! apt-cache webpack > /dev/null 2>/dev/null ; then
#    sudo apt install webpack
#fi
#if ! apt-cache node-webpack-merge > /dev/null 2>/dev/null ; then
#    sudo apt install node-webpack-merge
#fi
npm install --production=false
LC_ALL=C R --no-save <<EOT
install.packages("packer")
packer::bundle_prod()
EOT
