Hello community, here is the log from the commit of package platformsh-cli for openSUSE:Factory checked in at 2017-05-31 12:21:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/platformsh-cli (Old) and /work/SRC/openSUSE:Factory/.platformsh-cli.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "platformsh-cli" Wed May 31 12:21:32 2017 rev:13 rq:499785 version:3.17.0 Changes: -------- --- /work/SRC/openSUSE:Factory/platformsh-cli/platformsh-cli.changes 2017-05-22 10:48:58.936239266 +0200 +++ /work/SRC/openSUSE:Factory/.platformsh-cli.new/platformsh-cli.changes 2017-05-31 12:21:37.640433323 +0200 @@ -1,0 +2,10 @@ +Tue May 30 14:14:44 UTC 2017 - jimmy@boombatower.com + +- Update to version 3.17.0: + * Update console-form dependency + * Docs search now needs rawurlencode() + * Improve default Drush aliases on cloning (#603) + * Add environment:init command + * Release v3.17.0 + +------------------------------------------------------------------- Old: ---- platformsh-cli-3.16.2.tar.xz New: ---- platformsh-cli-3.17.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ platformsh-cli.spec ++++++ --- /var/tmp/diff_new_pack.Wjr5j8/_old 2017-05-31 12:21:38.312338473 +0200 +++ /var/tmp/diff_new_pack.Wjr5j8/_new 2017-05-31 12:21:38.312338473 +0200 @@ -17,7 +17,7 @@ Name: platformsh-cli -Version: 3.16.2 +Version: 3.17.0 Release: 0 Summary: Tool for managing Platform.sh services from the command line # See licenses.txt for dependency licenses. ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Wjr5j8/_old 2017-05-31 12:21:38.348333392 +0200 +++ /var/tmp/diff_new_pack.Wjr5j8/_new 2017-05-31 12:21:38.348333392 +0200 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">refs/tags/v3.16.2</param> + <param name="revision">refs/tags/v3.17.0</param> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Wjr5j8/_old 2017-05-31 12:21:38.372330004 +0200 +++ /var/tmp/diff_new_pack.Wjr5j8/_new 2017-05-31 12:21:38.372330004 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> - <param name="changesrevision">74265f2f14e1f2355371c9ad2c9117d01c28fe24</param> + <param name="changesrevision">d208570716b87cf061e296d346c0dd342aa3c1ba</param> </service> </servicedata> ++++++ licenses.txt ++++++ --- /var/tmp/diff_new_pack.Wjr5j8/_old 2017-05-31 12:21:38.416323793 +0200 +++ /var/tmp/diff_new_pack.Wjr5j8/_new 2017-05-31 12:21:38.420323229 +0200 @@ -15,8 +15,8 @@ guzzlehttp/streams 3.0.0 MIT padraic/humbug_get_contents 1.0.4 BSD-3-Clause padraic/phar-updater 1.0.3 BSD-3-Clause -platformsh/client v0.10.2 MIT -platformsh/console-form v0.0.8 MIT +platformsh/client v0.10.3 MIT +platformsh/console-form v0.0.10 MIT psr/log 1.0.2 MIT react/promise v2.5.1 MIT stecman/symfony-console-completion 0.7.0 MIT ++++++ platformsh-cli-3.16.2.tar.xz -> platformsh-cli-3.17.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/composer.json new/platformsh-cli-3.17.0/composer.json --- old/platformsh-cli-3.16.2/composer.json 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/composer.json 2017-05-30 14:25:44.000000000 +0200 @@ -7,7 +7,7 @@ "doctrine/cache": "~1.5", "guzzlehttp/guzzle": "^5.3", "guzzlehttp/ringphp": "^1.1", - "platformsh/console-form": "0.0.8", + "platformsh/console-form": "0.0.10", "platformsh/client": "^0.10", "symfony/console": "^3.0 !=3.2.5 !=3.2.6", "symfony/yaml": "^3.0 || ^2.6", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/composer.lock new/platformsh-cli-3.17.0/composer.lock --- old/platformsh-cli-3.16.2/composer.lock 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/composer.lock 2017-05-30 14:25:44.000000000 +0200 @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "c3322283a273a90a18178d15f6e44acc", + "content-hash": "2f96c4c4c7449d8115643ed6246dff2b", "packages": [ { "name": "cocur/slugify", @@ -593,16 +593,16 @@ }, { "name": "platformsh/client", - "version": "v0.10.2", + "version": "v0.10.3", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "69e90df40fe201469473a467420557aa9bb6bcd0" + "reference": "a9f8d69635b72869ce2931c57cef4bd1c5cbea8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/69e90d...", - "reference": "69e90df40fe201469473a467420557aa9bb6bcd0", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/a9f8d6...", + "reference": "a9f8d69635b72869ce2931c57cef4bd1c5cbea8f", "shasum": "" }, "require": { @@ -638,20 +638,20 @@ } ], "description": "Platform.sh API client", - "time": "2017-05-10T12:14:35+00:00" + "time": "2017-05-30T10:45:57+00:00" }, { "name": "platformsh/console-form", - "version": "v0.0.8", + "version": "v0.0.10", "source": { "type": "git", "url": "https://github.com/platformsh/console-form.git", - "reference": "7e9daa322d6c3d9cb939dfb7749d975e0d242205" + "reference": "6c4af8274d97fb7e9c4eaa8d0a72e79f4bbef0f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/console-form/zipball/7e9daa322d6c3d9...", - "reference": "7e9daa322d6c3d9cb939dfb7749d975e0d242205", + "url": "https://api.github.com/repos/platformsh/console-form/zipball/6c4af8274d97fb7...", + "reference": "6c4af8274d97fb7e9c4eaa8d0a72e79f4bbef0f9", "shasum": "" }, "require": { @@ -676,7 +676,7 @@ } ], "description": "A lightweight Symfony Console form system.", - "time": "2016-02-25T11:38:45+00:00" + "time": "2017-04-02T11:43:41+00:00" }, { "name": "psr/log", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/config.yaml new/platformsh-cli-3.17.0/config.yaml --- old/platformsh-cli-3.16.2/config.yaml 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/config.yaml 2017-05-30 14:25:44.000000000 +0200 @@ -1,7 +1,7 @@ # Metadata about the CLI application itself. application: name: 'Platform.sh CLI' - version: '3.16.2' + version: '3.17.0' executable: 'platform' package_name: 'platformsh/cli' installer_url: 'https://platform.sh/cli/installer' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/src/Application.php new/platformsh-cli-3.17.0/src/Application.php --- old/platformsh-cli-3.16.2/src/Application.php 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/src/Application.php 2017-05-30 14:25:44.000000000 +0200 @@ -117,6 +117,7 @@ $commands[] = new Command\Environment\EnvironmentListCommand(); $commands[] = new Command\Environment\EnvironmentLogCommand(); $commands[] = new Command\Environment\EnvironmentInfoCommand(); + $commands[] = new Command\Environment\EnvironmentInitCommand(); $commands[] = new Command\Environment\EnvironmentMergeCommand(); $commands[] = new Command\Environment\EnvironmentPushCommand(); $commands[] = new Command\Environment\EnvironmentRelationshipsCommand(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/src/Command/DocsCommand.php new/platformsh-cli-3.17.0/src/Command/DocsCommand.php --- old/platformsh-cli-3.16.2/src/Command/DocsCommand.php 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/src/Command/DocsCommand.php 2017-05-30 14:25:44.000000000 +0200 @@ -24,7 +24,7 @@ { if ($searchArguments = $input->getArgument('search')) { $query = $this->getSearchQuery($searchArguments); - $url = str_replace('{{ terms }}', urlencode($query), $this->config()->get('service.docs_search_url')); + $url = str_replace('{{ terms }}', rawurlencode($query), $this->config()->get('service.docs_search_url')); } else { $url = $this->config()->get('service.docs_url'); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/src/Command/Environment/EnvironmentInitCommand.php new/platformsh-cli-3.17.0/src/Command/Environment/EnvironmentInitCommand.php --- old/platformsh-cli-3.16.2/src/Command/Environment/EnvironmentInitCommand.php 1970-01-01 01:00:00.000000000 +0100 +++ new/platformsh-cli-3.17.0/src/Command/Environment/EnvironmentInitCommand.php 2017-05-30 14:25:44.000000000 +0200 @@ -0,0 +1,65 @@ +setName('environment:init') + ->addArgument('url', InputArgument::REQUIRED, 'A URL to a Git repository') + ->addOption('profile', null, InputOption::VALUE_REQUIRED, 'The name of the profile'); + $this->addProjectOption() + ->addEnvironmentOption() + ->addNoWaitOption(); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->validateInput($input, true); + if (!$this->hasSelectedEnvironment()) { + $this->selectEnvironment('master'); + } + + $environment = $this->getSelectedEnvironment(); + + $url = $input->getArgument('url'); + $profile = $input->getOption('profile') ?: basename($url); + + if (parse_url($url) === false) { + $this->stdErr->writeln(sprintf('Invalid repository URL: <error>%s</error>', $url)); + + return 1; + } + + try { + $activity = $environment->initialize($profile, $url); + } catch (OperationUnavailableException $e) { + if ($environment->has_code) { + $this->stdErr->writeln(sprintf('The environment <error>%s</error> cannot be initialized: it already contains code.', $environment->id)); + + return 1; + } + + throw $e; + } + + /** @var \Platformsh\Cli\Service\ActivityMonitor $activityMonitor */ + $activityMonitor = $this->getService('activity_monitor'); + $activityMonitor->waitAndLog($activity); + + return 0; + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/src/Command/Local/LocalDrushAliasesCommand.php new/platformsh-cli-3.17.0/src/Command/Local/LocalDrushAliasesCommand.php --- old/platformsh-cli-3.16.2/src/Command/Local/LocalDrushAliasesCommand.php 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/src/Command/Local/LocalDrushAliasesCommand.php 2017-05-30 14:25:44.000000000 +0200 @@ -1,6 +1,7 @@ ensureInstalled(); $aliases = $drush->getAliases($current_group); + if (!$aliases && !$new_group && $project && $current_group === $project->id) { + $new_group = (new Slugify())->slugify($project->title); + } if (($new_group && $new_group != $current_group) || !$aliases || $input->getOption('recreate')) { $new_group = $new_group ?: $current_group; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.16.2/src/Command/Project/ProjectGetCommand.php new/platformsh-cli-3.17.0/src/Command/Project/ProjectGetCommand.php --- old/platformsh-cli-3.16.2/src/Command/Project/ProjectGetCommand.php 2017-05-19 23:57:49.000000000 +0200 +++ new/platformsh-cli-3.17.0/src/Command/Project/ProjectGetCommand.php 2017-05-30 14:25:44.000000000 +0200 @@ -3,6 +3,7 @@ use Cocur\Slugify\Slugify; use Platformsh\Cli\Command\CommandBase; +use Platformsh\Cli\Exception\DependencyMissingException; use Platformsh\Cli\Local\BuildFlavor\Drupal; use Platformsh\Cli\Service\Ssh; use Symfony\Component\Console\Exception\InvalidArgumentException; @@ -150,14 +151,11 @@ // Ensure that Drush aliases are created. if (Drupal::isDrupal($projectRoot)) { $this->stdErr->writeln(''); - $this->runOtherCommand( - 'local:drush-aliases', - [ - // The default Drush alias group is the final part of the - // directory path. - '--group' => basename($projectRoot), - ] - ); + try { + $this->runOtherCommand('local:drush-aliases'); + } catch (DependencyMissingException $e) { + $this->stdErr->writeln(sprintf('<comment>%s</comment>', $e->getMessage())); + } } // Launch the first build. ++++++ platformsh-cli-vendor.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/autoload.php new/vendor/autoload.php --- old/vendor/autoload.php 2017-05-20 01:07:43.128812069 +0200 +++ new/vendor/autoload.php 2017-05-30 16:18:50.145942530 +0200 @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit828ef1533433a8420b9a137d399ff7b3::getLoader(); +return ComposerAutoloaderInit2b8af07a6bcb5c85efd6d055d31a81f6::getLoader(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_real.php new/vendor/composer/autoload_real.php --- old/vendor/composer/autoload_real.php 2017-05-20 01:07:43.128812069 +0200 +++ new/vendor/composer/autoload_real.php 2017-05-30 16:18:50.145942530 +0200 @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit828ef1533433a8420b9a137d399ff7b3 +class ComposerAutoloaderInit2b8af07a6bcb5c85efd6d055d31a81f6 { private static $loader; @@ -19,15 +19,15 @@ return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit828ef1533433a8420b9a137d399ff7b3', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit2b8af07a6bcb5c85efd6d055d31a81f6', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit828ef1533433a8420b9a137d399ff7b3', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit2b8af07a6bcb5c85efd6d055d31a81f6', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit828ef1533433a8420b9a137d399ff7b3::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit828ef1533433a8420b9a137d399ff7b3::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire828ef1533433a8420b9a137d399ff7b3($fileIdentifier, $file); + composerRequire2b8af07a6bcb5c85efd6d055d31a81f6($fileIdentifier, $file); } return $loader; } } -function composerRequire828ef1533433a8420b9a137d399ff7b3($fileIdentifier, $file) +function composerRequire2b8af07a6bcb5c85efd6d055d31a81f6($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_static.php new/vendor/composer/autoload_static.php --- old/vendor/composer/autoload_static.php 2017-05-20 01:07:43.128812069 +0200 +++ new/vendor/composer/autoload_static.php 2017-05-30 16:18:50.145942530 +0200 @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit828ef1533433a8420b9a137d399ff7b3 +class ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6 { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -183,9 +183,9 @@ public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit828ef1533433a8420b9a137d399ff7b3::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit828ef1533433a8420b9a137d399ff7b3::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit828ef1533433a8420b9a137d399ff7b3::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit2b8af07a6bcb5c85efd6d055d31a81f6::$classMap; }, null, ClassLoader::class); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/installed.json new/vendor/composer/installed.json --- old/vendor/composer/installed.json 2017-05-20 01:07:42.480806918 +0200 +++ new/vendor/composer/installed.json 2017-05-30 16:18:49.969940825 +0200 @@ -656,17 +656,17 @@ }, { "name": "platformsh/client", - "version": "v0.10.2", - "version_normalized": "0.10.2.0", + "version": "v0.10.3", + "version_normalized": "0.10.3.0", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "69e90df40fe201469473a467420557aa9bb6bcd0" + "reference": "a9f8d69635b72869ce2931c57cef4bd1c5cbea8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/69e90d...", - "reference": "69e90df40fe201469473a467420557aa9bb6bcd0", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/a9f8d6...", + "reference": "a9f8d69635b72869ce2931c57cef4bd1c5cbea8f", "shasum": "" }, "require": { @@ -679,7 +679,7 @@ "require-dev": { "phpunit/phpunit": "~4.5" }, - "time": "2017-05-10T12:14:35+00:00", + "time": "2017-05-30T10:45:57+00:00", "type": "library", "extra": { "patches": { @@ -941,17 +941,17 @@ }, { "name": "platformsh/console-form", - "version": "v0.0.8", - "version_normalized": "0.0.8.0", + "version": "v0.0.10", + "version_normalized": "0.0.10.0", "source": { "type": "git", "url": "https://github.com/platformsh/console-form.git", - "reference": "7e9daa322d6c3d9cb939dfb7749d975e0d242205" + "reference": "6c4af8274d97fb7e9c4eaa8d0a72e79f4bbef0f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/console-form/zipball/7e9daa322d6c3d9...", - "reference": "7e9daa322d6c3d9cb939dfb7749d975e0d242205", + "url": "https://api.github.com/repos/platformsh/console-form/zipball/6c4af8274d97fb7...", + "reference": "6c4af8274d97fb7e9c4eaa8d0a72e79f4bbef0f9", "shasum": "" }, "require": { @@ -960,7 +960,7 @@ "require-dev": { "phpunit/phpunit": "~4" }, - "time": "2016-02-25T11:38:45+00:00", + "time": "2017-04-02T11:43:41+00:00", "type": "library", "installation-source": "dist", "autoload": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Activity.php new/vendor/platformsh/client/src/Model/Activity.php --- old/vendor/platformsh/client/src/Model/Activity.php 2017-05-10 14:14:35.000000000 +0200 +++ new/vendor/platformsh/client/src/Model/Activity.php 2017-05-30 12:45:57.000000000 +0200 @@ -195,7 +195,7 @@ return sprintf( '%s initialized environment %s with profile %s', $payload['user']['display_name'], - $payload['outcome']['title'], + $payload['environment']['title'], $payload['profile'] ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/.travis.yml new/vendor/platformsh/console-form/.travis.yml --- old/vendor/platformsh/console-form/.travis.yml 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/.travis.yml 2017-04-02 13:43:41.000000000 +0200 @@ -1,14 +1,10 @@ language: php php: - - 5.4 - 5.5 - 5.6 - hhvm - 7.0 -matrix: - allow_failures: - - php: 7.0 - fast_finish: true + - 7.1 sudo: false cache: directories: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/README.md new/vendor/platformsh/console-form/README.md --- old/vendor/platformsh/console-form/README.md 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/README.md 2017-04-02 13:43:41.000000000 +0200 @@ -4,7 +4,7 @@ Commands can define forms which can be used both via command-line options and via interactive input. -[![Build Status](https://travis-ci.org/pjcdawkins/console-form.svg?branch=master)](https://travis-ci.org/pjcdawkins/console-form) +[![Build Status](https://travis-ci.org/platformsh/console-form.svg?branch=master)](https://travis-ci.org/platformsh/console-form) ## Example ```php diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/BooleanField.php new/vendor/platformsh/console-form/src/Field/BooleanField.php --- old/vendor/platformsh/console-form/src/Field/BooleanField.php 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/BooleanField.php 2017-04-02 13:43:41.000000000 +0200 @@ -2,6 +2,8 @@ namespace Platformsh\ConsoleForm\Field; +use Platformsh\ConsoleForm\Exception\InvalidValueException; + class BooleanField extends Field { public $default = true; @@ -22,8 +24,21 @@ */ protected function normalize($value) { - $false = ['false', '0', 'no', 'n']; - - return !in_array(strtolower($value), $false); + if (is_bool($value)) { + return $value; + } + elseif (preg_match('/^(0|false|no|n)$/i', $value)) { + return false; + } + elseif (preg_match('/^(1|true|yes|y)$/i', $value)) { + return true; + } + else { + throw new InvalidValueException(sprintf( + "Invalid value for '%s': %s (expected 1, 0, true, or false)", + $this->name, + $value + )); + } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/Field.php new/vendor/platformsh/console-form/src/Field/Field.php --- old/vendor/platformsh/console-form/src/Field/Field.php 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/Field.php 2017-04-02 13:43:41.000000000 +0200 @@ -61,6 +61,16 @@ protected $default; /** + * A callback used to calculate a dynamic default. + * + * The callback accepts an array of values entered previously for other form + * fields. It returns the new default. + * + * @var callable + */ + protected $defaultCallback; + + /** * Validator callbacks. * * @see self::validate() @@ -117,25 +127,40 @@ { $this->name = $name; foreach ($config as $key => $value) { - switch ($key) { - case 'validator': - $this->validators[] = $value; - break; - - case 'normalizer': - $this->normalizers[] = $value; - break; - - default: - if (!property_exists($this, $key)) { - throw new \InvalidArgumentException("Unrecognized config key: $key"); - } - $this->$key = $value; - } + $this->set($key, $value); } } /** + * Set or modify a configuration value. + * + * @param string $key + * @param mixed $value + * + * @return self + */ + public function set($key, $value) + { + switch ($key) { + case 'validator': + $this->validators[] = $value; + break; + + case 'normalizer': + $this->normalizers[] = $value; + break; + + default: + if (!property_exists($this, $key)) { + throw new \InvalidArgumentException("Unrecognized config key: $key"); + } + $this->$key = $value; + } + + return $this; + } + + /** * Get the field's conditions. * * @return array @@ -366,4 +391,17 @@ { return $this->name; } + + /** + * React to a change in user input. + * + * @param array $previousValues + */ + public function onChange(array $previousValues) + { + if (isset($this->defaultCallback)) { + $callback = $this->defaultCallback; + $this->default = $callback($previousValues); + } + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Field/OptionsField.php new/vendor/platformsh/console-form/src/Field/OptionsField.php --- old/vendor/platformsh/console-form/src/Field/OptionsField.php 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Field/OptionsField.php 2017-04-02 13:43:41.000000000 +0200 @@ -10,6 +10,16 @@ protected $asChoice = true; /** + * A callback used to calculate dynamic options. + * + * The callback accepts an array of values entered previously for other form + * fields. It returns the new options, as an array. + * + * @var callable + */ + protected $optionsCallback; + + /** * {@inheritdoc} */ public function __construct($name, array $config = []) @@ -65,4 +75,15 @@ return $question; } + + /** + * {@inheritdoc} + */ + public function onChange(array $previousValues) + { + if (isset($this->optionsCallback)) { + $callback = $this->optionsCallback; + $this->options = $callback($previousValues); + } + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/src/Form.php new/vendor/platformsh/console-form/src/Form.php --- old/vendor/platformsh/console-form/src/Form.php 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/src/Form.php 2017-04-02 13:43:41.000000000 +0200 @@ -107,6 +107,8 @@ { $values = []; foreach ($this->fields as $key => $field) { + $field->onChange($values); + if (!$this->includeField($field, $values)) { continue; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/console-form/tests/FormTest.php new/vendor/platformsh/console-form/tests/FormTest.php --- old/vendor/platformsh/console-form/tests/FormTest.php 2016-02-25 12:38:45.000000000 +0100 +++ new/vendor/platformsh/console-form/tests/FormTest.php 2017-04-02 13:43:41.000000000 +0200 @@ -47,6 +47,11 @@ 'with_default' => new Field('Field with default', [ 'default' => 'defaultValue', ]), + 'with_dynamic_default' => new Field('Field with dynamic default', [ + 'defaultCallback' => function (array $values) { + return $values['test_field']; + }, + ]), 'bool' => new BooleanField('Boolean field', [ 'optionName' => 'bool', 'required' => false, @@ -63,6 +68,7 @@ 'bool' => true, 'array' => [], 'with_default' => 'defaultValue', + 'with_dynamic_default' => $this->validString, ]; } @@ -126,7 +132,7 @@ $output = new NullOutput(); $helper->setInputStream($this->getInputStream( - "{$this->validString}\n{$this->validMail}\n" . str_repeat("\n", count($this->fields) - 2) + "{$this->validString}\n{$this->validMail}\n" . str_repeat("\n", count($this->form->getFields()) - 2) )); $result = $this->form->resolveOptions($input, $output, $helper); $this->assertEquals($this->validResult, $result, 'Valid input passes'); @@ -141,7 +147,7 @@ $input = new ArrayInput(['--mail' => $this->validMail], $definition); $helper->setInputStream($this->getInputStream( - "{$this->validString}\n" . str_repeat("\n", count($this->fields) - 1) + "{$this->validString}\n" . str_repeat("\n", count($this->form->getFields()) - 1) )); $result = $this->form->resolveOptions($input, $output, $helper); $this->assertEquals($this->validResult, $result, 'Valid input passes'); @@ -276,6 +282,7 @@ { $helper = $this->getQuestionHelper(); $definition = new InputDefinition(); + $countFieldsBefore = count($this->form->getFields()); $this->form->addField(new OptionsField('Options', [ 'options' => ['option1', 'option2', 'option3'], ]), 'options'); @@ -298,7 +305,7 @@ '--test' => $this->validString, '--mail' => $this->validMail, ], $definition); - $helper->setInputStream($this->getInputStream("\n\n\n1")); + $helper->setInputStream($this->getInputStream(str_repeat("\n", $countFieldsBefore) . '1')); $result = $this->form->resolveOptions($input, $output, $helper); $validResult = $this->validResult + ['options' => 'option2']; $this->assertEquals($validResult, $result, 'Valid interactive option input'); @@ -343,6 +350,26 @@ new Field('Test field', ['invalid' => 'invalid']); } + public function testOverrideField() + { + $fields = $this->fields; + $validResult = $this->validResult; + $validResult['test_field'] = 'Default result for test_field'; + $validResult['with_dynamic_default'] = $validResult['test_field']; + $validResult['email'] = 'test-default@example.com'; + $fields['test_field']->set('default', $validResult['test_field']); + $fields['email']->set('default', $validResult['email']); + + $definition = new InputDefinition(); + $this->form = Form::fromArray($fields); + $this->form->configureInputDefinition($definition); + + $input = new ArrayInput([], $definition); + $input->setInteractive(false); + $result = $this->form->resolveOptions($input, new NullOutput(), $this->getQuestionHelper()); + $this->assertEquals($validResult, $result, 'Empty input passes'); + } + /** * @return QuestionHelper */