Skip to content

Commit a4571fd

Browse files
author
Tint Naing Win
committed
chore:update
1 parent 554e36b commit a4571fd

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
# Changelog
22

33
All notable changes to `vapor-ignore` will be documented in this file.
4-
5-
## v1.0.0 - 2024-02-09
6-
7-
- Initial release
8-
9-
**Full Changelog**: https://github.com/ageekdev/vapor-ignore/commits/v1.0.0

src/Commands/CleanIgnoredFilesCommand.php

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
namespace AgeekDev\VaporIgnore\Commands;
44

55
use AgeekDev\VaporIgnore\Manifest;
6+
use AgeekDev\VaporIgnore\Path;
67
use AgeekDev\VaporIgnore\Vendor;
78
use Illuminate\Filesystem\Filesystem;
89
use Illuminate\Support\Str;
910
use Laravel\VaporCli\Helpers;
10-
use Laravel\VaporCli\Path;
1111
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
1212
use Symfony\Component\Finder\Finder;
1313

1414
class CleanIgnoredFilesCommand extends Command
1515
{
1616
protected Filesystem $files;
1717

18+
protected int $totalFiles = 0;
19+
20+
protected int $totalDirectories = 0;
21+
22+
protected int $totalFileSize = 0;
23+
1824
/**
1925
* Configure the command options.
2026
*/
@@ -46,6 +52,9 @@ public function handle(): void
4652
$this->removeOtherFiles();
4753
$this->removeUserIgnoredFiles();
4854
$this->removeVaporIgnoreYml();
55+
56+
Helpers::step('<comment>Total Removed Files Size:</comment> '.round($this->totalFileSize / 1024, 2).'kb');
57+
4958
}
5059

5160
/**
@@ -68,6 +77,8 @@ protected function removeReadmeFiles(): void
6877
protected function removeChangeLogFiles(): void
6978
{
7079
if (Manifest::isIgnoredVendor(Vendor::CHANGE_LOG)) {
80+
Helpers::step('<options=bold>Removing CHANGELOG files</>');
81+
7182
$this->removeFiles([
7283
'CHANGELOG.md',
7384
'changelog.htm',
@@ -81,7 +92,7 @@ protected function removeChangeLogFiles(): void
8192
protected function removeContributingFiles(): void
8293
{
8394
if (Manifest::isIgnoredVendor(Vendor::CONTRIBUTING)) {
84-
Helpers::step('<options=bold>Removing UPGRADE files</>');
95+
Helpers::step('<options=bold>Removing CONTRIBUTING files</>');
8596

8697
$this->removeFiles([
8798
'CONTRIBUTING.md',
@@ -96,7 +107,7 @@ protected function removeContributingFiles(): void
96107
protected function removeUpgradeFiles(): void
97108
{
98109
if (Manifest::isIgnoredVendor(Vendor::UPGRADE)) {
99-
Helpers::step('<options=bold>Removing Upgrade files</>');
110+
Helpers::step('<options=bold>Removing UPGRADE files</>');
100111

101112
$this->removeFiles([
102113
'UPGRADING.md',
@@ -111,7 +122,7 @@ protected function removeUpgradeFiles(): void
111122
protected function removeSecurityMdFiles(): void
112123
{
113124
if (Manifest::isIgnoredVendor(Vendor::SECURITY)) {
114-
Helpers::step('<options=bold>Removing security.md files</>');
125+
Helpers::step('<options=bold>Removing SECURITY.md files</>');
115126

116127
$this->removeFiles([
117128
'SECURITY.md',
@@ -125,7 +136,7 @@ protected function removeSecurityMdFiles(): void
125136
protected function removeTestDirectories(): void
126137
{
127138
if (Manifest::isIgnoredVendor(Vendor::TEST)) {
128-
Helpers::step('<options=bold>Removing Test</>');
139+
Helpers::step('<options=bold>Removing Test Folders</>');
129140

130141
$this->removeFiles([
131142
'phpunit.xml.dist',
@@ -137,6 +148,9 @@ protected function removeTestDirectories(): void
137148
->in(Path::vendor().'/*/*/');
138149

