Skip to content

Commit d80204c

Browse files
committed
Run pint to prevent having to constantly discard changes. References 4dc1bf3.
1 parent 4dc1bf3 commit d80204c

5 files changed

Lines changed: 43 additions & 37 deletions

File tree

src/Concerns/InstallsLegacy.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ protected function applyPermissions()
8080
$this->command->output->write('Updating file permissions...');
8181

8282
foreach (['local', 'site', 'statamic', 'assets'] as $folder) {
83-
$dir = $this->command->absolutePath . '/' . $folder;
83+
$dir = $this->command->absolutePath.'/'.$folder;
8484
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
8585

8686
foreach ($iterator as $item) {
8787
chmod($item, 0777);
8888
}
8989
}
9090

91-
$this->command->output->writeln(" <info>[✔]</info>");
91+
$this->command->output->writeln(' <info>[✔]</info>');
9292

9393
return $this;
9494
}
@@ -101,7 +101,8 @@ protected function createUser()
101101

102102
if (! $helper->ask($this->command->input, $this->command->output, $question)) {
103103
$this->command->output->writeln("\x1B[1A\x1B[2K{$questionText}<fg=red>[✘]</>");
104-
$this->command->output->writeln("<comment>[!]</comment> You may create a user with <comment>php please make:user</comment>");
104+
$this->command->output->writeln('<comment>[!]</comment> You may create a user with <comment>php please make:user</comment>');
105+
105106
return $this;
106107
}
107108

@@ -140,7 +141,7 @@ protected function getZipFromServer()
140141
}
141142

142143
$this->progressBar->setProgress($downloaded);
143-
}
144+
},
144145
]);
145146

146147
$response = $client->get("https://outpost.statamic.com/v2/get/{$this->version}");
@@ -172,7 +173,7 @@ protected function createProgressBar($downloadSize)
172173

173174
protected function formatBytes($bytes)
174175
{
175-
$units = array('B', 'KB', 'MB', 'GB', 'TB');
176+
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
176177
$bytes = max($bytes, 0);
177178
$pow = $bytes ? floor(log($bytes, 1024)) : 0;
178179
$pow = min($pow, count($units) - 1);

src/Concerns/RunsCommands.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ trait RunsCommands
99
/**
1010
* Run the given command.
1111
*
12-
* @param string $command
13-
* @param bool $disableOutput
12+
* @param string $command
13+
* @param bool $disableOutput
1414
* @return Process
1515
*/
1616
protected function runCommand($command, $disableOutput = false)
@@ -21,8 +21,8 @@ protected function runCommand($command, $disableOutput = false)
2121
/**
2222
* Run the given commands.
2323
*
24-
* @param array $commands
25-
* @param bool $disableOutput
24+
* @param array $commands
25+
* @param bool $disableOutput
2626
* @return Process
2727
*/
2828
protected function runCommands($commands, $disableOutput = false)

src/NewCommand.php

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use GuzzleHttp\Client;
66
use RuntimeException;
7-
use Statamic\Cli\Concerns;
8-
use Statamic\Cli\Please;
97
use Symfony\Component\Console\Command\Command;
108
use Symfony\Component\Console\Input\InputArgument;
119
use Symfony\Component\Console\Input\InputInterface;
@@ -65,8 +63,8 @@ protected function configure()
6563
/**
6664
* Execute the command.
6765
*
68-
* @param \Symfony\Component\Console\Input\InputInterface $input
69-
* @param \Symfony\Component\Console\Output\OutputInterface $output
66+
* @param \Symfony\Component\Console\Input\InputInterface $input
67+
* @param \Symfony\Component\Console\Output\OutputInterface $output
7068
* @return int
7169
*/
7270
protected function execute(InputInterface $input, OutputInterface $output)
@@ -138,8 +136,8 @@ protected function notifyIfOldCliVersion()
138136

139137
$this->output->write(PHP_EOL);
140138
$this->output->write("<comment>This is an old version of the Statamic CLI Tool, please upgrade to {$this->shouldUpdateCliToVersion}!</comment>".PHP_EOL);
141-
$this->output->write("<comment>If you have a global composer installation, you may upgrade by running the following command:</comment>".PHP_EOL);
142-
$this->output->write("<comment>composer global update statamic/cli</comment>".PHP_EOL);
139+
$this->output->write('<comment>If you have a global composer installation, you may upgrade by running the following command:</comment>'.PHP_EOL);
140+
$this->output->write('<comment>composer global update statamic/cli</comment>'.PHP_EOL);
143141

144142
return $this;
145143
}
@@ -180,6 +178,7 @@ protected function processArguments()
180178
* Validate arguments and options.
181179
*
182180
* @return $this
181+
*
183182
* @throws RuntimeException
184183
*/
185184
protected function validateArguments()
@@ -253,7 +252,7 @@ protected function askForRepo()
253252
'Starter Kit',
254253
];
255254

256-
$question = new ChoiceQuestion("Would you like to start with a blank site or starter kit? [<comment>Blank Site</comment>]", $options, 0);
255+
$question = new ChoiceQuestion('Would you like to start with a blank site or starter kit? [<comment>Blank Site</comment>]', $options, 0);
257256

258257
$choice = $helper->ask($this->input, new SymfonyStyle($this->input, $this->output), $question);
259258

