sweetchuck / robo-composer
Robo task wrapper for Composer
Installs: 98 370
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 3
Type:robo-tasks
Requires
- php: >=7.2
- ext-json: *
- ext-pcre: *
- consolidation/robo: ^2.0
- sweetchuck/utils: ^0.1.2
Requires (Dev)
- codeception/codeception: ^4.0
- codeception/module-asserts: ^1.1
- mikey179/vfsstream: ^1.6
- squizlabs/php_codesniffer: ^3.5
- sweetchuck/codeception-module-robo-task-runner: ^0.7
- sweetchuck/git-hooks: ^0.0
- sweetchuck/lint-report: ^0.0
- sweetchuck/robo-git: ^0.2
- sweetchuck/robo-phpcs: ^0.1
- symfony/error-handler: ^5.0
- symfony/yaml: ^4.0
- webmozart/path-util: ^2.3
README
@todo
Install
Run composer require --dev sweetchuck/robo-composer
Task - taskComposerLockDiffer
<?php declare(strict_types = 1); class RoboFileExample extends \Robo\Tasks { use \Sweetchuck\Robo\Composer\ComposerTaskLoader; /** * @hook validate @validateArgumentFileName */ public function validateArgumentFileName(\Consolidation\AnnotatedCommand\CommandData $commandData) { $argNames = $commandData->annotationData()->getList(__FUNCTION__); $input = $commandData->input(); foreach ($argNames as $argName) { assert($input->hasArgument($argName), 'invalid argument name'); $input->setArgument( $argName, $this->processFileName($input->getArgument($argName)), ); } } /** * @command composer:lock-diff * * @validateArgumentFileName fileA,fileB */ public function composerLockDiff(string $fileA, string $fileB) { $a = json_decode(file_get_contents($fileA), true); $b = json_decode(file_get_contents($fileB), true); return $this ->collectionBuilder() ->addTask( $this ->taskComposerLockDiffer() ->setLockA($a) ->setLockB($b) ) ->addCode(function (\Robo\State\Data $data): int { $this ->output() ->writeln(\Symfony\Component\Yaml\Yaml::dump($data['composer.lockDiff'])); return 0; }); } protected function processFileName(string $fileName): string { return preg_replace('@^/proc/self/fd/(\d+)$@', 'php://fd/$1', $fileName); } }
Run: vendor/bin/robo composer:lock-diff <(git show 'HEAD^:composer.lock') ./composer.lock
Example output:
symfony/filesystem: name: symfony/filesystem version_old: v4.4.5 version_new: v4.4.18 required_as: null symfony/finder: name: symfony/finder version_old: v4.4.5 version_new: v5.2.1 required_as: null
Task - taskComposerPackagePaths
<?php declare(strict_types = 1); class RoboFileExample extends \Robo\Tasks { use \Sweetchuck\Robo\Composer\ComposerTaskLoader; /** * @command composer:package-paths */ public function composerPackagePaths() { return $this ->collectionBuilder() ->addTask($this->taskComposerPackagePaths()) ->addCode(function (\Robo\State\Data $data): int { $output = $this->output(); foreach ($data['composer.packagePaths'] as $name => $path) { $output->writeln("$name => $path"); } return 0; }); } }
Run: vendor/bin/robo composer:package-paths
Example output:
symfony/filesystem => /my_project_01/vendor/symfony/filesystem symfony/finder => /my_project_01/vendor/symfony/finder