139150
foreach ($finder as $file) {
151+
Helpers::step('<comment>Removing Ignored Directory:</comment> '.str_replace(Path::current().'/', '', $file->getRealPath()));
152+
$this->totalFileSize += $file->getSize();
153+
$this->totalFiles++;
140154
$this->files->deleteDirectory($file->getRealPath(), true);
141155
}
142156
}
@@ -148,7 +162,7 @@ protected function removeTestDirectories(): void
148162
protected function removeLicenseFiles(): void
149163
{
150164
if (Manifest::isIgnoredVendor(Vendor::LICENSE)) {
151-
Helpers::step('<options=bold>Removing License Files</>');
165+
Helpers::step('<options=bold>Removing LICENSE Files</>');
152166

153167
$this->removeFiles([
154168
'LICENSE',
@@ -166,7 +180,7 @@ protected function removeLicenseFiles(): void
166180
protected function removeLaravelIdeaDirectory(): void
167181
{
168182
if (Manifest::isIgnoredVendor(Vendor::LARAVEL_IDEA)) {
169-
Helpers::step('<options=bold>Removing Laravel Idea Folder</>');
183+
Helpers::step('<options=bold>Removing Laravel IDEA Folder</>');
170184

171185
$this->removeDirectory(Path::vendor().'/_laravel_idea');
172186
}
@@ -178,14 +192,21 @@ protected function removeLaravelIdeaDirectory(): void
178192
protected function removeDotGithubDirectories(): void
179193
{
180194
if (Manifest::isIgnoredVendor(Vendor::DOT_GITHUB)) {
181-
Helpers::step('<options=bold>Removing .github Folders From Vendor</>');
195+
Helpers::step('<options=bold>Removing .github Folders</>');
182196

183197
$finder = (new Finder())
184198
->ignoreDotFiles(false)
185199
->directories()->name('.github')
186200
->in(Path::vendor().'/*/*/');
187201

202+
if ($finder->count() === 0) {
203+
Helpers::step('<comment>Not Found Ignored Directory:</comment> .github/');
204+
}
205+
188206
foreach ($finder as $file) {
207+
Helpers::step('<comment>Removing Ignored Directory:</comment> '.str_replace(Path::current().'/', '', $file->getRealPath()));
208+
$this->totalFileSize += $file->getSize();
209+
$this->totalDirectories++;
189210
$this->files->deleteDirectory($file->getRealPath(), true);
190211
}
191212
}
@@ -211,7 +232,7 @@ protected function removeOtherFiles(): void
211232
protected function removeDotFiles(): void
212233
{
213234
if (Manifest::isIgnoredVendor(Vendor::DOT_FILES)) {
214-
Helpers::step('<options=bold>Removing Dot Files From Vendor</>');
235+
Helpers::step('<options=bold>Removing Dot Files</>');
215236

216237
$this->removeFiles([
217238
'.editorconfig',
@@ -227,16 +248,29 @@ protected function removeDotFiles(): void
227248
*/
228249
protected function removeFiles($files, $ignoreDotFiles = true): void
229250
{
251+
$isEmpty = true;
252+
230253
foreach ($files as $item) {
231254
$finder = (new Finder())
232255
->files()->name($item)
233256
->ignoreDotFiles($ignoreDotFiles)
234257
->in(Path::vendor().'/*/*/');
235258

259+
if ($finder->count() > 0) {
260+
$isEmpty = false;
261+
}
262+
236263
foreach ($finder as $file) {
264+
$this->totalFileSize += $file->getSize();
265+
$this->totalFiles++;
266+
Helpers::step('<comment>Removing Ignored File:</comment> '.str_replace(Path::current().'/', '', $file->getRealPath()));
237267
$this->files->delete($file->getRealPath());
238268
}
239269
}
270+
271+
if ($isEmpty) {
272+
Helpers::step('<comment>Not Found Ignored File:</comment> '.implode(', ', $files));
273+
}
240274
}
241275

242276
/**
@@ -245,6 +279,9 @@ protected function removeFiles($files, $ignoreDotFiles = true): void
245279
protected function removeDirectory($directory): void
246280
{
247281
if ($this->files->isDirectory($directory)) {
282+
Helpers::step('<comment>Removing Ignored Directory: </comment> '.$directory.'/');
283+
$this->totalFileSize += $this->files->size($directory);
284+
$this->totalDirectories++;
248285
$this->files->deleteDirectory($directory, true);
249286
}
250287
}
@@ -260,15 +297,20 @@ protected function removeUserIgnoredFiles(): void
260297
return;
261298
}
262299

300+
Helpers::step('<options=bold>Removing User Ignored Files</>');
301+
263302
$notFoundDirectories = [];
264303

265304
foreach ($ignoredFiles as $pattern) {
266305
[$directory, $filePattern] = $this->parsePattern($pattern);
267306

268307
if ($this->files->exists($directory.'/'.$filePattern) && $this->files->isDirectory($directory.'/'.$filePattern)) {
269308
Helpers::step('<comment>Removing Ignored Directory:</comment> '.$filePattern.'/');
270-
309+
$fileSize = $this->files->size($directory.'/'.$filePattern);
271310
$this->files->deleteDirectory($directory.'/'.$filePattern);
311+
312+
$this->totalFileSize += $fileSize;
313+
$this->totalDirectories++;
272314
} else {
273315
try {
274316
$files = (new Finder())
@@ -279,8 +321,11 @@ protected function removeUserIgnoredFiles(): void
279321

280322
foreach ($files as $file) {
281323
Helpers::step('<comment>Removing Ignored File:</comment> '.str_replace(Path::current().'/', '', $file->getRealPath()));
282-
324+
$fileSize = $this->files->size($file->getRealPath());
283325
$this->files->delete($file->getRealPath());
326+
327+
$this->totalFileSize += $fileSize;
328+
$this->totalFiles++;
284329
}
285330
} catch (DirectoryNotFoundException) {
286331
$notFoundDirectories[] = $directory.'/'.$filePattern;

src/Manifest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static function addCleanCommandToVaporEnvironments(): void
8787
{
8888
$manifest = static::vapor();
8989

90-
$command = 'php ./vendor/bin/vapor-ignore clean:ignored-file';
90+
$command = 'php ./vendor/bin/vapor-ignore clean:ignored-files';
9191

9292
$environments = $manifest['environments'] ?? [];
9393

src/Path.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Path
1111
*/
1212
public static function vendor(): string
1313
{
14-
return static::build().'/vendor';
14+
return static::current().'/vendor';
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)