16
16
use function Laravel \Prompts \select ;
17
17
use function Orchestra \Testbench \default_skeleton_path ;
18
18
use function Orchestra \Testbench \package_path ;
19
+ use function Orchestra \Testbench \workbench_path ;
19
20
20
21
#[AsCommand(name: 'nova:devtool ' , description: 'Configure Laravel Nova DevTool ' )]
21
22
class DevToolCommand extends Command implements PromptsForMissingInput
@@ -40,13 +41,29 @@ public function handle(Filesystem $filesystem, PackageManifest $manifest): int
40
41
}
41
42
42
43
return match ($ action = $ this ->argument ('action ' )) {
44
+ 'setup ' => $ this ->setupNovaWorkbench ($ filesystem , $ manifest ),
43
45
'install ' => $ this ->installNpmDependencies ($ filesystem , $ manifest ),
44
46
'enable-vue-devtool ' => $ this ->enablesVueDevTool ($ filesystem , $ manifest ),
45
47
'disable-vue-devtool ' => $ this ->disablesVueDevTool ($ filesystem , $ manifest ),
46
48
default => throw new InvalidArgumentException (sprintf ('Unable to handle [%s] action ' , $ action )),
47
49
};
48
50
}
49
51
52
+ /**
53
+ * Setup Nova Workbench.
54
+ */
55
+ protected function setupNovaWorkbench (Filesystem $ filesystem , PackageManifest $ manifest ): int
56
+ {
57
+ $ this ->executeCommand ([
58
+ 'npm set progress=false ' ,
59
+ 'npm install --save-dev "vendor/laravel/nova-devtool" ' ,
60
+ ], package_path ());
61
+
62
+ return $ this ->call ('workbench:install ' , [
63
+ '--devtool ' => true ,
64
+ ]);
65
+ }
66
+
50
67
/**
51
68
* Install NPM dependencies.
52
69
*/
@@ -62,7 +79,14 @@ protected function installNpmDependencies(Filesystem $filesystem, PackageManifes
62
79
63
80
$ dependencies = multiselect (
64
81
label: 'Dependencies to install? ' ,
65
- options: ['axios ' , 'lodash ' , 'tailwindcss ' , 'vue ' ],
82
+ options: [
83
+ '@inertiajs/vue3 ' ,
84
+ 'axios ' ,
85
+ 'lodash ' ,
86
+ 'tailwindcss ' ,
87
+ 'vue ' ,
88
+ 'vuex ' ,
89
+ ],
66
90
default: [],
67
91
);
68
92
@@ -159,11 +183,12 @@ protected function promptForMissingArgumentsUsing(): array
159
183
return [
160
184
'action ' => fn () => select (
161
185
label: 'Which action to be executed? ' ,
162
- options: [
186
+ options: array_filter ([
187
+ 'setup ' => is_dir (workbench_path ()) ? null : 'Setup Nova Workbench ' ,
163
188
'install ' => 'Install NPM Dependencies ' ,
164
189
'enable-vue-devtool ' => 'Enable Vue DevTool ' ,
165
190
'disable-vue-devtool ' => 'Disable Vue DevTool ' ,
166
- ],
191
+ ]) ,
167
192
default: 'owner '
168
193
),
169
194
];
0 commit comments