diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4440e44..9b50855 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,3 @@
# Changelog
All notable changes to `vapor-ignore` will be documented in this file.
-
-## v1.0.0 - 2024-02-09
-
-- Initial release
-
-**Full Changelog**: https://github.com/ageekdev/vapor-ignore/commits/v1.0.0
diff --git a/src/Commands/CleanIgnoredFilesCommand.php b/src/Commands/CleanIgnoredFilesCommand.php
index ace6f81..1e4357e 100644
--- a/src/Commands/CleanIgnoredFilesCommand.php
+++ b/src/Commands/CleanIgnoredFilesCommand.php
@@ -3,11 +3,11 @@
namespace AgeekDev\VaporIgnore\Commands;
use AgeekDev\VaporIgnore\Manifest;
+use AgeekDev\VaporIgnore\Path;
use AgeekDev\VaporIgnore\Vendor;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Laravel\VaporCli\Helpers;
-use Laravel\VaporCli\Path;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
use Symfony\Component\Finder\Finder;
@@ -15,6 +15,12 @@ class CleanIgnoredFilesCommand extends Command
{
protected Filesystem $files;
+ protected int $totalFiles = 0;
+
+ protected int $totalDirectories = 0;
+
+ protected int $totalFileSize = 0;
+
/**
* Configure the command options.
*/
@@ -46,6 +52,9 @@ public function handle(): void
$this->removeOtherFiles();
$this->removeUserIgnoredFiles();
$this->removeVaporIgnoreYml();
+
+ Helpers::step('Total Removed Files Size: '.round($this->totalFileSize / 1024, 2).'kb');
+
}
/**
@@ -68,6 +77,8 @@ protected function removeReadmeFiles(): void
protected function removeChangeLogFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::CHANGE_LOG)) {
+ Helpers::step('Removing CHANGELOG files>');
+
$this->removeFiles([
'CHANGELOG.md',
'changelog.htm',
@@ -81,7 +92,7 @@ protected function removeChangeLogFiles(): void
protected function removeContributingFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::CONTRIBUTING)) {
- Helpers::step('Removing UPGRADE files>');
+ Helpers::step('Removing CONTRIBUTING files>');
$this->removeFiles([
'CONTRIBUTING.md',
@@ -96,7 +107,7 @@ protected function removeContributingFiles(): void
protected function removeUpgradeFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::UPGRADE)) {
- Helpers::step('Removing Upgrade files>');
+ Helpers::step('Removing UPGRADE files>');
$this->removeFiles([
'UPGRADING.md',
@@ -111,7 +122,7 @@ protected function removeUpgradeFiles(): void
protected function removeSecurityMdFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::SECURITY)) {
- Helpers::step('Removing security.md files>');
+ Helpers::step('Removing SECURITY.md files>');
$this->removeFiles([
'SECURITY.md',
@@ -125,7 +136,7 @@ protected function removeSecurityMdFiles(): void
protected function removeTestDirectories(): void
{
if (Manifest::isIgnoredVendor(Vendor::TEST)) {
- Helpers::step('Removing Test>');
+ Helpers::step('Removing Test Folders>');
$this->removeFiles([
'phpunit.xml.dist',
@@ -137,6 +148,9 @@ protected function removeTestDirectories(): void
->in(Path::vendor().'/*/*/');
foreach ($finder as $file) {
+ Helpers::step('Removing Ignored Directory: '.str_replace(Path::current().'/', '', $file->getRealPath()));
+ $this->totalFileSize += $file->getSize();
+ $this->totalFiles++;
$this->files->deleteDirectory($file->getRealPath(), true);
}
}
@@ -148,7 +162,7 @@ protected function removeTestDirectories(): void
protected function removeLicenseFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::LICENSE)) {
- Helpers::step('Removing License Files>');
+ Helpers::step('Removing LICENSE Files>');
$this->removeFiles([
'LICENSE',
@@ -166,7 +180,7 @@ protected function removeLicenseFiles(): void
protected function removeLaravelIdeaDirectory(): void
{
if (Manifest::isIgnoredVendor(Vendor::LARAVEL_IDEA)) {
- Helpers::step('Removing Laravel Idea Folder>');
+ Helpers::step('Removing Laravel IDEA Folder>');
$this->removeDirectory(Path::vendor().'/_laravel_idea');
}
@@ -178,14 +192,21 @@ protected function removeLaravelIdeaDirectory(): void
protected function removeDotGithubDirectories(): void
{
if (Manifest::isIgnoredVendor(Vendor::DOT_GITHUB)) {
- Helpers::step('Removing .github Folders From Vendor>');
+ Helpers::step('Removing .github Folders>');
$finder = (new Finder())
->ignoreDotFiles(false)
->directories()->name('.github')
->in(Path::vendor().'/*/*/');
+ if ($finder->count() === 0) {
+ Helpers::step('Not Found Ignored Directory: .github/');
+ }
+
foreach ($finder as $file) {
+ Helpers::step('Removing Ignored Directory: '.str_replace(Path::current().'/', '', $file->getRealPath()));
+ $this->totalFileSize += $file->getSize();
+ $this->totalDirectories++;
$this->files->deleteDirectory($file->getRealPath(), true);
}
}
@@ -211,7 +232,7 @@ protected function removeOtherFiles(): void
protected function removeDotFiles(): void
{
if (Manifest::isIgnoredVendor(Vendor::DOT_FILES)) {
- Helpers::step('Removing Dot Files From Vendor>');
+ Helpers::step('Removing Dot Files>');
$this->removeFiles([
'.editorconfig',
@@ -227,16 +248,29 @@ protected function removeDotFiles(): void
*/
protected function removeFiles($files, $ignoreDotFiles = true): void
{
+ $isEmpty = true;
+
foreach ($files as $item) {
$finder = (new Finder())
->files()->name($item)
->ignoreDotFiles($ignoreDotFiles)
->in(Path::vendor().'/*/*/');
+ if ($finder->count() > 0) {
+ $isEmpty = false;
+ }
+
foreach ($finder as $file) {
+ $this->totalFileSize += $file->getSize();
+ $this->totalFiles++;
+ Helpers::step('Removing Ignored File: '.str_replace(Path::current().'/', '', $file->getRealPath()));
$this->files->delete($file->getRealPath());
}
}
+
+ if ($isEmpty) {
+ Helpers::step('Not Found Ignored File: '.implode(', ', $files));
+ }
}
/**
@@ -245,6 +279,9 @@ protected function removeFiles($files, $ignoreDotFiles = true): void
protected function removeDirectory($directory): void
{
if ($this->files->isDirectory($directory)) {
+ Helpers::step('Removing Ignored Directory: '.$directory.'/');
+ $this->totalFileSize += $this->files->size($directory);
+ $this->totalDirectories++;
$this->files->deleteDirectory($directory, true);
}
}
@@ -260,6 +297,8 @@ protected function removeUserIgnoredFiles(): void
return;
}
+ Helpers::step('Removing User Ignored Files>');
+
$notFoundDirectories = [];
foreach ($ignoredFiles as $pattern) {
@@ -267,8 +306,11 @@ protected function removeUserIgnoredFiles(): void
if ($this->files->exists($directory.'/'.$filePattern) && $this->files->isDirectory($directory.'/'.$filePattern)) {
Helpers::step('Removing Ignored Directory: '.$filePattern.'/');
-
+ $fileSize = $this->files->size($directory.'/'.$filePattern);
$this->files->deleteDirectory($directory.'/'.$filePattern);
+
+ $this->totalFileSize += $fileSize;
+ $this->totalDirectories++;
} else {
try {
$files = (new Finder())
@@ -279,8 +321,11 @@ protected function removeUserIgnoredFiles(): void
foreach ($files as $file) {
Helpers::step('Removing Ignored File: '.str_replace(Path::current().'/', '', $file->getRealPath()));
-
+ $fileSize = $this->files->size($file->getRealPath());
$this->files->delete($file->getRealPath());
+
+ $this->totalFileSize += $fileSize;
+ $this->totalFiles++;
}
} catch (DirectoryNotFoundException) {
$notFoundDirectories[] = $directory.'/'.$filePattern;
diff --git a/src/Manifest.php b/src/Manifest.php
index 624c157..962cce8 100644
--- a/src/Manifest.php
+++ b/src/Manifest.php
@@ -87,7 +87,7 @@ public static function addCleanCommandToVaporEnvironments(): void
{
$manifest = static::vapor();
- $command = 'php ./vendor/bin/vapor-ignore clean:ignored-file';
+ $command = 'php ./vendor/bin/vapor-ignore clean:ignored-files';
$environments = $manifest['environments'] ?? [];
diff --git a/src/Path.php b/src/Path.php
index c471adc..c143449 100644
--- a/src/Path.php
+++ b/src/Path.php
@@ -11,7 +11,7 @@ class Path
*/
public static function vendor(): string
{
- return static::build().'/vendor';
+ return static::current().'/vendor';
}
/**