Skip to content

Conversation

@keywan-ghadami-oxid
Copy link
Contributor

include require-dev section from the module into the oxid installation
to be able to use development tools like phpstan

@alfredbez
Copy link
Collaborator

This looks a bit messy to me, maybe we should find a more readable and maintainable way for this.

@keywan-ghadami-oxid
Copy link
Contributor Author

any ideas?

@alfredbez
Copy link
Collaborator

We could create a script (copy-composer-contents.php?) like this:

<?php
$buildDir = getenv('BUILD_DIR');

$orgComposerContent = json_decode(file_get_contents("$buildDir/composer.json"), true);

$stuffToCopy = ['repositories', 'config', 'require-dev'];
$parts = [];
foreach ($stuffToCopy as $key) {
  $parts[$key] = $orgComposerContent[$key] ?: [];
}

$newComposerContent = json_decode(file_get_contents('composer.json'), true);
$newComposerContent = array_replace_recursive($newComposerContent, $reuse);

file_put_contents('composer.json', json_encode($newComposerContent, JSON_PRETTY_PRINT));

@alfredbez
Copy link
Collaborator

I'll close and reopen this to test if the travis build works.

@alfredbez alfredbez closed this Dec 5, 2019
@alfredbez alfredbez reopened this Dec 5, 2019
@alfredbez
Copy link
Collaborator

I'm not 100% sure, but I think that this also broke the script:

PHP Notice:  Undefined index: repositories in Command line code on line 3
PHP Stack trace:
PHP   1. {main}() Command line code:0
Notice: Undefined index: repositories in Command line code on line 3
Call Stack:
    0.0001     372576   1. {main}() Command line code:0
PHP Notice:  Undefined index: config in Command line code on line 4
PHP Stack trace:
PHP   1. {main}() Command line code:0
Notice: Undefined index: config in Command line code on line 4
Call Stack:
    0.0001     372576   1. {main}() Command line code:0
PHP Warning:  array_replace_recursive(): Argument #2 is not an array in Command line code on line 6
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. array_replace_recursive() Command line code:6
Warning: array_replace_recursive(): Argument #2 is not an array in Command line code on line 6
Call Stack:
    0.0001     372576   1. {main}() Command line code:0
    0.0003     389512   2. array_replace_recursive() Command line code:6
PHP Warning:  array_replace_recursive(): Argument #1 is not an array in Command line code on line 7
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. array_replace_recursive() Command line code:7
Warning: array_replace_recursive(): Argument #1 is not an array in Command line code on line 7
Call Stack:
    0.0001     372576   1. {main}() Command line code:0
    0.0003     388584   2. array_replace_recursive() Command line code:7
                                                                             
  [Composer\Json\JsonValidationException]                                    
  "./composer.json" does not match the expected JSON schema:                 
   - config : NULL value found, but an object is required                    
   - repositories : NULL value found, but an object or an array is required  

We need proper checks for this one, too I guess.

@keywan-ghadami-oxid
Copy link
Contributor Author

is that error from this branch? because the line number do not match, do they?

@alfredbez
Copy link
Collaborator

Just had the same error again, the unit-tests for my module are not executed anymore:

+ composer config repositories.build path /srv
+ php -r '
$orgComposerJson=json_decode(file_get_contents('\''/srv/composer.json'\''),true);
$reUse['\''repositories'\''] = $orgComposerJson['\''repositories'\''];
$reUse['\''config'\''] = $orgComposerJson['\''config'\''];
$c=json_decode(file_get_contents('\''composer.json'\''), true);
$c['\''repositories'\'']=array_replace_recursive($c['\''repositories'\''], $reUse['\''repositories'\'']);
$c['\''config'\'']=array_replace_recursive($reUse['\''config'\''], $c['\''config'\'']);
file_put_contents('\''composer.json'\'', json_encode($c, JSON_PRETTY_PRINT));
//print json_encode($c, JSON_PRETTY_PRINT);
'
+ composer config minimum-stability dev


  [Composer\Json\JsonValidationException]
  "./composer.json" does not match the expected JSON schema:
   - config : NULL value found, but an object is required
   - repositories : NULL value found, but an object or an array is required

Using version 0.1.4:

$ grep -A1 services/install-oxid-for-module composer.lock
            "name": "oxid-professional-services/install-oxid-for-module",
            "version": "0.1.4",

The broken values are in the composer.json of the shop:

root@c0d058e7863e:~/OXID# grep null composer.json 
    "config": null,
    "repositories": null

@alfredbez
Copy link
Collaborator

I'm not sure I got your point here at all.

I just stumbled upon the following problem:
I try to install a module, which has some conflicting dependencies (different phpunit and phpcs version), but those versions are added already to my composer.json. I'm not able to run composer remove phpunit/phpunit, because I have now a conflict in any command.

Why not just requiring additional packages manually? Automatically merging require-dev is not the best thing in all cases I guess.

I've released a new version to fix the problems I faced: 0.1.4...0.1.5

@keywan-ghadami-oxid
Copy link
Contributor Author

sorry I do not get the issue but currently I am using
https://github.com/OXIDprojects/docker-oxid-test/blob/master/scripts/setupPackage.sh#L14
let's have a call tomorrow and document results here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants