diff --git a/.pman.yml b/.composer.pman.yml similarity index 100% rename from .pman.yml rename to .composer.pman.yml diff --git a/bin/_pman-composer_local_deps.php b/bin/_pman-composer_local_deps.php index badae7b..868c1e3 100755 --- a/bin/_pman-composer_local_deps.php +++ b/bin/_pman-composer_local_deps.php @@ -3,7 +3,7 @@ require __DIR__ . "/../vendor/autoload.php"; use nulib\tools\pman\ComposerFile; -use nulib\tools\pman\PmanYamlConfigFile; +use nulib\tools\pman\ComposerPmanFile; use nulib\ValueException; $composer = new ComposerFile(); diff --git a/bin/_pman-composer_select_profile.php b/bin/_pman-composer_select_profile.php index 431259b..bf8cde3 100755 --- a/bin/_pman-composer_select_profile.php +++ b/bin/_pman-composer_select_profile.php @@ -3,11 +3,11 @@ require __DIR__ . "/../vendor/autoload.php"; use nulib\tools\pman\ComposerFile; -use nulib\tools\pman\PmanYamlConfigFile; +use nulib\tools\pman\ComposerPmanFile; use nulib\ValueException; $composer = new ComposerFile(); -$config = new PmanYamlConfigFile(); +$config = new ComposerPmanFile(); if ($argc <= 1) { throw new ValueException("Il faut spécifier le profil à sélectionner"); diff --git a/php/src/tools/pman/ComposerFile.php b/php/src/tools/pman/ComposerFile.php index d85a957..1cb8ed0 100644 --- a/php/src/tools/pman/ComposerFile.php +++ b/php/src/tools/pman/ComposerFile.php @@ -77,7 +77,7 @@ class ComposerFile { "nulib/php" => "nulib", ]; - function selectProfile(string $profile, PmanYamlConfigFile $config): void { + function selectProfile(string $profile, ComposerPmanFile $config): void { $config = $config->getProfileConfig($profile); // corriger les liens $deps = cl::merge(array_keys($config["require"]), array_keys($config["require-dev"])); diff --git a/php/src/tools/pman/PmanYamlConfigFile.php b/php/src/tools/pman/ComposerPmanFile.php similarity index 72% rename from php/src/tools/pman/PmanYamlConfigFile.php rename to php/src/tools/pman/ComposerPmanFile.php index c0998dd..b0520c0 100644 --- a/php/src/tools/pman/PmanYamlConfigFile.php +++ b/php/src/tools/pman/ComposerPmanFile.php @@ -6,9 +6,27 @@ use nulib\ext\yaml; use nulib\os\path; use nulib\ValueException; -class PmanYamlConfigFile { +class ComposerPmanFile { + const NAMES = [".composer.pman", ".pman"]; + const EXTS = [".yml", ".yaml"]; + function __construct(string $configFile=".", bool $ensureExists=true) { - if (is_dir($configFile)) $configFile = path::join($configFile, '.pman.yml'); + if (is_dir($configFile)) { + $found = false; + foreach (self::NAMES as $name) { + foreach (self::EXTS as $ext) { + $file = path::join($configFile, "$name$ext"); + if (file_exists($file)) { + $configFile = $file; + $found = true; + break; + } + } + } + if (!$found) { + $configFile = path::join($configFile, self::NAMES[0].self::EXTS[0]); + } + } if ($ensureExists && !file_exists($configFile)) { $message = path::ppath($configFile).": fichier introuvable"; throw new ValueException($message);