1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 08:40:09 +01:00
Files
laravel-valet/cli/Valet/Valet.php
Taylor Otwell d98fce6f08 extract logic
2016-05-11 15:29:04 -05:00

62 lines
1.4 KiB
PHP

<?php
namespace Valet;
class Valet
{
var $cli, $files;
var $valetBin = '/usr/local/bin/valet';
/**
* Create a new Valet instance.
*
* @param CommandLine $cli
* @param Filesystem $files
* @return void
*/
function __construct(CommandLine $cli, Filesystem $files)
{
$this->cli = $cli;
$this->files = $files;
}
/**
* Symlink the Valet Bash script into the user's local bin.
*
* @return void
*/
function symlinkToUsersBin()
{
$this->cli->quietly('rm '.$this->valetBin);
$this->cli->run('ln -s '.realpath(__DIR__.'/../../valet').' '.$this->valetBin);
}
/**
* Create the "sudoers.d" entry for running Valet.
*
* @return void
*/
function createSudoersEntry()
{
$this->files->ensureDirExists('/etc/sudoers.d');
$this->files->put('/etc/sudoers.d/valet', 'Cmnd_Alias VALET = /usr/local/bin/valet *
%admin ALL=(root) NOPASSWD: VALET'.PHP_EOL);
}
/**
* Determine if this is the latest version of Valet.
*
* @param string $currentVersion
* @return bool
*/
public function onLatestVersion($currentVersion)
{
$response = \Httpful\Request::get('https://api.github.com/repos/laravel/valet/releases/latest')->send();
return version_compare($currentVersion, trim($response->body->tag_name, 'v'), '>=');
}
}