Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
17
vendor/consolidation/site-alias/.editorconfig
vendored
Normal file
17
vendor/consolidation/site-alias/.editorconfig
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[{composer.json,composer.lock}]
|
||||
indent_size = 4
|
11
vendor/consolidation/site-alias/.github/issue_template.md
vendored
Normal file
11
vendor/consolidation/site-alias/.github/issue_template.md
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
### Steps to reproduce
|
||||
What did you do?
|
||||
|
||||
### Expected behavior
|
||||
Tell us what should happen
|
||||
|
||||
### Actual behavior
|
||||
Tell us what happens instead
|
||||
|
||||
### System Configuration
|
||||
Which O.S. and PHP version are you using?
|
16
vendor/consolidation/site-alias/.github/pull_request_template.md
vendored
Normal file
16
vendor/consolidation/site-alias/.github/pull_request_template.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
### Overview
|
||||
This pull request:
|
||||
|
||||
| Q | A
|
||||
| ------------- | ---
|
||||
| Bug fix? | yes/no
|
||||
| New feature? | yes/no <!-- don't forget to update CHANGELOG.md files -->
|
||||
| Has tests? | yes/no
|
||||
| BC breaks? | no
|
||||
| Deprecations? | yes/no
|
||||
|
||||
### Summary
|
||||
Short overview of what changed.
|
||||
|
||||
### Description
|
||||
Any additional information.
|
5
vendor/consolidation/site-alias/.gitignore
vendored
Normal file
5
vendor/consolidation/site-alias/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
.idea/
|
||||
box.phar
|
||||
build
|
||||
alias-tool.phar
|
||||
vendor/
|
57
vendor/consolidation/site-alias/.scenarios.lock/install
vendored
Executable file
57
vendor/consolidation/site-alias/.scenarios.lock/install
vendored
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCENARIO=$1
|
||||
DEPENDENCIES=${2-install}
|
||||
|
||||
# Convert the aliases 'highest', 'lowest' and 'lock' to
|
||||
# the corresponding composer command to run.
|
||||
case $DEPENDENCIES in
|
||||
highest)
|
||||
DEPENDENCIES=update
|
||||
;;
|
||||
lowest)
|
||||
DEPENDENCIES='update --prefer-lowest'
|
||||
;;
|
||||
lock|default|"")
|
||||
DEPENDENCIES=install
|
||||
;;
|
||||
esac
|
||||
|
||||
original_name=scenarios
|
||||
recommended_name=".scenarios.lock"
|
||||
|
||||
base="$original_name"
|
||||
if [ -d "$recommended_name" ] ; then
|
||||
base="$recommended_name"
|
||||
fi
|
||||
|
||||
# If scenario is not specified, install the lockfile at
|
||||
# the root of the project.
|
||||
dir="$base/${SCENARIO}"
|
||||
if [ -z "$SCENARIO" ] || [ "$SCENARIO" == "default" ] ; then
|
||||
SCENARIO=default
|
||||
dir=.
|
||||
fi
|
||||
|
||||
# Test to make sure that the selected scenario exists.
|
||||
if [ ! -d "$dir" ] ; then
|
||||
echo "Requested scenario '${SCENARIO}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "::"
|
||||
echo ":: Switch to ${SCENARIO} scenario"
|
||||
echo "::"
|
||||
echo
|
||||
|
||||
set -ex
|
||||
|
||||
composer -n validate --working-dir=$dir --no-check-all --ansi
|
||||
composer -n --working-dir=$dir ${DEPENDENCIES} --prefer-dist --no-scripts
|
||||
|
||||
# If called from a CI context, print out some extra information about
|
||||
# what we just installed.
|
||||
if [[ -n "$CI" ]] ; then
|
||||
composer -n --working-dir=$dir info
|
||||
fi
|
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/.gitignore
vendored
Normal file
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
vendor
|
80
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/composer.json
vendored
Normal file
80
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/composer.json
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"name": "consolidation/site-alias",
|
||||
"description": "Template project for PHP libraries.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
},
|
||||
{
|
||||
"name": "Moshe Weitzman",
|
||||
"email": "weitzman@tejasa.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Consolidation\\SiteAlias\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\SiteAlias\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"consolidation/Robo": "^1.2.3",
|
||||
"g1a/composer-test-scenarios": "^2",
|
||||
"knplabs/github-api": "^2.7",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"phpunit/phpunit": "^5.7.27",
|
||||
"satooshi/php-coveralls": "^2",
|
||||
"squizlabs/php_codesniffer": "^2.8",
|
||||
"symfony/console": "^2.8|^3|^4",
|
||||
"symfony/yaml": "~2.3|^3"
|
||||
},
|
||||
"scripts": {
|
||||
"phar:install-tools": [
|
||||
"gem install mime-types -v 2.6.2",
|
||||
"curl -LSs https://box-project.github.io/box2/installer.php | php"
|
||||
],
|
||||
"phar:build": "box build",
|
||||
"cs": "phpcs --standard=PSR2 -n src",
|
||||
"cbf": "phpcbf --standard=PSR2 -n src",
|
||||
"unit": "phpunit --colors=always",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"release": [
|
||||
"( sed -e 's/-dev$//' VERSION > VERSION.tmp && mv -f VERSION.tmp VERSION && ver=\"$(cat VERSION)\" && git add VERSION && git commit -m \"Version $ver\" && git tag \"$ver\" && git push origin \"$ver\" && a=( ${ver//./ } ) && ((a[2]++)) && echo \"${a[0]}.${a[1]}.${a[2]}-dev\" > VERSION && git add VERSION && git commit -m \"Back to -dev\" && git push origin master )"
|
||||
],
|
||||
"scenario": ".scenarios.lock/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario phpunit5 'phpunit/phpunit:^5.7.27' --platform-php '5.6.33'",
|
||||
"dependency-licenses"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "5.6.33"
|
||||
},
|
||||
"vendor-dir": "../../vendor"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable"
|
||||
}
|
3708
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/composer.lock
generated
vendored
Normal file
3708
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/src
vendored
Symbolic link
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/src
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../src
|
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/tests
vendored
Symbolic link
1
vendor/consolidation/site-alias/.scenarios.lock/phpunit5/tests
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../tests
|
11
vendor/consolidation/site-alias/.scrutinizer.yml
vendored
Normal file
11
vendor/consolidation/site-alias/.scrutinizer.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
checks:
|
||||
php: true
|
||||
filter:
|
||||
excluded_paths:
|
||||
- customize/*
|
||||
- tests/*
|
||||
tools:
|
||||
php_sim: true
|
||||
php_pdepend: true
|
||||
php_analyzer: true
|
||||
php_cs_fixer: false
|
41
vendor/consolidation/site-alias/.travis.yml
vendored
Normal file
41
vendor/consolidation/site-alias/.travis.yml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
dist: trusty
|
||||
language: php
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- "/^[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+.*$/"
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 7.2
|
||||
env: DEPENCENCIES=highest
|
||||
- php: 7.2
|
||||
- php: 7.1
|
||||
- php: 7.0.11
|
||||
- php: 5.6
|
||||
env: SCENARIO=phpunit5
|
||||
- php: 5.6
|
||||
env: SCENARIO=phpunit5 DEPENDENCIES=lowest
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.composer/cache"
|
||||
install:
|
||||
- composer scenario "${SCENARIO}" "${DEPENDENCIES}"
|
||||
script:
|
||||
- composer test
|
||||
after_success:
|
||||
- travis_retry php vendor/bin/php-coveralls -v
|
||||
before_deploy:
|
||||
- composer phar:install-tools
|
||||
- composer install --prefer-dist --no-dev --no-interaction
|
||||
- php box.phar build
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: Nk+oRXu2ZpF6UCKSxIK1FeQ4zykN8X2oGZrUjQy+tTVE2/BjhldFqlOxHhjfrtViC+eTvGbJbxGteQ7S+67WKyz5Kps9g2mlf7M2wJj9obIR2YJn1d8ch1PYKkWbiXcp8vZoMXDt++pP5TkL6IDTsV7pom7cBa9Yb7OlGkzyxQmu2sfqXzF4ivcsmmoF49ASkHpA6PmRJetXywW/zM1nglIGXZCqfIIYCMi6BLmWsDFBe1xLbvk4H4DgLyMs5O4p5cW9y2abQ0vydcUSoJmIo/7Ehjg4xy2UNWcJnS/oMc4jQj62uPgAtk81rrSAM8HgmCr/fDAVOdOryypElT6jCXSA0LRvCP67X9JkpM5PBGktFYJwMJFKygpGjyqYjI5u7CR8GQuUpJIhgOvIqJIsz+PoDkFnEohbS0NqtLkTfq4GP3wIr2u42NnArpUNw8ejawGk8sgHlhxWI98+3mif8ZHHZlUEr8JCppFIz/W9f2TiFvoRCsNUOR7t2FV/q0k5tbxRA3465fDy2fxz506c11rb6NHV61mu6Xl1RevtX97bHhRHT1Igmhzn3dnfxAyEWxU5CPeVUKFdAqx0WxrAlosQaUwmRXxUlq9qs5j8F2rjPbE+une/sB5S5+2+lSlz8ympF5vIKIE4eExdXaTaIoXO52hPIMKkhZCHxq5tdU4=
|
||||
file: alias-tool.phar
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
repo: consolidation/site-alias
|
36
vendor/consolidation/site-alias/CHANGELOG.md
vendored
Normal file
36
vendor/consolidation/site-alias/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Changelog
|
||||
|
||||
### 1.1.9 - 1.1.7 - 2018/Oct/30
|
||||
|
||||
* Fixes #11: Prevent calls to 'localRoot' from failing when there is no root set (#15)
|
||||
* Set short description in composer.json
|
||||
|
||||
### 1.1.6 - 2018/Oct/27
|
||||
|
||||
* Add an 'os' method to AliasRecord
|
||||
* Only run root through realpath if it is present (throw otherwise) (#11)
|
||||
* Add a site:value command for ad-hoc testing
|
||||
|
||||
### 1.1.5 - 1.1.3 - 2018/Sept/21
|
||||
|
||||
* Experimental wildcard environments
|
||||
* Find 'aliases.drushrc.php' files when converting aliases.
|
||||
* Fix get multiple (#6)
|
||||
|
||||
### 1.1.2 - 2018/Aug/21
|
||||
|
||||
* Allow SiteAliasFileLoader::loadMultiple to be filtered by location. (#3)
|
||||
|
||||
### 1.1.0 + 1.1.1 - 2018/Aug/14
|
||||
|
||||
* Add wildcard site alias environments. (#2)
|
||||
* Remove legacy AliasRecord definition; causes more problems than it solves.
|
||||
|
||||
### 1.0.1 - 2018/Aug/7
|
||||
|
||||
* Allow addSearchLocation to take an array
|
||||
|
||||
### 1.0.0 - 2018/July/5
|
||||
|
||||
* Initial release
|
||||
|
92
vendor/consolidation/site-alias/CONTRIBUTING.md
vendored
Normal file
92
vendor/consolidation/site-alias/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# Contributing to SiteAlias
|
||||
|
||||
Thank you for your interest in contributing to SiteAlias! Here are some of the guidelines you should follow to make the most of your efforts:
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
This project adheres to the [PSR-2 Coding Style Guide](http://www.php-fig.org/psr/psr-2/) for PHP code. An `.editorconfig` file is included with the repository to help you get up and running quickly. Most modern editors support this standard, but if yours does not or you would like to configure your editor manually, follow the guidelines in the document linked above.
|
||||
|
||||
You can run the PHP Codesniffer on your work using a convenient command provided as a composer script:
|
||||
```
|
||||
composer cs
|
||||
```
|
||||
The above will run the PHP Codesniffer on the project sources. To automatically clean up code style violations, run:
|
||||
```
|
||||
composer cbf
|
||||
```
|
||||
Please ensure all contributions are compliant _before_ submitting a pull request.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
### Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
### Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
### Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
### Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
### Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
24
vendor/consolidation/site-alias/LICENSE
vendored
Normal file
24
vendor/consolidation/site-alias/LICENSE
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Greg Anderson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
DEPENDENCY LICENSES:
|
||||
|
||||
Name Version License
|
178
vendor/consolidation/site-alias/README.md
vendored
Normal file
178
vendor/consolidation/site-alias/README.md
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
# SiteAlias
|
||||
|
||||
Manage alias records for local and remote sites.
|
||||
|
||||
[](https://travis-ci.org/consolidation/site-alias)
|
||||
[](https://ci.appveyor.com/project/greg-1-anderson/site-alias)
|
||||
[](https://scrutinizer-ci.com/g/consolidation/site-alias/?branch=master)
|
||||
[](https://coveralls.io/github/consolidation/site-alias?branch=master)
|
||||
[](LICENSE)
|
||||
|
||||
## Overview
|
||||
|
||||
This project provides the implementation for Drush site aliases. It is used in Drush 9 and later. It would also be possible to use this library to manage site aliases for similar commandline tools.
|
||||
|
||||
### Alias naming conventions
|
||||
|
||||
Site alias names always begin with a `@`, and typically are divided in three parts: the alias file location (optional), the site name, and the environment name, each separated by a dot. None of these names may contain a dot. An example alias that referenced the `dev` environment of the site `example` in the `myisp` directory might therefore look something like:
|
||||
```
|
||||
@myisp.example.dev
|
||||
```
|
||||
The location name is optional. If specified, it will only consider alias files located in directories with the same name as the provided location name. The remainder of the path is immaterial; only the directory that is the immediate parent of the site alias file is relevant. The location name may be omitted, e.g.:
|
||||
```
|
||||
@example.dev
|
||||
```
|
||||
If the location is not specified, then the alias manaager will consider all locations for an applicable site alias file. Note that by default, deep searching is disabled; unless deep searching is enabled, the location name must refer to a directory that is explicitly listed as a location to place site alias files (e.g. in the application's configuration file).
|
||||
|
||||
It is also possible to use single-word aliases. These can sometimes be ambiguous; the site alias manager will resolve single-word aliases as follows:
|
||||
|
||||
1. `@self` is interpreted to mean the site that has already been selected, or the site that would be selected in the absence of any alias.
|
||||
2. `@none` is interpreted as the empty alias--an alias with no items defined.
|
||||
3. `@<env>`, for any `<env>` is equivalent to `@self.<env>` if such an alias is defined. See below.
|
||||
4. `@<site>`, for any `<site>` is equivalent to the default environment of `<site>`, e.g. `@<site>.<default>`. The default environment defaults to `dev`, but may be explicitly set in the alias.
|
||||
|
||||
### Alias placement on commandline
|
||||
|
||||
It is up to each individual commandline tools how to utilize aliases. There are two primary examples:
|
||||
|
||||
1. Site selection alias: `tool @sitealias command`
|
||||
2. Alias parameters: `tool command @source @destination`
|
||||
|
||||
In the first example, with the site alias appearing before the command name, the alias is used to determine the target site for the current command. In the second example, the arguments of the command are used to specify source and destination sites.
|
||||
|
||||
### Alias filenames and locations
|
||||
|
||||
It is also up to each individual commandline tool where to search for alias files. Search locations may be added to the SiteAliasManager via an API call. By default, alias files are only found if they appear immediately inside one of the specified search locations. Deep searching is only done if explicitly enabled by the application.
|
||||
|
||||
Aliases are typically stored in Yaml files, although other formats may also be used if a custom alias data file loader is provided. The extension of the file determines the loader type (.yml for Yaml). The base name of the file, sans its extension, is the site name used to address the alias on the commandline. Site names may not contain periods.
|
||||
|
||||
### Alias file contents
|
||||
|
||||
The canonical site alias will contain information about how to locate the site on the local file system, and how the site is addressed on the network (when accessed via a web browser).
|
||||
```
|
||||
dev:
|
||||
root: /path/to/site
|
||||
uri: https://example.com
|
||||
```
|
||||
A more complex alias might also contain information about the server that the site is running on (when accessed via ssh for deployment and maintenance).
|
||||
```
|
||||
dev:
|
||||
root: /path/to/site
|
||||
uri: https://example.com
|
||||
remote: server.com
|
||||
user: www-data
|
||||
```
|
||||
|
||||
### Wildcard environments (Experimental)
|
||||
|
||||
It is also possible to define "wildcard" environments that will match any provided environment name. This is only possible to do in instances where the contents of the wildcard aliases are all the same, except for places where the environment name appears. To substitute the name of the environment into a wildcard domain, use the variable replacement string `${env-name}`. For example, a wildcard alias that will match any multisite in a Drupal site might look something like the following example:
|
||||
```
|
||||
'*':
|
||||
root: /wild/path/to/wild
|
||||
uri: https://${env-name}.example.com
|
||||
```
|
||||
|
||||
### 'Self' environment aliases
|
||||
|
||||
As previously mentioned, an alias in the form of `@<env>` is interpreted as `@self.<env>`. This allows sites to define a `self.site.yml` file that contains common aliases shared among a team--for example, `@stage` and `@live`.
|
||||
|
||||
## Site specifications
|
||||
|
||||
Site specifications are specially-crafted commandline arguments that can serve as replacements for simple site aliases. Site specifications are particularly useful for scripts that may wish to operate on a remote site without generating a temporary alias file.
|
||||
|
||||
The basic form for a site specification is:
|
||||
```
|
||||
user.name@example.com/path#uri
|
||||
```
|
||||
This is equivalent to the following alias record:
|
||||
```
|
||||
env:
|
||||
user: user.name
|
||||
host: example.com
|
||||
root: /path
|
||||
uri: somemultisite
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
To get started contributing to this project, simply clone it locally and then run `composer install`.
|
||||
|
||||
### Running the tests
|
||||
|
||||
The test suite may be run locally by way of some simple composer scripts:
|
||||
|
||||
| Test | Command
|
||||
| ---------------- | ---
|
||||
| Run all tests | `composer test`
|
||||
| PHPUnit tests | `composer unit`
|
||||
| PHP linter | `composer lint`
|
||||
| Code style | `composer cs`
|
||||
| Fix style errors | `composer cbf`
|
||||
|
||||
### Development Commandline Tool
|
||||
|
||||
This library comes with a commandline tool called `alias-tool`. The only purpose
|
||||
this tool serves is to provide a way to do ad-hoc experimentation and testing
|
||||
for this library.
|
||||
|
||||
Example:
|
||||
```
|
||||
$ ./alias-tool site:list tests/fixtures/sitealiases/sites/
|
||||
|
||||
! [NOTE] Add search location: tests/fixtures/sitealiases/sites/
|
||||
|
||||
'@single.alternate':
|
||||
foo: bar
|
||||
root: /alternate/path/to/single
|
||||
'@single.dev':
|
||||
foo: bar
|
||||
root: /path/to/single
|
||||
'@wild.*':
|
||||
foo: bar
|
||||
root: /wild/path/to/wild
|
||||
uri: 'https://*.example.com'
|
||||
'@wild.dev':
|
||||
foo: bar
|
||||
root: /path/to/wild
|
||||
uri: 'https://dev.example.com'
|
||||
|
||||
$ ./alias-tool site:get tests/fixtures/sitealiases/sites/ @single.dev
|
||||
|
||||
! [NOTE] Add search location: tests/fixtures/sitealiases/sites/
|
||||
|
||||
! [NOTE] Alias parameter: '@single.dev'
|
||||
|
||||
foo: bar
|
||||
root: /path/to/single
|
||||
```
|
||||
See `./alias-tool help` and `./alias-tool list` for more information.
|
||||
|
||||
## Release Procedure
|
||||
|
||||
To create a release:
|
||||
|
||||
- Edit the `VERSION` file to contain the version to release, and commit the change.
|
||||
- Run `composer release`
|
||||
|
||||
## Built With
|
||||
|
||||
This library was created with the [g1a/starter](https://github.com/g1a/starter) project, a fast way to create php libraries and [Robo](https://robo.li/) / [Symfony](https://symfony.com/) applications.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
|
||||
|
||||
## Versioning
|
||||
|
||||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases](https://github.com/consolidation/site-alias/releases) page.
|
||||
|
||||
## Authors
|
||||
|
||||
* **Greg Anderson**
|
||||
* **Moshe Weitzman**
|
||||
|
||||
See also the list of [contributors](https://github.com/consolidation/site-alias/contributors) who participated in this project. Thanks also to all of the [drush contributors](https://github.com/drush-ops/drush/contributors) who contributed directly or indirectly to site aliases.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
|
1
vendor/consolidation/site-alias/VERSION
vendored
Normal file
1
vendor/consolidation/site-alias/VERSION
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
1.1.11
|
45
vendor/consolidation/site-alias/alias-tool
vendored
Executable file
45
vendor/consolidation/site-alias/alias-tool
vendored
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Example commandline front controller
|
||||
*
|
||||
* The commandline tool is useful for providing ad-hoc access to our class implementations
|
||||
*/
|
||||
|
||||
// If we're running from phar load the phar autoload file.
|
||||
$pharPath = \Phar::running(true);
|
||||
if ($pharPath) {
|
||||
$autoloaderPath = "$pharPath/vendor/autoload.php";
|
||||
} else {
|
||||
if (file_exists(__DIR__.'/vendor/autoload.php')) {
|
||||
$autoloaderPath = __DIR__.'/vendor/autoload.php';
|
||||
} elseif (file_exists(__DIR__.'/../../autoload.php')) {
|
||||
$autoloaderPath = __DIR__ . '/../../autoload.php';
|
||||
} else {
|
||||
die("Could not find autoloader. Run 'composer install'.");
|
||||
}
|
||||
}
|
||||
$classLoader = require $autoloaderPath;
|
||||
|
||||
// Customization variables
|
||||
$argv = $_SERVER['argv'];
|
||||
$appName = "SiteAlias";
|
||||
$appVersion = trim(file_get_contents(__DIR__ . '/VERSION'));
|
||||
$commandClasses = [ \Consolidation\SiteAlias\Cli\SiteAliasCommands::class ];
|
||||
$selfUpdateRepository = 'consolidation/site-alias';
|
||||
$configPrefix = 'SITEALIAS';
|
||||
$configFilePath = getenv($configPrefix . '_CONFIG') ?: getenv('HOME') . '/.site-alias/site-alias.yml';
|
||||
|
||||
// Define our Runner, and pass it the command classes we provide.
|
||||
$runner = new \Robo\Runner($commandClasses);
|
||||
$runner
|
||||
->setSelfUpdateRepository($selfUpdateRepository)
|
||||
->setConfigurationFilename($configFilePath)
|
||||
->setEnvConfigPrefix($configPrefix)
|
||||
->setClassLoader($classLoader);
|
||||
|
||||
// Execute the command and return the result.
|
||||
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
|
||||
$statusCode = $runner->execute($argv, $appName, $appVersion, $output);
|
||||
exit($statusCode);
|
63
vendor/consolidation/site-alias/appveyor.yml
vendored
Normal file
63
vendor/consolidation/site-alias/appveyor.yml
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
build: false
|
||||
shallow_clone: false
|
||||
platform: 'x86'
|
||||
clone_folder: C:\projects\work
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
## Cache composer bits
|
||||
cache:
|
||||
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
|
||||
|
||||
init:
|
||||
#https://github.com/composer/composer/blob/master/appveyor.yml
|
||||
#- SET ANSICON=121x90 (121x90)
|
||||
|
||||
# Inspired by https://github.com/Codeception/base/blob/master/appveyor.yml and https://github.com/phpmd/phpmd/blob/master/appveyor.yml
|
||||
install:
|
||||
- cinst -y curl
|
||||
- SET PATH=C:\Program Files\curl;%PATH%
|
||||
#which is only needed by the test suite.
|
||||
- cinst -y which
|
||||
- SET PATH=C:\Program Files\which;%PATH%
|
||||
- git clone -q https://github.com/acquia/DevDesktopCommon.git #For tar, cksum, ...
|
||||
- SET PATH=%APPVEYOR_BUILD_FOLDER%/DevDesktopCommon/bintools-win/msys/bin;%PATH%
|
||||
- SET PATH=C:\Program Files\MySql\MySQL Server 5.7\bin\;%PATH%
|
||||
#Install PHP per https://blog.wyrihaximus.net/2016/11/running-php-unit-tests-on-windows-using-appveyor-and-chocolatey/
|
||||
- ps: appveyor-retry cinst --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $Env:php_ver_target | Select-Object -first 1) -replace '[php|]','')
|
||||
- cd c:\tools\php70
|
||||
- copy php.ini-production php.ini
|
||||
|
||||
- echo extension_dir=ext >> php.ini
|
||||
- echo extension=php_openssl.dll >> php.ini
|
||||
- echo date.timezone="UTC" >> php.ini
|
||||
- echo variables_order="EGPCS" >> php.ini #May be unneeded.
|
||||
- echo mbstring.http_input=pass >> php.ini
|
||||
- echo mbstring.http_output=pass >> php.ini
|
||||
- echo sendmail_path=nul >> php.ini
|
||||
- echo extension=php_mbstring.dll >> php.ini
|
||||
- echo extension=php_curl.dll >> php.ini
|
||||
- echo extension=php_pdo_mysql.dll >> php.ini
|
||||
- echo extension=php_pdo_pgsql.dll >> php.ini
|
||||
- echo extension=php_pdo_sqlite.dll >> php.ini
|
||||
- echo extension=php_pgsql.dll >> php.ini
|
||||
- echo extension=php_gd2.dll >> php.ini
|
||||
- SET PATH=C:\tools\php70;%PATH%
|
||||
#Install Composer
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
#- appveyor DownloadFile https://getcomposer.org/composer.phar
|
||||
- php -r "readfile('http://getcomposer.org/installer');" | php
|
||||
#Install dependencies via Composer
|
||||
- php composer.phar -q install --prefer-dist -n
|
||||
- SET PATH=%APPVEYOR_BUILD_FOLDER%;%APPVEYOR_BUILD_FOLDER%/vendor/bin;%PATH%
|
||||
#Create a sandbox for testing. Don't think we need this.
|
||||
- mkdir c:\test_temp
|
||||
|
||||
test_script:
|
||||
- php composer.phar unit
|
||||
|
||||
# environment variables
|
||||
environment:
|
||||
global:
|
||||
php_ver_target: 7.0
|
25
vendor/consolidation/site-alias/box.json.dist
vendored
Normal file
25
vendor/consolidation/site-alias/box.json.dist
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"alias": "alias-tool.phar",
|
||||
"chmod": "0755",
|
||||
"compactors": [],
|
||||
"directories": ["src"],
|
||||
"files": ["alias-tool", "README.md", "VERSION"],
|
||||
"finder": [
|
||||
{
|
||||
"name": "*.php",
|
||||
"exclude": [
|
||||
"test",
|
||||
"tests",
|
||||
"Test",
|
||||
"Tests",
|
||||
"Tester"
|
||||
],
|
||||
"in": "vendor"
|
||||
}
|
||||
],
|
||||
"git-commit": "git-commit",
|
||||
"git-version": "git-version",
|
||||
"output": "alias-tool.phar",
|
||||
"main": "alias-tool",
|
||||
"stub": true
|
||||
}
|
78
vendor/consolidation/site-alias/composer.json
vendored
Normal file
78
vendor/consolidation/site-alias/composer.json
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"name": "consolidation/site-alias",
|
||||
"description": "Manage alias records for local and remote sites.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Anderson",
|
||||
"email": "greg.1.anderson@greenknowe.org"
|
||||
},
|
||||
{
|
||||
"name": "Moshe Weitzman",
|
||||
"email": "weitzman@tejasa.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Consolidation\\SiteAlias\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Consolidation\\SiteAlias\\": "tests/src"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "~2.3|^3",
|
||||
"consolidation/Robo": "^1.2.3",
|
||||
"symfony/console": "^2.8|^3|^4",
|
||||
"knplabs/github-api": "^2.7",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"phpunit/phpunit": "^5",
|
||||
"g1a/composer-test-scenarios": "^2",
|
||||
"satooshi/php-coveralls": "^2",
|
||||
"squizlabs/php_codesniffer": "^2.8"
|
||||
},
|
||||
"scripts": {
|
||||
"phar:install-tools": [
|
||||
"gem install mime-types -v 2.6.2",
|
||||
"curl -LSs https://box-project.github.io/box2/installer.php | php"
|
||||
],
|
||||
"phar:build": "box build",
|
||||
"cs": "phpcs --standard=PSR2 -n src",
|
||||
"cbf": "phpcbf --standard=PSR2 -n src",
|
||||
"unit": "phpunit --colors=always",
|
||||
"lint": [
|
||||
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
|
||||
"find tests/src -name '*.php' -print0 | xargs -0 -n1 php -l"
|
||||
],
|
||||
"test": [
|
||||
"@lint",
|
||||
"@unit",
|
||||
"@cs"
|
||||
],
|
||||
"release": [
|
||||
"release VERSION"
|
||||
],
|
||||
"scenario": ".scenarios.lock/install",
|
||||
"post-update-cmd": [
|
||||
"create-scenario phpunit5 'phpunit/phpunit:^5.7.27' --platform-php '5.6.33'",
|
||||
"dependency-licenses"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "7.0.8"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
3714
vendor/consolidation/site-alias/composer.lock
generated
vendored
Normal file
3714
vendor/consolidation/site-alias/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
8
vendor/consolidation/site-alias/dependencies.yml
vendored
Normal file
8
vendor/consolidation/site-alias/dependencies.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
version: 2
|
||||
dependencies:
|
||||
- type: php
|
||||
path: /
|
||||
manifest_updates:
|
||||
filters:
|
||||
- name: ".*"
|
||||
versions: "L.Y.Y"
|
19
vendor/consolidation/site-alias/phpunit.xml.dist
vendored
Normal file
19
vendor/consolidation/site-alias/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<phpunit bootstrap="vendor/autoload.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="site-alias">
|
||||
<directory prefix="" suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<!--
|
||||
<log type="coverage-html" target="build/logs/coverage" lowUpperBound="35"
|
||||
highLowerBound="70"/>
|
||||
-->
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
260
vendor/consolidation/site-alias/src/AliasRecord.php
vendored
Normal file
260
vendor/consolidation/site-alias/src/AliasRecord.php
vendored
Normal file
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\Config\ConfigInterface;
|
||||
use Consolidation\Config\Util\ArrayUtil;
|
||||
use Consolidation\SiteAlias\Util\FsUtils;
|
||||
|
||||
/**
|
||||
* An alias record is a configuration record containing well-known items.
|
||||
*
|
||||
* @see AliasRecordInterface for documentation
|
||||
*/
|
||||
class AliasRecord extends Config implements AliasRecordInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __construct(array $data = null, $name = '', $env = '')
|
||||
{
|
||||
parent::__construct($data);
|
||||
if (!empty($env)) {
|
||||
$name .= ".$env";
|
||||
}
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getConfig(ConfigInterface $config, $key, $default = null)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return $this->get($key, $default);
|
||||
}
|
||||
return $config->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function name()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function hasRoot()
|
||||
{
|
||||
return $this->has('root');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function root()
|
||||
{
|
||||
$root = $this->get('root');
|
||||
if ($this->isLocal()) {
|
||||
return FsUtils::realpath($root);
|
||||
}
|
||||
return $root;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uri()
|
||||
{
|
||||
return $this->get('uri');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
return $this->set('uri', $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function remoteHostWithUser()
|
||||
{
|
||||
$result = $this->remoteHost();
|
||||
if (!empty($result) && $this->hasRemoteUser()) {
|
||||
$result = $this->remoteUser() . '@' . $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function remoteUser()
|
||||
{
|
||||
return $this->get('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function hasRemoteUser()
|
||||
{
|
||||
return $this->has('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function remoteHost()
|
||||
{
|
||||
return $this->get('host');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isRemote()
|
||||
{
|
||||
return $this->has('host');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isLocal()
|
||||
{
|
||||
return !$this->isRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function isNone()
|
||||
{
|
||||
return empty($this->root()) && $this->isLocal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function localRoot()
|
||||
{
|
||||
if ($this->isLocal() && $this->hasRoot()) {
|
||||
return $this->root();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* os returns the OS that this alias record points to. For local alias
|
||||
* records, PHP_OS will be returned. For remote alias records, the
|
||||
* value from the `os` element will be returned. If there is no `os`
|
||||
* element, then the default assumption is that the remote system is Linux.
|
||||
*
|
||||
* @return string
|
||||
* Linux
|
||||
* WIN* (e.g. WINNT)
|
||||
* CYGWIN
|
||||
* MINGW* (e.g. MINGW32)
|
||||
*/
|
||||
public function os()
|
||||
{
|
||||
if ($this->isLocal()) {
|
||||
return PHP_OS;
|
||||
}
|
||||
return $this->get('os', 'Linux');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function exportConfig()
|
||||
{
|
||||
return $this->remap($this->export());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconfigure data exported from the form it is expected to be in
|
||||
* inside an alias record to the form it is expected to be in when
|
||||
* inside a configuration file.
|
||||
*/
|
||||
protected function remap($data)
|
||||
{
|
||||
foreach ($this->remapOptionTable() as $from => $to) {
|
||||
if (isset($data[$from])) {
|
||||
unset($data[$from]);
|
||||
}
|
||||
$value = $this->get($from, null);
|
||||
if (isset($value)) {
|
||||
$data['options'][$to] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return new Config($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the parameter-specific options from the 'alias-parameters' section of the alias.
|
||||
* @param string $parameterName
|
||||
* @return array
|
||||
*/
|
||||
protected function getParameterSpecificOptions($aliasData, $parameterName)
|
||||
{
|
||||
if (!empty($parameterName) && $this->has("alias-parameters.{$parameterName}")) {
|
||||
return $this->get("alias-parameters.{$parameterName}");
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the data in this record to the layout that was used
|
||||
* in the legacy code, for backwards compatiblity.
|
||||
*/
|
||||
public function legacyRecord()
|
||||
{
|
||||
$result = $this->exportConfig()->get('options', []);
|
||||
|
||||
// Backend invoke needs a couple of critical items in specific locations.
|
||||
if ($this->has('paths.drush-script')) {
|
||||
$result['path-aliases']['%drush-script'] = $this->get('paths.drush-script');
|
||||
}
|
||||
if ($this->has('ssh.options')) {
|
||||
$result['ssh-options'] = $this->get('ssh.options');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion table from old to new option names. These all implicitly
|
||||
* go in `options`, although they can come from different locations.
|
||||
*/
|
||||
protected function remapOptionTable()
|
||||
{
|
||||
return [
|
||||
'user' => 'remote-user',
|
||||
'host' => 'remote-host',
|
||||
'root' => 'root',
|
||||
'uri' => 'uri',
|
||||
];
|
||||
}
|
||||
}
|
144
vendor/consolidation/site-alias/src/AliasRecordInterface.php
vendored
Normal file
144
vendor/consolidation/site-alias/src/AliasRecordInterface.php
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\Config\ConfigInterface;
|
||||
use Consolidation\Config\Util\ArrayUtil;
|
||||
|
||||
/**
|
||||
* An alias record is a configuration record containing well-known items.
|
||||
*
|
||||
* NOTE: AliasRecord is implemented as a Config subclass; however, it
|
||||
* should not be used as a config. (A better implementation would be
|
||||
* "hasa" config, but that is less convenient, as we want all of the
|
||||
* same capabilities as a config object).
|
||||
*
|
||||
* If using an alias record as config is desired, use the 'exportConfig()'
|
||||
* method.
|
||||
*
|
||||
* Example remote alias:
|
||||
*
|
||||
* ---
|
||||
* host: www.myisp.org
|
||||
* user: www-data
|
||||
* root: /path/to/drupal
|
||||
* uri: mysite.org
|
||||
*
|
||||
* Example local alias with global and command-specific options:
|
||||
*
|
||||
* ---
|
||||
* root: /path/to/drupal
|
||||
* uri: mysite.org
|
||||
* options:
|
||||
* no-interaction: true
|
||||
* command:
|
||||
* user:
|
||||
* login:
|
||||
* options:
|
||||
* name: superuser
|
||||
*/
|
||||
interface AliasRecordInterface extends ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Get a value from the provided config option. Values stored in
|
||||
* this alias record will override the configuration values, if present.
|
||||
*
|
||||
* If multiple alias records need to be chained together in a more
|
||||
* complex priority arrangement, @see \Consolidation\Config\Config\ConfigOverlay.
|
||||
*
|
||||
* @param ConfigInterface $config The configuration object to pull fallback data from
|
||||
* @param string $key The data item to fetch
|
||||
* @param mixed $default The default value to return if there is no match
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConfig(ConfigInterface $config, $key, $default = null);
|
||||
|
||||
/**
|
||||
* Return the name of this alias record.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function name();
|
||||
|
||||
/**
|
||||
* Remember the name of this record
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Determine whether this alias has a root.
|
||||
*/
|
||||
public function hasRoot();
|
||||
|
||||
/**
|
||||
* Get the root
|
||||
*/
|
||||
public function root();
|
||||
|
||||
/**
|
||||
* Get the uri
|
||||
*/
|
||||
public function uri();
|
||||
|
||||
/**
|
||||
* Record the uri
|
||||
*
|
||||
* @param string $uri
|
||||
*/
|
||||
public function setUri($uri);
|
||||
|
||||
/**
|
||||
* Return user@host, or just host if there is no user. Returns
|
||||
* an empty string if there is no host.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function remoteHostWithUser();
|
||||
|
||||
/**
|
||||
* Get the remote user
|
||||
*/
|
||||
public function remoteUser();
|
||||
|
||||
/**
|
||||
* Return true if this alias record has a remote user
|
||||
*/
|
||||
public function hasRemoteUser();
|
||||
|
||||
/**
|
||||
* Get the remote host
|
||||
*/
|
||||
public function remoteHost();
|
||||
|
||||
/**
|
||||
* Return true if this alias record has a remote host that is not
|
||||
* the local host
|
||||
*/
|
||||
public function isRemote();
|
||||
|
||||
/**
|
||||
* Return true if this alias record is for the local system
|
||||
*/
|
||||
public function isLocal();
|
||||
|
||||
/**
|
||||
* Determine whether this alias does not represent any site. An
|
||||
* alias record must either be remote or have a root.
|
||||
*/
|
||||
public function isNone();
|
||||
|
||||
/**
|
||||
* Return the 'root' element of this alias if this alias record
|
||||
* is local.
|
||||
*/
|
||||
public function localRoot();
|
||||
|
||||
/**
|
||||
* Export the configuration values in this alias record, and reconfigure
|
||||
* them so that the layout matches that of the global configuration object.
|
||||
*/
|
||||
public function exportConfig();
|
||||
}
|
145
vendor/consolidation/site-alias/src/Cli/SiteAliasCommands.php
vendored
Normal file
145
vendor/consolidation/site-alias/src/Cli/SiteAliasCommands.php
vendored
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace Consolidation\SiteAlias\Cli;
|
||||
|
||||
use Consolidation\SiteAlias\SiteAliasFileLoader;
|
||||
use Consolidation\SiteAlias\SiteAliasManager;
|
||||
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
|
||||
use Consolidation\SiteAlias\SiteSpecParser;
|
||||
use Consolidation\SiteAlias\SiteAliasName;
|
||||
|
||||
class SiteAliasCommands extends \Robo\Tasks
|
||||
{
|
||||
protected $aliasLoader;
|
||||
|
||||
/**
|
||||
* List available site aliases.
|
||||
*
|
||||
* @command site:list
|
||||
* @format yaml
|
||||
* @return array
|
||||
*/
|
||||
public function siteList(array $varArgs)
|
||||
{
|
||||
$this->aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->aliasLoader->addLoader('yml', $ymlLoader);
|
||||
$aliasName = $this->getLocationsAndAliasName($varArgs, $this->aliasLoader);
|
||||
|
||||
$this->manager = new SiteAliasManager($this->aliasLoader);
|
||||
|
||||
return $this->renderAliases($this->manager->getMultiple($aliasName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load available site aliases.
|
||||
*
|
||||
* @command site:load
|
||||
* @format yaml
|
||||
* @return array
|
||||
*/
|
||||
public function siteLoad(array $dirs)
|
||||
{
|
||||
$this->aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->aliasLoader->addLoader('yml', $ymlLoader);
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
$this->io()->note("Add search location: $dir");
|
||||
$this->aliasLoader->addSearchLocation($dir);
|
||||
}
|
||||
|
||||
$all = $this->aliasLoader->loadAll();
|
||||
|
||||
return $this->renderAliases($all);
|
||||
}
|
||||
|
||||
protected function getLocationsAndAliasName($varArgs)
|
||||
{
|
||||
$aliasName = '';
|
||||
foreach ($varArgs as $arg) {
|
||||
if (SiteAliasName::isAliasName($arg)) {
|
||||
$this->io()->note("Alias parameter: '$arg'");
|
||||
$aliasName = $arg;
|
||||
} else {
|
||||
$this->io()->note("Add search location: $arg");
|
||||
$this->aliasLoader->addSearchLocation($arg);
|
||||
}
|
||||
}
|
||||
return $aliasName;
|
||||
}
|
||||
|
||||
protected function renderAliases($all)
|
||||
{
|
||||
if (empty($all)) {
|
||||
throw new \Exception("No aliases found");
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($all as $name => $alias) {
|
||||
$result[$name] = $alias->export();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show contents of a single site alias.
|
||||
*
|
||||
* @command site:get
|
||||
* @format yaml
|
||||
* @return array
|
||||
*/
|
||||
public function siteGet(array $varArgs)
|
||||
{
|
||||
$this->aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->aliasLoader->addLoader('yml', $ymlLoader);
|
||||
$aliasName = $this->getLocationsAndAliasName($varArgs, $this->aliasLoader);
|
||||
|
||||
$manager = new SiteAliasManager($this->aliasLoader);
|
||||
$result = $manager->get($aliasName);
|
||||
if (!$result) {
|
||||
throw new \Exception("No alias found");
|
||||
}
|
||||
|
||||
return $result->export();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access a value from a single alias.
|
||||
*
|
||||
* @command site:value
|
||||
* @format yaml
|
||||
* @return string
|
||||
*/
|
||||
public function siteValue(array $varArgs)
|
||||
{
|
||||
$this->aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->aliasLoader->addLoader('yml', $ymlLoader);
|
||||
$key = array_pop($varArgs);
|
||||
$aliasName = $this->getLocationsAndAliasName($varArgs, $this->aliasLoader);
|
||||
|
||||
$manager = new SiteAliasManager($this->aliasLoader);
|
||||
$result = $manager->get($aliasName);
|
||||
if (!$result) {
|
||||
throw new \Exception("No alias found");
|
||||
}
|
||||
|
||||
return $result->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a site specification.
|
||||
*
|
||||
* @command site-spec:parse
|
||||
* @format yaml
|
||||
* @return array
|
||||
*/
|
||||
public function parse($spec, $options = ['root' => ''])
|
||||
{
|
||||
$parser = new SiteSpecParser();
|
||||
return $parser->parse($spec, $options['root']);
|
||||
}
|
||||
}
|
10
vendor/consolidation/site-alias/src/DataFileLoaderInterface.php
vendored
Normal file
10
vendor/consolidation/site-alias/src/DataFileLoaderInterface.php
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
interface DataFileLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function load($path);
|
||||
}
|
278
vendor/consolidation/site-alias/src/HostPath.php
vendored
Normal file
278
vendor/consolidation/site-alias/src/HostPath.php
vendored
Normal file
|
@ -0,0 +1,278 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\Config\Config;
|
||||
use Consolidation\Config\ConfigInterface;
|
||||
use Webmozart\PathUtil\Path;
|
||||
|
||||
/**
|
||||
* A host path is a path on some machine. The machine may be specified
|
||||
* by a label, and the label may be an @alias or a site specification.
|
||||
* If there is no label, then the local machine is assumed.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* @alias
|
||||
* @alias:/path
|
||||
* host:/path
|
||||
* user@host:/path
|
||||
* user@host/drupal-root#uri:/path
|
||||
* /path
|
||||
*
|
||||
* Note that /path does not have to begin with a '/'; it may
|
||||
* be a relative path, or it may begin with a path alias,
|
||||
* e.g. '%files'.
|
||||
*
|
||||
* It is permissible to have an alias or site specification
|
||||
* without a path, but it is not valid to have just a host
|
||||
* with no path.
|
||||
*/
|
||||
class HostPath
|
||||
{
|
||||
/** @var AliasRecord The alias record obtained from the host path */
|
||||
protected $alias_record;
|
||||
|
||||
/** @var string The entire original host path (e.g. @alias:/path) */
|
||||
protected $original_path;
|
||||
|
||||
/** @var string The "path" component from the host path */
|
||||
protected $path;
|
||||
|
||||
/** @var string The alias record is implicit (e.g. 'path' instead of '@self:path') */
|
||||
protected $implicit;
|
||||
|
||||
/**
|
||||
* HostPath constructor
|
||||
*
|
||||
* @param AliasRecord $alias_record The alias record or site specification record
|
||||
* @param string $original_path The original host path
|
||||
* @param string $path Just the 'path' component
|
||||
*/
|
||||
protected function __construct($alias_record, $original_path, $path = '', $implicit = false)
|
||||
{
|
||||
$this->alias_record = $alias_record;
|
||||
$this->original_path = $original_path;
|
||||
$this->path = $path;
|
||||
$this->implicit = $implicit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a host path.
|
||||
*
|
||||
* @param SiteAliasManager $manager We need to be provided a reference
|
||||
* to the alias manager to create a host path
|
||||
* @param string $hostPath The path to create.
|
||||
*/
|
||||
public static function create(SiteAliasManager $manager, $hostPath)
|
||||
{
|
||||
// Split the alias path up into
|
||||
// - $parts[0]: everything before the first ":"
|
||||
// - $parts[1]: everything after the ":", if there was one.
|
||||
$parts = explode(':', $hostPath, 2);
|
||||
|
||||
// Determine whether or not $parts[0] is a site spec or an alias
|
||||
// record. If $parts[0] is not in the right form, the result
|
||||
// will be 'false'. This will throw if $parts[0] is an @alias
|
||||
// record, but the requested alias cannot be found.
|
||||
$alias_record = $manager->get($parts[0]);
|
||||
|
||||
if (!isset($parts[1])) {
|
||||
return static::determinePathOrAlias($manager, $alias_record, $hostPath, $parts[0]);
|
||||
}
|
||||
|
||||
// If $parts[0] did not resolve to a site spec or alias record,
|
||||
// but there is a $parts[1], then $parts[0] must be a machine name.
|
||||
// Unless it was an alias that could not be found.
|
||||
if ($alias_record === false) {
|
||||
if (SiteAliasName::isAliasName($parts[0])) {
|
||||
throw new \Exception('Site alias ' . $parts[0] . ' not found.');
|
||||
}
|
||||
$alias_record = new AliasRecord(['host' => $parts[0]]);
|
||||
}
|
||||
|
||||
// Create our alias path
|
||||
return new HostPath($alias_record, $hostPath, $parts[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the alias record portion of the host path.
|
||||
*
|
||||
* @return AliasRecord
|
||||
*/
|
||||
public function getAliasRecord()
|
||||
{
|
||||
return $this->alias_record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this host path points at a remote machine
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRemote()
|
||||
{
|
||||
return $this->alias_record->isRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return just the path portion, without considering the alias root.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original host path string, as provided to the create() method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginal()
|
||||
{
|
||||
return $this->original_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return just the path portion of the host path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
if (empty($this->path)) {
|
||||
return $this->alias_record->root();
|
||||
}
|
||||
if ($this->alias_record->hasRoot() && !$this->implicit) {
|
||||
return Path::makeAbsolute($this->path, $this->alias_record->root());
|
||||
}
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the path portion of the host path begins with a
|
||||
* path alias (e.g. '%files'). Path aliases must appear at the beginning
|
||||
* of the path.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPathAlias()
|
||||
{
|
||||
$pathAlias = $this->getPathAlias();
|
||||
return !empty($pathAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return just the path alias portion of the path (e.g. '%files'), or
|
||||
* empty if there is no alias in the path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathAlias()
|
||||
{
|
||||
if (preg_match('#%([^/]*).*#', $this->path, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the path alias portion of the path with the resolved path.
|
||||
*
|
||||
* @param string $resolvedPath The converted path alias (e.g. 'sites/default/files')
|
||||
* @return $this
|
||||
*/
|
||||
public function replacePathAlias($resolvedPath)
|
||||
{
|
||||
$pathAlias = $this->getPathAlias();
|
||||
if (empty($pathAlias)) {
|
||||
return $this;
|
||||
}
|
||||
// Make sure that the resolved path always ends in a '\'.
|
||||
$resolvedPath .= '/';
|
||||
// Avoid double / in path.
|
||||
// $this->path: %files/foo
|
||||
// $pathAlias: files
|
||||
// We add one to the length of $pathAlias to account for the '%' in $this->path.
|
||||
if (strlen($this->path) > (strlen($pathAlias) + 1)) {
|
||||
$resolvedPath = rtrim($resolvedPath, '/');
|
||||
}
|
||||
// Once the path alias is resolved, replace the alias in the $path with the result.
|
||||
$this->path = $resolvedPath . substr($this->path, strlen($pathAlias) + 1);
|
||||
|
||||
// Using a path alias such as %files is equivalent to making explicit
|
||||
// use of @self:%files. We set implicit to false here so that the resolved
|
||||
// path will be returned as an absolute path rather than a relative path.
|
||||
$this->implicit = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the host portion of the host path, including the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->alias_record->remoteHostWithUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fully resolved path, e.g. user@server:/path/to/drupalroot/sites/default/files
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fullyQualifiedPath()
|
||||
{
|
||||
$host = $this->getHost();
|
||||
if (!empty($host)) {
|
||||
return $host . ':' . $this->getPath();
|
||||
}
|
||||
return $this->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Our fully qualified path passes the result through Path::makeAbsolute()
|
||||
* which canonicallizes the path, removing any trailing slashes.
|
||||
* That is what we want most of the time; however, the trailing slash is
|
||||
* sometimes significant, e.g. for rsync, so we provide a separate API
|
||||
* for those cases where the trailing slash should be preserved.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fullyQualifiedPathPreservingTrailingSlash()
|
||||
{
|
||||
$fqp = $this->fullyQualifiedPath();
|
||||
if ((substr($this->path, strlen($this->path) - 1) == '/') && (substr($fqp, strlen($fqp) - 1) != '/')) {
|
||||
$fqp .= '/';
|
||||
}
|
||||
return $fqp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for HostPath::create(). When the host path contains no
|
||||
* ':', this method determines whether the string that was provided is
|
||||
* a host or a path.
|
||||
*
|
||||
* @param SiteAliasManager $manager
|
||||
* @param AliasRecord|bool $alias_record
|
||||
* @param string $hostPath
|
||||
* @param string $single_part
|
||||
*/
|
||||
protected static function determinePathOrAlias(SiteAliasManager $manager, $alias_record, $hostPath, $single_part)
|
||||
{
|
||||
// If $alias_record is false, then $single_part must be a path.
|
||||
if ($alias_record === false) {
|
||||
return new HostPath($manager->getSelf(), $hostPath, $single_part, true);
|
||||
}
|
||||
|
||||
// Otherwise, we have a alias record without a path.
|
||||
// In this instance, the alias record _must_ have a root.
|
||||
if (!$alias_record->hasRoot()) {
|
||||
throw new \Exception("$hostPath does not define a path.");
|
||||
}
|
||||
return new HostPath($alias_record, $hostPath);
|
||||
}
|
||||
}
|
213
vendor/consolidation/site-alias/src/SiteAliasFileDiscovery.php
vendored
Normal file
213
vendor/consolidation/site-alias/src/SiteAliasFileDiscovery.php
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
/**
|
||||
* Discover alias files named:
|
||||
*
|
||||
* - sitename.site.yml: contains multiple aliases, one for each of the
|
||||
* environments of 'sitename'.
|
||||
*
|
||||
* Drush aliases that contain both a site name and an environment
|
||||
* (e.g. @site.env) will cause Drush to find the file named after
|
||||
* the respective site name and retrieve the specified environment
|
||||
* record.
|
||||
*
|
||||
* Sites may also define a special alias file self.site.yml, which
|
||||
* may be stored in the drush/sites directory relative to either
|
||||
* the Drupal root or the Composer root of the site. The environments
|
||||
* in this file will be merged with the available environments for
|
||||
* the element @self, however it is defined.
|
||||
*/
|
||||
class SiteAliasFileDiscovery
|
||||
{
|
||||
protected $searchLocations;
|
||||
protected $locationFilter;
|
||||
protected $depth;
|
||||
|
||||
public function __construct($searchLocations = [], $depth = '<= 1', $locationFilter = null)
|
||||
{
|
||||
$this->locationFilter = $locationFilter;
|
||||
$this->searchLocations = $searchLocations;
|
||||
$this->depth = $depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a location that alias files may be found.
|
||||
*
|
||||
* @param string $path
|
||||
* @return $this
|
||||
*/
|
||||
public function addSearchLocation($paths)
|
||||
{
|
||||
foreach ((array)$paths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$this->searchLocations[] = $path;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the paths where alias files may be found.
|
||||
* @return string[]
|
||||
*/
|
||||
public function searchLocations()
|
||||
{
|
||||
return $this->searchLocations;
|
||||
}
|
||||
|
||||
public function locationFilter()
|
||||
{
|
||||
return $this->locationFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the search depth for finding alias files
|
||||
*
|
||||
* @param string|int $depth (@see \Symfony\Component\Finder\Finder::depth)
|
||||
* @return $this
|
||||
*/
|
||||
public function depth($depth)
|
||||
{
|
||||
$this->depth = $depth;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only search for aliases that are in alias files stored in directories
|
||||
* whose basename or key matches the specified location.
|
||||
*/
|
||||
public function filterByLocation($location)
|
||||
{
|
||||
if (empty($location)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return new SiteAliasFileDiscovery($this->searchLocations(), $this->depth, $location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an alias file SITENAME.site.yml in one
|
||||
* of the specified search locations.
|
||||
*
|
||||
* @param string $siteName
|
||||
* @return string[]
|
||||
*/
|
||||
public function find($siteName)
|
||||
{
|
||||
return $this->searchForAliasFiles("$siteName.site.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an alias file SITENAME.site.yml in one
|
||||
* of the specified search locations.
|
||||
*
|
||||
* @param string $siteName
|
||||
* @return string|bool
|
||||
*/
|
||||
public function findSingleSiteAliasFile($siteName)
|
||||
{
|
||||
$matches = $this->find($siteName);
|
||||
if (empty($matches)) {
|
||||
return false;
|
||||
}
|
||||
return reset($matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all SITENAME.site.yml files in any of
|
||||
* the search locations.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function findAllSingleAliasFiles()
|
||||
{
|
||||
return $this->searchForAliasFiles('*.site.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the legacy alias files used in previous Drush versions.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function findAllLegacyAliasFiles()
|
||||
{
|
||||
return array_merge(
|
||||
$this->searchForAliasFiles('*.alias.drushrc.php'),
|
||||
$this->searchForAliasFiles('*.aliases.drushrc.php'),
|
||||
$this->searchForAliasFiles('aliases.drushrc.php')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Symfony Finder object to search all available search locations
|
||||
* for the specified search pattern.
|
||||
*
|
||||
* @param string $searchPattern
|
||||
* @return Finder
|
||||
*/
|
||||
protected function createFinder($searchPattern)
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->files()
|
||||
->name($searchPattern)
|
||||
->in($this->searchLocations)
|
||||
->depth($this->depth);
|
||||
return $finder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all alias files matching the provided pattern.
|
||||
*
|
||||
* @param string $searchPattern
|
||||
* @return string[]
|
||||
*/
|
||||
protected function searchForAliasFiles($searchPattern)
|
||||
{
|
||||
if (empty($this->searchLocations)) {
|
||||
return [];
|
||||
}
|
||||
list($match, $site) = $this->splitLocationFromSite($this->locationFilter);
|
||||
if (!empty($site)) {
|
||||
$searchPattern = str_replace('*', $site, $searchPattern);
|
||||
}
|
||||
$finder = $this->createFinder($searchPattern);
|
||||
$result = [];
|
||||
foreach ($finder as $file) {
|
||||
$path = $file->getRealPath();
|
||||
$result[] = $path;
|
||||
}
|
||||
// Find every location where the parent directory name matches
|
||||
// with the first part of the search pattern.
|
||||
// In theory we can use $finder->path() instead. That didn't work well,
|
||||
// in practice, though; had trouble correctly escaping the path separators.
|
||||
if (!empty($this->locationFilter)) {
|
||||
$result = array_filter($result, function ($path) use ($match) {
|
||||
return SiteAliasName::locationFromPath($path) === $match;
|
||||
});
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* splitLocationFromSite returns the part of 'site' before the first
|
||||
* '.' as the "path match" component, and the part after the first
|
||||
* '.' as the "site" component.
|
||||
*/
|
||||
protected function splitLocationFromSite($site)
|
||||
{
|
||||
$parts = explode('.', $site, 3) + ['', '', ''];
|
||||
|
||||
return array_slice($parts, 0, 2);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Seems like this could just be basename()
|
||||
protected function extractKey($basename, $filenameExensions)
|
||||
{
|
||||
return str_replace($filenameExensions, '', $basename);
|
||||
}
|
||||
}
|
596
vendor/consolidation/site-alias/src/SiteAliasFileLoader.php
vendored
Normal file
596
vendor/consolidation/site-alias/src/SiteAliasFileLoader.php
vendored
Normal file
|
@ -0,0 +1,596 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\Config\Loader\ConfigProcessor;
|
||||
use Dflydev\DotAccessData\Util as DotAccessDataUtil;
|
||||
|
||||
/**
|
||||
* Discover alias files:
|
||||
*
|
||||
* - sitename.site.yml: contains multiple aliases, one for each of the
|
||||
* environments of 'sitename'.
|
||||
*/
|
||||
class SiteAliasFileLoader
|
||||
{
|
||||
/**
|
||||
* @var SiteAliasFileDiscovery
|
||||
*/
|
||||
protected $discovery;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $referenceData;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* SiteAliasFileLoader constructor
|
||||
*
|
||||
* @param SiteAliasFileDiscovery|null $discovery
|
||||
*/
|
||||
public function __construct($discovery = null)
|
||||
{
|
||||
$this->discovery = $discovery ?: new SiteAliasFileDiscovery();
|
||||
$this->referenceData = [];
|
||||
$this->loader = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow configuration data to be used in replacements in the alias file.
|
||||
*/
|
||||
public function setReferenceData($data)
|
||||
{
|
||||
$this->referenceData = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a search location to our discovery object.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSearchLocation($path)
|
||||
{
|
||||
$this->discovery()->addSearchLocation($path);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return our discovery object.
|
||||
*
|
||||
* @return SiteAliasFileDiscovery
|
||||
*/
|
||||
public function discovery()
|
||||
{
|
||||
return $this->discovery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file containing the specified alias name.
|
||||
*
|
||||
* @param SiteAliasName $aliasName
|
||||
*
|
||||
* @return AliasRecord|false
|
||||
*/
|
||||
public function load(SiteAliasName $aliasName)
|
||||
{
|
||||
// First attempt to load a sitename.site.yml file for the alias.
|
||||
$aliasRecord = $this->loadSingleAliasFile($aliasName);
|
||||
if ($aliasRecord) {
|
||||
return $aliasRecord;
|
||||
}
|
||||
|
||||
// If aliasname was provides as @site.env and we did not find it,
|
||||
// then we are done.
|
||||
if ($aliasName->hasSitename()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If $aliasName was provided as `@foo` (`hasSitename()` returned `false`
|
||||
// above), then this was interpreted as `@self.foo` when we searched
|
||||
// above. If we could not find an alias record for `@self.foo`, then we
|
||||
// will try to search again, this time with the assumption that `@foo`
|
||||
// might be `@foo.<default>`, where `<default>` is the default
|
||||
// environment for the specified site. Note that in this instance, the
|
||||
// sitename will be found in $aliasName->env().
|
||||
$sitename = $aliasName->env();
|
||||
return $this->loadDefaultEnvFromSitename($sitename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given only a site name, load the default environment from it.
|
||||
*/
|
||||
protected function loadDefaultEnvFromSitename($sitename)
|
||||
{
|
||||
$path = $this->discovery()->findSingleSiteAliasFile($sitename);
|
||||
if (!$path) {
|
||||
return false;
|
||||
}
|
||||
$data = $this->loadSiteDataFromPath($path);
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$env = $this->getDefaultEnvironmentName($data);
|
||||
|
||||
$aliasName = new SiteAliasName($sitename, $env);
|
||||
$processor = new ConfigProcessor();
|
||||
return $this->fetchAliasRecordFromSiteAliasData($aliasName, $processor, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all site aliases loadable from any findable path.
|
||||
*
|
||||
* @return AliasRecord[]
|
||||
*/
|
||||
public function loadAll()
|
||||
{
|
||||
$result = [];
|
||||
$paths = $this->discovery()->findAllSingleAliasFiles();
|
||||
foreach ($paths as $path) {
|
||||
$aliasRecords = $this->loadSingleSiteAliasFileAtPath($path);
|
||||
if ($aliasRecords) {
|
||||
foreach ($aliasRecords as $aliasRecord) {
|
||||
$this->storeAliasRecordInResut($result, $aliasRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all available alias files. Does not include
|
||||
* legacy files.
|
||||
*
|
||||
* @param string $location Only consider alias files in the specified location.
|
||||
* @return string[]
|
||||
*/
|
||||
public function listAll($location = '')
|
||||
{
|
||||
return $this->discovery()->filterByLocation($location)->findAllSingleAliasFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an alias name that might represent multiple sites,
|
||||
* return a list of all matching alias records. If nothing was found,
|
||||
* or the name represents a single site + env, then we take
|
||||
* no action and return `false`.
|
||||
*
|
||||
* @param string $sitename The site name to return all environments for.
|
||||
* @return AliasRecord[]|false
|
||||
*/
|
||||
public function loadMultiple($sitename, $location = null)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->discovery()->filterByLocation($location)->find($sitename) as $path) {
|
||||
if ($siteData = $this->loadSiteDataFromPath($path)) {
|
||||
$location = SiteAliasName::locationFromPath($path);
|
||||
// Convert the raw array into a list of alias records.
|
||||
$result = array_merge(
|
||||
$result,
|
||||
$this->createAliasRecordsFromSiteData($sitename, $siteData, $location)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a location, return all alias files located there.
|
||||
*
|
||||
* @param string $location The location to filter.
|
||||
* @return AliasRecord[]
|
||||
*/
|
||||
public function loadLocation($location)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->listAll($location) as $path) {
|
||||
if ($siteData = $this->loadSiteDataFromPath($path)) {
|
||||
$location = SiteAliasName::locationFromPath($path);
|
||||
$sitename = $this->siteNameFromPath($path);
|
||||
// Convert the raw array into a list of alias records.
|
||||
$result = array_merge(
|
||||
$result,
|
||||
$this->createAliasRecordsFromSiteData($sitename, $siteData, $location)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $siteData list of sites with its respective data
|
||||
*
|
||||
* @param SiteAliasName $aliasName The name of the record being created
|
||||
* @param $siteData An associative array of envrionment => site data
|
||||
* @return AliasRecord[]
|
||||
*/
|
||||
protected function createAliasRecordsFromSiteData($sitename, $siteData, $location = '')
|
||||
{
|
||||
$result = [];
|
||||
if (!is_array($siteData) || empty($siteData)) {
|
||||
return $result;
|
||||
}
|
||||
foreach ($siteData as $envName => $data) {
|
||||
if (is_array($data) && $this->isValidEnvName($envName)) {
|
||||
$aliasName = new SiteAliasName($sitename, $envName, $location);
|
||||
|
||||
$processor = new ConfigProcessor();
|
||||
$oneRecord = $this->fetchAliasRecordFromSiteAliasData($aliasName, $processor, $siteData);
|
||||
$this->storeAliasRecordInResut($result, $oneRecord);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* isValidEnvName determines if a given entry should be skipped or not
|
||||
* (e.g. the "common" entry).
|
||||
*
|
||||
* @param string $envName The environment name to test
|
||||
*/
|
||||
protected function isValidEnvName($envName)
|
||||
{
|
||||
return $envName != 'common';
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an alias record in a list. If the alias record has
|
||||
* a known name, then the key of the list will be the record's name.
|
||||
* Otherwise, append the record to the end of the list with
|
||||
* a numeric index.
|
||||
*
|
||||
* @param &AliasRecord[] $result list of alias records
|
||||
* @param AliasRecord $aliasRecord one more alias to store in the result
|
||||
*/
|
||||
protected function storeAliasRecordInResut(&$result, AliasRecord $aliasRecord)
|
||||
{
|
||||
if (!$aliasRecord) {
|
||||
return;
|
||||
}
|
||||
$key = $aliasRecord->name();
|
||||
if (empty($key)) {
|
||||
$result[] = $aliasRecord;
|
||||
return;
|
||||
}
|
||||
$result[$key] = $aliasRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the alias name is '@sitename', or if it is '@sitename.env', then
|
||||
* look for a sitename.site.yml file that contains it. We also handle
|
||||
* '@location.sitename.env' here as well.
|
||||
*
|
||||
* @param SiteAliasName $aliasName
|
||||
*
|
||||
* @return AliasRecord|false
|
||||
*/
|
||||
protected function loadSingleAliasFile(SiteAliasName $aliasName)
|
||||
{
|
||||
// Check to see if the appropriate sitename.alias.yml file can be
|
||||
// found. Return if it cannot.
|
||||
$path = $this->discovery()
|
||||
->filterByLocation($aliasName->location())
|
||||
->findSingleSiteAliasFile($aliasName->sitename());
|
||||
if (!$path) {
|
||||
return false;
|
||||
}
|
||||
return $this->loadSingleAliasFileWithNameAtPath($aliasName, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given only the path to an alias file `site.alias.yml`, return all
|
||||
* of the alias records for every environment stored in that file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return AliasRecord[]
|
||||
*/
|
||||
protected function loadSingleSiteAliasFileAtPath($path)
|
||||
{
|
||||
$sitename = $this->siteNameFromPath($path);
|
||||
$location = SiteAliasName::locationFromPath($path);
|
||||
if ($siteData = $this->loadSiteDataFromPath($path)) {
|
||||
return $this->createAliasRecordsFromSiteData($sitename, $siteData, $location);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the path to a single site alias file `site.alias.yml`,
|
||||
* return the `site` part.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
protected function siteNameFromPath($path)
|
||||
{
|
||||
return $this->basenameWithoutExtension($path, '.site.yml');
|
||||
|
||||
// OR:
|
||||
// $filename = basename($path);
|
||||
// return preg_replace('#\..*##', '', $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chop off the `aliases.yml` or `alias.yml` part of a path. This works
|
||||
* just like `basename`, except it will throw if the provided path
|
||||
* does not end in the specified extension.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $extension
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function basenameWithoutExtension($path, $extension)
|
||||
{
|
||||
$result = basename($path, $extension);
|
||||
// It is an error if $path does not end with site.yml
|
||||
if ($result == basename($path)) {
|
||||
throw new \Exception("$path must end with '$extension'");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an alias name and a path, load the data from the path
|
||||
* and process it as needed to generate the alias record.
|
||||
*
|
||||
* @param SiteAliasName $aliasName
|
||||
* @param string $path
|
||||
* @return AliasRecord|false
|
||||
*/
|
||||
protected function loadSingleAliasFileWithNameAtPath(SiteAliasName $aliasName, $path)
|
||||
{
|
||||
$data = $this->loadSiteDataFromPath($path);
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$processor = new ConfigProcessor();
|
||||
return $this->fetchAliasRecordFromSiteAliasData($aliasName, $processor, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the yml from the given path
|
||||
*
|
||||
* @param string $path
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function loadSiteDataFromPath($path)
|
||||
{
|
||||
$data = $this->loadData($path);
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$selfSiteAliases = $this->findSelfSiteAliases($data);
|
||||
$data = array_merge($data, $selfSiteAliases);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of site aliases, find the first one that is
|
||||
* local (has no 'host' item) and also contains a 'self.site.yml' file.
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function findSelfSiteAliases($site_aliases)
|
||||
{
|
||||
foreach ($site_aliases as $site => $data) {
|
||||
if (!isset($data['host']) && isset($data['root'])) {
|
||||
foreach (['.', '..'] as $relative_path) {
|
||||
$candidate = $data['root'] . '/' . $relative_path . '/drush/sites/self.site.yml';
|
||||
if (file_exists($candidate)) {
|
||||
return $this->loadData($candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the contents of the specified file.
|
||||
*
|
||||
* @param string $path Path to file to load
|
||||
* @return array
|
||||
*/
|
||||
protected function loadData($path)
|
||||
{
|
||||
if (empty($path) || !file_exists($path)) {
|
||||
return [];
|
||||
}
|
||||
$loader = $this->getLoader(pathinfo($path, PATHINFO_EXTENSION));
|
||||
if (!$loader) {
|
||||
return [];
|
||||
}
|
||||
return $loader->load($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataFileLoaderInterface
|
||||
*/
|
||||
public function getLoader($extension)
|
||||
{
|
||||
if (!isset($this->loader[$extension])) {
|
||||
return null;
|
||||
}
|
||||
return $this->loader[$extension];
|
||||
}
|
||||
|
||||
public function addLoader($extension, DataFileLoaderInterface $loader)
|
||||
{
|
||||
$this->loader[$extension] = $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array containing site alias data, return an alias record
|
||||
* containing the data for the requested record. If there is a 'common'
|
||||
* section, then merge that in as well.
|
||||
*
|
||||
* @param SiteAliasName $aliasName the alias we are loading
|
||||
* @param array $data
|
||||
*
|
||||
* @return AliasRecord|false
|
||||
*/
|
||||
protected function fetchAliasRecordFromSiteAliasData(SiteAliasName $aliasName, ConfigProcessor $processor, array $data)
|
||||
{
|
||||
$data = $this->adjustIfSingleAlias($data);
|
||||
$env = $this->getEnvironmentName($aliasName, $data);
|
||||
$env_data = $this->getRequestedEnvData($data, $env);
|
||||
if (!$env_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the 'common' section if it exists.
|
||||
if ($this->siteEnvExists($data, 'common')) {
|
||||
$processor->add($data['common']);
|
||||
}
|
||||
|
||||
// Then add the data from the desired environment.
|
||||
$processor->add($env_data);
|
||||
|
||||
// Export the combined data and create an AliasRecord object to manage it.
|
||||
return new AliasRecord($processor->export($this->referenceData + ['env-name' => $env]), '@' . $aliasName->sitenameWithLocation(), $env);
|
||||
}
|
||||
|
||||
/**
|
||||
* getRequestedEnvData fetches the data for the specified environment
|
||||
* from the provided site record data.
|
||||
*
|
||||
* @param array $data The site alias data
|
||||
* @param string $env The name of the environment desired
|
||||
* @return array|false
|
||||
*/
|
||||
protected function getRequestedEnvData(array $data, $env)
|
||||
{
|
||||
// If the requested environment exists, we will use it.
|
||||
if ($this->siteEnvExists($data, $env)) {
|
||||
return $data[$env];
|
||||
}
|
||||
|
||||
// If there is a wildcard environment, then return that instead.
|
||||
if ($this->siteEnvExists($data, '*')) {
|
||||
return $data['*'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there is a valid-looking environment '$env' in the
|
||||
* provided site alias data.
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $env
|
||||
* @return bool
|
||||
*/
|
||||
protected function siteEnvExists(array $data, $env)
|
||||
{
|
||||
return (
|
||||
is_array($data) &&
|
||||
isset($data[$env]) &&
|
||||
is_array($data[$env])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the alias data for a single-site alias. Usually, a .yml alias
|
||||
* file will contain multiple entries, one for each of the environments
|
||||
* of an alias. If there are no environments
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function adjustIfSingleAlias($data)
|
||||
{
|
||||
if (!$this->detectSingleAlias($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$result = [
|
||||
'default' => $data,
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A single-environment alias looks something like this:
|
||||
*
|
||||
* ---
|
||||
* root: /path/to/drupal
|
||||
* uri: https://mysite.org
|
||||
*
|
||||
* A multiple-environment alias looks something like this:
|
||||
*
|
||||
* ---
|
||||
* default: dev
|
||||
* dev:
|
||||
* root: /path/to/dev
|
||||
* uri: https://dev.mysite.org
|
||||
* stage:
|
||||
* root: /path/to/stage
|
||||
* uri: https://stage.mysite.org
|
||||
*
|
||||
* The differentiator between these two is that the multi-environment
|
||||
* alias always has top-level elements that are associative arrays, and
|
||||
* the single-environment alias never does.
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
protected function detectSingleAlias($data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value) && DotAccessDataUtil::isAssoc($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the environment requested.
|
||||
*
|
||||
* @param SiteAliasName $aliasName the alias we are loading
|
||||
* @param array $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEnvironmentName(SiteAliasName $aliasName, array $data)
|
||||
{
|
||||
// If the alias name specifically mentions the environment
|
||||
// to use, then return it.
|
||||
if ($aliasName->hasEnv()) {
|
||||
return $aliasName->env();
|
||||
}
|
||||
return $this->getDefaultEnvironmentName($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a data array containing site alias environments, determine which
|
||||
* envirionmnet should be used as the default environment.
|
||||
*
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultEnvironmentName(array $data)
|
||||
{
|
||||
// If there is an entry named 'default', it will either contain the
|
||||
// name of the environment to use by default, or it will itself be
|
||||
// the default environment.
|
||||
if (isset($data['default'])) {
|
||||
return is_array($data['default']) ? 'default' : $data['default'];
|
||||
}
|
||||
// If there is an environment named 'dev', it will be our default.
|
||||
if (isset($data['dev'])) {
|
||||
return 'dev';
|
||||
}
|
||||
// If we don't know which environment to use, just take the first one.
|
||||
$keys = array_keys($data);
|
||||
return reset($keys);
|
||||
}
|
||||
}
|
214
vendor/consolidation/site-alias/src/SiteAliasManager.php
vendored
Normal file
214
vendor/consolidation/site-alias/src/SiteAliasManager.php
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
/**
|
||||
* Site Alias manager
|
||||
*/
|
||||
class SiteAliasManager
|
||||
{
|
||||
protected $aliasLoader;
|
||||
protected $selfAliasRecord;
|
||||
protected $specParser;
|
||||
protected $root = '';
|
||||
|
||||
/**
|
||||
* Constructor for SiteAliasManager
|
||||
*
|
||||
* @param SiteAliasFileLoader|null $aliasLoader an alias loader
|
||||
*/
|
||||
public function __construct($aliasLoader = null, $root = '')
|
||||
{
|
||||
$this->aliasLoader = $aliasLoader ?: new SiteAliasFileLoader();
|
||||
$this->specParser = new SiteSpecParser();
|
||||
$this->selfAliasRecord = new AliasRecord();
|
||||
$this->root = $root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow configuration data to be used in replacements in the alias file.
|
||||
*/
|
||||
public function setReferenceData($data)
|
||||
{
|
||||
$this->aliasLoader->setReferenceData($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the root of the selected site
|
||||
*
|
||||
* @param string $root
|
||||
* @return $this
|
||||
*/
|
||||
public function setRoot($root)
|
||||
{
|
||||
$this->root = $root;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a search location to our site alias discovery object.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSearchLocation($path)
|
||||
{
|
||||
$this->aliasLoader->discovery()->addSearchLocation($path);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add search locations to our site alias discovery object.
|
||||
*
|
||||
* @param array $paths Any path provided in --alias-path option
|
||||
* or drush.path.alias-path configuration item.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSearchLocations(array $paths)
|
||||
{
|
||||
foreach ($paths as $path) {
|
||||
$this->aliasLoader->discovery()->addSearchLocation($path);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the paths where alias files may be found.
|
||||
* @return string[]
|
||||
*/
|
||||
public function searchLocations()
|
||||
{
|
||||
return $this->aliasLoader->discovery()->searchLocations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an alias record by name, or convert a site specification
|
||||
* into an alias record via the site alias spec parser. If a
|
||||
* simple alias name is provided (e.g. '@alias'), it is interpreted
|
||||
* as a sitename, and the default environment for that site is returned.
|
||||
*
|
||||
* @param string $name Alias name or site specification
|
||||
*
|
||||
* @return AliasRecord|false
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (SiteAliasName::isAliasName($name)) {
|
||||
return $this->getAlias($name);
|
||||
}
|
||||
|
||||
if ($this->specParser->validSiteSpec($name)) {
|
||||
return new AliasRecord($this->specParser->parse($name, $this->root), $name);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the '@self' alias record.
|
||||
*
|
||||
* @return AliasRecord
|
||||
*/
|
||||
public function getSelf()
|
||||
{
|
||||
return $this->selfAliasRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force-set the current @self alias.
|
||||
*
|
||||
* @param AliasRecord $selfAliasRecord
|
||||
* @return $this
|
||||
*/
|
||||
public function setSelf(AliasRecord $selfAliasRecord)
|
||||
{
|
||||
$this->selfAliasRecord = $selfAliasRecord;
|
||||
$this->setRoot($selfAliasRecord->localRoot());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an alias record from a name. Does not accept site specifications.
|
||||
*
|
||||
* @param string $aliasName alias name
|
||||
*
|
||||
* @return AliasRecord
|
||||
*/
|
||||
public function getAlias($aliasName)
|
||||
{
|
||||
$aliasName = SiteAliasName::parse($aliasName);
|
||||
|
||||
if ($aliasName->isSelf()) {
|
||||
return $this->getSelf();
|
||||
}
|
||||
|
||||
if ($aliasName->isNone()) {
|
||||
return new AliasRecord([], '@none');
|
||||
}
|
||||
|
||||
// Search through all search locations, load
|
||||
// matching and potentially-matching alias files,
|
||||
// and return the alias matching the provided name.
|
||||
return $this->aliasLoader->load($aliasName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a simple alias name, e.g. '@alias', returns all of the
|
||||
* environments in the specified site.
|
||||
*
|
||||
* If the provided name is a site specification et. al.,
|
||||
* then this method will return 'false'.
|
||||
*
|
||||
* @param string $name Alias name
|
||||
* @return AliasRecord[]|false
|
||||
*/
|
||||
public function getMultiple($name = '')
|
||||
{
|
||||
if (empty($name)) {
|
||||
return $this->aliasLoader->loadAll();
|
||||
}
|
||||
|
||||
if (!SiteAliasName::isAliasName($name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trim off the '@'
|
||||
$trimmedName = ltrim($name, '@');
|
||||
|
||||
// If the provided name is a location, return all aliases there
|
||||
$result = $this->aliasLoader->loadLocation($trimmedName);
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// If the provided name is a site, return all environments
|
||||
$result = $this->aliasLoader->loadMultiple($trimmedName);
|
||||
if (!empty($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Special checking for @self
|
||||
if ($trimmedName == 'self') {
|
||||
$self = $this->getSelf();
|
||||
$result = array_merge(
|
||||
['@self' => $self],
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the paths to all alias files in all search locations known
|
||||
* to the alias manager.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function listAllFilePaths($location = '')
|
||||
{
|
||||
return $this->aliasLoader->listAll($location);
|
||||
}
|
||||
}
|
23
vendor/consolidation/site-alias/src/SiteAliasManagerAwareInterface.php
vendored
Normal file
23
vendor/consolidation/site-alias/src/SiteAliasManagerAwareInterface.php
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
/**
|
||||
* Inflection interface for the site alias manager.
|
||||
*/
|
||||
interface SiteAliasManagerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @param SiteAliasManager $siteAliasManager
|
||||
*/
|
||||
public function setSiteAliasManager($siteAliasManager);
|
||||
|
||||
/**
|
||||
* @return SiteAliasManager
|
||||
*/
|
||||
public function siteAliasManager();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSiteAliasManager();
|
||||
}
|
34
vendor/consolidation/site-alias/src/SiteAliasManagerAwareTrait.php
vendored
Normal file
34
vendor/consolidation/site-alias/src/SiteAliasManagerAwareTrait.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
/**
|
||||
* Inflection trait for the site alias manager.
|
||||
*/
|
||||
trait SiteAliasManagerAwareTrait
|
||||
{
|
||||
protected $siteAliasManager;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setSiteAliasManager($siteAliasManager)
|
||||
{
|
||||
$this->siteAliasManager = $siteAliasManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SiteAliasManager
|
||||
*/
|
||||
public function siteAliasManager()
|
||||
{
|
||||
return $this->siteAliasManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function hasSiteAliasManager()
|
||||
{
|
||||
return isset($this->siteAliasManager);
|
||||
}
|
||||
}
|
342
vendor/consolidation/site-alias/src/SiteAliasName.php
vendored
Normal file
342
vendor/consolidation/site-alias/src/SiteAliasName.php
vendored
Normal file
|
@ -0,0 +1,342 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
/**
|
||||
* Parse a string that contains a site alias name, and provide convenience
|
||||
* methods to access the parts.
|
||||
*
|
||||
* When provided by users, aliases must be in one of the following forms:
|
||||
*
|
||||
* - @sitename.env: List only sitename and environment.
|
||||
*
|
||||
* - @location.sitename.env: List only sitename and environment. Search
|
||||
* only those paths where the name of the folder holding the alias
|
||||
* files matches 'location'. Location terms may only be used when both
|
||||
* the sitename and env are also provided.
|
||||
*
|
||||
* - @env: Look up a named environment in instances where the site root
|
||||
* is known (e.g. via cwd). In this form, there is an implicit sitename
|
||||
* 'self' which is replaced by the actual site alias name once known.
|
||||
*
|
||||
* - @sitename: Provides only the sitename; uses the 'default' environment,
|
||||
* or 'dev' if there is no 'default' (or whatever is there if there is
|
||||
* only one). With this form, the site alias name has no environment
|
||||
* until the appropriate default environment is looked up. This form
|
||||
* is checked only after `@env` returns no matches. This form can NOT
|
||||
* be filtered with a `location.` term.
|
||||
*
|
||||
* There are also two special aliases that are recognized:
|
||||
*
|
||||
* - @self: The current bootstrapped site.
|
||||
*
|
||||
* - @none: No alias ('root' and 'uri' unset).
|
||||
*
|
||||
* The special alias forms have no environment component.
|
||||
*
|
||||
* When provided to an API, the '@' is optional.
|
||||
*
|
||||
* Note that @sitename and @env are ambiguous. Aliases in this form
|
||||
* (that are not one of the special aliases) will first be assumed
|
||||
* to be @env, and may be converted to @sitename later.
|
||||
*
|
||||
* Note that:
|
||||
*
|
||||
* - 'sitename' and 'env' MUST NOT contain a '.' (unlike previous
|
||||
* versions of Drush).
|
||||
* - Users SHOULD NOT create any environments that have the same name
|
||||
* as any site name (and visa-versa).
|
||||
* - All environments in one site record SHOULD be different versions
|
||||
* of the same site (e.g. dev / test / live).
|
||||
*/
|
||||
class SiteAliasName
|
||||
{
|
||||
protected $location;
|
||||
protected $sitename;
|
||||
protected $env;
|
||||
|
||||
/**
|
||||
* Match the parts of a regex name.
|
||||
*/
|
||||
const ALIAS_NAME_REGEX = '%^@?([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+)?(\.[a-zA-Z0-9_-]+)?$%';
|
||||
|
||||
/**
|
||||
* Create a new site alias name
|
||||
*
|
||||
* @param string $item
|
||||
* @return SiteAliasName
|
||||
*/
|
||||
public static function parse($item)
|
||||
{
|
||||
$aliasName = new self();
|
||||
$aliasName->doParse($item);
|
||||
return $aliasName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The 'location' of an alias file is defined as being the name
|
||||
* of the immediate parent of the alias file. e.g. the path
|
||||
* '$HOME/.drush/sites/isp/mysite.site.yml' would have a location
|
||||
* of 'isp' and a sitename of 'mysite'. The environments of the site
|
||||
* are defined by the alias contents.
|
||||
*
|
||||
* @param type $path
|
||||
* @return type
|
||||
*/
|
||||
public static function locationFromPath($path)
|
||||
{
|
||||
$location = ltrim(basename(dirname($path)), '.');
|
||||
if (($location === 'sites') || ($location === 'drush')) {
|
||||
return '';
|
||||
}
|
||||
return $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creae a SiteAliasName object from an alias name string.
|
||||
*
|
||||
* @param string $sitename The alias name for the site.
|
||||
* @param string $env The name for the site's environment.
|
||||
* @param string $location The location filter for the site.
|
||||
*/
|
||||
public function __construct($sitename = null, $env = null, $location = null)
|
||||
{
|
||||
$this->location = $location;
|
||||
$this->sitename = $sitename;
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an alias name back to a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$parts = [ $this->sitename() ];
|
||||
if ($this->hasLocation()) {
|
||||
array_unshift($parts, $this->location());
|
||||
}
|
||||
if ($this->hasEnv()) {
|
||||
$parts[] = $this->env();
|
||||
}
|
||||
return '@' . implode('.', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not the provided name is an alias name.
|
||||
*
|
||||
* @param string $aliasName
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAliasName($aliasName)
|
||||
{
|
||||
// Alias names provided by users must begin with '@'
|
||||
if (empty($aliasName) || ($aliasName[0] != '@')) {
|
||||
return false;
|
||||
}
|
||||
return preg_match(self::ALIAS_NAME_REGEX, $aliasName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sitename portion of the alias name. By definition,
|
||||
* every alias must have a sitename. If the site name is implicit,
|
||||
* then 'self' is assumed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sitename()
|
||||
{
|
||||
if (empty($this->sitename)) {
|
||||
return 'self';
|
||||
}
|
||||
return $this->sitename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sitename portion of the alias name. By definition,
|
||||
* every alias must have a sitename. If the site name is implicit,
|
||||
* then 'self' is assumed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sitenameWithLocation()
|
||||
{
|
||||
if (empty($this->sitename)) {
|
||||
return 'self';
|
||||
}
|
||||
return (empty($this->location) ? '' : $this->location . '.') . $this->sitename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sitename portion of the alias name
|
||||
*
|
||||
* @param string $sitename
|
||||
*/
|
||||
public function setSitename($sitename)
|
||||
{
|
||||
$this->sitename = $sitename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* In general, all aliases have a sitename. The time when one will not
|
||||
* is when an environment name `@env` is used as a shortcut for `@self.env`
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSitename()
|
||||
{
|
||||
return !empty($this->sitename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this alias name contains an 'env' portion.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnv()
|
||||
{
|
||||
return !empty($this->env);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the environment portion of the alias name.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public function setEnv($env)
|
||||
{
|
||||
$this->env = $env;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 'env' portion of the alias name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function env()
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this alias name contains a 'location' portion
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLocation()
|
||||
{
|
||||
return !empty($this->location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'loation' portion of the alias name.
|
||||
* @param string $location
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->location = $location;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the 'location' portion of the alias name.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public function location()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this alias name is the 'self' alias.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSelf()
|
||||
{
|
||||
return ($this->sitename == 'self') && !isset($this->env);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this alias name is the 'none' alias.
|
||||
*/
|
||||
public function isNone()
|
||||
{
|
||||
return ($this->sitename == 'none') && !isset($this->env);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the parts of an alias name to its various component parts.
|
||||
*
|
||||
* @param string $aliasName a string representation of an alias name.
|
||||
*/
|
||||
protected function doParse($aliasName)
|
||||
{
|
||||
// Example contents of $matches:
|
||||
//
|
||||
// - a.b:
|
||||
// [
|
||||
// 0 => 'a.b',
|
||||
// 1 => 'a',
|
||||
// 2 => '.b',
|
||||
// ]
|
||||
//
|
||||
// - a:
|
||||
// [
|
||||
// 0 => 'a',
|
||||
// 1 => 'a',
|
||||
// ]
|
||||
if (!preg_match(self::ALIAS_NAME_REGEX, $aliasName, $matches)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get rid of $matches[0]
|
||||
array_shift($matches);
|
||||
|
||||
// If $matches contains only one item1, then assume the alias name
|
||||
// contains only the environment.
|
||||
if (count($matches) == 1) {
|
||||
return $this->processSingleItem($matches[0]);
|
||||
}
|
||||
|
||||
// If there are three items, then the first is the location.
|
||||
if (count($matches) == 3) {
|
||||
$this->location = trim(array_shift($matches), '.');
|
||||
}
|
||||
|
||||
// The sitename and env follow the location.
|
||||
$this->sitename = trim(array_shift($matches), '.');
|
||||
$this->env = trim(array_shift($matches), '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an alias name provided as '@sitename'.
|
||||
*
|
||||
* @param string $sitename
|
||||
* @return true
|
||||
*/
|
||||
protected function processSingleItem($item)
|
||||
{
|
||||
if ($this->isSpecialAliasName($item)) {
|
||||
$this->setSitename($item);
|
||||
return true;
|
||||
}
|
||||
$this->sitename = '';
|
||||
$this->env = $item;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the requested name is a special alias name.
|
||||
*
|
||||
* @param string $item
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isSpecialAliasName($item)
|
||||
{
|
||||
return ($item == 'self') || ($item == 'none');
|
||||
}
|
||||
}
|
234
vendor/consolidation/site-alias/src/SiteSpecParser.php
vendored
Normal file
234
vendor/consolidation/site-alias/src/SiteSpecParser.php
vendored
Normal file
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
/**
|
||||
* Parse a string that contains a site specification.
|
||||
*
|
||||
* Site specifications contain some of the following elements:
|
||||
* - user
|
||||
* - host
|
||||
* - path
|
||||
* - uri (multisite selector)
|
||||
*/
|
||||
class SiteSpecParser
|
||||
{
|
||||
/**
|
||||
* @var string Relative path from the site root to directory where
|
||||
* multisite configuration directories are found.
|
||||
*/
|
||||
protected $multisiteDirectoryRoot = 'sites';
|
||||
|
||||
/**
|
||||
* Parse a site specification
|
||||
*
|
||||
* @param string $spec
|
||||
* A site specification in one of the accepted forms:
|
||||
* - /path/to/drupal#uri
|
||||
* - user@server/path/to/drupal#uri
|
||||
* - user@server/path/to/drupal
|
||||
* - user@server#uri
|
||||
* or, a site name:
|
||||
* - #uri
|
||||
* @param string $root
|
||||
* Drupal root (if provided).
|
||||
* @return array
|
||||
* A site specification array with the specified components filled in:
|
||||
* - user
|
||||
* - host
|
||||
* - path
|
||||
* - uri
|
||||
* or, an empty array if the provided parameter is not a valid site spec.
|
||||
*/
|
||||
public function parse($spec, $root = '')
|
||||
{
|
||||
$result = $this->match($spec);
|
||||
return $this->fixAndCheckUsability($result, $root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the provided specification is valid. Note that this
|
||||
* tests only for syntactic validity; to see if the specification is
|
||||
* usable, call 'parse()', which will also filter out specifications
|
||||
* for local sites that specify a multidev site that does not exist.
|
||||
*
|
||||
* @param string $spec
|
||||
* @see parse()
|
||||
* @return bool
|
||||
*/
|
||||
public function validSiteSpec($spec)
|
||||
{
|
||||
$result = $this->match($spec);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not the provided name is an alias name.
|
||||
*
|
||||
* @param string $aliasName
|
||||
* @return bool
|
||||
*/
|
||||
public function isAliasName($aliasName)
|
||||
{
|
||||
return !empty($aliasName) && ($aliasName[0] == '@');
|
||||
}
|
||||
|
||||
public function setMultisiteDirectoryRoot($location)
|
||||
{
|
||||
$this->multisiteDirectoryRoot = $location;
|
||||
}
|
||||
|
||||
public function getMultisiteDirectoryRoot($root)
|
||||
{
|
||||
return $root . DIRECTORY_SEPARATOR . $this->multisiteDirectoryRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the set of regular expression patterns that match the available
|
||||
* site specification formats.
|
||||
*
|
||||
* @return array
|
||||
* key: site specification regex
|
||||
* value: an array mapping from site specification component names to
|
||||
* the elements in the 'matches' array containing the data for that element.
|
||||
*/
|
||||
protected function patterns()
|
||||
{
|
||||
$PATH = '([a-zA-Z]:[/\\\\][^#]*|[/\\\\][^#]*)';
|
||||
$USER = '([a-zA-Z0-9\._-]+)';
|
||||
$SERVER = '([a-zA-Z0-9\._-]+)';
|
||||
$URI = '([a-zA-Z0-9_-]+)';
|
||||
|
||||
return [
|
||||
// /path/to/drupal#uri
|
||||
"%^{$PATH}#{$URI}\$%" => [
|
||||
'root' => 1,
|
||||
'uri' => 2,
|
||||
],
|
||||
// user@server/path/to/drupal#uri
|
||||
"%^{$USER}@{$SERVER}{$PATH}#{$URI}\$%" => [
|
||||
'user' => 1,
|
||||
'host' => 2,
|
||||
'root' => 3,
|
||||
'uri' => 4,
|
||||
],
|
||||
// user@server/path/to/drupal
|
||||
"%^{$USER}@{$SERVER}{$PATH}\$%" => [
|
||||
'user' => 1,
|
||||
'host' => 2,
|
||||
'root' => 3,
|
||||
'uri' => 'default', // Or '2' if uri should be 'host'
|
||||
],
|
||||
// user@server#uri
|
||||
"%^{$USER}@{$SERVER}#{$URI}\$%" => [
|
||||
'user' => 1,
|
||||
'host' => 2,
|
||||
'uri' => 3,
|
||||
],
|
||||
// #uri
|
||||
"%^#{$URI}\$%" => [
|
||||
'uri' => 1,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run through all of the available regex patterns and determine if
|
||||
* any match the provided specification.
|
||||
*
|
||||
* @return array
|
||||
* @see parse()
|
||||
*/
|
||||
protected function match($spec)
|
||||
{
|
||||
foreach ($this->patterns() as $regex => $map) {
|
||||
if (preg_match($regex, $spec, $matches)) {
|
||||
return $this->mapResult($map, $matches);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflate the provided array so that it always contains the required
|
||||
* elements.
|
||||
*
|
||||
* @return array
|
||||
* @see parse()
|
||||
*/
|
||||
protected function defaults($result = [])
|
||||
{
|
||||
$result += [
|
||||
'root' => '',
|
||||
'uri' => '',
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the data from the matches from the regular expression and
|
||||
* plug them into the result array per the info in the provided map.
|
||||
*
|
||||
* @param array $map
|
||||
* An array mapping from result key to matches index.
|
||||
* @param array $matches
|
||||
* The matched strings returned from preg_match
|
||||
* @return array
|
||||
* @see parse()
|
||||
*/
|
||||
protected function mapResult($map, $matches)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($map as $key => $index) {
|
||||
$value = is_string($index) ? $index : $matches[$index];
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
if (empty($result)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->defaults($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the provided result. If the result is local, then it must
|
||||
* have a 'root'. If it does not, then fill in the root that was provided
|
||||
* to us in our consturctor.
|
||||
*
|
||||
* @param array $result
|
||||
* @see parse() result.
|
||||
* @return array
|
||||
* @see parse()
|
||||
*/
|
||||
protected function fixAndCheckUsability($result, $root)
|
||||
{
|
||||
if (empty($result) || !empty($result['host'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (empty($result['root'])) {
|
||||
// TODO: should these throw an exception, so the user knows
|
||||
// why their site spec was invalid?
|
||||
if (empty($root) || !is_dir($root)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result['root'] = $root;
|
||||
}
|
||||
|
||||
// If using a sitespec `#uri`, then `uri` MUST
|
||||
// be the name of a folder that exists in __DRUPAL_ROOT__/sites.
|
||||
// This restriction does NOT apply to the --uri option. Are there
|
||||
// instances where we need to allow 'uri' to be a literal uri
|
||||
// rather than the folder name? If so, we need to loosen this check.
|
||||
// I think it's fine as it is, though.
|
||||
$path = $this->getMultisiteDirectoryRoot($result['root']) . DIRECTORY_SEPARATOR . $result['uri'];
|
||||
if (!is_dir($path)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
26
vendor/consolidation/site-alias/src/Util/FsUtils.php
vendored
Normal file
26
vendor/consolidation/site-alias/src/Util/FsUtils.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias\Util;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Webmozart\PathUtil\Path;
|
||||
|
||||
class FsUtils
|
||||
{
|
||||
/**
|
||||
* Returns canonicalized absolute pathname.
|
||||
*
|
||||
* The difference between this and PHP's realpath() is that this will
|
||||
* return the original path even if it doesn't exist.
|
||||
*
|
||||
* @param string $path
|
||||
* The path being checked.
|
||||
*
|
||||
* @return string
|
||||
* The canonicalized absolute pathname.
|
||||
*/
|
||||
public static function realpath($path)
|
||||
{
|
||||
$realpath = realpath($path);
|
||||
return $realpath ?: $path;
|
||||
}
|
||||
}
|
16
vendor/consolidation/site-alias/src/Util/YamlDataFileLoader.php
vendored
Normal file
16
vendor/consolidation/site-alias/src/Util/YamlDataFileLoader.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias\Util;
|
||||
|
||||
use Consolidation\SiteAlias\DataFileLoaderInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlDataFileLoader implements DataFileLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function load($path)
|
||||
{
|
||||
return (array) Yaml::parse(file_get_contents($path));
|
||||
}
|
||||
}
|
109
vendor/consolidation/site-alias/tests/SiteAliasCommandsTest.php
vendored
Normal file
109
vendor/consolidation/site-alias/tests/SiteAliasCommandsTest.php
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class ExampleCommandsTest extends TestCase
|
||||
{
|
||||
/** @var string[] */
|
||||
protected $commandClasses;
|
||||
|
||||
/** @var string */
|
||||
protected $appName;
|
||||
|
||||
/** @var string */
|
||||
protected $appVersion;
|
||||
|
||||
const STATUS_OK = 0;
|
||||
const STATUS_ERROR = 1;
|
||||
|
||||
/**
|
||||
* Instantiate a new runner
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
// Store the command classes we are going to test
|
||||
$this->commandClasses = [ \Consolidation\SiteAlias\Cli\SiteAliasCommands::class ];
|
||||
|
||||
// Define our invariants for our test
|
||||
$this->appName = 'TestFixtureApp';
|
||||
$this->appVersion = '1.0.1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testExample.
|
||||
*
|
||||
* Return an array of arrays, each of which contains the parameter
|
||||
* values to be used in one invocation of the testExample test function.
|
||||
*/
|
||||
public function exampleTestCommandParameters()
|
||||
{
|
||||
return [
|
||||
|
||||
[
|
||||
'Add search location: /fixtures/sitealiases/sites', self::STATUS_ERROR,
|
||||
'site:list', '/fixtures/sitealiases/sites',
|
||||
],
|
||||
|
||||
[
|
||||
'List available site aliases', self::STATUS_OK,
|
||||
'list',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test our example class. Each time this function is called, it will
|
||||
* be passed data from the data provider function idendified by the
|
||||
* dataProvider annotation.
|
||||
*
|
||||
* @dataProvider exampleTestCommandParameters
|
||||
*/
|
||||
public function testExampleCommands($expectedOutput, $expectedStatus, $variable_args)
|
||||
{
|
||||
// Create our argv array and run the command
|
||||
$argv = $this->argv(func_get_args());
|
||||
list($actualOutput, $statusCode) = $this->execute($argv);
|
||||
|
||||
// Confirm that our output and status code match expectations
|
||||
$this->assertContains($expectedOutput, $actualOutput);
|
||||
$this->assertEquals($expectedStatus, $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare our $argv array; put the app name in $argv[0] followed by
|
||||
* the command name and all command arguments and options.
|
||||
*/
|
||||
protected function argv($functionParameters)
|
||||
{
|
||||
$argv = $functionParameters;
|
||||
array_shift($argv);
|
||||
array_shift($argv);
|
||||
array_unshift($argv, $this->appName);
|
||||
|
||||
// TODO: replace paths beginning with '/fixtures' with actual path to fixture data
|
||||
|
||||
return $argv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulated front controller
|
||||
*/
|
||||
protected function execute($argv)
|
||||
{
|
||||
// Define a global output object to capture the test results
|
||||
$output = new BufferedOutput();
|
||||
|
||||
// We can only call `Runner::execute()` once; then we need to tear down.
|
||||
$runner = new \Robo\Runner($this->commandClasses);
|
||||
$statusCode = $runner->execute($argv, $this->appName, $this->appVersion, $output);
|
||||
\Robo\Robo::unsetContainer();
|
||||
|
||||
// Return the output and status code.
|
||||
$actualOutput = trim($output->fetch());
|
||||
return [$actualOutput, $statusCode];
|
||||
}
|
||||
}
|
70
vendor/consolidation/site-alias/tests/SiteAliasFileDiscoveryTest.php
vendored
Normal file
70
vendor/consolidation/site-alias/tests/SiteAliasFileDiscoveryTest.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteAliasFileDiscoveryTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
use FunctionUtils;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
$this->sut = new SiteAliasFileDiscovery();
|
||||
}
|
||||
|
||||
public function testSearchForSingleAliasFile()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
$path = $this->sut->findSingleSiteAliasFile('single');
|
||||
$this->assertLocation('sites', $path);
|
||||
$this->assertBasename('single.site.yml', $path);
|
||||
}
|
||||
|
||||
public function testSearchForMissingSingleAliasFile()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
$path = $this->sut->findSingleSiteAliasFile('missing');
|
||||
$this->assertFalse($path);
|
||||
}
|
||||
|
||||
public function testFindAllLegacyAliasFiles()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/legacy');
|
||||
|
||||
$result = $this->sut->findAllLegacyAliasFiles();
|
||||
$paths = $this->simplifyToBasenamesWithLocation($result);
|
||||
$this->assertEquals('legacy/aliases.drushrc.php,legacy/cc.aliases.drushrc.php,legacy/one.alias.drushrc.php,legacy/pantheon.aliases.drushrc.php,legacy/server.aliases.drushrc.php', implode(',', $paths));
|
||||
}
|
||||
|
||||
protected function assertLocation($expected, $path)
|
||||
{
|
||||
$this->assertEquals($expected, basename(dirname($path)));
|
||||
}
|
||||
|
||||
protected function assertBasename($expected, $path)
|
||||
{
|
||||
$this->assertEquals($expected, basename($path));
|
||||
}
|
||||
|
||||
protected function simplifyToBasenamesWithLocation($result)
|
||||
{
|
||||
if (!is_array($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = array_map(
|
||||
function ($item) {
|
||||
return basename(dirname($item)) . '/' . basename($item);
|
||||
}
|
||||
,
|
||||
$result
|
||||
);
|
||||
|
||||
sort($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
165
vendor/consolidation/site-alias/tests/SiteAliasFileLoaderTest.php
vendored
Normal file
165
vendor/consolidation/site-alias/tests/SiteAliasFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
|
||||
|
||||
class SiteAliasFileLoaderTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
use FunctionUtils;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
$this->sut = new SiteAliasFileLoader();
|
||||
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$this->sut->addLoader('yml', $ymlLoader);
|
||||
}
|
||||
|
||||
public function testLoadWildAliasFile()
|
||||
{
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/wild.site.yml'));
|
||||
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Try to get the dev environment.
|
||||
$name = SiteAliasName::parse('@wild.dev');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/wild', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Try to fetch an environment that does not exist. Since this is
|
||||
// a wildcard alias, there should
|
||||
$name = SiteAliasName::parse('@wild.other');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/wild/path/to/wild', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
}
|
||||
|
||||
public function testLoadSingleAliasFile()
|
||||
{
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/simple.site.yml'));
|
||||
$this->assertTrue(is_file($siteAliasFixtures . '/single.site.yml'));
|
||||
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Add a secondary location
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/other';
|
||||
$this->assertTrue(is_dir($siteAliasFixtures));
|
||||
$this->sut->addSearchLocation($siteAliasFixtures);
|
||||
|
||||
// Look for a simple alias with no environments defined
|
||||
$name = new SiteAliasName('simple');
|
||||
$this->assertEquals('simple', $name->sitename());
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/simple', $result->get('root'));
|
||||
|
||||
// Look for a single alias without an environment specified.
|
||||
$name = new SiteAliasName('single');
|
||||
$this->assertEquals('single', $name->sitename());
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with environment explicitly requested.
|
||||
$name = SiteAliasName::parse('@single.alternate');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/alternate/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with location explicitly filtered.
|
||||
$name = SiteAliasName::parse('@other.single.dev');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/other/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('baz', $result->get('foo'));
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = SiteAliasName::parse('@missing');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertFalse($result);
|
||||
|
||||
// Try to fetch an alias using a missing location
|
||||
$name = SiteAliasName::parse('@missing.single.alternate');
|
||||
$result = $this->callProtected('loadSingleAliasFile', [$name]);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testLoadLegacy()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/legacy');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
|
||||
// Look for a simple alias with no environments defined
|
||||
$name = new SiteAliasName('simple');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/simple', $result->get('root'));
|
||||
|
||||
// Look for a single alias without an environment specified.
|
||||
$name = new SiteAliasName('single');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Same test, but with environment explicitly requested.
|
||||
$name = new SiteAliasName('single', 'alternate');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertTrue($result instanceof AliasRecord);
|
||||
$this->assertEquals('/alternate/path/to/single', $result->get('root'));
|
||||
$this->assertEquals('bar', $result->get('foo'));
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = new SiteAliasName('missing');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertFalse($result);
|
||||
|
||||
// Try to fetch an alias that does not exist.
|
||||
$name = new SiteAliasName('missing');
|
||||
$result = $this->sut->load($name);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testLoadAll()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$all = $this->sut->loadAll();
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', array_keys($all)));
|
||||
}
|
||||
|
||||
public function testLoadMultiple()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$aliases = $this->sut->loadMultiple('single');
|
||||
$this->assertEquals('@single.dev,@single.alternate,@single.empty,@other.single.dev,@other.single.other', implode(',', array_keys($aliases)));
|
||||
}
|
||||
|
||||
public function testLoadLocation()
|
||||
{
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/sites');
|
||||
$this->sut->addSearchLocation($this->fixturesDir() . '/sitealiases/other');
|
||||
|
||||
$aliases = $this->sut->loadLocation('other');
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', array_keys($aliases)));
|
||||
}
|
||||
}
|
215
vendor/consolidation/site-alias/tests/SiteAliasManagerTest.php
vendored
Normal file
215
vendor/consolidation/site-alias/tests/SiteAliasManagerTest.php
vendored
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class SiteAliasManagerTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
|
||||
protected $manager;
|
||||
|
||||
/**
|
||||
* Set up for tests
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$root = $this->siteDir();
|
||||
$referenceData = [];
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/sites';
|
||||
|
||||
$aliasLoader = new SiteAliasFileLoader();
|
||||
$ymlLoader = new YamlDataFileLoader();
|
||||
$aliasLoader->addLoader('yml', $ymlLoader);
|
||||
|
||||
$this->manager = new SiteAliasManager($aliasLoader, $root);
|
||||
$this->manager
|
||||
->setReferenceData($referenceData)
|
||||
->addSearchLocation($siteAliasFixtures);
|
||||
}
|
||||
|
||||
public function managerGetTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function managerGetWithOtherLocationTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.other', false,
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.other', 'foo: baz
|
||||
root: /other/other/path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function managerGetWithDupLocationsTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@single.dev', 'foo: bar
|
||||
root: /path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@other.single.dev', 'foo: baz
|
||||
root: /other/path/to/single',
|
||||
],
|
||||
|
||||
[
|
||||
'@dup.single.dev', 'foo: dup
|
||||
root: /dup/path/to/single',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This test is just to ensure that our fixture data is being loaded
|
||||
* accurately so that we can start writing tests. Its okay to remove
|
||||
* rather than maintain this test once the suite is mature.
|
||||
*/
|
||||
public function testGetMultiple()
|
||||
{
|
||||
// First set of tests: get all aliases in the default location
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@single.alternate,@single.dev,@single.empty', implode(',', $allNames));
|
||||
|
||||
// Next set of tests: Get all aliases in the 'other' location
|
||||
|
||||
$this->addAlternateLocation('other');
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
|
||||
// Add the 'dup' location and do some more tests
|
||||
|
||||
$this->addAlternateLocation('dup');
|
||||
|
||||
$all = $this->manager->getMultiple();
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.bob.dev,@dup.bob.other,@dup.fred.dev,@dup.fred.other,@dup.single.alternate,@dup.single.dev,@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other,@single.alternate,@single.dev,@single.empty,@wild.*,@wild.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@dup');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.bob.dev,@dup.bob.other,@dup.fred.dev,@dup.fred.other,@dup.single.alternate,@dup.single.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.bob.dev,@other.bob.other,@other.fred.dev,@other.fred.other,@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@dup.single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@dup.single.alternate,@dup.single.dev', implode(',', $allNames));
|
||||
|
||||
$all = $this->manager->getMultiple('@other.single');
|
||||
$allNames = array_keys($all);
|
||||
sort($allNames);
|
||||
|
||||
$this->assertEquals('@other.single.dev,@other.single.other', implode(',', $allNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetTestValues
|
||||
*/
|
||||
public function testGet(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$alias = $this->manager->get($aliasName);
|
||||
$actual = $this->renderAlias($alias);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetWithOtherLocationTestValues
|
||||
*/
|
||||
public function testGetWithOtherLocation(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$this->addAlternateLocation('other');
|
||||
$this->testGet($aliasName, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider managerGetWithDupLocationsTestValues
|
||||
*/
|
||||
public function testGetWithDupLocations(
|
||||
$aliasName,
|
||||
$expected)
|
||||
{
|
||||
$this->addAlternateLocation('dup');
|
||||
$this->testGetWithOtherLocation($aliasName, $expected);
|
||||
}
|
||||
|
||||
protected function addAlternateLocation($fixtureDirName)
|
||||
{
|
||||
// Add another search location IN ADDITION to the one
|
||||
// already added in the setup() mehtod.
|
||||
$siteAliasFixtures = $this->fixturesDir() . '/sitealiases/' . $fixtureDirName;
|
||||
$this->manager->addSearchLocation($siteAliasFixtures);
|
||||
}
|
||||
|
||||
protected function renderAlias($alias)
|
||||
{
|
||||
if (!$alias) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return trim(Yaml::Dump($alias->export()));
|
||||
}
|
||||
}
|
49
vendor/consolidation/site-alias/tests/SiteAliasNameTest.php
vendored
Normal file
49
vendor/consolidation/site-alias/tests/SiteAliasNameTest.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteAliasNameTest extends TestCase
|
||||
{
|
||||
public function testSiteAliasName()
|
||||
{
|
||||
// Test an ambiguous sitename or env alias.
|
||||
$name = SiteAliasName::parse('@simple');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertTrue(!$name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('simple', $name->env());
|
||||
$this->assertEquals('@self.simple', (string)$name);
|
||||
|
||||
// Test a non-ambiguous sitename.env alias.
|
||||
$name = SiteAliasName::parse('@site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertTrue($name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('site', $name->sitename());
|
||||
$this->assertEquals('env', $name->env());
|
||||
$this->assertEquals('@site.env', (string)$name);
|
||||
|
||||
// Test a non-ambiguous location.sitename.env alias.
|
||||
$name = SiteAliasName::parse('@location.site.env');
|
||||
$this->assertTrue($name->hasLocation());
|
||||
$this->assertTrue($name->hasSitename());
|
||||
$this->assertTrue($name->hasEnv());
|
||||
$this->assertEquals('location', $name->location());
|
||||
$this->assertEquals('site', $name->sitename());
|
||||
$this->assertEquals('env', $name->env());
|
||||
$this->assertEquals('@location.site.env', (string)$name);
|
||||
|
||||
// Test an invalid alias - bad character
|
||||
$name = SiteAliasName::parse('!site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertFalse($name->hasSitename());
|
||||
$this->assertFalse($name->hasEnv());
|
||||
|
||||
// Test an invalid alias - too many separators
|
||||
$name = SiteAliasName::parse('@location.group.site.env');
|
||||
$this->assertFalse($name->hasLocation());
|
||||
$this->assertFalse($name->hasSitename());
|
||||
$this->assertFalse($name->hasEnv());
|
||||
}
|
||||
}
|
177
vendor/consolidation/site-alias/tests/SiteSpecParserTest.php
vendored
Normal file
177
vendor/consolidation/site-alias/tests/SiteSpecParserTest.php
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SiteSpecParserTest extends TestCase
|
||||
{
|
||||
use FixtureFactory;
|
||||
|
||||
/**
|
||||
* @dataProvider parserTestValues
|
||||
*/
|
||||
public function testSiteSpecParser(
|
||||
$spec,
|
||||
$expected)
|
||||
{
|
||||
$root = $this->siteDir();
|
||||
$fixtureSite = '/' . basename($root);
|
||||
$parser = new SiteSpecParser();
|
||||
|
||||
// If the test spec begins with '/fixtures', substitute the
|
||||
// actual path to our fixture site.
|
||||
$spec = preg_replace('%^/fixtures%', $root, $spec);
|
||||
|
||||
// Make sure that our spec is valid
|
||||
$this->assertTrue($parser->validSiteSpec($spec));
|
||||
|
||||
// Parse it!
|
||||
$result = $parser->parse($spec, $root);
|
||||
|
||||
// If the result contains the path to our fixtures site, replace
|
||||
// it with the simple string '/fixtures'.
|
||||
if (isset($result['root'])) {
|
||||
$result['root'] = preg_replace("%.*$fixtureSite%", '/fixtures', $result['root']);
|
||||
}
|
||||
|
||||
// Compare the altered result with the expected value.
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validSiteSpecs
|
||||
*/
|
||||
public function testValidSiteSpecs($spec)
|
||||
{
|
||||
$this->isSpecValid($spec, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidSiteSpecs
|
||||
*/
|
||||
public function testInvalidSiteSpecs($spec)
|
||||
{
|
||||
$this->isSpecValid($spec, false);
|
||||
}
|
||||
|
||||
protected function isSpecValid($spec, $expected)
|
||||
{
|
||||
$parser = new SiteSpecParser();
|
||||
|
||||
$result = $parser->validSiteSpec($spec);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public static function validSiteSpecs()
|
||||
{
|
||||
return [
|
||||
[ '/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal#uri' ],
|
||||
[ 'user.name@example.com/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal' ],
|
||||
[ 'user@example.com/path/to/drupal' ],
|
||||
[ 'user@server#uri' ],
|
||||
[ 'user@example.com#uri' ],
|
||||
[ '#uri' ],
|
||||
];
|
||||
}
|
||||
|
||||
public static function invalidSiteSpecs()
|
||||
{
|
||||
return [
|
||||
[ 'uri' ],
|
||||
[ '@/#' ],
|
||||
[ 'user@#uri' ],
|
||||
[ '@server/path/to/drupal#uri' ],
|
||||
[ 'user@server/path/to/drupal#' ],
|
||||
[ 'user@server/path/to/drupal#uri!' ],
|
||||
[ 'user@server/path/to/drupal##uri' ],
|
||||
[ 'user#server/path/to/drupal#uri' ],
|
||||
];
|
||||
}
|
||||
|
||||
public static function parserTestValues()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'user@server/path#somemultisite',
|
||||
[
|
||||
'user' => 'user',
|
||||
'host' => 'server',
|
||||
'root' => '/path',
|
||||
'uri' => 'somemultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user.name@example.com/path#somemultisite',
|
||||
[
|
||||
'user' => 'user.name',
|
||||
'host' => 'example.com',
|
||||
'root' => '/path',
|
||||
'uri' => 'somemultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user@server/path',
|
||||
[
|
||||
'user' => 'user',
|
||||
'host' => 'server',
|
||||
'root' => '/path',
|
||||
'uri' => 'default',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'user.name@example.com/path',
|
||||
[
|
||||
'user' => 'user.name',
|
||||
'host' => 'example.com',
|
||||
'root' => '/path',
|
||||
'uri' => 'default',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/fixtures#mymultisite',
|
||||
[
|
||||
'root' => '/fixtures',
|
||||
'uri' => 'mymultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'#mymultisite',
|
||||
[
|
||||
'root' => '/fixtures',
|
||||
'uri' => 'mymultisite',
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/fixtures#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/path#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'/path#mymultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
|
||||
[
|
||||
'#somemultisite',
|
||||
[
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/bob.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/bob.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/bob
|
||||
other:
|
||||
root: /other/other/path/to/bob
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/fred.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/fred.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/fred
|
||||
other:
|
||||
root: /other/other/path/to/fred
|
8
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/single.site.yml
vendored
Normal file
8
vendor/consolidation/site-alias/tests/fixtures/sitealiases/dup/single.site.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /dup/path/to/single
|
||||
alternate:
|
||||
root: /dup/alternate/path/to/single
|
||||
common:
|
||||
foo: dup
|
||||
|
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/aliases.drushrc.php
vendored
Normal file
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
$aliases['production'] = [
|
||||
'uri' => 'example.com',
|
||||
'root' => '/path/to/drupal',
|
||||
];
|
||||
|
||||
$aliases['staging'] = [
|
||||
'uri' => 'staging.example.com',
|
||||
'root' => '/path/to/drupal',
|
||||
];
|
43
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php
vendored
Normal file
43
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/cc.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
$aliases['live'] = array (
|
||||
'parent' => '@server.digital-ocean',
|
||||
'project-type' => 'live',
|
||||
'root' => '/srv/www/couturecostume.com/htdocs',
|
||||
'uri' => 'couturecostume.com',
|
||||
'path-aliases' => array(
|
||||
'%dump-dir' => '/var/sql-dump/',
|
||||
),
|
||||
'target-command-specific' => array(
|
||||
'sql-sync' => array(
|
||||
'disable' => array('stage_file_proxy'),
|
||||
'permission' => array(
|
||||
'authenticated user' => array(
|
||||
'remove' => array('access environment indicator'),
|
||||
),
|
||||
'anonymous user' => array(
|
||||
'remove' => 'access environment indicator',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$aliases['update'] = array (
|
||||
'parent' => '@server.nitrogen',
|
||||
'root' => '/srv/www/update.couturecostume.com/htdocs',
|
||||
'uri' => 'update.couturecostume.com',
|
||||
'target-command-specific' => array(
|
||||
'sql-sync' => array(
|
||||
'enable' => array('environment_indicator', 'stage_file_proxy'),
|
||||
'permission' => array(
|
||||
'authenticated user' => array(
|
||||
'add' => array('access environment indicator'),
|
||||
),
|
||||
'anonymous user' => array(
|
||||
'add' => 'access environment indicator',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
3
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/do-not-find-me.php
vendored
Normal file
3
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/do-not-find-me.php
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
// The search scripts shouldn't find me as I do not match the patterns.
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/one.alias.drushrc.php
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/one.alias.drushrc.php
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
$options['uri'] = 'http://example.com';
|
||||
$options['root'] = '/path/to/drupal';
|
50
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php
vendored
Normal file
50
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/pantheon.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Pantheon drush alias file, to be placed in your ~/.drush directory or the aliases
|
||||
* directory of your local Drush home. Once it's in place, clear drush cache:
|
||||
*
|
||||
* drush cc drush
|
||||
*
|
||||
* To see all your available aliases:
|
||||
*
|
||||
* drush sa
|
||||
*
|
||||
* See http://helpdesk.getpantheon.com/customer/portal/articles/411388 for details.
|
||||
*/
|
||||
|
||||
$aliases['outlandish-josh.test'] = array(
|
||||
'uri' => 'test-outlandish-josh.pantheonsite.io',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.test.site-id.drush.in:11621/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.test.site-id.drush.in',
|
||||
'remote-user' => 'test.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
||||
$aliases['outlandish-josh.live'] = array(
|
||||
'uri' => 'www.outlandishjosh.com',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.live.site-id.drush.in:10516/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.live.site-id.drush.in',
|
||||
'remote-user' => 'live.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
||||
$aliases['outlandish-josh.dev'] = array(
|
||||
'uri' => 'dev-outlandish-josh.pantheonsite.io',
|
||||
'db-url' => 'mysql://pantheon:pw@dbserver.dev.site-id.drush.in:21086/pantheon',
|
||||
'db-allows-remote' => TRUE,
|
||||
'remote-host' => 'appserver.dev.site-id.drush.in',
|
||||
'remote-user' => 'dev.site-id',
|
||||
'ssh-options' => '-p 2222 -o "AddressFamily inet"',
|
||||
'path-aliases' => array(
|
||||
'%files' => 'code/sites/default/files',
|
||||
'%drush-script' => 'drush',
|
||||
),
|
||||
);
|
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php
vendored
Normal file
11
vendor/consolidation/site-alias/tests/fixtures/sitealiases/legacy/server.aliases.drushrc.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
$aliases['isp'] = array (
|
||||
'remote-host' => 'hydrogen.server.org',
|
||||
'remote-user' => 'www-admin',
|
||||
);
|
||||
|
||||
$aliases['nitrogen'] = array (
|
||||
'remote-host' => 'nitrogen.server.org',
|
||||
'remote-user' => 'admin',
|
||||
);
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/bob.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/bob.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/bob
|
||||
other:
|
||||
root: /other/other/path/to/bob
|
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/fred.site.yml
vendored
Normal file
4
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/fred.site.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dev:
|
||||
root: /other/path/to/fred
|
||||
other:
|
||||
root: /other/other/path/to/fred
|
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/simple.site.yml
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/simple.site.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
root: /other/path/to/simple
|
7
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/single.site.yml
vendored
Normal file
7
vendor/consolidation/site-alias/tests/fixtures/sitealiases/other/single.site.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /other/path/to/single
|
||||
other:
|
||||
root: /other/other/path/to/single
|
||||
common:
|
||||
foo: baz
|
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/simple.site.yml
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/simple.site.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
root: /path/to/simple
|
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/single.site.yml
vendored
Normal file
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/single.site.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /path/to/single
|
||||
alternate:
|
||||
root: /alternate/path/to/single
|
||||
empty:
|
||||
foo: bar
|
||||
common:
|
||||
foo: bar
|
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/wild.site.yml
vendored
Normal file
9
vendor/consolidation/site-alias/tests/fixtures/sitealiases/sites/wild.site.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
default: dev
|
||||
dev:
|
||||
root: /path/to/wild
|
||||
uri: https://dev.example.com
|
||||
'*':
|
||||
root: /wild/path/to/wild
|
||||
uri: https://${env-name}.example.com
|
||||
common:
|
||||
foo: bar
|
1
vendor/consolidation/site-alias/tests/fixtures/sites/d8/sites/mymultisite/settings.php
vendored
Normal file
1
vendor/consolidation/site-alias/tests/fixtures/sites/d8/sites/mymultisite/settings.php
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<?php
|
24
vendor/consolidation/site-alias/tests/src/FixtureFactory.php
vendored
Normal file
24
vendor/consolidation/site-alias/tests/src/FixtureFactory.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
use \Drush\Config\Environment;
|
||||
|
||||
trait FixtureFactory
|
||||
{
|
||||
protected function fixturesDir()
|
||||
{
|
||||
return dirname(__DIR__) . '/fixtures';
|
||||
}
|
||||
|
||||
protected function homeDir()
|
||||
{
|
||||
return $this->fixturesDir() . '/home';
|
||||
}
|
||||
|
||||
// It is still an aspirational goal to add Drupal 7 support back to Drush. :P
|
||||
// For now, only Drupal 8 is supported.
|
||||
protected function siteDir($majorVersion = '8')
|
||||
{
|
||||
return $this->fixturesDir() . '/sites/d' . $majorVersion;
|
||||
}
|
||||
}
|
14
vendor/consolidation/site-alias/tests/src/FunctionUtils.php
vendored
Normal file
14
vendor/consolidation/site-alias/tests/src/FunctionUtils.php
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Consolidation\SiteAlias;
|
||||
|
||||
trait FunctionUtils
|
||||
{
|
||||
protected $sut;
|
||||
|
||||
protected function callProtected($methodName, $args = [])
|
||||
{
|
||||
$r = new \ReflectionMethod($this->sut, $methodName);
|
||||
$r->setAccessible(true);
|
||||
return $r->invokeArgs($this->sut, $args);
|
||||
}
|
||||
}
|
Reference in a new issue