mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
refactoring
This commit is contained in:
33
app/SSHCommands/Website/CloneRepositoryCommand.php
Executable file
33
app/SSHCommands/Website/CloneRepositoryCommand.php
Executable 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();
|
||||
}
|
||||
}
|
25
app/SSHCommands/Website/ComposerInstallCommand.php
Executable file
25
app/SSHCommands/Website/ComposerInstallCommand.php
Executable 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();
|
||||
}
|
||||
}
|
26
app/SSHCommands/Website/UpdateBranchCommand.php
Normal file
26
app/SSHCommands/Website/UpdateBranchCommand.php
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user