99use Illuminate \Foundation \PackageManifest ;
1010use Illuminate \Support \Str ;
1111use InvalidArgumentException ;
12+ use Orchestra \Testbench \Foundation \Console \Actions \GeneratesFile ;
1213use Symfony \Component \Console \Attribute \AsCommand ;
1314
1415use function Illuminate \Filesystem \join_paths ;
@@ -41,18 +42,19 @@ public function handle(Filesystem $filesystem, PackageManifest $manifest): int
4142 }
4243
4344 return match ($ action = $ this ->argument ('action ' )) {
44- 'setup ' => $ this ->setupNovaWorkbench ($ filesystem , $ manifest ),
45+ 'setup ' => $ this ->installNovaWorkbench ($ filesystem , $ manifest ),
4546 'install ' => $ this ->installNpmDependencies ($ filesystem , $ manifest ),
4647 'enable-vue-devtool ' => $ this ->enablesVueDevTool ($ filesystem , $ manifest ),
4748 'disable-vue-devtool ' => $ this ->disablesVueDevTool ($ filesystem , $ manifest ),
49+ 'tsconfig ' => $ this ->installTypeScriptConfiguration ($ filesystem , $ manifest ),
4850 default => throw new InvalidArgumentException (sprintf ('Unable to handle [%s] action ' , $ action )),
4951 };
5052 }
5153
5254 /**
5355 * Setup Nova Workbench.
5456 */
55- protected function setupNovaWorkbench (Filesystem $ filesystem , PackageManifest $ manifest ): int
57+ protected function installNovaWorkbench (Filesystem $ filesystem , PackageManifest $ manifest ): int
5658 {
5759 $ this ->executeCommand ([
5860 'npm set progress=false ' ,
@@ -64,6 +66,24 @@ protected function setupNovaWorkbench(Filesystem $filesystem, PackageManifest $m
6466 ]);
6567 }
6668
69+ /**
70+ * Install `tsconfig.json` configuration.
71+ */
72+ protected function installTypeScriptConfiguration (Filesystem $ filesystem , PackageManifest $ manifest ): int
73+ {
74+ (new GeneratesFile (
75+ filesystem: $ filesystem ,
76+ components: $ this ->components ,
77+ force: false ,
78+ confirmation: true ,
79+ ))->handle (
80+ join_paths (__DIR__ , 'stubs ' , 'tsconfig.json ' ),
81+ package_path ('tsconfig.json ' )
82+ );
83+
84+ return self ::SUCCESS ;
85+ }
86+
6787 /**
6888 * Install NPM dependencies.
6989 */
@@ -101,8 +121,6 @@ protected function installNpmDependencies(Filesystem $filesystem, PackageManifes
101121 'npm install --dev ' .implode (' ' , $ dependencies ),
102122 ], package_path ());
103123
104- $ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'tsconfig.json ' ), package_path ('tsconfig.json ' ));
105-
106124 if (in_array ('tailwindcss ' , $ dependencies )) {
107125 $ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'postcss.config.js ' ), package_path ('postcss.config.js ' ));
108126 $ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'tailwind.config.js ' ), package_path ('tailwind.config.js ' ));
@@ -113,7 +131,7 @@ protected function installNpmDependencies(Filesystem $filesystem, PackageManifes
113131 ], package_path ('tailwind.config.js ' ));
114132 }
115133
116- return self :: SUCCESS ;
134+ return $ this -> installTypeScriptConfiguration ( $ filesystem , $ manifest ) ;
117135 }
118136
119137 /**
@@ -188,6 +206,7 @@ protected function promptForMissingArgumentsUsing(): array
188206 'install ' => 'Install NPM Dependencies ' ,
189207 'enable-vue-devtool ' => 'Enable Vue DevTool ' ,
190208 'disable-vue-devtool ' => 'Disable Vue DevTool ' ,
209+ 'tsconfig ' => 'Install `tsconfig.json` for Nova ' ,
191210 ]),
192211 default: 'owner '
193212 ),
0 commit comments