From 9f9f21772d4ac502a29a0a276eac513a1447538d Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 23 Jun 2019 18:02:57 +0200 Subject: [PATCH 1/6] [*nix] Add initial version of script --- install.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..d43252d --- /dev/null +++ b/install.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +function error() { + echo " ! $@" + exit 1 +} + +function clone() { + git clone https://github.com/$1 $2 \ + || error "Failed to clone $2" +} + +function checkdep() { + test -n `which $1` \ + || error "$1 not found! $2" +} + +echo " * Testing for dependencies..." + + +checkdep npm "NPM is needed to set up webui" +checkdep sbt "This project is built by sbt" +checkdep git "Git is required to clone individual subrepos" + +echo " * Cloning repositories..." + +test -e chatoverflow && error "The chatoverflow directory already exists!" + +clone codeoverflow-org/chatoverflow chatoverflow +# todo: make the clones parallel? +clone codeoverflow-org/chatoverflow-api chatoverflow/api +clone codeoverflow-org/chatoverflow-gui chatoverflow/gui +clone codeoverflow-org/chatoverflow-plugins chatoverflow/plugins-public + +# switching to chatoverflow dir +cd chatoverflow + +echo " * Refreshing using sbt..." + +# update project first, then fetch plugins; then update the whole thing again +# (including plugins this time) +sbt ";update;fetch;update" + +# done? +echo " * Success! You can now open the project in IntelliJ (or whatever IDE you prefer)" From ff4eb1c54d7f878b20e48bec81cc6b27462283ea Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 14 Jul 2019 14:09:35 +0200 Subject: [PATCH 2/6] Check if sbt exists only for refresh; fix cloning --- install.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index d43252d..b84fe92 100755 --- a/install.sh +++ b/install.sh @@ -11,7 +11,7 @@ function clone() { } function checkdep() { - test -n `which $1` \ + command -v $1 >/dev/null 2>&1 \ || error "$1 not found! $2" } @@ -19,24 +19,31 @@ echo " * Testing for dependencies..." checkdep npm "NPM is needed to set up webui" -checkdep sbt "This project is built by sbt" checkdep git "Git is required to clone individual subrepos" echo " * Cloning repositories..." -test -e chatoverflow && error "The chatoverflow directory already exists!" - -clone codeoverflow-org/chatoverflow chatoverflow +test -e chatoverflow || clone codeoverflow-org/chatoverflow chatoverflow # todo: make the clones parallel? -clone codeoverflow-org/chatoverflow-api chatoverflow/api -clone codeoverflow-org/chatoverflow-gui chatoverflow/gui -clone codeoverflow-org/chatoverflow-plugins chatoverflow/plugins-public +test -e chatoverflow/api || clone codeoverflow-org/chatoverflow-api chatoverflow/api +test -e chatoverflow/gui || clone codeoverflow-org/chatoverflow-gui chatoverflow/gui +test -e chatoverflow/plugins-public || clone codeoverflow-org/chatoverflow-plugins chatoverflow/plugins-public # switching to chatoverflow dir cd chatoverflow + echo " * Refreshing using sbt..." +function sbterr() { + echo "We would love to set the project up for you, but it seems like you don't have sbt installed." + echo "Please install sbt and execute $ sbt ';update;fetch;update'" + echo "Or follow the guide at https://github.com/codeoverflow-org/chatoverflow/wiki/Installation" + exit +} + +command -v sbt >/dev/null 2>&1 || sbterr + # update project first, then fetch plugins; then update the whole thing again # (including plugins this time) sbt ";update;fetch;update" From c43b75886b0757b80e1fc649ca88c60ff049b4e0 Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 14 Jul 2019 14:21:55 +0200 Subject: [PATCH 3/6] fix sbterr, add yarn support --- install.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index b84fe92..7b5ddd7 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ function checkdep() { echo " * Testing for dependencies..." -checkdep npm "NPM is needed to set up webui" +command -v npm >/dev/null 2>&1 || command -v yarn >/dev/null 2>&1 || error "NPM or yarn is needed to set up webui" checkdep git "Git is required to clone individual subrepos" echo " * Cloning repositories..." @@ -39,14 +39,21 @@ function sbterr() { echo "We would love to set the project up for you, but it seems like you don't have sbt installed." echo "Please install sbt and execute $ sbt ';update;fetch;update'" echo "Or follow the guide at https://github.com/codeoverflow-org/chatoverflow/wiki/Installation" - exit } -command -v sbt >/dev/null 2>&1 || sbterr +command -v sbt >/dev/null 2>&1 \ + && sbt ";update;fetch;update" \ + || sbterr # update project first, then fetch plugins; then update the whole thing again # (including plugins this time) -sbt ";update;fetch;update" + +echo " * Setting up GUI..." + +cd gui + +command -v npm >/dev/null 2>&1 && npm install +command -v yarn >/dev/null 2>&1 && yarn # done? echo " * Success! You can now open the project in IntelliJ (or whatever IDE you prefer)" From 8e51c47f949f89a616245360915561477e42fb30 Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 14 Jul 2019 14:31:03 +0200 Subject: [PATCH 4/6] Prefer yarn, don't init gui twice --- install.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 7b5ddd7..2469cd2 100755 --- a/install.sh +++ b/install.sh @@ -52,8 +52,13 @@ echo " * Setting up GUI..." cd gui -command -v npm >/dev/null 2>&1 && npm install -command -v yarn >/dev/null 2>&1 && yarn +function finished() { + # done? + echo " * Success! You can now open the project in IntelliJ (or whatever IDE you prefer)" + exit +} -# done? -echo " * Success! You can now open the project in IntelliJ (or whatever IDE you prefer)" +# don't install the project twice, lol +# prefer yarn cause yarn is better, lol +command -v yarn >/dev/null 2>&1 && yarn && finished +command -v npm >/dev/null 2>&1 && npm install && finished From e3fd8d43f9de7a1900b373342e821ef4ac2f2631 Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 14 Jul 2019 14:40:39 +0200 Subject: [PATCH 5/6] Format nonexisting sbt as error --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 2469cd2..98463aa 100755 --- a/install.sh +++ b/install.sh @@ -36,9 +36,9 @@ cd chatoverflow echo " * Refreshing using sbt..." function sbterr() { - echo "We would love to set the project up for you, but it seems like you don't have sbt installed." - echo "Please install sbt and execute $ sbt ';update;fetch;update'" - echo "Or follow the guide at https://github.com/codeoverflow-org/chatoverflow/wiki/Installation" + echo " ! We would love to set the project up for you, but it seems like you don't have sbt installed." + echo " ! Please install sbt and execute $ sbt ';update;fetch;update'" + echo " ! Or follow the guide at https://github.com/codeoverflow-org/chatoverflow/wiki/Installation" } command -v sbt >/dev/null 2>&1 \ From 1ededba3345ffecc32e3d176853441dfe84edf2b Mon Sep 17 00:00:00 2001 From: Gerd Sattler Date: Sun, 14 Jul 2019 19:27:58 +0200 Subject: [PATCH 6/6] change shell to /bin/sh should work on all POSIX systems now --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 98463aa..fb4c240 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh function error() { echo " ! $@"