diff --git a/CHANGELOG.md b/CHANGELOG.md index 5440d4c..7838230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use LoggerInterface - Extract TemplateHelper::processTemplateToFile() to TemplateShellHelper +### Removed +- Stop creating links from application path to version files and folders + ## [v0.3.0] ### Changed diff --git a/app/Command/Deploy.php b/app/Command/Deploy.php index 72a9a04..01c7615 100644 --- a/app/Command/Deploy.php +++ b/app/Command/Deploy.php @@ -9,9 +9,7 @@ use function escapeshellarg; use function fgets; use function file_exists; -use function in_array; use function realpath; -use function scandir; use function strtr; use function trim; use const STDIN; @@ -311,61 +309,17 @@ public function actionDeploy(bool $isSkipGit = false): void public function actionSwitch(): void { - $applicationPath = (string) $this->getParam('application-path'); $user = (string) $this->getParam('user'); $afterSwitchScripts = $this->getParam('after-switch-script'); $currentLink = (string) $this->getParam('current-link-path'); $versionPath = (string) $this->getParam('version-path'); - $applicationFiles = scandir($applicationPath); - - $versionFiles = scandir($versionPath); - - foreach ([&$applicationFiles, &$versionFiles] as &$files) { - foreach ([".", "..", "versions"] as $excludeFile) { - $key = array_search($excludeFile, $files); - if ($key !== false) { - unset($files[$key]); - } - } - } - - $this->logger->info("Create new links"); - $linksCreated = false; - foreach ($versionFiles as $versionFile) { - if (!in_array($versionFile, $applicationFiles)) { - $this->shellHelper->sudo($user)->ln( - "{$applicationPath}/{$versionFile}", - "$currentLink/{$versionFile}" - ); - $linksCreated = true; - } - } - - if ($linksCreated === false) { - $this->logger->info("No new links found"); - } - - $this->logger->info("Switch version"); $this->shellHelper->sudo($user)->ln( - $currentLink, - $versionPath + link: $currentLink, + destination: $versionPath ); - $this->logger->info("Remove old links"); - $linksRemoved = false; - foreach ($applicationFiles as $applicationFile) { - if (!in_array($applicationFile, $versionFiles)) { - $linksRemoved = true; - $this->shellHelper->sudo($user)->rm("{$applicationPath}/{$applicationFile}"); - } - } - - if ($linksRemoved === false) { - $this->logger->info("No links to remove found"); - } - if ($afterSwitchScripts !== null) { $this->logger->info("Run after switch scripts"); foreach ($afterSwitchScripts as $afterSwitchScript) {