Browse Source

Merge pull request #81 from rodmen/master

add user data and message to lock command
1.0
Andrés Montañez 10 years ago
parent
commit
ec29aa37b8
  1. 1
      Mage/Command/BuiltIn/DeployCommand.php
  2. 14
      Mage/Command/BuiltIn/LockCommand.php
  3. 1
      Mage/Command/BuiltIn/ReleasesCommand.php
  4. 1
      Mage/Command/BuiltIn/RollbackCommand.php
  5. 13
      Mage/Console.php

1
Mage/Command/BuiltIn/DeployCommand.php

@ -104,6 +104,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile)) { if (file_exists($lockFile)) {
Console::output('<red>This environment is locked!</red>', 1, 2); Console::output('<red>This environment is locked!</red>', 1, 2);
echo file_get_contents($lockFile);
return; return;
} }

14
Mage/Command/BuiltIn/LockCommand.php

@ -27,8 +27,20 @@ class LockCommand extends AbstractCommand implements RequiresEnvironment
*/ */
public function run() public function run()
{ {
Console::output('Your name (enter to leave blank): ', 0, 0);
$name = Console::readInput();
Console::output('Your email (enter to leave blank): ', 0, 0);
$email = Console::readInput();
Console::output('Reason of lock (enter to leave blank): ', 0, 0);
$reason = Console::readInput();
$lockmsg = PHP_EOL;
if ($name) $lockmsg .= 'Locked by ' . $name . ' ';
if ($email) $lockmsg .= '(' . $email . ')';
if ($reason) $lockmsg .= PHP_EOL . $reason . PHP_EOL;
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s')); file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s') . $lockmsg);
Console::output('Locked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2); Console::output('Locked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2);
} }

1
Mage/Command/BuiltIn/ReleasesCommand.php

@ -37,6 +37,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile) && ($subcommand == 'rollback')) { if (file_exists($lockFile) && ($subcommand == 'rollback')) {
Console::output('<red>This environment is locked!</red>', 1, 2); Console::output('<red>This environment is locked!</red>', 1, 2);
echo file_get_contents($lockFile);
return null; return null;
} }

1
Mage/Command/BuiltIn/RollbackCommand.php

@ -37,6 +37,7 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile) && ($subcommand == 'rollback')) { if (file_exists($lockFile) && ($subcommand == 'rollback')) {
Console::output('<red>This environment is locked!</red>', 1, 2); Console::output('<red>This environment is locked!</red>', 1, 2);
echo file_get_contents($lockFile);
return null; return null;
} }

13
Mage/Console.php

@ -227,6 +227,18 @@ class Console
return self::$logFile; return self::$logFile;
} }
/**
* Read String From Prompt
*/
public static function readInput()
{
$fp = fopen("php://stdin","r");
$line = '';
$line = fgets($fp);
return rtrim($line);
}
/** /**
* Check Logs * Check Logs
* @param \Mage\Config $config * @param \Mage\Config $config
@ -252,4 +264,5 @@ class Console
} }
} }
} }
} }
Loading…
Cancel
Save