|
|
|
@ -64,6 +64,40 @@ class Build {
|
|
|
|
|
$climate->out(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function showCopyTo(string $prodDirectory) { |
|
|
|
|
$climate = new CLImate; |
|
|
|
|
if ($this->copyTo($prodDirectory)) { |
|
|
|
|
$climate->info('> Fichiers copiés en prod'); |
|
|
|
|
} else { |
|
|
|
|
$climate->error('! Échec de la recopie en prod'); |
|
|
|
|
} |
|
|
|
|
$climate->out(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function copyTo(string $prodDirectory) { |
|
|
|
|
if (!is_dir($prodDirectory)) { |
|
|
|
|
throw new \Exception(sprintf('Directory %s needs to exists', $prodDirectory)); |
|
|
|
|
} |
|
|
|
|
$files = [$this->pharFilename, 'version']; |
|
|
|
|
foreach ($files as $file) { |
|
|
|
|
if (!file_exists($this->buildDirectory . '/' . $file)) { |
|
|
|
|
throw new \Exception(sprintf('File %s is not compiled ?', $this->buildDirectory . '/' . $file)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
foreach ($files as $file) { |
|
|
|
|
if (file_exists($prodDirectory . '/' . $file)) { |
|
|
|
|
unlink($prodDirectory . '/' . $file); |
|
|
|
|
} |
|
|
|
|
copy($this->buildDirectory . '/' . $file, $prodDirectory . '/' . $file); |
|
|
|
|
} |
|
|
|
|
foreach ($files as $file) { |
|
|
|
|
if (!file_exists($prodDirectory . '/' . $file)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getStats(): array { |
|
|
|
|
return $this->stats; |
|
|
|
|
} |
|
|
|
|