mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 23:12:35 +00:00
#591 - sites [wip]
This commit is contained in:
@ -13,6 +13,8 @@ abstract class AbstractSiteType implements SiteType
|
||||
{
|
||||
public function __construct(protected Site $site) {}
|
||||
|
||||
abstract public static function make(): self;
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [];
|
||||
@ -28,11 +30,6 @@ public function data(array $input): array
|
||||
return [];
|
||||
}
|
||||
|
||||
public function editRules(array $input): array
|
||||
{
|
||||
return $this->createRules($input);
|
||||
}
|
||||
|
||||
public function baseCommands(): array
|
||||
{
|
||||
return [];
|
||||
|
@ -2,8 +2,15 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\Models\Site;
|
||||
|
||||
class Laravel extends PHPSite
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::LARAVEL]));
|
||||
}
|
||||
|
||||
public function baseCommands(): array
|
||||
{
|
||||
return array_merge(parent::baseCommands(), [
|
||||
|
@ -2,13 +2,21 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\LoadBalancerMethod;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoadBalancer extends AbstractSiteType
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::LOAD_BALANCER]));
|
||||
}
|
||||
|
||||
public function language(): string
|
||||
{
|
||||
return 'yaml';
|
||||
@ -21,12 +29,30 @@ public function supportedFeatures(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('method')
|
||||
->select()
|
||||
->label('Load Balancing Method')
|
||||
->options([
|
||||
LoadBalancerMethod::IP_HASH,
|
||||
LoadBalancerMethod::ROUND_ROBIN,
|
||||
LoadBalancerMethod::LEAST_CONNECTIONS,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
'method' => [
|
||||
'required',
|
||||
Rule::in(LoadBalancerMethod::all()),
|
||||
Rule::in([
|
||||
LoadBalancerMethod::IP_HASH,
|
||||
LoadBalancerMethod::ROUND_ROBIN,
|
||||
LoadBalancerMethod::LEAST_CONNECTIONS,
|
||||
]),
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -47,9 +73,4 @@ public function install(): void
|
||||
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
}
|
||||
|
||||
public function edit(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,20 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPBlank extends PHPSite
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::PHP]));
|
||||
}
|
||||
|
||||
public function supportedFeatures(): array
|
||||
{
|
||||
return [
|
||||
@ -19,9 +27,28 @@ public function supportedFeatures(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('php_version')
|
||||
->component()
|
||||
->label('PHP Version'),
|
||||
DynamicFieldDTO::make('web_directory')
|
||||
->text()
|
||||
->label('Web Directory')
|
||||
->placeholder('For / leave empty')
|
||||
->description('The relative path of your website from /home/vito/your-domain/'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
'web_directory' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:255',
|
||||
],
|
||||
'php_version' => [
|
||||
'required',
|
||||
Rule::in($this->site->server->installedPHPVersions()),
|
||||
|
@ -2,12 +2,20 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPMyAdmin extends PHPSite
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::PHPMYADMIN]));
|
||||
}
|
||||
|
||||
public function supportedFeatures(): array
|
||||
{
|
||||
return [
|
||||
@ -15,6 +23,15 @@ public function supportedFeatures(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('php_version')
|
||||
->component()
|
||||
->label('PHP Version'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
@ -22,7 +39,6 @@ public function createRules(array $input): array
|
||||
'required',
|
||||
Rule::in($this->site->server->installedPHPVersions()),
|
||||
],
|
||||
'version' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
@ -37,7 +53,7 @@ public function createFields(array $input): array
|
||||
public function data(array $input): array
|
||||
{
|
||||
return [
|
||||
'version' => $input['version'],
|
||||
'version' => '5.2.2',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,23 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Site;
|
||||
use App\SSH\Composer\Composer;
|
||||
use App\SSH\Git\Git;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPSite extends AbstractSiteType
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::PHP]));
|
||||
}
|
||||
|
||||
public function language(): string
|
||||
{
|
||||
return 'php';
|
||||
@ -27,14 +35,33 @@ public function supportedFeatures(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function baseCommands(): array
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name' => 'Install Composer Dependencies',
|
||||
'command' => 'composer install --no-dev --no-interaction --no-progress',
|
||||
],
|
||||
];
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('php_version')
|
||||
->component()
|
||||
->label('PHP Version'),
|
||||
DynamicFieldDTO::make('source_control')
|
||||
->component()
|
||||
->label('Source Control'),
|
||||
DynamicFieldDTO::make('web_directory')
|
||||
->text()
|
||||
->label('Web Directory')
|
||||
->placeholder('For / leave empty')
|
||||
->description('The relative path of your website from /home/vito/your-domain/'),
|
||||
DynamicFieldDTO::make('repository')
|
||||
->text()
|
||||
->label('Repository')
|
||||
->placeholder('organization/repository'),
|
||||
DynamicFieldDTO::make('branch')
|
||||
->text()
|
||||
->label('Branch')
|
||||
->default('main'),
|
||||
DynamicFieldDTO::make('composer')
|
||||
->checkbox()
|
||||
->label('Run `composer install --no-dev`')
|
||||
->default(false),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
@ -101,13 +128,13 @@ public function install(): void
|
||||
}
|
||||
}
|
||||
|
||||
public function editRules(array $input): array
|
||||
public function baseCommands(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function edit(): void
|
||||
{
|
||||
//
|
||||
return [
|
||||
[
|
||||
'name' => 'Install Composer Dependencies',
|
||||
'command' => 'composer install --no-dev --no-interaction --no-progress',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
|
||||
interface SiteType
|
||||
{
|
||||
public function language(): string;
|
||||
@ -11,6 +13,8 @@ public function language(): string;
|
||||
*/
|
||||
public function supportedFeatures(): array;
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
@ -31,14 +35,6 @@ public function data(array $input): array;
|
||||
|
||||
public function install(): void;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function editRules(array $input): array;
|
||||
|
||||
public function edit(): void;
|
||||
|
||||
/**
|
||||
* @return array<array<string, string>>
|
||||
*/
|
||||
|
@ -5,15 +5,23 @@
|
||||
use App\Actions\Database\CreateDatabase;
|
||||
use App\Actions\Database\CreateDatabaseUser;
|
||||
use App\Actions\Database\LinkUser;
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Site;
|
||||
use Closure;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class Wordpress extends AbstractSiteType
|
||||
{
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::WORDPRESS]));
|
||||
}
|
||||
|
||||
public function language(): string
|
||||
{
|
||||
return 'php';
|
||||
@ -27,6 +35,40 @@ public function supportedFeatures(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('php_version')
|
||||
->component()
|
||||
->label('PHP Version'),
|
||||
DynamicFieldDTO::make('title')
|
||||
->text()
|
||||
->label('Site Title')
|
||||
->placeholder('My WordPress Site'),
|
||||
DynamicFieldDTO::make('username')
|
||||
->text()
|
||||
->label('Admin Username')
|
||||
->placeholder('admin'),
|
||||
DynamicFieldDTO::make('password')
|
||||
->text()
|
||||
->label('Admin Password'),
|
||||
DynamicFieldDTO::make('email')
|
||||
->text()
|
||||
->label('Admin Email'),
|
||||
DynamicFieldDTO::make('database')
|
||||
->text()
|
||||
->label('Database Name')
|
||||
->placeholder('wordpress'),
|
||||
DynamicFieldDTO::make('database_user')
|
||||
->text()
|
||||
->label('Database User')
|
||||
->placeholder('wp_user'),
|
||||
DynamicFieldDTO::make('database_password')
|
||||
->text()
|
||||
->label('Database Password'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
@ -117,17 +159,4 @@ public function install(): void
|
||||
$this->progress(60);
|
||||
app(\App\SSH\Wordpress\Wordpress::class)->install($this->site);
|
||||
}
|
||||
|
||||
public function editRules(array $input): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'url' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function edit(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user