Skip to content

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

Merged
merged 10 commits into from
Oct 27, 2016

Conversation

frenck
Copy link
Contributor

@frenck frenck commented Oct 25, 2016

No description provided.

@@ -0,0 +1,74 @@
#!/usr/bin/env bash
set -eu

Copy link
Contributor

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

Copy link
Contributor Author

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!"
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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 ***"
Copy link
Contributor

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).

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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)" = \
Copy link
Contributor

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
Copy link
Contributor

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, chowning would probably also require sudo, so... meh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎱

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two ifs 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"
Copy link
Contributor

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

Copy link
Contributor Author

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. 👍

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better 👍

Copy link
Contributor Author

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...

@Potherca
Copy link
Contributor

I would strongly suggest reading the bashstyle for some general pointers (including "all code should go in a function").

@frenck
Copy link
Contributor Author

frenck commented Oct 27, 2016

@Potherca Updated PR.
Left out GPG, since that requires some more internal organisation (like determining how we are going to distribute a keyring or use a organisation wide key with developer sub-keys....)

…ot recommended, forbidding it could give problems in CI builds (e.g. TravisCI & Bitbucket Pipelines).
@Potherca
Copy link
Contributor

Potherca commented Oct 27, 2016

👍 🚢

Using Composer (preferred method):

```bash
composer require --dev "dealerdirect/qa-tools:*"
Copy link
Contributor

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": "*"
Copy link
Contributor

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"

@frenck frenck merged commit 46f7a3f into master Oct 27, 2016
@frenck frenck deleted the feature/install-script branch October 27, 2016 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants