mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 23:42:34 +00:00
Merge (#127)
This commit is contained in:
@ -1,36 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Contracts\Database\Query\Expression;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function random_color(): string
|
||||
{
|
||||
return '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
function get_hostname_from_repo($repo): string
|
||||
{
|
||||
$repo = Str::after($repo, '@');
|
||||
|
||||
return Str::before($repo, ':');
|
||||
}
|
||||
|
||||
function generate_uid(): string
|
||||
{
|
||||
return hash('sha256', uniqid(rand(1111111111, 9999999999), true).Str::random(64).strtotime('now'));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @param $privateKeyPath
|
||||
// * @return array|string|string[]
|
||||
// */
|
||||
// function generate_public_key($privateKeyPath)
|
||||
// {
|
||||
// $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyPath));
|
||||
// $publicKey = openssl_pkey_get_details($privateKey);
|
||||
//
|
||||
// return $publicKey['key'];
|
||||
// }
|
||||
use App\Helpers\HtmxResponse;
|
||||
|
||||
function generate_public_key($privateKeyPath, $publicKeyPath): void
|
||||
{
|
||||
@ -44,16 +14,6 @@ function generate_key_pair($path): void
|
||||
chmod($path, 0400);
|
||||
}
|
||||
|
||||
function make_bash_script($commands): string
|
||||
{
|
||||
$script = '';
|
||||
foreach (preg_split("/((\r?\n)|(\r\n?))/", $commands) as $line) {
|
||||
$script .= 'if ! '.$line."; then\n echo 'VITO_SSH_ERROR' && exit 1 \nfi"."\n";
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
@ -65,9 +25,7 @@ function date_with_timezone($date, $timezone): string
|
||||
return $dt->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
function cast_to_json(array $json): Illuminate\Database\Query\Expression|Expression
|
||||
function htmx(): HtmxResponse
|
||||
{
|
||||
$json = addslashes(json_encode($json));
|
||||
|
||||
return DB::raw("CAST('{$json}' AS JSON)");
|
||||
return new HtmxResponse();
|
||||
}
|
||||
|
Reference in New Issue
Block a user