1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bmatovu\MultiAuth\Console\Traits; |
4
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
6
|
|
|
use Illuminate\Support\Str; |
7
|
|
|
use Symfony\Component\Finder\Finder; |
8
|
|
|
|
9
|
|
|
trait InstallsInertiaVueStack |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Install the InertiaVue Breeze stack. |
13
|
|
|
* |
14
|
|
|
* @return null|int |
15
|
|
|
*/ |
16
|
1 |
|
protected function installInertiaVueStack() |
17
|
|
|
{ |
18
|
1 |
|
$fs = new Filesystem; |
19
|
1 |
|
$guard = $this->argument('guard'); |
|
|
|
|
20
|
1 |
|
$pluralClass = Str::plural(Str::studly($guard)); |
21
|
1 |
|
$singularSlug = Str::singular(Str::slug($guard)); |
|
|
|
|
22
|
1 |
|
$singularClass = Str::singular(Str::studly($guard)); |
23
|
|
|
|
24
|
1 |
|
if (!$this->option('dark')) { |
|
|
|
|
25
|
1 |
|
$finder = (new Finder) |
26
|
1 |
|
->in(__DIR__ . "/../../../.stubs/vue/resources/js") |
27
|
1 |
|
->name('*.vue') |
28
|
1 |
|
->notName('Welcome.vue'); |
29
|
|
|
|
30
|
1 |
|
$this->removeDarkClasses($finder); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
// Module... |
34
|
1 |
|
$fs->ensureDirectoryExists(app_path("Modules/{$pluralClass}")); |
35
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/src', app_path("Modules/{$pluralClass}")); |
36
|
|
|
|
37
|
|
|
// Views... |
38
|
1 |
|
$fs->ensureDirectoryExists(resource_path("js/{$pluralClass}")); |
39
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/js', resource_path("js/{$pluralClass}")); |
40
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/views', resource_path("views")); |
41
|
|
|
|
42
|
|
|
// Tests... |
43
|
1 |
|
$fs->ensureDirectoryExists(base_path("tests/Feature/{$pluralClass}")); |
44
|
1 |
|
if ($this->option('pest')) { |
45
|
|
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/pest-tests/Feature', base_path("tests/Feature/{$pluralClass}")); |
46
|
|
|
} else { |
47
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/tests/Feature', base_path("tests/Feature/{$pluralClass}")); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// Conclude... |
51
|
1 |
|
$this->info("{$singularClass} guard successfully setup."); |
|
|
|
|
52
|
|
|
|
53
|
1 |
|
$serviceProvider = "App\\Modules\\{$pluralClass}\\{$singularClass}ServiceProvider::class"; |
54
|
|
|
|
55
|
1 |
|
$this->info("\nRegister `{$serviceProvider}` in `config/app.php`"); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|