-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[✨Feature Request]: Automatic deletion of no longer used models #27
Comments
I agree that this would be a nice feature to have but there are a few things to consider:
These are just the first few issues I see with that. I am open for any suggestions on how to deal with those. An alternative solution for what you are asking for could be implemented on a per project basis using the PHP API if you are not intending to change those parameters: <?php
declare(strict_types=1);
namespace App;
use Brainshaker95\PhpToTsBundle\Interface\Config;
use Brainshaker95\PhpToTsBundle\Model\TsInterface;
use Brainshaker95\PhpToTsBundle\Service\Configuration;
use Brainshaker95\PhpToTsBundle\Service\Dumper;
use Brainshaker95\PhpToTsBundle\Service\Filesystem;
final class Foo
{
public function __construct(
private readonly Configuration $config,
private readonly Dumper $dumper,
private readonly Filesystem $filesystem,
) {
}
public function bar(): void
{
$config = $this->config->get();
$fileNames = [];
$this->dumper->dumpDir(
$config,
static function (string $path, TsInterface $tsInterface): void {
$fileNames[] = $tsInterface->getFileName();
},
);
foreach ($this->filesystem->getSplFileInfoArray([$config->getOutputDir()]) as $file) {
if (!in_array($file->getFilename(), $fileNames, true)) {
$this->filesystem->remove($file->getRealPath());
}
}
}
} Note that |
I am closing this now since no one added any input on this. If there is a need for further discussion in the future I am happy to re-open this issue again. For now I have added the lack of this feature to the known limitations in the readme. |
I have integrated your package in a new projects and it looks fine so far.
However, I've noticed, that if I remove the annotation within my model, to longer auto-generate the ts interface, it is not automatically removed from the generated output directory.
Would be a great feature, if once generated and the annotation removed at a later point, the corresponding autogenerated file will be replaced too!
The text was updated successfully, but these errors were encountered: