#!/bin/bash
set -e

REPO="https://grafana.github.io/helm-charts"
VERSION="6.1.10"
CHART="grafana"

if [ ! -d charts ]; then
  # Fetch the helm chart so that we have a vendored copy
  helm fetch \
    --untar \
    --repo="$REPO" \
    --version="$VERSION" \
    --destination="charts/" \
    $CHART

  # Clean up the tarball that helm leaves
  # behind after unpacking the chart
  rm -r "charts/$CHART-$VERSION.tgz"
fi

# Our typescript code will be built and written to "./dist"
# so we'll copy our charts/ folder in there as well
mkdir -p ./dist || true
cp -r ./charts ./dist/
