diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc53e970..497817c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,27 @@ #Change Log All notable changes to this project starting with the 0.6.0 release will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org) -## MASTER +### [0.12.0] - 2016-08-24 +### Added +- Added `choices` property to `InputHelper::siteName` parameter object. (#1152) +- Added `TerminusCollection::listing` to create a list of models therein. (#1152) +- Added `UserSiteMemberships` collection and `UserSiteMembership` model. (#1152) +- Added `UserOrganizationMemberships` collection and `UserOrganizationMembership` model. (#1152) + +### Changed +- Renamed `Sites::addSite` to `Sites::create`. (#1152) +- Renamed `OrganizationUserMemberships::addMember` to `OrganizationUserMemberships::create`. (#1152) +- Renamed `OrganizationSiteMemberships::addMember` to `OrganizationSiteMemberships::create`. (#1152) +- When using the sites collection to gather all sites, you now must use `Sites::fetch()` to retrieve the relevant objects. (#1152) +- Renamed `OrganizationSiteMembership::removeMember` to `OrganizationSiteMembership::delete`. (#1152) +- Renamed `OrganizationUserMembership::removeMember` to `OrganizationUserMembership::delete`. (#1152) +- Remamed `Sites::filterAllByTag` to `Sites::filterByTag`. (#1152) +- Renamed `UserOrganizationMemberships::get` to `UserOrganizationMemberships::getOrganization`. (#1152) +- `Sites::get` no longer fetches all sites to find the named site. (#1152) + ### Removed - `cli cache-clear` command. (#1152) +- The `SitesCache` class and all site cache-relevant functions have been removed. (#1152) - The command `site set-php-version` has been removed. Please set your PHP version by your pantheon.yml file. (See: https://pantheon.io/docs/php-versions) (#1121) ## [0.11.4] - 2016-08-10 diff --git a/README.md b/README.md index bc21d161b..2579d61fc 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ composer require pantheon-systems/terminus Run this in this in your terminal client: ```bash -curl https://github.com/pantheon-systems/terminus/releases/download/0.11.4/terminus.phar -L -o /usr/local/bin/terminus && chmod +x /usr/local/bin/terminus +curl https://github.com/pantheon-systems/terminus/releases/download/0.12.0/terminus.phar -L -o /usr/local/bin/terminus && chmod +x /usr/local/bin/terminus ``` ####Installing with [Homebrew](http://brew.sh/)(for Macs) diff --git a/composer.lock b/composer.lock index 476063f31..f960b40e2 100644 --- a/composer.lock +++ b/composer.lock @@ -401,16 +401,16 @@ }, { "name": "psr/http-message", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "shasum": "" }, "require": { @@ -438,6 +438,7 @@ } ], "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", "keywords": [ "http", "http-message", @@ -446,7 +447,7 @@ "request", "response" ], - "time": "2015-05-04 20:22:00" + "time": "2016-08-06 14:39:51" }, { "name": "psr/log", @@ -1476,6 +1477,7 @@ "rest", "web service" ], + "abandoned": "guzzlehttp/guzzle", "time": "2014-01-28 22:29:15" }, { @@ -2360,23 +2362,23 @@ }, { "name": "sebastian/environment", - "version": "1.3.7", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4e8f0da10ac5802913afc151413bc8c53b6c2716", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { @@ -2406,7 +2408,7 @@ "environment", "hhvm" ], - "time": "2016-05-17 03:18:57" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", @@ -3215,28 +3217,29 @@ }, { "name": "webmozart/assert", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde" + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bb2d123231c095735130cc8f6d31385a44c7b308", + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3|^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -3260,7 +3263,7 @@ "check", "validate" ], - "time": "2015-08-24 13:29:44" + "time": "2016-08-09 15:02:57" } ], "aliases": [], diff --git a/config/constants.yml b/config/constants.yml index af877a33d..0d2522aea 100644 --- a/config/constants.yml +++ b/config/constants.yml @@ -7,7 +7,7 @@ --- # App -TERMINUS_VERSION: '0.11.4' +TERMINUS_VERSION: '0.12.0' # Connectivity TERMINUS_HOST: 'dashboard.pantheon.io' @@ -25,7 +25,7 @@ TERMINUS_CONFIG_DIR: '~/terminus' TERMINUS_LOG_DIR: '/tmp' TERMINUS_PLUGINS_DIR: '[[ TERMINUS_CONFIG_DIR ]]/plugins' TERMINUS_TOKENS_DIR: '[[ TERMINUS_CACHE_DIR ]]/tokens' -TERMINUS_ASSETS_DIR: '[[ TERMINUS_ROOT ]]/app/assets' +TERMINUS_ASSETS_DIR: '[[ TERMINUS_ROOT ]]/php/assets' # Helpers TERMINUS_USER: null diff --git a/docs/Helpers/InputHelper.md b/docs/Helpers/InputHelper.md index 5668557f2..002ee0539 100644 --- a/docs/Helpers/InputHelper.md +++ b/docs/Helpers/InputHelper.md @@ -288,9 +288,10 @@ ##### Parameters: [array] $arg_options Elements as follow: - -array args The args passed in from argv - -string key Args key to search for - -string message Prompt for STDOUT + -array args The args passed in from argv + -Site[] choices An array of sites to use as options + -string key Args key to search for + -string message Prompt for STDOUT ##### Return: [string] Site name diff --git a/docs/Models/Collections/OrganizationSiteMemberships.md b/docs/Models/Collections/OrganizationSiteMemberships.md index 3a1553b05..2dfda0bc4 100644 --- a/docs/Models/Collections/OrganizationSiteMemberships.md +++ b/docs/Models/Collections/OrganizationSiteMemberships.md @@ -1,6 +1,31 @@ # Terminus\Models\Collections\OrganizationSiteMemberships -### addMember +### __construct +##### Description: + Instantiates the collection + +##### Parameters: + [array] $options To be set + +##### Return: + [OrganizationSiteMemberships] + +--- + +### add +##### Description: + Adds a model to this collection + +##### Parameters: + [object] $model_data Data to feed into attributes of new model + [array] $arg_options Data to make properties of the new model + +##### Return: + [void] + +--- + +### create ##### Description: Adds a site to this organization @@ -20,19 +45,34 @@ [string] $id UUID or name of desired site membership instance ##### Return: - [Site] + [OrganizationSiteMembership] --- -### fetch +### getSite ##### Description: - Fetches model data from API and instantiates its model instances + Retrieves the matching site from model members ##### Parameters: - [array] $options params to pass to url request + [string] $site_id ID or name of desired site ##### Return: - [OrganizationSiteMemberships] + [Site] $site + +##### Throws: + TerminusException + +--- + +### siteIsMember +##### Description: + Determines whether a site is a member of this collection + +##### Parameters: + [Site] $site Site to determine membership of + +##### Return: + [bool] --- diff --git a/docs/Models/Collections/OrganizationUserMemberships.md b/docs/Models/Collections/OrganizationUserMemberships.md index abc754b01..56f76f872 100644 --- a/docs/Models/Collections/OrganizationUserMemberships.md +++ b/docs/Models/Collections/OrganizationUserMemberships.md @@ -1,6 +1,28 @@ # Terminus\Models\Collections\OrganizationUserMemberships -### addMember +### __construct +##### Description: + Instantiates the collection, sets param members as properties + +##### Parameters: + [array] $options To be set to $this->key + +--- + +### add +##### Description: + Adds a model to this collection + +##### Parameters: + [object] $model_data Data to feed into attributes of new model + [array] $arg_options Data to make properties of the new model + +##### Return: + [void] + +--- + +### create ##### Description: Adds a user to this organization @@ -28,15 +50,3 @@ --- -### fetch -##### Description: - Fetches model data from API and instantiates its model instances - -##### Parameters: - [array] $options params to pass to url request - -##### Return: - [OrganizationUserMemberships] - ---- - diff --git a/docs/Models/Collections/Sites.md b/docs/Models/Collections/Sites.md index 32ed2d8cd..a8d7fe323 100644 --- a/docs/Models/Collections/Sites.md +++ b/docs/Models/Collections/Sites.md @@ -12,7 +12,16 @@ --- -### addSite +### all +##### Description: + Retrieves all sites + +##### Return: + [Site[]] + +--- + +### create ##### Description: Creates a new site @@ -29,56 +38,52 @@ --- -### addSiteToCache +### fetch ##### Description: - Adds site with given site ID to cache + Fetches model data from API and instantiates its model instances ##### Parameters: - [string] $site_id UUID of site to add to cache - [string] $org_id UUID of org to which new site belongs + [array] $arg_options params to pass to url request ##### Return: - [Site] The newly created site object + [Sites] --- -### deleteSiteFromCache +### filterByTag ##### Description: - Removes site with given site ID from cache + Filters sites list by tag ##### Parameters: - [string] $site_name Name of site to remove from cache + [string] $tag Tag to filter by + [string] $org_id ID of an organization which has tagged sites ##### Return: - [void] + [Sites] --- -### fetch +### filterByName ##### Description: - Fetches model data from API and instantiates its model instances + Filters an array of sites by whether the user is an organizational member ##### Parameters: - [array] $options params to pass to url request + [string] $regex Non-delimited PHP regex to filter site names by ##### Return: [Sites] --- -### filterAllByTag +### filterByOwner ##### Description: - Filters sites list by tag + Filters an array of sites by whether the user is an organizational member ##### Parameters: - [string] $tag Tag to filter by - [string] $org Organization which has tagged sites + [string] $owner_uuid UUID of the owning user to filter by ##### Return: - [Site[]] - -##### Throws: - TerminusException + [Sites] --- @@ -109,12 +114,15 @@ --- -### rebuildCache +### nameIsTaken ##### Description: - Clears sites cache + Determines whether a given site name is taken or not. + +##### Parameters: + [string] $name Name of the site to look up ##### Return: - [void] + [boolean] --- diff --git a/docs/Models/Collections/TerminusCollection.md b/docs/Models/Collections/TerminusCollection.md index 9cf1b22b3..08fce2e01 100644 --- a/docs/Models/Collections/TerminusCollection.md +++ b/docs/Models/Collections/TerminusCollection.md @@ -9,9 +9,23 @@ --- +### add +##### Description: + Adds a model to this collection + +##### Parameters: + [object] $model_data Data to feed into attributes of new model + [array] $options Data to make properties of the new model + +##### Return: + [TerminusModel] + +--- + ### all ##### Description: Retrieves all models + TODO: Remove automatic fetching and make fetches explicit ##### Return: [TerminusModel[]] @@ -54,16 +68,18 @@ --- -### add +### listing ##### Description: - Adds a model to this collection + Returns an array of data where the keys are the attribute $key and the + values are the attribute $value ##### Parameters: - [object] $model_data Data to feed into attributes of new model - [array] $options Data to make properties of the new model + [string] $key Name of attribute to make array keys + [mixed] $value Name(s) of attribute(s) to comprise array values ##### Return: - [TerminusModel] + [array] Array rendered as requested + -$this->attribute->$key = $this->attribute->$value --- diff --git a/docs/Models/Collections/UserOrganizationMemberships.md b/docs/Models/Collections/UserOrganizationMemberships.md index 94f1af54b..9718dae4a 100644 --- a/docs/Models/Collections/UserOrganizationMemberships.md +++ b/docs/Models/Collections/UserOrganizationMemberships.md @@ -9,27 +9,31 @@ --- -### fetch +### add ##### Description: - Fetches model data from API and instantiates its model instances + Adds a model to this collection ##### Parameters: - [array] $options params to pass to url request + [object] $model_data Data to feed into attributes of new model + [array] $arg_options Data to make properties of the new model ##### Return: - [UserOrganizationMemberships] + [void] --- -### get +### getOrganization ##### Description: - Retrieves the model of the given ID + Retrieves the matching organization from model members ##### Parameters: - [string] $id ID or name of desired organization + [string] $org ID or name of desired organization ##### Return: - [UserOrganizationMembership] $model + [Organization] $organization + +##### Throws: + TerminusException --- diff --git a/docs/Models/Collections/UserSiteMemberships.md b/docs/Models/Collections/UserSiteMemberships.md new file mode 100644 index 000000000..bf54c22ef --- /dev/null +++ b/docs/Models/Collections/UserSiteMemberships.md @@ -0,0 +1,24 @@ +# Terminus\Models\Collections\UserSiteMemberships + +### __construct +##### Description: + Instantiates the collection, sets param members as properties + +##### Parameters: + [array] $options To be set to $this->key + +--- + +### add +##### Description: + Adds a model to this collection + +##### Parameters: + [object] $model_data Data to feed into attributes of new model + [array] $arg_options Data to make properties of the new model + +##### Return: + [void] + +--- + diff --git a/docs/Models/Environment.md b/docs/Models/Environment.md index c26f412fa..21487d839 100644 --- a/docs/Models/Environment.md +++ b/docs/Models/Environment.md @@ -320,19 +320,6 @@ --- -### setPhpVersion -##### Description: - Sets the PHP version number of this environment - -##### Parameters: - [string] $version_number The version number to set this environment to - -use - -##### Return: - [void] - ---- - ### unlock ##### Description: Disable HTTP Basic Access authentication on the web environment @@ -342,15 +329,6 @@ --- -### unsetPhpVersion -##### Description: - Unsets the PHP version of this environment so it will use the site default - -##### Return: - [void] - ---- - ### wake ##### Description: "Wake" a site diff --git a/docs/Models/Organization.md b/docs/Models/Organization.md index 9da74f7c4..1b731fc1d 100644 --- a/docs/Models/Organization.md +++ b/docs/Models/Organization.md @@ -8,6 +8,9 @@ [object] $attributes Attributes of this model [array] $options Options to set as $this->key +##### Return: + [Organization] + --- ### getFeature @@ -27,7 +30,7 @@ Retrieves organization sites ##### Return: - [OrganizationSiteMembership[]] + [Site[]] --- @@ -36,7 +39,7 @@ Retrieves organization users ##### Return: - [OrganizationUserMembership[]] + [User[]] --- diff --git a/docs/Models/OrganizationSiteMembership.md b/docs/Models/OrganizationSiteMembership.md index f756918c5..60aae9136 100644 --- a/docs/Models/OrganizationSiteMembership.md +++ b/docs/Models/OrganizationSiteMembership.md @@ -1,6 +1,19 @@ # Terminus\Models\OrganizationSiteMembership -### removeMember +### __construct +##### Description: + Object constructor + +##### Parameters: + [object] $attributes Attributes of this model + [array] $options Options to set as $this->key + +##### Return: + [OrganizationSiteMembership] + +--- + +### delete ##### Description: Removes a site from this organization diff --git a/docs/Models/OrganizationUserMembership.md b/docs/Models/OrganizationUserMembership.md index ec585e4a2..4be483f29 100644 --- a/docs/Models/OrganizationUserMembership.md +++ b/docs/Models/OrganizationUserMembership.md @@ -1,6 +1,19 @@ # Terminus\Models\OrganizationUserMembership -### removeMember +### __construct +##### Description: + Object constructor + +##### Parameters: + [object] $attributes Attributes of this model + [array] $options Options to set as $this->key + +##### Return: + [OrganizationSiteMembership] + +--- + +### delete ##### Description: Removes a user from this organization diff --git a/docs/Models/Site.md b/docs/Models/Site.md index 60938edf9..ed57d78db 100644 --- a/docs/Models/Site.md +++ b/docs/Models/Site.md @@ -109,15 +109,6 @@ --- -### deleteFromCache -##### Description: - Deletes site from cache - -##### Return: - [void] - ---- - ### disableNewRelic ##### Description: Disables New Relic @@ -368,21 +359,6 @@ --- -### setPhpVersion -##### Description: - Sets the PHP version number of this site - Note: Once this changes, you need to refresh the data in the cache for - this site or the returned PHP version will not reflect the change. - $this->fetchAttributes() will complete this action for you. - -##### Parameters: - [string] $version_number The version number to set this site to use - -##### Return: - [void] - ---- - ### updateServiceLevel ##### Description: Update service level diff --git a/docs/Models/User.md b/docs/Models/User.md index 38f6c2546..8da9c1ce1 100644 --- a/docs/Models/User.md +++ b/docs/Models/User.md @@ -10,21 +10,9 @@ --- -### parseAttributes -##### Description: - Modify response data between fetch and assignment - -##### Parameters: - [object] $data attributes received from API response - -##### Return: - [object] $data - ---- - ### getAliases ##### Description: - Retrieves drush aliases for this user + Retrieves Drush aliases for this user ##### Return: [\stdClass] @@ -44,12 +32,8 @@ ##### Description: Requests API data and returns an object of user site data -##### Parameters: - [string] $organization UUID of organization to requests sites from, - -or null to fetch for all organizations. - ##### Return: - [\stdClass] + [Site[]] --- diff --git a/docs/Models/UserOrganizationMembership.md b/docs/Models/UserOrganizationMembership.md new file mode 100644 index 000000000..30d95843f --- /dev/null +++ b/docs/Models/UserOrganizationMembership.md @@ -0,0 +1,15 @@ +# Terminus\Models\UserOrganizationMembership + +### __construct +##### Description: + Object constructor + +##### Parameters: + [object] $attributes Attributes of this model + [array] $options Options to set as $this->key + +##### Return: + [UserSiteMembership] + +--- + diff --git a/docs/Models/UserSiteMembership.md b/docs/Models/UserSiteMembership.md new file mode 100644 index 000000000..0e2905c36 --- /dev/null +++ b/docs/Models/UserSiteMembership.md @@ -0,0 +1,15 @@ +# Terminus\Models\UserSiteMembership + +### __construct +##### Description: + Object constructor + +##### Parameters: + [object] $attributes Attributes of this model + [array] $options Options to set as $this->key + +##### Return: + [UserSiteMembership] + +--- + diff --git a/php/Terminus/Commands/MachineTokensCommand.php b/php/Terminus/Commands/MachineTokensCommand.php index 58e8c2124..67b8161e3 100755 --- a/php/Terminus/Commands/MachineTokensCommand.php +++ b/php/Terminus/Commands/MachineTokensCommand.php @@ -25,7 +25,7 @@ public function __construct(array $options = []) { } /** - * Show a list of your macnine tokens on Pantheon + * Show a list of your machine tokens on Pantheon * * @subcommand list * @alias show diff --git a/php/Terminus/Configurator.php b/php/Terminus/Configurator.php index 48085bdd9..f0b798fd7 100755 --- a/php/Terminus/Configurator.php +++ b/php/Terminus/Configurator.php @@ -213,7 +213,7 @@ private function ensureDirExists($dir) { try { $dir_exists = ( is_dir($dir) - || (!file_exists($dir) && mkdir($dir, 0777, true)) + || (!file_exists($dir) && @mkdir($dir, 0777, true)) ); } catch (\Exception $e) { return false; diff --git a/php/Terminus/Models/Collections/Sites.php b/php/Terminus/Models/Collections/Sites.php index 576357ada..e6db66550 100644 --- a/php/Terminus/Models/Collections/Sites.php +++ b/php/Terminus/Models/Collections/Sites.php @@ -72,19 +72,19 @@ public function fetch(array $arg_options = []) { ]; $options = array_merge($default_options, $arg_options); + $sites = []; if (is_null($options['org_id'])) { $sites = $this->user->getSites(); - if (!$options['team_only']) { - $organizations = $this->user->getOrganizations(); - foreach ($organizations as $organization) { - $sites = array_merge($sites, $organization->getSites()); + } + if (!$options['team_only']) { + $memberships = $this->user->org_memberships->fetch()->all(); + foreach ($memberships as $membership) { + if ($membership->get('role') != 'unprivileged') { + $sites = array_merge($sites, $membership->organization->getSites()); } } - } else { - $this->user->org_memberships->fetch(); - $sites = $this->user->org_memberships->get($options['org_id']) - ->organization->getSites(); } + foreach ($sites as $site) { if (!isset($this->models[$site->id])) { $site->collection = $this; diff --git a/php/Terminus/Models/Organization.php b/php/Terminus/Models/Organization.php index dc02e0c4a..2112114bb 100644 --- a/php/Terminus/Models/Organization.php +++ b/php/Terminus/Models/Organization.php @@ -64,18 +64,19 @@ public function getFeature($feature) { * @return Site[] */ public function getSites() { + $site_memberships = $this->site_memberships->all(); $sites = array_combine( array_map( function($membership) { return $membership->site->id; }, - $this->site_memberships->all() + $site_memberships ), array_map( function($membership) { return $membership->site; }, - $this->site_memberships->all() + $site_memberships ) ); return $sites; diff --git a/tests/features/auth.feature b/tests/features/auth.feature index 6aef82cc0..b7404ba75 100644 --- a/tests/features/auth.feature +++ b/tests/features/auth.feature @@ -48,7 +48,7 @@ Feature: Authorization command [[user_uuid]] """ - Scenario: Checking my user should not give any useful result when I am logged out. + Scenario: Checking my user should not get any useful result when I am logged out. When I am not authenticated And I run "terminus auth whoami" Then I should not get: