Skip to content

Commit

Permalink
upgrade artifact builds presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Aug 4, 2024
1 parent 13c0f9f commit c741243
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Composer/ManifestOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getFormatDisplay(): string
return match ($this->getFormat()) {
ManifestFormat::auto => 'AUTO detection mode',
ManifestFormat::plain, ManifestFormat::ansi, ManifestFormat::console => 'TEXT',
ManifestFormat::sbomXml, ManifestFormat::sbomJson => 'SBom ' . $this->getSbomSpec(),
ManifestFormat::sbomXml, ManifestFormat::sbomJson => 'SBOM ' . $this->getSbomSpec(),
default => $this->getFormat(true),
};
}
Expand Down
36 changes: 26 additions & 10 deletions src/Console/Command/ManifestStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var DebugFormatterHelper $debugFormatter */
$debugFormatter = $this->getHelper('debug_formatter');

$templateFile = $io->getTypedOption(ManifestOptions::TEMPLATE_OPTION)->asNullableString();

$pid = uniqid();

if ($io->isVeryVerbose()) {
$templatePath = $templateFile ? : dirname(__DIR__, 3) . '/resources/default_stub.template';
$io->write(
$debugFormatter->start($pid, 'Generating stub', 'STARTED')
$debugFormatter->start($pid, 'Generating stub ' . sprintf('from template "%s"', $templatePath), 'STARTED')
);
}

Expand All @@ -103,19 +106,29 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$manifestHelper = $this->getHelper(ManifestHelper::NAME);

$config = $boxHelper->getBoxConfiguration(
$io->isVerbose() ? $io : $io->withOutput(new NullOutput()),
$io->withOutput(new NullOutput()),
true,
$io->getTypedOption(BoxHelper::NO_CONFIG_OPTION)->asBoolean()
);

$configPath = $config->getConfigurationFile();

if ($io->isVeryVerbose()) {
$message = $configPath
? sprintf('Using the configuration file "<info>%s</info>"', $configPath)
: 'Ignoring any configuration file'
;
$io->writeln(
$debugFormatter->progress($pid, $message, false, 'STARTED')
);
}

$stubGenerator = $manifestHelper->getStubGenerator(
$io->getTypedOption(ManifestOptions::TEMPLATE_OPTION)->asNullableString(),
$templateFile,
$io->getTypedOption(ManifestOptions::RESOURCE_OPTION)->asNonEmptyStringList(),
$config->getFileMapper()->getMap()
);

$configPath = $config->getConfigurationFile();

if ($configPath) {
/** @var null|non-empty-string $shebang */
$shebang = $config->getShebang();
Expand Down Expand Up @@ -143,25 +156,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (empty($outputFile)) {
$output->writeln($stub);
$message = 'Writing stub code to standard output';
$message = 'Writing stub PHP code to standard output';
} else {
// @phpstan-ignore argument.type
$stream = new StreamOutput(fopen($outputFile, 'w'));
$stream->write($stub);
fclose($stream->getStream());

$message = sprintf('Writing stub to file "<comment>%s</comment>"', realpath($outputFile));
$message = sprintf('Writing stub PHP code to file "<comment>%s</comment>"', realpath($outputFile));
}

if ($io->isVeryVerbose()) {
$io->write(
$debugFormatter->stop($pid, $message, true, 'RESPONSE')
);
$io->write(
$debugFormatter->stop($pid, 'Process elapsed time ' . Helper::formatTime(microtime(true) - $startTime), true, 'FINISHED')
$debugFormatter->stop(
$pid,
'Process elapsed time ' . Helper::formatTime(microtime(true) - $startTime),
true,
'FINISHED'
)
);
} elseif ($io->isVerbose()) {
$io->comment($message);
}

return Command::SUCCESS;
Expand Down

0 comments on commit c741243

Please sign in to comment.