33namespace App \Commands ;
44
55use App \Support \Configuration ;
6+ use Carbon \CarbonInterval ;
67use Illuminate \Console \Scheduling \Schedule ;
78use Laravel \Forge \Forge ;
89use LaravelZero \Framework \Commands \Command ;
910
1011class DeployCommand extends ForgeCommand
1112{
12- protected $ signature = 'deploy {environment=production} {--update-script} ' ;
13+ protected $ signature = 'deploy {environment=production} {--update-script} {--no-wait} ' ;
1314
1415 protected $ description = 'Deploy the current project to Forge ' ;
1516
1617 public function handle (Forge $ forge , Configuration $ configuration )
1718 {
18- if (! $ this ->ensureHasToken ()) {
19+ if (!$ this ->ensureHasToken ()) {
1920 return 1 ;
2021 }
21- if (! $ this ->ensureHasForgeConfiguration ()) {
22+ if (!$ this ->ensureHasForgeConfiguration ()) {
2223 return 1 ;
2324 }
2425
@@ -39,16 +40,20 @@ public function handle(Forge $forge, Configuration $configuration)
3940
4041 $ forge ->deploySite ($ serverId , $ siteId );
4142
42- $ forge ->retry ($ forge ->timeout , function () use ($ serverId , $ siteId , $ forge ) {
43- $ site = $ forge ->site ($ serverId , $ siteId );
43+ if (!$ this ->option ('no-wait ' )) {
44+ $ forge ->retry (CarbonInterval::minutes (10 )->totalSeconds , function () use ($ serverId , $ siteId , $ forge ) {
45+ $ site = $ forge ->site ($ serverId , $ siteId );
4446
45- return is_null ($ site ->deploymentStatus );
46- }, 5 );
47+ return is_null ($ site ->deploymentStatus );
48+ }, 5 );
49+ }
4750
4851 $ this ->info ('The site has been deployed ' );
4952
50- $ this ->call ('deploy:log ' , [
51- 'environment ' => $ environment ,
52- ]);
53+ if (!$ this ->option ('no-wait ' )) {
54+ $ this ->call ('deploy:log ' , [
55+ 'environment ' => $ environment ,
56+ ]);
57+ }
5358 }
5459}
0 commit comments