refactoring

This commit is contained in:
Saeed Vaziry
2023-08-04 18:28:04 +02:00
parent 8444323cf4
commit 643318fcfc
349 changed files with 3189 additions and 2729 deletions

View File

@ -0,0 +1,33 @@
<?php
namespace App\SSHCommands\Website;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
class CloneRepositoryCommand extends Command
{
public function __construct(
protected string $repository,
protected string $path,
protected string $branch,
protected string $privateKeyPath
) {
}
public function file(): string
{
return File::get(resource_path('commands/website/clone-repository.sh'));
}
public function content(): string
{
return str($this->file())
->replace('__repo__', $this->repository)
->replace('__host__', str($this->repository)->after('@')->before('-'))
->replace('__branch__', $this->branch)
->replace('__path__', $this->path)
->replace('__key__', $this->privateKeyPath)
->toString();
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\SSHCommands\Website;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
class ComposerInstallCommand extends Command
{
public function __construct(protected string $path)
{
}
public function file(): string
{
return File::get(resource_path('commands/website/composer-install.sh'));
}
public function content(): string
{
return str($this->file())
->replace('__path__', $this->path)
->toString();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\SSHCommands\Website;
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
class UpdateBranchCommand extends Command
{
public function __construct(protected string $path, protected string $branch)
{
}
public function file(): string
{
return File::get(resource_path('commands/website/update-branch.sh'));
}
public function content(): string
{
return str($this->file())
->replace('__path__', $this->path)
->replace('__branch__', $this->branch)
->toString();
}
}