瀏覽代碼

Composer init - abandoned package warning

Added warning for abandoned packages in case more than one package is found for require / require-dev in composer init.
Arjan 7 年之前
父節點
當前提交
a03efa2fda
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      src/Composer/Command/InitCommand.php

+ 11 - 1
src/Composer/Command/InitCommand.php

@@ -391,7 +391,17 @@ EOT
                 $exactMatch = null;
                 $choices = array();
                 foreach ($matches as $position => $foundPackage) {
-                    $choices[] = sprintf(' <info>%5s</info> %s', "[$position]", $foundPackage['name']);
+                    $abandoned = '';
+                    if (isset($foundPackage['abandoned'])) {
+                        if (is_string($foundPackage['abandoned'])) {
+                            $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
+                        } else {
+                            $replacement = 'No replacement was suggested';
+                        }
+                        $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
+                    }
+
+                    $choices[] = sprintf(' <info>%5s</info> %s %s',"[$position]", $foundPackage['name'], $abandoned);
                     if ($foundPackage['name'] === $package) {
                         $exactMatch = true;
                         break;