-
Notifications
You must be signed in to change notification settings - Fork 336
Check for new version of installer on new
#438
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
protected function checkForUpdate(InputInterface $input, OutputInterface $output) | ||
{ |
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.
Should this return early if ! $input->isInteractive()
?
if (confirm(label: 'Would you like to update now?')) { | ||
$this->runCommands(['composer global update laravel/installer'], $input, $output); | ||
$this->proxyLaravelNew($input, $output); | ||
} |
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 are more ways the installer can be installed besides composer and Herd. Obviously these are the major ones (probably 95%+ of users) but it might be reasonable to somehow check if laravel
is actually installed via composer.
Not sure how this'd be done on Windows but on Mac/Linux I think this could be as simple as checking that which laravel
starts with composer global config home 2>/dev/null
.
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.
Actually using which
is dumb, we can get the path to the currently running script (which is what matters here) using realpath($_SERVER['SCRIPT_FILENAME'])
.
So the check should probably be just: str_starts_with(realpath($_SERVER['SCRIPT_FILENAME']), $composerHome
) where $composerHome
is the stdout of composer global config home
(can also just use --quiet
).
This PR checks for any newer versions of the installer on Packagist and offers to self-update for the user if one exists.
It only checks Packagist at most once per 24 hours, and sends the
If-Modified-Since
header for maximum caching.