Skip to content

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jul 26, 2018
2 parents 94408ac + 931d45e commit 2a78172
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -40,6 +40,19 @@ composer require bringyourownideas/silverstripe-composer-update-checker ^1
vendor/bin/sake dev/build flush=1
vendor/bin/sake dev/tasks/UpdatePackageInfoTask
```

## Note for private repositories

Please note that if your project has modules that are stored in private repositories, the server running the BuildTask
will need to have the necessary permissions to access the private VCS repositories in order for the report to include
update information about necessary updates to the module.

If the process looking for available updates fails (for example, due to an authentication failure against a private
repository) the process will fail gracefully and allow the rest of the report generation to continue.

Users on the [Common Web Platform](https://cwp.govt.nz) will currently not be able to retrieve information about
updates to private repositories.

## Documentation

Please see the user guide section of the [SilverStripe Maintenance module](https://github.com/bringyourownideas/silverstripe-maintenance/tree/master/docs/en/userguide).
Expand Down
18 changes: 15 additions & 3 deletions src/Extensions/CheckComposerUpdatesExtension.php
Expand Up @@ -4,8 +4,11 @@

use BringYourOwnIdeas\Maintenance\Tasks\UpdatePackageInfoTask;
use BringYourOwnIdeas\UpdateChecker\UpdateChecker;
use Psr\Log\LoggerInterface;
use RuntimeException;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;

/**
* Task which does the actual checking of updates
Expand Down Expand Up @@ -51,9 +54,18 @@ public function updatePackageInfo(array &$installedPackageList)
}
$packageData = $composerPackagesAndConstraints[$packageName];

// Check for a relevant update version to recommend returned as keyed array and add to existing package
// details array
$updates = $this->getUpdateChecker()->checkForUpdates($packageData['package'], $packageData['constraint']);
try {
// Check for a relevant update version to recommend returned as keyed array and add to existing package
// details array
$updates = $this->getUpdateChecker()
->checkForUpdates($packageData['package'], $packageData['constraint']);
} catch (RuntimeException $ex) {
// If exceptions are thrown during execution, fail gracefully and allow the rest of the report
// generation to continue
$updates = [];
Injector::inst()->get(LoggerInterface::class)->debug($ex->getMessage());
}

$installedPackage = array_merge($installedPackage, $updates);
}
}
Expand Down

0 comments on commit 2a78172

Please sign in to comment.