#!/bin/bash

config_path=$1

if [ "$config_path" == "" ];
then
  echo "Please provide a configuration file."
  exit 1
fi

./example/compose/nginx/portal/render.js

./scripts/utils/prepare-environment.sh

./node_modules/.bin/typescript-json-schema -o server/src/lib/configuration/Configuration.schema.json --strictNullChecks --required server/tsconfig.json Configuration

server_watcher="./node_modules/.bin/nodemon -e yml,js,ts,json --exec ./scripts/run-dev-server.sh $config_path 2>&1 /tmp/authelia-server.log"
client_watcher="cd client && BROWSER=none npm run start > /tmp/authelia-client.log"

./node_modules/.bin/concurrently "$server_watcher" "$client_watcher"