Hello,
That looks decent indeed. One thing it doesn't do is add that packages to the main composer.json file as the require key does. That might be something good to have as well.
I just added this on dev-master. Feel free to test it out. 馃憤
This has now been tagged.
Thanks :)
What about the scripts?
//scripts
$scripts = $module->getComposerAttr('scripts', []);
$composer = json_decode(file_get_contents(base_path('composer.json')), true);
foreach ($scripts as $key => $script):
$composer['scripts'][$key] = array_unique(array_merge($composer['scripts'][$key], $script));
endforeach;
file_put_contents(base_path('composer.json'), json_encode($composer, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
I don't know if my approach is the best way to do this but it's working.
For example, i have a dev module where i add all dev packages that i need. When i install the dev module i want to install the dev packages and update the scripts from the main composer.
For example:
Update
"scripts":{
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
With
"scripts":{
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"php artisan optimize"
]
},
Oh, you're right, I missed that part. I'll try to implement this asap.
This is now on dev-master as well. Has to change your code a bit so it'd work if the script title wasn't present in the main composer.json file.
Thanks :). Will test soon.
Most helpful comment
This is now on
dev-masteras well. Has to change your code a bit so it'd work if the script title wasn't present in the main composer.json file.