Passed
Pull Request — 2.x (#936)
by Harings
15:33
created

SetupDevTools   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 18
c 1
b 0
f 1
dl 0
loc 45
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 24 2
1
<?php
2
3
namespace A17\Twill\Commands;
4
5
class SetupDevTools extends Command
6
{
7
    /**
8
     * The name and signature of the console command.
9
     *
10
     * @var string
11
     */
12
    protected $signature = 'twill:setup-devtools';
13
14
    /**
15
     * The console command description.
16
     *
17
     * @var string
18
     */
19
    protected $description = 'Sets up the twill dev tools for standards';
20
21
    /*
22
     * Executes the console command.
23
     *
24
     * @return mixed
25
     */
26
    public function handle()
27
    {
28
        if (! $this->confirm('This command is only intended for a development environment and will change and create files in your project, do you want to continue?')) {
29
            $this->error('cancelled');
30
31
            return;
32
        }
33
        $basePath = base_path();
34
        $this->line('Installing php cs fixer');
35
        exec("cd $basePath && composer require friendsofphp/php-cs-fixer");
36
37
        $source = __DIR__ . '/../../.php-cs-fixer.dist.php';
38
        exec("cp $source $basePath/.php-cs-fixer.dist.php");
39
40
        $this->line('Installing prettier and eslint');
41
        exec(
42
            "cd $basePath && npm i --save-dev prettier eslint eslint-config-prettier"
43
        );
44
45
        $source = __DIR__ . '/../../.prettierrc.yml';
46
        exec("cp $source $basePath/.prettierrc.yml");
47
48
        $source = __DIR__ . '/../../.eslintrc.js';
49
        exec("cp $source $basePath/.eslintrc.js");
50
    }
51
}
52