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

@ -26,6 +26,9 @@ public function setUp(): void
{
parent::setUp();
config()->set('queue.connections.ssh.driver', 'sync');
config()->set('filesystems.disks.key-pairs.root', storage_path('app/key-pairs-test'));
$this->user = User::factory()->create();
$this->setupServer();
@ -41,6 +44,11 @@ private function setupServer(): void
'user_id' => $this->user->id,
]);
$keys = $this->server->sshKey();
if (! File::exists($keys['public_key_path']) || ! File::exists($keys['private_key_path'])) {
$this->server->provider()->generateKeyPair();
}
$this->server->type()->createServices([
'webserver' => Webserver::NGINX,
'database' => Database::MYSQL80,
@ -57,21 +65,25 @@ private function setupSite(): void
/** @var SourceControl $sourceControl */
$sourceControl = SourceControl::factory()->github()->create();
$this->site = Site::factory()->create([
'domain' => 'vito.test',
'aliases' => ['www.vito.test'],
'server_id' => $this->server->id,
'source_control_id' => $sourceControl->id,
'repository' => 'organization/repository',
'path' => '/home/vito/vito.test',
'web_directory' => 'public',
'branch' => 'main',
]);
}
private function setupKeys(): void
{
config()->set('core.ssh_public_key_name', 'ssh-public.key');
config()->set('core.ssh_private_key_name', 'ssh-private.pem');
if (! File::exists(storage_path(config('core.ssh_public_key_name')))) {
File::put(storage_path(config('core.ssh_public_key_name')), 'public_key');
}
if (! File::exists(storage_path(config('core.ssh_private_key_name')))) {
File::put(storage_path(config('core.ssh_private_key_name')), 'private_key');
config()->set('core.ssh_public_key_name', 'test-key.pub');
config()->set('core.ssh_private_key_name', 'test-key');
$publicKeypath = storage_path(config('core.ssh_public_key_name'));
$privateKeyPath = storage_path(config('core.ssh_private_key_name'));
if (! File::exists($publicKeypath) || ! File::exists($privateKeyPath)) {
generate_key_pair(storage_path('test-key'));
}
}
}