diff --git a/src/Decomposer.php b/src/Decomposer.php index 2aa4bc7..9f67df4 100644 --- a/src/Decomposer.php +++ b/src/Decomposer.php @@ -133,6 +133,16 @@ public static function getComposerArray() public static function getPackagesAndDependencies($packagesArray) { + $packageLockDetails = []; + 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"); @@ -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] : "" ]; } } @@ -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) { $size += is_file($each) ? filesize($each) : self::folderSize($each); } return $size; diff --git a/src/views/index.blade.php b/src/views/index.blade.php index bc4ae44..8f3b1b1 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -128,14 +128,15 @@
Package Name : Version | +Package Name : Version : Version Installed | Dependency Name : Version |
---|---|---|
{{ $package['name'] }} : {{ $package['version'] }} | +{{ $package['name'] }} : {{ $package['version'] }} : {{ isset($package['version-installed']->version) ? $package['version-installed']->version : "N/A" }} |
|