mirror of
https://github.com/silverstripe/recipe-plugin.git
synced 2024-10-22 14:05:55 +02:00
BUG Fix recipes not being un-installed after inlining
Improve format of output logging
This commit is contained in:
parent
c8288e2be5
commit
651f1f13af
@ -74,6 +74,9 @@ trait RecipeCommandBehaviour
|
|||||||
throw new InvalidArgumentException("Invalid composer.json data with error: " . json_last_error_msg());
|
throw new InvalidArgumentException("Invalid composer.json data with error: " . json_last_error_msg());
|
||||||
}
|
}
|
||||||
file_put_contents($path, $content);
|
file_put_contents($path, $content);
|
||||||
|
|
||||||
|
// Reset composer object
|
||||||
|
$this->resetComposer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,7 +238,7 @@ trait RecipeCommandBehaviour
|
|||||||
foreach ($installedRecipe->getRequires() as $requireName => $require) {
|
foreach ($installedRecipe->getRequires() as $requireName => $require) {
|
||||||
$requireVersion = $require->getPrettyConstraint();
|
$requireVersion = $require->getPrettyConstraint();
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
" * Inline dependency <info>{$requireName}</info> as <info>{$requireVersion}</info>"
|
" - Inlining <info>{$requireName}</info> (<comment>{$requireVersion}</comment>)"
|
||||||
);
|
);
|
||||||
$composerData['require'][$requireName] = $requireVersion;
|
$composerData['require'][$requireName] = $requireVersion;
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,33 @@ class RecipeInstaller extends LibraryInstaller {
|
|||||||
protected function installProjectFiles($recipe, $sourceRoot, $destinationRoot, $filePatterns)
|
protected function installProjectFiles($recipe, $sourceRoot, $destinationRoot, $filePatterns)
|
||||||
{
|
{
|
||||||
$fileIterator = $this->getFileIterator($sourceRoot, $filePatterns);
|
$fileIterator = $this->getFileIterator($sourceRoot, $filePatterns);
|
||||||
|
$any = false;
|
||||||
foreach($fileIterator as $path => $info) {
|
foreach($fileIterator as $path => $info) {
|
||||||
$relativePath = substr($path, strlen($sourceRoot));
|
$relativePath = substr($path, strlen($sourceRoot));
|
||||||
$destination = $destinationRoot . $relativePath;
|
$destination = $destinationRoot . $relativePath;
|
||||||
|
|
||||||
// Only copy non-existent files
|
// Write header
|
||||||
if (file_exists($destination)) {
|
if (!$any) {
|
||||||
continue;
|
$this->io->write("Installing project files for recipe <info>{$recipe}</info>:");
|
||||||
|
$any = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file exists
|
||||||
|
if (file_exists($destination)) {
|
||||||
|
if (file_get_contents($destination) === file_get_contents($path)) {
|
||||||
|
$this->io->write(
|
||||||
|
" - Skipping <info>$relativePath</info> (<comment>existing, but unchanged</comment>)"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->io->write(
|
||||||
|
" - Skipping <info>$relativePath</info> (<comment>existing and modified in project</comment>)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->io->write(" - Installing <info>$relativePath</info>");
|
||||||
|
$this->filesystem->ensureDirectoryExists(dirname($destination));
|
||||||
|
copy($path, $destination);
|
||||||
}
|
}
|
||||||
$this->io->write("Installing recipe <info>$recipe</info> file <info>$relativePath</info>");
|
|
||||||
$this->filesystem->ensureDirectoryExists(dirname($destination));
|
|
||||||
copy($path, $destination);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class RecipePlugin implements PluginInterface, EventSubscriberInterface, Capable
|
|||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'post-package-update' => 'installPackage',
|
||||||
'post-package-install' => 'installPackage',
|
'post-package-install' => 'installPackage',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user