Compare commits

...

7 Commits
1 ... 2.0.0

Author SHA1 Message Date
Guy Sartorelli f003b8d56d
FIX Always put public resources in a public/ dir (#31) 2022-12-14 15:44:45 +13:00
Sabina Talipova cb22983fa8
API Remove deprecated code (#30) 2022-12-08 10:44:56 +13:00
Sabina Talipova fe4865a1bd Merge branch '1' into 2 2022-11-21 16:21:54 +13:00
Guy Sartorelli 80e0232bc9
Merge pull request #28 from creative-commoners/pulls/2/upgrade-installer-deps
DEP Upgrade installer dependencies
2022-10-28 10:00:31 +13:00
Sabina Talipova b81b640235 DEP Upgrade installer dependencies 2022-10-26 13:52:21 +13:00
Guy Sartorelli f55a2d91bc
Merge pull request #25 from creative-commoners/pulls/2/major-deps
DEP Update core dependencies for CMS 5
2022-08-09 09:47:07 +12:00
Steve Boyd e0aeb694a9 DEP Update core dependencies for CMS 5 2022-08-05 09:43:42 +12:00
2 changed files with 8 additions and 47 deletions

View File

@ -22,11 +22,12 @@
"lint-clean": "phpcbf src/"
},
"require": {
"composer-plugin-api": "^1.1 || ^2"
"php": "^8.1",
"composer-plugin-api": "^2"
},
"require-dev": {
"composer/composer": "^1.2 || 2",
"squizlabs/php_codesniffer": "^3.5"
"composer/composer": "^2",
"squizlabs/php_codesniffer": "^3.7"
},
"minimum-stability": "dev"
}
}

View File

@ -96,8 +96,7 @@ class RecipeInstaller extends LibraryInstaller
$relativePath = substr($sourcePath ?? '', strlen($sourceRoot ?? '') + 1); // Name path without leading '/'
// Get destination path
$relativeDestination = $this->rewriteFilePath($destinationRoot, $relativePath);
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativeDestination;
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativePath;
// Check if file exists
if (file_exists($destination ?? '')) {
@ -110,10 +109,7 @@ class RecipeInstaller extends LibraryInstaller
" - 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 ?? [])) {
// Don't re-install previously installed files that have been deleted
$this->io->write(
" - Skipping <info>$relativePath</info> (<comment>previously installed</comment>)"
@ -189,8 +185,7 @@ class RecipeInstaller extends LibraryInstaller
$projectPath = dirname(realpath(Factory::getComposerFile() ?? '') ?? '');
// Find public path
$candidatePublicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
$publicPath = is_dir($candidatePublicPath ?? '') ? $candidatePublicPath : $projectPath;
$publicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
// Copy project files to root
$name = $package->getName();
@ -220,39 +215,4 @@ class RecipeInstaller extends LibraryInstaller
);
}
}
/**
* Perform any file rewrites necessary to a relative path of a file being installed.
* E.g. if 'mysite' folder exists, rewrite 'mysite' to 'app' and 'mysite/code' to 'app/src'
*
* This will be removed in 2.0 as the app folder will be hard coded and no rewrites supported.
*
* @deprecated 1.2.0 Will be removed without equivalent functionality to replace it
* @param string $destinationRoot Project root
* @param string $relativePath Relative path to the resource being installed
* @return string Relative path we should write to
*/
protected function rewriteFilePath($destinationRoot, $relativePath)
{
// If app folder exists, no rewrite
if (is_dir($destinationRoot . DIRECTORY_SEPARATOR . 'app')) {
return $relativePath;
}
// if mysite folder does NOT exist, no rewrite
if (!is_dir($destinationRoot . DIRECTORY_SEPARATOR . 'mysite')) {
return $relativePath;
}
// Return first rewrite
$rewrites = [
'app/src' => 'mysite/code',
'app' => 'mysite',
];
foreach ($rewrites as $from => $to) {
if (stripos($relativePath ?? '', $from ?? '') === 0) {
return $to . substr($relativePath ?? '', strlen($from ?? ''));
}
}
return $relativePath;
}
}