-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstall.php
66 lines (54 loc) · 1.88 KB
/
Install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace YumemiInc\IntellijProfiles\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand('install')]
class Install extends Command
{
protected function configure(): void
{
$this
->addOption('use', 'u', InputOption::VALUE_NONE, 'Sets the installed profiles as project default.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
foreach ($this->definitions() as $source => $target) {
$source = __DIR__ . '/../../resources/' . $source;
$target = getcwd() . '/' . $target;
if (file_exists($target) && !$io->confirm("File '$target' already exists. Overwrite?", false)) {
continue;
}
file_put_contents($target, file_get_contents($source));
}
if ($input->getOption('use')) {
file_put_contents(
getcwd() . '/.idea/inspectionProfiles/profiles_settings.xml',
trim(
<<<'EOD'
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="yumemi-inc/php-intellij-profiles" />
<version value="1.0" />
</settings>
</component>
EOD,
),
);
}
$io->success('Installed IntelliJ profiles successfully!');
return 0;
}
private function definitions(): array
{
return [
'Profile.xml' => '.idea/inspectionProfiles/yumemi-inc.xml',
'Scheme.xml' => '.idea/codeStyles/Project.xml',
];
}
}