public function run()
{
if ($this->config->project === 'default') {
throw new ProjectNeeded();
}
$path = $this->config->projects_root . '/projects/' . $this->config->project;
if (!file_exists($path)) {
throw new NoSuchProject($this->config->project);
}
display("Cleaning project {$this->config->project}\n");
$dirsToErase = array('log', 'report', 'Premier-ace', 'faceted', 'faceted2', 'ambassador');
foreach ($dirsToErase as $dir) {
$dirPath = $path . '/' . $dir;
if (file_exists($dirPath)) {
display('removing ' . $dir);
rmdirRecursive($dirPath);
}
}
// rebuild log
mkdir($path . '/log', 0755);
$filesToErase = array('Flat-html.html', 'Flat-markdown.md', 'Flat-sqlite.sqlite', 'Flat-text.txt', 'Premier-ace.zip', 'Premier-html.html', 'Premier-markdown.md', 'Premier-sqlite.sqlite', 'Premier-text.txt', 'datastore.sqlite', 'magicnumber.sqlite', 'report.html', 'report.md', 'report.odt', 'report.pdf', 'report.sqlite', 'report.txt', 'report.zip', 'EchoWithConcat.json', 'PhpFunctions.json', 'bigArrays.txt', 'counts.sqlite', 'stats.txt', 'dump.sqlite', 'faceted.zip', 'faceted2.zip');
$total = 0;
foreach ($filesToErase as $file) {
$filePath = $path . '/' . $file;
if (file_exists($filePath)) {
display('removing ' . $file);
unlink($filePath);
++$total;
}
}
display("Removed {$total} files\n");
$this->datastore = new Datastore($this->config, Datastore::CREATE);
display("Recreating database\n");
}