Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Steve Boyd | acb067fdc2 |
|
@ -4,13 +4,8 @@ on:
|
|||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
# Every Friday at 12:00pm UTC
|
||||
schedule:
|
||||
- cron: '0 12 * * 5'
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: CI
|
||||
# Only run cron on the silverstripe account
|
||||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
|
||||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
name: Dispatch CI
|
||||
|
||||
on:
|
||||
# At 12:00 PM UTC, only on Friday and Saturday
|
||||
schedule:
|
||||
- cron: '0 12 * * 5,6'
|
||||
|
||||
jobs:
|
||||
dispatch-ci:
|
||||
name: Dispatch CI
|
||||
# Only run cron on the silverstripe account
|
||||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dispatch CI
|
||||
uses: silverstripe/gha-dispatch-ci@v1
|
|
@ -22,12 +22,11 @@
|
|||
"lint-clean": "phpcbf src/"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"composer-plugin-api": "^2"
|
||||
"composer-plugin-api": "^1.1 || ^2"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^2",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
"composer/composer": "^1.2 || 2",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ class RecipeInstaller extends LibraryInstaller
|
|||
$relativePath = substr($sourcePath ?? '', strlen($sourceRoot ?? '') + 1); // Name path without leading '/'
|
||||
|
||||
// Get destination path
|
||||
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativePath;
|
||||
$relativeDestination = $this->rewriteFilePath($destinationRoot, $relativePath);
|
||||
$destination = $destinationRoot . DIRECTORY_SEPARATOR . $relativeDestination;
|
||||
|
||||
// Check if file exists
|
||||
if (file_exists($destination ?? '')) {
|
||||
|
@ -109,7 +110,10 @@ class RecipeInstaller extends LibraryInstaller
|
|||
" - Skipping <info>$relativePath</info> (<comment>existing and modified in project</comment>)"
|
||||
);
|
||||
}
|
||||
} elseif (in_array($relativePath, $installedFiles ?? [])) {
|
||||
} elseif (
|
||||
in_array($relativePath, $installedFiles ?? []) ||
|
||||
in_array($relativeDestination, $installedFiles ?? [])
|
||||
) {
|
||||
// Don't re-install previously installed files that have been deleted
|
||||
$this->io->write(
|
||||
" - Skipping <info>$relativePath</info> (<comment>previously installed</comment>)"
|
||||
|
@ -185,7 +189,8 @@ class RecipeInstaller extends LibraryInstaller
|
|||
$projectPath = dirname(realpath(Factory::getComposerFile() ?? '') ?? '');
|
||||
|
||||
// Find public path
|
||||
$publicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
|
||||
$candidatePublicPath = $projectPath . DIRECTORY_SEPARATOR . RecipePlugin::PUBLIC_PATH;
|
||||
$publicPath = is_dir($candidatePublicPath ?? '') ? $candidatePublicPath : $projectPath;
|
||||
|
||||
// Copy project files to root
|
||||
$name = $package->getName();
|
||||
|
@ -215,4 +220,39 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue