|
1
|
|
|
<?php namespace Arcanedev\Assets\Console; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Assets\Pipes; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class InitCommand |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanedev\Assets\Console |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class InitCommand extends Command |
|
12
|
|
|
{ |
|
13
|
|
|
/* ----------------------------------------------------------------- |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ----------------------------------------------------------------- |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* The name and signature of the console command. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $signature = 'assets:init |
|
24
|
|
|
{name=laravel : The assets name folder} |
|
25
|
|
|
{--W|workspace= : Select a predefined workspace}'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* The console command description. |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $description = 'Init the assets structure'; |
|
33
|
|
|
|
|
34
|
|
|
/* ----------------------------------------------------------------- |
|
35
|
|
|
| Main Methods |
|
36
|
|
|
| ----------------------------------------------------------------- |
|
37
|
|
|
*/ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Execute the console command. |
|
41
|
|
|
* |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function handle() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->info('[WARNING] This command will change/reset all your resources!'); |
|
47
|
|
|
|
|
48
|
|
|
if ( ! $this->confirm('Are you sure to continue?')) |
|
49
|
|
|
return; |
|
50
|
|
|
|
|
51
|
|
|
$this->pipeline() |
|
52
|
|
|
->send($this->getPassable()) |
|
53
|
|
|
->through([ |
|
54
|
|
|
Pipes\Init\EnsureRootDirectoryExists::class, |
|
55
|
|
|
Pipes\Init\MoveDefaultLaravelAssets::class, |
|
56
|
|
|
Pipes\Init\ExtractNpmDependencies::class, |
|
57
|
|
|
Pipes\Init\CopyYarnRcFile::class, |
|
58
|
|
|
Pipes\Init\CopyRootMixFile::class, |
|
59
|
|
|
Pipes\Init\CreateMixFile::class, |
|
60
|
|
|
Pipes\Init\CopyGitIgnoreFile::class, |
|
61
|
|
|
]) |
|
62
|
|
|
->then(function (array $passable) { |
|
|
|
|
|
|
63
|
|
|
$this->info('All finished! Please run `yarn install && yarn run dev` and you are all set to go!'); |
|
64
|
|
|
}); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/* ----------------------------------------------------------------- |
|
68
|
|
|
| Other Methods |
|
69
|
|
|
| ----------------------------------------------------------------- |
|
70
|
|
|
*/ |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get the passable for the pipeline. |
|
74
|
|
|
* |
|
75
|
|
|
* @return array |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function getPassable() |
|
78
|
|
|
{ |
|
79
|
|
|
return parent::getPassable() + [ |
|
80
|
|
|
'name' => $this->argument('name'), |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.