@@ 7-58 (lines=52) @@ | ||
4 | ||
5 | use Illuminate\Filesystem\Filesystem; |
|
6 | ||
7 | class MakeComponent extends VueGeneratorsCommand |
|
8 | { |
|
9 | /** |
|
10 | * The name and signature of the console command. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $signature = 'vueg:component {name} {--empty} {--path=}'; |
|
15 | ||
16 | /** |
|
17 | * The console command description. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $description = 'Create a new Vue js component file.'; |
|
22 | ||
23 | /** |
|
24 | * Execute the console command. |
|
25 | */ |
|
26 | public function handle() |
|
27 | { |
|
28 | $filesystem = new Filesystem(); |
|
29 | ||
30 | $name = $this->argument('name').'.vue'; |
|
31 | ||
32 | $path = $this->createPath($filesystem, 'component'); |
|
33 | ||
34 | $fullPath = resource_path("{$path}/{$name}"); |
|
35 | ||
36 | $this->checkFileExists($filesystem, $fullPath, $name); |
|
37 | ||
38 | $stub = $this->getStub($filesystem); |
|
39 | ||
40 | $filesystem->put($fullPath, $stub); |
|
41 | ||
42 | $this->info("Component {$name} succesfully created."); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Get and return stub. |
|
47 | * |
|
48 | * @param Filesystem $filesystem |
|
49 | * |
|
50 | * @return string |
|
51 | */ |
|
52 | protected function getStub(Filesystem $filesystem) |
|
53 | { |
|
54 | $fileName = $this->option('empty') ? 'EmptyComponent' : 'Component'; |
|
55 | ||
56 | return $filesystem->get(__DIR__.'/../Stubs/'.$fileName.'.vue'); |
|
57 | } |
|
58 | } |
|
59 |
@@ 7-58 (lines=52) @@ | ||
4 | ||
5 | use Illuminate\Filesystem\Filesystem; |
|
6 | ||
7 | class MakeMixin extends VueGeneratorsCommand |
|
8 | { |
|
9 | /** |
|
10 | * The name and signature of the console command. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $signature = 'vueg:mixin {name} {--empty} {--path=}'; |
|
15 | ||
16 | /** |
|
17 | * The console command description. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $description = 'Create a new Vue js mixin file.'; |
|
22 | ||
23 | /** |
|
24 | * Execute the console command. |
|
25 | */ |
|
26 | public function handle() |
|
27 | { |
|
28 | $filesystem = new Filesystem(); |
|
29 | ||
30 | $name = $this->argument('name').'.js'; |
|
31 | ||
32 | $path = $this->createPath($filesystem, 'mixin'); |
|
33 | ||
34 | $fullPath = resource_path("{$path}/{$name}"); |
|
35 | ||
36 | $this->checkFileExists($filesystem, $fullPath, $name); |
|
37 | ||
38 | $stub = $this->getStub($filesystem); |
|
39 | ||
40 | $filesystem->put($fullPath, $stub); |
|
41 | ||
42 | $this->info("Mixin {$name} succesfully created."); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Get and return stub. |
|
47 | * |
|
48 | * @param Filesystem $filesystem |
|
49 | * |
|
50 | * @return string |
|
51 | */ |
|
52 | protected function getStub(Filesystem $filesystem) |
|
53 | { |
|
54 | $fileName = $this->option('empty') ? 'EmptyMixin' : 'Mixin'; |
|
55 | ||
56 | return $filesystem->get(__DIR__.'/../Stubs/'.$fileName.'.js'); |
|
57 | } |
|
58 | } |
|
59 |