1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Vaimo Group. All rights reserved. |
4
|
|
|
* See LICENSE_VAIMO.txt for license details. |
5
|
|
|
*/ |
6
|
|
|
namespace Vaimo\ComposerChangelogs\Commands; |
7
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
use Vaimo\ComposerChangelogs\Resolvers; |
11
|
|
|
|
12
|
|
|
use Vaimo\ComposerChangelogs\Factories; |
13
|
|
|
|
14
|
|
|
class GenerateCommand extends \Composer\Command\BaseCommand |
15
|
|
|
{ |
16
|
|
|
protected function configure() |
17
|
|
|
{ |
18
|
|
|
$this->setName('changelog:generate'); |
19
|
|
|
|
20
|
|
|
$this->setDescription('Generates documentation output from changelog source'); |
21
|
|
|
|
22
|
|
|
$this->addArgument( |
23
|
|
|
'name', |
24
|
|
|
\Symfony\Component\Console\Input\InputArgument::OPTIONAL, |
25
|
|
|
'Targeted package name. Default: root package' |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
$this->addOption( |
29
|
|
|
'--from-source', |
30
|
|
|
null, |
31
|
|
|
\Symfony\Component\Console\Input\InputOption::VALUE_NONE, |
32
|
|
|
'Extract configuration from vendor package instead of using global installation data' |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$this->addOption( |
36
|
|
|
'--url', |
37
|
|
|
null, |
38
|
|
|
\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, |
39
|
|
|
'Repository URL to use for generating version-bound links for sources and comparisons' |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
44
|
|
|
{ |
45
|
|
|
$packageName = $input->getArgument('name'); |
46
|
|
|
|
47
|
|
|
$fromSource = $input->getOption('from-source'); |
48
|
|
|
$repositoryUrl = $input->getOption('url'); |
49
|
|
|
|
50
|
|
|
$composerRuntime = $this->getComposer(); |
51
|
|
|
|
52
|
|
|
$chLogRepoFactory = new Factories\ChangelogRepositoryFactory($composerRuntime, $output); |
|
|
|
|
53
|
|
|
$chLogRepo = $chLogRepoFactory->create($fromSource); |
54
|
|
|
|
55
|
|
|
$changelog = $chLogRepo->getByPackageName( |
56
|
|
|
$packageName, |
57
|
|
|
$output->getVerbosity() |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
if ($changelog === null) { |
61
|
|
|
return 1; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$confResolverFactory = new Factories\Changelog\ConfigResolverFactory($composerRuntime); |
65
|
|
|
|
66
|
|
|
$confResolver = $confResolverFactory->create($fromSource); |
67
|
|
|
|
68
|
|
|
$package = $changelog->getOwner(); |
69
|
|
|
|
70
|
|
|
$output->writeln( |
71
|
|
|
sprintf('Generating changelog output for <info>%s</info>', $package->getName()) |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$infoResolver = new Resolvers\PackageInfoResolver( |
75
|
|
|
$composerRuntime->getInstallationManager() |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$featureFlags = $confResolver->getFeatureFlags($package); |
79
|
|
|
|
80
|
|
|
$urlResolver = $this->createUrlResolver($repositoryUrl, $featureFlags); |
81
|
|
|
|
82
|
|
|
$docsGenerator = new \Vaimo\ComposerChangelogs\Generators\DocumentationGenerator( |
83
|
|
|
$confResolver, |
84
|
|
|
$infoResolver, |
85
|
|
|
$urlResolver |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
try { |
89
|
|
|
$docsGenerator->generate($package, $changelog->getReleases()); |
90
|
|
|
} catch (\Vaimo\ComposerChangelogs\Exceptions\GeneratorException $exception) { |
91
|
|
|
$output->writeln( |
92
|
|
|
sprintf('<error>%s</error>', $exception->getMessage()) |
93
|
|
|
); |
94
|
|
|
|
95
|
|
|
return 1; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
$output->writeln('<info>Done</info>'); |
99
|
|
|
|
100
|
|
|
return 0; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
private function createUrlResolver($repositoryUrl, array $featureFlags) |
104
|
|
|
{ |
105
|
|
|
if ($repositoryUrl !== null || !$featureFlags['links']) { |
106
|
|
|
return new Resolvers\Url\CustomSourceResolver($repositoryUrl); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$composerRuntime = $this->getComposer(); |
110
|
|
|
|
111
|
|
|
$infoResolver = new Resolvers\PackageInfoResolver( |
112
|
|
|
$composerRuntime->getInstallationManager() |
113
|
|
|
); |
114
|
|
|
|
115
|
|
|
return new Resolvers\Url\RemoteSourceResolver($infoResolver); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
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