Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Install NPM dependencies and build assets #180

Merged
merged 2 commits into from
Aug 12, 2022
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
24 changes: 24 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use RuntimeException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -197,4 +198,27 @@ protected function phpBinary()
{
return (new PhpExecutableFinder())->find(false) ?: 'php';
}

/**
* Run the given commands.
*
* @param array $commands
* @return void
*/
protected function runCommands($commands)
{
$process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null);

if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
try {
$process->setTty(true);
} catch (RuntimeException $e) {
$this->output->writeln(' <bg=yellow;fg=black> WARN </> '.$e->getMessage().PHP_EOL);
}
}

$process->run(function ($type, $line) {
$this->output->write(' '.$line);
});
}
}
4 changes: 3 additions & 1 deletion src/Console/InstallsBladeStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ protected function installBladeStack()
copy(__DIR__.'/../../stubs/default/resources/css/app.css', resource_path('css/app.css'));
copy(__DIR__.'/../../stubs/default/resources/js/app.js', resource_path('js/app.js'));

$this->runCommands(['npm install', 'npm run build']);

$this->line('');
$this->components->info('Breeze scaffolding installed successfully.');
$this->components->warn('Please execute the [npm install && npm run dev] commands to build your assets.');
}
}
8 changes: 6 additions & 2 deletions src/Console/InstallsInertiaStacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ protected function installInertiaVueStack()
$this->installInertiaVueSsrStack();
}

$this->runCommands(['npm install', 'npm run build']);

$this->line('');
$this->components->info('Breeze scaffolding installed successfully.');
$this->components->warn('Please execute the [npm install && npm run dev] commands to build your assets.');
}

/**
Expand Down Expand Up @@ -197,8 +199,10 @@ protected function installInertiaReactStack()
$this->installInertiaReactSsrStack();
}

$this->runCommands(['npm install', 'npm run build']);

$this->line('');
$this->components->info('Breeze scaffolding installed successfully.');
$this->components->warn('Please execute the [npm install && npm run dev] commands to build your assets.');
}

/**
Expand Down