@@ -73,7 +73,7 @@ public function __construct(
7373 * @throws Throwable
7474 * @throws Exception
7575 */
76- public function run (OutputInterface $ output , string $ stage , string $ task = self :: TASK_DEPLOY ): int
76+ public function run (OutputInterface $ output , string $ stage , string $ task, bool $ configureBuildStage , bool $ configureServers ): int
7777 {
7878 $ console = new Application ();
7979 $ deployer = new Deployer ($ console );
@@ -87,7 +87,7 @@ public function run(OutputInterface $output, string $stage, string $task = self:
8787 );
8888
8989 try {
90- $ this ->initializeDeployer ($ deployer , $ task );
90+ $ this ->initializeDeployer ($ deployer , $ configureBuildStage , $ configureServers );
9191 } catch (InvalidConfigurationException $ e ) {
9292 $ output ->write ($ e ->getMessage ());
9393 return 1 ;
@@ -104,13 +104,20 @@ public function run(OutputInterface $output, string $stage, string $task = self:
104104 * @throws Throwable
105105 * @throws InvalidConfigurationException
106106 */
107- private function initializeDeployer (Deployer $ deployer , string $ task ): void
107+ private function initializeDeployer (Deployer $ deployer , bool $ configureBuildStage , bool $ configureServers ): void
108108 {
109109 $ this ->recipeLoader ->load ('common.php ' );
110110 $ tasks = $ this ->taskFactory ->loadAll ();
111111 $ config = $ this ->getConfiguration ($ deployer );
112112 $ config ->setLogger ($ this ->log );
113- $ this ->configureStages ($ config , $ task );
113+
114+ if ($ configureBuildStage ) {
115+ $ this ->initializeBuildStage ($ config );
116+ }
117+
118+ if ($ configureServers ) {
119+ $ this ->configureServers ($ config );
120+ }
114121
115122 foreach ($ tasks as $ task ) {
116123 $ task ->configure ($ config );
@@ -180,17 +187,11 @@ private function getConfiguration(Deployer $deployer): Configuration
180187 }
181188 }
182189
183- private function configureStages (Configuration $ config, string $ task ): void
190+ private function configureServers (Configuration $ config ): void
184191 {
185- if ($ task === self ::TASK_BUILD ) {
186- $ this ->initializeBuildStage ($ config );
187- }
188-
189- if ($ task === self ::TASK_DEPLOY ) {
190- foreach ($ config ->getStages () as $ stage ) {
191- foreach ($ stage ->getServers () as $ server ) {
192- $ this ->configureStageServer ($ stage , $ server , $ config );
193- }
192+ foreach ($ config ->getStages () as $ stage ) {
193+ foreach ($ stage ->getServers () as $ server ) {
194+ $ this ->configureStageServer ($ stage , $ server , $ config );
194195 }
195196 }
196197 }
0 commit comments