I always thought this magento-deploy-ignore
was a per file but its actually per map
definition in the modules composer json.
The code in the magento composer installer that creates the files looks like this
/**
* Normalize mapping parameters using a glob wildcard.
*
* Delegate the creation of the module's files in the given destination.
*
* @param string $source
* @param string $dest
* @throws \ErrorException
* @return bool
*/
public function create($source, $dest)
{
if($this->isDestinationIgnored($dest)){
return;
}
So if you have a look in map within vendor/magento/magento2-base/composer.json
you can see how it has mostly each file spelled out like so
[
"app/etc/db_schema.xml",
"app/etc/db_schema.xml"
],
[
"app/etc/di.xml",
"app/etc/di.xml"
],
[
"app/etc/registration_globlist.php",
"app/etc/registration_globlist.php"
],
Unfortunately Magento was not so specific with the setup
directory and only define its map
like
[
"setup",
"setup"
],
That means the isDestinationIgnored function to decide whether to copy over the files has dodgy inputs
/**
* @param string $destination
*
* @return bool
*/
protected function isDestinationIgnored($destination)
{
$destination = '/'.$destination;
$destination = str_replace('/./','/', $destination);
$destination = str_replace('//','/', $destination);
foreach($this->ignoredMappings as $ignored){
if( 0 === strpos($ignored,$destination) ){
return true;
}
}
return false;
}
I hacked it locally to add this echo
if( 0 === strpos($ignored,$destination) ){
echo "$destination is ignored by $ignored" . PHP_EOL;
return true;
}
Then I did rm -rf vendor/magento/magento2-base
and then ran composer install
and I can see stuff like
/.gitignore is ignored by /.gitignore
/.user.ini is ignored by /.user.ini
/setup is ignored by /setup/config/modules.config.php
So there we are. Because the string check within isDestinationIgnored
matches it doesn't copy over the whole setup directory.