|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Administration\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
6
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
use Symfony\Component\Finder\Finder; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
#[AsCommand( |
|
13
|
|
|
name: 'administration:generate-git-attributes', |
|
14
|
|
|
description: 'Generates the .gitattributes file for the administration.', |
|
15
|
|
|
)] |
|
16
|
|
|
#[Package('admin')] |
|
17
|
|
|
class GenerateAdministrationGitAttributes extends Command |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @internal |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct( |
|
23
|
|
|
private readonly string $projectDir |
|
24
|
|
|
) { |
|
25
|
|
|
parent::__construct(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function configure(): void |
|
32
|
|
|
{ |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
36
|
|
|
{ |
|
37
|
|
|
$output->writeln('Generating .gitattributes file for the administration...'); |
|
38
|
|
|
|
|
39
|
|
|
$attributeFile = $this->projectDir . '/src/Administration/.gitattributes'; |
|
40
|
|
|
$staticContent = <<<EOT |
|
41
|
|
|
# General ignore rules |
|
42
|
|
|
/Test export-ignore |
|
43
|
|
|
/Resources/ide-twig.json export-ignore |
|
44
|
|
|
/Resources/app/administration/build export-ignore |
|
45
|
|
|
/Resources/app/administration/test export-ignore |
|
46
|
|
|
/Resources/app/administration/src/meta export-ignore |
|
47
|
|
|
/Resources/app/administration/src/scripts/create-spec-file export-ignore |
|
48
|
|
|
|
|
49
|
|
|
# Ignore all spec files |
|
50
|
|
|
|
|
51
|
|
|
EOT; |
|
52
|
|
|
|
|
53
|
|
|
\file_put_contents($attributeFile, $staticContent); |
|
54
|
|
|
|
|
55
|
|
|
$finder = new Finder(); |
|
56
|
|
|
$files = $finder->in($this->projectDir . '/src/Administration/Resources/app/administration') |
|
57
|
|
|
->notPath('node_modules') |
|
58
|
|
|
->name('/.*\.spec\.(js|ts)/') |
|
59
|
|
|
->files() |
|
60
|
|
|
->getIterator(); |
|
61
|
|
|
|
|
62
|
|
|
$files = \iterator_to_array($files); |
|
63
|
|
|
\sort($files); |
|
64
|
|
|
|
|
65
|
|
|
$handler = \fopen($attributeFile, 'ab'); |
|
66
|
|
|
if (!$handler) { |
|
|
|
|
|
|
67
|
|
|
throw new \RuntimeException('Could not open file for writing: ' . $attributeFile); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
foreach ($files as $file) { |
|
71
|
|
|
fwrite($handler, '/Resources/app/administration/' . $file->getRelativePathname() . ' export-ignore' . \PHP_EOL); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
fclose($handler); |
|
75
|
|
|
|
|
76
|
|
|
$output->writeln('Done!'); |
|
77
|
|
|
|
|
78
|
|
|
return 0; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths