From 7815d74c2c01cd6fff14669b704065bf47e72eb3 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Sat, 10 Jun 2017 13:03:19 -0700 Subject: [PATCH 1/2] [console] Fix package. --- src/Command/Shared/InputTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/Shared/InputTrait.php b/src/Command/Shared/InputTrait.php index 5d0907f..622d0f3 100644 --- a/src/Command/Shared/InputTrait.php +++ b/src/Command/Shared/InputTrait.php @@ -10,7 +10,7 @@ /** * Class InputTrait * - * @package Drupal\Console\Core\Command + * @package Drupal\Console\Core\Command\Shared */ trait InputTrait { From b75cb7fb1ba252c3e49c736807eea29f0aca770a Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Tue, 20 Jun 2017 01:35:49 -0700 Subject: [PATCH 2/2] [console] Add webmozart/path-util dependency. --- composer.json | 3 +- composer.lock | 98 +++++++++++++++++++++++++++++- src/Utils/ConfigurationManager.php | 23 ++----- 3 files changed, 104 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 359ac1f..7d36a21 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,8 @@ "symfony/yaml": ">=2.7 <3.0", "symfony/event-dispatcher": ">=2.7 <3.0", "twig/twig": "^1.23.1", - "webflo/drupal-finder": "^0.3.0" + "webflo/drupal-finder": "^0.3.0", + "webmozart/path-util": "^2.3" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/composer.lock b/composer.lock index 1b4ecd8..4f65fe3 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "5378635239d17fe962f215288baee221", + "content-hash": "88c2fa1e120bd53d8ea20d4cba060bdf", "packages": [ { "name": "dflydev/dot-access-configuration", @@ -1036,6 +1036,102 @@ ], "description": "Helper class to locate a Drupal installation from a given path.", "time": "2017-05-04T08:54:02+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23T20:04:58+00:00" + }, + { + "name": "webmozart/path-util", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/path-util.git", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "webmozart/assert": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\PathUtil\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "time": "2015-12-17T08:42:14+00:00" } ], "packages-dev": [], diff --git a/src/Utils/ConfigurationManager.php b/src/Utils/ConfigurationManager.php index abb2fe8..5811a49 100644 --- a/src/Utils/ConfigurationManager.php +++ b/src/Utils/ConfigurationManager.php @@ -7,6 +7,7 @@ use Symfony\Component\Finder\Finder; use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder; use Dflydev\DotAccessConfiguration\ConfigurationInterface; +use Webmozart\PathUtil\Path; /** * Class ConfigurationManager. @@ -44,7 +45,7 @@ class ConfigurationManager */ public function loadConfiguration($applicationDirectory) { - $homeConfig = $this->getHomeDirectory() . '/.console/'; + $homeConfig = Path::getHomeDirectory() . '/.console/'; if (!is_dir($homeConfig)) { mkdir($homeConfig, 0777); } @@ -57,7 +58,7 @@ public function loadConfiguration($applicationDirectory) $configurationDirectories[] = $applicationDirectory.DRUPAL_CONSOLE_CORE; $configurationDirectories[] = $applicationDirectory.DRUPAL_CONSOLE; $configurationDirectories[] = '/etc/console/'; - $configurationDirectories[] = $this->getHomeDirectory() . '/.console/'; + $configurationDirectories[] = Path::getHomeDirectory() . '/.console/'; $configurationDirectories[] = $applicationDirectory .'/console/'; if ($root) { $configurationDirectories[] = $root . '/console/'; @@ -148,20 +149,6 @@ public function readTarget($target) ); } - /** - * Return the user home directory. - * - * @return string - */ - public function getHomeDirectory() - { - if (function_exists('posix_getuid')) { - return posix_getpwuid(posix_getuid())['dir']; - } - - return realpath(rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\')); - } - /** * @return string */ @@ -238,7 +225,7 @@ public function readDrushEquivalents($commandName) */ public function getConsoleDirectory() { - return sprintf('%s/.console/', $this->getHomeDirectory()); + return sprintf('%s/.console/', Path::getHomeDirectory()); } /** @@ -286,7 +273,7 @@ public function appendCommandAliases() public function loadExtendConfiguration() { - $directory = $this->getHomeDirectory() . '/.console/extend/'; + $directory = Path::getHomeDirectory() . '/.console/extend/'; if (!is_dir($directory)) { return null; }