#!/usr/bin/env bash

set -euo pipefail

##
# NOTE: Formatting for these tokens is specific to the auto-formatter.
##

# Jira Credentials
echo "export default {
  username: '',
  password: '',
};" > src/tokens/jira-creds.ts

# Google Calendar 'Creds'
echo "export default {
  installed: {
    client_id: '',
    project_id: '',
    auth_uri: '',
    token_uri: '',
    auth_provider_x509_cert_url: '',
    client_secret: '',
    redirect_uris: ['', ''],
  },
};" > src/tokens/google-calendar-creds.ts

# Google Calendar 'Token'
echo "export default {
  access_token: '',
  refresh_token: '',
  scope: '',
  token_type: '',
  expiry_date: 0,
};" > src/tokens/google-calendar-token.ts

# Github token
echo "export default {
  variables: {
    gitHubToken: '',
  },
};" > src/tokens/github-token.ts

# Slack token
echo "export default {
  token: '',
};" > src/tokens/slack-token.ts

# Install Yarn
if ! hash yarn > /dev/null 2>&1; then
    curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt-get update
    sudo apt-get install --assume-yes yarn
fi

# Install dependencies.
yarn install --frozen-lockfile

# Make sure files follow formatting guidelines.
yarn lint:dry

# Run unit tests.
yarn unit

# Make a production build.
yarn build
