diff --git a/.env b/.env index 1a10ad9..50a3dee 100644 --- a/.env +++ b/.env @@ -62,7 +62,11 @@ APP_BPN_CRM_ID_TEAMER=1070 APP_DEFAULT_EMAIL_FROM=team@ep-reisen.de APP_DEFAULT_EMAIL_TO=team@ep-reisen.de -XML_EXPORT_PATH="%kernel.project_dir%/var/xmlexport" +SFTP_XML_EXPORT_HOST= +SFTP_XML_EXPORT_PORT=22 +SFTP_XML_EXPORT_USER= +SFTP_XML_EXPORT_PASSWORD= +SFTP_XML_EXPORT_ROOT= MYEP_OAUTH2_CLIENT_ID= MYEP_OAUTH2_CLIENT_SECRET= diff --git a/config/packages/flysystem.yaml b/config/packages/flysystem.yaml index 0bf5f39..7242945 100644 --- a/config/packages/flysystem.yaml +++ b/config/packages/flysystem.yaml @@ -2,13 +2,12 @@ flysystem: storages: xml_export.storage: - local: - directory: '%env(resolve:XML_EXPORT_PATH)%' + sftp: + host: '%env(SFTP_XML_EXPORT_HOST)%' + port: '%env(int:SFTP_XML_EXPORT_PORT)%' + username: '%env(SFTP_XML_EXPORT_USER)%' + password: '%env(SFTP_XML_EXPORT_PASSWORD)%' + root: '%env(SFTP_XML_EXPORT_ROOT)%' xml_dump.storage: local: directory: '%kernel.project_dir%/var/bpn' -# sftp: -# host: '%env(SFTP_XML_EXPORT_HOST)%' -# port: '%env(int:SFTP_XML_EXPORT_PORT)%' -# username: '%env(SFTP_XML_EXPORT_USER)%' -# password: '%env(SFTP_XML_EXPORT_PASSWORD)%' diff --git a/deploy.php b/deploy.php index e2c2cec..edae1d9 100644 --- a/deploy.php +++ b/deploy.php @@ -97,6 +97,19 @@ host('staging') ->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://myep-team.ep-reisen.net') ; +host('hetzner') + ->setHostname('dedi10193.your-server.de') + ->setRemoteUser('myepteam') + ->setForwardAgent(true) + ->setSshMultiplexing(true) + ->setDeployPath('/usr/home/myepteam/public_html/myep-team') + ->set('bin/php', '/usr/bin/php') + ->set('http_user', 'myepteam') + ->set('rsync_src', __DIR__) + ->set('rsync', $rsyncOptions) + ->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://myep-team.ep-reisen.net') +; + task('deploy', [ 'deploy:info', 'deploy:setup', diff --git a/src/Command/BpnImportCommand.php b/src/Command/BpnImportCommand.php index b568fff..5f362fc 100644 --- a/src/Command/BpnImportCommand.php +++ b/src/Command/BpnImportCommand.php @@ -39,7 +39,7 @@ class BpnImportCommand extends Command try { $xmlFiles = $this ->xmlExport - ->listContents('.') + ->listContents('') ->filter(fn (StorageAttributes $attributes) => $attributes->isFile() && str_starts_with($attributes->path(), 'Ziel_')) ->toArray(); } catch (FilesystemException $e) { @@ -59,14 +59,23 @@ class BpnImportCommand extends Command $io->info('Found '.$totalCount.' XML files'); $addedCount = 0; $updatedCount = 0; + $warnings = []; + + $progressBar = $io->createProgressBar($totalCount); + $progressBar->setFormat(" %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%\n %message%"); + $progressBar->setMessage('Starting'); + $progressBar->start(); // Iterate over xml files foreach ($xmlFiles as $xmlFile) { + $progressBar->setMessage($xmlFile->path()); + // Load xml file into simplexml object try { $xml = simplexml_load_string($this->xmlExport->read($xmlFile->path())); } catch (FilesystemException $e) { - $io->warning('Unable to read XML file '.$xmlFile->path()); + $warnings[] = 'Unable to read XML file '.$xmlFile->path(); + $progressBar->advance(); continue; } @@ -84,7 +93,7 @@ class BpnImportCommand extends Command $pickupBusProId = (int) $pickupXml->attributes()['idbuspro']; if ($pickupBusProId) { if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) { - $io->warning('Pickup with busProId '.$pickupBusProId.' not found'); + $warnings[] = 'Pickup with busProId '.$pickupBusProId.' not found'; continue; } @@ -101,7 +110,7 @@ class BpnImportCommand extends Command foreach ($destinationXml->xpath('hotel') as $hotelXml) { $hotelBusProId = (int) $hotelXml->attributes()['idbuspro']; if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) { - $io->warning('Hotel with busProId '.$hotelBusProId.' not found'); + $warnings[] = 'Hotel with busProId '.$hotelBusProId.' not found'; continue; } @@ -146,6 +155,16 @@ class BpnImportCommand extends Command } } } + + $progressBar->advance(); + } + + $progressBar->setMessage('Done'); + $progressBar->finish(); + $io->newLine(2); + + if ($warnings) { + $io->warning(array_unique($warnings)); } $logMessage = 'Added '.$addedCount.' and updated '.$updatedCount.' destinations';