Skip to content

Releases: inpsyde/wp-translation-downloader

2.5

14 Apr 08:54
623b060
Compare
Choose a tag to compare

Use HttpDownloader in [TranslatablePackageFactory

Previously the JSON data was downloaded via file_get_contents(), which did not allow to make use of the stored credentials in Composer Config file. This new implementation will make use of the Composer\Util\HttpDownloader internally, which uses the Composer Config and the stored credentials to send alongside with the Request API Tokens or Basic Auth credentials.

Read more about the changes in docs: Configuration.md

This new implementation solves some requirements from #35 .

QoL

  • workflows/behat.yml // remove composer v2.0 which has no support for PHP 8.1

  • [workflows/behat.yml // add PHP 8.1 and 8.2 and Composer v2.4 and v2.5

  • workflows // add lint-php and combine 3 workflows into 1 workflow run.

2.4

09 Dec 13:09
531e545
Compare
Choose a tag to compare
2.4

TranslatablePackageFactory

Introduce new placeholders for resolving the endpoint URL dynamically.

For custom GlotPress installations, the REST Endpoints can be cached. We added the following new placeholders, which will automatically be filled in based on the current Package:

  • %packageDistSha1Checksum% - The sha1 checksum for the distribution archive of this version
  • %packageDistReference% - The reference of the distribution archive. E.g., main, 1.0.0, or a commit hash
  • %packageSourceReference% - The repository reference. E.g., main, 1.0.0, or a commit hash
  • %packageUniqueName% - The package's unique name, constructed from name and version

2.3

22 Jun 07:55
2539fd3
Compare
Choose a tag to compare
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:

  1. 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
  2. we instantiate a Composer's Downloader via Composer's Composer\Downloader\DownloadManager::getDownloader()
  3. we use the Downloader to download the "fake" package, via the Composer's SyncHelper::downloadAndInstallPackageSync which is an utility that Composer's developers introduced for this exact scope.

This logic is implemented in


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 in composer.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 💪

2.2.1

25 May 11:28
5edb344
Compare
Choose a tag to compare

Fix: Virtual Packages in DownloadCommand

This release fixes an issue with the newly introduced virtual-packages which were not used in the composer wp-translation-downloader:download command. To reduce duplicated code, a new method Plugin::availablePackages(Composer $composer): array was introduced, which is being used internally in Plugin and in DownloadCommand to guarantee the same collection of Composer\Package\PackageInterface, when executing the command or using "auto-run": true in configuration.

2.2

24 May 07:25
b5867d8
Compare
Choose a tag to compare
2.2

Virtual Packages

This version introduces a new configuration setting virtual-packages which allows you to define "pre-installed platform dependencies", which are not part of require or require-dev in composer.json, to be able to download those translations additionally.

Read more: https://github.com/inpsyde/wp-translation-downloader/blob/2.2/docs/Configuraton.md#virtual-packages


New command clean-cache

This version introduces a new command composer wp-translation-downloader:clean-cache to allow deleting the translation zip file cache without clearing the whole composer cache.

Read more: https://github.com/inpsyde/wp-translation-downloader/blob/2.2/docs/Commands.md#clean-cache


Improvements

Plugin

  • keep track of already processed folders (created) to avoid multiple filesystem calls.
  • doUpdatePackage() - change order to avoid creating a TranslatablePackage when it is excluded.

Remover

  • catch exception in case the folder does not exist and write down exception in verbose mode.

Behat

  • Moved complete test suite into tests/-folder.

props to @gmazzap and @benoitchantre for testing and discussions 💪

2.1.1

13 May 14:19
72ab08b
Compare
Choose a tag to compare

Fixes

  • PluginConfiguration, TranslatablePackageFactory // ensure that directory separator is correctly trimmed on end of directory input.
  • Plugin // changed Plugin::ensureDirectories() to Plugin::ensureDirectoryExists(string $dir) and call when iterating over TranslatablePackage. Relates to: #29
  • Downloader // use the "updated" date for translations as filemtime() on cached ZIP files.. Ensure that updated zip files are downloaded again. Relates to: #30

Improvements

  • Unzipper // only write information about "falling back from unzip to ZipArchive" and vise versa when running in verbose mode.
  • workflows/behat // make use of ramsey/composer-install@v1. upgrade actions/checktout to v3, add --colors to behat call.
  • tests // moved "features" into "tests/Behat"-folder. Moved FeatureContext into Inpsyde\WpTranslationDownloader-namespace.

2.1

12 May 08:30
050c8fd
Compare
Choose a tag to compare
2.1

Locker

This release introduces the Util\Locker-class, which will generate on installation a wp-translation-downloader.lock-file to keep track of the installated translations. On next run it will check against the lock file and only download newer translation files.

Related issues: #9 #26
Read more: https://github.com/inpsyde/wp-translation-downloader/blob/master/docs/Locker.md

Custom composer types and directories

This release will allow you to configure in your wp-translation-downloader.json the directories.names and directories.types mapping with a sub-folder name. This will also open this package to install every Composer type available, instead of just the pre-defined static ones included in this package.

The configuration key directory is now deprecated and will be removed in future. Please make sure to update your configuration to the new key languageRootDir.

Related issues: #13 #27
Read more: https://github.com/inpsyde/wp-translation-downloader/blob/master/docs/Configuraton.md#languagerootdir-and-directories

Support for root package

The root package, which contains the wp-translation-downloader-configuration, is now also added to the list of packages to process.

Related issue: #25 #27

JSON Schema validation

When loading the wp-translation-downloader-configuration, we will now use https://json-schema.org/ to validate the file by using justinrainbow/json-schema, which is included in Composer.

The PluginConfigurationBuilder::build() will now return null when the JSON Schema does not validate successfully against the input and print out information about the errors.

Related issue: #28

Changes under the hood

This release contains a few changes under the hood, including some refactored code and simplifications:

  • Removed Inpsyde\WpTranslationDownloader\Io - instead Composer\IO\IOInterface is now used.
  • Introduced a new TranslateablePackage and TranslatablePackageInterface which replaces the specific implementations of WpCorePackage, WpThemePackage, WpPluginPackage, LibraryPackage and the TranslatablePackageTrait.
  • Plugin will now not create services on activate(). Instead a new method Plugin::bootstrap() was implemented and is being used in the event callbacks to instantiate the Services late.
  • ApiEndpointResolver was merged into TranslatablePackageFactory.
  • PluginConfiguration::isValid() was removed due the newly implemented JSON Schema implementation.

Improvements

  • Documentation is now moved into docs/-folder, split into mulitiple files and has more examples and details in it.
  • Allow composer/installers v2.
  • composer normalize.
  • add config.allow-plugins property.
  • Run tests on PHP v8.0 and v8.1.
  • More behat tests were added 😱
  • Removed issue templates - the global Inpsyde ones from https://github.com/inpsyde/.github are now used.
  • Use inpsyde/reusable-workflows for running Github Action workflows.

props to @tyrann0us 💪 and myself @Chrico 😬

2.0.4

04 Nov 08:43
026fe59
Compare
Choose a tag to compare

Improvements

  • Plugin // add check for Cache folder to be enabled (created).

2.0.3

25 Mar 09:37
e01829a
Compare
Choose a tag to compare

Fixes

  • Fix unused "excludes" from PluginConfig while updating translations.

Improvements

  • Add new testcase for testing "exclude".
  • Update documentation examples to use "dev-master" instead of a specific version of wp-translation-downloader.

1.2.3

26 Mar 06:30
1c6df86
Compare
Choose a tag to compare

Bugfixes

  • Fix unused "excludes" from PluginConfig while updating translations.