Skip to content

Commit b2d265b

Browse files
author
Robert Kummer
committed
Using laravel/ui to meet the laravel 7 dependencies.
Updated base class reference to ui command and preset including type hints.
1 parent 758e024 commit b2d265b

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
}
1212
],
1313
"require": {
14-
"laravel/framework": "^5.8|^6.0",
15-
"inertiajs/inertia-laravel": "^0.1"
14+
"laravel/ui": "^2.0",
15+
"inertiajs/inertia-laravel": "^0.2"
1616
},
1717
"require-dev": {
1818
"orchestra/testbench": "^3.8"

src/InertiaJsPreset.php

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

55
use Illuminate\Container\Container;
66
use Illuminate\Filesystem\Filesystem;
7-
use Illuminate\Foundation\Console\Presets\Preset;
8-
use Illuminate\Support\Arr;
9-
use Illuminate\Support\Facades\Artisan;
107
use Illuminate\Support\Str;
11-
use Symfony\Component\Process\Process;
8+
use Laravel\Ui\Presets\Preset;
129

1310
class InertiaJsPreset extends Preset
1411
{
@@ -40,55 +37,55 @@ protected static function updatePackageArray(array $packages)
4037
protected static function updateComposerArray(array $packages)
4138
{
4239
return array_merge([
43-
'inertiajs/inertia-laravel' => '^0.1',
40+
'inertiajs/inertia-laravel' => '^0.2',
4441
], $packages);
4542
}
4643

4744
protected static function updateBootstrapping()
4845
{
49-
copy(__DIR__.'/inertiajs-stubs/webpack.mix.js', base_path('webpack.mix.js'));
46+
copy(__DIR__ . '/inertiajs-stubs/webpack.mix.js', base_path('webpack.mix.js'));
5047

51-
copy(__DIR__.'/inertiajs-stubs/resources/js/app.js', resource_path('js/app.js'));
48+
copy(__DIR__ . '/inertiajs-stubs/resources/js/app.js', resource_path('js/app.js'));
5249

53-
copy(__DIR__.'/inertiajs-stubs/resources/sass/app.scss', resource_path('sass/app.scss'));
54-
copy(__DIR__.'/inertiajs-stubs/resources/sass/_nprogress.scss', resource_path('sass/_nprogress.scss'));
50+
copy(__DIR__ . '/inertiajs-stubs/resources/sass/app.scss', resource_path('sass/app.scss'));
51+
copy(__DIR__ . '/inertiajs-stubs/resources/sass/_nprogress.scss', resource_path('sass/_nprogress.scss'));
5552
}
5653

5754
protected static function updateWelcomePage()
5855
{
5956
(new Filesystem)->delete(resource_path('views/welcome.blade.php'));
6057

61-
copy(__DIR__.'/inertiajs-stubs/resources/views/app.blade.php', resource_path('views/app.blade.php'));
58+
copy(__DIR__ . '/inertiajs-stubs/resources/views/app.blade.php', resource_path('views/app.blade.php'));
6259
}
6360

6461
protected static function updateGitignore()
6562
{
6663
file_put_contents(
6764
base_path('.gitignore'),
68-
file_get_contents(__DIR__.'/inertiajs-stubs/gitignore'),
65+
file_get_contents(__DIR__ . '/inertiajs-stubs/gitignore'),
6966
FILE_APPEND
7067
);
7168
}
7269

7370
protected static function scaffoldComponents()
7471
{
75-
tap(new Filesystem, function ($fs) {
72+
tap(new Filesystem, function (Filesystem $fs) {
7673
$fs->deleteDirectory(resource_path('js/components'));
7774

78-
$fs->copyDirectory(__DIR__.'/inertiajs-stubs/resources/js/Shared', resource_path('js/Shared'));
75+
$fs->copyDirectory(__DIR__ . '/inertiajs-stubs/resources/js/Shared', resource_path('js/Shared'));
7976

80-
$fs->copyDirectory(__DIR__.'/inertiajs-stubs/resources/js/Pages', resource_path('js/Pages'));
77+
$fs->copyDirectory(__DIR__ . '/inertiajs-stubs/resources/js/Pages', resource_path('js/Pages'));
8178
});
8279
}
8380

8481
protected static function scaffoldRoutes()
8582
{
86-
copy(__DIR__.'/inertiajs-stubs/routes/web.php', base_path('routes/web.php'));
83+
copy(__DIR__ . '/inertiajs-stubs/routes/web.php', base_path('routes/web.php'));
8784
}
8885

8986
protected static function updateComposer($dev = true)
9087
{
91-
if (! file_exists(base_path('composer.json'))) {
88+
if (!file_exists(base_path('composer.json'))) {
9289
return;
9390
}
9491

@@ -97,22 +94,21 @@ protected static function updateComposer($dev = true)
9794
$packages = json_decode(file_get_contents(base_path('composer.json')), true);
9895

9996
$packages[$configurationKey] = static::updateComposerArray(
100-
array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : [],
101-
$configurationKey
97+
array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : []
10298
);
10399

104100
ksort($packages[$configurationKey]);
105101

106102
file_put_contents(
107103
base_path('composer.json'),
108-
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
104+
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL
109105
);
110106
}
111107

112108
public static function publishInertiaServiceProvider()
113109
{
114110
copy(
115-
__DIR__.'/inertiajs-stubs/providers/InertiaJsServiceProvider.stub',
111+
__DIR__ . '/inertiajs-stubs/providers/InertiaJsServiceProvider.stub',
116112
app_path('Providers/InertiaJsServiceProvider.php')
117113
);
118114
}
@@ -123,7 +119,7 @@ public static function registerInertiaServiceProvider()
123119

124120
$appConfig = file_get_contents(config_path('app.php'));
125121

126-
if (Str::contains($appConfig, $namespace.'\\Providers\\InertiaJsServiceProvider::class')) {
122+
if (Str::contains($appConfig, $namespace . '\\Providers\\InertiaJsServiceProvider::class')) {
127123
return;
128124
}
129125

@@ -136,8 +132,8 @@ public static function registerInertiaServiceProvider()
136132
$eol = array_keys($lineEndingCount, max($lineEndingCount))[0];
137133

138134
file_put_contents(config_path('app.php'), str_replace(
139-
"{$namespace}\\Providers\\RouteServiceProvider::class,".$eol,
140-
"{$namespace}\\Providers\\RouteServiceProvider::class,".$eol." {$namespace}\Providers\InertiaJsServiceProvider::class,".$eol,
135+
"{$namespace}\\Providers\\RouteServiceProvider::class," . $eol,
136+
"{$namespace}\\Providers\\RouteServiceProvider::class," . $eol . " {$namespace}\Providers\InertiaJsServiceProvider::class," . $eol,
141137
$appConfig
142138
));
143139

src/InertiaJsPresetServiceProvider.php

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

33
namespace LaravelFrontendPresets\InertiaJsPreset;
44

5-
use Illuminate\Foundation\Console\PresetCommand;
65
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Ui\UiCommand;
77

88
class InertiaJsPresetServiceProvider extends ServiceProvider
99
{
1010
public function boot()
1111
{
12-
PresetCommand::macro('inertiajs', function ($command) {
12+
UiCommand::macro('inertiajs', function (UiCommand $command) {
1313
InertiaJsPreset::install();
1414

1515
$command->info('Inertia.js scaffolding installed successfully.');

0 commit comments

Comments
 (0)