4
4
5
5
use Illuminate \Container \Container ;
6
6
use Illuminate \Filesystem \Filesystem ;
7
- use Illuminate \Foundation \Console \Presets \Preset ;
8
- use Illuminate \Support \Arr ;
9
- use Illuminate \Support \Facades \Artisan ;
10
7
use Illuminate \Support \Str ;
11
- use Symfony \ Component \ Process \ Process ;
8
+ use Laravel \ Ui \ Presets \ Preset ;
12
9
13
10
class InertiaJsPreset extends Preset
14
11
{
@@ -40,55 +37,55 @@ protected static function updatePackageArray(array $packages)
40
37
protected static function updateComposerArray (array $ packages )
41
38
{
42
39
return array_merge ([
43
- 'inertiajs/inertia-laravel ' => '^0.1 ' ,
40
+ 'inertiajs/inertia-laravel ' => '^0.2 ' ,
44
41
], $ packages );
45
42
}
46
43
47
44
protected static function updateBootstrapping ()
48
45
{
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 ' ));
50
47
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 ' ));
52
49
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 ' ));
55
52
}
56
53
57
54
protected static function updateWelcomePage ()
58
55
{
59
56
(new Filesystem )->delete (resource_path ('views/welcome.blade.php ' ));
60
57
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 ' ));
62
59
}
63
60
64
61
protected static function updateGitignore ()
65
62
{
66
63
file_put_contents (
67
64
base_path ('.gitignore ' ),
68
- file_get_contents (__DIR__ . '/inertiajs-stubs/gitignore ' ),
65
+ file_get_contents (__DIR__ . '/inertiajs-stubs/gitignore ' ),
69
66
FILE_APPEND
70
67
);
71
68
}
72
69
73
70
protected static function scaffoldComponents ()
74
71
{
75
- tap (new Filesystem , function ($ fs ) {
72
+ tap (new Filesystem , function (Filesystem $ fs ) {
76
73
$ fs ->deleteDirectory (resource_path ('js/components ' ));
77
74
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 ' ));
79
76
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 ' ));
81
78
});
82
79
}
83
80
84
81
protected static function scaffoldRoutes ()
85
82
{
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 ' ));
87
84
}
88
85
89
86
protected static function updateComposer ($ dev = true )
90
87
{
91
- if (! file_exists (base_path ('composer.json ' ))) {
88
+ if (!file_exists (base_path ('composer.json ' ))) {
92
89
return ;
93
90
}
94
91
@@ -97,22 +94,21 @@ protected static function updateComposer($dev = true)
97
94
$ packages = json_decode (file_get_contents (base_path ('composer.json ' )), true );
98
95
99
96
$ packages [$ configurationKey ] = static ::updateComposerArray (
100
- array_key_exists ($ configurationKey , $ packages ) ? $ packages [$ configurationKey ] : [],
101
- $ configurationKey
97
+ array_key_exists ($ configurationKey , $ packages ) ? $ packages [$ configurationKey ] : []
102
98
);
103
99
104
100
ksort ($ packages [$ configurationKey ]);
105
101
106
102
file_put_contents (
107
103
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
109
105
);
110
106
}
111
107
112
108
public static function publishInertiaServiceProvider ()
113
109
{
114
110
copy (
115
- __DIR__ . '/inertiajs-stubs/providers/InertiaJsServiceProvider.stub ' ,
111
+ __DIR__ . '/inertiajs-stubs/providers/InertiaJsServiceProvider.stub ' ,
116
112
app_path ('Providers/InertiaJsServiceProvider.php ' )
117
113
);
118
114
}
@@ -123,7 +119,7 @@ public static function registerInertiaServiceProvider()
123
119
124
120
$ appConfig = file_get_contents (config_path ('app.php ' ));
125
121
126
- if (Str::contains ($ appConfig , $ namespace. '\\Providers \\InertiaJsServiceProvider::class ' )) {
122
+ if (Str::contains ($ appConfig , $ namespace . '\\Providers \\InertiaJsServiceProvider::class ' )) {
127
123
return ;
128
124
}
129
125
@@ -136,8 +132,8 @@ public static function registerInertiaServiceProvider()
136
132
$ eol = array_keys ($ lineEndingCount , max ($ lineEndingCount ))[0 ];
137
133
138
134
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 ,
141
137
$ appConfig
142
138
));
143
139
0 commit comments