inpsyde / wp-translation-downloader

Composer plugin to download WordPress translations
MIT License
45 stars 3 forks source link

Make use of HttpDownloader and JsonFile for downloading the TranslatePackage translations. #38

Closed Chrico closed 1 year ago

Chrico commented 1 year ago

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

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 implementation will make use of the Composer HttpDownloader which uses internally the Composer Config and the stored credentials to send alongside with the Request API Tokens or Basic Auth credentials.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No

Other information:

See #35

Chrico commented 1 year ago

LGTM. Did you already do some e2e test?

yip - at least some local testing. Not sure how we can cover that with Behat. I guess for that we need to start a PHP server, which logs requests (GET and SERVER) away into a file and afterwards we can check the log file if the bearer/basic is set. 😬 Probably easier to do with some Integration Test Suite.... ;)

What I did:

wp-translation-downloader.json

{
    "auto-run": false,
    "api": {
        "names": {
            "*": "http://my-local-machine.localhost.com/?package=%projectName%"
        }
    }
}

auth.json

{
    "bearer": {
        "my-local-machine.localhost.com": "some-random-token123"
    }
}

When setting debug breakpoint on the index.php I can see: image

And with auth.json:

{
     "http-basic": {
        "my-local-machine.localhost.com": {
            "username": "username",
            "password": "password"
        }
    },
}

I can see: image