@@ -397,6 +396,7 @@ protected function confirmSingleSiteLicense()
397396
* Install base project.
398397
*
399398
* @return $this
399+
*
400400
* @throws RuntimeException
401401
*/
402402
protected function installBaseProject()
@@ -437,6 +437,7 @@ protected function installBaseProject()
437437
* Install starter kit.
438438
*
439439
* @return $this
440+
*
440441
* @throws RuntimeException
441442
*/
442443
protected function installStarterKit()
@@ -540,8 +541,8 @@ protected function makeSuperUserInWindows()
540541
$please->run('make:user', '--super', $email);
541542

542543
$updateUser = '\Statamic\Facades\User::findByEmail('.escapeshellarg($email).')'
543-
. '->password('.escapeshellarg($password).')'
544-
. '->makeSuper()';
544+
.'->password('.escapeshellarg($password).')'
545+
.'->makeSuper()';
545546

546547
if ($name) {
547548
$updateUser .= '->set("name", '.escapeshellarg($name).')';
@@ -557,8 +558,8 @@ protected function makeSuperUserInWindows()
557558
/**
558559
* Ask for basic input.
559560
*
560-
* @param string $label
561-
* @param bool $hiddenInput
561+
* @param string $label
562+
* @param bool $hiddenInput
562563
* @return mixed
563564
*/
564565
protected function askForBasicInput($label, $hiddenInput = false)
@@ -573,7 +574,7 @@ protected function askForBasicInput($label, $hiddenInput = false)
573574
/**
574575
* Validate email address.
575576
*
576-
* @param string $email
577+
* @param string $email
577578
* @return bool
578579
*/
579580
protected function validateEmail($email)
@@ -582,15 +583,15 @@ protected function validateEmail($email)
582583
return true;
583584
}
584585

585-
$this->output->write("<error>Invalid email address.</error>".PHP_EOL);
586+
$this->output->write('<error>Invalid email address.</error>'.PHP_EOL);
586587

587588
return false;
588589
}
589590

590591
/**
591592
* Validate password.
592593
*
593-
* @param string $password
594+
* @param string $password
594595
* @return bool
595596
*/
596597
protected function validatePassword($password)
@@ -599,7 +600,7 @@ protected function validatePassword($password)
599600
return true;
600601
}
601602

602-
$this->output->write("<error>The input must be at least 8 characters.</error>".PHP_EOL);
603+
$this->output->write('<error>The input must be at least 8 characters.</error>'.PHP_EOL);
603604

604605
return false;
605606
}
@@ -613,7 +614,7 @@ protected function showSuccessMessage()
613614
{
614615
$this->output->writeln(PHP_EOL."<info>[✔] Statamic has been successfully installed into the <comment>{$this->relativePath}</comment> directory.</info>");
615616

616-
$this->output->writeln("Build something rad!");
617+
$this->output->writeln('Build something rad!');
617618

618619
return $this;
619620
}
@@ -639,9 +640,13 @@ protected function askToSpreadJoy()
639640
return $this;
640641
}
641642

642-
if (PHP_OS_FAMILY == 'Darwin') exec('open https://github.com/statamic/cms');
643-
if (PHP_OS_FAMILY == 'Windows') exec('start https://github.com/statamic/cms');
644-
if (PHP_OS_FAMILY == 'Linux') exec('xdg-open https://github.com/statamic/cms');
643+
if (PHP_OS_FAMILY == 'Darwin') {
644+
exec('open https://github.com/statamic/cms');
645+
} elseif (PHP_OS_FAMILY == 'Windows') {
646+
exec('start https://github.com/statamic/cms');
647+
} elseif (PHP_OS_FAMILY == 'Linux') {
648+
exec('xdg-open https://github.com/statamic/cms');
649+
}
645650

646651
return $this;
647652
}
@@ -746,9 +751,9 @@ protected function updateEnvVars()
746751
/**
747752
* Replace the given string in the given file.
748753
*
749-
* @param string $search
750-
* @param string $replace
751-
* @param string $file
754+
* @param string $search
755+
* @param string $replace
756+
* @param string $file
752757
*/
753758
protected function replaceInFile(string $search, string $replace, string $file)
754759
{
@@ -801,7 +806,8 @@ protected function getStarterKitLicense()
801806
*/
802807
protected function exitInstallation()
803808
{
804-
return new class {
809+
return new class
810+
{
805811
public function __call($method, $args)
806812
{
807813
return $this;

src/Please.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Statamic\Cli;
44

5-
use Symfony\Component\Process\Process;
65
use Symfony\Component\Console\Output\OutputInterface;
76
use Symfony\Component\Process\Exception\RuntimeException;
7+
use Symfony\Component\Process\Process;
88

99
class Please
1010
{
@@ -15,7 +15,7 @@ class Please
1515
/**
1616
* Instantiate Statamic `please` command wrapper.
1717
*
18-
* @param OutputInterface $output
18+
* @param OutputInterface $output
1919
*/
2020
public function __construct(OutputInterface $output)
2121
{
@@ -25,7 +25,7 @@ public function __construct(OutputInterface $output)
2525
/**
2626
* Get or set current working directory.
2727
*
28-
* @param mixed $cwd
28+
* @param mixed $cwd
2929
* @return mixed
3030
*/
3131
public function cwd($cwd = null)
@@ -52,7 +52,7 @@ public function isV2()
5252
/**
5353
* Run please command.
5454
*
55-
* @param mixed $commandParts
55+
* @param mixed $commandParts
5656
* @return int
5757
*/
5858
public function run(...$commandParts)

src/UpdateCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Statamic\Cli;
44

5-
use Statamic\Cli\Concerns;
65
use Symfony\Component\Console\Command\Command;
76
use Symfony\Component\Console\Input\InputInterface;
87
use Symfony\Component\Console\Output\OutputInterface;

0 commit comments

Comments
 (0)