From 79f09365b65ccde9c637d7ffe55c47f34b2b7602 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Tue, 24 Oct 2023 14:51:31 -0400 Subject: [PATCH 1/2] Copy Command --- .../Bard/src/Console/Application.php | 1 + .../Bard/src/Console/Command/CopyCommand.php | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php diff --git a/src/SonsOfPHP/Bard/src/Console/Application.php b/src/SonsOfPHP/Bard/src/Console/Application.php index e77d7bf0..605df806 100644 --- a/src/SonsOfPHP/Bard/src/Console/Application.php +++ b/src/SonsOfPHP/Bard/src/Console/Application.php @@ -24,6 +24,7 @@ protected function getDefaultCommands(): array { return array_merge(parent::getDefaultCommands(), [ new \SonsOfPHP\Bard\Console\Command\AddCommand(), + new \SonsOfPHP\Bard\Console\Command\CopyCommand(), new \SonsOfPHP\Bard\Console\Command\InitCommand(), new \SonsOfPHP\Bard\Console\Command\InstallCommand(), new \SonsOfPHP\Bard\Console\Command\MergeCommand(), diff --git a/src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php b/src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php new file mode 100644 index 00000000..5e9c852b --- /dev/null +++ b/src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php @@ -0,0 +1,48 @@ + + */ +final class CopyCommand extends AbstractCommand +{ + protected static $defaultName = 'copy'; + + protected function configure(): void + { + $this + ->setDescription('Copies a file to each package') + ->addArgument('source', InputArgument::REQUIRED, 'Source file to copy') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $sourceFile = $input->getOption('working-dir') . '/' . $input->getArgument('source'); + if (!is_file($sourceFile)) { + throw new \RuntimeException(sprintf('The file "%s" is an invalid file.', $sourceFile)); + } + $bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json'); + foreach ($bardJsonFile->getSection('packages') as $pkg) { + $process = new Process(['cp', $sourceFile, $pkg['path']]); + $io->text($process->getCommandLine()); + $this->getHelper('process')->run($output, $process); + } + + $io->success('File has been copied.'); + + return self::SUCCESS; + } +} From c8fafab88b5e3f25e938ee6e9d52b90086534750 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Tue, 24 Oct 2023 14:53:46 -0400 Subject: [PATCH 2/2] updated documentation --- docs/bard/index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/bard/index.md b/docs/bard/index.md index 8bda479a..77007625 100644 --- a/docs/bard/index.md +++ b/docs/bard/index.md @@ -36,3 +36,8 @@ bard release patch Bard will track the versions so you can just use the keywords: major, minor, patch. + +Copy the LICENSE file from the root to all packages +```shell +bard copy LICENSE +```