2.3
Downloader, Unzipper and Cache
The complete logic of Downloader, Unzipper and Cache was refactored and now works seamlessly with Composer v2.
The logic we follow now is:
- Create a Composer
Package
for each translation package. In this "fake" package, we set the "dist" URL, to the URL of translation package we want to download - we instantiate a Composer's
Downloader
via Composer'sComposer\Downloader\DownloadManager::getDownloader()
- we use the
Downloader
to download the "fake" package, via the Composer'sSyncHelper::downloadAndInstallPackageSync
which is an utility that Composer's developers introduced for this exact scope.
This logic is implemented in
- the edited
Downloader
- the new
TranslationPackageDownloader
. - and in the new ProjectTranslation that helps with the creation of the "fake" package (which actually happens in the
Downloader
)
Code changes
A new FnMatcher
object
Many places in the plugin accepts package names/types via "shell wildcard patterns" (that is, using *
). The new FnMatcher
will provide some reusable code which is used in multiple places.
More powerful download command
The download command already accepts a list of packages, but that list must contain exact names. E. g. "inpsyde/foo", "inpsyde/bar", etc. As a consequence of having the new FnMatcher
class, now the command accepts pattern as well, so we can do --packages="inpsyde/*"
Further improvements
- Support for Composer v1 is now completely removed. It was already officially "not supported", but in
composer.json
we still had compatible constraints, and we had code to deal with v1, now we only require v2 incomposer.json
and all code that dealt with v1 has been removed. - A bug was there when using root packages, due to the fact that often root packages have no version, so Composer adds a "fake" version that causes troubles with the APIs.
- Various plugin tasks/commands are made more "lazy" making the code do nothing until last minute, to avoid undesired side-effects
PackageNameResolver
was a single-static-method class used in two classes in the "Package" namespace. It has been converted to a trait in the "Package" namespace to keep root namespace clean.- The "logo" has been made more "slim", and some other output improvements, for example display the number of errors for each package and an "overall stats" which was missing.
- To make code more "future proof" the method
Composer::getComposer
is not used when using a Composer version where it is deprecated (v2.3+). - The
PluginConfiguration
class now uses constants for hardcoded strings for keys, to avoid typos and get auto-complete. - Some output messages are improved to bring more clarity, or just read better in English.
Test & QA changes
- Psalm has been added to the library.
- PHPUnit usage of mocks as been reduced to the minimum, preferring real classes whenever possible without much effort.
- Behat test setup has been optimized to run tests locally.
- GitHub action workflows have been optimized
Big props to @gmazzap for the time and work put into this 💪