mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
* Add node support using nvm * Add icon * Rename to NodeJS * Rename to NodeJS * update php and node logo * only services which have units can be started,restarted,stopped,disabled and enabled * add tests --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com> Co-authored-by: Saeed Vaziry <61919774+saeedvaziry@users.noreply.github.com>
33 lines
999 B
PHP
33 lines
999 B
PHP
<?php
|
|
|
|
namespace App\Actions\NodeJS;
|
|
|
|
use App\Enums\ServiceStatus;
|
|
use App\Models\Server;
|
|
use App\SSH\Services\NodeJS\NodeJS;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
class ChangeDefaultCli
|
|
{
|
|
public function change(Server $server, array $input): void
|
|
{
|
|
$this->validate($server, $input);
|
|
$service = $server->nodejs($input['version']);
|
|
/** @var NodeJS $handler */
|
|
$handler = $service->handler();
|
|
$handler->setDefaultCli();
|
|
$server->defaultService('nodejs')->update(['is_default' => 0]);
|
|
$service->update(['is_default' => 1]);
|
|
$service->update(['status' => ServiceStatus::READY]);
|
|
}
|
|
|
|
public function validate(Server $server, array $input): void
|
|
{
|
|
if (! isset($input['version']) || ! in_array($input['version'], $server->installedNodejsVersions())) {
|
|
throw ValidationException::withMessages(
|
|
['version' => __('This version is not installed')]
|
|
);
|
|
}
|
|
}
|
|
}
|