Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Concerns/RunsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ trait RunsCommands
*
* @return Process
*/
protected function runCommand(string $command, ?string $workingPath = null, bool $disableOutput = false, ?string $taskLabel = null)
protected function runCommand(string $command, ?string $workingPath = null, bool $disableOutput = false, ?string $taskLabel = null, ?string $completedTaskLabel = null)
{
return $this->runCommands([$command], $workingPath, $disableOutput, $taskLabel);
return $this->runCommands([$command], $workingPath, $disableOutput, $taskLabel, $completedTaskLabel);
}

/**
* Run the given commands.
*
* @return Process
*/
protected function runCommands(array $commands, ?string $workingPath = null, bool $disableOutput = false, ?string $taskLabel = null)
protected function runCommands(array $commands, ?string $workingPath = null, bool $disableOutput = false, ?string $taskLabel = null, ?string $completedTaskLabel = null)
{
if (! $this->output->isDecorated()) {
$commands = array_map(function ($value) {
Expand Down Expand Up @@ -66,7 +66,7 @@ protected function runCommands(array $commands, ?string $workingPath = null, boo
$process = Process::fromShellCommandline(implode(' && ', $commands), $workingPath, timeout: null);

if ($taskLabel && ! $disableOutput && $this->shouldRunAsTask()) {
return $this->runProcessAsTask($process, $taskLabel);
return $this->runProcessAsTask($process, $taskLabel, $completedTaskLabel);
}

if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
Expand Down Expand Up @@ -105,21 +105,23 @@ private function shouldRunAsTask(): bool
/**
* Run the given process within a Laravel Prompts task, streaming its output into the task's log.
*/
private function runProcessAsTask(Process $process, string $taskLabel): Process
private function runProcessAsTask(Process $process, string $taskLabel, ?string $completedTaskLabel = null): Process
{
$output = '';

task(
label: $taskLabel,
keepSummary: true,
callback: function (Logger $logger) use ($process, &$output) {
callback: function (Logger $logger) use ($process, $completedTaskLabel, &$output) {
$process->run(function ($type, $line) use ($logger, &$output) {
$output .= $line;
$logger->line($line);
});

if (! $process->isSuccessful()) {
$logger->error("Failed with exit code {$process->getExitCode()}");
} elseif ($completedTaskLabel) {
$logger->label($completedTaskLabel);
}
},
);
Expand Down
8 changes: 5 additions & 3 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ protected function installBaseProject()
$commands[] = "chmod 755 \"$this->absolutePath/please\"";
}

$this->runCommands($commands, taskLabel: 'Installing Statamic');
$this->runCommands($commands, taskLabel: 'Installing Statamic', completedTaskLabel: 'Statamic installed');

if (! $this->wasBaseInstallSuccessful()) {
throw new RuntimeException('There was a problem installing Statamic!');
Expand Down Expand Up @@ -842,7 +842,7 @@ protected function initializeGitRepository()
"git branch -M {$branch}",
];

$this->runCommands($commands, workingPath: $this->absolutePath, taskLabel: 'Initializing Git repository');
$this->runCommands($commands, workingPath: $this->absolutePath, taskLabel: 'Initializing Git repository', completedTaskLabel: 'Git repository initialized');

return $this;
}
Expand Down Expand Up @@ -1041,12 +1041,14 @@ protected function enableStatamicPro()

$statusCode = (new Please($this->output))
->cwd($this->absolutePath)
->run('pro:enable', '--no-interaction');
->run('pro:enable', '--no-interaction', '--quiet');

if ($statusCode !== 0) {
throw new RuntimeException('There was a problem enabling Statamic Pro!');
}

$this->output->writeln(' <fg=green>✔</> Pro enabled');

if ($this->statamicLicenseKey) {
$this->writeStatamicLicenseKeyToEnv();
}
Expand Down
Loading