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

Conversation

sbramley
Copy link

@sbramley sbramley commented Dec 5, 2017

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.

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.

// reformat packages for easy reference
$package_lock_details = [];
foreach($lock_file->packages as $the_package) {

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

@introwit
Copy link
Contributor

introwit commented Dec 5, 2017

@sbramley Hey thanks for the PR, it's great 🙂 Few nitpicks:

  • Use camelCasing for variable names instead of underscores.
  • Remove that comment saying // reformat packages for easy reference
  • Put a space after foreach keyword
  • Rename the_package variable to just package

@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>
Copy link
Contributor

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

Copy link
Author

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.
@@ -133,6 +133,16 @@ public static function getComposerArray()

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

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 = [];
if(file_exists(base_path('composer.lock'))) {

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

@@ -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')));

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

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

$packageLockDetails = [];

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

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

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

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


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

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

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

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

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

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 = [];
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.

@@ -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 :)

@@ -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

@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?

@introwit
Copy link
Contributor

introwit commented Dec 6, 2017

@sbramley this looks neat :) Few final minor things, after that it's ready to be merged. Thank you for the contribution Sam 🙂

@ajitbohra
Copy link
Member

@sbramley thanks for the PR, can you help us with the changes @introwit suggested and we are all good to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants