From 957d9a951021913fc4e1c36f16ef14e454071f05 Mon Sep 17 00:00:00 2001 From: Netkas Date: Wed, 25 Oct 2023 22:00:37 -0400 Subject: [PATCH] Added the ability to use 'all' as a build configuration when running `ncc build`, to build all build configurations in the project. The build command in ncc has been updated to accept 'all' as a build configuration which prompts the build of all configurations in the project. Previously, builds had to be triggered for each individual configurations. This change simplifies the build process especially for projects with multiple configurations, making the process more efficient and less prone to human error. --- CHANGELOG.md | 2 ++ src/ncc/CLI/Commands/BuildCommand.php | 40 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91783f3..7cc062a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ This update introduces minor bug fixes. ### Added - Added host resolving in network calls to improve the handling of invalid or unreachable URLs + - Added the ability to use 'all' as a build configuration when running `ncc build`, to build all build configurations + in the project. ### Changed - Update progress bar text to display basename only diff --git a/src/ncc/CLI/Commands/BuildCommand.php b/src/ncc/CLI/Commands/BuildCommand.php index f2bff4f..19ef8c4 100644 --- a/src/ncc/CLI/Commands/BuildCommand.php +++ b/src/ncc/CLI/Commands/BuildCommand.php @@ -89,19 +89,43 @@ return 1; } - // Build the project - try + $build_configuration = $args['config'] ?? $args['c'] ?? BuildConfigurationValues::DEFAULT; + + if($build_configuration === BuildConfigurationValues::ALL) { - $build_configuration = $args['config'] ?? $args['c'] ?? BuildConfigurationValues::DEFAULT; - $output = $project_manager->build($build_configuration, $options); + // Build all configurations + foreach($project_manager->getProjectConfiguration()->getBuild()->getBuildConfigurations() as $configuration_name) + { + Console::out(sprintf('Building configuration \'%s\'', $configuration_name)); + try + { + $output = $project_manager->build($configuration_name, $options); + } + catch (Exception $e) + { + Console::outException('Failed to build project', $e, 1); + return 1; + } + + Console::out($output); + } } - catch (Exception $e) + else { - Console::outException('Failed to build project', $e, 1); - return 1; + // Build the project + try + { + $output = $project_manager->build($build_configuration, $options); + } + catch (Exception $e) + { + Console::outException('Failed to build project', $e, 1); + return 1; + } + + Console::out($output); } - Console::out($output); return 0; }