1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scaffolder\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Illuminate\Support\Facades\File; |
7
|
|
|
|
8
|
|
|
use stdClass ; |
9
|
|
|
|
10
|
|
|
// Support classes |
11
|
|
|
use Scaffolder\Support\Directory; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class BuildCommand extends Command |
15
|
|
|
{ |
16
|
|
|
protected $signature = 'scaffolder:build {app=webapp}'; |
17
|
|
|
|
18
|
|
|
protected $description = 'Build the generated code to public folder'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Execute the Command. |
22
|
|
|
*/ |
23
|
|
|
public function handle() |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
switch ($this->argument('app')) { |
28
|
|
|
case 'webapp': |
|
|
|
|
29
|
|
|
|
30
|
|
|
$this->cleanPublicFolder(); |
31
|
|
|
|
32
|
|
|
$gulpCommand = sprintf('gulp build --cwd "%s/codificar/scaffolder-theme-material/"', base_path('vendor')); |
33
|
|
|
|
34
|
|
|
//$this->info('- gulpCommand: '. $gulpCommand); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$handle = popen($gulpCommand, 'r'); |
37
|
|
|
|
38
|
|
|
while(!feof($handle)) |
39
|
|
|
{ |
40
|
|
|
// send the current file part to the browser |
41
|
|
|
$this->info(fread($handle, 1024)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
fclose($handle); |
45
|
|
|
|
46
|
|
|
// php artisan serve |
47
|
|
|
$this->call('serve'); |
48
|
|
|
|
49
|
|
|
break; |
50
|
|
|
|
51
|
|
|
default: |
52
|
|
|
$this->info('Invalid arguments'); |
53
|
|
|
break; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
private function cleanPublicFolder(){ |
59
|
|
|
$this->info('Cleaning public directory'); |
60
|
|
|
|
61
|
|
|
File::deleteDirectory(sprintf("%s/app", base_path('public'))); |
62
|
|
|
File::deleteDirectory(sprintf("%s/assets", base_path('public'))); |
63
|
|
|
File::deleteDirectory(sprintf("%s/fonts", base_path('public'))); |
64
|
|
|
File::deleteDirectory(sprintf("%s/maps", base_path('public'))); |
65
|
|
|
File::deleteDirectory(sprintf("%s/scripts", base_path('public'))); |
66
|
|
|
File::deleteDirectory(sprintf("%s/styles", base_path('public'))); |
67
|
|
|
|
68
|
|
|
File::delete(sprintf("%s/index.html", base_path('public'))); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
} |
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.