Exemplo n.º 1
0
 public function run(Context $context)
 {
     if (($type = $context->nextNamedArgument()) == null) {
         throw new \Exception('Missing the thing to make');
     }
     $name = $context->nextNamedArgument();
     switch (strtolower($type)) {
         case 'command':
             if (empty($name)) {
                 throw new \Exception("Name required");
             }
             $name = ucfirst(strtolower($name));
             $filename = "{$name}Command.php";
             $path = "commands";
             if (file_exists($path) == false) {
                 throw new \Exception('Commands directory not found. Have you run "minion init" yet?');
             }
             $context->say("Creating <bold>{$name}</bold> command");
             if (file_exists("{$path}/{$filename}")) {
                 throw new \Exception("File \"{$path}/{$filename}\" already exists");
             }
             $command = file_get_contents(__DIR__ . '/../src/templates/Command.php.tpl');
             $command = preg_replace('/\\:CommandName/', "{$name}Command", $command);
             file_put_contents("{$path}/{$filename}", $command);
             break;
         case 'task':
             if (empty($name)) {
                 throw new \Exception("Name required");
             }
             $name = ucfirst(strtolower($name));
             $filename = "{$name}Task.php";
             $path = "tasks";
             if (file_exists($path) == false) {
                 throw new \Exception('Tasks directory not found. Have you run "minion init" yet?');
             }
             $context->say("Creating <bold>{$name}</bold> task");
             if (file_exists("{$path}/{$filename}")) {
                 throw new \Exception("File \"{$path}/{$filename}\" already exists");
             }
             $command = file_get_contents(__DIR__ . '/../src/templates/Task.php.tpl');
             $command = preg_replace('/\\:TaskName/', "{$name}Task", $command);
             file_put_contents("{$path}/{$filename}", $command);
             break;
         case 'config':
             $context->say("Creating new default config file");
             if (!$name) {
                 $name = 'minion.yml';
             }
             if (file_exists($name)) {
                 throw new \Exception("Config file \"{$name}\" already exists");
             }
             copy(__DIR__ . '/../src/templates/config.yml.tpl', $name);
             break;
         default:
             throw new \Exception('Unsupported type');
     }
 }
Exemplo n.º 2
0
 public function run(Context $context, Environment $environment, ConnectionInterface $connection = null)
 {
     if ($connection->execute("if [ -d \"{$environment->remote->deployTo}\" ]; then echo 1; fi")) {
         $releases = $connection->execute("ls {$environment->remote->deployTo}");
         $releases = explode("\n", trim($releases));
         if (($trim = count($releases) - $environment->remote->keepReleases) > 0) {
             $releases = array_slice($releases, 0, $trim);
             foreach ($releases as $release) {
                 $context->say("\tPruning {$release}...");
                 $connection->execute("rm -Rf {$environment->remote->deployTo}/{$release}");
             }
         }
     }
 }
Exemplo n.º 3
0
 public function run(Context $context, Environment $environment, ConnectionInterface $connection = null)
 {
     $currentRelease = $environment->remote->currentRelease;
     // Make directories
     $context->say("\tCreating required directories...");
     $connection->execute("mkdir -p {$currentRelease}/bootstrap/cache");
     $connection->execute("mkdir -p {$currentRelease}/storage/app/public");
     $connection->execute("mkdir -p {$currentRelease}/storage/framework/cache");
     $connection->execute("mkdir -p {$currentRelease}/storage/framework/sessions");
     $connection->execute("mkdir -p {$currentRelease}/storage/framework/views");
     $connection->execute("mkdir -p {$currentRelease}/storage/logs");
     // Change ownership
     $context->say("\tChanging ownership....");
     $connection->execute("sudo chown fedora.apache {$currentRelease}/storage -R");
     $connection->execute("sudo chown fedora.apache {$currentRelease}/bootstrap/cache -R");
     // Change permissions
     $context->say("\tChanging permissions...");
     $connection->execute("sudo chmod 770 {$currentRelease}/storage -R");
     $connection->execute("sudo chmod 770 {$currentRelease}/bootstrap/cache -R");
     // Link up the environment
     $context->say("\tLinking environment config...");
     $connection->execute("cd {$currentRelease}&&ln -s .env.{$environment->name} .env");
 }