From 73897601a4a2b121c214058c2d1c107606c9da10 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Tue, 22 Mar 2016 13:14:32 +0100 Subject: [PATCH 001/101] Switch to new recommended syntax Composer now recommends using `||` instead of single `|`. --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 06b3c11..9cfa5d1 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,10 @@ "require": { "composer-plugin-api": "^1.0", "illuminate/support": "~5.0", - "symfony/console": "^2.7|^3.0", - "symfony/finder": "^2.5|^3.0", - "symfony/filesystem": "^2.5|^3.0", - "symfony/process": "^2.5|^3.0" + "symfony/console": "^2.7 || ^3.0", + "symfony/finder": "^2.5 || ^3.0", + "symfony/filesystem": "^2.5 || ^3.0", + "symfony/process": "^2.5 || ^3.0" }, "require-dev": { "composer/composer": "dev-master", From 3c0925df521a66a0f8db76a5673ba2174eb98c3c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 25 Mar 2016 13:49:43 +0900 Subject: [PATCH 002/101] Remove unused imports --- src/Console/LoadCommand.php | 1 - src/Console/ScrapCommand.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Console/LoadCommand.php b/src/Console/LoadCommand.php index e2563fd..bca5bb2 100644 --- a/src/Console/LoadCommand.php +++ b/src/Console/LoadCommand.php @@ -4,7 +4,6 @@ use Studio\Package; use Studio\Config\Config; -use Studio\Shell\Shell; use Symfony\Component\Console\Input\InputArgument; class LoadCommand extends BaseCommand diff --git a/src/Console/ScrapCommand.php b/src/Console/ScrapCommand.php index abb60a8..686a0ee 100644 --- a/src/Console/ScrapCommand.php +++ b/src/Console/ScrapCommand.php @@ -4,7 +4,6 @@ use Studio\Package; use Studio\Config\Config; -use Studio\Shell\Shell; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Filesystem\Filesystem; From f73f701b2cdcae2a4e35fbec67e13cd555727724 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 26 Mar 2016 20:37:32 +0900 Subject: [PATCH 003/101] Import class --- src/Shell/Shell.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Shell/Shell.php b/src/Shell/Shell.php index 56d80d6..909b3aa 100644 --- a/src/Shell/Shell.php +++ b/src/Shell/Shell.php @@ -2,6 +2,7 @@ namespace Studio\Shell; +use RuntimeException; use Symfony\Component\Process\Process; class Shell @@ -17,7 +18,7 @@ public static function run($task, $directory = null) if (! $process->isSuccessful()) { $command = collect(explode(' ', $task))->first(); $error = $process->getErrorOutput(); - throw new \RuntimeException("Error while running $command: $error"); + throw new RuntimeException("Error while running $command: $error"); } return $process->getOutput(); From 4d315fd5f4a2e7458308ebef7f85c5f3f53047d3 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 26 Mar 2016 20:38:27 +0900 Subject: [PATCH 004/101] Don't go over board on the formatting --- src/Package.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Package.php b/src/Package.php index af20541..a1b86f9 100644 --- a/src/Package.php +++ b/src/Package.php @@ -30,11 +30,7 @@ public static function fromFolder($path) list($vendor, $name) = explode('/', $composer->name, 2); - return new static( - $vendor, - $name, - $path - ); + return new static($vendor, $name, $path); } public function __construct($vendor, $name, $path) From 5f6eadb8661fcfebaffcfb5f6ec96096010b2f08 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 26 Mar 2016 21:39:14 +0900 Subject: [PATCH 005/101] Remove illuminate/support dependency It was only needed for one line apparently. Refs #48. --- composer.json | 1 - src/Shell/Shell.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9cfa5d1..c8baa8e 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,6 @@ }, "require": { "composer-plugin-api": "^1.0", - "illuminate/support": "~5.0", "symfony/console": "^2.7 || ^3.0", "symfony/finder": "^2.5 || ^3.0", "symfony/filesystem": "^2.5 || ^3.0", diff --git a/src/Shell/Shell.php b/src/Shell/Shell.php index 909b3aa..b863701 100644 --- a/src/Shell/Shell.php +++ b/src/Shell/Shell.php @@ -16,7 +16,7 @@ public static function run($task, $directory = null) $process->run(); if (! $process->isSuccessful()) { - $command = collect(explode(' ', $task))->first(); + $command = preg_replace('/ .+$/', '', $task); $error = $process->getErrorOutput(); throw new RuntimeException("Error while running $command: $error"); } From ea6aafcb06e78a38b8792ec8fe23a9b6e80500f8 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 26 Mar 2016 21:42:41 +0900 Subject: [PATCH 006/101] Remove unneeded symfony/finder dependency Closes #48. --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index c8baa8e..0c0337d 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ "require": { "composer-plugin-api": "^1.0", "symfony/console": "^2.7 || ^3.0", - "symfony/finder": "^2.5 || ^3.0", "symfony/filesystem": "^2.5 || ^3.0", "symfony/process": "^2.5 || ^3.0" }, From 78ba2fa1ff2508ab432a04c723ab0fceb48ded43 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Mar 2016 15:16:36 +0900 Subject: [PATCH 007/101] When running studio create, only load the package when it makes sense Fixes #53. --- src/Console/BaseCommand.php | 6 ++++++ src/Console/CreateCommand.php | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Console/BaseCommand.php b/src/Console/BaseCommand.php index d0eac37..b31c1df 100644 --- a/src/Console/BaseCommand.php +++ b/src/Console/BaseCommand.php @@ -16,6 +16,11 @@ abstract class BaseCommand extends Command */ protected $input; + /** + * @var \Symfony\Component\Console\Output\OutputInterface + */ + protected $trueOutput; + /** * @var \Symfony\Component\Console\Style\StyleInterface */ @@ -24,6 +29,7 @@ abstract class BaseCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; + $this->trueOutput = $output; $this->output = new SymfonyStyle($input, $output); try { diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index 498ff09..f4c012e 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -9,6 +9,7 @@ use Studio\Creator\GitRepoCreator; use Studio\Creator\GitSubmoduleCreator; use Studio\Creator\SkeletonCreator; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -70,7 +71,6 @@ protected function fire() $creator = $this->makeCreator($this->input); $package = $creator->create(); - $this->config->addPackage($package); $path = $package->getPath(); $this->output->success("Package directory $path created."); @@ -78,6 +78,13 @@ protected function fire() $this->output->note('Running composer install for new package...'); Shell::run('composer install --prefer-dist', $package->getPath()); $this->output->success('Package successfully created.'); + + if ($this->shouldLoadNewPackage()) { + $this->getApplication()->find('load')->run( + new ArrayInput(['path' => $path]), + $this->trueOutput + ); + } } /** @@ -120,4 +127,18 @@ protected function makeParts() }, $this->partClasses); } + protected function shouldLoadNewPackage() + { + if (!file_exists('composer.json')) { + return false; + } else if (!file_exists('studio.json')) { + return $this->output->confirm( + 'Do you want to load this package in the surrounding Composer package using Studio?', + false + ); + } else { + return true; + } + } + } From 1e8b09b3145464d830953657041848c70359a96a Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Mar 2016 15:17:54 +0900 Subject: [PATCH 008/101] Rename base command properties --- src/Console/BaseCommand.php | 10 +++++----- src/Console/CreateCommand.php | 12 ++++++------ src/Console/LoadCommand.php | 2 +- src/Console/ScrapCommand.php | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Console/BaseCommand.php b/src/Console/BaseCommand.php index b31c1df..da7c716 100644 --- a/src/Console/BaseCommand.php +++ b/src/Console/BaseCommand.php @@ -19,23 +19,23 @@ abstract class BaseCommand extends Command /** * @var \Symfony\Component\Console\Output\OutputInterface */ - protected $trueOutput; + protected $output; /** * @var \Symfony\Component\Console\Style\StyleInterface */ - protected $output; + protected $io; protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; - $this->trueOutput = $output; - $this->output = new SymfonyStyle($input, $output); + $this->output = $output; + $this->io = new SymfonyStyle($input, $output); try { $this->fire(); } catch (Exception $e) { - $this->output->error($e->getMessage()); + $this->io->error($e->getMessage()); } } diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index f4c012e..a2e7401 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -66,23 +66,23 @@ protected function configure() protected function fire() { - $this->partInput = new ConsoleInput($this->output); + $this->partInput = new ConsoleInput($this->io); $creator = $this->makeCreator($this->input); $package = $creator->create(); $path = $package->getPath(); - $this->output->success("Package directory $path created."); + $this->io->success("Package directory $path created."); - $this->output->note('Running composer install for new package...'); + $this->io->note('Running composer install for new package...'); Shell::run('composer install --prefer-dist', $package->getPath()); - $this->output->success('Package successfully created.'); + $this->io->success('Package successfully created.'); if ($this->shouldLoadNewPackage()) { $this->getApplication()->find('load')->run( new ArrayInput(['path' => $path]), - $this->trueOutput + $this->output ); } } @@ -132,7 +132,7 @@ protected function shouldLoadNewPackage() if (!file_exists('composer.json')) { return false; } else if (!file_exists('studio.json')) { - return $this->output->confirm( + return $this->io->confirm( 'Do you want to load this package in the surrounding Composer package using Studio?', false ); diff --git a/src/Console/LoadCommand.php b/src/Console/LoadCommand.php index bca5bb2..a5eebcb 100644 --- a/src/Console/LoadCommand.php +++ b/src/Console/LoadCommand.php @@ -36,7 +36,7 @@ protected function fire() $package = Package::fromFolder($this->input->getArgument('path')); $this->config->addPackage($package); - $this->output->success('Package loaded successfully.'); + $this->io->success('Package loaded successfully.'); } } diff --git a/src/Console/ScrapCommand.php b/src/Console/ScrapCommand.php index 686a0ee..6bf8da0 100644 --- a/src/Console/ScrapCommand.php +++ b/src/Console/ScrapCommand.php @@ -37,24 +37,24 @@ protected function fire() $path = $this->input->getArgument('path'); if ($this->abortDeletion($path)) { - $this->output->note('Aborted.'); + $this->io->note('Aborted.'); return; } $package = Package::fromFolder($path); $this->config->removePackage($package); - $this->output->note('Removing package...'); + $this->io->note('Removing package...'); $filesystem = new Filesystem; $filesystem->remove($path); - $this->output->success('Package successfully removed.'); + $this->io->success('Package successfully removed.'); } protected function abortDeletion($path) { - $this->output->caution("This will delete the entire $path folder and all files within."); + $this->io->caution("This will delete the entire $path folder and all files within."); - return ! $this->output->confirm( + return ! $this->io->confirm( "Do you really want to scrap the package at $path? ", false ); From 133b39de2eaf8a5e27973b5418fe21a27a650b1c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Mar 2016 15:37:41 +0900 Subject: [PATCH 009/101] Fix a leftover function from illuminate/support Refs #48. --- src/Parts/PhpSpec/Part.php | 3 ++- src/Parts/PhpUnit/Part.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Parts/PhpSpec/Part.php b/src/Parts/PhpSpec/Part.php index 1372487..3876f15 100644 --- a/src/Parts/PhpSpec/Part.php +++ b/src/Parts/PhpSpec/Part.php @@ -13,7 +13,8 @@ public function setupPackage($composer, Directory $target) if ($this->input->confirm('Do you want to set up PhpSpec as a testing tool?')) { $composer->{'require-dev'}['phpspec/phpspec'] = '~2.0'; - $namespace = head(array_keys((array) $composer->autoload->{'psr-4'})); + $psr4Autoloading = (array) $composer->autoload->{'psr-4'}; + $namespace = key($psr4Autoloading).'Tests'; $namespace = rtrim($namespace, '\\'); $this->copyTo( diff --git a/src/Parts/PhpUnit/Part.php b/src/Parts/PhpUnit/Part.php index 92b16de..ae9c1a7 100644 --- a/src/Parts/PhpUnit/Part.php +++ b/src/Parts/PhpUnit/Part.php @@ -14,8 +14,8 @@ public function setupPackage($composer, Directory $target) $composer->{'require-dev'}['phpunit/phpunit'] = '4.*'; // Add autoloading rules for tests - $namespace = head(array_keys((array) $composer->autoload->{'psr-4'})); - $namespace .= 'Tests'; + $psr4Autoloading = (array) $composer->autoload->{'psr-4'}; + $namespace = key($psr4Autoloading).'Tests'; @$composer->{'autoload-dev'}->{'psr-4'}->{"$namespace\\"} = 'tests/'; From b5a28cf2d6f713359cd635081d1298b21b87ec92 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Mar 2016 15:38:29 +0900 Subject: [PATCH 010/101] Change default value Refs #53. --- src/Console/CreateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index a2e7401..0c36e0e 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -134,7 +134,7 @@ protected function shouldLoadNewPackage() } else if (!file_exists('studio.json')) { return $this->io->confirm( 'Do you want to load this package in the surrounding Composer package using Studio?', - false + true ); } else { return true; From 663d98b9b196b8962ab9c15ce9bf08f7a99f11e5 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 5 Apr 2016 20:37:50 +0900 Subject: [PATCH 011/101] Alias new branch to 0.11 branch --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0c0337d..2a1ccea 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ }, "extra": { "branch-alias": { - "dev-master": "0.10.x-dev" + "dev-master": "0.10.x-dev", + "dev-next": "0.11.x-dev" }, "class": "Studio\\Composer\\StudioPlugin" }, From dc6eb3d446a4020ac8eacc6941b5ef1cbc229a29 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 5 Apr 2016 21:40:58 +0900 Subject: [PATCH 012/101] Plugin: Load paths, not packages In preparation for #54. --- src/Composer/StudioPlugin.php | 4 ++-- src/Config/Config.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 482fe92..00c22d7 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -55,8 +55,8 @@ public function registerStudioPackages(Event $event) $repoManager = $event->getComposer()->getRepositoryManager(); $composerConfig = $event->getComposer()->getConfig(); - foreach ($config->getPackages() as $package => $path) { - $io->writeError("[Studio] Registering package $package with $path"); + foreach ($config->getPaths() as $path) { + $io->writeError("[Studio] Loading path $path"); $repoManager->prependRepository(new PathRepository( ['url' => $path], $io, diff --git a/src/Config/Config.php b/src/Config/Config.php index 8e1aed9..e11b155 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -31,6 +31,11 @@ public function getPackages() return $this->packages; } + public function getPaths() + { + return array_values($this->getPackages()); + } + public function addPackage(Package $package) { // Ensure our packages are loaded From 60e130378d5e573409416b70406ea0543e908699 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 5 Apr 2016 21:46:23 +0900 Subject: [PATCH 013/101] Make method private --- src/Config/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index e11b155..1480207 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -21,7 +21,7 @@ public function __construct(StorageInterface $storage) $this->storage = $storage; } - public function getPackages() + private function getPackages() { if (! $this->loaded) { $this->packages = $this->storage->load(); From 9c59cb1b09d4695b83cd634882b356fb95c164df Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 5 Apr 2016 22:11:06 +0900 Subject: [PATCH 014/101] Change Config to deal with paths instead of packages Refs #54. --- bin/studio | 3 +- src/Composer/StudioPlugin.php | 14 +------ src/Config/Config.php | 42 +++++++++++-------- src/Config/Storage.php | 10 +++++ .../{FileStorage.php => Version1Storage.php} | 16 +++++-- 5 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 src/Config/Storage.php rename src/Config/{FileStorage.php => Version1Storage.php} (72%) diff --git a/bin/studio b/bin/studio index 8ece4be..e234dc7 100755 --- a/bin/studio +++ b/bin/studio @@ -20,8 +20,7 @@ use Studio\Console\LoadCommand; use Studio\Console\ScrapCommand; use Symfony\Component\Console\Application; -$studioFile = getcwd().'/studio.json'; -$config = new Config(new FileStorage($studioFile)); +$config = Config::make(); $application = new Application('studio', '0.10.0'); $application->add(new CreateCommand($config)); diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 00c22d7..cb3f362 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -46,9 +46,8 @@ public static function getSubscribedEvents() public function registerStudioPackages(Event $event) { $this->targetDir = realpath($event->getComposer()->getPackage()->getTargetDir()); - $studioFile = "{$this->targetDir}/studio.json"; - $config = $this->getConfig($studioFile); + $config = Config::make("{$this->targetDir}/studio.json"); if ($config->hasPackages()) { $io = $event->getIO(); @@ -65,15 +64,4 @@ public function registerStudioPackages(Event $event) } } } - - /** - * Instantiate and return the config object. - * - * @param string $file - * @return Config - */ - protected function getConfig($file) - { - return new Config(new FileStorage($file)); - } } diff --git a/src/Config/Config.php b/src/Config/Config.php index 1480207..550ad9b 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -7,61 +7,67 @@ class Config { /** - * @var StorageInterface + * @var Storage */ protected $storage; - protected $packages; + protected $paths; protected $loaded = false; - public function __construct(StorageInterface $storage) + public function __construct(Storage $storage) { $this->storage = $storage; } - private function getPackages() + public static function make($file = null) { - if (! $this->loaded) { - $this->packages = $this->storage->load(); - $this->loaded = true; + if (is_null($file)) { + $file = getcwd().'/studio.json'; } - return $this->packages; + return new static( + new Version1Storage($file) + ); } public function getPaths() { - return array_values($this->getPackages()); + if (! $this->loaded) { + $this->paths = $this->storage->readPaths(); + $this->loaded = true; + } + + return $this->paths; } public function addPackage(Package $package) { // Ensure our packages are loaded - $this->getPackages(); + $this->getPaths(); - $this->packages[$package->getComposerId()] = $package->getPath(); - $this->storage->store($this->packages); + $this->paths[] = $package->getPath(); + $this->storage->writePaths($this->paths); } public function hasPackages() { // Ensure our packages are loaded - $this->getPackages(); + $this->getPaths(); - return ! empty($this->packages); + return ! empty($this->paths); } public function removePackage(Package $package) { // Ensure our packages are loaded - $this->getPackages(); + $this->getPaths(); - $key = $package->getComposerId(); + $path = $package->getPath(); - if (isset($this->packages[$key])) { - unset($this->packages[$key]); + if (($key = array_search($path, $this->paths)) !== false) { + unset($this->paths[$key]); $this->storage->store($this->packages); } } diff --git a/src/Config/Storage.php b/src/Config/Storage.php new file mode 100644 index 0000000..34b97cf --- /dev/null +++ b/src/Config/Storage.php @@ -0,0 +1,10 @@ +file = $file; } - public function store($packages) + public function readPaths() + { + return array_values($this->load()); + } + + public function writePaths($paths) + { + $this->store($paths); + } + + protected function store($packages) { $this->writeToFile(['packages' => $packages]); } - public function load() + protected function load() { if (!file_exists($this->file)) return []; From 562a4a704794abfc9d69cc863b66df7f440adb7b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 5 Apr 2016 22:14:32 +0900 Subject: [PATCH 015/101] Remove old interface --- src/Config/StorageInterface.php | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/Config/StorageInterface.php diff --git a/src/Config/StorageInterface.php b/src/Config/StorageInterface.php deleted file mode 100644 index 1133744..0000000 --- a/src/Config/StorageInterface.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Tue, 5 Apr 2016 22:33:54 +0900 Subject: [PATCH 016/101] Storage -> Serializer, move file writing and reading to config class Refs #54. --- src/Config/Config.php | 48 +++++++++++++++++++++++----- src/Config/Serializer.php | 10 ++++++ src/Config/Storage.php | 10 ------ src/Config/Version1Serializer.php | 16 ++++++++++ src/Config/Version1Storage.php | 53 ------------------------------- 5 files changed, 66 insertions(+), 71 deletions(-) create mode 100644 src/Config/Serializer.php delete mode 100644 src/Config/Storage.php create mode 100644 src/Config/Version1Serializer.php delete mode 100644 src/Config/Version1Storage.php diff --git a/src/Config/Config.php b/src/Config/Config.php index 550ad9b..23c69fa 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -7,18 +7,21 @@ class Config { /** - * @var Storage + * @var Serializer */ - protected $storage; + protected $serializer; protected $paths; protected $loaded = false; + protected $file; - public function __construct(Storage $storage) + + public function __construct($file, Serializer $serializer) { - $this->storage = $storage; + $this->file = $file; + $this->serializer = $serializer; } public static function make($file = null) @@ -28,14 +31,23 @@ public static function make($file = null) } return new static( - new Version1Storage($file) + $file, + new Version1Serializer() ); } + protected function readPaths() + { + if (!file_exists($this->file)) return []; + + $data = $this->readFromFile(); + return $this->serializer->deserializePaths($data); + } + public function getPaths() { if (! $this->loaded) { - $this->paths = $this->storage->readPaths(); + $this->paths = $this->readPaths(); $this->loaded = true; } @@ -48,7 +60,9 @@ public function addPackage(Package $package) $this->getPaths(); $this->paths[] = $package->getPath(); - $this->storage->writePaths($this->paths); + $this->writeToFile( + $this->serializer->serializePaths($this->paths) + ); } public function hasPackages() @@ -68,7 +82,25 @@ public function removePackage(Package $package) if (($key = array_search($path, $this->paths)) !== false) { unset($this->paths[$key]); - $this->storage->store($this->packages); + $this->writeToFile( + $this->serializer->serializePaths($this->paths) + ); } } + + protected function writeToFile(array $data) + { + file_put_contents( + $this->file, + json_encode( + $data, + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE + )."\n" + ); + } + + protected function readFromFile() + { + return json_decode(file_get_contents($this->file), true); + } } \ No newline at end of file diff --git a/src/Config/Serializer.php b/src/Config/Serializer.php new file mode 100644 index 0000000..0ccd297 --- /dev/null +++ b/src/Config/Serializer.php @@ -0,0 +1,10 @@ + $paths]; + } +} diff --git a/src/Config/Version1Storage.php b/src/Config/Version1Storage.php deleted file mode 100644 index 940be86..0000000 --- a/src/Config/Version1Storage.php +++ /dev/null @@ -1,53 +0,0 @@ -file = $file; - } - - public function readPaths() - { - return array_values($this->load()); - } - - public function writePaths($paths) - { - $this->store($paths); - } - - protected function store($packages) - { - $this->writeToFile(['packages' => $packages]); - } - - protected function load() - { - if (!file_exists($this->file)) return []; - - $contents = $this->readFromFile(); - return $contents['packages']; - } - - protected function writeToFile(array $data) - { - file_put_contents( - $this->file, - json_encode( - $data, - JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE - )."\n" - ); - } - - protected function readFromFile() - { - return json_decode(file_get_contents($this->file), true); - } -} From e89657fc1483ce338864eac641dabbdb5f9d269e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 21:20:46 +0900 Subject: [PATCH 017/101] Implement a VersionedSerializer class to support reading/writing different config versions In preparation for #54. --- src/Config/VersionedSerializer.php | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/Config/VersionedSerializer.php diff --git a/src/Config/VersionedSerializer.php b/src/Config/VersionedSerializer.php new file mode 100644 index 0000000..953e836 --- /dev/null +++ b/src/Config/VersionedSerializer.php @@ -0,0 +1,59 @@ + $serializer], $version); + } + + public function __construct(array $serializers, $defaultVersion) + { + $this->serializers = $serializers; + $this->defaultVersion = $defaultVersion; + } + + public function version($version, Serializer $serializer) + { + $this->serializers[$version] = $serializer; + + return $this; + } + + public function deserializePaths($obj) + { + if (!isset($obj['version'])) { + $serializer = $this->serializers[$this->default]; + } else if (array_key_exists(intval($obj['version']), $this->serializers)) { + $serializer = $this->serializers[$obj['version']]; + } else { + throw new \InvalidArgumentException('Invalid version'); + } + + return $serializer->deserializePaths($obj); + } + + public function serializePaths($paths) + { + $lastSerializer = $this->serializers[max(array_keys($this->serializers))]; + + return $lastSerializer->serializePaths($paths); + } +} From 0540c43a97382773c696b8da49c52bb91fd03693 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 21:28:07 +0900 Subject: [PATCH 018/101] Write the version field in the VersionedSerializer --- src/Config/VersionedSerializer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Config/VersionedSerializer.php b/src/Config/VersionedSerializer.php index 953e836..99c6d97 100644 --- a/src/Config/VersionedSerializer.php +++ b/src/Config/VersionedSerializer.php @@ -52,8 +52,9 @@ public function deserializePaths($obj) public function serializePaths($paths) { - $lastSerializer = $this->serializers[max(array_keys($this->serializers))]; + $lastVersion = max(array_keys($this->serializers)); + $serializer = $this->serializers[$lastVersion]; - return $lastSerializer->serializePaths($paths); + return ['version' => $lastVersion] + $serializer->serializePaths($paths); } } From 13ee7604ae5428dd8e8829f4718a2ad051b0a4a4 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 21:30:33 +0900 Subject: [PATCH 019/101] Fix variable name --- src/Config/VersionedSerializer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/VersionedSerializer.php b/src/Config/VersionedSerializer.php index 99c6d97..9a4311d 100644 --- a/src/Config/VersionedSerializer.php +++ b/src/Config/VersionedSerializer.php @@ -40,7 +40,7 @@ public function version($version, Serializer $serializer) public function deserializePaths($obj) { if (!isset($obj['version'])) { - $serializer = $this->serializers[$this->default]; + $serializer = $this->serializers[$this->defaultVersion]; } else if (array_key_exists(intval($obj['version']), $this->serializers)) { $serializer = $this->serializers[$obj['version']]; } else { From 7cca50bf81b935e6e1e21d834dcba2c9734cd482 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 21:33:44 +0900 Subject: [PATCH 020/101] Use new VersionedSerializer in Config --- src/Config/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 23c69fa..73f9a7a 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -32,7 +32,7 @@ public static function make($file = null) return new static( $file, - new Version1Serializer() + VersionedSerializer::withDefault(1, new Version1Serializer) ); } From 880d2c7088b4489d7eceedca4603726236d28ca1 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 21:37:28 +0900 Subject: [PATCH 021/101] Use typehint in interface signature --- src/Config/Serializer.php | 2 +- src/Config/Version1Serializer.php | 2 +- src/Config/VersionedSerializer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Config/Serializer.php b/src/Config/Serializer.php index 0ccd297..e178610 100644 --- a/src/Config/Serializer.php +++ b/src/Config/Serializer.php @@ -6,5 +6,5 @@ interface Serializer { public function deserializePaths($obj); - public function serializePaths($paths); + public function serializePaths(array $paths); } diff --git a/src/Config/Version1Serializer.php b/src/Config/Version1Serializer.php index 0e5f6e2..66f3d5b 100644 --- a/src/Config/Version1Serializer.php +++ b/src/Config/Version1Serializer.php @@ -9,7 +9,7 @@ public function deserializePaths($obj) return array_values($obj['packages']); } - public function serializePaths($paths) + public function serializePaths(array $paths) { return ['packages' => $paths]; } diff --git a/src/Config/VersionedSerializer.php b/src/Config/VersionedSerializer.php index 9a4311d..62f64b8 100644 --- a/src/Config/VersionedSerializer.php +++ b/src/Config/VersionedSerializer.php @@ -50,7 +50,7 @@ public function deserializePaths($obj) return $serializer->deserializePaths($obj); } - public function serializePaths($paths) + public function serializePaths(array $paths) { $lastVersion = max(array_keys($this->serializers)); $serializer = $this->serializers[$lastVersion]; From 549578a7f28d2cf2379705dc6649964f528b9ec9 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:01:09 +0900 Subject: [PATCH 022/101] Backwards-compatible implementation of the Version1Serializer --- src/Config/Version1Serializer.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Config/Version1Serializer.php b/src/Config/Version1Serializer.php index 66f3d5b..662f3e5 100644 --- a/src/Config/Version1Serializer.php +++ b/src/Config/Version1Serializer.php @@ -2,6 +2,8 @@ namespace Studio\Config; +use Studio\Package; + class Version1Serializer implements Serializer { public function deserializePaths($obj) @@ -11,6 +13,32 @@ public function deserializePaths($obj) public function serializePaths(array $paths) { - return ['packages' => $paths]; + $globbedPaths = array_map(function ($path) { + return glob($path, GLOB_MARK | GLOB_ONLYDIR); + }, $paths); + + $allPaths = array_reduce($globbedPaths, function ($collect, $pathOrPaths) { + if (is_array($pathOrPaths)) { + return array_merge($collect, $pathOrPaths); + } else { + $collect[] = $pathOrPaths; + return $collect; + } + }, []); + + $allPaths = array_filter($allPaths, function ($path) { + return is_dir($path) && file_exists("$path/composer.json"); + }); + + $packages = array_map(function ($path) { + return Package::fromFolder(rtrim($path, '/')); + }, $allPaths); + + $packagePaths = array_reduce($packages, function ($collect, Package $package) { + $collect[$package->getComposerId()] = $package->getPath(); + return $collect; + }, []); + + return ['packages' => $packagePaths]; } } From e5b5ba778130e1065aa483579872aaf268750380 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:03:48 +0900 Subject: [PATCH 023/101] Do not pass Config object to CreateCommand --- bin/studio | 2 +- src/Console/CreateCommand.php | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bin/studio b/bin/studio index e234dc7..a0c5fbd 100755 --- a/bin/studio +++ b/bin/studio @@ -23,7 +23,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); $application = new Application('studio', '0.10.0'); -$application->add(new CreateCommand($config)); +$application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new ScrapCommand($config)); $application->run(); diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index 0c36e0e..88cbbaa 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -17,8 +17,6 @@ class CreateCommand extends BaseCommand { - protected $config; - protected $partClasses = [ 'Studio\Parts\Base\Part', 'Studio\Parts\Composer\Part', @@ -33,13 +31,6 @@ class CreateCommand extends BaseCommand protected $partInput; - public function __construct(Config $config) - { - parent::__construct(); - - $this->config = $config; - } - protected function configure() { $this From a450b89f04af20c6d3849f72503a3426a1029362 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:08:59 +0900 Subject: [PATCH 024/101] Document the VersionedSerializer class --- src/Config/VersionedSerializer.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Config/VersionedSerializer.php b/src/Config/VersionedSerializer.php index 62f64b8..90c5991 100644 --- a/src/Config/VersionedSerializer.php +++ b/src/Config/VersionedSerializer.php @@ -2,6 +2,20 @@ namespace Studio\Config; +/** + * A decorator for serializing from/to multiple versions + * + * We support several versions of the Studio config file. + * + * This serializer class uses the serializer according to + * the "version" field or the default one if no "version" + * is provided for reading. + * + * For writing, the serializer with the highest version + * number is used. + * + * @package Studio\Config + */ class VersionedSerializer implements Serializer { /** From a4563f09fee4a16ad33d12817a43ea31ad1ee738 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:17:56 +0900 Subject: [PATCH 025/101] Implement a config serializer for the new version, storing only paths to be loaded Closes #54. --- src/Config/Version2Serializer.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Config/Version2Serializer.php diff --git a/src/Config/Version2Serializer.php b/src/Config/Version2Serializer.php new file mode 100644 index 0000000..9345b4b --- /dev/null +++ b/src/Config/Version2Serializer.php @@ -0,0 +1,16 @@ + array_values($paths)]; + } +} From c51e914ae07fc08e0705b0a48b3f5eb1a52ec963 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:18:19 +0900 Subject: [PATCH 026/101] Config: Support both the old and the new studio.json format Refs #54. --- src/Config/Config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 73f9a7a..d549dc7 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -32,7 +32,9 @@ public static function make($file = null) return new static( $file, - VersionedSerializer::withDefault(1, new Version1Serializer) + VersionedSerializer + ::withDefault(1, new Version1Serializer) + ->version(2, new Version2Serializer) ); } From ed749c671e0394c43eacdb12b27772d0e71b3833 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:22:30 +0900 Subject: [PATCH 027/101] load command: Load paths, not packages --- src/Config/Config.php | 6 +++--- src/Console/LoadCommand.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index d549dc7..53a5513 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -56,12 +56,12 @@ public function getPaths() return $this->paths; } - public function addPackage(Package $package) + public function addPath($path) { - // Ensure our packages are loaded + // ensure paths are loaded $this->getPaths(); - $this->paths[] = $package->getPath(); + $this->paths[] = $path; $this->writeToFile( $this->serializer->serializePaths($this->paths) ); diff --git a/src/Console/LoadCommand.php b/src/Console/LoadCommand.php index a5eebcb..cba2d74 100644 --- a/src/Console/LoadCommand.php +++ b/src/Console/LoadCommand.php @@ -2,7 +2,6 @@ namespace Studio\Console; -use Studio\Package; use Studio\Config\Config; use Symfony\Component\Console\Input\InputArgument; @@ -23,7 +22,7 @@ protected function configure() { $this ->setName('load') - ->setDescription('Load a package to be managed with Studio') + ->setDescription('Load a path to be managed with Studio') ->addArgument( 'path', InputArgument::REQUIRED, @@ -33,10 +32,11 @@ protected function configure() protected function fire() { - $package = Package::fromFolder($this->input->getArgument('path')); - $this->config->addPackage($package); + $this->config->addPath( + $path = $this->input->getArgument('path') + ); - $this->io->success('Package loaded successfully.'); + $this->io->success("Packages matching the path $path will now be loaded by Composer."); } } From 9b173ffa17ffecfa80a3d857d45821cbb3494a27 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:24:32 +0900 Subject: [PATCH 028/101] Extract dumping of config into separate method --- src/Config/Config.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 53a5513..2519762 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -58,18 +58,16 @@ public function getPaths() public function addPath($path) { - // ensure paths are loaded + // Ensure paths are loaded $this->getPaths(); $this->paths[] = $path; - $this->writeToFile( - $this->serializer->serializePaths($this->paths) - ); + $this->dump(); } public function hasPackages() { - // Ensure our packages are loaded + // Ensure paths are loaded $this->getPaths(); return ! empty($this->paths); @@ -77,19 +75,24 @@ public function hasPackages() public function removePackage(Package $package) { - // Ensure our packages are loaded + // Ensure paths are loaded $this->getPaths(); $path = $package->getPath(); if (($key = array_search($path, $this->paths)) !== false) { unset($this->paths[$key]); - $this->writeToFile( - $this->serializer->serializePaths($this->paths) - ); + $this->dump(); } } + protected function dump() + { + $this->writeToFile( + $this->serializer->serializePaths($this->paths) + ); + } + protected function writeToFile(array $data) { file_put_contents( From b25a2c35929b6f4688186d080350df650c4ee999 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 6 Apr 2016 22:28:08 +0900 Subject: [PATCH 029/101] Release version 0.11.0 --- bin/studio | 2 +- composer.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/studio b/bin/studio index a0c5fbd..6a643cf 100755 --- a/bin/studio +++ b/bin/studio @@ -22,7 +22,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.10.0'); +$application = new Application('studio', '0.11.0'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new ScrapCommand($config)); diff --git a/composer.json b/composer.json index 2a1ccea..7b03368 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.10.x-dev", - "dev-next": "0.11.x-dev" + "dev-master": "0.11.x-dev" }, "class": "Studio\\Composer\\StudioPlugin" }, From 36ad0121fc7d891962c74dea7fc4beb79d5dc149 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 7 Apr 2016 21:36:16 +0900 Subject: [PATCH 030/101] Configure PhpSpec --- phpspec.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 phpspec.yml diff --git a/phpspec.yml b/phpspec.yml new file mode 100644 index 0000000..e3b2291 --- /dev/null +++ b/phpspec.yml @@ -0,0 +1,4 @@ +suites: + studio_suite: + namespace: Studio + psr4_prefix: Studio \ No newline at end of file From ab4c72be07da625b1b243a686044c5be278141d4 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 7 Apr 2016 21:36:32 +0900 Subject: [PATCH 031/101] Add first spec --- spec/Config/Version2SerializerSpec.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/Config/Version2SerializerSpec.php diff --git a/spec/Config/Version2SerializerSpec.php b/spec/Config/Version2SerializerSpec.php new file mode 100644 index 0000000..f76e987 --- /dev/null +++ b/spec/Config/Version2SerializerSpec.php @@ -0,0 +1,19 @@ +shouldHaveType('Studio\Config\Version2Serializer'); + } + + function it_stores_paths_alphabetically() + { + $this->serializePaths(['foo', 'bar'])->shouldReturn(['paths' => ['bar', 'foo']]); + } +} From ff800d44354cc4b2defdcb54320e624a250674cb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 7 Apr 2016 21:36:44 +0900 Subject: [PATCH 032/101] Version2Serializer: Sort paths before storing them This will make the spec pass. --- src/Config/Version2Serializer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config/Version2Serializer.php b/src/Config/Version2Serializer.php index 9345b4b..9107bf3 100644 --- a/src/Config/Version2Serializer.php +++ b/src/Config/Version2Serializer.php @@ -11,6 +11,7 @@ public function deserializePaths($obj) public function serializePaths(array $paths) { + sort($paths); return ['paths' => array_values($paths)]; } } From b1812cd9c7de39994819b3276cf7bd1c44770f4e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 7 Apr 2016 21:39:05 +0900 Subject: [PATCH 033/101] Set up Travis CI --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..58cd6a5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +before_script: + - travis_retry composer self-update + - travis_retry composer install --prefer-dist --no-interaction + +script: vendor/bin/phpspec run From 11d7bc89e79008e5cef3bbb23eedc2d4fa616bc5 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 7 Apr 2016 21:42:46 +0900 Subject: [PATCH 034/101] TravisCI part: Test on PHP 7, dump PHP 5.4 --- src/Parts/TravisCI/stubs/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parts/TravisCI/stubs/.travis.yml b/src/Parts/TravisCI/stubs/.travis.yml index f60bbe0..ac80f2d 100644 --- a/src/Parts/TravisCI/stubs/.travis.yml +++ b/src/Parts/TravisCI/stubs/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm before_script: From 18495d3f87b2a4a4048143f65d51b449b169fa3e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 10 Apr 2016 20:46:33 +0900 Subject: [PATCH 035/101] Start working on a license part Refs #11. --- src/Parts/License/Part.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Parts/License/Part.php diff --git a/src/Parts/License/Part.php b/src/Parts/License/Part.php new file mode 100644 index 0000000..31a92c7 --- /dev/null +++ b/src/Parts/License/Part.php @@ -0,0 +1,23 @@ +input->confirm('Do you want to configure a license for your project?')) { + $licenses = new SpdxLicenses(); + + // 1. Choose a license from a list + // 2. Generate the license file, with year and name + // 3. Add it to composer.json + } + } + +} From dbb3f6baefea6e4f8bc9fe57e73e8ea3800e8e9f Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 10 Apr 2016 20:50:31 +0900 Subject: [PATCH 036/101] Just a bit of code consistency --- src/Console/BaseCommand.php | 2 -- src/Console/CreateCommand.php | 2 -- src/Console/LoadCommand.php | 2 -- src/Console/ScrapCommand.php | 2 -- src/Creator/CreatorInterface.php | 4 +--- src/Creator/GitRepoCreator.php | 2 -- src/Creator/GitSubmoduleCreator.php | 2 -- src/Creator/SkeletonCreator.php | 2 -- src/Package.php | 2 -- src/Parts/AbstractPart.php | 2 -- src/Parts/Base/Part.php | 2 -- src/Parts/Composer/Part.php | 2 -- src/Parts/ConsoleInput.php | 2 -- src/Parts/License/Part.php | 2 -- src/Parts/PartInputInterface.php | 2 -- src/Parts/PartInterface.php | 2 -- src/Parts/PhpSpec/Part.php | 2 -- src/Parts/PhpUnit/Part.php | 2 -- src/Parts/TravisCI/Part.php | 2 -- src/Shell/Shell.php | 2 -- 20 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/Console/BaseCommand.php b/src/Console/BaseCommand.php index da7c716..93c9aeb 100644 --- a/src/Console/BaseCommand.php +++ b/src/Console/BaseCommand.php @@ -10,7 +10,6 @@ abstract class BaseCommand extends Command { - /** * @var \Symfony\Component\Console\Input\InputInterface */ @@ -40,5 +39,4 @@ protected function execute(InputInterface $input, OutputInterface $output) } abstract protected function fire(); - } diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index 88cbbaa..e6dd56c 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -16,7 +16,6 @@ class CreateCommand extends BaseCommand { - protected $partClasses = [ 'Studio\Parts\Base\Part', 'Studio\Parts\Composer\Part', @@ -131,5 +130,4 @@ protected function shouldLoadNewPackage() return true; } } - } diff --git a/src/Console/LoadCommand.php b/src/Console/LoadCommand.php index cba2d74..8ca00ff 100644 --- a/src/Console/LoadCommand.php +++ b/src/Console/LoadCommand.php @@ -7,7 +7,6 @@ class LoadCommand extends BaseCommand { - protected $config; @@ -38,5 +37,4 @@ protected function fire() $this->io->success("Packages matching the path $path will now be loaded by Composer."); } - } diff --git a/src/Console/ScrapCommand.php b/src/Console/ScrapCommand.php index 6bf8da0..c5a6961 100644 --- a/src/Console/ScrapCommand.php +++ b/src/Console/ScrapCommand.php @@ -9,7 +9,6 @@ class ScrapCommand extends BaseCommand { - protected $config; @@ -59,5 +58,4 @@ protected function abortDeletion($path) false ); } - } diff --git a/src/Creator/CreatorInterface.php b/src/Creator/CreatorInterface.php index 0235683..2dd1e11 100644 --- a/src/Creator/CreatorInterface.php +++ b/src/Creator/CreatorInterface.php @@ -4,12 +4,10 @@ interface CreatorInterface { - /** * Create the new package. * * @return \Studio\Package */ public function create(); - -} \ No newline at end of file +} diff --git a/src/Creator/GitRepoCreator.php b/src/Creator/GitRepoCreator.php index 0107367..0658f9f 100644 --- a/src/Creator/GitRepoCreator.php +++ b/src/Creator/GitRepoCreator.php @@ -7,7 +7,6 @@ class GitRepoCreator implements CreatorInterface { - protected $repo; protected $path; @@ -35,5 +34,4 @@ protected function cloneRepository() { Shell::run("git clone $this->repo $this->path"); } - } diff --git a/src/Creator/GitSubmoduleCreator.php b/src/Creator/GitSubmoduleCreator.php index a0a4c85..d00ed5f 100644 --- a/src/Creator/GitSubmoduleCreator.php +++ b/src/Creator/GitSubmoduleCreator.php @@ -6,11 +6,9 @@ class GitSubmoduleCreator extends GitRepoCreator { - protected function cloneRepository() { Shell::run("git submodule add $this->repo $this->path"); Shell::run("git submodule init"); } - } diff --git a/src/Creator/SkeletonCreator.php b/src/Creator/SkeletonCreator.php index 61dcfef..43d0e1b 100644 --- a/src/Creator/SkeletonCreator.php +++ b/src/Creator/SkeletonCreator.php @@ -8,7 +8,6 @@ class SkeletonCreator implements CreatorInterface { - /** * @var string */ @@ -64,5 +63,4 @@ protected function installParts() ) ); } - } diff --git a/src/Package.php b/src/Package.php index a1b86f9..dafb49d 100644 --- a/src/Package.php +++ b/src/Package.php @@ -6,7 +6,6 @@ class Package { - protected $vendor; protected $name; @@ -59,5 +58,4 @@ public function getPath() { return $this->path; } - } diff --git a/src/Parts/AbstractPart.php b/src/Parts/AbstractPart.php index be3be4a..06d3fbb 100644 --- a/src/Parts/AbstractPart.php +++ b/src/Parts/AbstractPart.php @@ -7,7 +7,6 @@ abstract class AbstractPart implements PartInterface { - /** * @var PartInputInterface */ @@ -35,5 +34,4 @@ protected function copyTo($file, Directory $target, $targetName = null, Closure $target->write($targetName, $content); } - } diff --git a/src/Parts/Base/Part.php b/src/Parts/Base/Part.php index 9eee6b7..8c9b5cb 100644 --- a/src/Parts/Base/Part.php +++ b/src/Parts/Base/Part.php @@ -7,7 +7,6 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { $target->makeDir('src'); @@ -15,5 +14,4 @@ public function setupPackage($composer, Directory $target) $this->copyTo(__DIR__ . '/stubs/gitignore.txt', $target, '.gitignore'); } - } diff --git a/src/Parts/Composer/Part.php b/src/Parts/Composer/Part.php index ed69305..7774cd3 100644 --- a/src/Parts/Composer/Part.php +++ b/src/Parts/Composer/Part.php @@ -7,7 +7,6 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { // Ask for package name @@ -46,5 +45,4 @@ protected function makeDefaultNamespace($package) return ucfirst($vendor) . '\\' . ucfirst($name); } - } diff --git a/src/Parts/ConsoleInput.php b/src/Parts/ConsoleInput.php index 7080137..d80f10b 100644 --- a/src/Parts/ConsoleInput.php +++ b/src/Parts/ConsoleInput.php @@ -6,7 +6,6 @@ class ConsoleInput implements PartInputInterface { - /** * @var StyleInterface */ @@ -45,5 +44,4 @@ protected function validateWith($regex, $errorText) throw new \RuntimeException($errorText); }; } - } diff --git a/src/Parts/License/Part.php b/src/Parts/License/Part.php index 31a92c7..f066c53 100644 --- a/src/Parts/License/Part.php +++ b/src/Parts/License/Part.php @@ -8,7 +8,6 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to configure a license for your project?')) { @@ -19,5 +18,4 @@ public function setupPackage($composer, Directory $target) // 3. Add it to composer.json } } - } diff --git a/src/Parts/PartInputInterface.php b/src/Parts/PartInputInterface.php index 98fdcc6..73ae6f6 100644 --- a/src/Parts/PartInputInterface.php +++ b/src/Parts/PartInputInterface.php @@ -4,9 +4,7 @@ interface PartInputInterface { - public function confirm($question); public function ask($question, $regex, $errorText = null, $default = null); - } diff --git a/src/Parts/PartInterface.php b/src/Parts/PartInterface.php index 769f759..08d0e33 100644 --- a/src/Parts/PartInterface.php +++ b/src/Parts/PartInterface.php @@ -6,7 +6,5 @@ interface PartInterface { - public function setupPackage($composer, Directory $target); - } diff --git a/src/Parts/PhpSpec/Part.php b/src/Parts/PhpSpec/Part.php index 3876f15..8ecfc61 100644 --- a/src/Parts/PhpSpec/Part.php +++ b/src/Parts/PhpSpec/Part.php @@ -7,7 +7,6 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to set up PhpSpec as a testing tool?')) { @@ -29,5 +28,4 @@ function ($content) use ($namespace) { $target->makeDir('spec'); } } - } diff --git a/src/Parts/PhpUnit/Part.php b/src/Parts/PhpUnit/Part.php index ae9c1a7..ab356a4 100644 --- a/src/Parts/PhpUnit/Part.php +++ b/src/Parts/PhpUnit/Part.php @@ -7,7 +7,6 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to set up PhpUnit as a testing tool?')) { @@ -32,5 +31,4 @@ function ($content) use ($namespace) { $this->copyTo(__DIR__ . '/stubs/phpunit.xml', $target); } } - } diff --git a/src/Parts/TravisCI/Part.php b/src/Parts/TravisCI/Part.php index ce612ff..4e3aa27 100644 --- a/src/Parts/TravisCI/Part.php +++ b/src/Parts/TravisCI/Part.php @@ -7,12 +7,10 @@ class Part extends AbstractPart { - public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to set up TravisCI as continuous integration tool?')) { $this->copyTo(__DIR__ . '/stubs/.travis.yml', $target); } } - } diff --git a/src/Shell/Shell.php b/src/Shell/Shell.php index b863701..5c60e44 100644 --- a/src/Shell/Shell.php +++ b/src/Shell/Shell.php @@ -7,7 +7,6 @@ class Shell { - public static function run($task, $directory = null) { $process = new Process("$task", $directory); @@ -23,5 +22,4 @@ public static function run($task, $directory = null) return $process->getOutput(); } - } From cce60082f4de15afe85f82567b944a4d49576e72 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 10 Apr 2016 20:51:00 +0900 Subject: [PATCH 037/101] Remove unused import --- src/Console/CreateCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index e6dd56c..878769f 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -4,7 +4,6 @@ use Studio\Parts\ConsoleInput; use Studio\Shell\Shell; -use Studio\Config\Config; use Studio\Creator\CreatorInterface; use Studio\Creator\GitRepoCreator; use Studio\Creator\GitSubmoduleCreator; From a740716f9bbc8f9288190537d1c69c629618578f Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 11 Apr 2016 21:24:33 +0900 Subject: [PATCH 038/101] More work on license part Refs #11. --- src/Parts/License/Part.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Parts/License/Part.php b/src/Parts/License/Part.php index f066c53..81e6694 100644 --- a/src/Parts/License/Part.php +++ b/src/Parts/License/Part.php @@ -13,9 +13,22 @@ public function setupPackage($composer, Directory $target) if ($this->input->confirm('Do you want to configure a license for your project?')) { $licenses = new SpdxLicenses(); - // 1. Choose a license from a list - // 2. Generate the license file, with year and name - // 3. Add it to composer.json + $license = $this->selectLicenseFromList($licenses); + + $this->copyLicenseFileTo($target, $license); + + $composer->license = $license; } } + + protected function selectLicenseFromList($licenses) + { + // Ask the user to chosse a license from the list + } + + protected function copyLicenseFileTo(Directory $target, $license) + { + // Download the file + // Add year and name + } } From fa2b35125dfb6b10966765bbc69650a32813ac92 Mon Sep 17 00:00:00 2001 From: Otto Rask Date: Fri, 20 May 2016 15:37:01 +0300 Subject: [PATCH 039/101] Additions to README regarding usage workflow Add a section about the general workflow when using studio to develop packages. Refs #60. --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 65c28f4..0dae61c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,44 @@ Per project: `composer require --dev franzl/studio` All commands should be run from the root of your project, where the `composer.json` file is located. -### Create a new package skeleton +### General workflow + +Studio packages are local directories, which are symlinked to Composer's `vendor` directory for use in a project. + +First, we need to create the local directory for the development package: + + $ studio create foo + # or if you want to clone a git repo + $ studio create foo --git git@github.com:vendor/package.git + +This will create a package inside the current working directory under directory `foo`. + +Now we need to load it using studio, so studio knows to tell Composer that the development package is available locally. + + $ studio load foo + +This command should create a `studio.json` file into the current working directory. +It contains mappings to package names and local directories containing said packages. + +Now that we have studio packages loaded and ready, we need to tell Composer that we want to use said packages in our current project. +Insert the packages to `composer.json`: + + "require": { + "bar/foo": "dev-master" + } + +Next we run `composer update` and the following happens: + +1. Composer begins checking dependencies for updates. +2. Studio jumps in and informs Composer about the packages defined in the `studio.json` file. +3. Composer symlinks studio packages into the `vendor` directory (or in case of installers to their respective installation locations), + so they behave like "normal" Composer packages. +4. Composer generates proper autoloading rules for the studio packages. +5. For non-studio packages Composer works as always. + +### Commands + +#### Create a new package skeleton studio create foo/bar @@ -45,19 +82,19 @@ All its dependencies will be available when using Composer. During creation, you will be asked a series of questions to configure your skeleton. This will include things like configuration for testing tools, Travis CI, and autoloading. -### Manage existing packages by cloning a Git repository +#### Manage existing packages by cloning a Git repository studio create bar --git git@github.com:me/myrepo.git This will clone the given Git repository to the `bar` directory and install its dependencies. -### Import a package from an existing directory +#### Import a package from an existing directory studio load baz This will make sure the package in the `baz` directory will be autoloadable using Composer. -### Remove a package +#### Remove a package Sometimes you want to throw away a package. You can do so with the `scrap` command, passing a path for a Studio-managed package: From 429aff0c48011daf8c9e9116cc19fdef20ecc77c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 29 Jul 2016 23:30:13 +0900 Subject: [PATCH 040/101] Tweak README, add much more workflow information --- README.md | 96 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 0dae61c..5fccfe9 100644 --- a/README.md +++ b/README.md @@ -34,46 +34,74 @@ Per project: `composer require --dev franzl/studio` All commands should be run from the root of your project, where the `composer.json` file is located. -### General workflow +### Workflow -Studio packages are local directories, which are symlinked to Composer's `vendor` directory for use in a project. +Typically, you will want to require one of your own Composer packages in an application. +With Studio, you can pull in your local copy of the package *instead of* the version hosted on Packagist. +The kicker: You can keep developing your library while you dogfood it, but **you won't need to change your composer.json file**. -First, we need to create the local directory for the development package: +#### Loading local packages - $ studio create foo - # or if you want to clone a git repo - $ studio create foo --git git@github.com:vendor/package.git - -This will create a package inside the current working directory under directory `foo`. +To use one of your own libraries within your application, you need to tell Studio where it can locate the library. +You can do so with the `load` command. +When Composer resolves its dependencies, Studio will then pitch in and symlink your local directory to Composer's `vendor` directory. -Now we need to load it using studio, so studio knows to tell Composer that the development package is available locally. +So, to have Studio manage your awesome world domination library, all you have to do is run the following command: - $ studio load foo - -This command should create a `studio.json` file into the current working directory. -It contains mappings to package names and local directories containing said packages. + $ studio load path/to/world-domination -Now that we have studio packages loaded and ready, we need to tell Composer that we want to use said packages in our current project. -Insert the packages to `composer.json`: +This command should create a `studio.json` file in the current working directory. +It contains a list of directories for Studio to load. - "require": { - "bar/foo": "dev-master" - } +Next, if you haven't already done so, make sure you actually require the package in your composer.json: + + $ composer require my/world-domination -Next we run `composer update` and the following happens: +If the package is already in your composer.json, you need to tell Studio to set up the symlinks: + + $ composer update my/world-domination + +If all goes well, you should now see a brief message along the following as part of Composer's output: + +> [Studio] Loading path installer + +This is what will happen under the hood: + +1. Composer begins checking dependencies for updates. +2. Studio jumps in and informs Composer to prefer packages from the directories listed in the `studio.json` file over downloading them from Packagist. +3. Composer symlinks these packages into the `vendor` directory or any other appropriate place (e.g. for [custom installers](https://getcomposer.org/doc/articles/custom-installers.md)). + Thus, to your application, these packages will behave just like "normal" Composer packages. +4. Composer generates proper autoloading rules for the Studio packages. +5. For non-Studio packages, Composer works as always. + + +**Pro tip:** If you keep all your libraries in one directory, you can let Studio find all of them by using a wildcard: + + $ studio load path/to/my/libraries/* + +#### Kickstarting package development + +If you haven't started world domination yet, Studio also includes a handy generator for new Composer packages. +Besides the usual ceremony, it contains several optional components, such as configuration for unit tests, continuous integration on Travis-CI and others. + +First, we need to create the local directory for the development package: + + $ studio create domination + # or if you want to clone a git repo + $ studio create domination --git git@github.com:vendor/domination.git + +After asking you a series of questions, this will create (or download) a package in the `domination` subdirectory inside the current working directory. +There is a good chance that you need a little time to develop this package before publishing it on Packagist. +Therefore, if you ran this command in a Composer application, Studio will offer you to load your new package immediately. +This essentially comes down to running `studio load domination`. -1. Composer begins checking dependencies for updates. -2. Studio jumps in and informs Composer about the packages defined in the `studio.json` file. -3. Composer symlinks studio packages into the `vendor` directory (or in case of installers to their respective installation locations), - so they behave like "normal" Composer packages. -4. Composer generates proper autoloading rules for the studio packages. -5. For non-studio packages Composer works as always. +Finally, don't forget to use `composer require` to actually add your package as a dependency. -### Commands +### Command Reference -#### Create a new package skeleton +#### create: Create a new package skeleton - studio create foo/bar + $ studio create foo/bar This command creates a skeleton for a new Composer package, already filled with some helpful files to get you started. In the above example, we're creating a new package in the folder `foo/bar` in your project root. @@ -82,24 +110,24 @@ All its dependencies will be available when using Composer. During creation, you will be asked a series of questions to configure your skeleton. This will include things like configuration for testing tools, Travis CI, and autoloading. -#### Manage existing packages by cloning a Git repository +#### create --git: Manage existing packages by cloning a Git repository - studio create bar --git git@github.com:me/myrepo.git + $ studio create bar --git git@github.com:me/myrepo.git This will clone the given Git repository to the `bar` directory and install its dependencies. -#### Import a package from an existing directory +#### load: Import a package from an existing directory - studio load baz + $ studio load baz This will make sure the package in the `baz` directory will be autoloadable using Composer. -#### Remove a package +#### scrap: Remove a package Sometimes you want to throw away a package. You can do so with the `scrap` command, passing a path for a Studio-managed package: - studio scrap foo + $ studio scrap foo Don't worry - you'll be asked for a confirmation first. From cf9e446f6159a519cb46ed8fe52594f0fde77769 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 29 Jul 2016 23:48:45 +0900 Subject: [PATCH 041/101] README: Tweak workflow instructions again Studio does not yet hook into the `composer require` command. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5fccfe9..81bb6ff 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,11 @@ It contains a list of directories for Studio to load. Next, if you haven't already done so, make sure you actually require the package in your composer.json: - $ composer require my/world-domination + "require": { + "my/world-domination": "dev-master" + } -If the package is already in your composer.json, you need to tell Studio to set up the symlinks: +And finally, tell Studio to set up the symlinks: $ composer update my/world-domination @@ -74,7 +76,6 @@ This is what will happen under the hood: 4. Composer generates proper autoloading rules for the Studio packages. 5. For non-Studio packages, Composer works as always. - **Pro tip:** If you keep all your libraries in one directory, you can let Studio find all of them by using a wildcard: $ studio load path/to/my/libraries/* @@ -129,7 +130,7 @@ You can do so with the `scrap` command, passing a path for a Studio-managed pack $ studio scrap foo -Don't worry - you'll be asked for a confirmation first. +Don't worry - you'll be asked for confirmation first. ## License From fef747b03e4704fc9ae0009231340553b8b0ef71 Mon Sep 17 00:00:00 2001 From: Otto Rask Date: Sat, 19 Nov 2016 13:25:09 +0200 Subject: [PATCH 042/101] Add an unload command (#68) Refs #67. --- README.md | 10 +++++++++ bin/studio | 2 ++ src/Config/Config.php | 14 ++++++++++++- src/Console/UnloadCommand.php | 39 +++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/Console/UnloadCommand.php diff --git a/README.md b/README.md index 81bb6ff..5b66348 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,16 @@ This will clone the given Git repository to the `bar` directory and install its This will make sure the package in the `baz` directory will be autoloadable using Composer. +#### unload: Stop using a studio package with Composer project + + $ studio unload foo + +This will remove the path `foo` from the studio.json configuration. This means the package will not be loaded from the local development path anymore but will use your `composer.json` file's repositories definitions instead. + +This does not remove the package contents from the file system. See `scrap` for total removal. + +You can reload the package using the `load` command. + #### scrap: Remove a package Sometimes you want to throw away a package. diff --git a/bin/studio b/bin/studio index 6a643cf..982596d 100755 --- a/bin/studio +++ b/bin/studio @@ -17,6 +17,7 @@ use Studio\Config\Config; use Studio\Config\FileStorage; use Studio\Console\CreateCommand; use Studio\Console\LoadCommand; +use Studio\Console\UnloadCommand; use Studio\Console\ScrapCommand; use Symfony\Component\Console\Application; @@ -25,5 +26,6 @@ $config = Config::make(); $application = new Application('studio', '0.11.0'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); +$application->add(new UnloadCommand($config)); $application->add(new ScrapCommand($config)); $application->run(); diff --git a/src/Config/Config.php b/src/Config/Config.php index 2519762..821c11c 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -65,6 +65,18 @@ public function addPath($path) $this->dump(); } + public function removePath($path) + { + // Ensure paths are loaded + $this->getPaths(); + + $this->paths = array_filter($this->paths, function ($existing) use ($path) { + return $existing !== $path; + }); + + $this->dump(); + } + public function hasPackages() { // Ensure paths are loaded @@ -108,4 +120,4 @@ protected function readFromFile() { return json_decode(file_get_contents($this->file), true); } -} \ No newline at end of file +} diff --git a/src/Console/UnloadCommand.php b/src/Console/UnloadCommand.php new file mode 100644 index 0000000..2f978de --- /dev/null +++ b/src/Console/UnloadCommand.php @@ -0,0 +1,39 @@ +config = $config; + } + + protected function configure() + { + $this + ->setName('unload') + ->setDescription('Unload a package path from being managed with Studio') + ->addArgument( + 'path', + InputArgument::REQUIRED, + 'The path where the package files are located' + ); + } + + protected function fire() + { + $this->config->removePath( + $path = $this->input->getArgument('path') + ); + + $this->io->success("Packages matching the path $path will no longer be loaded by Composer."); + } +} From 55f7a0db23c7d29b4484164184f7ecc69685be71 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 19 Nov 2016 12:31:27 +0100 Subject: [PATCH 043/101] Tweak README --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5b66348..3bdbc73 100644 --- a/README.md +++ b/README.md @@ -117,21 +117,23 @@ This will include things like configuration for testing tools, Travis CI, and au This will clone the given Git repository to the `bar` directory and install its dependencies. -#### load: Import a package from an existing directory +#### load: Make all packages from the given local path available to Composer $ studio load baz -This will make sure the package in the `baz` directory will be autoloadable using Composer. +This will make sure all packages in the `baz` directory (paths with wildcards are supported, too) will be autoloadable using Composer. -#### unload: Stop using a studio package with Composer project +#### unload: Stop managing a local path $ studio unload foo -This will remove the path `foo` from the studio.json configuration. This means the package will not be loaded from the local development path anymore but will use your `composer.json` file's repositories definitions instead. +This will remove the path `foo` from the studio.json configuration file. +This means any packages in that path will not be available to Composer anymore (unless they are still hosted on Packagist). -This does not remove the package contents from the file system. See `scrap` for total removal. +This does not remove the package contents from the file system. +See `scrap` for completely removing a package. -You can reload the package using the `load` command. +You can reload the path using the `load` command. #### scrap: Remove a package From 76d65d2eb132bdf4fb0c1a53507adcaac207ef1d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 19 Nov 2016 12:32:27 +0100 Subject: [PATCH 044/101] Bump version to 0.11.1 --- bin/studio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/studio b/bin/studio index 982596d..6ce46f1 100755 --- a/bin/studio +++ b/bin/studio @@ -23,7 +23,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.11.0'); +$application = new Application('studio', '0.11.1'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new UnloadCommand($config)); From a4adb5913f28b183638b9c6008841ac6b502366b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 19 Nov 2016 15:42:49 +0100 Subject: [PATCH 045/101] Use existing instance variables instead of traversing object tree. --- src/Composer/StudioPlugin.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index cb3f362..e62558e 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -7,7 +7,6 @@ use Composer\IO\IOInterface; use Composer\Plugin\PluginInterface; use Composer\Repository\PathRepository; -use Composer\Script\Event; use Composer\Script\ScriptEvents; use Studio\Config\Config; use Studio\Config\FileStorage; @@ -43,22 +42,21 @@ public static function getSubscribedEvents() ]; } - public function registerStudioPackages(Event $event) + public function registerStudioPackages() { - $this->targetDir = realpath($event->getComposer()->getPackage()->getTargetDir()); + $this->targetDir = realpath($this->composer->getPackage()->getTargetDir()); $config = Config::make("{$this->targetDir}/studio.json"); if ($config->hasPackages()) { - $io = $event->getIO(); - $repoManager = $event->getComposer()->getRepositoryManager(); - $composerConfig = $event->getComposer()->getConfig(); + $repoManager = $this->composer->getRepositoryManager(); + $composerConfig = $this->composer->getConfig(); foreach ($config->getPaths() as $path) { - $io->writeError("[Studio] Loading path $path"); + $this->io->writeError("[Studio] Loading path $path"); $repoManager->prependRepository(new PathRepository( ['url' => $path], - $io, + $this->io, $composerConfig )); } From cce74f0c9645ce05ed06d6d31c8e6ca0b74f6e1a Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 19 Nov 2016 15:52:18 +0100 Subject: [PATCH 046/101] Refactor: Extract a method --- src/Composer/StudioPlugin.php | 47 +++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index e62558e..c1b3b41 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -23,11 +23,6 @@ class StudioPlugin implements PluginInterface, EventSubscriberInterface */ protected $io; - /** - * @var string|null - */ - protected $targetDir; - public function activate(Composer $composer, IOInterface $io) { $this->composer = $composer; @@ -42,24 +37,38 @@ public static function getSubscribedEvents() ]; } + /** + * Register all managed paths with Composer. + * + * This function configures Composer to treat all Studio-managed paths as local path repositories, so that packages + * therein will be symlinked directly. + */ public function registerStudioPackages() { - $this->targetDir = realpath($this->composer->getPackage()->getTargetDir()); - - $config = Config::make("{$this->targetDir}/studio.json"); + $repoManager = $this->composer->getRepositoryManager(); + $composerConfig = $this->composer->getConfig(); - if ($config->hasPackages()) { - $repoManager = $this->composer->getRepositoryManager(); - $composerConfig = $this->composer->getConfig(); + foreach ($this->getManagedPaths() as $path) { + $this->io->writeError("[Studio] Loading path $path"); - foreach ($config->getPaths() as $path) { - $this->io->writeError("[Studio] Loading path $path"); - $repoManager->prependRepository(new PathRepository( - ['url' => $path], - $this->io, - $composerConfig - )); - } + $repoManager->prependRepository(new PathRepository( + ['url' => $path], + $this->io, + $composerConfig + )); } } + + /** + * Get the list of paths that are being managed by Studio. + * + * @return array + */ + private function getManagedPaths() + { + $targetDir = realpath($this->composer->getPackage()->getTargetDir()); + $config = Config::make("{$targetDir}/studio.json"); + + return $config->getPaths(); + } } From 863422ab45f7a9cd43c501d989b8ca8086545a58 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 25 Nov 2016 18:29:36 +0100 Subject: [PATCH 047/101] Replace slashes with backslash in namespace Fixes #70. --- src/Parts/Composer/Part.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Parts/Composer/Part.php b/src/Parts/Composer/Part.php index 7774cd3..efc7a75 100644 --- a/src/Parts/Composer/Part.php +++ b/src/Parts/Composer/Part.php @@ -25,6 +25,7 @@ public function setupPackage($composer, Directory $target) ); // Normalize and store the namespace + $namespace = str_replace('/', '\\', $namespace); $namespace = rtrim($namespace, '\\'); @$composer->autoload->{'psr-4'}->{"$namespace\\"} = 'src/'; From c1359ff9fdec24ca4e3ceb5dd38e09ce9ba8b2db Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 25 Nov 2016 18:31:51 +0100 Subject: [PATCH 048/101] Bump version to 0.11.2 --- bin/studio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/studio b/bin/studio index 6ce46f1..9b35b6f 100755 --- a/bin/studio +++ b/bin/studio @@ -23,7 +23,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.11.1'); +$application = new Application('studio', '0.11.2'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new UnloadCommand($config)); From da3cc1c4b4b4e56d98d3183eea24dcd9441b03f0 Mon Sep 17 00:00:00 2001 From: Arcesilas Date: Fri, 15 Sep 2017 13:38:01 +0200 Subject: [PATCH 049/101] Use more recent PHPUnit and PHPSpec versions (#76) * Use more recent PHPUnit and PHPSpec versions * Drop HHVM support (see https://github.com/phpspec/phpspec/issues/1139) --- .travis.yml | 1 - src/Parts/PhpSpec/Part.php | 2 +- src/Parts/PhpUnit/Part.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58cd6a5..09ed090 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ php: - 5.5 - 5.6 - 7.0 - - hhvm before_script: - travis_retry composer self-update diff --git a/src/Parts/PhpSpec/Part.php b/src/Parts/PhpSpec/Part.php index 8ecfc61..ed92c55 100644 --- a/src/Parts/PhpSpec/Part.php +++ b/src/Parts/PhpSpec/Part.php @@ -10,7 +10,7 @@ class Part extends AbstractPart public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to set up PhpSpec as a testing tool?')) { - $composer->{'require-dev'}['phpspec/phpspec'] = '~2.0'; + $composer->{'require-dev'}['phpspec/phpspec'] = '^4.0'; $psr4Autoloading = (array) $composer->autoload->{'psr-4'}; $namespace = key($psr4Autoloading).'Tests'; diff --git a/src/Parts/PhpUnit/Part.php b/src/Parts/PhpUnit/Part.php index ab356a4..ab5185c 100644 --- a/src/Parts/PhpUnit/Part.php +++ b/src/Parts/PhpUnit/Part.php @@ -10,7 +10,7 @@ class Part extends AbstractPart public function setupPackage($composer, Directory $target) { if ($this->input->confirm('Do you want to set up PhpUnit as a testing tool?')) { - $composer->{'require-dev'}['phpunit/phpunit'] = '4.*'; + $composer->{'require-dev'}['phpunit/phpunit'] = '^6.3'; // Add autoloading rules for tests $psr4Autoloading = (array) $composer->autoload->{'psr-4'}; From 4f1cbbf0d1e2899ab3021e55a2b9691696ef0983 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 15 Sep 2017 13:41:54 +0200 Subject: [PATCH 050/101] Bump version to 0.12.0 --- bin/studio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/studio b/bin/studio index 9b35b6f..86eea82 100755 --- a/bin/studio +++ b/bin/studio @@ -23,7 +23,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.11.2'); +$application = new Application('studio', '0.12.0'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new UnloadCommand($config)); From b2f0062c70c5cf1d6415e897e01ce18d43341b29 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 16 Oct 2017 18:52:06 +0100 Subject: [PATCH 051/101] Update PHPUnit Example Test stub to correctly reference the PHPUnit TestCase class. --- src/Parts/PhpUnit/stubs/tests/ExampleTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/Parts/PhpUnit/stubs/tests/ExampleTest.php diff --git a/src/Parts/PhpUnit/stubs/tests/ExampleTest.php b/src/Parts/PhpUnit/stubs/tests/ExampleTest.php old mode 100644 new mode 100755 index 284d79b..b49327c --- a/src/Parts/PhpUnit/stubs/tests/ExampleTest.php +++ b/src/Parts/PhpUnit/stubs/tests/ExampleTest.php @@ -2,7 +2,9 @@ namespace Foo\Bar\Tests; -class ExampleTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class ExampleTest extends TestCase { } From dd5385fd6c2934ab1a3418bce7b301d2d262a406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Thu, 30 Nov 2017 22:24:42 +0100 Subject: [PATCH 052/101] Allow install on Symfony 4.0 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7b03368..4d03844 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ }, "require": { "composer-plugin-api": "^1.0", - "symfony/console": "^2.7 || ^3.0", - "symfony/filesystem": "^2.5 || ^3.0", - "symfony/process": "^2.5 || ^3.0" + "symfony/console": "^2.7 || ^3.0 || ^4.0", + "symfony/filesystem": "^2.5 || ^3.0 || ^4.0", + "symfony/process": "^2.5 || ^3.0 || ^4.0" }, "require-dev": { "composer/composer": "dev-master", From aa0cde68b06ccb60b8648baf95f6d2a933a2e208 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 4 Dec 2017 22:46:01 +0100 Subject: [PATCH 053/101] Bump version to 0.13.0 --- bin/studio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/studio b/bin/studio index 86eea82..e86a9a0 100755 --- a/bin/studio +++ b/bin/studio @@ -23,7 +23,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.12.0'); +$application = new Application('studio', '0.13.0'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new UnloadCommand($config)); From d6668b7ae7eb825093fdb80b078ca173f83eada6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 12:14:28 +0100 Subject: [PATCH 054/101] Start setting up GitHub Actions --- .github/main.workflow | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/main.workflow diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..10e1515 --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,9 @@ +workflow "CI" { + on = "push" + resolves = ["Install dependencies"] +} + +action "Install dependencies" { + uses = "pxgamer/composer-action@master" + args = "install --prefer-dist" +} From 8889309bc0544efd379faad82179e360d1995d77 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 12:18:44 +0100 Subject: [PATCH 055/101] CI: Run PhpSpec tests with GitHub Actions --- .github/main.workflow | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/main.workflow b/.github/main.workflow index 10e1515..bc97aa3 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -1,9 +1,15 @@ workflow "CI" { on = "push" - resolves = ["Install dependencies"] + resolves = ["PhpSpec tests"] } action "Install dependencies" { uses = "pxgamer/composer-action@master" args = "install --prefer-dist" } + +action "PhpSpec tests" { + uses = "sh" + needs = ["Install dependencies"] + args = "vendor/bin/phpspec run" +} From 901766587be2bddd57e91e1c4f81ddde7f29c3d5 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 12:20:21 +0100 Subject: [PATCH 056/101] Fix GitHub Actions setup --- .github/main.workflow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/main.workflow b/.github/main.workflow index bc97aa3..8e42c84 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -9,7 +9,7 @@ action "Install dependencies" { } action "PhpSpec tests" { - uses = "sh" + uses = "actions/bin/sh@master" needs = ["Install dependencies"] args = "vendor/bin/phpspec run" } From 85c084542fa7900b8478f7e065aafad0c2205140 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 14:01:26 +0100 Subject: [PATCH 057/101] CI: Try to make PhpSpec run --- .github/main.workflow | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/main.workflow b/.github/main.workflow index 8e42c84..d03c9a8 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -1,6 +1,6 @@ workflow "CI" { on = "push" - resolves = ["PhpSpec tests"] + resolves = ["Run tests (PHP 7.1)"] } action "Install dependencies" { @@ -8,8 +8,8 @@ action "Install dependencies" { args = "install --prefer-dist" } -action "PhpSpec tests" { - uses = "actions/bin/sh@master" +action "Run tests (PHP 7.1)" { needs = ["Install dependencies"] - args = "vendor/bin/phpspec run" + uses = "franzliedke/gh-action-php@master" + runs = "php7.1 vendor/bin/phpspec run" } From b54b85456e41ee6ab2df81086fa76faec0858afa Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 14:10:04 +0100 Subject: [PATCH 058/101] CI: Run tests in five PHP versions --- .github/main.workflow | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/main.workflow b/.github/main.workflow index d03c9a8..1f4141f 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -1,6 +1,12 @@ workflow "CI" { on = "push" - resolves = ["Run tests (PHP 7.1)"] + resolves = [ + "Run tests (PHP 5.6)", + "Run tests (PHP 7.0)", + "Run tests (PHP 7.1)", + "Run tests (PHP 7.2)", + "Run tests (PHP 7.3)", + ] } action "Install dependencies" { @@ -8,8 +14,32 @@ action "Install dependencies" { args = "install --prefer-dist" } -action "Run tests (PHP 7.1)" { +action "Run tests (PHP 5.6)" { + uses = "franzliedke/gh-action-php@master" needs = ["Install dependencies"] + runs = "php5.6 vendor/bin/phpspec run" +} + +action "Run tests (PHP 7.0)" { + uses = "franzliedke/gh-action-php@master" + needs = ["Install dependencies"] + runs = "php7.0 vendor/bin/phpspec run" +} + +action "Run tests (PHP 7.1)" { uses = "franzliedke/gh-action-php@master" + needs = ["Install dependencies"] runs = "php7.1 vendor/bin/phpspec run" } + +action "Run tests (PHP 7.2)" { + uses = "franzliedke/gh-action-php@master" + needs = ["Install dependencies"] + runs = "php7.2 vendor/bin/phpspec run" +} + +action "Run tests (PHP 7.3)" { + uses = "franzliedke/gh-action-php@master" + needs = ["Install dependencies"] + runs = "php7.3 vendor/bin/phpspec run" +} From 3debb8a2614a7ad69678c35f3e805d5f91c6d5f6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 14:21:26 +0100 Subject: [PATCH 059/101] Drop PHP < 7 --- .github/main.workflow | 7 ------- composer.json | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/main.workflow b/.github/main.workflow index 1f4141f..4fa242a 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -1,7 +1,6 @@ workflow "CI" { on = "push" resolves = [ - "Run tests (PHP 5.6)", "Run tests (PHP 7.0)", "Run tests (PHP 7.1)", "Run tests (PHP 7.2)", @@ -14,12 +13,6 @@ action "Install dependencies" { args = "install --prefer-dist" } -action "Run tests (PHP 5.6)" { - uses = "franzliedke/gh-action-php@master" - needs = ["Install dependencies"] - runs = "php5.6 vendor/bin/phpspec run" -} - action "Run tests (PHP 7.0)" { uses = "franzliedke/gh-action-php@master" needs = ["Install dependencies"] diff --git a/composer.json b/composer.json index 4d03844..e319a1e 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ } }, "require": { + "php": ">=7.0", "composer-plugin-api": "^1.0", "symfony/console": "^2.7 || ^3.0 || ^4.0", "symfony/filesystem": "^2.5 || ^3.0 || ^4.0", From 4a9380a603fc13369b7b8b5a74a7f7837826b0ab Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 14:22:43 +0100 Subject: [PATCH 060/101] Configure composer test --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e319a1e..99a69a3 100644 --- a/composer.json +++ b/composer.json @@ -29,5 +29,8 @@ }, "class": "Studio\\Composer\\StudioPlugin" }, - "bin": ["bin/studio"] + "bin": ["bin/studio"], + "scripts": { + "test": "phpspec run" + } } From 64096b2e74df895638158fb597054ea17c643a84 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 2 Mar 2019 14:39:52 +0100 Subject: [PATCH 061/101] Remove Travis --- .travis.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09ed090..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - -before_script: - - travis_retry composer self-update - - travis_retry composer install --prefer-dist --no-interaction - -script: vendor/bin/phpspec run From 4c7e2334038a37ab647e387f1e66e9ec0f46e01c Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Wed, 22 May 2019 10:25:56 +0200 Subject: [PATCH 062/101] Add an --options argument to provide options to 'git clone' and 'git submodule add'. --- README.md | 14 ++++++++++++++ src/Console/CreateCommand.php | 22 +++++++++++++++------- src/Creator/GitRepoCreator.php | 7 +++++-- src/Creator/GitSubmoduleCreator.php | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3bdbc73..c538839 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,20 @@ This will include things like configuration for testing tools, Travis CI, and au This will clone the given Git repository to the `bar` directory and install its dependencies. +#### create --submodule: Manage existing packages by loading a Git repository as submodule + + $ studio create bar --submodule git@github.com:me/myrepo.git + +This will load the given Git repository to the `bar` directory as a submodule and install its dependencies. + +#### create --options: Provide specific options to Git when loading the repository + + $ studio create bar --git git@github.com:me/myrepo.git --options="--single-branch --branch=mybranch" + $ studio create bar --submodule git@github.com:me/myrepo.git --options="-b mybranch" + +This will load the given Git repository and checkout a specific branch. +To have an overview of all the options available to you, check `git clone --help` and `git submodule add --help`. + #### load: Make all packages from the given local path available to Composer $ studio load baz diff --git a/src/Console/CreateCommand.php b/src/Console/CreateCommand.php index 878769f..e541556 100644 --- a/src/Console/CreateCommand.php +++ b/src/Console/CreateCommand.php @@ -50,6 +50,12 @@ protected function configure() 'gs', InputOption::VALUE_REQUIRED, 'If set, this will download the given Git repository (as submodule) instead of creating a new one.' + ) + ->addOption( + 'options', + 'go', + InputOption::VALUE_REQUIRED, + 'If set, this will provide options to Git when fetching the repository or submodule.' ); } @@ -87,14 +93,16 @@ protected function makeCreator(InputInterface $input) $path = $input->getArgument('path'); if ($input->getOption('git')) { - return new GitRepoCreator($input->getOption('git'), $path); - } elseif ($input->getOption('submodule')) { - return new GitSubmoduleCreator($input->getOption('submodule'), $path); - } else { - $creator = new SkeletonCreator($path); - $this->installParts($creator); - return $creator; + return new GitRepoCreator($input->getOption('git'), $path, $input->getOption('options')); } + + if ($input->getOption('submodule')) { + return new GitSubmoduleCreator($input->getOption('submodule'), $path, $input->getOption('options')); + } + + $creator = new SkeletonCreator($path); + $this->installParts($creator); + return $creator; } protected function installParts(SkeletonCreator $creator) diff --git a/src/Creator/GitRepoCreator.php b/src/Creator/GitRepoCreator.php index 0658f9f..d9b4200 100644 --- a/src/Creator/GitRepoCreator.php +++ b/src/Creator/GitRepoCreator.php @@ -11,11 +11,14 @@ class GitRepoCreator implements CreatorInterface protected $path; + protected $options; - public function __construct($repo, $path) + + public function __construct($repo, $path, $options = '') { $this->repo = $repo; $this->path = $path; + $this->options = $options; } /** @@ -32,6 +35,6 @@ public function create() protected function cloneRepository() { - Shell::run("git clone $this->repo $this->path"); + Shell::run("git clone $this->options $this->repo $this->path"); } } diff --git a/src/Creator/GitSubmoduleCreator.php b/src/Creator/GitSubmoduleCreator.php index d00ed5f..f576719 100644 --- a/src/Creator/GitSubmoduleCreator.php +++ b/src/Creator/GitSubmoduleCreator.php @@ -8,7 +8,7 @@ class GitSubmoduleCreator extends GitRepoCreator { protected function cloneRepository() { - Shell::run("git submodule add $this->repo $this->path"); + Shell::run("git submodule add $this->options $this->repo $this->path"); Shell::run("git submodule init"); } } From f1c2e80fa4d3601458da7b2f9c3752197de54259 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 25 May 2019 18:17:05 +0200 Subject: [PATCH 063/101] Create FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b649af9 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [franzliedke] +tidelift: packagist/franzl/studio From ee4f9a1807527997049190e18680d38692d39f94 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 25 May 2019 18:21:25 +0200 Subject: [PATCH 064/101] Fix Tidelift sponsor link --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index b649af9..c68a026 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: [franzliedke] -tidelift: packagist/franzl/studio +tidelift: packagist/franzl%2Fstudio From 32f7b174c2df2db752b5c58fe7990a2b6c640c3e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 2 Jun 2019 22:40:08 +0200 Subject: [PATCH 065/101] Deduplicate entries in studio.json Fixes #94. --- spec/Config/Version2SerializerSpec.php | 5 +++++ src/Config/Version2Serializer.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/Config/Version2SerializerSpec.php b/spec/Config/Version2SerializerSpec.php index f76e987..89b1c04 100644 --- a/spec/Config/Version2SerializerSpec.php +++ b/spec/Config/Version2SerializerSpec.php @@ -16,4 +16,9 @@ function it_stores_paths_alphabetically() { $this->serializePaths(['foo', 'bar'])->shouldReturn(['paths' => ['bar', 'foo']]); } + + function it_deduplicates_paths() + { + $this->serializePaths(['foo', 'bar', 'foo'])->shouldReturn(['paths' => ['bar', 'foo']]); + } } diff --git a/src/Config/Version2Serializer.php b/src/Config/Version2Serializer.php index 9107bf3..7aed35e 100644 --- a/src/Config/Version2Serializer.php +++ b/src/Config/Version2Serializer.php @@ -12,6 +12,6 @@ public function deserializePaths($obj) public function serializePaths(array $paths) { sort($paths); - return ['paths' => array_values($paths)]; + return ['paths' => array_unique(array_values($paths))]; } } From 0a7d5c3be241725ae125114cf245c75ffb984023 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 2 Jul 2019 23:33:08 +0200 Subject: [PATCH 066/101] Clean up FUNDING file --- .github/FUNDING.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c68a026..3a7bd94 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1 @@ -github: [franzliedke] -tidelift: packagist/franzl%2Fstudio +tidelift: packagist/franzl/studio From 6da1d3d0f85086d62f8eaff3f8c09c63a9dc33c1 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 2 Jul 2019 23:48:31 +0200 Subject: [PATCH 067/101] Update security policy --- .github/SECURITY.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/SECURITY.md diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..ad018d9 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +## Supported Versions + +Currently, only the [latest stable release](https://github.com/franzliedke/studio/releases) is supported with security updates. + +## Reporting a Vulnerability + +To report a security vulnerability, please use the +[Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. From 3e3db0da82e69d0ed26cad2c79ea9bfef613469e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 3 Jul 2019 00:04:19 +0200 Subject: [PATCH 068/101] Update README, link to Tidelift --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index c538839..dfcaf61 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # studio +* [Installation](#installation) +* [Usage](#installation) + * [Workflow](#workflow) + * [Command Reference](#command-reference) +* [License](#license) +* [Contributing](#contributing) +* [Support development](#support-development) + Develop your Composer libraries with style. This package makes it easy to develop Composer packages while using them. @@ -167,3 +175,11 @@ This means you can do almost anything with it, as long as the copyright notice a Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated! + +## Support development + +[Tidelift][tidelift] gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools. + +[Support Studio's ongoing development with a Tidelift subscription!][tidelift] + +[tidelift]: https://tidelift.com/subscription/pkg/packagist-franzl-studio?utm_source=packagist-franzl-studio&utm_medium=referral&utm_campaign=readme From 00084765e9a1bb4a267d84645a5f3e1a523b0131 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 15 Aug 2019 22:39:16 +0200 Subject: [PATCH 069/101] Update to new GitHub Actions beta --- .github/workflows/phpspec.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/phpspec.yml diff --git a/.github/workflows/phpspec.yml b/.github/workflows/phpspec.yml new file mode 100644 index 0000000..2cbfa09 --- /dev/null +++ b/.github/workflows/phpspec.yml @@ -0,0 +1,15 @@ +name: CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Install Composer dependencies + run: composer install --prefer-dist + - name: Run tests (PHP 7.0) + run: php7.0 vendor/bin/phpspec run From 8435db30aa56d8c00c5c050151cee753658b03bf Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 15 Aug 2019 23:52:34 +0200 Subject: [PATCH 070/101] GitHub Actions: Tweak the new workflow --- .github/main.workflow | 38 ----------------------- .github/workflows/{phpspec.yml => ci.yml} | 12 ++++--- 2 files changed, 7 insertions(+), 43 deletions(-) delete mode 100644 .github/main.workflow rename .github/workflows/{phpspec.yml => ci.yml} (55%) diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index 4fa242a..0000000 --- a/.github/main.workflow +++ /dev/null @@ -1,38 +0,0 @@ -workflow "CI" { - on = "push" - resolves = [ - "Run tests (PHP 7.0)", - "Run tests (PHP 7.1)", - "Run tests (PHP 7.2)", - "Run tests (PHP 7.3)", - ] -} - -action "Install dependencies" { - uses = "pxgamer/composer-action@master" - args = "install --prefer-dist" -} - -action "Run tests (PHP 7.0)" { - uses = "franzliedke/gh-action-php@master" - needs = ["Install dependencies"] - runs = "php7.0 vendor/bin/phpspec run" -} - -action "Run tests (PHP 7.1)" { - uses = "franzliedke/gh-action-php@master" - needs = ["Install dependencies"] - runs = "php7.1 vendor/bin/phpspec run" -} - -action "Run tests (PHP 7.2)" { - uses = "franzliedke/gh-action-php@master" - needs = ["Install dependencies"] - runs = "php7.2 vendor/bin/phpspec run" -} - -action "Run tests (PHP 7.3)" { - uses = "franzliedke/gh-action-php@master" - needs = ["Install dependencies"] - runs = "php7.3 vendor/bin/phpspec run" -} diff --git a/.github/workflows/phpspec.yml b/.github/workflows/ci.yml similarity index 55% rename from .github/workflows/phpspec.yml rename to .github/workflows/ci.yml index 2cbfa09..ef9800c 100644 --- a/.github/workflows/phpspec.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,15 @@ name: CI on: [push] jobs: - build: - + phpspec: runs-on: ubuntu-latest - + strategy: + matrix: + php: [7.1, 7.2, 7.3] steps: - uses: actions/checkout@v1 - name: Install Composer dependencies run: composer install --prefer-dist - - name: Run tests (PHP 7.0) - run: php7.0 vendor/bin/phpspec run + - name: Run tests + run: php${{ matrix.php }} vendor/bin/phpspec run + From ed7c639812146888189c5f5a2f6029d677df8a4c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 28 Aug 2019 23:18:00 +0200 Subject: [PATCH 071/101] Improve CI workflow --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef9800c..6e39583 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,10 @@ jobs: php: [7.1, 7.2, 7.3] steps: - uses: actions/checkout@v1 + - name: Validate Composer files + run: composer validate --no-check-all --strict - name: Install Composer dependencies - run: composer install --prefer-dist + run: composer install --prefer-dist --no-progress --no-suggest - name: Run tests run: php${{ matrix.php }} vendor/bin/phpspec run From 66dc86a07e2125bf52161dd3866271dc50d7ab3c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 15 Oct 2019 21:58:55 +0200 Subject: [PATCH 072/101] FUNDING: Link to GitHub Sponsors --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 3a7bd94..b039a3d 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ +github: franzliedke tidelift: packagist/franzl/studio From ee5440aab89c47644e50652a34940c4cd1014c78 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Oct 2019 23:35:38 +0100 Subject: [PATCH 073/101] README: Update Tidelift copy --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dfcaf61..8c6c156 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ * [Command Reference](#command-reference) * [License](#license) * [Contributing](#contributing) -* [Support development](#support-development) +* [For enterprise](#franzl-studio-for-enterprise) Develop your Composer libraries with style. @@ -176,10 +176,8 @@ This means you can do almost anything with it, as long as the copyright notice a Feel free to send pull requests or create issues if you come across problems or have great ideas. Any input is appreciated! -## Support development +## franzl/studio for enterprise -[Tidelift][tidelift] gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools. +Available as part of the Tidelift Subscription -[Support Studio's ongoing development with a Tidelift subscription!][tidelift] - -[tidelift]: https://tidelift.com/subscription/pkg/packagist-franzl-studio?utm_source=packagist-franzl-studio&utm_medium=referral&utm_campaign=readme +The maintainers of franzl/studio and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-franzl-studio?utm_source=packagist-franzl-studio&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) From 53a47c7c7b3dd62f2cc7a4b0fa8572e501877d3b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 27 Oct 2019 23:36:05 +0100 Subject: [PATCH 074/101] README: Fix link in table of contents --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c6c156..feb62d2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ * [Command Reference](#command-reference) * [License](#license) * [Contributing](#contributing) -* [For enterprise](#franzl-studio-for-enterprise) +* [For enterprise](#franzlstudio-for-enterprise) Develop your Composer libraries with style. From 013cce6dfde32da0b2fd5513b47208a8592a2a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Sat, 30 Nov 2019 00:40:54 +0100 Subject: [PATCH 075/101] Allow Symfony 5.0 (#98) --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 99a69a3..e966812 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,9 @@ "require": { "php": ">=7.0", "composer-plugin-api": "^1.0", - "symfony/console": "^2.7 || ^3.0 || ^4.0", - "symfony/filesystem": "^2.5 || ^3.0 || ^4.0", - "symfony/process": "^2.5 || ^3.0 || ^4.0" + "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0", + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" }, "require-dev": { "composer/composer": "dev-master", From e90fd88a49a40e20338777d264ba2c5af08b1d31 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Fri, 22 May 2020 16:22:42 +0200 Subject: [PATCH 076/101] Commands must return an exit status --- src/Console/BaseCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Console/BaseCommand.php b/src/Console/BaseCommand.php index 93c9aeb..e8a2a87 100644 --- a/src/Console/BaseCommand.php +++ b/src/Console/BaseCommand.php @@ -33,8 +33,10 @@ protected function execute(InputInterface $input, OutputInterface $output) try { $this->fire(); + return 0; } catch (Exception $e) { $this->io->error($e->getMessage()); + return 1; } } From 8bb399243119d7a43dbff649c37893909fbc0a05 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Fri, 22 May 2020 16:28:36 +0200 Subject: [PATCH 077/101] Use correct (and up-to-date) versions in require-dev --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e966812..22fc921 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "composer/composer": "dev-master", - "phpspec/phpspec": "~2.3" + "composer/composer": "1.10.x-dev", + "phpspec/phpspec": "^6.1" }, "replace": { "franzliedke/studio": "self.version" From 6fdeaf9a44b2ae95a6aff93341331377aec5fbed Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 24 May 2020 22:37:43 +0200 Subject: [PATCH 078/101] CI: Run tests on pull requests as well --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e39583..25c4c96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: phpspec: From 38cfc1b1457ba9bd7d11e59af0a82b22502da03d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 24 May 2020 22:41:57 +0200 Subject: [PATCH 079/101] Downgrade phpspec dependency for PHP 7.1 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 22fc921..02c60e4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "composer/composer": "1.10.x-dev", - "phpspec/phpspec": "^6.1" + "phpspec/phpspec": "^5.1" }, "replace": { "franzliedke/studio": "self.version" From b2844d47abc01796bbb22a75e710b8b457451b41 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 24 May 2020 22:50:47 +0200 Subject: [PATCH 080/101] CI: Setup PHP with shivamathur/setup-php action This will ensure that Composer will use the intended PHP version as well. --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25c4c96..e46803f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,10 +10,13 @@ jobs: php: [7.1, 7.2, 7.3] steps: - uses: actions/checkout@v1 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} - name: Validate Composer files run: composer validate --no-check-all --strict - name: Install Composer dependencies run: composer install --prefer-dist --no-progress --no-suggest - name: Run tests - run: php${{ matrix.php }} vendor/bin/phpspec run + run: php vendor/bin/phpspec run From ec8e631042766159db5942caa6d83f6a6beba696 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 14 Jul 2020 23:55:11 +0200 Subject: [PATCH 081/101] Export a clean array (#103) --- spec/Config/Version2SerializerSpec.php | 3 ++- src/Config/Version2Serializer.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/Config/Version2SerializerSpec.php b/spec/Config/Version2SerializerSpec.php index 89b1c04..9e64e20 100644 --- a/spec/Config/Version2SerializerSpec.php +++ b/spec/Config/Version2SerializerSpec.php @@ -19,6 +19,7 @@ function it_stores_paths_alphabetically() function it_deduplicates_paths() { - $this->serializePaths(['foo', 'bar', 'foo'])->shouldReturn(['paths' => ['bar', 'foo']]); + // return array should have no gaps + $this->serializePaths(['bar', 'foo', 'test', 'foo'])->shouldReturn(['paths' => [0 => 'bar', 1 => 'foo', 2 => 'test']]); } } diff --git a/src/Config/Version2Serializer.php b/src/Config/Version2Serializer.php index 7aed35e..8c653d9 100644 --- a/src/Config/Version2Serializer.php +++ b/src/Config/Version2Serializer.php @@ -12,6 +12,6 @@ public function deserializePaths($obj) public function serializePaths(array $paths) { sort($paths); - return ['paths' => array_unique(array_values($paths))]; + return ['paths' => array_values(array_unique($paths))]; } } From 7ae5020a5bea4048d1d8b13d00775d1df0b0ace0 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 11:15:25 +0100 Subject: [PATCH 082/101] CI: Test on PHP 7.4 and 8 as well --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e46803f..b7541d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [7.1, 7.2, 7.3] + php: [7.1, 7.2, 7.3, 7.4, 8.0] steps: - uses: actions/checkout@v1 - uses: shivammathur/setup-php@v2 From f7fff58c746f0a10bd5f2785aa342124d434e9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Fri, 18 Dec 2020 11:41:33 +0100 Subject: [PATCH 083/101] Add support for Composer 2 (#104) --- composer.json | 2 +- src/Composer/StudioPlugin.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 02c60e4..7cb9eba 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ }, "require": { "php": ">=7.0", - "composer-plugin-api": "^1.0", + "composer-plugin-api": "^1.0 || ^2.0", "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0", "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0", "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index c1b3b41..bd74389 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -29,6 +29,14 @@ public function activate(Composer $composer, IOInterface $io) $this->io = $io; } + public function deactivate(Composer $composer, IOInterface $io) + { + } + + public function uninstall(Composer $composer, IOInterface $io) + { + } + public static function getSubscribedEvents() { return [ From f100666966fdd57e6eb436d7d1ec5aa63144e68b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 11:47:10 +0100 Subject: [PATCH 084/101] Update PhpSpec to support PHP 7.4 and 8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7cb9eba..bb1e9c3 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "composer/composer": "1.10.x-dev", - "phpspec/phpspec": "^5.1" + "phpspec/phpspec": "^6.3" }, "replace": { "franzliedke/studio": "self.version" From 4f77298f51c77b0380a86c1a74bb50c5b5afb74b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 11:49:56 +0100 Subject: [PATCH 085/101] Stop running tests on PHP 7.1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7541d7..8dd2b85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.2, 7.3, 7.4, 8.0] steps: - uses: actions/checkout@v1 - uses: shivammathur/setup-php@v2 From 9fcf9a13185e991ea1f349b27a2ebef296661a73 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 12:10:27 +0100 Subject: [PATCH 086/101] Remove some obsolete imports --- bin/studio | 1 - src/Composer/StudioPlugin.php | 1 - 2 files changed, 2 deletions(-) diff --git a/bin/studio b/bin/studio index e86a9a0..4b8fc9c 100755 --- a/bin/studio +++ b/bin/studio @@ -14,7 +14,6 @@ foreach ($autoloaders as $autoload) { } use Studio\Config\Config; -use Studio\Config\FileStorage; use Studio\Console\CreateCommand; use Studio\Console\LoadCommand; use Studio\Console\UnloadCommand; diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index bd74389..1730db1 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -9,7 +9,6 @@ use Composer\Repository\PathRepository; use Composer\Script\ScriptEvents; use Studio\Config\Config; -use Studio\Config\FileStorage; class StudioPlugin implements PluginInterface, EventSubscriberInterface { From e866e643f50bfaadb70847f38ee58ddd3ab62300 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 12:29:27 +0100 Subject: [PATCH 087/101] Add support for Symfony 5 to process runner Brought up in #98. --- src/Shell/Shell.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Shell/Shell.php b/src/Shell/Shell.php index 5c60e44..5d56276 100644 --- a/src/Shell/Shell.php +++ b/src/Shell/Shell.php @@ -2,6 +2,7 @@ namespace Studio\Shell; +use ReflectionClass; use RuntimeException; use Symfony\Component\Process\Process; @@ -9,7 +10,7 @@ class Shell { public static function run($task, $directory = null) { - $process = new Process("$task", $directory); + $process = static::makeProcess($task, $directory); $process->setTimeout(3600); $process->run(); @@ -22,4 +23,17 @@ public static function run($task, $directory = null) return $process->getOutput(); } + + private function makeProcess($task, $directory) + { + $reflection = new ReflectionClass(Process::class); + $params = $reflection->getConstructor()->getParameters(); + $type = $params[0]->getType(); + + if ($type && $type->getName() === 'array') { // Symfony 5 + return new Process(explode(' ', $task), $directory); + } else { // Older versions + return new Process($task, $directory); + } + } } From d9502a583f4a0c43aa9875c8d8cfd3a66065a8da Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 18 Dec 2020 12:30:50 +0100 Subject: [PATCH 088/101] Release version 0.15.0 --- bin/studio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/studio b/bin/studio index 4b8fc9c..95e1110 100755 --- a/bin/studio +++ b/bin/studio @@ -22,7 +22,7 @@ use Symfony\Component\Console\Application; $config = Config::make(); -$application = new Application('studio', '0.13.0'); +$application = new Application('studio', '0.15.0'); $application->add(new CreateCommand); $application->add(new LoadCommand($config)); $application->add(new UnloadCommand($config)); From a59f502ec88968336eaf7443b8d4302a00f639be Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 20 Dec 2020 23:18:44 +0100 Subject: [PATCH 089/101] Make statically-called method static --- src/Shell/Shell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shell/Shell.php b/src/Shell/Shell.php index 5d56276..d670c1c 100644 --- a/src/Shell/Shell.php +++ b/src/Shell/Shell.php @@ -10,7 +10,7 @@ class Shell { public static function run($task, $directory = null) { - $process = static::makeProcess($task, $directory); + $process = self::makeProcess($task, $directory); $process->setTimeout(3600); $process->run(); @@ -24,7 +24,7 @@ public static function run($task, $directory = null) return $process->getOutput(); } - private function makeProcess($task, $directory) + private static function makeProcess($task, $directory) { $reflection = new ReflectionClass(Process::class); $params = $reflection->getConstructor()->getParameters(); From e1637a41b24d7da36e55b117a83d167de16a9677 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 3 Jan 2021 02:03:04 +0100 Subject: [PATCH 090/101] CI: Stop using deprecated Composer option --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dd2b85..0ebc99a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Validate Composer files run: composer validate --no-check-all --strict - name: Install Composer dependencies - run: composer install --prefer-dist --no-progress --no-suggest + run: composer install --prefer-dist --no-progress - name: Run tests run: php vendor/bin/phpspec run From 0309c1a69968f7cd291c0768f0fc95639ec81ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?imme=C3=ABmosol?= Date: Thu, 11 Feb 2021 20:56:55 +0100 Subject: [PATCH 091/101] account for glob in studio load wildcard/* example (#109) add quotes so many shells will refrain from expanding the asterisk to multiple paths --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index feb62d2..e973539 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ This is what will happen under the hood: **Pro tip:** If you keep all your libraries in one directory, you can let Studio find all of them by using a wildcard: - $ studio load path/to/my/libraries/* + $ studio load 'path/to/my/libraries/*' #### Kickstarting package development From 5b765a089fdfd8a16beb3e25d4a05278e8d3297a Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 9 Feb 2022 21:17:27 +0100 Subject: [PATCH 092/101] CI: Test with PHP 8.1, too --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ebc99a..3c564d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [7.2, 7.3, 7.4, 8.0] + php: [7.2, 7.3, 7.4, 8.0, 8.1] steps: - uses: actions/checkout@v1 - uses: shivammathur/setup-php@v2 From 33c01976b934c892d76c5b47ebdef5578613fb68 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 9 Feb 2022 21:20:36 +0100 Subject: [PATCH 093/101] Allow phpspec v7 for PHP 8.1 compatibility --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bb1e9c3..9639fa0 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "composer/composer": "1.10.x-dev", - "phpspec/phpspec": "^6.3" + "phpspec/phpspec": "^6.3 || ^7.0" }, "replace": { "franzliedke/studio": "self.version" From 1314350e9b6e1311fa474872c863b0799b7e2e5c Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 9 Feb 2022 23:25:00 +0300 Subject: [PATCH 094/101] Allow Symfony 6.0 (#112) --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 9639fa0..0c531ee 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,9 @@ "require": { "php": ">=7.0", "composer-plugin-api": "^1.0 || ^2.0", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" + "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", + "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0", + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { "composer/composer": "1.10.x-dev", From a9c6bb7589ff378890842fef3b3c40b406eaac62 Mon Sep 17 00:00:00 2001 From: Bauke van der Woude <6784391+baukevdw@users.noreply.github.com> Date: Tue, 26 Jul 2022 12:36:03 +0200 Subject: [PATCH 095/101] Fix LogicException for composer ^2.3 Fixes #115 --- src/Composer/StudioPlugin.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 1730db1..1db34ae 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -58,11 +58,23 @@ public function registerStudioPackages() foreach ($this->getManagedPaths() as $path) { $this->io->writeError("[Studio] Loading path $path"); - $repoManager->prependRepository(new PathRepository( - ['url' => $path], - $this->io, - $composerConfig - )); + // In case composer version >= 2.3.0 + if (method_exists($this->composer, 'getLoop')) { + $repoManager->prependRepository(new PathRepository( + ['url' => $path], + $this->io, + $composerConfig, + $this->composer->getLoop()->getHttpDownloader(), + $this->composer->getEventDispatcher(), + $this->composer->getLoop()->getProcessExecutor() + )); + } else { + $repoManager->prependRepository(new PathRepository( + ['url' => $path], + $this->io, + $composerConfig + )); + } } } From 0673ec82a2407c5292ccdc58079fa9b8953b02ee Mon Sep 17 00:00:00 2001 From: Bauke van der Woude <6784391+baukevdw@users.noreply.github.com> Date: Tue, 26 Jul 2022 23:56:44 +0200 Subject: [PATCH 096/101] Fix deprecation notice in php 8.1 (#117) Fixes #113 --- src/Composer/StudioPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 1730db1..50db6ba 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -73,7 +73,7 @@ public function registerStudioPackages() */ private function getManagedPaths() { - $targetDir = realpath($this->composer->getPackage()->getTargetDir()); + $targetDir = realpath($this->composer->getPackage()->getTargetDir() ?? ''); $config = Config::make("{$targetDir}/studio.json"); return $config->getPaths(); From 970db71441c9e9adf5e584bd9c4461a673cb3c4a Mon Sep 17 00:00:00 2001 From: Bart Reunes Date: Fri, 26 Aug 2022 21:29:30 +0200 Subject: [PATCH 097/101] change the path argument into a required array argument --- src/Console/LoadCommand.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Console/LoadCommand.php b/src/Console/LoadCommand.php index 8ca00ff..dc5048a 100644 --- a/src/Console/LoadCommand.php +++ b/src/Console/LoadCommand.php @@ -24,17 +24,17 @@ protected function configure() ->setDescription('Load a path to be managed with Studio') ->addArgument( 'path', - InputArgument::REQUIRED, - 'The path where the package files are located' + InputArgument::IS_ARRAY | InputArgument::REQUIRED, + 'The path(s) where the package files are located' ); } protected function fire() { - $this->config->addPath( - $path = $this->input->getArgument('path') - ); - - $this->io->success("Packages matching the path $path will now be loaded by Composer."); + foreach ($this->input->getArgument('path') as $path) { + $this->config->addPath($path); + + $this->io->success("Packages matching the path $path will now be loaded by Composer."); + } } } From fb3d368704e559e447d96a746b346fb13ddeded1 Mon Sep 17 00:00:00 2001 From: Bart Reunes Date: Fri, 26 Aug 2022 21:32:08 +0200 Subject: [PATCH 098/101] change the path argument into a required array argument --- src/Console/UnloadCommand.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Console/UnloadCommand.php b/src/Console/UnloadCommand.php index 2f978de..1d1aff3 100644 --- a/src/Console/UnloadCommand.php +++ b/src/Console/UnloadCommand.php @@ -23,17 +23,17 @@ protected function configure() ->setDescription('Unload a package path from being managed with Studio') ->addArgument( 'path', - InputArgument::REQUIRED, - 'The path where the package files are located' + InputArgument::IS_ARRAY | InputArgument::REQUIRED, + 'The path(s) where the package files are located' ); } protected function fire() { - $this->config->removePath( - $path = $this->input->getArgument('path') - ); - - $this->io->success("Packages matching the path $path will no longer be loaded by Composer."); + foreach ($this->input->getArgument('path') as $path) { + $this->config->removePath($path); + + $this->io->success("Packages matching the path $path will no longer be loaded by Composer."); + } } } From a9f2f34135383c010f2ad714bfcdbea6bccd927b Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 12 Oct 2022 12:13:31 +0200 Subject: [PATCH 099/101] Extend comment about loop integration --- src/Composer/StudioPlugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 1db34ae..a9f3ddc 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -58,7 +58,8 @@ public function registerStudioPackages() foreach ($this->getManagedPaths() as $path) { $this->io->writeError("[Studio] Loading path $path"); - // In case composer version >= 2.3.0 + // Composer v2 always exposes the internal loop, so keep reusing it + // that is a fixed requirement since Composer >= 2.3 if (method_exists($this->composer, 'getLoop')) { $repoManager->prependRepository(new PathRepository( ['url' => $path], From 735e94f59e17ecac3cd86ac916a44ec90ef031d0 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 12 Oct 2022 12:13:41 +0200 Subject: [PATCH 100/101] Use Composer v2 when developing --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0c531ee..3ac6eab 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "composer/composer": "1.10.x-dev", + "composer/composer": "^2.4.2", "phpspec/phpspec": "^6.3 || ^7.0" }, "replace": { From d0b983e4633bb32bf0747fd3649e35dafc67b28d Mon Sep 17 00:00:00 2001 From: Kennard Vermeiren <5852381+kennaar@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:23:19 +0200 Subject: [PATCH 101/101] Allow symfony/* ^7.0 version (#124) Co-authored-by: Kennard Vermeiren --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3ac6eab..499fc1e 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,11 @@ } }, "require": { - "php": ">=7.0", + "php": "^7.0 || ^8.0", "composer-plugin-api": "^1.0 || ^2.0", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/filesystem": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "composer/composer": "^2.4.2",