Skip to content

Commit a8ac1ba

Browse files
J-T-McCStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent 104876a commit a8ac1ba

File tree

9 files changed

+50
-43
lines changed

9 files changed

+50
-43
lines changed

config/atomic-deployments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
'build-limit' => 10,
2929

3030
/**
31-
* Logic used when creating a deployment directory
31+
* Logic used when creating a deployment directory.
3232
*
3333
* Default => git - uses hash for current HEAD
3434
* Options: [ git, rand ]
@@ -51,7 +51,7 @@
5151
* @see https://www.php.net/manual/en/function.glob.php
5252
*/
5353
'migrate' => [
54-
// 'storage/framework/sessions/*',
54+
// 'storage/framework/sessions/*',
5555
],
5656

5757
];

src/Helpers/FileHelper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Support\Facades\File;
66
use JTMcC\AtomicDeployments\Exceptions\ExecuteFailedException;
77
use JTMcC\AtomicDeployments\Exceptions\InvalidPathException;
8-
98
use JTMcC\AtomicDeployments\Services\Exec;
109
use RecursiveDirectoryIterator;
1110
use RecursiveIteratorIterator;
@@ -31,21 +30,22 @@ public static function confirmPathsExist(string ...$paths): bool
3130
}
3231

3332
/**
34-
* Recursively update symbolic links with new endpoint
33+
* Recursively update symbolic links with new endpoint.
3534
*
3635
* @param $from
3736
* @param $to
3837
*
3938
* @throws ExecuteFailedException
4039
*/
41-
public static function recursivelyUpdateSymlinks($from, $to) {
40+
public static function recursivelyUpdateSymlinks($from, $to)
41+
{
4242
$dir = new RecursiveDirectoryIterator($to);
43-
foreach(new RecursiveIteratorIterator($dir) as $file) {
44-
if(is_link($file)) {
43+
foreach (new RecursiveIteratorIterator($dir) as $file) {
44+
if (is_link($file)) {
4545
$link = $file->getPathName();
4646
$target = $file->getLinkTarget();
4747
$newPath = str_replace($from, $to, $target);
48-
if($target !== $newPath) {
48+
if ($target !== $newPath) {
4949
Exec::ln($link, $newPath);
5050
}
5151
}

src/Services/AtomicDeploymentService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,13 @@ public function copyMigrationContents(): void
242242
/**
243243
* @throws ExecuteFailedException
244244
*/
245-
public function updateSymlinks() {
246-
245+
public function updateSymlinks()
246+
{
247247
Output::info('Correcting old symlinks that still reference the build directory');
248248

249-
if($this->isDryRun()) {
249+
if ($this->isDryRun()) {
250250
Output::warn('Dry run - skipping symlink corrections');
251+
251252
return;
252253
}
253254

src/Services/Deployment.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
namespace JTMcC\AtomicDeployments\Services;
66

7-
use Illuminate\Support\Str;
87
use Illuminate\Support\Facades\File;
9-
8+
use Illuminate\Support\Str;
109
use JTMcC\AtomicDeployments\Exceptions\ExecuteFailedException;
1110
use JTMcC\AtomicDeployments\Exceptions\InvalidPathException;
1211
use JTMcC\AtomicDeployments\Helpers\FileHelper;
@@ -71,13 +70,11 @@ public function setDeploymentDirectory(string $name = ''): void
7170
$this->setDeploymentPath();
7271
}
7372

74-
7573
public function getDeploymentDirectory(): string
7674
{
7775
return $this->deploymentDirectory;
7876
}
7977

80-
8178
/**
8279
* Get the current symlinked deployment path.
8380
*
@@ -96,13 +93,15 @@ public function getCurrentDeploymentPath(): string
9693
}
9794

9895
/**
99-
* @return string
10096
* @throws ExecuteFailedException
97+
*
98+
* @return string
10199
*/
102-
public function getDirectoryName() {
103-
switch($this->directoryNaming) {
100+
public function getDirectoryName()
101+
{
102+
switch ($this->directoryNaming) {
104103
case 'rand':
105-
return Str::random(5) . time();
104+
return Str::random(5).time();
106105
case 'git':
107106
default:
108107
return Exec::getGitHash();

src/Services/Exec.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ public static function getGitHash()
8181
{
8282
return self::run('git log --pretty="%h" -n1');
8383
}
84-
8584
}

tests/Integration/Services/AtomicDeploymentServiceTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function it_doesnt_allow_deployments_folder_to_be_subdirectory_of_build_f
9696
/**
9797
* @test
9898
*/
99-
public function it_rolls_back_symbolic_link_to_deployment_detected_on_boot() {
99+
public function it_rolls_back_symbolic_link_to_deployment_detected_on_boot()
100+
{
100101
$atomicDeployment1 = self::getAtomicDeployment();
101102
$atomicDeployment1->createDeploymentDirectory();
102103
$atomicDeployment1->linkDeployment();
@@ -117,10 +118,11 @@ public function it_rolls_back_symbolic_link_to_deployment_detected_on_boot() {
117118
/**
118119
* @test
119120
*/
120-
public function it_calls_closure_on_success() {
121+
public function it_calls_closure_on_success()
122+
{
121123
$this->expectsEvents(DeploymentSuccessful::class);
122124
$success = false;
123-
self::getAtomicDeployment()->deploy(function () use(&$success) {
125+
self::getAtomicDeployment()->deploy(function () use (&$success) {
124126
$success = true;
125127
});
126128
$this->assertTrue($success);
@@ -129,14 +131,15 @@ public function it_calls_closure_on_success() {
129131
/**
130132
* @test
131133
*/
132-
public function it_calls_closure_on_failure() {
134+
public function it_calls_closure_on_failure()
135+
{
133136
$this->app['config']->set('atomic-deployments.build-path', $this->buildPath);
134137
$this->app['config']->set('atomic-deployments.deployments-path', $this->buildPath.'/deployments');
135138
$this->expectsEvents(DeploymentFailed::class);
136139
$this->expectException(InvalidPathException::class);
137140
$failed = false;
138141
$atomicDeployment = self::getAtomicDeployment();
139-
$atomicDeployment->deploy(fn() => '', function () use(&$failed) {
142+
$atomicDeployment->deploy(fn () => '', function () use (&$failed) {
140143
$failed = true;
141144
});
142145
$this->assertTrue($failed);

tests/Integration/Services/DeploymentTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ public function it_links_and_confirms_deployment()
2626
/**
2727
* @test
2828
*/
29-
public function it_sets_deployment_directory() {
29+
public function it_sets_deployment_directory()
30+
{
3031
$atomicDeployment = self::getDeployment();
3132
$atomicDeployment->setDeploymentDirectory('abc123');
32-
$this->assertTrue( $atomicDeployment->getDeploymentDirectory() === 'abc123');
33+
$this->assertTrue($atomicDeployment->getDeploymentDirectory() === 'abc123');
3334
}
3435

3536
/**
3637
* @test
3738
*/
38-
public function it_names_deployment_folder_using_config_directory_naming_git() {
39+
public function it_names_deployment_folder_using_config_directory_naming_git()
40+
{
3941
$gitHash = Exec::getGitHash();
4042
$atomicDeployment = self::getDeployment();
4143
$atomicDeployment->createDirectory();
@@ -45,7 +47,8 @@ public function it_names_deployment_folder_using_config_directory_naming_git() {
4547
/**
4648
* @test
4749
*/
48-
public function it_names_deployment_folder_using_config_directory_naming_rand() {
50+
public function it_names_deployment_folder_using_config_directory_naming_rand()
51+
{
4952
$this->app['config']->set('atomic-deployments.directory-naming', 'rand');
5053
$gitHash = Exec::getGitHash();
5154
$atomicDeployment = self::getDeployment();
@@ -57,7 +60,8 @@ public function it_names_deployment_folder_using_config_directory_naming_rand()
5760
/**
5861
* @test
5962
*/
60-
public function it_sets_deployment_path() {
63+
public function it_sets_deployment_path()
64+
{
6165
$atomicDeployment = self::getDeployment();
6266
$atomicDeployment->setDeploymentPath();
6367
$this->assertNotEmpty(trim($atomicDeployment->getDeploymentPath()));
@@ -66,7 +70,8 @@ public function it_sets_deployment_path() {
6670
/**
6771
* @test
6872
*/
69-
public function it_creates_a_directory() {
73+
public function it_creates_a_directory()
74+
{
7075
$atomicDeployment = self::getDeployment();
7176
$atomicDeployment->createDirectory();
7277
$this->assertTrue($this->fileSystem->exists($atomicDeployment->getDeploymentPath()));
@@ -75,10 +80,10 @@ public function it_creates_a_directory() {
7580
/**
7681
* @test
7782
*/
78-
public function it_updates_model_status() {
83+
public function it_updates_model_status()
84+
{
7985
$atomicDeployment = self::getDeployment();
8086
$atomicDeployment->updateDeploymentStatus(DeploymentStatus::SUCCESS);
81-
$this->assertTrue((int)AtomicDeployment::first()->deployment_status === DeploymentStatus::SUCCESS);
87+
$this->assertTrue((int) AtomicDeployment::first()->deployment_status === DeploymentStatus::SUCCESS);
8288
}
83-
8489
}

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public static function getAtomicDeployment($hash = '')
126126
/**
127127
* @return Deployment
128128
*/
129-
public static function getDeployment() {
129+
public static function getDeployment()
130+
{
130131
return app(Deployment::class);
131132
}
132133
}

tests/Unit/Helpers/FileHelperTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public function it_updates_symbolic_links_to_new_path()
2525
{
2626

2727
//create test build & deployment scenario
28-
$oldSite = self::tmpFolder . 'build/site';
29-
$oldContent = $oldSite . '/content';
30-
$oldLink = $oldSite . '/link';
28+
$oldSite = self::tmpFolder.'build/site';
29+
$oldContent = $oldSite.'/content';
30+
$oldLink = $oldSite.'/link';
3131

32-
$newSite = self::tmpFolder . 'deployments/site';
33-
$newContent = $newSite . '/content';
34-
$newLink = $newSite . '/link';
32+
$newSite = self::tmpFolder.'deployments/site';
33+
$newContent = $newSite.'/content';
34+
$newLink = $newSite.'/link';
3535

3636
$this->fileSystem->ensureDirectoryExists($oldContent);
3737
$this->fileSystem->ensureDirectoryExists($newSite);
@@ -41,12 +41,11 @@ public function it_updates_symbolic_links_to_new_path()
4141
$this->assertTrue(Exec::readlink($oldLink) === $oldContent);
4242

4343
//copy old content to deployment folder and confirm link still points to build folder
44-
Exec::rsync($oldSite . '/', $newSite . '/');
44+
Exec::rsync($oldSite.'/', $newSite.'/');
4545
$this->assertTrue(Exec::readlink($newLink) === $oldContent);
4646

4747
//convert links to new deployment path and confirm
4848
FileHelper::recursivelyUpdateSymlinks($oldSite, $newSite);
4949
$this->assertTrue(Exec::readlink($newLink) === $newContent);
50-
5150
}
5251
}

0 commit comments

Comments
 (0)