Skip to content
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/add-currently-installed-package-versions #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Decomposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ public static function getComposerArray()

public static function getPackagesAndDependencies($packagesArray)
{
$packageLockDetails = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $packageLockDetails array is also initialized in the if loop below. We don't need to initialize it twice.

if (file_exists(base_path('composer.lock'))) {
$lockFile = json_decode(file_get_contents(base_path('composer.lock')));

$packageLockDetails = [];
foreach ($lockFile->packages as $package) {
$packageLockDetails[$package->name] = $package;
}
}

foreach ($packagesArray as $key => $value) {
$packageFile = base_path("/vendor/{$key}/composer.json");

Expand All @@ -146,7 +156,8 @@ public static function getPackagesAndDependencies($packagesArray)
'name' => $key,
'version' => $value,
'dependencies' => $dependencies,
'dev-dependencies' => $devDependencies
'dev-dependencies' => $devDependencies,
'version-installed' => isset($packageLockDetails[$key]) ? $packageLockDetails[$key] : ""
];
}
}
Expand Down Expand Up @@ -265,7 +276,7 @@ private static function checkSslIsInstalled()
private static function folderSize($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
foreach (glob(rtrim($dir, '/') . '/*', GLOB_NOSORT) as $each) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may remove the spaces back, it looks clean that older way :)

$size += is_file($each) ? filesize($each) : self::folderSize($each);
}
return $size;
Expand Down
5 changes: 3 additions & 2 deletions src/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,15 @@
<table id="decomposer" class="table table-hover table-bordered">
<thead>
<tr>
<th>Package Name : Version</th>
<th>Package Name : Version : Version Installed</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this Package name : Required version : Version installed

<th>Dependency Name : Version</th>
</tr>
</thead>
<tbody>

@foreach($packages as $package)
<tr>
<td>{{ $package['name'] }} : <span class="label ld-version-tag">{{ $package['version'] }}</span></td>
<td>{{ $package['name'] }} : <span class="label ld-version-tag">{{ $package['version'] }}</span> : <span class="label ld-version-tag">{{ isset($package['version-installed']->version) ? $package['version-installed']->version : "N/A" }}</span> </td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the array above why $package['version-installed']->version I guess $package['version-installed'] should be enough?

<td>
<ul>
@if(is_array($package['dependencies']))
Expand Down