This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
238 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Symplify\ChangelogLinker; | ||
|
||
use Nette\Utils\Strings; | ||
use Symplify\ChangelogLinker\Analyzer\LinksAnalyzer; | ||
|
||
final class ChangelogCleaner | ||
{ | ||
/** | ||
* @var LinksAnalyzer | ||
*/ | ||
private $linksAnalyzer; | ||
|
||
public function __construct(LinksAnalyzer $linksAnalyzer) | ||
{ | ||
$this->linksAnalyzer = $linksAnalyzer; | ||
} | ||
|
||
public function processContent(string $changelogContent): string | ||
{ | ||
$this->linksAnalyzer->analyzeContent($changelogContent); | ||
|
||
$deadLinks = $this->linksAnalyzer->getDeadLinks(); | ||
|
||
foreach ($deadLinks as $deadLink) { | ||
$changelogContent = Strings::replace($changelogContent, sprintf('#\[\#?(%s)\]:(.*?)\n#', $deadLink)); | ||
} | ||
|
||
return $changelogContent; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/ChangelogLinker/src/Console/Command/CleanupCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Symplify\ChangelogLinker\Console\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symplify\ChangelogLinker\ChangelogCleaner; | ||
use Symplify\ChangelogLinker\FileSystem\ChangelogFileSystem; | ||
use Symplify\PackageBuilder\Console\Command\CommandNaming; | ||
|
||
final class CleanupCommand extends Command | ||
{ | ||
/** | ||
* @var ChangelogFileSystem | ||
*/ | ||
private $changelogFileSystem; | ||
|
||
/** | ||
* @var ChangelogCleaner | ||
*/ | ||
private $changelogCleaner; | ||
|
||
public function __construct(ChangelogFileSystem $changelogFileSystem, ChangelogCleaner $changelogCleaner) | ||
{ | ||
parent::__construct(); | ||
$this->changelogFileSystem = $changelogFileSystem; | ||
$this->changelogCleaner = $changelogCleaner; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->setName(CommandNaming::classToName(self::class)); | ||
$this->setDescription('Removes dead links from CHANGELOG.md'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$changelogContent = $this->changelogFileSystem->readChangelog(); | ||
|
||
$processedChangelogContent = $this->changelogCleaner->processContent($changelogContent); | ||
|
||
$this->changelogFileSystem->storeChangelog($processedChangelogContent); | ||
|
||
// success | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...es/ChangelogLinker/tests/Analyzer/LinksAnalyzer/Source/SomeFileWithDeadlinks.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### Added | ||
|
||
- [#10] A link | ||
|
||
[#5]: Link | ||
[#10]: Deadlink | ||
[#15]: Deadlink |
Oops, something went wrong.