From da38f18a721ebe44bdb38bfcf894c49503a09900 Mon Sep 17 00:00:00 2001 From: Sam Bramley Date: Mon, 4 Dec 2017 23:19:14 -0600 Subject: [PATCH 1/3] First ever commit to open source :-O Be gentle... I've added a get contents method on the current composer.lock file, this should capture all the installed package versions then map them to the composer.json file so you can see not only what minimum requirements your package has, but what the currently installed version is as well. --- src/Decomposer.php | 11 ++++++++++- src/views/index.blade.php | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Decomposer.php b/src/Decomposer.php index 2aa4bc7..9ee3820 100644 --- a/src/Decomposer.php +++ b/src/Decomposer.php @@ -133,6 +133,14 @@ public static function getComposerArray() public static function getPackagesAndDependencies($packagesArray) { + $lock_file = json_decode(file_get_contents(base_path('composer.lock'))); + + // reformat packages for easy reference + $package_lock_details = []; + foreach($lock_file->packages as $the_package) { + $package_lock_details[$the_package->name] = $the_package; + } + foreach ($packagesArray as $key => $value) { $packageFile = base_path("/vendor/{$key}/composer.json"); @@ -146,7 +154,8 @@ public static function getPackagesAndDependencies($packagesArray) 'name' => $key, 'version' => $value, 'dependencies' => $dependencies, - 'dev-dependencies' => $devDependencies + 'dev-dependencies' => $devDependencies, + 'version-installed' => isset($package_lock_details[$key]) ? $package_lock_details[$key] : "" ]; } } diff --git a/src/views/index.blade.php b/src/views/index.blade.php index bc4ae44..b336f38 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -128,14 +128,15 @@ - + + @foreach($packages as $package) - + - +
Package Name : VersionPackage Name : Version : Version Installed Dependency Name : Version
{{ $package['name'] }} : {{ $package['version'] }}{{ $package['name'] }} : {{ $package['version'] }} : {{ $package['version-installed']->version }}
    @if(is_array($package['dependencies'])) From f79e6cbaa2f72d050c5d3d399fd7bcd9591cf114 Mon Sep 17 00:00:00 2001 From: Sam Bramley Date: Tue, 5 Dec 2017 11:39:54 -0600 Subject: [PATCH 2/3] Updated logic to match coding standards of package, added a wrapper in for the composer.lock file should it not exist. --- src/Decomposer.php | 16 +++++++++------- src/views/index.blade.php | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Decomposer.php b/src/Decomposer.php index 9ee3820..fb95f7c 100644 --- a/src/Decomposer.php +++ b/src/Decomposer.php @@ -133,13 +133,15 @@ public static function getComposerArray() public static function getPackagesAndDependencies($packagesArray) { - $lock_file = json_decode(file_get_contents(base_path('composer.lock'))); + $packageLockDetails = []; + if(file_exists(base_path('composer.lock'))) { + $lockFile = json_decode(file_get_contents(base_path('composer.lock'))); - // reformat packages for easy reference - $package_lock_details = []; - foreach($lock_file->packages as $the_package) { - $package_lock_details[$the_package->name] = $the_package; - } + $packageLockDetails = []; + foreach ($lockFile->packages as $package) { + $packageLockDetails[$package->name] = $package; + } + } foreach ($packagesArray as $key => $value) { $packageFile = base_path("/vendor/{$key}/composer.json"); @@ -155,7 +157,7 @@ public static function getPackagesAndDependencies($packagesArray) 'version' => $value, 'dependencies' => $dependencies, 'dev-dependencies' => $devDependencies, - 'version-installed' => isset($package_lock_details[$key]) ? $package_lock_details[$key] : "" + 'version-installed' => isset($packageLockDetails[$key]) ? $packageLockDetails[$key] : "" ]; } } diff --git a/src/views/index.blade.php b/src/views/index.blade.php index b336f38..8f3b1b1 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -136,7 +136,7 @@ @foreach($packages as $package)
{{ $package['name'] }} : {{ $package['version'] }} : {{ $package['version-installed']->version }} {{ $package['name'] }} : {{ $package['version'] }} : {{ isset($package['version-installed']->version) ? $package['version-installed']->version : "N/A" }}
    @if(is_array($package['dependencies'])) From 37bda1a1ac3ee0c42d07e4c4e46d30e23edc1e7c Mon Sep 17 00:00:00 2001 From: Sam Bramley Date: Tue, 5 Dec 2017 11:47:06 -0600 Subject: [PATCH 3/3] No tabs, only spaces. --- src/Decomposer.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Decomposer.php b/src/Decomposer.php index fb95f7c..9f67df4 100644 --- a/src/Decomposer.php +++ b/src/Decomposer.php @@ -133,15 +133,15 @@ 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 = []; + 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; - } - } + $packageLockDetails = []; + foreach ($lockFile->packages as $package) { + $packageLockDetails[$package->name] = $package; + } + } foreach ($packagesArray as $key => $value) { $packageFile = base_path("/vendor/{$key}/composer.json"); @@ -276,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;