1212use JTMcC \AtomicDeployments \Exceptions \ExecuteFailedException ;
1313use JTMcC \AtomicDeployments \Helpers \FileHelper ;
1414use JTMcC \AtomicDeployments \Interfaces \DeploymentInterface ;
15- use JTMcC \AtomicDeployments \Models \AtomicDeployment as Model ;
15+ use JTMcC \AtomicDeployments \Models \AtomicDeployment ;
1616use JTMcC \AtomicDeployments \Models \Enums \DeploymentStatus ;
1717
1818class AtomicDeploymentService
@@ -47,7 +47,7 @@ public function __construct(DeploymentInterface $deployment, array $migrate = []
4747
4848 register_shutdown_function ([$ this , 'shutdown ' ]);
4949
50- $ this ->initialDeploymentPath = $ deployment ->getCurrentDeploymentPath ();
50+ $ this ->initialDeploymentPath = $ deployment ->getCurrentPath ();
5151 }
5252
5353 /**
@@ -69,10 +69,10 @@ public function getInitialDeploymentPath(): string
6969 /**
7070 * Run full deployment.
7171 *
72- * @param Closure|null $success
73- * @param Closure|null $failed
72+ * @param Closure|null $successCallback
73+ * @param Closure|null $failedCallback
7474 */
75- public function deploy (?Closure $ success = null , ?Closure $ failed = null ): void
75+ public function deploy (?Closure $ successCallback = null , ?Closure $ failedCallback = null ): void
7676 {
7777 try {
7878 if ($ this ->isDryRun ()) {
@@ -98,14 +98,14 @@ public function deploy(?Closure $success = null, ?Closure $failed = null): void
9898
9999 DeploymentSuccessful::dispatch ($ this , $ this ->deployment ->getModel ());
100100
101- if ($ success ) {
102- $ success ($ this );
101+ if ($ successCallback ) {
102+ $ successCallback ($ this );
103103 }
104104 } catch (\Throwable $ e ) {
105- $ this ->failed ();
105+ $ this ->fail ();
106106 Output::throwable ($ e );
107- if ($ failed ) {
108- $ failed ($ this );
107+ if ($ failedCallback ) {
108+ $ failedCallback ($ this );
109109 }
110110 }
111111 }
@@ -120,18 +120,18 @@ public function updateDeploymentStatus(int $status): void
120120
121121 return ;
122122 }
123- $ this ->deployment ->updateDeploymentStatus ($ status );
123+ $ this ->deployment ->updateStatus ($ status );
124124 }
125125
126126 public function linkDeployment (): void
127127 {
128- Output::info ("Creating symbolic link: {$ this ->deployment ->getDeploymentLink ()} -> {$ this ->deployment ->getDeploymentPath ()}" );
128+ Output::info ("Creating symbolic link: {$ this ->deployment ->getLink ()} -> {$ this ->deployment ->getPath ()}" );
129129 if ($ this ->isDryRun ()) {
130130 Output::warn ('Dry run - Skipping symbolic link deployment ' );
131131
132132 return ;
133133 }
134- $ this ->deployment ->linkDeployment ();
134+ $ this ->deployment ->link ();
135135 Output::info ('Link created ' );
136136 }
137137
@@ -153,8 +153,8 @@ public function confirmSymbolicLink(): bool
153153 if (!$ this ->deployment ->isDeployed ()) {
154154 throw new ExecuteFailedException (
155155 'Expected deployment link to direct to ' .
156- $ this ->deployment ->getDeploymentPath ().' but found ' .
157- $ this ->deployment ->getCurrentDeploymentPath ()
156+ $ this ->deployment ->getPath ().' but found ' .
157+ $ this ->deployment ->getCurrentPath ()
158158 );
159159 }
160160
@@ -165,7 +165,7 @@ public function confirmSymbolicLink(): bool
165165
166166 public function createDeploymentDirectory (): void
167167 {
168- Output::info ("Creating directory at {$ this ->deployment ->getDeploymentPath ()}" );
168+ Output::info ("Creating directory at {$ this ->deployment ->getPath ()}" );
169169
170170 if ($ this ->isDryRun ()) {
171171 Output::warn ('Dry run - Skipping creating deployment directory ' );
@@ -209,7 +209,7 @@ public function copyMigrationContents(): void
209209 }
210210
211211 $ rootFrom = rtrim ($ this ->initialDeploymentPath , DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR ;
212- $ rootTo = rtrim ($ this ->deployment ->getDeploymentPath (), DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR ;
212+ $ rootTo = rtrim ($ this ->deployment ->getPath (), DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR ;
213213
214214 foreach (File::glob ($ rootFrom .$ pattern ) as $ from ) {
215215 $ dir = $ from ;
@@ -254,7 +254,7 @@ public function updateSymlinks()
254254
255255 FileHelper::recursivelyUpdateSymlinks (
256256 $ this ->getDeployment ()->getBuildPath (),
257- $ this ->getDeployment ()->getDeploymentPath ()
257+ $ this ->getDeployment ()->getPath ()
258258 );
259259
260260 Output::info ('Finished correcting symlinks ' );
@@ -265,7 +265,7 @@ public function rollback(): void
265265 Output::warn ('Atomic deployment rollback has been requested ' );
266266
267267 if (!$ this ->isDryRun ()) {
268- $ currentPath = $ this ->deployment ->getCurrentDeploymentPath ();
268+ $ currentPath = $ this ->deployment ->getCurrentPath ();
269269
270270 if (
271271 //confirm if we need to revert the link
@@ -276,8 +276,8 @@ public function rollback(): void
276276
277277 try {
278278 //attempt to revert link to our original path
279- Exec::ln ($ this ->deployment ->getDeploymentLink (), $ this ->initialDeploymentPath );
280- if ($ this ->deployment ->getCurrentDeploymentPath () === $ this ->initialDeploymentPath ) {
279+ Exec::ln ($ this ->deployment ->getLink (), $ this ->initialDeploymentPath );
280+ if ($ this ->deployment ->getCurrentPath () === $ this ->initialDeploymentPath ) {
281281 Output::info ('Successfully rolled back symbolic link ' );
282282
283283 return ;
@@ -300,7 +300,7 @@ public function isDryRun(): bool
300300 return $ this ->dryRun ;
301301 }
302302
303- public function failed (): void
303+ public function fail (): void
304304 {
305305 $ this ->rollback ();
306306 DeploymentFailed::dispatch ($ this , $ this ->deployment ->getModel ());
@@ -311,7 +311,7 @@ public function shutdown(): void
311311 {
312312 if ($ error = error_get_last ()) {
313313 Output::error ('Error detected during shutdown, requesting rollback ' );
314- $ this ->failed ();
314+ $ this ->fail ();
315315 }
316316 }
317317
@@ -320,16 +320,16 @@ public function cleanBuilds(int $limit): void
320320 Output::alert ('Running Build Cleanup ' );
321321 Output::info ("Max deployment directories allowed set to {$ limit }" );
322322
323- $ buildIDs = Model ::successful ()
323+ $ buildIDs = AtomicDeployment ::successful ()
324324 ->orderBy ('id ' , 'desc ' )
325325 ->limit ($ limit )
326326 ->pluck ('id ' );
327327
328- $ buildsToRemove = Model ::whereNotIn ('id ' , $ buildIDs )->get ();
328+ $ buildsToRemove = AtomicDeployment ::whereNotIn ('id ' , $ buildIDs )->get ();
329329
330- $ found = $ buildsToRemove ->count ();
330+ $ countOfBuildsToRemove = $ buildsToRemove ->count ();
331331
332- Output::info ('Found ' .$ found .' ' .Pluralizer::plural ('folder ' , $ found ).' to be removed ' );
332+ Output::info ('Found ' .$ countOfBuildsToRemove .' ' .Pluralizer::plural ('folder ' , $ countOfBuildsToRemove ).' to be removed ' );
333333
334334 foreach ($ buildsToRemove as $ deployment ) {
335335 if ($ deployment ->isCurrentlyDeployed ) {
0 commit comments