mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\Contracts\SiteType;
|
||||
use App\Jobs\Site\DeleteSite;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Models\Site;
|
||||
use Closure;
|
||||
|
||||
abstract class AbstractSiteType implements SiteType
|
||||
{
|
||||
@ -16,16 +14,25 @@ public function __construct(Site $site)
|
||||
$this->site = $site;
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
protected function progress(int $percentage): void
|
||||
{
|
||||
dispatch(new DeleteSite($this->site))->onConnection('ssh');
|
||||
$this->site->progress = $percentage;
|
||||
$this->site->save();
|
||||
}
|
||||
|
||||
protected function progress(int $percentage): Closure
|
||||
/**
|
||||
* @throws SourceControlIsNotConnected
|
||||
*/
|
||||
protected function deployKey(): void
|
||||
{
|
||||
return function () use ($percentage) {
|
||||
$this->site->progress = $percentage;
|
||||
$this->site->save();
|
||||
};
|
||||
$os = $this->site->server->os();
|
||||
$os->generateSSHKey($this->site->getSshKeyName());
|
||||
$this->site->ssh_key = $os->readSSHKey($this->site->getSshKeyName());
|
||||
$this->site->save();
|
||||
$this->site->sourceControl()->provider()->deployKey(
|
||||
$this->site->domain.'-key-'.$this->site->id,
|
||||
$this->site->repository,
|
||||
$this->site->ssh_key
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user