Make Vite exec-less on a local machine

Right now, vite uses exec to perform some things. By grepping around a little bit i found that it's mostly $this->server->ssh()->exec( on a remote machine where vite has root priviledges and can do anything, which is fine.

However, there are two unfortunate cases (besides install script, which is not really necessary, since vite can be installed manually like a normal laravel app) where it uses execon a remote host in two important spots, and that's in helpers.php:

1) one, where it's creating a new server in:

function generate_key_pair($path): void
{
    exec("ssh-keygen -t ed25519 -m PEM -N '' -f {$path}");
    chmod($path, 0400);
}

2) and second one when it's doing a version check during health check and displays info in a navigation:

function vito_version(): string
{
    $version = exec('git describe --tags');
    if (str($version)->contains('-')) {
        return str($version)->before('-').' (dev)';
    }

    return $version;
}

Now, with some clients, it's impossible to use exec inside php on some servers, either because of company infrastructure or buisness and security practices regarding vps they operate.

But these cases seem really unnecessary and can be fully avoided; for a) by using phpseclib3\Crypt\ED25519::createKey() and for b) simply keeping version in a config/db/anywhere, or if you really must use git use cpliakas/git-wrapper (very simply, like new Repository(base_path())->getTags()->last()).

That would make Vito be available to be installed on a much wider range of machines and cases.

Please authenticate to join the conversation.

Upvoters
Status

In Review

Board

πŸ’‘ Feature Request

Date

Almost 2 years ago

Author

verybigelephants

Subscribe to post

Get notified by email when there are changes.