adding kirby3-janitor
This commit is contained in:
30
vendor/seld/cli-prompt/.github/workflows/lint.yml
vendored
Normal file
30
vendor/seld/cli-prompt/.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: "PHP Lint"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: "Lint"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "5.3"
|
||||
- "8.0"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
coverage: "none"
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: "Lint PHP files"
|
||||
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
|
||||
46
vendor/seld/cli-prompt/.github/workflows/phpstan.yml
vendored
Normal file
46
vendor/seld/cli-prompt/.github/workflows/phpstan.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: "PHPStan"
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
env:
|
||||
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: "PHPStan"
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "8.0"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "actions/checkout@v2"
|
||||
|
||||
- name: "Install PHP"
|
||||
uses: "shivammathur/setup-php@v2"
|
||||
with:
|
||||
coverage: "none"
|
||||
php-version: "${{ matrix.php-version }}"
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: "Install latest dependencies"
|
||||
run: "composer update ${{ env.COMPOSER_FLAGS }}"
|
||||
|
||||
- name: Run PHPStan
|
||||
run: composer phpstan
|
||||
1
vendor/seld/cli-prompt/.gitignore
vendored
Normal file
1
vendor/seld/cli-prompt/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/vendor/
|
||||
19
vendor/seld/cli-prompt/LICENSE
vendored
Normal file
19
vendor/seld/cli-prompt/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015 Jordi Boggiano
|
||||
|
||||
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.
|
||||
61
vendor/seld/cli-prompt/README.md
vendored
Normal file
61
vendor/seld/cli-prompt/README.md
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
CLI-Prompt
|
||||
==========
|
||||
|
||||
While prompting for user input using `fgets()` is quite easy, sometimes you
|
||||
need to prompt for sensitive information. In these cases, the characters typed
|
||||
in by the user should not be directly visible, and this is quite a pain to
|
||||
do in a cross-platform way.
|
||||
|
||||
This tiny package fixes just that for you:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
echo 'Say hello: ';
|
||||
|
||||
$answer = Seld\CliPrompt\CliPrompt::hiddenPrompt();
|
||||
|
||||
echo 'You answered: '.$answer . PHP_EOL;
|
||||
|
||||
// Output in the CLI:
|
||||
//
|
||||
// Say hello:
|
||||
// You answered: hello
|
||||
```
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
`composer require seld/cli-prompt`
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
- `Seld\CliPrompt\CliPrompt::hiddenPrompt($allowFallback = false);`
|
||||
|
||||
> Prompts the user for input and hides what they type. If this fails for any
|
||||
> reason and `$allowFallback` is set to `true` the prompt will be done using
|
||||
> the usual `fgets()` and characters will be visible.
|
||||
|
||||
- `Seld\CliPrompt\CliPrompt::prompt();`
|
||||
|
||||
> Regular user prompt for input with characters being shown on screen.
|
||||
|
||||
In both cases, the trailing newline the user enters when submitting the answer
|
||||
is trimmed.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
PHP 5.3 and above
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
CLI-Prompt is licensed under the MIT License - see the LICENSE file for details
|
||||
|
||||
Acknowledgments
|
||||
---------------
|
||||
|
||||
- This project uses hiddeninput.exe to prompt for passwords on Windows, sources
|
||||
and details can be found on the [github page of the project](https://github.com/Seldaek/hidden-input).
|
||||
35
vendor/seld/cli-prompt/composer.json
vendored
Normal file
35
vendor/seld/cli-prompt/composer.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "seld/cli-prompt",
|
||||
"description": "Allows you to prompt for user input on the command line, and optionally hide the characters they type",
|
||||
"type": "library",
|
||||
"keywords": ["cli", "console", "hidden", "input", "prompt"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Seld\\CliPrompt\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^0.12.63"
|
||||
},
|
||||
"scripts": {
|
||||
"phpstan": "vendor/bin/phpstan analyse"
|
||||
},
|
||||
"config": {
|
||||
"lock": false
|
||||
}
|
||||
}
|
||||
5
vendor/seld/cli-prompt/phpstan.neon.dist
vendored
Normal file
5
vendor/seld/cli-prompt/phpstan.neon.dist
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
parameters:
|
||||
level: 8
|
||||
|
||||
paths:
|
||||
- src/
|
||||
15
vendor/seld/cli-prompt/res/example.php
vendored
Normal file
15
vendor/seld/cli-prompt/res/example.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
echo 'Say hello (visible): ';
|
||||
|
||||
$answer = Seld\CliPrompt\CliPrompt::prompt();
|
||||
|
||||
echo 'You answered: '.$answer . PHP_EOL;
|
||||
|
||||
echo 'Say hello (hidden): ';
|
||||
|
||||
$answer = Seld\CliPrompt\CliPrompt::hiddenPrompt();
|
||||
|
||||
echo 'You answered: '.$answer . PHP_EOL;
|
||||
BIN
vendor/seld/cli-prompt/res/hiddeninput.exe
vendored
Normal file
BIN
vendor/seld/cli-prompt/res/hiddeninput.exe
vendored
Normal file
Binary file not shown.
127
vendor/seld/cli-prompt/src/CliPrompt.php
vendored
Normal file
127
vendor/seld/cli-prompt/src/CliPrompt.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of CLI Prompt.
|
||||
*
|
||||
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Seld\CliPrompt;
|
||||
|
||||
class CliPrompt
|
||||
{
|
||||
/**
|
||||
* Prompts the user for input and shows what they type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function prompt()
|
||||
{
|
||||
$stdin = fopen('php://stdin', 'r');
|
||||
if (false === $stdin) {
|
||||
throw new \RuntimeException('Failed to open STDIN, could not prompt user for input.');
|
||||
}
|
||||
$answer = self::trimAnswer(fgets($stdin, 4096));
|
||||
fclose($stdin);
|
||||
|
||||
return $answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user for input and hides what they type
|
||||
*
|
||||
* @param bool $allowFallback If prompting fails for any reason and this is set to true the prompt
|
||||
* will be done using the regular prompt() function, otherwise a
|
||||
* \RuntimeException is thrown.
|
||||
* @return string
|
||||
* @throws \RuntimeException on failure to prompt, unless $allowFallback is true
|
||||
*/
|
||||
public static function hiddenPrompt($allowFallback = false)
|
||||
{
|
||||
// handle windows
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
// fallback to hiddeninput executable
|
||||
$exe = __DIR__.'\\..\\res\\hiddeninput.exe';
|
||||
|
||||
// handle code running from a phar
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
$tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
|
||||
|
||||
// use stream_copy_to_stream instead of copy
|
||||
// to work around https://bugs.php.net/bug.php?id=64634
|
||||
$source = fopen($exe, 'r');
|
||||
$target = fopen($tmpExe, 'w+');
|
||||
if (false === $source) {
|
||||
throw new \RuntimeException('Failed to open '.$exe.' for reading.');
|
||||
}
|
||||
if (false === $target) {
|
||||
throw new \RuntimeException('Failed to open '.$tmpExe.' for writing.');
|
||||
}
|
||||
stream_copy_to_stream($source, $target);
|
||||
fclose($source);
|
||||
fclose($target);
|
||||
unset($source, $target);
|
||||
|
||||
$exe = $tmpExe;
|
||||
}
|
||||
|
||||
$output = shell_exec($exe);
|
||||
|
||||
// clean up
|
||||
if (isset($tmpExe)) {
|
||||
unlink($tmpExe);
|
||||
}
|
||||
|
||||
if ($output !== null) {
|
||||
// output a newline to be on par with the regular prompt()
|
||||
echo PHP_EOL;
|
||||
|
||||
return self::trimAnswer($output);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists('/usr/bin/env')) {
|
||||
// handle other OSs with bash/zsh/ksh/csh if available to hide the answer
|
||||
$test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
|
||||
foreach (array('bash', 'zsh', 'ksh', 'csh', 'sh') as $sh) {
|
||||
$output = shell_exec(sprintf($test, $sh));
|
||||
if (is_string($output) && 'OK' === rtrim($output)) {
|
||||
$shell = $sh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($shell)) {
|
||||
$readCmd = ($shell === 'csh') ? 'set mypassword = $<' : 'read -r mypassword';
|
||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||
$output = shell_exec($command);
|
||||
|
||||
if ($output !== null) {
|
||||
// output a newline to be on par with the regular prompt()
|
||||
echo PHP_EOL;
|
||||
|
||||
return self::trimAnswer($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not able to hide the answer
|
||||
if (!$allowFallback) {
|
||||
throw new \RuntimeException('Could not prompt for input in a secure fashion, aborting');
|
||||
}
|
||||
|
||||
return self::prompt();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|bool $str
|
||||
* @return string
|
||||
*/
|
||||
private static function trimAnswer($str)
|
||||
{
|
||||
return preg_replace('{\r?\n$}D', '', (string) $str) ?: '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user