diff --git a/composer.json b/composer.json index 688199e..8682648 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Runs migrations automatically", "keywords": ["composer", "development", "craftcms"], "type": "composer-plugin", - "version": "2.0.0", + "version": "2.1.0", "license": "MIT", "autoload": { "psr-4": { diff --git a/src/Plugin.php b/src/Plugin.php index 3d5b4c5..6efc953 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -46,13 +46,13 @@ public static function getSubscribedEvents() /** * Initialize Composer plugin * - * @param Composer $composer + * @param Composer $composer * @param IOInterface $io */ public function activate(Composer $composer, IOInterface $io) { $this->composer = $composer; - $this->io = $io; + $this->io = $io; } /** @@ -64,7 +64,9 @@ public function activate(Composer $composer, IOInterface $io) public function runCommands() { if (getenv('DISABLE_CRAFT_AUTOMIGRATE') == 1) { - $this->io->write(PHP_EOL . "▶ Craft auto migrate disabled by ENV var: DISABLE_CRAFT_AUTOMIGRATE"); + $this->io->write( + PHP_EOL . "▶ Craft auto migrate disabled by ENV var: DISABLE_CRAFT_AUTOMIGRATE" + ); return true; } @@ -91,7 +93,6 @@ public function runCommands() if ($this->hasProjectConfigFile()) { - $cmd = new CraftCommand( ["project-config/sync"], new ProcessExecutor($this->io) @@ -102,7 +103,7 @@ public function runCommands() $this->io->write(PHP_EOL . $cmd->getOutput()); } else { $this->io->writeError(PHP_EOL . "▶ Craft auto migrate [project-config/sync ERROR]"); - $this->io->writeError(PHP_EOL .$cmd->getErrorOutput()); + $this->io->writeError(PHP_EOL . $cmd->getErrorOutput()); return false; } } @@ -139,10 +140,11 @@ protected function isCraftInstalled() */ protected function hasProjectConfigFile(): bool { - $projectRoot = realpath(dirname(Factory::getComposerFile())); - $pathToConfig = $projectRoot . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'project.yaml'; + $projectRoot = realpath(dirname(Factory::getComposerFile())); + $pathToConfigFile = $projectRoot . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'project.yaml'; + $pathToConfigDir = $projectRoot . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'project'; - return (file_exists($pathToConfig)) ? true : false; + return (file_exists($pathToConfigFile) || is_dir($pathToConfigDir)) ? true : false; } }