mirror of
https://github.com/silverstripe/recipe-plugin.git
synced 2024-10-22 14:05:55 +02:00
Compare commits
2 Commits
a76509e8a6
...
8a77da94d1
Author | SHA1 | Date | |
---|---|---|---|
|
8a77da94d1 | ||
|
02f5008b46 |
@ -103,17 +103,17 @@ trait RecipeCommandBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Existing version is already a ^1.0.0 or ~1.0.0 constraint
|
// Existing version is already a ^1.0.0 or ~1.0.0 constraint
|
||||||
if (preg_match('#^[~^]#', $existingVersion)) {
|
if (preg_match('#^[~^]#', $existingVersion ?? '')) {
|
||||||
return $existingVersion;
|
return $existingVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Existing version is already a dev constraint
|
// Existing version is already a dev constraint
|
||||||
if (stristr($existingVersion, 'dev') !== false) {
|
if (stristr($existingVersion ?? '', 'dev') !== false) {
|
||||||
return $existingVersion;
|
return $existingVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Numeric-only version maps to semver constraint
|
// Numeric-only version maps to semver constraint
|
||||||
if (preg_match('#^([\d.]+)$#', $existingVersion)) {
|
if (preg_match('#^([\d.]+)$#', $existingVersion ?? '')) {
|
||||||
return "^{$existingVersion}";
|
return "^{$existingVersion}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
$relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles);
|
$relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles);
|
||||||
|
|
||||||
// Add file to installed (even if already exists)
|
// Add file to installed (even if already exists)
|
||||||
if (!in_array($relativePath, $installedFiles)) {
|
if (!in_array($relativePath, $installedFiles ?? [])) {
|
||||||
$installedFiles[] = $relativePath;
|
$installedFiles[] = $relativePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,15 +87,15 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
protected function installProjectFile($sourceRoot, $destinationRoot, $sourcePath, $installedFiles)
|
protected function installProjectFile($sourceRoot, $destinationRoot, $sourcePath, $installedFiles)
|
||||||
{
|
{
|
||||||
// Relative path
|
// Relative path
|
||||||
$relativePath = substr($sourcePath, strlen($sourceRoot) + 1); // Name path without leading '/'
|
$relativePath = substr($sourcePath ?? '', strlen($sourceRoot ?? '') + 1); // Name path without leading '/'
|
||||||
|
|
||||||
// Get destination path
|
// Get destination path
|
||||||
$relativeDestination = $this->rewriteFilePath($destinationRoot, $relativePath);
|
$relativeDestination = $this->rewriteFilePath($destinationRoot, $relativePath);
|
||||||
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativeDestination;
|
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativeDestination;
|
||||||
|
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (file_exists($destination)) {
|
if (file_exists($destination ?? '')) {
|
||||||
if (file_get_contents($destination) === file_get_contents($sourcePath)) {
|
if (file_get_contents($destination ?? '') === file_get_contents($sourcePath ?? '')) {
|
||||||
$this->io->write(
|
$this->io->write(
|
||||||
" - Skipping <info>$relativePath</info> (<comment>existing, but unchanged</comment>)"
|
" - Skipping <info>$relativePath</info> (<comment>existing, but unchanged</comment>)"
|
||||||
);
|
);
|
||||||
@ -104,15 +104,17 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
" - Skipping <info>$relativePath</info> (<comment>existing and modified in project</comment>)"
|
" - Skipping <info>$relativePath</info> (<comment>existing and modified in project</comment>)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (in_array($relativePath, $installedFiles) || in_array($relativeDestination, $installedFiles)) {
|
} elseif (in_array($relativePath, $installedFiles ?? []) ||
|
||||||
|
in_array($relativeDestination, $installedFiles ?? [])
|
||||||
|
) {
|
||||||
// Don't re-install previously installed files that have been deleted
|
// Don't re-install previously installed files that have been deleted
|
||||||
$this->io->write(
|
$this->io->write(
|
||||||
" - Skipping <info>$relativePath</info> (<comment>previously installed</comment>)"
|
" - Skipping <info>$relativePath</info> (<comment>previously installed</comment>)"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->io->write(" - Copying <info>$relativePath</info>");
|
$this->io->write(" - Copying <info>$relativePath</info>");
|
||||||
$this->filesystem->ensureDirectoryExists(dirname($destination));
|
$this->filesystem->ensureDirectoryExists(dirname($destination ?? ''));
|
||||||
copy($sourcePath, $destination);
|
copy($sourcePath ?? '', $destination ?? '');
|
||||||
}
|
}
|
||||||
return $relativePath;
|
return $relativePath;
|
||||||
}
|
}
|
||||||
@ -155,10 +157,10 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
*/
|
*/
|
||||||
protected function globToRegexp($glob)
|
protected function globToRegexp($glob)
|
||||||
{
|
{
|
||||||
$sourceParts = explode('*', $glob);
|
$sourceParts = explode('*', $glob ?? '');
|
||||||
$regexParts = array_map(function ($part) {
|
$regexParts = array_map(function ($part) {
|
||||||
return preg_quote($part, '#');
|
return preg_quote($part ?? '', '#');
|
||||||
}, $sourceParts);
|
}, $sourceParts ?? []);
|
||||||
return implode('(.+)', $regexParts);
|
return implode('(.+)', $regexParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,11 +178,11 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
$recipePath = $this->getInstallPath($package);
|
$recipePath = $this->getInstallPath($package);
|
||||||
|
|
||||||
// Find project path
|
// Find project path
|
||||||
$projectPath = dirname(realpath(Factory::getComposerFile()));
|
$projectPath = dirname(realpath(Factory::getComposerFile() ?? '') ?? '');
|
||||||
|
|
||||||
// Find public path
|
// Find public path
|
||||||
$candidatePublicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
|
$candidatePublicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
|
||||||
$publicPath = is_dir($candidatePublicPath) ? $candidatePublicPath : $projectPath;
|
$publicPath = is_dir($candidatePublicPath ?? '') ? $candidatePublicPath : $projectPath;
|
||||||
|
|
||||||
// Copy project files to root
|
// Copy project files to root
|
||||||
$name = $package->getName();
|
$name = $package->getName();
|
||||||
@ -238,8 +240,8 @@ class RecipeInstaller extends LibraryInstaller
|
|||||||
'app' => 'mysite',
|
'app' => 'mysite',
|
||||||
];
|
];
|
||||||
foreach ($rewrites as $from => $to) {
|
foreach ($rewrites as $from => $to) {
|
||||||
if (stripos($relativePath, $from) === 0) {
|
if (stripos($relativePath ?? '', $from ?? '') === 0) {
|
||||||
return $to . substr($relativePath, strlen($from));
|
return $to . substr($relativePath ?? '', strlen($from ?? ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $relativePath;
|
return $relativePath;
|
||||||
|
@ -137,11 +137,9 @@ class RecipePlugin implements PluginInterface, EventSubscriberInterface, Capable
|
|||||||
|
|
||||||
public function deactivate(Composer $composer, IOInterface $io)
|
public function deactivate(Composer $composer, IOInterface $io)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall(Composer $composer, IOInterface $io)
|
public function uninstall(Composer $composer, IOInterface $io)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user