/**
  * @param string $projectName
  * @param null|string $gitSource
  * @param null|string $version
  * @throws RuntimeException
  * @throws LogicException
  */
 public function setUp($projectName, $gitSource = null, $version = null)
 {
     echo "\nCreating project {$projectName}\n";
     if (!file_exists($projectName)) {
         if (!mkdir($projectName) && !is_dir($projectName)) {
             throw new RuntimeException("Error creating project {$projectName}\n");
         }
         $this->installBase($projectName, $gitSource, $version);
         VagrantWorker::startVagrant($projectName);
         $this->runComposer($projectName);
     } else {
         throw new LogicException("ERROR: Project ' . {$projectName} . ' already exists!\n");
     }
 }
Exemplo n.º 2
0
<?php

require_once 'helpers/VagrantWorker.php';
require_once 'helpers/InstallationWizard.php';
require_once 'TwistedBytes/TwistedBoxInstaller.php';
require_once 'TwistedBytes/TwistedBoxHelp.php';
$args = $argv;
$boxID = 1;
$wizard = new InstallationWizard();
if (count($argv) === 1) {
    $args = $wizard->projectWizard($args);
}
$boxHelper = new TwistedBoxInstaller();
$args[3] = isset($argv[3]) ? $argv[3] : null;
$args[4] = isset($args[4]) ? $args[4] : null;
// @todo Make this dynamic. It's too strict atm.
if ($args[1] === 'help') {
    TwistedBoxHelp::help();
} elseif ($args[1] === 'destroy' && isset($args[2])) {
    VagrantWorker::tearDown($args[2]);
} elseif ($args[1] === 'init') {
    $boxHelper->setUp($args[2], $args[3], $args[4]);
} elseif (count($args) > 1 && $args[1] !== 'destroy') {
    echo 'Command definition not found, assuming init a new project';
    $boxHelper->setUp($args[1], $args[3]);
} else {
    throw new LogicException('Unknown command');
}