Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/DiffRecipeVersionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$packages = [];
$requires = [];

while (false !== $package = fgets(STDIN)) {
while (false !== $package = fgets(\STDIN)) {
$package = substr($package, 0, -1);

$versions = scandir($package, SCANDIR_SORT_NONE);
$versions = scandir($package, \SCANDIR_SORT_NONE);
usort($versions, 'version_compare');

if (!$versions = array_slice($versions, 2)) {
if (!$versions = \array_slice($versions, 2)) {
continue;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($versions as $version) {
$diff = shell_exec(sprintf('LC_ALL=C git diff --color=never --no-index %s/%s %1$s/%s', $package, $previousVersion, $version));

$output->writeln("<details>");
$output->writeln('<details>');
$output->writeln(sprintf("<summary>%s <em>vs</em> %s</summary>\n", $previousVersion, $version));
$output->writeln("```diff\n$diff```");
$output->writeln("\n</details>\n");
Expand Down
31 changes: 21 additions & 10 deletions src/GenerateFlexEndpointCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpClient\HttpClient;

#[AsCommand(name: 'generate:flex-endpoint', description: 'Generates the json files required by Flex')]
class GenerateFlexEndpointCommand extends Command
Expand Down Expand Up @@ -56,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// stdin usually generated by `git ls-tree HEAD */*/*`

while (false !== $line = fgets(STDIN)) {
while (false !== $line = fgets(\STDIN)) {
[$tree, $package] = explode("\t", trim($line));
[,, $tree] = explode(' ', $tree);

Expand Down Expand Up @@ -98,8 +97,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'repository' => sprintf('github.com/%s', $repository),
'origin_template' => sprintf('{package}:{version}@github.com/%s:%s', $repository, $sourceBranch),
'recipe_template' => sprintf('https://raw.githubusercontent.com/%s/%s/{package_dotted}.{version}.json', $repository, $flexBranch),
'archived_recipes_template' => sprintf('https://raw.githubusercontent.com/%s/%s/archived/{package_dotted}/{ref}.json', $repository, $flexBranch),
],
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n");
], \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)."\n");

return 0;
}
Expand Down Expand Up @@ -138,15 +138,26 @@ private function generatePackageJson(string $package, string $version, array $ma

ksort($files, \SORT_NATURAL);

file_put_contents(sprintf('%s/%s.%s.json', $outputDir, str_replace('/', '.', $package), $version), json_encode([
'manifests' => [
$package => [
'manifest' => $manifest,
'files' => $files,
'ref' => $tree,
$contents = json_encode(
[
'manifests' => [
$package => [
'manifest' => $manifest,
'files' => $files,
'ref' => $tree,
],
],
],
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n");
\JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES
)."\n";
file_put_contents(sprintf('%s/%s.%s.json', $outputDir, str_replace('/', '.', $package), $version), $contents);

// save another version for the archives
$archivedPath = sprintf('%s/archived/%s.%s/%s.json', $outputDir, str_replace('/', '.', $package), $version, $tree);
if (!file_exists(\dirname($archivedPath))) {
mkdir(\dirname($archivedPath), 0777, true);
}
file_put_contents($archivedPath, $contents);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LintYamlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$exit = 0;

while (false !== $file = fgets(STDIN)) {
while (false !== $file = fgets(\STDIN)) {
$file = substr($file, 0, -1);
$this->validate($file, $output, $exit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ListUnpatchedPackagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$client = HttpClient::create();
$diff = $client->request('GET', $data['pull_request']['diff_url'], ['auth_bearer' => $input->getArgument('github_token')])->getContent();

preg_match_all('{^diff --git a/(([^/]++/[^/]++)/.*) b/\1$}m', $diff, $matches, PREG_PATTERN_ORDER);
preg_match_all('{^diff --git a/(([^/]++/[^/]++)/.*) b/\1$}m', $diff, $matches, \PREG_PATTERN_ORDER);

$patchedPackages = array_flip($matches[2]);

Expand Down