Skip to content

Commit

Permalink
FIX Don't try getting information from packagist
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed May 7, 2024
1 parent 8168234 commit baf2287
Show file tree
Hide file tree
Showing 12 changed files with 432 additions and 877 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions client/src/components/ModuleDetails/ModuleDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import i18n from 'i18n';
import { Popover, PopoverHeader, PopoverBody } from 'reactstrap';
import ModuleHealthIndicator from 'components/ModuleDetails/ModuleHealthIndicator';

/**
* Module details are a link and popover, attached to each report row. The popover
* will contain a description, link to more information, ratings, etc
* will contain a description, link to more information, etc
*/
class ModuleDetails extends Component {
constructor(props) {
Expand Down Expand Up @@ -61,7 +60,7 @@ class ModuleDetails extends Component {
}

render() {
const { dataSchema: { description, link, linkTitle, rating }, detailsId } = this.props;
const { dataSchema: { description, link, linkTitle }, detailsId } = this.props;
const popoverId = `${detailsId}-popover`;
const triggerId = `${detailsId}-trigger`;

Expand All @@ -88,8 +87,6 @@ class ModuleDetails extends Component {
<span className="package-summary__details-header-text">
{i18n._t('ModuleDetails.MODULE_INFO', 'Module info')}
</span>

<ModuleHealthIndicator link={link} rating={rating} />
</PopoverHeader>

<PopoverBody>
Expand Down Expand Up @@ -121,8 +118,7 @@ ModuleDetails.propTypes = {
description: PropTypes.string,
link: PropTypes.string,
linkTitle: PropTypes.string,
securityAlerts: PropTypes.array,
rating: PropTypes.number
securityAlerts: PropTypes.array
}),
};

Expand Down
5 changes: 2 additions & 3 deletions docs/en/userguide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ the CMS while the update is run.

## Check for additional modules

Click on the 'Explore Addons' button to access [SilverStripe's Add-ons](https://www.silverstripe.org/software/addons/) repository. Use this site to find modules and
themes to add to your SilverStripe website.
Click on the 'Browse Modules' button to browse [Silverstripe CMS modules on packagist](https://packagist.org/search/?type=silverstripe-vendormodule).

## What do "Version, Available, Latest" mean?

Expand All @@ -59,7 +58,7 @@ version, it means that this latest version is outside of your version constraint

## What do the security alerts mean?

The [SilverStripe Composer Security Checker module](https://addons.silverstripe.org/add-ons/bringyourownideas/silverstripe-composer-security-checker)
The [SilverStripe Composer Security Checker module](https://packagist.org/packages/bringyourownideas/silverstripe-composer-security-checker)
adds a task which runs a check if any of the dependencies has known security vulnerabilities.

Provided this optional module is installed, you may see security alerts, if security updates are present for installed
Expand Down
2 changes: 2 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ en:
db_Version: Version
db_VersionConstraint: 'Version constraint'
db_VersionHash: 'Version hash'
VIEW_ON_PACKAGIST: 'View {package} on packagist.org'
BringYourOwnIdeas\Maintenance\Reports\SiteSummary:
FilterSupported: 'Supported modules'
FilterUnsupported: 'Unsupported modules'
LAST_UPDATED: 'Last updated {updated}'
LINK_TO_ADDONS: 'Explore Addons'
LINK_TO_PACKAGIST: 'Browse Modules'
MORE_INFORMATION: 'More information'
ShowAllModules: 'Show all modules'
TITLE: 'Installed modules'
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ public function getDataSchema()
{
$schema = [
'description' => $this->Description,
'link' => 'https://addons.silverstripe.org/add-ons/' . $this->Name,
'link' => 'https://packagist.org/packages/' . $this->Name,
'linkTitle' => _t(
__CLASS__ . '.ADDONS_LINK_TITLE',
'View {package} on addons.silverstripe.org',
__CLASS__ . '.VIEW_ON_PACKAGIST',
'View {package} on packagist.org',
['package' => $this->Title]
),
'rating'=> (int) $this->Rating
Expand Down
4 changes: 2 additions & 2 deletions src/Reports/SiteSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public function getReportField()
Injector::inst()->create(GridFieldRefreshButton::class, 'buttons-before-left'),
Injector::inst()->create(
GridFieldLinkButton::class,
'https://addons.silverstripe.org',
_t(__CLASS__ . '.LINK_TO_ADDONS', 'Explore Addons'),
'https://packagist.org/search/?type=silverstripe-vendormodule',
_t(__CLASS__ . '.LINK_TO_PACKAGIST', 'Browse Modules'),
'buttons-before-left'
),
$this->getDropdownFilter(),
Expand Down
16 changes: 11 additions & 5 deletions src/Tasks/UpdatePackageInfoTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\ORM\DataObjectSchema;
use BringYourOwnIdeas\Maintenance\Model\Package;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Dev\Deprecation;

/**
* Parses a composer lock file in order to cache information about the installation.
Expand Down Expand Up @@ -66,6 +67,7 @@ class UpdatePackageInfoTask extends BuildTask

/**
* @var ModuleHealthLoader
* @deprecated 3.2.0 Will be removed without equivalent functionality
*/
protected $moduleHealthLoader;

Expand Down Expand Up @@ -112,18 +114,24 @@ public function setSupportedAddonsLoader(SupportedAddonsLoader $supportedAddonsL

/**
* @return ModuleHealthLoader
* @deprecated 3.2.0 Will be removed without equivalent functionality
*/
public function getModuleHealthLoader()
{
Deprecation::notice('3.2.0', 'Will be removed without equivalent functionality');
return $this->moduleHealthLoader;
}

/**
* @param ModuleHealthLoader $moduleHealthLoader
* @return $this
* @deprecated 3.2.0 Will be removed without equivalent functionality
*/
public function setModuleHealthLoader(ModuleHealthLoader $moduleHealthLoader)
{
Deprecation::withNoReplacement(
fn() => Deprecation::notice('3.2.0', 'Will be removed without equivalent functionality')
);
$this->moduleHealthLoader = $moduleHealthLoader;
return $this;
}
Expand Down Expand Up @@ -166,7 +174,6 @@ public function run($request)
$moduleNames = array_column($packages ?? [], 'Name');

$supportedPackages = $this->getSupportedPackages();
$moduleHealthInfo = $this->getHealthIndicator($moduleNames);

// Extensions to the process that add data may rely on external services.
// There may be a communication issue between the site and the external service,
Expand All @@ -181,9 +188,6 @@ public function run($request)
if (is_array($supportedPackages)) {
$package['Supported'] = in_array($packageName, $supportedPackages ?? []);
}
if (is_array($moduleHealthInfo) && isset($moduleHealthInfo[$packageName])) {
$package['Rating'] = $moduleHealthInfo[$packageName];
}
Package::create()->update($package)->write();
}
}
Expand Down Expand Up @@ -213,7 +217,7 @@ public function getPackageInfo($packageList)
}

/**
* Return an array of supported modules as fetched from addons.silverstripe.org. Outputs a message and returns null
* Return an array of supported modules as fetched from silverstripe/supported-modules. Outputs a message and returns null
* if an error occurs
*
* @return null|array
Expand All @@ -235,9 +239,11 @@ public function getSupportedPackages()
*
* @param string[] $moduleNames
* @return null|array
* @deprecated 3.2.0 Will be removed without equivalent functionality
*/
public function getHealthIndicator(array $moduleNames)
{
Deprecation::notice('3.2.0', 'Will be removed without equivalent functionality');
try {
return $this->getModuleHealthLoader()->setModuleNames($moduleNames)->getModuleHealthInfo() ?: [];
} catch (RuntimeException $exception) {
Expand Down
2 changes: 2 additions & 0 deletions src/Util/ApiLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SilverStripe\Core\Convert;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;

/**
* Handles fetching supported module details
Expand Down Expand Up @@ -74,6 +75,7 @@ public function doRequest($endpoint, callable $callback)
$responseJson = $this->parseResponseContents($response->getBody()->getContents(), $failureMessage);

if (str_contains($endpoint, 'addons.silverstripe.org')) {
Deprecation::notice('3.2.0', 'addons.silverstripe.org is no longer operational. Use packagist instead.', Deprecation::SCOPE_GLOBAL);
if (!isset($responseJson['success']) || !$responseJson['success']) {
throw new RuntimeException($failureMessage . 'Response returned unsuccessfully');
}
Expand Down
Loading

0 comments on commit baf2287

Please sign in to comment.