public function run()
{
$this->logger = new Logger('php://memory');
$this->setupPhp();
$config = $this->loadConfig();
if (!$config) {
return 1;
}
$this->logger = new Logger($config['log']);
$this->logger->useColors = (bool) $config['colors'];
$this->logger->showProgress = (bool) $config['progress'];
if (!is_dir($tempDir = $config['tempdir'])) {
$this->logger->log("Creating temporary directory {$tempDir}");
mkdir($tempDir, 0777, TRUE);
}
$time = time();
$this->logger->log("Started at " . date('[Y/m/d H:i]'));
$this->logger->log("Config file is {$this->configFile}");
foreach ($this->batches as $name => $batch) {
$this->logger->log("\nDeploying {$name}");
$deployment = $this->createDeployer($batch);
$deployment->tempDir = $tempDir;
if ($this->mode === 'generate') {
$this->logger->log('Scanning files');
$localPaths = $deployment->collectPaths();
$this->logger->log("Saved " . $deployment->writeDeploymentFile($localPaths));
continue;
}
if ($deployment->testMode) {
$this->logger->log('Test mode', 'lime');
} else {
$this->logger->log('Live mode', 'aqua');
}
if (!$deployment->allowDelete) {
$this->logger->log('Deleting disabled');
}
$deployment->deploy();
}
$time = time() - $time;
$this->logger->log("\nFinished at " . date('[Y/m/d H:i]') . " (in {$time} seconds)", 'lime');
}