-
Notifications
You must be signed in to change notification settings - Fork 6
Added install script & documentation for installing this repository. #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… including Bash & ZSH shells. Needs testing.
@@ -0,0 +1,74 @@ | |||
#!/usr/bin/env bash | |||
set -eu | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this script does not pipe anything, I would recommend adding
set -o pipefail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
# Ensure PHP is installed | ||
if ! command -v php > /dev/null 2>&1; then | ||
echo "PHP is not found, installation aborted!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an error it should be redirected to STDERR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Ensure PHP is installed | ||
if ! command -v php > /dev/null 2>&1; then | ||
echo "PHP is not found, installation aborted!" | ||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is more than one exit scenario I would prefer to see a different exit code than 1
exit 1 | ||
fi | ||
|
||
# Ensure Composer is installed/updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a comment it might be better to have a function named ensureComposerInstalled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to keep it simple, top down. But I agree as well... 👍
|
||
# Ensure Composer is installed/updated | ||
if ! command -v composer > /dev/null 2>&1; then | ||
echo "*** Installing Composer ***" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a personal standard for messages I would prefer to see a convention being used. (For instance the Heroku output formats).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... Since we don't have a convention for it yet... Nevertheless, nice link, will "borrow" some. 😉
@@ -0,0 +1,74 @@ | |||
#!/usr/bin/env bash | |||
set -eu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer seeing the more verbose set -o errexit
as that is a bit more understandable than -e
(and set -o nounset
rather than -u
). It would also be helpful to add a comment after each flag for developers less familiar with bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Agreed
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
|
||
if [ \ | ||
"$(curl -S https://composer.github.io/installer.sig)" = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
"$(php -r \"echo hash_file\('SHA384', 'composer-setup.php'\);\")" \ | ||
]; then | ||
php composer-setup.php --quiet --filename=composer | ||
sudo mv composer /usr/local/bin/composer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirly sure about the sudo
, then again, chown
ing would probably also require sudo, so... meh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been decided:
@8BallTweets Should we use `sudo mv`?
— 422 - Unprocessable (@Potherca) October 25, 2016
@potherca - Yes
— Ask the Magic 8 Ball (@8BallTweets) October 25, 2016
if [[ ! -f "$HOME/.profile" ]]; then | ||
touch "$HOME/.profile" | ||
fi | ||
if grep -q -F "export COMPOSER_HOME=$HOME/.composer" "$HOME/.profile"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two if
s belong in an else
. If we've just created the file it does not make sense to grep it.
|
||
# Source the .profile to pick up changes | ||
# shellcheck source=/dev/null | ||
source "$HOME/.profile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have unintended side-effects, depending on what the user has (been told by other programs to) put in their .profile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It "should not", but I like the don't assume approach. Replacing it with a success message at the end including an instruction would make more sense I guess. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also just run the export COMPOSER_HOME=$HOME/.composer
and/or export PATH=$PATH:\$COMPOSER_HOME/vendor/bin
in the relevant if
to have the same effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your last comment... actually, you can't...
I would strongly suggest reading the bashstyle for some general pointers (including "all code should go in a function"). |
@Potherca Updated PR. |
…ot recommended, forbidding it could give problems in CI builds (e.g. TravisCI & Bitbucket Pipelines).
👍 🚢 |
Using Composer (preferred method): | ||
|
||
```bash | ||
composer require --dev "dealerdirect/qa-tools:*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The star is not needed composer require --dev "dealerdirect/qa-tools
would just grab the latest version. (Taking constraints into account).
"…": "*" | ||
}, | ||
"require-dev": { | ||
"dealerdirect/qa-tools": "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to add a version number rather than "no constraint"
…tructions, in case of require-dev
No description provided.