-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
8,906 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace eiriksm\CosyComposer; | ||
|
||
use eiriksm\ViolinistMessages\UpdateListItem; | ||
use Violinist\ComposerLockData\ComposerLockData; | ||
|
||
class LockDataComparer | ||
{ | ||
protected $beforeData; | ||
protected $afterData; | ||
|
||
public function __construct(\stdClass $before, \stdClass $after) | ||
{ | ||
$this->beforeData = ComposerLockData::createFromString(json_encode($before)); | ||
$this->afterData = ComposerLockData::createFromString(json_encode($after)); | ||
} | ||
|
||
/** | ||
* @return UpdateListItem[] | ||
*/ | ||
public function getUpdateList() | ||
{ | ||
$list = []; | ||
$package_types = [ | ||
'packages', | ||
'packages-dev', | ||
]; | ||
$after_data = $this->afterData->getData(); | ||
foreach ($package_types as $package_type) { | ||
foreach ($after_data->{$package_type} as $package) { | ||
// See if we can find that one in the before data. | ||
$old_package = null; | ||
try { | ||
$old_package = $this->beforeData->getPackageData($package->name); | ||
} catch (\Exception $e) { | ||
// Must mean the package is new, it was not installed before. | ||
} | ||
if (!$old_package) { | ||
// Must mean the package is new, it was not installed before. | ||
$list[] = new UpdateListItem($package->name, $package->version); | ||
} else { | ||
if ($old_package->version === $package->version) { | ||
continue; | ||
} | ||
$list[] = new UpdateListItem($package->name, $package->version, $old_package->version); | ||
} | ||
} | ||
} | ||
|
||
return $list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "derpy/derp", | ||
"require": { | ||
"drupal/core": "^8.8.0" | ||
} | ||
} |
Oops, something went wrong.