File tree Expand file tree Collapse file tree 6 files changed +27
-17
lines changed Expand file tree Collapse file tree 6 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -12,19 +12,19 @@ class ListCommand extends BaseCommand
1212
1313 protected $ description = 'List currently available deployments ' ;
1414
15- public function handle ()
15+ public function handle (): void
1616 {
1717 ConsoleOutput::line ('' );
1818 ConsoleOutput::alert ('Available Deployments ' );
1919
20- $ deployments = AtomicDeployment::select (
20+ $ deployments = AtomicDeployment::query ()-> select ([
2121 'id ' ,
2222 'commit_hash ' ,
2323 'deployment_path ' ,
2424 'deployment_link ' ,
2525 'deployment_status ' ,
2626 'created_at ' ,
27- )->get ()->map (function ($ deployment ) {
27+ ] )->get ()->map (function (AtomicDeployment $ deployment ) {
2828 $ deployment ->append ('is_currently_deployed ' );
2929 $ deployment ->deployment_status = DeploymentStatus::getNameFromValue ($ deployment ->deployment_status );
3030
Original file line number Diff line number Diff line change 66
77/**
88 * @method static void line(string $string)
9+ * @method static void warn(string $string)
910 * @method static void alert(string $string)
1011 * @method static void error(string $string)
1112 * @method static void info(string $string)
12- * @method static void table(string $string )
13+ * @method static void table(array $titles, array $rows )
1314 */
1415class ConsoleOutput
1516{
Original file line number Diff line number Diff line change @@ -23,4 +23,10 @@ public function getLink();
2323 public function getModel ();
2424
2525 public function updateStatus (int $ status );
26+
27+ public function isDeployed (): bool ;
28+
29+ public function getDirectoryName (): string ;
30+
31+ public function createDirectory ();
2632}
Original file line number Diff line number Diff line change 1818 *
1919 * @property-read bool $has_deployment
2020 * @property-read bool $is_currently_deployed
21+ * @property string $commit_hash
22+ * @property int $deployment_status
23+ * @property string $build_path
24+ * @property string $deployment_path
25+ * @property string $deployment_link
2126 */
2227class AtomicDeployment extends Model
2328{
Original file line number Diff line number Diff line change 55namespace JTMcC \AtomicDeployments \Services ;
66
77use Closure ;
8+ use Illuminate \Database \Eloquent \Collection ;
89use Illuminate \Support \Facades \File ;
910use Illuminate \Support \Pluralizer ;
1011use JTMcC \AtomicDeployments \Events \DeploymentFailed ;
@@ -310,13 +311,15 @@ public function cleanBuilds(int $limit): void
310311 ->limit ($ limit )
311312 ->pluck ('id ' );
312313
313- $ buildsToRemove = AtomicDeployment::whereNotIn ('id ' , $ buildIDs )->get ();
314+ /* @var Collection<AtomicDeployment> $buildsToRemove */
315+ $ buildsToRemove = AtomicDeployment::query ()->whereNotIn ('id ' , $ buildIDs )->get ();
314316
315317 $ countOfBuildsToRemove = $ buildsToRemove ->count ();
316318
317319 Output::info ('Found ' .$ countOfBuildsToRemove .' ' .Pluralizer::plural ('folder ' , $ countOfBuildsToRemove ).' to be removed ' );
318320
319321 foreach ($ buildsToRemove as $ deployment ) {
322+
320323 if ($ deployment ->is_currently_deployed ) {
321324 Output::warn ('Current linked path has appeared in the directory cleaning logic ' );
322325 Output::warn ('This either means you currently have an old build deployed or there is a problem with your deployment data ' );
@@ -328,6 +331,7 @@ public function cleanBuilds(int $limit): void
328331 Output::info ("Deleting {$ deployment ->commit_hash }" );
329332
330333 if (! $ this ->isDryRun ()) {
334+ // @phpstan-ignore-next-line
331335 $ deployment ->delete ();
332336 Output::info ('Deployment deleted ' );
333337 } else {
Original file line number Diff line number Diff line change @@ -94,21 +94,15 @@ public function getCurrentPath(): string
9494 }
9595
9696 /**
97- * @return string
98- *
9997 * @throws ExecuteFailedException
10098 */
101- public function getDirectoryName ()
99+ public function getDirectoryName (): string
102100 {
103- switch ($ this ->directoryNaming ) {
104- case 'datetime ' :
105- return Carbon::now ()->format ('Y-m-d_H-i-s ' );
106- case 'rand ' :
107- return Str::random (5 ).time ();
108- case 'git ' :
109- default :
110- return Exec::getGitHash ();
111- }
101+ return match ($ this ->directoryNaming ) {
102+ 'datetime ' => Carbon::now ()->format ('Y-m-d_H-i-s ' ),
103+ 'rand ' => Str::random (5 ).time (),
104+ default => Exec::getGitHash (),
105+ };
112106 }
113107
114108 /**
You can’t perform that action at this time.
0 commit comments