Closed jepster closed 2 years ago
Your definition of dev-files
is incorrect and therefore file will not be removed.
Only in dev-files
keys can there be a filter by package name. And you are using lowercase letters in definition then set match-case
to false
is required.
This is valid definition for remove index.php
from symfony/http-client-contracts
:
{
"require": {
"symfony/http-client-contracts": "^2.3"
},
"extra": {
"dev-files": {
"symfony/http-client-contracts": [
"/test/fixtures/web/index.php"
]
}
},
"config": {
"dev-files": {
"match-case": false
}
}
}
Complete valid definition for your example packages (some conditions overlap):
{
"require": {
"composer/semver": "^3.2",
"consolidation/output-formatters": "^4.1",
"symfony/filesystem": "^5.2",
"symfony/http-client-contracts": "^2.3",
"twig/twig": "^3.2"
},
"extra": {
"dev-files": {
"/": [
"demos/",
"demo/",
"tests/",
"testing/",
"testing/",
"consolidation/",
"examples/",
"!/modules/lightning_core/"
],
"symfony/filesystem": [
"/tests/",
"/tests/filesystemtest.php",
"/tests/filesystemtestcase.php",
"/tests/lockhandlertest.php"
],
"twig/twig": [
"/src/test/integrationtestcase.php",
"/src/test/integrationtestcase.php"
],
"composer/semver": [
"/src/versionparser.php"
],
"consolidation/output-formatters": [
"/src/formatters/stringformatter.php",
"/src/transformations/tabletransformation.php",
"/src/transformations/wrap/columnwidths.php"
],
"symfony/http-client-contracts": [
"/test/",
"/test/fixtures/web/index.php"
]
}
},
"config": {
"dev-files": {
"match-case": false
}
}
}
Key "/"
means find in all packages.
Can be simplified as follows example:
{
"require": {
"composer/semver": "^3.2",
"consolidation/output-formatters": "^4.1",
"symfony/filesystem": "^5.2",
"symfony/http-client-contracts": "^2.3",
"twig/twig": "^3.2"
},
"extra": {
"dev-files": {
"/": [
"demos/",
"demo/",
"tests/",
"testing/",
"consolidation/",
"examples/",
"!/modules/lightning_core/"
],
"twig/twig": [
"/src/test/integrationtestcase.php"
],
"composer/semver": [
"/src/versionparser.php"
],
"consolidation/output-formatters": [
"/src/formatters/stringformatter.php",
"/src/transformations/tabletransformation.php",
"/src/transformations/wrap/columnwidths.php"
],
"symfony/http-client-contracts": [
"/test/"
]
}
},
"config": {
"dev-files": {
"match-case": false
}
}
}
Thanks for your quick response and your detailed instructions.
Sadly this approach does not work for me. I have tried your config, tried to modify the match-case
option, tried with paths with lower- and uppercase (e.g. src/Formatters/StringFormatter.php). Also I tried with all paths under the /
key, like in my first approach.
I could not accomplish the file deletion. Please notice that the folder deletion worked with match-case: false
. I really tried multiple times and now I do not have any further ideas. Always deleting the vendor
folder from Composer and running composer install --no-dev
afterwards. It looks like your Composer plugin has a bug related to file deletion. For your background info: I am working on macOS.
I was also checking your code, but it is a bit too abstract for me and it's hard to follow the program flow. You might implement more unit tests for file deletion with and without the match-case
option.
I hope I could provide you good feedback to your Composer plugin. Thanks again for sharing!
It worked now. But I needed to execute "composer update --no-dev" after changing my definitions within the composer.json file. I was thinking that the usage should be "composer install --no-dev" after the changes have been made. I think it's helpful, if you describe the workflow on your project page a bit more detailed.
Try to run composer with --verbose
parameter and attach all output here (composer.json file also).
Maybe plugin have some problem on macOS, but i don't have this OS for test.
@jepster I created repo https://github.com/liborm85/cvc-tests with composer.json mentioned above and run GitHub Actions with various OS.
Jobs results:
On all platforms is same result: "Removed 21 files and 8 (of which 1 are empty) directories from 17 packages
"
Cannot be reproduced.
Hi,
first of all: thanks for sharing your composer package!
I see that folders are removed correctly. Also folders can be excluded. But file paths are not handled, yet.
See the dev-files section from my composer.json file:
None of the specified file paths like
symfony/http-client-contracts/test/fixtures/web/index.php
do remove any files.