-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
base: master
Are you sure you want to change the base?
feature/add-currently-installed-package-versions #17
Conversation
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
Outdated
|
||
// reformat packages for easy reference | ||
$package_lock_details = []; | ||
foreach($lock_file->packages as $the_package) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected 1 space after FOREACH keyword; 0 found
@sbramley Hey thanks for the PR, it's great 🙂 Few nitpicks:
|
src/views/index.blade.php
Outdated
@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">{{ $package['version-installed']->version }}</span> </td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess only $package['version-installed']
would work. No need of ->version
again at the end. Not sure, make sure you test it :) Will be adding tests to this package really soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey mate, I'm actually taking the entire package object and passing it across, so you could effectively get more than the version:
"aws/aws-sdk-php" => {#716 ▼
+"name": "aws/aws-sdk-php"
+"version": "3.40.0"
+"source": {#721 ▶}
+"dist": {#719 ▶}
+"require": {#714 ▶}
+"require-dev": {#724 ▶}
+"suggest": {#720 ▶}
+"type": "library"
+"extra": {#725 ▶}
+"autoload": {#727 ▶}
+"notification-url": "https://packagist.org/downloads/"
+"license": array:1 [▶]
+"authors": array:1 [▶]
+"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project"
+"homepage": "http://aws.amazon.com/sdkforphp"
+"keywords": array:8 [▶]
+"time": "2017-11-27T09:20:45+00:00"
}
I can pass just the version across if you prefer it that way, I normally lean to more info so it's easy to extend on.
…n for the composer.lock file should it not exist.
src/Decomposer.php
Outdated
@@ -133,6 +133,16 @@ public static function getComposerArray() | |||
|
|||
public static function getPackagesAndDependencies($packagesArray) | |||
{ | |||
$packageLockDetails = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
@@ -133,6 +133,16 @@ public static function getComposerArray() | |||
|
|||
public static function getPackagesAndDependencies($packagesArray) | |||
{ | |||
$packageLockDetails = []; | |||
if(file_exists(base_path('composer.lock'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Spaces must be used to indent lines; tabs are not allowed
- Expected 1 space after IF keyword; 0 found
src/Decomposer.php
Outdated
@@ -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'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
if(file_exists(base_path('composer.lock'))) { | ||
$lockFile = json_decode(file_get_contents(base_path('composer.lock'))); | ||
|
||
$packageLockDetails = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
$lockFile = json_decode(file_get_contents(base_path('composer.lock'))); | ||
|
||
$packageLockDetails = []; | ||
foreach ($lockFile->packages as $package) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
|
||
$packageLockDetails = []; | ||
foreach ($lockFile->packages as $package) { | ||
$packageLockDetails[$package->name] = $package; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
$packageLockDetails = []; | ||
foreach ($lockFile->packages as $package) { | ||
$packageLockDetails[$package->name] = $package; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
src/Decomposer.php
Outdated
foreach ($lockFile->packages as $package) { | ||
$packageLockDetails[$package->name] = $package; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces must be used to indent lines; tabs are not allowed
@@ -133,6 +133,16 @@ public static function getComposerArray() | |||
|
|||
public static function getPackagesAndDependencies($packagesArray) | |||
{ | |||
$packageLockDetails = []; |
There was a problem hiding this comment.
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.
@@ -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) { |
There was a problem hiding this comment.
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 :)
@@ -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> |
There was a problem hiding this comment.
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
@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> |
There was a problem hiding this comment.
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?
@sbramley this looks neat :) Few final minor things, after that it's ready to be merged. Thank you for the contribution Sam 🙂 |
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.