update composer (#84)

* update composer
log viewer
code style format

* fix composer
This commit is contained in:
Saeed Vaziry 2024-01-01 22:05:31 +01:00 committed by GitHub
parent 551f1ce40e
commit fd2244d382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 1527 additions and 966 deletions

View File

@ -15,13 +15,13 @@ public function create(
?int $siteId = null
): void;
public function delete(int $id, int $siteId = null): void;
public function delete(int $id, ?int $siteId = null): void;
public function restart(int $id, int $siteId = null): void;
public function restart(int $id, ?int $siteId = null): void;
public function stop(int $id, int $siteId = null): void;
public function stop(int $id, ?int $siteId = null): void;
public function start(int $id, int $siteId = null): void;
public function start(int $id, ?int $siteId = null): void;
public function getLogs(string $logPath): string;
}

View File

@ -12,7 +12,7 @@ public function credentialData(array $input): array;
public function data(array $input): array;
public function connect(array $credentials = null): bool;
public function connect(?array $credentials = null): bool;
public function plans(): array;

View File

@ -6,7 +6,7 @@ interface SourceControlProvider
{
public function connect(): bool;
public function getRepo(string $repo = null): mixed;
public function getRepo(?string $repo = null): mixed;
public function fullRepoUrl(string $repo, string $key): string;

View File

@ -7,7 +7,7 @@
class SourceControlIsNotConnected extends Exception
{
public function __construct(protected SourceControl|string|null $sourceControl, string $message = null)
public function __construct(protected SourceControl|string|null $sourceControl, ?string $message = null)
{
parent::__construct($message ?? 'Source control is not connected');
}

View File

@ -31,7 +31,7 @@ class SSH
protected PrivateKey $privateKey;
public function init(Server $server, string $asUser = null): self
public function init(Server $server, ?string $asUser = null): self
{
$this->connection = null;
$this->log = null;
@ -87,7 +87,7 @@ public function connect(bool $sftp = false): void
/**
* @throws Throwable
*/
public function exec(string|array|SSHCommand $commands, string $log = '', int $siteId = null): string
public function exec(string|array|SSHCommand $commands, string $log = '', ?int $siteId = null): string
{
if ($log) {
$this->setLog($log, $siteId);

View File

@ -12,8 +12,8 @@
class AutoDeployment extends Component
{
use RefreshComponentOnBroadcast;
use HasToast;
use RefreshComponentOnBroadcast;
public Site $site;

View File

@ -11,8 +11,8 @@
class Deploy extends Component
{
use RefreshComponentOnBroadcast;
use HasToast;
use RefreshComponentOnBroadcast;
public Site $site;

View File

@ -10,8 +10,8 @@
class DeploymentsList extends Component
{
use RefreshComponentOnBroadcast;
use HasCustomPaginationView;
use RefreshComponentOnBroadcast;
public Site $site;

View File

@ -11,8 +11,8 @@
class LogsList extends Component
{
use RefreshComponentOnBroadcast;
use HasCustomPaginationView;
use RefreshComponentOnBroadcast;
public ?int $count = null;

View File

@ -10,8 +10,8 @@
class SslsList extends Component
{
use RefreshComponentOnBroadcast;
use HasToast;
use RefreshComponentOnBroadcast;
public Site $site;

View File

@ -13,7 +13,7 @@ class Initialize extends InstallationJob
protected ?string $asUser;
public function __construct(Server $server, string $asUser = null)
public function __construct(Server $server, ?string $asUser = null)
{
$this->server = $server->refresh();
$this->asUser = $asUser;

View File

@ -233,7 +233,7 @@ public function install(): void
// $this->team->notify(new ServerInstallationStarted($this));
}
public function ssh(string $user = null): \App\Helpers\SSH|SSHFake
public function ssh(?string $user = null): \App\Helpers\SSH|SSHFake
{
return SSH::init($this, $user);
}
@ -263,7 +263,7 @@ public function provider(): \App\Contracts\ServerProvider
return new $providerClass($this);
}
public function webserver(string $version = null): ?Service
public function webserver(?string $version = null): ?Service
{
if (! $version) {
return $this->defaultService('webserver');
@ -272,7 +272,7 @@ public function webserver(string $version = null): ?Service
return $this->service('webserver', $version);
}
public function database(string $version = null): ?Service
public function database(?string $version = null): ?Service
{
if (! $version) {
return $this->defaultService('database');
@ -281,7 +281,7 @@ public function database(string $version = null): ?Service
return $this->service('database', $version);
}
public function firewall(string $version = null): ?Service
public function firewall(?string $version = null): ?Service
{
if (! $version) {
return $this->defaultService('firewall');
@ -290,7 +290,7 @@ public function firewall(string $version = null): ?Service
return $this->service('firewall', $version);
}
public function processManager(string $version = null): ?Service
public function processManager(?string $version = null): ?Service
{
if (! $version) {
return $this->defaultService('process_manager');
@ -299,7 +299,7 @@ public function processManager(string $version = null): ?Service
return $this->service('process_manager', $version);
}
public function php(string $version = null): ?Service
public function php(?string $version = null): ?Service
{
if (! $version) {
return $this->defaultService('php');

View File

@ -33,7 +33,7 @@ public function provider(): SourceControlProvider
return new $providerClass($this);
}
public function getRepo(string $repo = null): ?array
public function getRepo(?string $repo = null): ?array
{
return $this->provider()->getRepo($repo);
}

View File

@ -63,7 +63,7 @@ public function data(array $input): array
/**
* @throws CouldNotConnectToProvider
*/
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
try {
$this->connectToEc2ClientTest($credentials);

View File

@ -10,7 +10,7 @@ abstract class AbstractProvider implements ServerProvider
{
protected ?Server $server;
public function __construct(Server $server = null)
public function __construct(?Server $server = null)
{
$this->server = $server;
}

View File

@ -42,7 +42,7 @@ public function data(array $input): array
return [];
}
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
return true;
}

View File

@ -58,7 +58,7 @@ public function data(array $input): array
/**
* @throws CouldNotConnectToProvider
*/
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
$connect = Http::withToken($credentials['token'])->get($this->apiUrl.'/account');
if (! $connect->ok()) {

View File

@ -45,7 +45,7 @@ public function data(array $input): array
/**
* @throws CouldNotConnectToProvider
*/
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
$connect = Http::withToken($credentials['token'])->get($this->apiUrl.'/servers');
if (! $connect->ok()) {

View File

@ -57,7 +57,7 @@ public function data(array $input): array
/**
* @throws CouldNotConnectToProvider
*/
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
$connect = Http::withToken($credentials['token'])->get($this->apiUrl.'/account');
if (! $connect->ok()) {

View File

@ -59,7 +59,7 @@ public function data(array $input): array
/**
* @throws CouldNotConnectToProvider
*/
public function connect(array $credentials = null): bool
public function connect(?array $credentials = null): bool
{
$connect = Http::withToken($credentials['token'])->get($this->apiUrl.'/account');
if (! $connect->ok()) {

View File

@ -16,7 +16,7 @@ public function __construct(Server $server)
$this->server = $server;
}
protected function progress(int $percentage, string $step = null): Closure
protected function progress(int $percentage, ?string $step = null): Closure
{
return function () use ($percentage, $step) {
$this->server->progress = $percentage;

View File

@ -47,7 +47,7 @@ public function create(
/**
* @throws Throwable
*/
public function delete(int $id, int $siteId = null): void
public function delete(int $id, ?int $siteId = null): void
{
$this->service->server->ssh()->exec(
new DeleteWorkerCommand($id),
@ -59,7 +59,7 @@ public function delete(int $id, int $siteId = null): void
/**
* @throws Throwable
*/
public function restart(int $id, int $siteId = null): void
public function restart(int $id, ?int $siteId = null): void
{
$this->service->server->ssh()->exec(
new RestartWorkerCommand($id),
@ -71,7 +71,7 @@ public function restart(int $id, int $siteId = null): void
/**
* @throws Throwable
*/
public function stop(int $id, int $siteId = null): void
public function stop(int $id, ?int $siteId = null): void
{
$this->service->server->ssh()->exec(
new StopWorkerCommand($id),
@ -83,7 +83,7 @@ public function stop(int $id, int $siteId = null): void
/**
* @throws Throwable
*/
public function start(int $id, int $siteId = null): void
public function start(int $id, ?int $siteId = null): void
{
$this->service->server->ssh()->exec(
new StartWorkerCommand($id),

View File

@ -24,7 +24,7 @@ public function connect(): bool
/**
* @throws Exception
*/
public function getRepo(string $repo = null): mixed
public function getRepo(?string $repo = null): mixed
{
$res = Http::withToken($this->sourceControl->access_token)
->get($this->apiUrl."/repositories/$repo");

View File

@ -25,7 +25,7 @@ public function connect(): bool
/**
* @throws Exception
*/
public function getRepo(string $repo = null): mixed
public function getRepo(?string $repo = null): mixed
{
if ($repo) {
$url = $this->apiUrl.'/repos/'.$repo;

View File

@ -25,7 +25,7 @@ public function connect(): bool
/**
* @throws Exception
*/
public function getRepo(string $repo = null): mixed
public function getRepo(?string $repo = null): mixed
{
$repository = $repo ? urlencode($repo) : null;
$res = Http::withToken($this->sourceControl->access_token)

View File

@ -15,7 +15,7 @@ class SSHFake
protected string $output = '';
public function init(Server $server, string $asUser = null): self
public function init(Server $server, ?string $asUser = null): self
{
return $this;
}
@ -47,7 +47,7 @@ public function assertExecuted(array|string $commands): void
PHPUnit::assertTrue(true, $allExecuted);
}
public function exec(string|array|SSHCommand $commands, string $log = '', int $siteId = null): string
public function exec(string|array|SSHCommand $commands, string $log = '', ?int $siteId = null): string
{
if (! is_array($commands)) {
$commands = [$commands];

View File

@ -16,6 +16,7 @@
"laravel/tinker": "^2.8",
"livewire/livewire": "^2.12",
"phpseclib/phpseclib": "~3.0",
"opcodesio/log-viewer": "^2.5",
"ext-ftp": "*"
},
"require-dev": {
@ -24,7 +25,6 @@
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"opcodesio/log-viewer": "^2.5",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0"
},

2188
composer.lock generated

File diff suppressed because it is too large Load Diff

217
config/log-viewer.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Opcodes\LogViewer\Level;
return [
/*
|--------------------------------------------------------------------------
| Log Viewer
|--------------------------------------------------------------------------
| Log Viewer can be disabled, so it's no longer accessible via browser.
|
*/
'enabled' => env('LOG_VIEWER_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Log Viewer Domain
|--------------------------------------------------------------------------
| You may change the domain where Log Viewer should be active.
| If the domain is empty, all domains will be valid.
|
*/
'route_domain' => null,
/*
|--------------------------------------------------------------------------
| Log Viewer Route
|--------------------------------------------------------------------------
| Log Viewer will be available under this URL.
|
*/
'route_path' => 'log-viewer',
/*
|--------------------------------------------------------------------------
| Back to system URL
|--------------------------------------------------------------------------
| When set, displays a link to easily get back to this URL.
| Set to `null` to hide this link.
|
| Optional label to display for the above URL.
|
*/
'back_to_system_url' => config('app.url', null),
'back_to_system_label' => null, // Displayed by default: "Back to {{ app.name }}"
/*
|--------------------------------------------------------------------------
| Log Viewer time zone.
|--------------------------------------------------------------------------
| The time zone in which to display the times in the UI. Defaults to
| the application's timezone defined in config/app.php.
|
*/
'timezone' => null,
/*
|--------------------------------------------------------------------------
| Log Viewer route middleware.
|--------------------------------------------------------------------------
| Optional middleware to use when loading the initial Log Viewer page.
|
*/
'middleware' => [
'web',
\Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
'auth',
],
/*
|--------------------------------------------------------------------------
| Log Viewer API middleware.
|--------------------------------------------------------------------------
| Optional middleware to use on every API request. The same API is also
| used from within the Log Viewer user interface.
|
*/
'api_middleware' => [
\Opcodes\LogViewer\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
],
/*
|--------------------------------------------------------------------------
| Log Viewer Remote hosts.
|--------------------------------------------------------------------------
| Log Viewer supports viewing Laravel logs from remote hosts. They must
| be running Log Viewer as well. Below you can define the hosts you
| would like to show in this Log Viewer instance.
|
*/
'hosts' => [
'local' => [
'name' => ucfirst(env('APP_ENV', 'local')),
],
// 'staging' => [
// 'name' => 'Staging',
// 'host' => 'https://staging.example.com/log-viewer',
// 'auth' => [ // Example of HTTP Basic auth
// 'username' => 'username',
// 'password' => 'password',
// ],
// ],
//
// 'production' => [
// 'name' => 'Production',
// 'host' => 'https://example.com/log-viewer',
// 'auth' => [ // Example of Bearer token auth
// 'token' => env('LOG_VIEWER_PRODUCTION_TOKEN'),
// ],
// 'headers' => [
// 'X-Foo' => 'Bar',
// ],
// ],
],
/*
|--------------------------------------------------------------------------
| Include file patterns
|--------------------------------------------------------------------------
|
*/
'include_files' => [
'*.log',
'**/*.log',
// '/absolute/paths/supported',
],
/*
|--------------------------------------------------------------------------
| Exclude file patterns.
|--------------------------------------------------------------------------
| This will take precedence over included files.
|
*/
'exclude_files' => [
// 'my_secret.log'
],
/*
|--------------------------------------------------------------------------
| Shorter stack trace filters.
|--------------------------------------------------------------------------
| Lines containing any of these strings will be excluded from the full log.
| This setting is only active when the function is enabled via the user interface.
|
*/
'shorter_stack_trace_excludes' => [
'/vendor/symfony/',
'/vendor/laravel/framework/',
'/vendor/barryvdh/laravel-debugbar/',
],
/*
|--------------------------------------------------------------------------
| Log matching patterns
|--------------------------------------------------------------------------
| Regexes for matching log files
|
*/
'patterns' => [
'laravel' => [
'log_matching_regex' => '/^\[(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}\.?(\d{6}([\+-]\d\d:\d\d)?)?)\].*/',
/**
* This pattern, used for processing Laravel logs, returns these results:
* $matches[0] - the full log line being tested.
* $matches[1] - full timestamp between the square brackets (includes microseconds and timezone offset)
* $matches[2] - timestamp microseconds, if available
* $matches[3] - timestamp timezone offset, if available
* $matches[4] - contents between timestamp and the severity level
* $matches[5] - environment (local, production, etc)
* $matches[6] - log severity (info, debug, error, etc)
* $matches[7] - the log text, the rest of the text.
*/
'log_parsing_regex' => '/^\[(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}\.?(\d{6}([\+-]\d\d:\d\d)?)?)\](.*?(\w+)\.|.*?)('
.implode('|', array_filter(Level::caseValues()))
.')?: (.*?)( in [\/].*?:[0-9]+)?$/is',
],
],
/*
|--------------------------------------------------------------------------
| Cache driver
|--------------------------------------------------------------------------
| Cache driver to use for storing the log indices. Indices are used to speed up
| log navigation. Defaults to your application's default cache driver.
|
*/
'cache_driver' => env('LOG_VIEWER_CACHE_DRIVER', null),
/*
|--------------------------------------------------------------------------
| Chunk size when scanning log files lazily
|--------------------------------------------------------------------------
| The size in MB of files to scan before updating the progress bar when searching across all files.
|
*/
'lazy_scan_chunk_size_in_mb' => 50,
];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"/app.js": "/app.js?id=2ca3fa12f273bd645611f1acf3d81355",
"/app.css": "/app.css?id=93151d8b186ef7758df8582425ff8082",
"/app.js": "/app.js?id=5f574f36f456b103dffcfa21d5612785",
"/app.css": "/app.css?id=b701a4344131bb2c00e9f0b1ef1ab3c1",
"/img/log-viewer-128.png": "/img/log-viewer-128.png?id=d576c6d2e16074d3f064e60fe4f35166",
"/img/log-viewer-32.png": "/img/log-viewer-32.png?id=f8ec67d10f996aa8baf00df3b61eea6d",
"/img/log-viewer-64.png": "/img/log-viewer-64.png?id=8902d596fc883ca9eb8105bb683568c6"