@@ -11,7 +11,9 @@ class InstallCommand extends Command
11
11
*
12
12
* @var string
13
13
*/
14
- protected $ signature = 'sail:install {--with= : The services that should be included in the installation} ' ;
14
+ protected $ signature = 'sail:install
15
+ {--with= : The services that should be included in the installation}
16
+ {--devcontainer : Create a .devcontainer configuration directory} ' ;
15
17
16
18
/**
17
19
* The console command description.
@@ -38,6 +40,10 @@ public function handle()
38
40
$ this ->buildDockerCompose ($ services );
39
41
$ this ->replaceEnvVariables ($ services );
40
42
43
+ if ($ this ->option ('devcontainer ' )) {
44
+ $ this ->installDevContainer ();
45
+ }
46
+
41
47
$ this ->info ('Sail scaffolding installed successfully. ' );
42
48
}
43
49
@@ -136,4 +142,28 @@ protected function replaceEnvVariables(array $services)
136
142
137
143
file_put_contents ($ this ->laravel ->basePath ('.env ' ), $ environment );
138
144
}
145
+
146
+ /**
147
+ * Install the devcontainer.json configuration file.
148
+ *
149
+ * @return void
150
+ */
151
+ protected function installDevContainer ()
152
+ {
153
+ if (! is_dir ($ this ->laravel ->basePath ('.devcontainer ' ))) {
154
+ mkdir ($ this ->laravel ->basePath ('.devcontainer ' ), 0755 , true );
155
+ }
156
+
157
+ file_put_contents (
158
+ $ this ->laravel ->basePath ('.devcontainer/devcontainer.json ' ),
159
+ file_get_contents (__DIR__ .'/../../stubs/devcontainer.stub ' )
160
+ );
161
+
162
+ $ environment = file_get_contents ($ this ->laravel ->basePath ('.env ' ));
163
+
164
+ $ environment .= "\nWWWGROUP=1000 " ;
165
+ $ environment .= "\nWWWUSER=1000 \n" ;
166
+
167
+ file_put_contents ($ this ->laravel ->basePath ('.env ' ), $ environment );
168
+ }
139
169
}
0 commit comments