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 1 commit
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
11 changes: 10 additions & 1 deletion src/Decomposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

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

$package_lock_details[$the_package->name] = $the_package;
}

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

Expand All @@ -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] : ""
];
}
}
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">{{ $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.

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