Skip to content

Commit 20fc6ed

Browse files
Update for Laravel 6
We need to account for the fact that the default Bootstrap preset has been extracted to a separate package in laravel/ui and install this, before being able to run the Inertia.js preset over the top of it.
1 parent 0facbe0 commit 20fc6ed

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/InertiaJsPreset.php

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

33
namespace LaravelFrontendPresets\InertiaJsPreset;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Filesystem\Filesystem;
7+
use Symfony\Component\Process\Process;
8+
use Illuminate\Support\Facades\Artisan;
69
use Illuminate\Foundation\Console\Presets\Preset;
7-
use Illuminate\Support\Arr;
810

911
class InertiaJsPreset extends Preset
1012
{
11-
public static function install()
13+
private static $command;
14+
15+
public static function install($command)
1216
{
17+
static::$command = $command;
18+
1319
static::updatePackages();
20+
static::installBootstrapDefault();
1421
static::updateBootstrapping();
1522
static::updateWelcomePage();
1623
static::updateGitignore();
@@ -25,6 +32,7 @@ protected static function updatePackageArray(array $packages)
2532
'@babel/plugin-syntax-dynamic-import' => '^7.2.0',
2633
'@inertiajs/inertia' => '^0.1.0',
2734
'@inertiajs/inertia-vue' => '^0.1.0',
35+
'vue' => '^2.5.17',
2836
'vue-template-compiler' => '^2.6.10',
2937
], $packages);
3038
}
@@ -70,4 +78,21 @@ protected static function scaffoldRoutes()
7078
{
7179
copy(__DIR__.'/inertiajs-stubs/routes/web.php', base_path('routes/web.php'));
7280
}
81+
82+
protected static function installBootstrapDefault()
83+
{
84+
if (! file_exists(base_path('composer.json'))) {
85+
return;
86+
}
87+
88+
tap(new Process('composer require --dev laravel/ui=^1.0', base_path()), function ($process) {
89+
$process->run();
90+
91+
Artisan::call('preset bootstrap', [], static::$command->getOutput());
92+
});
93+
94+
tap(new Process('composer remove --dev laravel/ui', base_path()), function ($process) {
95+
$process->run();
96+
});
97+
}
7398
}

src/InertiaJsPresetServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class InertiaJsPresetServiceProvider extends ServiceProvider
1010
public function boot()
1111
{
1212
PresetCommand::macro('inertiajs', function ($command) {
13-
InertiaJsPreset::install();
13+
InertiaJsPreset::install($command);
1414

1515
$command->info('Inertia.js scaffolding installed successfully.');
1616
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');

src/inertiajs-stubs/gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/public/css
22
/public/js
3+
/public/mix-manifest.json

0 commit comments

Comments
 (0)