summaryrefslogtreecommitdiff
path: root/bin/setup
blob: c73aeeea8651ae2b5b78e0ba9c959850381af1df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash

set -e

version_lt() { test "$(printf '%s\n' "$@" | { [ "$(uname)" = "Linux" ] && sort -V || sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n; } | tail -n 1)" != "$1"; }

# run command at repo root
CURRENT_PATH=$PWD
if [ -d .git ]; then
  cd "$(git rev-parse --show-toplevel)"
fi

if ! type yarn > /dev/null
then
  cat << EOF
yarn is not installed, please install Node.js, npm and yarn.
Read more on Node.js official website: https://nodejs.org
And for yarn package manager at: https://yarnpkg.com/en/
Setup will not be run
EOF
  exit 1
fi

if version_lt "$(yarn --version)" '1.22.0'; then
  cat <<EOF
FATAL: Your Yarn version is outdated.

Please upgrade to a version newer than 1.22.0.
See https://classic.yarnpkg.com/en/docs/install for instructions.
EOF
  exit 1
fi

if version_lt "$(node --version)" 'v10.13.0'; then
  cat <<EOF
FATAL: Your Node.js version is outdated.

Please upgrade to version 10.13 or higher.
We recommend running the latest LTS release.
EOF
  exit 1
fi

echo "copy config files"
if [ ! -f config.json ]; then
  cp config.json.example config.json
fi

if [ ! -f .sequelizerc ]; then
  cp .sequelizerc.example .sequelizerc
fi

echo "install packages"
yarn install --pure-lockfile
yarn install --production=false --pure-lockfile

cat << EOF


Edit the following config file to setup HedgeDoc server and client.
Read more info at https://github.com/hedgedoc/hedgedoc#configuration-files

* config.json           -- HedgeDoc config
* .sequelizerc          -- db config

EOF

# change directory back
cd "$CURRENT_PATH"