refactoring (#116)

- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
This commit is contained in:
Saeed Vaziry
2024-03-14 20:03:43 +01:00
committed by GitHub
parent cee4a70c3c
commit 428140b931
472 changed files with 24110 additions and 8159 deletions

View File

@ -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
);
}
}