Skip to content
Snippets Groups Projects
Commit d6cddaec authored by Sebastien's avatar Sebastien
Browse files

Merge request modifications: naming consistancy + remove symfony comments +...

Merge request modifications: naming consistancy + remove symfony comments + php8 array initialization
parent d052f551
Branches
Tags
1 merge request!74tuleap-190 : add command to update projects with latest version of capsule-prototype
......@@ -71,29 +71,27 @@ class UpdateAllProjects extends Command
$legacy_root = $this->kernel->getProjectDir() . '/legacy';
$capsule_prototype_root = './capsule-prototype';
$blackList = array(
'css', 'create.zip', 'favicon.ico', 'la-page-des-malins.php', 'js', 'php', 'shared', '.', '..'
);
$black_list = ['css', 'create.zip', 'favicon.ico', 'la-page-des-malins.php', 'js', 'php', 'shared', '.', '..'];
$directory_files = scandir($legacy_root);
if (false === $directory_files) {
return Command::FAILURE;
}
$all_file_in_directory = array_diff($directory_files, $blackList);
$all_file_in_directory = array_diff($directory_files, $black_list);
$phpFiles = glob($capsule_prototype_root . '/php/*.php');
$php_files = glob($capsule_prototype_root . '/php/*.php');
// add +1 for index.html file
$phpFilesCountPerProjects = count($phpFiles ?: []) + 1;
$php_files_count_per_projects = count($php_files ?: []) + 1;
$allProjectsProgressBar = new ProgressBar($output->section());
$allProjectsProgressBar->setFormat(
$all_projects_progress_bar = new ProgressBar($output->section());
$all_projects_progress_bar->setFormat(
'%current%/%max% [%bar%] %percent%% : Overall project update progressing (%elapsed%)'
);
$allProjectsProgressBar->SetMessage('Projects update progress');
$allProjectsProgressBar->start();
$all_projects_progress_bar->SetMessage('Projects update progress');
$all_projects_progress_bar->start();
foreach ($allProjectsProgressBar->iterate($all_file_in_directory) as $value) {
foreach ($all_projects_progress_bar->iterate($all_file_in_directory) as $value) {
$current_legacy_path = Path::normalize($legacy_root . '/' . $value);
if (!$this->filesystem->exists($current_legacy_path)) {
......@@ -104,15 +102,15 @@ class UpdateAllProjects extends Command
continue;
}
if (in_array($value, $blackList)) {
if (in_array($value, $black_list)) {
continue;
}
$progressBar = new ProgressBar($output->section(), $phpFilesCountPerProjects);
$progressBar->setFormat('project_update_message');
$progressBar->setMessage($current_legacy_path, 'project');
$progress_bar = new ProgressBar($output->section(), $php_files_count_per_projects);
$progress_bar->setFormat('project_update_message');
$progress_bar->setMessage($current_legacy_path, 'project');
$progressBar->start();
$progress_bar->start();
// override index.html
$this->filesystem->copy(
......@@ -120,7 +118,7 @@ class UpdateAllProjects extends Command
Path::normalize($current_legacy_path . '/index.html'),
true
);
$progressBar->advance();
$progress_bar->advance();
// override php files
$this->filesystem->mirror(
......@@ -129,23 +127,13 @@ class UpdateAllProjects extends Command
null,
['override' => true, 'delete' => true ]
);
$progressBar->advance($phpFilesCountPerProjects - 1);
$progressBar->finish();
$allProjectsProgressBar->advance($phpFilesCountPerProjects);
$progress_bar->advance($php_files_count_per_projects - 1);
$progress_bar->finish();
$all_projects_progress_bar->advance($php_files_count_per_projects);
}
$allProjectsProgressBar->finish();
$all_projects_progress_bar->finish();
// return this if there was no problem running the command
// (it's equivalent to returning int(0))
return Command::SUCCESS;
// or return this if some error happened during the execution
// (it's equivalent to returning int(1))
// return Command::FAILURE;
// or return this to indicate incorrect command usage; e.g. invalid options
// or missing arguments (it's equivalent to returning int(2))
// return Command::INVALID
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment