From 41e88144a4da59cf030c33cf53ed8d5914131cf2 Mon Sep 17 00:00:00 2001 From: ArthurErlich Date: Sun, 12 Jul 2026 22:47:34 +0200 Subject: [PATCH] chore(namespace): rewirtten namspeace from app to GitContributionGraph. --- TODO.md | 2 +- bin/console | 2 +- composer.json | 4 +- config/routes.yaml | 2 +- config/services.yaml | 12 ++--- public/index.php | 2 +- public/worker.php | 2 +- src/Command/RefetchContributionsCommand.php | 54 +++++++++++++++++++ src/Controller/GraphController.php | 8 +-- src/Entity/Contribution.php | 2 +- src/Entity/ContributionCollection.php | 2 +- src/Kernel.php | 2 +- src/Service/ContributionAggregator.php | 4 +- src/Service/ContributionStore.php | 6 +-- src/Service/Provider/GitHubProvider.php | 2 +- src/Service/Provider/GitLabProvider.php | 2 +- src/Service/Provider/GiteaProvider.php | 2 +- src/Service/Provider/ProbeTrait.php | 2 +- src/Service/Provider/ProviderErrorCode.php | 2 +- .../Provider/ProviderHealthChecker.php | 2 +- src/Service/Provider/ProviderInterface.php | 2 +- src/Service/Provider/ProviderStatus.php | 2 +- src/Service/Provider/ProviderStatusType.php | 2 +- src/Service/Renderer/SvgRenderer.php | 2 +- .../Entity/ContributionCollectionTest.php | 6 +-- tests/Unit/Entity/ContributionTest.php | 4 +- .../Service/ContributionAggregatorTest.php | 6 +-- tests/Unit/Service/ContributionStoreTest.php | 4 +- .../Service/Provider/GitHubProviderTest.php | 4 +- .../Service/Provider/GitLabProviderTest.php | 4 +- .../Service/Provider/GiteaProviderTest.php | 4 +- .../Unit/Service/Provider/ProbeTraitTest.php | 10 ++-- .../Provider/ProviderHealthCheckerTest.php | 12 ++--- .../Service/Provider/ProviderStatusTest.php | 8 +-- .../Unit/Service/Renderer/SvgRendererTest.php | 4 +- 35 files changed, 122 insertions(+), 68 deletions(-) create mode 100644 src/Command/RefetchContributionsCommand.php diff --git a/TODO.md b/TODO.md index 4ac298a..10121f4 100644 --- a/TODO.md +++ b/TODO.md @@ -184,7 +184,7 @@ PHP `max_execution_time` fatal can't be caught by `try/catch` at all, so - [ ] `.env` — document `CONTRIBUTIONS_RETENTION_DAYS` (empty by default), same style as the existing `ALLOWED_HOSTS` comment. -## 9. `app:contributions:refetch` console command +## 9. `graph:contributions:refetch` console command Manual escape hatch for forcing a full or ranged re-fetch (e.g. after adding a new host, or if the store needs rebuilding) — bypasses step 5's diff --git a/bin/console b/bin/console index f7ba6f7..f8e868b 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env php io = new SymfonyStyle($input, $output); + } + + public function __invoke( + //TODO: check if its possible to add the preview with real strings from the providers. + #[Option("(repeatable/comma-split, restricts to named provider(s), default = all configured", "provider", "p", "")] + string $providers = "" + ) { + $requested = $providers === '' ? null : explode(',', $providers); + $byName = []; + + foreach ($this->providers as $provider) { + $byName[$provider->getName()] = $provider; + } + + if ($requested !== null) { + foreach ($requested as $name) { + if (!isset($byName[$name])) { + $this->io->error("Unknown provider: {$name}"); + return Command::FAILURE; + } + } + $byName = array_intersect_key($byName, array_flip($requested)); + } + } +} diff --git a/src/Controller/GraphController.php b/src/Controller/GraphController.php index 18b520f..6d716c9 100644 --- a/src/Controller/GraphController.php +++ b/src/Controller/GraphController.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\Controller; +namespace GitContributionGraph\Controller; -use App\Service\ContributionAggregator; -use App\Service\Provider\ProviderHealthChecker; -use App\Service\Renderer\SvgRenderer; +use GitContributionGraph\Service\ContributionAggregator; +use GitContributionGraph\Service\Provider\ProviderHealthChecker; +use GitContributionGraph\Service\Renderer\SvgRenderer; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\RedirectResponse; diff --git a/src/Entity/Contribution.php b/src/Entity/Contribution.php index 9e04820..2e05227 100644 --- a/src/Entity/Contribution.php +++ b/src/Entity/Contribution.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Entity; +namespace GitContributionGraph\Entity; final class Contribution { diff --git a/src/Entity/ContributionCollection.php b/src/Entity/ContributionCollection.php index 60d26e7..eabbec0 100644 --- a/src/Entity/ContributionCollection.php +++ b/src/Entity/ContributionCollection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Entity; +namespace GitContributionGraph\Entity; /** * @implements \IteratorAggregate diff --git a/src/Kernel.php b/src/Kernel.php index 779cd1f..e8ad584 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -1,6 +1,6 @@