summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Bungers2020-11-17 21:39:18 +0100
committerGitHub2020-11-17 21:39:18 +0100
commitb111d1f7fd577286817cbba56d323ba67505671f (patch)
tree0d92aa84b8d7ed52f3f94b605275bbcafe55ec50
parented98084c1362a3b81f67753c913e9d695cbb4e5a (diff)
parentac7dd2982f53de30f428b57edf54c225b4bd91c5 (diff)
Merge pull request #5 from SISheogorath/fix/setupVersions
Add some version checks to setup script
Diffstat (limited to '')
-rwxr-xr-xbin/setup41
1 files changed, 31 insertions, 10 deletions
diff --git a/bin/setup b/bin/setup
index 2fcc65d6..0f1edca0 100755
--- a/bin/setup
+++ b/bin/setup
@@ -2,24 +2,46 @@
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
+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
+FATAL: Yarn could not be found.
+
+Please follow the official installation instructions at
+https://classic.yarnpkg.com/en/docs/install
+and try again.
+EOF
+ exit 1
+fi
+
+if version_lt "$(yarn --version)" '1.22.0'; then
+ cat << EOF
+FATAL: Your Yarn version is outdated.
+
+Please upgrade to version 1.22.0 or higher and try again.
+See https://classic.yarnpkg.com/en/docs/install for instructions.
EOF
- exit 0
+ exit 1
fi
-echo "copy config files"
+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 and try again.
+We recommend running the latest LTS release, see https://nodejs.org/en/about/releases/ for details.
+EOF
+ exit 1
+fi
+
+echo "Copying config files..."
if [ ! -f config.json ]; then
cp config.json.example config.json
fi
@@ -28,7 +50,7 @@ if [ ! -f .sequelizerc ]; then
cp .sequelizerc.example .sequelizerc
fi
-echo "install packages"
+echo "Installing packages..."
yarn install --pure-lockfile
yarn install --production=false --pure-lockfile
@@ -40,7 +62,6 @@ Read more info at https://github.com/hedgedoc/hedgedoc#configuration-files
* config.json -- HedgeDoc config
* .sequelizerc -- db config
-
EOF
# change directory back