Added refresh-remote-state option to deploy command
This commit is contained in:
4 files changed
+68
-2
No files matched your search
@@ -39,6 +39,7 @@ class CallFtpDeployApiCommand extends Command
|
||||
$response = Http::acceptJson()
|
||||
->withToken($token)
|
||||
->timeout($timeout)
|
||||
->connectTimeout(min(5, $timeout))
|
||||
->get($url)
|
||||
->throw();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ use function Laravel\Prompts\warning;
|
||||
{--disk= : Filesystem disk configured for the FTP server}
|
||||
{--state= : Remote sync-state file path}
|
||||
{--exclude=* : Extra exclude path or wildcard pattern; comma-separated values are supported}
|
||||
{--refresh-remote-state : Call the configured JSON API before comparing the remote sync-state}
|
||||
{--dry-run : Show what would be uploaded without changing the FTP server}
|
||||
{--force : Upload every included local file}
|
||||
{--yes : Skip the confirmation prompt}')]
|
||||
@@ -55,6 +56,15 @@ class DeployFtpChangedFilesCommand extends Command
|
||||
|
||||
$remoteDisk = Storage::disk($diskName);
|
||||
$currentState = $this->ftpDeployManager->buildCurrentState($localRoot, $excludedPatterns);
|
||||
|
||||
if ((bool) $this->option('refresh-remote-state')) {
|
||||
$refreshExitCode = $this->refreshRemoteState();
|
||||
|
||||
if ($refreshExitCode !== self::SUCCESS) {
|
||||
return $refreshExitCode;
|
||||
}
|
||||
}
|
||||
|
||||
$remoteState = $this->ftpDeployManager->readRemoteState($remoteDisk, $statePath);
|
||||
|
||||
if ($remoteState === null) {
|
||||
@@ -102,6 +112,13 @@ class DeployFtpChangedFilesCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function refreshRemoteState(): int
|
||||
{
|
||||
info('Refreshing remote sync-state before deployment.');
|
||||
|
||||
return $this->call('ftp:api-summary');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{data: array<int, array<string, mixed>>} $currentState
|
||||
* @param array<int, array<string, mixed>> $changedFiles
|
||||
|
||||
Reference in new issue
Block a user