-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add installation request for missing dependencies (bunq/tinker_php#18) #19
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ ERROR_SYSTEM_UNKNOWN='Unknown system found "%s".\n' | |
ERROR_RUN_IN_EMPTY_DIRECTORY='Please run the script from an empty directory\n' | ||
ERROR_COULD_NOT_FIND_COMMAND='Could not find "%s", try installing it by running "%s".' | ||
|
||
MESSAGE_INSTALL_DEPENDENCY='Do you want to try and install this now? (y/N)? ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Y |
||
|
||
# System Constants | ||
SYSTEM_NAME_LINUX='Linux' | ||
SYSTEM_NAME_MAC_OS='Darwin' | ||
|
@@ -14,6 +16,7 @@ ALL_SYSTEM_SUPPORTED="${SYSTEM_NAME_LINUX} ${SYSTEM_NAME_MAC_OS} ${SYSTEM_NAME_F | |
# Prerequisite constants. | ||
PREREQUISITE_CONSTANT_PREFIX='ALL_PREREQUISITE_' | ||
ALL_PREREQUISITE_GLOBAL='git php composer qrencode jq' | ||
ALL_PREREQUISITE_COMPOSER=$(curl -s https://raw.githubusercontent.com/bunq/sdk_php/master/composer.json | fgrep ext | tr -d "\"*\:,\ ") | ||
ALL_PREREQUISITE_LINUX='' | ||
ALL_PREREQUISITE_DARWIN='brew' | ||
ALL_PREREQUISITE_FREEBSD='' | ||
|
@@ -57,10 +60,27 @@ function assertAllPrerequisitePresent | |
else | ||
echo -n "$(determineInstructionInstallationAllPrerequisiteMissing "${allPrerequisiteMissing}")" | ||
|
||
exit 1 | ||
if [${1} ]; then | ||
exit 1 | ||
else | ||
assertAllPrerequisitePresent true | ||
fi | ||
fi | ||
} | ||
|
||
function assertComposerPrerequisitePresent | ||
{ | ||
phpModules=$(php -m) | ||
|
||
for composerPrerequisite in ${ALL_PREREQUISITE_COMPOSER}; do | ||
composerPrerequisite=${composerPrerequisite:4} | ||
|
||
if [[ ${phpModules} != *"${composerPrerequisite}"* ]]; then | ||
determineInstructionInstallation "php-${composerPrerequisite}" "$(determineSystemName)" "php-${composerPrerequisite}" | ||
fi | ||
done | ||
} | ||
|
||
function determineAllPrerequisiteMissing | ||
{ | ||
for prerequisite in $(determineAllPrerequisite); do | ||
|
@@ -129,7 +149,17 @@ function determineInstructionInstallation | |
systemName="${2}" | ||
programPackageName=${3:-${programName}} | ||
commandInstallationConstantName="${COMMAND_INSTALLATION_PREFIX}$(capitalize ${systemName})" | ||
printf "${ERROR_COULD_NOT_FIND_COMMAND}" "${programName}" "${!commandInstallationConstantName} ${programPackageName}" | ||
|
||
warningMessage=$(printf "${ERROR_COULD_NOT_FIND_COMMAND}" "${programName}" "${!commandInstallationConstantName} ${programPackageName}") | ||
|
||
echo ${warningMessage} >$(tty) | ||
echo ${MESSAGE_INSTALL_DEPENDENCY} >$(tty) | ||
|
||
read answer | ||
if [ "$answer" != "${answer#[Yy]}" ] ;then | ||
echo "${!commandInstallationConstantName} ${programPackageName} -y" >$(tty) | ||
eval "${!commandInstallationConstantName} ${programPackageName} -y" >$(tty) | ||
fi | ||
} | ||
|
||
function determineSystemName | ||
|
@@ -176,6 +206,7 @@ function capitalizeFirstLetter | |
assertIsSystemSupported | ||
assertIsRanInEmptyDirectory | ||
assertAllPrerequisitePresent | ||
assertComposerPrerequisitePresent | ||
cloneTinkerPhp | ||
composerInstall | ||
startTinker | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Y