9
9
use Illuminate \Foundation \PackageManifest ;
10
10
use Illuminate \Support \Str ;
11
11
use InvalidArgumentException ;
12
+ use Orchestra \Testbench \Foundation \Console \Actions \GeneratesFile ;
12
13
use Symfony \Component \Console \Attribute \AsCommand ;
13
14
14
15
use function Illuminate \Filesystem \join_paths ;
@@ -41,18 +42,19 @@ public function handle(Filesystem $filesystem, PackageManifest $manifest): int
41
42
}
42
43
43
44
return match ($ action = $ this ->argument ('action ' )) {
44
- 'setup ' => $ this ->setupNovaWorkbench ($ filesystem , $ manifest ),
45
+ 'setup ' => $ this ->installNovaWorkbench ($ filesystem , $ manifest ),
45
46
'install ' => $ this ->installNpmDependencies ($ filesystem , $ manifest ),
46
47
'enable-vue-devtool ' => $ this ->enablesVueDevTool ($ filesystem , $ manifest ),
47
48
'disable-vue-devtool ' => $ this ->disablesVueDevTool ($ filesystem , $ manifest ),
49
+ 'tsconfig ' => $ this ->installTypeScriptConfiguration ($ filesystem , $ manifest ),
48
50
default => throw new InvalidArgumentException (sprintf ('Unable to handle [%s] action ' , $ action )),
49
51
};
50
52
}
51
53
52
54
/**
53
55
* Setup Nova Workbench.
54
56
*/
55
- protected function setupNovaWorkbench (Filesystem $ filesystem , PackageManifest $ manifest ): int
57
+ protected function installNovaWorkbench (Filesystem $ filesystem , PackageManifest $ manifest ): int
56
58
{
57
59
$ this ->executeCommand ([
58
60
'npm set progress=false ' ,
@@ -64,6 +66,24 @@ protected function setupNovaWorkbench(Filesystem $filesystem, PackageManifest $m
64
66
]);
65
67
}
66
68
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
+
67
87
/**
68
88
* Install NPM dependencies.
69
89
*/
@@ -101,8 +121,6 @@ protected function installNpmDependencies(Filesystem $filesystem, PackageManifes
101
121
'npm install --dev ' .implode (' ' , $ dependencies ),
102
122
], package_path ());
103
123
104
- $ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'tsconfig.json ' ), package_path ('tsconfig.json ' ));
105
-
106
124
if (in_array ('tailwindcss ' , $ dependencies )) {
107
125
$ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'postcss.config.js ' ), package_path ('postcss.config.js ' ));
108
126
$ filesystem ->copy (join_paths (__DIR__ , 'stubs ' , 'tailwind.config.js ' ), package_path ('tailwind.config.js ' ));
@@ -113,7 +131,7 @@ protected function installNpmDependencies(Filesystem $filesystem, PackageManifes
113
131
], package_path ('tailwind.config.js ' ));
114
132
}
115
133
116
- return self :: SUCCESS ;
134
+ return $ this -> installTypeScriptConfiguration ( $ filesystem , $ manifest ) ;
117
135
}
118
136
119
137
/**
@@ -188,6 +206,7 @@ protected function promptForMissingArgumentsUsing(): array
188
206
'install ' => 'Install NPM Dependencies ' ,
189
207
'enable-vue-devtool ' => 'Enable Vue DevTool ' ,
190
208
'disable-vue-devtool ' => 'Disable Vue DevTool ' ,
209
+ 'tsconfig ' => 'Install `tsconfig.json` for Nova ' ,
191
210
]),
192
211
default: 'owner '
193
212
),
0 commit comments