Skip to content

Commit

Permalink
Fix phar build
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Dec 10, 2021
1 parent eb61c15 commit 7659bf1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -31,7 +31,7 @@
"justinrainbow/json-schema": "^5.2.11",
"psr/log": "^1.0 || ^2.0",
"seld/jsonlint": "^1.4",
"seld/phar-utils": "^1.0",
"seld/phar-utils": "^1.2",
"symfony/console": "^5.4.1 || ^6.0",
"symfony/filesystem": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 11 additions & 17 deletions src/Composer/Compiler.php
Expand Up @@ -50,25 +50,13 @@ public function compile($pharFile = 'composer.phar')
unlink($pharFile);
}

// TODO in v2.3 always call with an array
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
$process = new Process(array('git', 'log', '--pretty="%H"', '-n1', 'HEAD'), __DIR__);
} else {
// @phpstan-ignore-next-line
$process = new Process('git log --pretty="%H" -n1 HEAD', __DIR__);
}
$process = new Process(array('git', 'log', '--pretty=%H', '-n1', 'HEAD'), __DIR__);
if ($process->run() != 0) {
throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.');
}
$this->version = trim($process->getOutput());

// TODO in v2.3 always call with an array
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
$process = new Process(array('git', 'log', '-n1', '--pretty=%ci', 'HEAD'), __DIR__);
} else {
// @phpstan-ignore-next-line
$process = new Process('git log -n1 --pretty=%ci HEAD', __DIR__);
}
$process = new Process(array('git', 'log', '-n1', '--pretty=%ci', 'HEAD'), __DIR__);
if ($process->run() != 0) {
throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.');
}
Expand Down Expand Up @@ -137,8 +125,8 @@ public function compile($pharFile = 'composer.phar')
$finder->files()
->ignoreVCS(true)
->notPath('/\/(composer\.(json|lock)|[A-Z]+\.md|\.gitignore|appveyor.yml|phpunit\.xml\.dist|phpstan\.neon\.dist|phpstan-config\.neon)$/')
->notPath('/bin\/(jsonlint|validate-json|simple-phpunit)(\.bat)?$/')
->notPath('symfony/debug/Resources/ext/')
->notPath('/bin\/(jsonlint|validate-json|simple-phpunit|phpstan|phpstan\.phar)(\.bat)?$/')
->notPath('symfony/console/Resources/completion.bash')
->notPath('justinrainbow/json-schema/demo/')
->notPath('justinrainbow/json-schema/dist/')
->notPath('composer/installed.json')
Expand Down Expand Up @@ -205,7 +193,13 @@ public function compile($pharFile = 'composer.phar')
$util->updateTimestamps($this->versionDate);
$util->save($pharFile, \Phar::SHA512);

Linter::lint($pharFile);
Linter::lint($pharFile, [
'vendor/symfony/console/Attribute/AsCommand.php',
'vendor/symfony/polyfill-intl-grapheme/bootstrap80.php',
'vendor/symfony/polyfill-intl-normalizer/bootstrap80.php',
'vendor/symfony/polyfill-mbstring/bootstrap80.php',
'vendor/symfony/service-contracts/Attribute/SubscribedService.php',
]);
}

/**
Expand Down

0 comments on commit 7659bf1

Please sign in to comment.