wearerequired / composer-scripts

🧰 A collection of useful Composer scripts and commands, especially for WordPress projects.
https://packagist.org/packages/wearerequired/composer-scripts
4 stars 0 forks source link

Check if api.w.org is available #5

Open ocean90 opened 7 years ago

ocean90 commented 7 years ago

Currently when you run composer update and api.w.org isn't available you get two misleading warnings. Example:

> Required\ComposerScripts\PluginAvailability::checkAvailability
The plugin wpackagist-plugin/facebook-conversion-pixel does not seem to be available in the WordPress Plugin Directory anymore
> Required\ComposerScripts\PluginAvailability::checkMaintenanceStatus
The plugin wpackagist-plugin/facebook-conversion-pixel has not been updated in over two years. Please double-check before using it.
  - Updating wpackagist-plugin/facebook-conversion-pixel (2.0.1 => 2.1.0): Downloading (100%)

I suggest to check the HTTP response and provide some more information in this case. Or skip any checks.

ocean90 commented 6 years ago

isPluginAvailable() and isPluginActivelyMaintained() are already trying to catch an ErrorException exception. So if loadPluginData() would return an exception in case of an unavailable API we could instead return true in both methods and print a debug message (once?) that the API couldn't be reached.

swissspidy commented 6 years ago

We could probably add a private property to the class and set that flag once the API is not available. At the end, add an info/warning if the flag is set.

What if the API is only unavailable for some requests?

Also, it's probably easier to add a custom Exception class for this.

swissspidy commented 6 years ago

See also https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper/commit/68d6912bb18e45db5e47757fcb2d2b61d1a32941