mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-03 05:33:16 +07:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
06929bdf4c | |||
e97e822eff | |||
0f97f445fb | |||
507cc5e95d | |||
2a30f9d208 | |||
eaf140ca8b | |||
dcd432d918 | |||
91a03a2865 | |||
ca33947c62 | |||
932b66f3fc | |||
651d2619bb | |||
16f13a69eb | |||
9134867822 | |||
36104f0983 | |||
a0b0e58cb3 | |||
c6f956927a | |||
83cc9a4bcf | |||
e63fd8e122 | |||
d33e2e06e4 | |||
7fcf39f8e9 | |||
43a64813f3 | |||
ba83ab2e67 |
@ -55,7 +55,7 @@ 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 hello@codecov.io. All
|
||||
reported by contacting the project team at contact@shivammathur.com. 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.
|
||||
@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
https://www.contributor-covenant.org/faq
|
54
.github/CONTRIBUTING.md
vendored
Normal file
54
.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
# Contributing to setup-php
|
||||
|
||||
## Contributor Code of Conduct
|
||||
|
||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||
|
||||
## Workflow
|
||||
|
||||
* Fork the project.
|
||||
* Make your bug fix or feature addition.
|
||||
* Add tests for it. This is important so we don't break it in a future version unintentionally.
|
||||
* Send a pull request to the develop branch.
|
||||
|
||||
Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
|
||||
|
||||
Due to time constraints, you may not always get a quick responce. Please do not take delays personal and feel free to remind me.
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
This project comes with a `.prettierrc.json` configuration file. Please run the following command to format the code before commiting it.
|
||||
|
||||
```bash
|
||||
$ npm run format
|
||||
```
|
||||
|
||||
## Using setup-php from a Git checkout
|
||||
|
||||
The following commands can be used to perform the initial checkout of setup-php:
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/shivammathur/setup-php.git
|
||||
|
||||
$ cd setup-php
|
||||
```
|
||||
|
||||
Install setup-php dependencies using [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the test suite
|
||||
|
||||
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:
|
||||
|
||||
```bash
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Reporting issues
|
||||
|
||||
Please submit the issue using the appropiate template provided for a bug report or a feature request:
|
||||
|
||||
* [Issues](https://github.com/shivammathur/setup-php/issues)
|
34
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
34
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
name: |
|
||||
🐞 Failing Test
|
||||
🐞 Bug Fix
|
||||
⚙ Improvement
|
||||
🎉 New Feature
|
||||
about: You found a bug, have a failing test, want to improve something or add a new feature
|
||||
labels: bug or enhancement
|
||||
---
|
||||
|
||||
## A Pull Request should be associated with an Issue.
|
||||
|
||||
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
|
||||
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
|
||||
> and potentially we'll be able to point development in a particular direction.
|
||||
|
||||
Related issue:
|
||||
|
||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
|
||||
|
||||
### Description
|
||||
|
||||
This PR [briefly explain what it does]
|
||||
|
||||
> In case this PR introduced TypeScript/JavaScript code changes:
|
||||
|
||||
- [ ] I have written test cases for the changes in this pull request
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
-->
|
30
.github/PULL_REQUEST_TEMPLATE/FAILING_TEST.md
vendored
Normal file
30
.github/PULL_REQUEST_TEMPLATE/FAILING_TEST.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: 🐞 Failing Test
|
||||
about: You found a bug and have a failing test?
|
||||
labels: bug
|
||||
---
|
||||
|
||||
## A Pull Request should be associated with an Issue.
|
||||
|
||||
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
|
||||
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
|
||||
> and potentially we'll be able to point development in a particular direction.
|
||||
|
||||
Related issue:
|
||||
|
||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
|
||||
|
||||
### Description
|
||||
|
||||
This PR [briefly explain what it does]
|
||||
|
||||
> In case this PR introduced TypeScript/JavaScript code changes:
|
||||
|
||||
- [ ] I have written test cases for the changes in this pull request
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
-->
|
30
.github/PULL_REQUEST_TEMPLATE/FIX.md
vendored
Normal file
30
.github/PULL_REQUEST_TEMPLATE/FIX.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: 🐞 Bug Fix
|
||||
about: You have a fix for a bug?
|
||||
labels: bug
|
||||
---
|
||||
|
||||
## A Pull Request should be associated with an Issue.
|
||||
|
||||
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
|
||||
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
|
||||
> and potentially we'll be able to point development in a particular direction.
|
||||
|
||||
Related issue:
|
||||
|
||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
|
||||
|
||||
### Description
|
||||
|
||||
This PR [briefly explain what it does]
|
||||
|
||||
> In case this PR introduced TypeScript/JavaScript code changes:
|
||||
|
||||
- [ ] I have written test cases for the changes in this pull request
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
-->
|
30
.github/PULL_REQUEST_TEMPLATE/IMPROVEMENT.md
vendored
Normal file
30
.github/PULL_REQUEST_TEMPLATE/IMPROVEMENT.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: ⚙ Improvement
|
||||
about: You have some improvement to make setup-php better?
|
||||
labels: enhancement
|
||||
---
|
||||
|
||||
## A Pull Request should be associated with an Issue.
|
||||
|
||||
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
|
||||
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
|
||||
> and potentially we'll be able to point development in a particular direction.
|
||||
|
||||
Related issue:
|
||||
|
||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
|
||||
|
||||
### Description
|
||||
|
||||
This PR [briefly explain what it does]
|
||||
|
||||
> In case this PR introduced TypeScript/JavaScript code changes:
|
||||
|
||||
- [ ] I have written test cases for the changes in this pull request
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
-->
|
30
.github/PULL_REQUEST_TEMPLATE/NEW_FEATURE.md
vendored
Normal file
30
.github/PULL_REQUEST_TEMPLATE/NEW_FEATURE.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: 🎉 New Feature
|
||||
about: You have implemented some neat idea that you want to make part of setup-php?
|
||||
labels: enhancement
|
||||
---
|
||||
|
||||
## A Pull Request should be associated with an Issue.
|
||||
|
||||
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
|
||||
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
|
||||
> and potentially we'll be able to point development in a particular direction.
|
||||
|
||||
Related issue:
|
||||
|
||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
|
||||
|
||||
### Description
|
||||
|
||||
This PR [briefly explain what it does]
|
||||
|
||||
> In case this PR introduced TypeScript/JavaScript code changes:
|
||||
|
||||
- [ ] I have written test cases for the changes in this pull request
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
-->
|
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
@ -5,7 +5,7 @@ jobs:
|
||||
name: Run
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
max-parallel: 6
|
||||
max-parallel: 8
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
|
||||
@ -24,7 +24,7 @@ jobs:
|
||||
- name: Run tests and send coverage
|
||||
run: |
|
||||
npm test
|
||||
curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov
|
||||
curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}-php${{ matrix.php-versions }}
|
||||
|
||||
- name: Installing PHP with extensions and custom config
|
||||
run: node lib/install.js
|
||||
|
81
README.md
81
README.md
@ -1,23 +1,35 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/marketplace/actions/setup-php-action" target="_blank">
|
||||
<img src="https://repository-images.githubusercontent.com/206578964/e0a18480-dc65-11e9-8dd3-b9ffbf5575fe" alt="Setup PHP in GitHub Actions" width="400">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# Setup PHP in GitHub Actions
|
||||
|
||||
<p align="left">
|
||||
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
||||
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>
|
||||
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Get Help on codementor" src="https://cdn.codementor.io/badges/get_help_github.svg"></a>
|
||||
</p>
|
||||
|
||||
[GitHub Action](https://github.com/features/actions) to install PHP with required extensions, php.ini configuration and composer. This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#usage) section to see how to use this.
|
||||
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section to see how to use this.
|
||||
|
||||
## PHP Versions Support
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4 `7.4.0beta4` on `ubuntu`, and `7.4.0RC2` on `windows` and `macOS`
|
||||
## :tada: PHP Support
|
||||
|
||||
**Note:** PHP 7.4 is currently in development, do not use in production.
|
||||
|PHP Version|Stability|Release Support|
|
||||
|--- |--- |--- |
|
||||
|5.6|`Stable`|`End of life`|
|
||||
|7.0|`Stable`|`End of life`|
|
||||
|7.1|`Stable`|`Security fixes only`|
|
||||
|7.2|`Stable`|`Active`|
|
||||
|7.3|`Stable`|`Active`|
|
||||
|7.4|`Beta`/`RC`|`Active`|
|
||||
|
||||
## OS Support
|
||||
**Note:** PHP 7.4 is currently in development, do not use in production/release branches.
|
||||
|
||||
## :cloud: OS/Platform Support
|
||||
|
||||
|Virtual environment|matrix.operating-system|
|
||||
|--- |--- |
|
||||
@ -28,19 +40,40 @@
|
||||
|macOS X Mojave 10.14|`macOS-latest` or `macOS-10.14`|
|
||||
|
||||
|
||||
## PHP Extension Support
|
||||
## :wrench: PHP Extension Support
|
||||
- On `ubuntu` extensions which have the package in apt are installed.
|
||||
- On `windows` and `macOS` PECL extensions are installed.
|
||||
- Extensions which are installed along with PHP if specified are enabled.
|
||||
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped.
|
||||
|
||||
## Usage
|
||||
## :signal_strength: Coverage support
|
||||
- Specify `coverage: xdebug` to use `Xdebug`.
|
||||
- Runs on all [PHP versions supported](#tada-php-support)
|
||||
```
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: 7.3
|
||||
coverage: xdebug
|
||||
```
|
||||
- Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`
|
||||
- For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
|
||||
- `PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
|
||||
```
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: 7.3
|
||||
ini-values-csv: 'pcov.directory=api' #optional, see above for usage.
|
||||
coverage: pcov
|
||||
```
|
||||
|
||||
## :memo: Usage
|
||||
|
||||
Inputs supported by this GitHub Action.
|
||||
|
||||
- php-version
|
||||
- extension-csv (optional)
|
||||
- ini-values-csv (optional)
|
||||
- coverage (optional)
|
||||
|
||||
See [action.yml](action.yml) for more info
|
||||
|
||||
@ -56,6 +89,7 @@ steps:
|
||||
php-version: 7.3
|
||||
extension-csv: mbstring, xdebug #optional
|
||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
||||
coverage: xdebug #optional
|
||||
- name: Check PHP Version
|
||||
run: php -v
|
||||
- name: Check Composer Version
|
||||
@ -85,6 +119,7 @@ jobs:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extension-csv: mbstring, xdebug #optional
|
||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
||||
coverage: xdebug #optional
|
||||
- name: Check PHP Version
|
||||
run: php -v
|
||||
- name: Check Composer Version
|
||||
@ -94,15 +129,25 @@ jobs:
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
### Examples
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
- [Laravel](./example/laravel.yml)
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
## :scroll: License
|
||||
|
||||
## This action uses the following works
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE). This project has multiple [dependencies](https://github.com/shivammathur/setup-php/network/dependencies) and their licenses can be found in their respective repositories.
|
||||
|
||||
## :+1: Contributions
|
||||
|
||||
Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md).
|
||||
|
||||
## :sparkling_heart: Support this project
|
||||
|
||||
- Please star the project and share it among your developer friends.
|
||||
- Consider supporting on <a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> and <a href="https://www.paypal.me/shivammathur"><img alt="Support me on Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>.
|
||||
|
||||
## :bookmark: This action uses the following works
|
||||
|
||||
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager)
|
||||
- [Homebrew](https://brew.sh/)
|
||||
@ -110,7 +155,7 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated)
|
||||
- [phpbrew](https://github.com/phpbrew/phpbrew)
|
||||
|
||||
## Further Reading
|
||||
## :bookmark_tabs: Further Reading
|
||||
|
||||
- [About GitHub Actions](https://github.com/features/actions)
|
||||
- [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions)
|
||||
|
@ -14,25 +14,25 @@ describe('Features tests', () => {
|
||||
'7.2',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension pcov -MinimumStability stable'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
||||
const extension_url: string =
|
||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension xdebug -MinimumStability alpha'
|
||||
);
|
||||
expect(win32).toContain(
|
||||
'Install-PhpExtension pcov -MinimumStability alpha'
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
||||
);
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
|
||||
win32 = await features.addExtension('DoesNotExist', '7.2', 'win32');
|
||||
expect(win32).not.toContain(
|
||||
'Install-PhpExtension DoesNotExist -MinimumStability stable'
|
||||
);
|
||||
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
||||
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
||||
|
||||
win32 = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(win32).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await features.addExtension(
|
||||
'xdebug, pcov',
|
||||
@ -45,7 +45,15 @@ describe('Features tests', () => {
|
||||
expect(linux).toContain(
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
|
||||
);
|
||||
|
||||
linux = await features.addExtension('xdebug, pcov', '7.4', 'linux');
|
||||
expect(linux).toContain('./xdebug.sh');
|
||||
expect(linux).toContain('./pcov.sh');
|
||||
|
||||
linux = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(linux).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
let darwin: string = await features.addExtension(
|
||||
'xdebug, pcov',
|
||||
@ -55,8 +63,31 @@ describe('Features tests', () => {
|
||||
expect(darwin).toContain('sudo pecl install xdebug');
|
||||
expect(darwin).toContain('sudo pecl install pcov');
|
||||
|
||||
darwin = await features.addExtension('DoesNotExist', '7.2', 'darwin');
|
||||
expect(darwin).not.toContain('sudo pecl install DoesNotExist');
|
||||
darwin = await features.addExtension('pcov', '5.6', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install pcov');
|
||||
|
||||
darwin = await features.addExtension('pcov', '7.2', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install pcov');
|
||||
|
||||
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||
|
||||
darwin = await features.addExtension('xdebug', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
||||
|
||||
darwin = await features.addExtension('pcov', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./pcov.sh');
|
||||
|
||||
darwin = await features.addExtension('xdebug', '7.2', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug');
|
||||
|
||||
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
|
||||
expect(darwin).toContain(
|
||||
'Could not find does_not_exist for PHP7.2 on PECL'
|
||||
);
|
||||
|
||||
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(darwin).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addINIValuesOnWindows', async () => {
|
||||
@ -73,6 +104,12 @@ describe('Features tests', () => {
|
||||
expect(win32).toContain(
|
||||
'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"'
|
||||
);
|
||||
|
||||
win32 = await features.addINIValues(
|
||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||
'fedora'
|
||||
);
|
||||
expect(win32).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addINIValuesOnLinux', async () => {
|
||||
@ -83,6 +120,12 @@ describe('Features tests', () => {
|
||||
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file');
|
||||
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file');
|
||||
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
||||
|
||||
linux = await features.addINIValues(
|
||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||
'fedora'
|
||||
);
|
||||
expect(linux).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addINIValuesOnDarwin', async () => {
|
||||
@ -93,5 +136,76 @@ describe('Features tests', () => {
|
||||
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file');
|
||||
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file');
|
||||
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
||||
|
||||
darwin = await features.addINIValues(
|
||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||
'fedora'
|
||||
);
|
||||
expect(darwin).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addCoverage on windows', async () => {
|
||||
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
|
||||
const extension_url: string =
|
||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
expect(win32).toContain(
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
||||
);
|
||||
|
||||
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
||||
|
||||
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
expect(win32).toContain(
|
||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||
);
|
||||
|
||||
win32 = await features.addCoverage('pcov', '7.3', 'win32');
|
||||
expect(win32).toContain('Install-PhpExtension pcov');
|
||||
expect(win32).toContain(
|
||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||
);
|
||||
|
||||
win32 = await features.addCoverage('nocov', '7.3', 'win32');
|
||||
expect(win32).toContain('');
|
||||
|
||||
win32 = await features.addCoverage('pcov', '7.0', 'win32');
|
||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
||||
|
||||
win32 = await features.addCoverage('pcov', '5.6', 'win32');
|
||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
||||
|
||||
win32 = await features.addCoverage('', '7.4', 'win32');
|
||||
expect(win32).toEqual('');
|
||||
});
|
||||
|
||||
it('checking addCoverage on linux', async () => {
|
||||
let linux: string = await features.addCoverage('xdebug', '7.4', 'linux');
|
||||
expect(linux).toContain('./xdebug.sh');
|
||||
|
||||
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
||||
expect(linux).toContain('./pcov.sh');
|
||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
||||
|
||||
linux = await features.addCoverage('', '7.4', 'linux');
|
||||
expect(linux).toEqual('');
|
||||
});
|
||||
|
||||
it('checking addCoverage on darwin', async () => {
|
||||
let darwin: string = await features.addCoverage('xdebug', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
||||
|
||||
darwin = await features.addCoverage('xdebug', '5.6', 'darwin');
|
||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||
|
||||
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
|
||||
expect(darwin).toContain('sh ./pcov.sh');
|
||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
|
||||
|
||||
darwin = await features.addCoverage('', '7.4', 'win32');
|
||||
expect(darwin).toEqual('');
|
||||
});
|
||||
});
|
||||
|
15
__tests__/pecl.test.ts
Normal file
15
__tests__/pecl.test.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as pecl from '../src/pecl';
|
||||
|
||||
let valid_extensions = ['xdebug', 'pcov'];
|
||||
jest.mock('../src/pecl', () => ({
|
||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||
return valid_extensions.indexOf(extension) !== -1;
|
||||
})
|
||||
}));
|
||||
|
||||
describe('pecl tests', () => {
|
||||
it('checking checkPECLExtension', async () => {
|
||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||
});
|
||||
});
|
@ -1,12 +1,10 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
import * as pecl from '../src/pecl';
|
||||
|
||||
let valid_extensions = ['xdebug', 'pcov'];
|
||||
jest.mock('../src/pecl', () => ({
|
||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||
return valid_extensions.indexOf(extension) !== -1;
|
||||
jest.mock('@actions/core', () => ({
|
||||
getInput: jest.fn().mockImplementation(key => {
|
||||
return ['setup-php'].indexOf(key) !== -1 ? key : '';
|
||||
})
|
||||
}));
|
||||
|
||||
@ -21,7 +19,10 @@ async function cleanup(path: string): Promise<void> {
|
||||
describe('Utils tests', () => {
|
||||
it('checking getInput', async () => {
|
||||
process.env['test'] = 'setup-php';
|
||||
process.env['undefined'] = '';
|
||||
expect(await utils.getInput('test', false)).toBe('setup-php');
|
||||
expect(await utils.getInput('undefined', false)).toBe('');
|
||||
expect(await utils.getInput('setup-php', false)).toBe('setup-php');
|
||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||
});
|
||||
|
||||
@ -36,25 +37,29 @@ describe('Utils tests', () => {
|
||||
|
||||
it('checking readScripts', async () => {
|
||||
let rc: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/7.4.sh'),
|
||||
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let darwin: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/darwin.sh'),
|
||||
path.join(__dirname, '../src/scripts/darwin.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let linux: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/linux.sh'),
|
||||
path.join(__dirname, '../src/scripts/linux.sh'),
|
||||
'utf8'
|
||||
);
|
||||
let win32: string = fs.readFileSync(
|
||||
path.join(__dirname, '../src/win32.ps1'),
|
||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||
'utf8'
|
||||
);
|
||||
expect(rc).toBe(await utils.readScript('darwin.sh', '7.4', 'darwin'));
|
||||
expect(darwin).toBe(await utils.readScript('darwin.sh', '7.3', 'darwin'));
|
||||
expect(linux).toBe(await utils.readScript('linux.sh', '7.3', 'linux'));
|
||||
expect(win32).toBe(await utils.readScript('win32.ps1', '7.3', 'win32'));
|
||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
|
||||
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
||||
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
||||
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
||||
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
||||
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking writeScripts', async () => {
|
||||
@ -76,6 +81,8 @@ describe('Utils tests', () => {
|
||||
'c',
|
||||
'd'
|
||||
]);
|
||||
expect(await utils.extensionArray('')).toEqual([]);
|
||||
expect(await utils.extensionArray(' ')).toEqual([]);
|
||||
});
|
||||
|
||||
it('checking INIArray', async () => {
|
||||
@ -84,10 +91,47 @@ describe('Utils tests', () => {
|
||||
'b=2',
|
||||
'c=3'
|
||||
]);
|
||||
expect(await utils.INIArray('')).toEqual([]);
|
||||
expect(await utils.INIArray(' ')).toEqual([]);
|
||||
});
|
||||
|
||||
it('checking checkPECLExtension', async () => {
|
||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||
it('checking log', async () => {
|
||||
let message: string = 'Test message';
|
||||
|
||||
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
||||
// expect(warning_log).toEqual(
|
||||
// "Write-Host '" + message + "' -ForegroundColor yellow"
|
||||
// );
|
||||
warning_log = await utils.log(message, 'linux', 'warning');
|
||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||
warning_log = await utils.log(message, 'darwin', 'warning');
|
||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||
|
||||
let error_log: string = await utils.log(message, 'win32', 'error');
|
||||
// expect(error_log).toEqual(
|
||||
// "Write-Host '" + message + "' -ForegroundColor red"
|
||||
// );
|
||||
error_log = await utils.log(message, 'linux', 'error');
|
||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||
error_log = await utils.log(message, 'darwin', 'error');
|
||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||
|
||||
let success_log: string = await utils.log(message, 'win32', 'success');
|
||||
// expect(success_log).toEqual(
|
||||
// "Write-Host '" + message + "' -ForegroundColor green"
|
||||
// );
|
||||
success_log = await utils.log(message, 'linux', 'success');
|
||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||
success_log = await utils.log(message, 'darwin', 'success');
|
||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||
});
|
||||
|
||||
it('checking getExtensionPrefix', async () => {
|
||||
expect(await utils.getExtensionPrefix('extensionDoesNotExist')).toEqual(
|
||||
'extension'
|
||||
);
|
||||
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
||||
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||
});
|
||||
});
|
||||
|
@ -14,6 +14,9 @@ inputs:
|
||||
ini-values-csv:
|
||||
description: '(Optional) Custom values you want to set in php.ini'
|
||||
required: false
|
||||
coverage:
|
||||
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug and pcov)'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/install.js'
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Contributors
|
||||
|
||||
Please submit a Pull Request to the develop branch
|
58
example/laravel.yml
Normal file
58
example/laravel.yml
Normal file
@ -0,0 +1,58 @@
|
||||
name: Laravel
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
|
||||
phpunit:
|
||||
name: PHPUnit (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DB_PASSWORD: password
|
||||
BROADCAST_DRIVER: log
|
||||
CACHE_DRIVER: redis
|
||||
QUEUE_CONNECTION: redis
|
||||
SESSION_DRIVER: redis
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
MYSQL_DATABASE: laravel
|
||||
ports:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379/tcp
|
||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 15
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
php-versions: ['7.2', '7.3']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extension-csv: mbstring, xdebug #optional
|
||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
||||
coverage: xdebug #optional
|
||||
- name: Install Composer dependencies
|
||||
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||
- name: Prepare the application
|
||||
run: |
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
- name: Clear Config
|
||||
run: php artisan config:clear
|
||||
- name: Run Migration
|
||||
run: php artisan migrate -v
|
||||
env:
|
||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
267
lib/features.js
267
lib/features.js
@ -18,24 +18,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils = __importStar(require("./utils"));
|
||||
const pecl = __importStar(require("./pecl"));
|
||||
function addExtension(extensions, version, os_version) {
|
||||
function addExtension(extension_csv, version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (os_version === 'win32') {
|
||||
return yield addExtensionWindows(extensions, version);
|
||||
switch (os_version) {
|
||||
case 'win32':
|
||||
return yield addExtensionWindows(extension_csv, version);
|
||||
case 'darwin':
|
||||
return yield addExtensionDarwin(extension_csv, version);
|
||||
case 'linux':
|
||||
return yield addExtensionLinux(extension_csv, version);
|
||||
default:
|
||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
else if (os_version === 'linux') {
|
||||
return yield addExtensionLinux(extensions, version);
|
||||
}
|
||||
return yield addExtensionDarwin(extensions);
|
||||
});
|
||||
}
|
||||
exports.addExtension = addExtension;
|
||||
function addINIValues(ini_values_csv, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (os_version === 'win32') {
|
||||
return yield addINIValuesWindows(ini_values_csv);
|
||||
switch (os_version) {
|
||||
case 'win32':
|
||||
return yield addINIValuesWindows(ini_values_csv);
|
||||
case 'darwin':
|
||||
case 'linux':
|
||||
return yield addINIValuesUnix(ini_values_csv);
|
||||
default:
|
||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
return yield addINIValuesUnix(ini_values_csv);
|
||||
});
|
||||
}
|
||||
exports.addINIValues = addINIValues;
|
||||
@ -46,18 +54,17 @@ exports.addINIValues = addINIValues;
|
||||
*/
|
||||
function enableExtensionWindows(extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return `try {
|
||||
$${extension}_found = 0
|
||||
$ext_dir = Get-PhpIniKey extension_dir
|
||||
return (`try {
|
||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||
$enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}"
|
||||
if($enabled -eq 'no' -and $exist) {
|
||||
Enable-PhpExtension ${extension} C:\\tools\\php
|
||||
$${extension}_found = 1
|
||||
}
|
||||
} catch [Exception] {
|
||||
echo $_
|
||||
}\n`;
|
||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
||||
(yield utils.log('Enabled ' + extension, 'win32', 'success')) +
|
||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||
(yield utils.log('Extension ' + extension + ' was already enabled', 'win32', 'success')) +
|
||||
` }
|
||||
} catch [Exception] {\n` +
|
||||
(yield utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
||||
` }\n`);
|
||||
});
|
||||
}
|
||||
exports.enableExtensionWindows = enableExtensionWindows;
|
||||
@ -65,16 +72,16 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
||||
* Enable extensions which are installed but not enabled on unix
|
||||
*
|
||||
* @param extension
|
||||
* @param os_version
|
||||
*/
|
||||
function enableExtensionUnix(extension) {
|
||||
function enableExtensionUnix(extension, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return `${extension}_found=0
|
||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
||||
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||
echo "${extension} enabled"
|
||||
${extension}_found=1
|
||||
fi\n`;
|
||||
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||
(yield utils.log('Enabled ' + extension, os_version, 'success')) +
|
||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||
(yield utils.log('Extension ' + extension + ' was already enabled', os_version, 'success')) +
|
||||
`; fi\n`);
|
||||
});
|
||||
}
|
||||
exports.enableExtensionUnix = enableExtensionUnix;
|
||||
@ -82,24 +89,57 @@ exports.enableExtensionUnix = enableExtensionUnix;
|
||||
* Install and enable extensions for darwin
|
||||
*
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
*/
|
||||
function addExtensionDarwin(extension_csv) {
|
||||
function addExtensionDarwin(extension_csv, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let extensions = yield utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += yield enableExtensionUnix(extension);
|
||||
if (yield pecl.checkPECLExtension(extension)) {
|
||||
script +=
|
||||
'if [ $' +
|
||||
extension +
|
||||
'_found -eq 0 ]; then sudo pecl install ' +
|
||||
extension +
|
||||
' || echo "Couldn\'t find extension: ' +
|
||||
extension +
|
||||
'"; fi\n';
|
||||
script += yield enableExtensionUnix(extension, 'darwin');
|
||||
switch (yield pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
case '5.6xdebug':
|
||||
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
||||
' || ' +
|
||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
||||
'; fi\n';
|
||||
break;
|
||||
case false:
|
||||
default:
|
||||
script +=
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
')" ]; then \n' +
|
||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error')) +
|
||||
'; fi\n';
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -119,24 +159,47 @@ function addExtensionWindows(extension_csv, version) {
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += yield enableExtensionWindows(extension);
|
||||
let extension_version = 'stable';
|
||||
if (version == '7.4') {
|
||||
extension_version = 'alpha';
|
||||
}
|
||||
if (yield pecl.checkPECLExtension(extension)) {
|
||||
script +=
|
||||
'if($' +
|
||||
extension +
|
||||
'_found -eq 0) { ' +
|
||||
'try { Install-PhpExtension ' +
|
||||
extension +
|
||||
' -MinimumStability ' +
|
||||
extension_version +
|
||||
' } catch [Exception] { echo $_; echo "Could not install extension: "' +
|
||||
extension +
|
||||
' } }\n';
|
||||
switch (yield pecl.checkPECLExtension(extension)) {
|
||||
case true:
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
const extension_url = 'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||
install_command =
|
||||
'Invoke-WebRequest -Uri ' +
|
||||
extension_url +
|
||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll\n';
|
||||
install_command += 'Enable-PhpExtension xdebug';
|
||||
break;
|
||||
case '7.2xdebug':
|
||||
default:
|
||||
install_command = 'Install-PhpExtension ' + extension;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if(!(php -m | findstr -i ' +
|
||||
extension +
|
||||
')) { ' +
|
||||
'try { ' +
|
||||
install_command +
|
||||
'\n' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
||||
' } catch [Exception] { ' +
|
||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error')) +
|
||||
' } }\n';
|
||||
break;
|
||||
case false:
|
||||
default:
|
||||
script +=
|
||||
'if(!(php -m | findstr -i ' +
|
||||
extension +
|
||||
')) { ' +
|
||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error')) +
|
||||
' } \n';
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -156,20 +219,38 @@ function addExtensionLinux(extension_csv, version) {
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
// add script to enable extension is already installed along with php
|
||||
script += yield enableExtensionUnix(extension);
|
||||
script += yield enableExtensionUnix(extension, 'linux');
|
||||
let install_command = '';
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' >/dev/null 2>&1';
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'if [ $' +
|
||||
'if [ ! "$(php -m | grep -i ' +
|
||||
extension +
|
||||
'_found -eq 0 ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
' || echo "Couldn\'t find extension php' +
|
||||
version +
|
||||
'-' +
|
||||
extension +
|
||||
'"; fi\n';
|
||||
')" ]; then ' +
|
||||
install_command +
|
||||
' && ' +
|
||||
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
||||
' || ' +
|
||||
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) +
|
||||
'; fi\n';
|
||||
});
|
||||
});
|
||||
return script;
|
||||
@ -207,11 +288,59 @@ function addINIValuesWindows(ini_values_csv) {
|
||||
yield utils.asyncForEach(ini_values, function (ini_value) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// add script to set ini value
|
||||
script +=
|
||||
'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
||||
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
||||
});
|
||||
});
|
||||
return script;
|
||||
});
|
||||
}
|
||||
exports.addINIValuesWindows = addINIValuesWindows;
|
||||
function addCoverage(coverage, version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let script = '';
|
||||
script += '\n';
|
||||
coverage = coverage.toLowerCase();
|
||||
// pcov
|
||||
switch (coverage) {
|
||||
case 'pcov':
|
||||
// if version is 7.1 or newer
|
||||
switch (version) {
|
||||
default:
|
||||
script += yield addExtension('pcov', version, os_version);
|
||||
script += yield addINIValues('pcov.enabled=1', os_version);
|
||||
// add command to disable xdebug and enable pcov
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||
break;
|
||||
case 'darwin':
|
||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||
break;
|
||||
case 'win32':
|
||||
script +=
|
||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
||||
break;
|
||||
}
|
||||
// success
|
||||
script += yield utils.log('pcov enabled as coverage driver', os_version, 'success');
|
||||
// version is not supported
|
||||
break;
|
||||
case '5.6':
|
||||
case '7.0':
|
||||
script += yield utils.log('pcov requires php 7.1 or newer', os_version, 'warning');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//xdebug
|
||||
case 'xdebug':
|
||||
script += yield addExtension('xdebug', version, os_version);
|
||||
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success');
|
||||
break;
|
||||
// unknown coverage driver
|
||||
default:
|
||||
script = '';
|
||||
}
|
||||
return script;
|
||||
});
|
||||
}
|
||||
exports.addCoverage = addCoverage;
|
||||
|
@ -30,19 +30,22 @@ function run() {
|
||||
let version = yield utils.getInput('php-version', true);
|
||||
let extension_csv = yield utils.getInput('extension-csv', false);
|
||||
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
|
||||
let coverage = yield utils.getInput('coverage', false);
|
||||
let os_version = process.platform;
|
||||
// check the os version and run the respective script
|
||||
if (os_version == 'darwin') {
|
||||
let darwin = yield utils.readScript('darwin.sh', version, os_version);
|
||||
darwin += yield features.addExtension(extension_csv, version, os_version);
|
||||
darwin += yield features.addINIValues(ini_values_csv, os_version);
|
||||
darwin += yield features.addCoverage(coverage, version, os_version);
|
||||
yield utils.writeScript('darwin.sh', version, darwin);
|
||||
yield exec_1.exec('sh -x ./' + version + 'darwin.sh ' + version);
|
||||
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
||||
}
|
||||
else if (os_version == 'win32') {
|
||||
let windows = yield utils.readScript('win32.ps1', version, os_version);
|
||||
windows += yield features.addExtension(extension_csv, version, os_version);
|
||||
windows += yield features.addINIValues(ini_values_csv, os_version);
|
||||
windows += yield features.addCoverage(coverage, version, os_version);
|
||||
yield utils.writeScript('win32.ps1', version, windows);
|
||||
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
||||
}
|
||||
@ -50,6 +53,7 @@ function run() {
|
||||
let linux = yield utils.readScript('linux.sh', version, os_version);
|
||||
linux += yield features.addExtension(extension_csv, version, os_version);
|
||||
linux += yield features.addINIValues(ini_values_csv, os_version);
|
||||
linux += yield features.addCoverage(coverage, version, os_version);
|
||||
yield utils.writeScript('linux.sh', version, linux);
|
||||
yield exec_1.exec('./' + version + 'linux.sh ' + version);
|
||||
}
|
||||
|
119
lib/utils.js
119
lib/utils.js
@ -22,10 +22,13 @@ const core = __importStar(require("@actions/core"));
|
||||
function getInput(name, mandatory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let input = process.env[name];
|
||||
if (!input) {
|
||||
input = core.getInput(name, { required: mandatory });
|
||||
switch (input) {
|
||||
case '':
|
||||
case undefined:
|
||||
return core.getInput(name, { required: mandatory });
|
||||
default:
|
||||
return input;
|
||||
}
|
||||
return input;
|
||||
});
|
||||
}
|
||||
exports.getInput = getInput;
|
||||
@ -44,6 +47,19 @@ function asyncForEach(array, callback) {
|
||||
});
|
||||
}
|
||||
exports.asyncForEach = asyncForEach;
|
||||
/**
|
||||
* Copy config
|
||||
*
|
||||
* @param files
|
||||
*/
|
||||
function readFiles74(files) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield asyncForEach(files, function (filename) {
|
||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.readFiles74 = readFiles74;
|
||||
/**
|
||||
* Read the scripts
|
||||
*
|
||||
@ -53,10 +69,34 @@ exports.asyncForEach = asyncForEach;
|
||||
*/
|
||||
function readScript(filename, version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (version === '7.4' && os_version === 'darwin') {
|
||||
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||
switch (os_version) {
|
||||
case 'darwin':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
yield readFiles74([
|
||||
'configs/config.yaml',
|
||||
'scripts/xdebug_darwin.sh',
|
||||
'scripts/pcov.sh'
|
||||
]);
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
}
|
||||
case 'linux':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
case '7.3':
|
||||
default:
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
}
|
||||
case 'win32':
|
||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||
default:
|
||||
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
|
||||
});
|
||||
}
|
||||
exports.readScript = readScript;
|
||||
@ -79,12 +119,18 @@ exports.writeScript = writeScript;
|
||||
*/
|
||||
function extensionArray(extension_csv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return extension_csv.split(',').map(function (extension) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
});
|
||||
switch (extension_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return extension_csv.split(',').map(function (extension) {
|
||||
return extension
|
||||
.trim()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.extensionArray = extensionArray;
|
||||
@ -96,9 +142,52 @@ exports.extensionArray = extensionArray;
|
||||
*/
|
||||
function INIArray(ini_values_csv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return ini_values_csv.split(',').map(function (ini_value) {
|
||||
return ini_value.trim();
|
||||
});
|
||||
switch (ini_values_csv) {
|
||||
case '':
|
||||
case ' ':
|
||||
return [];
|
||||
default:
|
||||
return ini_values_csv.split(',').map(function (ini_value) {
|
||||
return ini_value.trim();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.INIArray = INIArray;
|
||||
function log(message, os_version, log_type) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const unix_color = {
|
||||
error: '31',
|
||||
success: '32',
|
||||
warning: '33'
|
||||
};
|
||||
switch (os_version) {
|
||||
case 'win32':
|
||||
const color = {
|
||||
error: 'red',
|
||||
success: 'green',
|
||||
warning: 'yellow'
|
||||
};
|
||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
default:
|
||||
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.log = log;
|
||||
function getExtensionPrefix(extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let zend = ['xdebug', 'opcache'];
|
||||
switch (zend.indexOf(extension)) {
|
||||
case 0:
|
||||
case 1:
|
||||
return 'zend_extension';
|
||||
case -1:
|
||||
default:
|
||||
return 'extension';
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getExtensionPrefix = getExtensionPrefix;
|
||||
|
15
node_modules/.bin/codecov
generated
vendored
15
node_modules/.bin/codecov
generated
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../codecov/bin/codecov" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../codecov/bin/codecov" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
node_modules/.bin/codecov.cmd
generated
vendored
7
node_modules/.bin/codecov.cmd
generated
vendored
@ -1,7 +0,0 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\codecov\bin\codecov" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\codecov\bin\codecov" %*
|
||||
)
|
15
node_modules/.bin/esparse
generated
vendored
15
node_modules/.bin/esparse
generated
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../esprima/bin/esparse.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
node_modules/.bin/esparse.cmd
generated
vendored
7
node_modules/.bin/esparse.cmd
generated
vendored
@ -1,7 +0,0 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esparse.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\esprima\bin\esparse.js" %*
|
||||
)
|
15
node_modules/.bin/esvalidate
generated
vendored
15
node_modules/.bin/esvalidate
generated
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../esprima/bin/esvalidate.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
node_modules/.bin/esvalidate.cmd
generated
vendored
7
node_modules/.bin/esvalidate.cmd
generated
vendored
@ -1,7 +0,0 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esvalidate.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\esprima\bin\esvalidate.js" %*
|
||||
)
|
15
node_modules/.bin/js-yaml
generated
vendored
15
node_modules/.bin/js-yaml
generated
vendored
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../js-yaml/bin/js-yaml.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
node_modules/.bin/js-yaml.cmd
generated
vendored
7
node_modules/.bin/js-yaml.cmd
generated
vendored
@ -1,7 +0,0 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\js-yaml\bin\js-yaml.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\js-yaml\bin\js-yaml.js" %*
|
||||
)
|
7
node_modules/@actions/core/LICENSE.md
generated
vendored
7
node_modules/@actions/core/LICENSE.md
generated
vendored
@ -1,7 +0,0 @@
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
8
node_modules/@actions/core/lib/command.js
generated
vendored
8
node_modules/@actions/core/lib/command.js
generated
vendored
@ -20,7 +20,7 @@ function issue(name, message = '') {
|
||||
issueCommand(name, {}, message);
|
||||
}
|
||||
exports.issue = issue;
|
||||
const CMD_PREFIX = '##[';
|
||||
const CMD_STRING = '::';
|
||||
class Command {
|
||||
constructor(command, properties, message) {
|
||||
if (!command) {
|
||||
@ -31,7 +31,7 @@ class Command {
|
||||
this.message = message;
|
||||
}
|
||||
toString() {
|
||||
let cmdStr = CMD_PREFIX + this.command;
|
||||
let cmdStr = CMD_STRING + this.command;
|
||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
||||
cmdStr += ' ';
|
||||
for (const key in this.properties) {
|
||||
@ -40,12 +40,12 @@ class Command {
|
||||
if (val) {
|
||||
// safely append the val - avoid blowing up when attempting to
|
||||
// call .replace() if message is not a string for some reason
|
||||
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
||||
cmdStr += `${key}=${escape(`${val || ''}`)},`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cmdStr += ']';
|
||||
cmdStr += CMD_STRING;
|
||||
// safely append the message - avoid blowing up when attempting to
|
||||
// call .replace() if message is not a string for some reason
|
||||
const message = `${this.message || ''}`;
|
||||
|
2
node_modules/@actions/core/lib/command.js.map
generated
vendored
2
node_modules/@actions/core/lib/command.js.map
generated
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
5
node_modules/@actions/core/lib/core.d.ts
generated
vendored
5
node_modules/@actions/core/lib/core.d.ts
generated
vendored
@ -71,6 +71,11 @@ export declare function error(message: string): void;
|
||||
* @param message warning issue message
|
||||
*/
|
||||
export declare function warning(message: string): void;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
export declare function info(message: string): void;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
|
11
node_modules/@actions/core/lib/core.js
generated
vendored
11
node_modules/@actions/core/lib/core.js
generated
vendored
@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const command_1 = require("./command");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
/**
|
||||
* The code to exit an action
|
||||
@ -68,7 +69,7 @@ exports.addPath = addPath;
|
||||
* @returns string
|
||||
*/
|
||||
function getInput(name, options) {
|
||||
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
||||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
||||
if (options && options.required && !val) {
|
||||
throw new Error(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
@ -125,6 +126,14 @@ function warning(message) {
|
||||
command_1.issue('warning', message);
|
||||
}
|
||||
exports.warning = warning;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
function info(message) {
|
||||
process.stdout.write(message + os.EOL);
|
||||
}
|
||||
exports.info = info;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
|
2
node_modules/@actions/core/lib/core.js.map
generated
vendored
2
node_modules/@actions/core/lib/core.js.map
generated
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}
|
||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}
|
21
node_modules/@actions/core/package.json
generated
vendored
21
node_modules/@actions/core/package.json
generated
vendored
@ -1,33 +1,33 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@actions/core@1.1.0",
|
||||
"@actions/core@1.1.1",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "@actions/core@1.1.0",
|
||||
"_id": "@actions/core@1.1.0",
|
||||
"_from": "@actions/core@1.1.1",
|
||||
"_id": "@actions/core@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==",
|
||||
"_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
|
||||
"_location": "/@actions/core",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@actions/core@1.1.0",
|
||||
"raw": "@actions/core@1.1.1",
|
||||
"name": "@actions/core",
|
||||
"escapedName": "@actions%2fcore",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "1.1.0",
|
||||
"rawSpec": "1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.0"
|
||||
"fetchSpec": "1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/",
|
||||
"/@actions/tool-cache"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz",
|
||||
"_spec": "1.1.0",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
|
||||
"_spec": "1.1.1",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
@ -43,7 +43,6 @@
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"keywords": [
|
||||
"github",
|
||||
@ -64,5 +63,5 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
"version": "1.1.1"
|
||||
}
|
||||
|
7
node_modules/@actions/tool-cache/LICENSE.md
generated
vendored
7
node_modules/@actions/tool-cache/LICENSE.md
generated
vendored
@ -1,7 +0,0 @@
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
10
node_modules/@actions/tool-cache/README.md
generated
vendored
10
node_modules/@actions/tool-cache/README.md
generated
vendored
@ -11,7 +11,7 @@ You can use this to download tools (or other files) from a download URL:
|
||||
```js
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
```
|
||||
|
||||
#### Extract
|
||||
@ -22,15 +22,15 @@ These can then be extracted in platform specific ways:
|
||||
const tc = require('@actions/tool-cache');
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
|
||||
const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
|
||||
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
|
||||
|
||||
// Or alternately
|
||||
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
|
||||
const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
|
||||
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
else {
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
```
|
||||
@ -45,7 +45,7 @@ You'll often want to add it to the path as part of this step:
|
||||
const tc = require('@actions/tool-cache');
|
||||
const core = require('@actions/core');
|
||||
|
||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
||||
|
||||
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
|
||||
|
15
node_modules/@actions/tool-cache/lib/tool-cache.js
generated
vendored
15
node_modules/@actions/tool-cache/lib/tool-cache.js
generated
vendored
@ -218,12 +218,7 @@ function extractZip(file, dest) {
|
||||
yield extractZipWin(file, dest);
|
||||
}
|
||||
else {
|
||||
if (process.platform === 'darwin') {
|
||||
yield extractZipDarwin(file, dest);
|
||||
}
|
||||
else {
|
||||
yield extractZipNix(file, dest);
|
||||
}
|
||||
yield extractZipNix(file, dest);
|
||||
}
|
||||
return dest;
|
||||
});
|
||||
@ -252,13 +247,7 @@ function extractZipWin(file, dest) {
|
||||
}
|
||||
function extractZipNix(file, dest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
|
||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
||||
});
|
||||
}
|
||||
function extractZipDarwin(file, dest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
|
||||
const unzipPath = yield io.which('unzip');
|
||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
||||
});
|
||||
}
|
||||
|
2
node_modules/@actions/tool-cache/lib/tool-cache.js.map
generated
vendored
2
node_modules/@actions/tool-cache/lib/tool-cache.js.map
generated
vendored
File diff suppressed because one or more lines are too long
21
node_modules/@actions/tool-cache/package.json
generated
vendored
21
node_modules/@actions/tool-cache/package.json
generated
vendored
@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@actions/tool-cache@1.1.1",
|
||||
"@actions/tool-cache@1.1.2",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "@actions/tool-cache@1.1.1",
|
||||
"_id": "@actions/tool-cache@1.1.1",
|
||||
"_from": "@actions/tool-cache@1.1.2",
|
||||
"_id": "@actions/tool-cache@1.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-AILekrrj/L4N/5z5TGtUKVie4nKjxDioCgOEymyYxzPhGfjIxfE71tN2VTTpiICEWJ883rPRj2+WinTr1b6yVA==",
|
||||
"_integrity": "sha512-IJczPaZr02ECa3Lgws/TJEVco9tjOujiQSZbO3dHuXXjhd5vrUtfOgGwhmz3/f97L910OraPZ8SknofUk6RvOQ==",
|
||||
"_location": "/@actions/tool-cache",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@actions/tool-cache@1.1.1",
|
||||
"raw": "@actions/tool-cache@1.1.2",
|
||||
"name": "@actions/tool-cache",
|
||||
"escapedName": "@actions%2ftool-cache",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "1.1.1",
|
||||
"rawSpec": "1.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.1"
|
||||
"fetchSpec": "1.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.1.tgz",
|
||||
"_spec": "1.1.1",
|
||||
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.2.tgz",
|
||||
"_spec": "1.1.2",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
@ -54,7 +54,6 @@
|
||||
"lib",
|
||||
"scripts"
|
||||
],
|
||||
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||
"keywords": [
|
||||
"github",
|
||||
@ -75,5 +74,5 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "1.1.1"
|
||||
"version": "1.1.2"
|
||||
}
|
||||
|
BIN
node_modules/@actions/tool-cache/scripts/externals/unzip
generated
vendored
BIN
node_modules/@actions/tool-cache/scripts/externals/unzip
generated
vendored
Binary file not shown.
BIN
node_modules/@actions/tool-cache/scripts/externals/unzip-darwin
generated
vendored
BIN
node_modules/@actions/tool-cache/scripts/externals/unzip-darwin
generated
vendored
Binary file not shown.
24
node_modules/agent-base/.travis.yml
generated
vendored
24
node_modules/agent-base/.travis.yml
generated
vendored
@ -1,24 +0,0 @@
|
||||
sudo: false
|
||||
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "4"
|
||||
- "5"
|
||||
- "6"
|
||||
- "7"
|
||||
- "8"
|
||||
- "9"
|
||||
- "10"
|
||||
|
||||
install:
|
||||
- PATH="`npm bin`:`npm bin -g`:$PATH"
|
||||
# Install dependencies and build
|
||||
- npm install
|
||||
|
||||
script:
|
||||
# Output useful info for debugging
|
||||
- node --version
|
||||
- npm --version
|
||||
# Run tests
|
||||
- npm test
|
113
node_modules/agent-base/History.md
generated
vendored
113
node_modules/agent-base/History.md
generated
vendored
@ -1,113 +0,0 @@
|
||||
|
||||
4.2.0 / 2018-01-15
|
||||
==================
|
||||
|
||||
* Add support for returning an `http.Agent` instance
|
||||
* Optimize promisifying logic
|
||||
* Set `timeout` to null for proper cleanup
|
||||
* Remove Node.js <= 0.11.3 special-casing from test case
|
||||
|
||||
4.1.2 / 2017-11-20
|
||||
==================
|
||||
|
||||
* test Node 9 on Travis
|
||||
* ensure that `https.get()` uses the patched `https.request()`
|
||||
|
||||
4.1.1 / 2017-07-20
|
||||
==================
|
||||
|
||||
* Correct `https.request()` with a String (#9)
|
||||
|
||||
4.1.0 / 2017-06-26
|
||||
==================
|
||||
|
||||
* mix in Agent options into Request options
|
||||
* throw when nothing is returned from agent-base callback
|
||||
* do not modify the options object for https requests
|
||||
|
||||
4.0.1 / 2017-06-13
|
||||
==================
|
||||
|
||||
* add `this` context tests and fixes
|
||||
|
||||
4.0.0 / 2017-06-06
|
||||
==================
|
||||
|
||||
* drop support for Node.js < 4
|
||||
* drop old versions of Node.js from Travis-CI
|
||||
* specify Node.js >= 4.0.0 in `engines.node`
|
||||
* remove more old code
|
||||
* remove "extend" dependency
|
||||
* remove "semver" dependency
|
||||
* make the Promise logic a bit cleaner
|
||||
* add async function pseudo-example to README
|
||||
* use direct return in README example
|
||||
|
||||
3.0.0 / 2017-06-02
|
||||
==================
|
||||
|
||||
* drop support for Node.js v0.8 and v0.10
|
||||
* add support for async, Promises, and direct return
|
||||
* add a couple `options` test cases
|
||||
* implement a `"timeout"` option
|
||||
* rename main file to `index.js`
|
||||
* test Node 8 on Travis
|
||||
|
||||
2.1.1 / 2017-05-30
|
||||
==================
|
||||
|
||||
* Revert [`fe2162e`](https://github.com/TooTallNate/node-agent-base/commit/fe2162e0ba18123f5b301cba4de1e9dd74e437cd) and [`270bdc9`](https://github.com/TooTallNate/node-agent-base/commit/270bdc92eb8e3bd0444d1e5266e8e9390aeb3095) (fixes #7)
|
||||
|
||||
2.1.0 / 2017-05-26
|
||||
==================
|
||||
|
||||
* unref is not supported for node < 0.9.1 (@pi0)
|
||||
* add tests to dangling socket (@pi0)
|
||||
* check unref() is supported (@pi0)
|
||||
* fix dangling sockets problem (@pi0)
|
||||
* add basic "ws" module tests
|
||||
* make `Agent` be subclassable
|
||||
* turn `addRequest()` into a named function
|
||||
* test: Node.js v4 likes to call `cork` on the stream (#3, @tomhughes)
|
||||
* travis: test node v4, v5, v6 and v7
|
||||
|
||||
2.0.1 / 2015-09-10
|
||||
==================
|
||||
|
||||
* package: update "semver" to v5.0.1 for WebPack (#1, @vhpoet)
|
||||
|
||||
2.0.0 / 2015-07-10
|
||||
==================
|
||||
|
||||
* refactor to patch Node.js core for more consistent `opts` values
|
||||
* ensure that HTTP(s) default port numbers are always given
|
||||
* test: use ssl-cert-snakeoil SSL certs
|
||||
* test: add tests for arbitrary options
|
||||
* README: add API section
|
||||
* README: make the Agent HTTP/HTTPS generic in the example
|
||||
* README: use SVG for Travis-CI badge
|
||||
|
||||
1.0.2 / 2015-06-27
|
||||
==================
|
||||
|
||||
* agent: set `req._hadError` to true after emitting "error"
|
||||
* package: update "mocha" to v2
|
||||
* test: add artificial HTTP GET request test
|
||||
* test: add artificial data events test
|
||||
* test: fix artifical GET response test on node > v0.11.3
|
||||
* test: use a real timeout for the async error test
|
||||
|
||||
1.0.1 / 2013-09-09
|
||||
==================
|
||||
|
||||
* Fix passing an "error" object to the callback function on the first tick
|
||||
|
||||
1.0.0 / 2013-09-09
|
||||
==================
|
||||
|
||||
* New API: now you pass a callback function directly
|
||||
|
||||
0.0.1 / 2013-07-09
|
||||
==================
|
||||
|
||||
* Initial release
|
145
node_modules/agent-base/README.md
generated
vendored
145
node_modules/agent-base/README.md
generated
vendored
@ -1,145 +0,0 @@
|
||||
agent-base
|
||||
==========
|
||||
### Turn a function into an [`http.Agent`][http.Agent] instance
|
||||
[](https://travis-ci.org/TooTallNate/node-agent-base)
|
||||
|
||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
||||
given callback function when sending outbound HTTP requests.
|
||||
|
||||
#### Some subclasses:
|
||||
|
||||
Here's some more interesting uses of `agent-base`.
|
||||
Send a pull request to list yours!
|
||||
|
||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS (v4a) proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install agent-base
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
||||
|
||||
```js
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var agent = require('agent-base');
|
||||
|
||||
var endpoint = 'http://nodejs.org/api/';
|
||||
var parsed = url.parse(endpoint);
|
||||
|
||||
// This is the important part!
|
||||
parsed.agent = agent(function (req, opts) {
|
||||
var socket;
|
||||
// `secureEndpoint` is true when using the https module
|
||||
if (opts.secureEndpoint) {
|
||||
socket = tls.connect(opts);
|
||||
} else {
|
||||
socket = net.connect(opts);
|
||||
}
|
||||
return socket;
|
||||
});
|
||||
|
||||
// Everything else works just like normal...
|
||||
http.get(parsed, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
Returning a Promise or using an `async` function is also supported:
|
||||
|
||||
```js
|
||||
agent(async function (req, opts) {
|
||||
await sleep(1000);
|
||||
// etc…
|
||||
});
|
||||
```
|
||||
|
||||
Return another `http.Agent` instance to "pass through" the responsibility
|
||||
for that HTTP request to that agent:
|
||||
|
||||
```js
|
||||
agent(function (req, opts) {
|
||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
## Agent(Function callback[, Object options]) → [http.Agent][]
|
||||
|
||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
||||
for every HTTP request that it is used as the `agent` for. The callback function
|
||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
||||
used as the underlying socket in the HTTP request.
|
||||
|
||||
The `options` object accepts the following properties:
|
||||
|
||||
* `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
|
||||
|
||||
The callback function should have the following signature:
|
||||
|
||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
||||
|
||||
The ClientRequest `req` can be accessed to read request headers and
|
||||
and the path, etc. The `options` object contains the options passed
|
||||
to the `http.request()`/`https.request()` function call, and is formatted
|
||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
||||
else you want a Socket to be created. Pass the created socket to
|
||||
the callback function `cb` once created, and the HTTP request will
|
||||
continue to proceed.
|
||||
|
||||
If the `https` module is used to invoke the HTTP request, then the
|
||||
`secureEndpoint` property on `options` _will be set to `true`_.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
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.
|
||||
|
||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
||||
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
43
node_modules/agent-base/index.d.ts
generated
vendored
43
node_modules/agent-base/index.d.ts
generated
vendored
@ -1,43 +0,0 @@
|
||||
// Type definitions for agent-base 4.2.1
|
||||
// Project: https://github.com/TooTallNate/node-agent-base
|
||||
// Definitions by: Christopher Quadflieg <https://github.com/Shinigami92>
|
||||
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
declare namespace Agent {
|
||||
export type AgentCallback = (
|
||||
req?: any,
|
||||
opts?: {
|
||||
secureEndpoint: boolean;
|
||||
}
|
||||
) => void;
|
||||
|
||||
export interface AgentOptions {
|
||||
timeout?: number;
|
||||
host?: string;
|
||||
port?: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface Agent extends EventEmitter {
|
||||
_promisifiedCallback: boolean;
|
||||
timeout: number | null;
|
||||
options?: AgentOptions;
|
||||
callback: AgentCallback;
|
||||
addRequest: (req?: any, opts?: any) => void;
|
||||
freeSocket: (socket: any, opts: any) => void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*/
|
||||
declare function Agent(opts?: Agent.AgentOptions): Agent.Agent;
|
||||
declare function Agent(
|
||||
callback: Agent.AgentCallback,
|
||||
opts?: Agent.AgentOptions
|
||||
): Agent.Agent;
|
||||
|
||||
export = Agent;
|
170
node_modules/agent-base/index.js
generated
vendored
170
node_modules/agent-base/index.js
generated
vendored
@ -1,170 +0,0 @@
|
||||
'use strict';
|
||||
require('./patch-core');
|
||||
const inherits = require('util').inherits;
|
||||
const promisify = require('es6-promisify');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
|
||||
module.exports = Agent;
|
||||
|
||||
function isAgent(v) {
|
||||
return v && typeof v.addRequest === 'function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
function Agent(callback, _opts) {
|
||||
if (!(this instanceof Agent)) {
|
||||
return new Agent(callback, _opts);
|
||||
}
|
||||
|
||||
EventEmitter.call(this);
|
||||
|
||||
// The callback gets promisified if it has 3 parameters
|
||||
// (i.e. it has a callback function) lazily
|
||||
this._promisifiedCallback = false;
|
||||
|
||||
let opts = _opts;
|
||||
if ('function' === typeof callback) {
|
||||
this.callback = callback;
|
||||
} else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
|
||||
// timeout for the socket to be returned from the callback
|
||||
this.timeout = (opts && opts.timeout) || null;
|
||||
|
||||
this.options = opts;
|
||||
}
|
||||
inherits(Agent, EventEmitter);
|
||||
|
||||
/**
|
||||
* Override this function in your subclass!
|
||||
*/
|
||||
Agent.prototype.callback = function callback(req, opts) {
|
||||
throw new Error(
|
||||
'"agent-base" has no default implementation, you must subclass and override `callback()`'
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
Agent.prototype.addRequest = function addRequest(req, _opts) {
|
||||
const ownOpts = Object.assign({}, _opts);
|
||||
|
||||
// Set default `host` for HTTP to localhost
|
||||
if (null == ownOpts.host) {
|
||||
ownOpts.host = 'localhost';
|
||||
}
|
||||
|
||||
// Set default `port` for HTTP if none was explicitly specified
|
||||
if (null == ownOpts.port) {
|
||||
ownOpts.port = ownOpts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
|
||||
const opts = Object.assign({}, this.options, ownOpts);
|
||||
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most likely the
|
||||
// result of a `url.parse()` call... we need to remove the `path` portion so
|
||||
// that `net.connect()` doesn't attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
|
||||
// Create the `stream.Duplex` instance
|
||||
let timeout;
|
||||
let timedOut = false;
|
||||
const timeoutMs = this.timeout;
|
||||
const freeSocket = this.freeSocket;
|
||||
|
||||
function onerror(err) {
|
||||
if (req._hadError) return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
}
|
||||
|
||||
function ontimeout() {
|
||||
timeout = null;
|
||||
timedOut = true;
|
||||
const err = new Error(
|
||||
'A "socket" was not created for HTTP request before ' + timeoutMs + 'ms'
|
||||
);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
}
|
||||
|
||||
function callbackError(err) {
|
||||
if (timedOut) return;
|
||||
if (timeout != null) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
onerror(err);
|
||||
}
|
||||
|
||||
function onsocket(socket) {
|
||||
if (timedOut) return;
|
||||
if (timeout != null) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an http.Agent instance, so relinquish
|
||||
// responsibility for this `req` to the Agent from here on
|
||||
socket.addRequest(req, opts);
|
||||
} else if (socket) {
|
||||
function onfree() {
|
||||
freeSocket(socket, opts);
|
||||
}
|
||||
socket.on('free', onfree);
|
||||
req.onSocket(socket);
|
||||
} else {
|
||||
const err = new Error(
|
||||
'no Duplex stream was returned to agent-base for `' + req.method + ' ' + req.path + '`'
|
||||
);
|
||||
onerror(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._promisifiedCallback && this.callback.length >= 3) {
|
||||
// Legacy callback function - convert to a Promise
|
||||
this.callback = promisify(this.callback, this);
|
||||
this._promisifiedCallback = true;
|
||||
}
|
||||
|
||||
if (timeoutMs > 0) {
|
||||
timeout = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
|
||||
try {
|
||||
Promise.resolve(this.callback(req, opts)).then(onsocket, callbackError);
|
||||
} catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
};
|
||||
|
||||
Agent.prototype.freeSocket = function freeSocket(socket, opts) {
|
||||
// TODO reuse sockets
|
||||
socket.destroy();
|
||||
};
|
70
node_modules/agent-base/package.json
generated
vendored
70
node_modules/agent-base/package.json
generated
vendored
@ -1,70 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"agent-base@4.3.0",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "agent-base@4.3.0",
|
||||
"_id": "agent-base@4.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
|
||||
"_location": "/agent-base",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "agent-base@4.3.0",
|
||||
"name": "agent-base",
|
||||
"escapedName": "agent-base",
|
||||
"rawSpec": "4.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/https-proxy-agent"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
||||
"_spec": "4.3.0",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"author": {
|
||||
"name": "Nathan Rajlich",
|
||||
"email": "nathan@tootallnate.net",
|
||||
"url": "http://n8.io/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-agent-base/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
},
|
||||
"description": "Turn a function into an `http.Agent` instance",
|
||||
"devDependencies": {
|
||||
"@types/es6-promisify": "^5.0.0",
|
||||
"@types/node": "^10.5.3",
|
||||
"mocha": "^3.4.2",
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/TooTallNate/node-agent-base#readme",
|
||||
"keywords": [
|
||||
"http",
|
||||
"agent",
|
||||
"base",
|
||||
"barebones",
|
||||
"https"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"name": "agent-base",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-agent-base.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"version": "4.3.0"
|
||||
}
|
51
node_modules/agent-base/patch-core.js
generated
vendored
51
node_modules/agent-base/patch-core.js
generated
vendored
@ -1,51 +0,0 @@
|
||||
'use strict';
|
||||
const url = require('url');
|
||||
const https = require('https');
|
||||
|
||||
/**
|
||||
* This currently needs to be applied to all Node.js versions
|
||||
* in order to determine if the `req` is an HTTP or HTTPS request.
|
||||
*
|
||||
* There is currently no PR attempting to move this property upstream.
|
||||
*/
|
||||
const patchMarker = "__agent_base_https_request_patched__";
|
||||
if (!https.request[patchMarker]) {
|
||||
https.request = (function(request) {
|
||||
return function(_options, cb) {
|
||||
let options;
|
||||
if (typeof _options === 'string') {
|
||||
options = url.parse(_options);
|
||||
} else {
|
||||
options = Object.assign({}, _options);
|
||||
}
|
||||
if (null == options.port) {
|
||||
options.port = 443;
|
||||
}
|
||||
options.secureEndpoint = true;
|
||||
return request.call(https, options, cb);
|
||||
};
|
||||
})(https.request);
|
||||
https.request[patchMarker] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is needed for Node.js >= 9.0.0 to make sure `https.get()` uses the
|
||||
* patched `https.request()`.
|
||||
*
|
||||
* Ref: https://github.com/nodejs/node/commit/5118f31
|
||||
*/
|
||||
https.get = function (_url, _options, cb) {
|
||||
let options;
|
||||
if (typeof _url === 'string' && _options && typeof _options !== 'function') {
|
||||
options = Object.assign({}, url.parse(_url), _options);
|
||||
} else if (!_options && !cb) {
|
||||
options = _url;
|
||||
} else if (!cb) {
|
||||
options = _url;
|
||||
cb = _options;
|
||||
}
|
||||
|
||||
const req = https.request(options, cb);
|
||||
req.end();
|
||||
return req;
|
||||
};
|
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
@ -1,15 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICWwIBAAKBgQCzURxIqzer0ACAbX/lHdsn4Gd9PLKrf7EeDYfIdV0HZKPD8WDr
|
||||
bBx2/fBu0OW2sjnzv/SVZbJ0DAuPE/p0+eT0qb2qC10iz9iTD7ribd7gxhirVb8y
|
||||
b3fBjXsxc8V8p4Ny1LcvNSqCjwUbJqdRogfoJeTiqPM58z5sNzuv5iq7iwIDAQAB
|
||||
AoGAPMQy4olrP0UotlzlJ36bowLP70ffgHCwU+/f4NWs5fF78c3du0oSx1w820Dd
|
||||
Z7E0JF8bgnlJJTxjumPZz0RUCugrEHBKJmzEz3cxF5E3+7NvteZcjKn9D67RrM5x
|
||||
1/uSZ9cqKE9cYvY4fSuHx18diyZ4axR/wB1Pea2utjjDM+ECQQDb9ZbmmaWMiRpQ
|
||||
5Up+loxP7BZNPsEVsm+DVJmEFbaFgGfncWBqSIqnPNjMwTwj0OigTwCAEGPkfRVW
|
||||
T0pbYWCxAkEA0LK7SCTwzyDmhASUalk0x+3uCAA6ryFdwJf/wd8TRAvVOmkTEldX
|
||||
uJ7ldLvfrONYO3v56uKTU/SoNdZYzKtO+wJAX2KM4ctXYy5BXztPpr2acz4qHa1N
|
||||
Bh+vBAC34fOYhyQ76r3b1btHhWZ5jbFuZwm9F2erC94Ps5IaoqcX07DSwQJAPKGw
|
||||
h2U0EPkd/3zVIZCJJQya+vgWFIs9EZcXVtvYXQyTBkVApTN66MhBIYjzkub5205J
|
||||
bVQmOV37AKklY1DhwQJAA1wos0cYxro02edzatxd0DIR2r4qqOqLkw6BhYHhq6HJ
|
||||
ZvIcQkHqdSXzdETFc01I1znDGGIrJHcnvKWgBPoEUg==
|
||||
-----END RSA PRIVATE KEY-----
|
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
@ -1,12 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB1TCCAT4CCQDV5mPlzm9+izANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyQ3
|
||||
NTI3YmQ3Ny1hYjNlLTQ3NGItYWNlNy1lZWQ2MDUzOTMxZTcwHhcNMTUwNzA2MjI0
|
||||
NTA3WhcNMjUwNzAzMjI0NTA3WjAvMS0wKwYDVQQDEyQ3NTI3YmQ3Ny1hYjNlLTQ3
|
||||
NGItYWNlNy1lZWQ2MDUzOTMxZTcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
||||
ALNRHEirN6vQAIBtf+Ud2yfgZ308sqt/sR4Nh8h1XQdko8PxYOtsHHb98G7Q5bay
|
||||
OfO/9JVlsnQMC48T+nT55PSpvaoLXSLP2JMPuuJt3uDGGKtVvzJvd8GNezFzxXyn
|
||||
g3LUty81KoKPBRsmp1GiB+gl5OKo8znzPmw3O6/mKruLAgMBAAEwDQYJKoZIhvcN
|
||||
AQEFBQADgYEACzoHUF8UV2Z6541Q2wKEA0UFUzmUjf/E1XwBO+1P15ZZ64uw34B4
|
||||
1RwMPtAo9RY/PmICTWtNxWGxkzwb2JtDWtnxVER/lF8k2XcXPE76fxTHJF/BKk9J
|
||||
QU8OTD1dd9gHCBviQB9TqntRZ5X7axjtuWjb2umY+owBYzAHZkp1HKI=
|
||||
-----END CERTIFICATE-----
|
728
node_modules/agent-base/test/test.js
generated
vendored
728
node_modules/agent-base/test/test.js
generated
vendored
@ -1,728 +0,0 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var url = require('url');
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var WebSocket = require('ws');
|
||||
var assert = require('assert');
|
||||
var events = require('events');
|
||||
var inherits = require('util').inherits;
|
||||
var Agent = require('../');
|
||||
|
||||
var PassthroughAgent = Agent(function(req, opts) {
|
||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
||||
});
|
||||
|
||||
describe('Agent', function() {
|
||||
describe('subclass', function() {
|
||||
it('should be subclassable', function(done) {
|
||||
function MyAgent() {
|
||||
Agent.call(this);
|
||||
}
|
||||
inherits(MyAgent, Agent);
|
||||
|
||||
MyAgent.prototype.callback = function(req, opts, fn) {
|
||||
assert.equal(req.path, '/foo');
|
||||
assert.equal(req.getHeader('host'), '127.0.0.1:1234');
|
||||
assert.equal(opts.secureEndpoint, true);
|
||||
done();
|
||||
};
|
||||
|
||||
var info = url.parse('https://127.0.0.1:1234/foo');
|
||||
info.agent = new MyAgent();
|
||||
https.get(info);
|
||||
});
|
||||
});
|
||||
describe('options', function() {
|
||||
it('should support an options Object as first argument', function() {
|
||||
var agent = new Agent({ timeout: 1000 });
|
||||
assert.equal(1000, agent.timeout);
|
||||
});
|
||||
it('should support an options Object as second argument', function() {
|
||||
var agent = new Agent(function() {}, { timeout: 1000 });
|
||||
assert.equal(1000, agent.timeout);
|
||||
});
|
||||
it('should be mixed in with HTTP request options', function(done) {
|
||||
var agent = new Agent({
|
||||
host: 'my-proxy.com',
|
||||
port: 3128,
|
||||
foo: 'bar'
|
||||
});
|
||||
agent.callback = function(req, opts, fn) {
|
||||
assert.equal('bar', opts.foo);
|
||||
assert.equal('a', opts.b);
|
||||
|
||||
// `host` and `port` are special-cases, and should always be
|
||||
// overwritten in the request `opts` inside the agent-base callback
|
||||
assert.equal('localhost', opts.host);
|
||||
assert.equal(80, opts.port);
|
||||
done();
|
||||
};
|
||||
var opts = {
|
||||
b: 'a',
|
||||
agent: agent
|
||||
};
|
||||
http.get(opts);
|
||||
});
|
||||
});
|
||||
describe('`this` context', function() {
|
||||
it('should be the Agent instance', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent();
|
||||
agent.callback = function() {
|
||||
called = true;
|
||||
assert.equal(this, agent);
|
||||
};
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function(err) {
|
||||
assert(/no Duplex stream was returned/.test(err.message));
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be the Agent instance with callback signature', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent();
|
||||
agent.callback = function(req, opts, fn) {
|
||||
called = true;
|
||||
assert.equal(this, agent);
|
||||
fn();
|
||||
};
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function(err) {
|
||||
assert(/no Duplex stream was returned/.test(err.message));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('"error" event', function() {
|
||||
it('should be invoked on `http.ClientRequest` instance if `callback()` has not been defined', function(
|
||||
done
|
||||
) {
|
||||
var agent = new Agent();
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function(err) {
|
||||
assert.equal(
|
||||
'"agent-base" has no default implementation, you must subclass and override `callback()`',
|
||||
err.message
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be invoked on `http.ClientRequest` instance if Error passed to callback function on the first tick', function(
|
||||
done
|
||||
) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
fn(new Error('is this caught?'));
|
||||
});
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function(err) {
|
||||
assert.equal('is this caught?', err.message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be invoked on `http.ClientRequest` instance if Error passed to callback function after the first tick', function(
|
||||
done
|
||||
) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
setTimeout(function() {
|
||||
fn(new Error('is this caught?'));
|
||||
}, 10);
|
||||
});
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function(err) {
|
||||
assert.equal('is this caught?', err.message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('artificial "streams"', function() {
|
||||
it('should send a GET request', function(done) {
|
||||
var stream = new events.EventEmitter();
|
||||
|
||||
// needed for the `http` module to call .write() on the stream
|
||||
stream.writable = true;
|
||||
|
||||
stream.write = function(str) {
|
||||
assert(0 == str.indexOf('GET / HTTP/1.1'));
|
||||
done();
|
||||
};
|
||||
|
||||
// needed for `http` module in Node.js 4
|
||||
stream.cork = function() {};
|
||||
|
||||
var opts = {
|
||||
method: 'GET',
|
||||
host: '127.0.0.1',
|
||||
path: '/',
|
||||
port: 80,
|
||||
agent: new Agent(function(req, opts, fn) {
|
||||
fn(null, stream);
|
||||
})
|
||||
};
|
||||
var req = http.request(opts);
|
||||
req.end();
|
||||
});
|
||||
it('should receive a GET response', function(done) {
|
||||
var stream = new events.EventEmitter();
|
||||
var opts = {
|
||||
method: 'GET',
|
||||
host: '127.0.0.1',
|
||||
path: '/',
|
||||
port: 80,
|
||||
agent: new Agent(function(req, opts, fn) {
|
||||
fn(null, stream);
|
||||
})
|
||||
};
|
||||
var req = http.request(opts, function(res) {
|
||||
assert.equal('1.0', res.httpVersion);
|
||||
assert.equal(200, res.statusCode);
|
||||
assert.equal('bar', res.headers.foo);
|
||||
assert.deepEqual(['1', '2'], res.headers['set-cookie']);
|
||||
done();
|
||||
});
|
||||
|
||||
// have to wait for the "socket" event since `http.ClientRequest`
|
||||
// doesn't *actually* attach the listeners to the "stream" until
|
||||
// this happens
|
||||
req.once('socket', function() {
|
||||
var buf = Buffer.from(
|
||||
'HTTP/1.0 200\r\n' +
|
||||
'Foo: bar\r\n' +
|
||||
'Set-Cookie: 1\r\n' +
|
||||
'Set-Cookie: 2\r\n\r\n'
|
||||
);
|
||||
stream.emit('data', buf);
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"http" module', function() {
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTP server
|
||||
before(function(done) {
|
||||
server = http.createServer();
|
||||
server.listen(0, function() {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function(done) {
|
||||
server.once('close', function() {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should work for basic HTTP requests', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
called = true;
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
http.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support direct return in `connect()`', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts) {
|
||||
called = true;
|
||||
return net.connect(opts);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
http.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support returning a Promise in `connect()`', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
called = true;
|
||||
resolve(net.connect(opts));
|
||||
});
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
http.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the `Connection: close` response header', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
called = true;
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Url', req.url);
|
||||
assert.equal('close', req.headers.connection);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/bar');
|
||||
info.agent = agent;
|
||||
http.get(info, function(res) {
|
||||
assert.equal('/bar', res.headers['x-url']);
|
||||
assert.equal('close', res.headers.connection);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass through options from `http.request()`', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
assert.equal('google.com', opts.host);
|
||||
assert.equal('bar', opts.foo);
|
||||
done();
|
||||
});
|
||||
|
||||
http.get({
|
||||
host: 'google.com',
|
||||
foo: 'bar',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
|
||||
it('should default to port 80', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
assert.equal(80, opts.port);
|
||||
done();
|
||||
});
|
||||
|
||||
// (probably) not hitting a real HTTP server here,
|
||||
// so no need to add a httpServer request listener
|
||||
http.get({
|
||||
host: '127.0.0.1',
|
||||
path: '/foo',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
|
||||
it('should support the "timeout" option', function(done) {
|
||||
// ensure we timeout after the "error" event had a chance to trigger
|
||||
this.timeout(1000);
|
||||
this.slow(800);
|
||||
|
||||
var agent = new Agent(
|
||||
function(req, opts, fn) {
|
||||
// this function will time out
|
||||
},
|
||||
{ timeout: 100 }
|
||||
);
|
||||
|
||||
var opts = url.parse('http://nodejs.org');
|
||||
opts.agent = agent;
|
||||
|
||||
var req = http.get(opts);
|
||||
req.once('error', function(err) {
|
||||
assert.equal('ETIMEOUT', err.code);
|
||||
req.abort();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should free sockets after use', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
http.get(info, function(res) {
|
||||
res.socket.emit('free');
|
||||
assert.equal(true, res.socket.destroyed);
|
||||
assert(gotReq);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('PassthroughAgent', function() {
|
||||
it('should pass through to `http.globalAgent`', function(done) {
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = PassthroughAgent;
|
||||
http.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"https" module', function() {
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTPS server
|
||||
before(function(done) {
|
||||
var options = {
|
||||
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
|
||||
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
|
||||
};
|
||||
server = https.createServer(options);
|
||||
server.listen(0, function() {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function(done) {
|
||||
server.once('close', function() {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should not modify the passed in Options object', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
called = true;
|
||||
assert.equal(true, opts.secureEndpoint);
|
||||
assert.equal(443, opts.port);
|
||||
assert.equal('localhost', opts.host);
|
||||
});
|
||||
var opts = { agent: agent };
|
||||
var req = https.request(opts);
|
||||
assert.equal(true, called);
|
||||
assert.equal(false, 'secureEndpoint' in opts);
|
||||
assert.equal(false, 'port' in opts);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should work with a String URL', function(done) {
|
||||
var endpoint = 'https://127.0.0.1:' + port;
|
||||
var req = https.get(endpoint);
|
||||
|
||||
// it's gonna error out since `rejectUnauthorized` is not being passed in
|
||||
req.on('error', function(err) {
|
||||
assert.equal(err.code, 'DEPTH_ZERO_SELF_SIGNED_CERT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work for basic HTTPS requests', function(done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
called = true;
|
||||
assert(opts.secureEndpoint);
|
||||
var socket = tls.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTPS server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('https://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
info.rejectUnauthorized = false;
|
||||
https.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass through options from `https.request()`', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
assert.equal('google.com', opts.host);
|
||||
assert.equal('bar', opts.foo);
|
||||
done();
|
||||
});
|
||||
|
||||
https.get({
|
||||
host: 'google.com',
|
||||
foo: 'bar',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
|
||||
it('should support the 3-argument `https.get()`', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
assert.equal('google.com', opts.host);
|
||||
assert.equal('/q', opts.pathname || opts.path);
|
||||
assert.equal('881', opts.port);
|
||||
assert.equal('bar', opts.foo);
|
||||
done();
|
||||
});
|
||||
|
||||
https.get(
|
||||
'https://google.com:881/q',
|
||||
{
|
||||
host: 'google.com',
|
||||
foo: 'bar',
|
||||
agent: agent
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should default to port 443', function(done) {
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
assert.equal(true, opts.secureEndpoint);
|
||||
assert.equal(false, opts.rejectUnauthorized);
|
||||
assert.equal(443, opts.port);
|
||||
done();
|
||||
});
|
||||
|
||||
// (probably) not hitting a real HTTPS server here,
|
||||
// so no need to add a httpsServer request listener
|
||||
https.get({
|
||||
host: '127.0.0.1',
|
||||
path: '/foo',
|
||||
agent: agent,
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
});
|
||||
|
||||
it('should not re-patch https.request', () => {
|
||||
var patchModulePath = "../patch-core";
|
||||
var patchedRequest = https.request;
|
||||
|
||||
delete require.cache[require.resolve(patchModulePath)];
|
||||
require(patchModulePath);
|
||||
|
||||
assert.equal(patchedRequest, https.request);
|
||||
assert.equal(true, https.request.__agent_base_https_request_patched__);
|
||||
});
|
||||
|
||||
describe('PassthroughAgent', function() {
|
||||
it('should pass through to `https.globalAgent`', function(done) {
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function(req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('https://127.0.0.1:' + port + '/foo');
|
||||
info.agent = PassthroughAgent;
|
||||
info.rejectUnauthorized = false;
|
||||
https.get(info, function(res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"ws" server', function() {
|
||||
var wss;
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTP server
|
||||
before(function(done) {
|
||||
server = http.createServer();
|
||||
wss = new WebSocket.Server({ server: server });
|
||||
server.listen(0, function() {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function(done) {
|
||||
server.once('close', function() {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should work for basic WebSocket connections', function(done) {
|
||||
function onconnection(ws) {
|
||||
ws.on('message', function(data) {
|
||||
assert.equal('ping', data);
|
||||
ws.send('pong');
|
||||
});
|
||||
}
|
||||
wss.on('connection', onconnection);
|
||||
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
var client = new WebSocket('ws://127.0.0.1:' + port + '/', {
|
||||
agent: agent
|
||||
});
|
||||
|
||||
client.on('open', function() {
|
||||
client.send('ping');
|
||||
});
|
||||
|
||||
client.on('message', function(data) {
|
||||
assert.equal('pong', data);
|
||||
client.close();
|
||||
wss.removeListener('connection', onconnection);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"wss" server', function() {
|
||||
var wss;
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTP server
|
||||
before(function(done) {
|
||||
var options = {
|
||||
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
|
||||
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
|
||||
};
|
||||
server = https.createServer(options);
|
||||
wss = new WebSocket.Server({ server: server });
|
||||
server.listen(0, function() {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function(done) {
|
||||
server.once('close', function() {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should work for secure WebSocket connections', function(done) {
|
||||
function onconnection(ws) {
|
||||
ws.on('message', function(data) {
|
||||
assert.equal('ping', data);
|
||||
ws.send('pong');
|
||||
});
|
||||
}
|
||||
wss.on('connection', onconnection);
|
||||
|
||||
var agent = new Agent(function(req, opts, fn) {
|
||||
var socket = tls.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
var client = new WebSocket('wss://127.0.0.1:' + port + '/', {
|
||||
agent: agent,
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
|
||||
client.on('open', function() {
|
||||
client.send('ping');
|
||||
});
|
||||
|
||||
client.on('message', function(data) {
|
||||
assert.equal('pong', data);
|
||||
client.close();
|
||||
wss.removeListener('connection', onconnection);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
185
node_modules/argparse/CHANGELOG.md
generated
vendored
185
node_modules/argparse/CHANGELOG.md
generated
vendored
@ -1,185 +0,0 @@
|
||||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
- First release.
|
21
node_modules/argparse/LICENSE
generated
vendored
21
node_modules/argparse/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
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.
|
257
node_modules/argparse/README.md
generated
vendored
257
node_modules/argparse/README.md
generated
vendored
@ -1,257 +0,0 @@
|
||||
argparse
|
||||
========
|
||||
|
||||
[](http://travis-ci.org/nodeca/argparse)
|
||||
[](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
|
||||
|
3
node_modules/argparse/index.js
generated
vendored
3
node_modules/argparse/index.js
generated
vendored
@ -1,3 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/argparse');
|
146
node_modules/argparse/lib/action.js
generated
vendored
146
node_modules/argparse/lib/action.js
generated
vendored
@ -1,146 +0,0 @@
|
||||
/**
|
||||
* class Action
|
||||
*
|
||||
* Base class for all actions
|
||||
* Do not call in your code, use this class only for inherits your own action
|
||||
*
|
||||
* Information about how to convert command line strings to Javascript objects.
|
||||
* Action objects are used by an ArgumentParser to represent the information
|
||||
* needed to parse a single argument from one or more strings from the command
|
||||
* line. The keyword arguments to the Action constructor are also all attributes
|
||||
* of Action instances.
|
||||
*
|
||||
* ##### Allowed keywords:
|
||||
*
|
||||
* - `store`
|
||||
* - `storeConstant`
|
||||
* - `storeTrue`
|
||||
* - `storeFalse`
|
||||
* - `append`
|
||||
* - `appendConstant`
|
||||
* - `count`
|
||||
* - `help`
|
||||
* - `version`
|
||||
*
|
||||
* Information about action options see [[Action.new]]
|
||||
*
|
||||
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
|
||||
/**
|
||||
* new Action(options)
|
||||
*
|
||||
* Base class for all actions. Used only for inherits
|
||||
*
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `optionStrings` A list of command-line option strings for the action.
|
||||
* - `dest` Attribute to hold the created object(s)
|
||||
* - `nargs` The number of command-line arguments that should be consumed.
|
||||
* By default, one argument will be consumed and a single value will be
|
||||
* produced.
|
||||
* - `constant` Default value for an action with no value.
|
||||
* - `defaultValue` The value to be produced if the option is not specified.
|
||||
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
||||
* None, 'string'.
|
||||
* - `choices` The choices available.
|
||||
* - `required` True if the action must always be specified at the command
|
||||
* line.
|
||||
* - `help` The help describing the argument.
|
||||
* - `metavar` The name to be used for the option's argument with the help
|
||||
* string. If None, the 'dest' value will be used as the name.
|
||||
*
|
||||
* ##### nargs supported values:
|
||||
*
|
||||
* - `N` (an integer) consumes N arguments (and produces a list)
|
||||
* - `?` consumes zero or one arguments
|
||||
* - `*` consumes zero or more arguments (and produces a list)
|
||||
* - `+` consumes one or more arguments (and produces a list)
|
||||
*
|
||||
* Note: that the difference between the default and nargs=1 is that with the
|
||||
* default, a single value will be produced, while with nargs=1, a list
|
||||
* containing a single value will be produced.
|
||||
**/
|
||||
var Action = module.exports = function Action(options) {
|
||||
options = options || {};
|
||||
this.optionStrings = options.optionStrings || [];
|
||||
this.dest = options.dest;
|
||||
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
||||
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
||||
this.defaultValue = options.defaultValue;
|
||||
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
||||
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
||||
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
||||
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
||||
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
||||
|
||||
if (!(this.optionStrings instanceof Array)) {
|
||||
throw new Error('optionStrings should be an array');
|
||||
}
|
||||
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
||||
throw new Error('required should be a boolean');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#getName -> String
|
||||
*
|
||||
* Tells action name
|
||||
**/
|
||||
Action.prototype.getName = function () {
|
||||
if (this.optionStrings.length > 0) {
|
||||
return this.optionStrings.join('/');
|
||||
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
||||
return this.metavar;
|
||||
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
||||
return this.dest;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isOptional -> Boolean
|
||||
*
|
||||
* Return true if optional
|
||||
**/
|
||||
Action.prototype.isOptional = function () {
|
||||
return !this.isPositional();
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isPositional -> Boolean
|
||||
*
|
||||
* Return true if positional
|
||||
**/
|
||||
Action.prototype.isPositional = function () {
|
||||
return (this.optionStrings.length === 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Should be implemented in inherited classes
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
||||
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
* };
|
||||
*
|
||||
**/
|
||||
Action.prototype.call = function () {
|
||||
throw new Error('.call() not defined');// Not Implemented error
|
||||
};
|
53
node_modules/argparse/lib/action/append.js
generated
vendored
53
node_modules/argparse/lib/action/append.js
generated
vendored
@ -1,53 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppend
|
||||
*
|
||||
* This action stores a list, and appends each argument value to the list.
|
||||
* This is useful to allow an option to be specified multiple times.
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppend(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
* Note: options.nargs should be optional for constants
|
||||
* and more then zero for other
|
||||
**/
|
||||
var ActionAppend = module.exports = function ActionAppend(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for append actions must be > 0; if arg ' +
|
||||
'strings are not supplying the value to append, ' +
|
||||
'the append const action may be more appropriate');
|
||||
}
|
||||
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppend, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppend.prototype.call = function (parser, namespace, values) {
|
||||
var items = (namespace[this.dest] || []).slice();
|
||||
items.push(values);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
47
node_modules/argparse/lib/action/append/constant.js
generated
vendored
47
node_modules/argparse/lib/action/append/constant.js
generated
vendored
@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppendConstant
|
||||
*
|
||||
* This stores a list, and appends the value specified by
|
||||
* the const keyword argument to the list.
|
||||
* (Note that the const keyword argument defaults to null.)
|
||||
* The 'appendConst' action is typically useful when multiple
|
||||
* arguments need to store constants to the same list.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppendConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for appendAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppendConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
||||
var items = [].concat(namespace[this.dest] || []);
|
||||
items.push(this.constant);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
40
node_modules/argparse/lib/action/count.js
generated
vendored
40
node_modules/argparse/lib/action/count.js
generated
vendored
@ -1,40 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionCount
|
||||
*
|
||||
* This counts the number of times a keyword argument occurs.
|
||||
* For example, this is useful for increasing verbosity levels
|
||||
*
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionCount(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionCount = module.exports = function ActionCount(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionCount, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionCount.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
};
|
47
node_modules/argparse/lib/action/help.js
generated
vendored
47
node_modules/argparse/lib/action/help.js
generated
vendored
@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionHelp
|
||||
*
|
||||
* Support action for printing help
|
||||
* This class inherided from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionHelp(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionHelp = module.exports = function ActionHelp(options) {
|
||||
options = options || {};
|
||||
if (options.defaultValue !== null) {
|
||||
options.defaultValue = options.defaultValue;
|
||||
} else {
|
||||
options.defaultValue = c.SUPPRESS;
|
||||
}
|
||||
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
Action.call(this, options);
|
||||
|
||||
};
|
||||
util.inherits(ActionHelp, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionHelp#call(parser, namespace, values, optionString)
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print help and exit
|
||||
**/
|
||||
ActionHelp.prototype.call = function (parser) {
|
||||
parser.printHelp();
|
||||
parser.exit();
|
||||
};
|
50
node_modules/argparse/lib/action/store.js
generated
vendored
50
node_modules/argparse/lib/action/store.js
generated
vendored
@ -1,50 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStore
|
||||
*
|
||||
* This action just stores the argument’s value. This is the default action.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStore(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStore = module.exports = function ActionStore(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for store actions must be > 0; if you ' +
|
||||
'have nothing to store, actions such as store ' +
|
||||
'true or store const may be more appropriate');
|
||||
|
||||
}
|
||||
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStore, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStore.prototype.call = function (parser, namespace, values) {
|
||||
namespace.set(this.dest, values);
|
||||
};
|
43
node_modules/argparse/lib/action/store/constant.js
generated
vendored
43
node_modules/argparse/lib/action/store/constant.js
generated
vendored
@ -1,43 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreConstant
|
||||
*
|
||||
* This action stores the value specified by the const keyword argument.
|
||||
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
||||
* The 'store_const' action is most commonly used with optional
|
||||
* arguments that specify some sort of flag.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for storeAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, this.constant);
|
||||
};
|
27
node_modules/argparse/lib/action/store/false.js
generated
vendored
27
node_modules/argparse/lib/action/store/false.js
generated
vendored
@ -1,27 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreFalse
|
||||
*
|
||||
* This action store the values False respectively.
|
||||
* This is special cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreFalse(options)
|
||||
* - options (object): hash of options see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
||||
options = options || {};
|
||||
options.constant = false;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
26
node_modules/argparse/lib/action/store/true.js
generated
vendored
26
node_modules/argparse/lib/action/store/true.js
generated
vendored
@ -1,26 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreTrue
|
||||
*
|
||||
* This action store the values True respectively.
|
||||
* This isspecial cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreTrue(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
||||
options = options || {};
|
||||
options.constant = true;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
149
node_modules/argparse/lib/action/subparsers.js
generated
vendored
149
node_modules/argparse/lib/action/subparsers.js
generated
vendored
@ -1,149 +0,0 @@
|
||||
/** internal
|
||||
* class ActionSubparsers
|
||||
*
|
||||
* Support the creation of such sub-commands with the addSubparsers()
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('../argument/error');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ChoicesPseudoAction(name, help)
|
||||
*
|
||||
* Create pseudo action for correct help text
|
||||
*
|
||||
**/
|
||||
function ChoicesPseudoAction(name, help) {
|
||||
var options = {
|
||||
optionStrings: [],
|
||||
dest: name,
|
||||
help: help
|
||||
};
|
||||
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ChoicesPseudoAction, Action);
|
||||
|
||||
/**
|
||||
* new ActionSubparsers(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
function ActionSubparsers(options) {
|
||||
options = options || {};
|
||||
options.dest = options.dest || c.SUPPRESS;
|
||||
options.nargs = c.PARSER;
|
||||
|
||||
this.debug = (options.debug === true);
|
||||
|
||||
this._progPrefix = options.prog;
|
||||
this._parserClass = options.parserClass;
|
||||
this._nameParserMap = {};
|
||||
this._choicesActions = [];
|
||||
|
||||
options.choices = this._nameParserMap;
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ActionSubparsers, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
||||
* - name (string): sub-command name
|
||||
* - options (object): see [[ArgumentParser.new]]
|
||||
*
|
||||
* Note:
|
||||
* addParser supports an additional aliases option,
|
||||
* which allows multiple strings to refer to the same subparser.
|
||||
* This example, like svn, aliases co as a shorthand for checkout
|
||||
*
|
||||
**/
|
||||
ActionSubparsers.prototype.addParser = function (name, options) {
|
||||
var parser;
|
||||
|
||||
var self = this;
|
||||
|
||||
options = options || {};
|
||||
|
||||
options.debug = (this.debug === true);
|
||||
|
||||
// set program from the existing prefix
|
||||
if (!options.prog) {
|
||||
options.prog = this._progPrefix + ' ' + name;
|
||||
}
|
||||
|
||||
var aliases = options.aliases || [];
|
||||
|
||||
// create a pseudo-action to hold the choice help
|
||||
if (!!options.help || typeof options.help === 'string') {
|
||||
var help = options.help;
|
||||
delete options.help;
|
||||
|
||||
var choiceAction = new ChoicesPseudoAction(name, help);
|
||||
this._choicesActions.push(choiceAction);
|
||||
}
|
||||
|
||||
// create the parser and add it to the map
|
||||
parser = new this._parserClass(options);
|
||||
this._nameParserMap[name] = parser;
|
||||
|
||||
// make parser available under aliases also
|
||||
aliases.forEach(function (alias) {
|
||||
self._nameParserMap[alias] = parser;
|
||||
});
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
ActionSubparsers.prototype._getSubactions = function () {
|
||||
return this._choicesActions;
|
||||
};
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Parse input aguments
|
||||
**/
|
||||
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
||||
var parserName = values[0];
|
||||
var argStrings = values.slice(1);
|
||||
|
||||
// set the parser name if requested
|
||||
if (this.dest !== c.SUPPRESS) {
|
||||
namespace[this.dest] = parserName;
|
||||
}
|
||||
|
||||
// select the parser
|
||||
if (this._nameParserMap[parserName]) {
|
||||
parser = this._nameParserMap[parserName];
|
||||
} else {
|
||||
throw argumentErrorHelper(format(
|
||||
'Unknown parser "%s" (choices: [%s]).',
|
||||
parserName,
|
||||
Object.keys(this._nameParserMap).join(', ')
|
||||
));
|
||||
}
|
||||
|
||||
// parse all the remaining options into the namespace
|
||||
parser.parseArgs(argStrings, namespace);
|
||||
};
|
||||
|
||||
module.exports = ActionSubparsers;
|
47
node_modules/argparse/lib/action/version.js
generated
vendored
47
node_modules/argparse/lib/action/version.js
generated
vendored
@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionVersion
|
||||
*
|
||||
* Support action for printing program version
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionVersion(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionVersion = module.exports = function ActionVersion(options) {
|
||||
options = options || {};
|
||||
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
||||
options.dest = (options.dest || c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
this.version = options.version;
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionVersion, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print version and exit
|
||||
**/
|
||||
ActionVersion.prototype.call = function (parser) {
|
||||
var version = this.version || parser.version;
|
||||
var formatter = parser._getFormatter();
|
||||
formatter.addText(version);
|
||||
parser.exit(0, formatter.formatHelp());
|
||||
};
|
482
node_modules/argparse/lib/action_container.js
generated
vendored
482
node_modules/argparse/lib/action_container.js
generated
vendored
@ -1,482 +0,0 @@
|
||||
/** internal
|
||||
* class ActionContainer
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
//Actions
|
||||
var ActionHelp = require('./action/help');
|
||||
var ActionAppend = require('./action/append');
|
||||
var ActionAppendConstant = require('./action/append/constant');
|
||||
var ActionCount = require('./action/count');
|
||||
var ActionStore = require('./action/store');
|
||||
var ActionStoreConstant = require('./action/store/constant');
|
||||
var ActionStoreTrue = require('./action/store/true');
|
||||
var ActionStoreFalse = require('./action/store/false');
|
||||
var ActionVersion = require('./action/version');
|
||||
var ActionSubparsers = require('./action/subparsers');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('./argument/error');
|
||||
|
||||
/**
|
||||
* new ActionContainer(options)
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `description` -- A description of what the program does
|
||||
* - `prefixChars` -- Characters that prefix optional arguments
|
||||
* - `argumentDefault` -- The default value for all arguments
|
||||
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
||||
**/
|
||||
var ActionContainer = module.exports = function ActionContainer(options) {
|
||||
options = options || {};
|
||||
|
||||
this.description = options.description;
|
||||
this.argumentDefault = options.argumentDefault;
|
||||
this.prefixChars = options.prefixChars || '';
|
||||
this.conflictHandler = options.conflictHandler;
|
||||
|
||||
// set up registries
|
||||
this._registries = {};
|
||||
|
||||
// register actions
|
||||
this.register('action', null, ActionStore);
|
||||
this.register('action', 'store', ActionStore);
|
||||
this.register('action', 'storeConst', ActionStoreConstant);
|
||||
this.register('action', 'storeTrue', ActionStoreTrue);
|
||||
this.register('action', 'storeFalse', ActionStoreFalse);
|
||||
this.register('action', 'append', ActionAppend);
|
||||
this.register('action', 'appendConst', ActionAppendConstant);
|
||||
this.register('action', 'count', ActionCount);
|
||||
this.register('action', 'help', ActionHelp);
|
||||
this.register('action', 'version', ActionVersion);
|
||||
this.register('action', 'parsers', ActionSubparsers);
|
||||
|
||||
// raise an exception if the conflict handler is invalid
|
||||
this._getHandler();
|
||||
|
||||
// action storage
|
||||
this._actions = [];
|
||||
this._optionStringActions = {};
|
||||
|
||||
// groups
|
||||
this._actionGroups = [];
|
||||
this._mutuallyExclusiveGroups = [];
|
||||
|
||||
// defaults storage
|
||||
this._defaults = {};
|
||||
|
||||
// determines whether an "option" looks like a negative number
|
||||
// -1, -1.5 -5e+4
|
||||
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
||||
|
||||
// whether or not there are any optionals that look like negative
|
||||
// numbers -- uses a list so it can be shared and edited
|
||||
this._hasNegativeNumberOptionals = [];
|
||||
};
|
||||
|
||||
// Groups must be required, then ActionContainer already defined
|
||||
var ArgumentGroup = require('./argument/group');
|
||||
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
||||
|
||||
//
|
||||
// Registration methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#register(registryName, value, object) -> Void
|
||||
* - registryName (String) : object type action|type
|
||||
* - value (string) : keyword
|
||||
* - object (Object|Function) : handler
|
||||
*
|
||||
* Register handlers
|
||||
**/
|
||||
ActionContainer.prototype.register = function (registryName, value, object) {
|
||||
this._registries[registryName] = this._registries[registryName] || {};
|
||||
this._registries[registryName][value] = object;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
||||
if (arguments.length < 3) {
|
||||
defaultValue = null;
|
||||
}
|
||||
return this._registries[registryName][value] || defaultValue;
|
||||
};
|
||||
|
||||
//
|
||||
// Namespace default accessor methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#setDefaults(options) -> Void
|
||||
* - options (object):hash of options see [[Action.new]]
|
||||
*
|
||||
* Set defaults
|
||||
**/
|
||||
ActionContainer.prototype.setDefaults = function (options) {
|
||||
options = options || {};
|
||||
for (var property in options) {
|
||||
if ($$.has(options, property)) {
|
||||
this._defaults[property] = options[property];
|
||||
}
|
||||
}
|
||||
|
||||
// if these defaults match any existing arguments, replace the previous
|
||||
// default on the object with the new one
|
||||
this._actions.forEach(function (action) {
|
||||
if ($$.has(options, action.dest)) {
|
||||
action.defaultValue = options[action.dest];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#getDefault(dest) -> Mixed
|
||||
* - dest (string): action destination
|
||||
*
|
||||
* Return action default value
|
||||
**/
|
||||
ActionContainer.prototype.getDefault = function (dest) {
|
||||
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
||||
|
||||
this._actions.forEach(function (action) {
|
||||
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
||||
result = action.defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
//
|
||||
// Adding argument actions
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgument(args, options) -> Object
|
||||
* - args (String|Array): argument key, or array of argument keys
|
||||
* - options (Object): action objects see [[Action.new]]
|
||||
*
|
||||
* #### Examples
|
||||
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
||||
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
||||
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
||||
**/
|
||||
ActionContainer.prototype.addArgument = function (args, options) {
|
||||
args = args;
|
||||
options = options || {};
|
||||
|
||||
if (typeof args === 'string') {
|
||||
args = [ args ];
|
||||
}
|
||||
if (!Array.isArray(args)) {
|
||||
throw new TypeError('addArgument first argument should be a string or an array');
|
||||
}
|
||||
if (typeof options !== 'object' || Array.isArray(options)) {
|
||||
throw new TypeError('addArgument second argument should be a hash');
|
||||
}
|
||||
|
||||
// if no positional args are supplied or only one is supplied and
|
||||
// it doesn't look like an option string, parse a positional argument
|
||||
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
||||
if (args && !!options.dest) {
|
||||
throw new Error('dest supplied twice for positional argument');
|
||||
}
|
||||
options = this._getPositional(args, options);
|
||||
|
||||
// otherwise, we're adding an optional argument
|
||||
} else {
|
||||
options = this._getOptional(args, options);
|
||||
}
|
||||
|
||||
// if no default was supplied, use the parser-level default
|
||||
if (typeof options.defaultValue === 'undefined') {
|
||||
var dest = options.dest;
|
||||
if ($$.has(this._defaults, dest)) {
|
||||
options.defaultValue = this._defaults[dest];
|
||||
} else if (typeof this.argumentDefault !== 'undefined') {
|
||||
options.defaultValue = this.argumentDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// create the action object, and add it to the parser
|
||||
var ActionClass = this._popActionClass(options);
|
||||
if (typeof ActionClass !== 'function') {
|
||||
throw new Error(format('Unknown action "%s".', ActionClass));
|
||||
}
|
||||
var action = new ActionClass(options);
|
||||
|
||||
// throw an error if the action type is not callable
|
||||
var typeFunction = this._registryGet('type', action.type, action.type);
|
||||
if (typeof typeFunction !== 'function') {
|
||||
throw new Error(format('"%s" is not callable', typeFunction));
|
||||
}
|
||||
|
||||
return this._addAction(action);
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
||||
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
||||
*
|
||||
* Create new arguments groups
|
||||
**/
|
||||
ActionContainer.prototype.addArgumentGroup = function (options) {
|
||||
var group = new ArgumentGroup(this, options);
|
||||
this._actionGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
||||
* - options (Object): {required: false}
|
||||
*
|
||||
* Create new mutual exclusive groups
|
||||
**/
|
||||
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
||||
var group = new MutuallyExclusiveGroup(this, options);
|
||||
this._mutuallyExclusiveGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
// resolve any conflicts
|
||||
this._checkConflict(action);
|
||||
|
||||
// add to actions list
|
||||
this._actions.push(action);
|
||||
action.container = this;
|
||||
|
||||
// index the action by any option strings it has
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
self._optionStringActions[optionString] = action;
|
||||
});
|
||||
|
||||
// set the flag if any option strings look like negative numbers
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
if (optionString.match(self._regexpNegativeNumber)) {
|
||||
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
||||
self._hasNegativeNumberOptionals.push(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// return the created action
|
||||
return action;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._removeAction = function (action) {
|
||||
var actionIndex = this._actions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._actions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addContainerActions = function (container) {
|
||||
// collect groups by titles
|
||||
var titleGroupMap = {};
|
||||
this._actionGroups.forEach(function (group) {
|
||||
if (titleGroupMap[group.title]) {
|
||||
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
||||
}
|
||||
titleGroupMap[group.title] = group;
|
||||
});
|
||||
|
||||
// map each action to its group
|
||||
var groupMap = {};
|
||||
function actionHash(action) {
|
||||
// unique (hopefully?) string suitable as dictionary key
|
||||
return action.getName();
|
||||
}
|
||||
container._actionGroups.forEach(function (group) {
|
||||
// if a group with the title exists, use that, otherwise
|
||||
// create a new group matching the container's group
|
||||
if (!titleGroupMap[group.title]) {
|
||||
titleGroupMap[group.title] = this.addArgumentGroup({
|
||||
title: group.title,
|
||||
description: group.description
|
||||
});
|
||||
}
|
||||
|
||||
// map the actions to their new group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
||||
});
|
||||
}, this);
|
||||
|
||||
// add container's mutually exclusive groups
|
||||
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||
// description= then this code will need to be expanded as above
|
||||
var mutexGroup;
|
||||
container._mutuallyExclusiveGroups.forEach(function (group) {
|
||||
mutexGroup = this.addMutuallyExclusiveGroup({
|
||||
required: group.required
|
||||
});
|
||||
// map the actions to their new mutex group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = mutexGroup;
|
||||
});
|
||||
}, this); // forEach takes a 'this' argument
|
||||
|
||||
// add all actions to this container or their group
|
||||
container._actions.forEach(function (action) {
|
||||
var key = actionHash(action);
|
||||
if (groupMap[key]) {
|
||||
groupMap[key]._addAction(action);
|
||||
} else {
|
||||
this._addAction(action);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getPositional = function (dest, options) {
|
||||
if (Array.isArray(dest)) {
|
||||
dest = dest[0];
|
||||
}
|
||||
// make sure required is not specified
|
||||
if (options.required) {
|
||||
throw new Error('"required" is an invalid argument for positionals.');
|
||||
}
|
||||
|
||||
// mark positional arguments as required if at least one is
|
||||
// always required
|
||||
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
||||
options.required = true;
|
||||
}
|
||||
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
||||
options.required = true;
|
||||
}
|
||||
|
||||
// return the keyword arguments with no option strings
|
||||
options.dest = dest;
|
||||
options.optionStrings = [];
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getOptional = function (args, options) {
|
||||
var prefixChars = this.prefixChars;
|
||||
var optionStrings = [];
|
||||
var optionStringsLong = [];
|
||||
|
||||
// determine short and long option strings
|
||||
args.forEach(function (optionString) {
|
||||
// error on strings that don't start with an appropriate prefix
|
||||
if (prefixChars.indexOf(optionString[0]) < 0) {
|
||||
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
||||
optionString,
|
||||
prefixChars
|
||||
));
|
||||
}
|
||||
|
||||
// strings starting with two prefix characters are long options
|
||||
optionStrings.push(optionString);
|
||||
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
||||
optionStringsLong.push(optionString);
|
||||
}
|
||||
});
|
||||
|
||||
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
||||
var dest = options.dest || null;
|
||||
delete options.dest;
|
||||
|
||||
if (!dest) {
|
||||
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
||||
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
||||
|
||||
if (dest.length === 0) {
|
||||
throw new Error(
|
||||
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
||||
);
|
||||
}
|
||||
dest = dest.replace(/-/g, '_');
|
||||
}
|
||||
|
||||
// return the updated keyword arguments
|
||||
options.dest = dest;
|
||||
options.optionStrings = optionStrings;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
||||
defaultValue = defaultValue || null;
|
||||
|
||||
var action = (options.action || defaultValue);
|
||||
delete options.action;
|
||||
|
||||
var actionClass = this._registryGet('action', action, action);
|
||||
return actionClass;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getHandler = function () {
|
||||
var handlerString = this.conflictHandler;
|
||||
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
||||
var func = this[handlerFuncName];
|
||||
if (typeof func === 'undefined') {
|
||||
var msg = 'invalid conflict resolution value: ' + handlerString;
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
return func;
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._checkConflict = function (action) {
|
||||
var optionStringActions = this._optionStringActions;
|
||||
var conflictOptionals = [];
|
||||
|
||||
// find all options that conflict with this option
|
||||
// collect pairs, the string, and an existing action that it conflicts with
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
var conflOptional = optionStringActions[optionString];
|
||||
if (typeof conflOptional !== 'undefined') {
|
||||
conflictOptionals.push([ optionString, conflOptional ]);
|
||||
}
|
||||
});
|
||||
|
||||
if (conflictOptionals.length > 0) {
|
||||
var conflictHandler = this._getHandler();
|
||||
conflictHandler.call(this, action, conflictOptionals);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
||||
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
||||
conflicts = conflicts.join(', ');
|
||||
throw argumentErrorHelper(
|
||||
action,
|
||||
format('Conflicting option string(s): %s', conflicts)
|
||||
);
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
||||
// remove all conflicting options
|
||||
var self = this;
|
||||
conflOptionals.forEach(function (pair) {
|
||||
var optionString = pair[0];
|
||||
var conflictingAction = pair[1];
|
||||
// remove the conflicting option string
|
||||
var i = conflictingAction.optionStrings.indexOf(optionString);
|
||||
if (i >= 0) {
|
||||
conflictingAction.optionStrings.splice(i, 1);
|
||||
}
|
||||
delete self._optionStringActions[optionString];
|
||||
// if the option now has no option string, remove it from the
|
||||
// container holding it
|
||||
if (conflictingAction.optionStrings.length === 0) {
|
||||
conflictingAction.container._removeAction(conflictingAction);
|
||||
}
|
||||
});
|
||||
};
|
14
node_modules/argparse/lib/argparse.js
generated
vendored
14
node_modules/argparse/lib/argparse.js
generated
vendored
@ -1,14 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.ArgumentParser = require('./argument_parser.js');
|
||||
module.exports.Namespace = require('./namespace');
|
||||
module.exports.Action = require('./action');
|
||||
module.exports.HelpFormatter = require('./help/formatter.js');
|
||||
module.exports.Const = require('./const.js');
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter =
|
||||
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
|
||||
module.exports.RawDescriptionHelpFormatter =
|
||||
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
|
||||
module.exports.RawTextHelpFormatter =
|
||||
require('./help/added_formatters.js').RawTextHelpFormatter;
|
50
node_modules/argparse/lib/argument/error.js
generated
vendored
50
node_modules/argparse/lib/argument/error.js
generated
vendored
@ -1,50 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var ERR_CODE = 'ARGError';
|
||||
|
||||
/*:nodoc:*
|
||||
* argumentError(argument, message) -> TypeError
|
||||
* - argument (Object): action with broken argument
|
||||
* - message (String): error message
|
||||
*
|
||||
* Error format helper. An error from creating or using an argument
|
||||
* (optional or positional). The string value of this exception
|
||||
* is the message, augmented with information
|
||||
* about the argument that caused it.
|
||||
*
|
||||
* #####Example
|
||||
*
|
||||
* var argumentErrorHelper = require('./argument/error');
|
||||
* if (conflictOptionals.length > 0) {
|
||||
* throw argumentErrorHelper(
|
||||
* action,
|
||||
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
|
||||
* );
|
||||
* }
|
||||
*
|
||||
**/
|
||||
module.exports = function (argument, message) {
|
||||
var argumentName = null;
|
||||
var errMessage;
|
||||
var err;
|
||||
|
||||
if (argument.getName) {
|
||||
argumentName = argument.getName();
|
||||
} else {
|
||||
argumentName = '' + argument;
|
||||
}
|
||||
|
||||
if (!argumentName) {
|
||||
errMessage = message;
|
||||
} else {
|
||||
errMessage = format('argument "%s": %s', argumentName, message);
|
||||
}
|
||||
|
||||
err = new TypeError(errMessage);
|
||||
err.code = ERR_CODE;
|
||||
return err;
|
||||
};
|
54
node_modules/argparse/lib/argument/exclusive.js
generated
vendored
54
node_modules/argparse/lib/argument/exclusive.js
generated
vendored
@ -1,54 +0,0 @@
|
||||
/** internal
|
||||
* class MutuallyExclusiveGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ArgumentGroup = require('./group');
|
||||
|
||||
/**
|
||||
* new MutuallyExclusiveGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): options.required -> true/false
|
||||
*
|
||||
* `required` could be an argument itself, but making it a property of
|
||||
* the options argument is more consistent with the JS adaptation of the Python)
|
||||
**/
|
||||
var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
|
||||
var required;
|
||||
options = options || {};
|
||||
required = options.required || false;
|
||||
ArgumentGroup.call(this, container);
|
||||
this.required = required;
|
||||
|
||||
};
|
||||
util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._addAction = function (action) {
|
||||
var msg;
|
||||
if (action.required) {
|
||||
msg = 'mutually exclusive arguments must be optional';
|
||||
throw new Error(msg);
|
||||
}
|
||||
action = this._container._addAction(action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._removeAction = function (action) {
|
||||
this._container._removeAction(action);
|
||||
this._groupActions.remove(action);
|
||||
};
|
||||
|
75
node_modules/argparse/lib/argument/group.js
generated
vendored
75
node_modules/argparse/lib/argument/group.js
generated
vendored
@ -1,75 +0,0 @@
|
||||
/** internal
|
||||
* class ArgumentGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionContainer = require('../action_container');
|
||||
|
||||
|
||||
/**
|
||||
* new ArgumentGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): hash of group options
|
||||
*
|
||||
* #### options
|
||||
* - **prefixChars** group name prefix
|
||||
* - **argumentDefault** default argument value
|
||||
* - **title** group title
|
||||
* - **description** group description
|
||||
*
|
||||
**/
|
||||
var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// add any missing keyword arguments by checking the container
|
||||
options.conflictHandler = (options.conflictHandler || container.conflictHandler);
|
||||
options.prefixChars = (options.prefixChars || container.prefixChars);
|
||||
options.argumentDefault = (options.argumentDefault || container.argumentDefault);
|
||||
|
||||
ActionContainer.call(this, options);
|
||||
|
||||
// group attributes
|
||||
this.title = options.title;
|
||||
this._groupActions = [];
|
||||
|
||||
// share most attributes with the container
|
||||
this._container = container;
|
||||
this._registries = container._registries;
|
||||
this._actions = container._actions;
|
||||
this._optionStringActions = container._optionStringActions;
|
||||
this._defaults = container._defaults;
|
||||
this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
|
||||
this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
|
||||
};
|
||||
util.inherits(ArgumentGroup, ActionContainer);
|
||||
|
||||
|
||||
ArgumentGroup.prototype._addAction = function (action) {
|
||||
// Parent add action
|
||||
action = ActionContainer.prototype._addAction.call(this, action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
ArgumentGroup.prototype._removeAction = function (action) {
|
||||
// Parent remove action
|
||||
ActionContainer.prototype._removeAction.call(this, action);
|
||||
var actionIndex = this._groupActions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._groupActions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
1161
node_modules/argparse/lib/argument_parser.js
generated
vendored
1161
node_modules/argparse/lib/argument_parser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
21
node_modules/argparse/lib/const.js
generated
vendored
21
node_modules/argparse/lib/const.js
generated
vendored
@ -1,21 +0,0 @@
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports.EOL = '\n';
|
||||
|
||||
module.exports.SUPPRESS = '==SUPPRESS==';
|
||||
|
||||
module.exports.OPTIONAL = '?';
|
||||
|
||||
module.exports.ZERO_OR_MORE = '*';
|
||||
|
||||
module.exports.ONE_OR_MORE = '+';
|
||||
|
||||
module.exports.PARSER = 'A...';
|
||||
|
||||
module.exports.REMAINDER = '...';
|
||||
|
||||
module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
|
87
node_modules/argparse/lib/help/added_formatters.js
generated
vendored
87
node_modules/argparse/lib/help/added_formatters.js
generated
vendored
@ -1,87 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
var HelpFormatter = require('./formatter.js');
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which adds default values to argument help.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function ArgumentDefaultsHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
|
||||
|
||||
ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
|
||||
var help = action.help;
|
||||
if (action.help.indexOf('%(defaultValue)s') === -1) {
|
||||
if (action.defaultValue !== c.SUPPRESS) {
|
||||
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
|
||||
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
|
||||
help += ' (default: %(defaultValue)s)';
|
||||
}
|
||||
}
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains any formatting in descriptions.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawDescriptionHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
|
||||
|
||||
RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = text.split('\n');
|
||||
lines = lines.map(function (line) {
|
||||
return $$.trimEnd(indent + line);
|
||||
});
|
||||
return lines.join('\n');
|
||||
};
|
||||
module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawTextHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains formatting of all help text.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawTextHelpFormatter(options) {
|
||||
RawDescriptionHelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
|
||||
|
||||
RawTextHelpFormatter.prototype._splitLines = function (text) {
|
||||
return text.split('\n');
|
||||
};
|
||||
|
||||
module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
|
795
node_modules/argparse/lib/help/formatter.js
generated
vendored
795
node_modules/argparse/lib/help/formatter.js
generated
vendored
@ -1,795 +0,0 @@
|
||||
/**
|
||||
* class HelpFormatter
|
||||
*
|
||||
* Formatter for generating usage messages and argument help strings. Only the
|
||||
* name of this class is considered a public API. All the methods provided by
|
||||
* the class are considered an implementation detail.
|
||||
*
|
||||
* Do not call in your code, use this class only for inherits your own forvatter
|
||||
*
|
||||
* ToDo add [additonal formatters][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#formatter-class
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
|
||||
|
||||
/*:nodoc:* internal
|
||||
* new Support(parent, heding)
|
||||
* - parent (object): parent section
|
||||
* - heading (string): header string
|
||||
*
|
||||
**/
|
||||
function Section(parent, heading) {
|
||||
this._parent = parent;
|
||||
this._heading = heading;
|
||||
this._items = [];
|
||||
}
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#addItem(callback) -> Void
|
||||
* - callback (array): tuple with function and args
|
||||
*
|
||||
* Add function for single element
|
||||
**/
|
||||
Section.prototype.addItem = function (callback) {
|
||||
this._items.push(callback);
|
||||
};
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#formatHelp(formatter) -> string
|
||||
* - formatter (HelpFormatter): current formatter
|
||||
*
|
||||
* Form help section string
|
||||
*
|
||||
**/
|
||||
Section.prototype.formatHelp = function (formatter) {
|
||||
var itemHelp, heading;
|
||||
|
||||
// format the indented section
|
||||
if (this._parent) {
|
||||
formatter._indent();
|
||||
}
|
||||
|
||||
itemHelp = this._items.map(function (item) {
|
||||
var obj, func, args;
|
||||
|
||||
obj = formatter;
|
||||
func = item[0];
|
||||
args = item[1];
|
||||
return func.apply(obj, args);
|
||||
});
|
||||
itemHelp = formatter._joinParts(itemHelp);
|
||||
|
||||
if (this._parent) {
|
||||
formatter._dedent();
|
||||
}
|
||||
|
||||
// return nothing if the section was empty
|
||||
if (!itemHelp) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// add the heading if the section was non-empty
|
||||
heading = '';
|
||||
if (this._heading && this._heading !== c.SUPPRESS) {
|
||||
var currentIndent = formatter.currentIndent;
|
||||
heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;
|
||||
}
|
||||
|
||||
// join the section-initialize newline, the heading and the help
|
||||
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
|
||||
};
|
||||
|
||||
/**
|
||||
* new HelpFormatter(options)
|
||||
*
|
||||
* #### Options:
|
||||
* - `prog`: program name
|
||||
* - `indentIncriment`: indent step, default value 2
|
||||
* - `maxHelpPosition`: max help position, default value = 24
|
||||
* - `width`: line width
|
||||
*
|
||||
**/
|
||||
var HelpFormatter = module.exports = function HelpFormatter(options) {
|
||||
options = options || {};
|
||||
|
||||
this._prog = options.prog;
|
||||
|
||||
this._maxHelpPosition = options.maxHelpPosition || 24;
|
||||
this._width = (options.width || ((process.env.COLUMNS || 80) - 2));
|
||||
|
||||
this._currentIndent = 0;
|
||||
this._indentIncriment = options.indentIncriment || 2;
|
||||
this._level = 0;
|
||||
this._actionMaxLength = 0;
|
||||
|
||||
this._rootSection = new Section(null);
|
||||
this._currentSection = this._rootSection;
|
||||
|
||||
this._whitespaceMatcher = new RegExp('\\s+', 'g');
|
||||
this._longBreakMatcher = new RegExp(c.EOL + c.EOL + c.EOL + '+', 'g');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._indent = function () {
|
||||
this._currentIndent += this._indentIncriment;
|
||||
this._level += 1;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._dedent = function () {
|
||||
this._currentIndent -= this._indentIncriment;
|
||||
this._level -= 1;
|
||||
if (this._currentIndent < 0) {
|
||||
throw new Error('Indent decreased below 0.');
|
||||
}
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._addItem = function (func, args) {
|
||||
this._currentSection.addItem([ func, args ]);
|
||||
};
|
||||
|
||||
//
|
||||
// Message building methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#startSection(heading) -> Void
|
||||
* - heading (string): header string
|
||||
*
|
||||
* Start new help section
|
||||
*
|
||||
* See alse [code example][1]
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.startSection = function (heading) {
|
||||
this._indent();
|
||||
var section = new Section(this._currentSection, heading);
|
||||
var func = section.formatHelp.bind(section);
|
||||
this._addItem(func, [ this ]);
|
||||
this._currentSection = section;
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#endSection -> Void
|
||||
*
|
||||
* End help section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
**/
|
||||
HelpFormatter.prototype.endSection = function () {
|
||||
this._currentSection = this._currentSection._parent;
|
||||
this._dedent();
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addText(text) -> Void
|
||||
* - text (string): plain text
|
||||
*
|
||||
* Add plain text into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addText = function (text) {
|
||||
if (text && text !== c.SUPPRESS) {
|
||||
this._addItem(this._formatText, [ text ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addUsage(usage, actions, groups, prefix) -> Void
|
||||
* - usage (string): usage text
|
||||
* - actions (array): actions list
|
||||
* - groups (array): groups list
|
||||
* - prefix (string): usage prefix
|
||||
*
|
||||
* Add usage data into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addUsage(this.usage, this._actions, []);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {
|
||||
if (usage !== c.SUPPRESS) {
|
||||
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArgument(action) -> Void
|
||||
* - action (object): action
|
||||
*
|
||||
* Add argument into current section
|
||||
*
|
||||
* Single variant of [[HelpFormatter#addArguments]]
|
||||
**/
|
||||
HelpFormatter.prototype.addArgument = function (action) {
|
||||
if (action.help !== c.SUPPRESS) {
|
||||
var self = this;
|
||||
|
||||
// find all invocations
|
||||
var invocations = [ this._formatActionInvocation(action) ];
|
||||
var invocationLength = invocations[0].length;
|
||||
|
||||
var actionLength;
|
||||
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
|
||||
var invocationNew = self._formatActionInvocation(subaction);
|
||||
invocations.push(invocationNew);
|
||||
invocationLength = Math.max(invocationLength, invocationNew.length);
|
||||
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
|
||||
// update the maximum item length
|
||||
actionLength = invocationLength + this._currentIndent;
|
||||
this._actionMaxLength = Math.max(this._actionMaxLength, actionLength);
|
||||
|
||||
// add the item to the list
|
||||
this._addItem(this._formatAction, [ action ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArguments(actions) -> Void
|
||||
* - actions (array): actions list
|
||||
*
|
||||
* Mass add arguments into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addArguments = function (actions) {
|
||||
var self = this;
|
||||
actions.forEach(function (action) {
|
||||
self.addArgument(action);
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// Help-formatting methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#formatHelp -> string
|
||||
*
|
||||
* Format help
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addText(this.epilog);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.formatHelp = function () {
|
||||
var help = this._rootSection.formatHelp(this);
|
||||
if (help) {
|
||||
help = help.replace(this._longBreakMatcher, c.EOL + c.EOL);
|
||||
help = $$.trimChars(help, c.EOL) + c.EOL;
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._joinParts = function (partStrings) {
|
||||
return partStrings.filter(function (part) {
|
||||
return (part && part !== c.SUPPRESS);
|
||||
}).join('');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatUsage = function (usage, actions, groups, prefix) {
|
||||
if (!prefix && typeof prefix !== 'string') {
|
||||
prefix = 'usage: ';
|
||||
}
|
||||
|
||||
actions = actions || [];
|
||||
groups = groups || [];
|
||||
|
||||
|
||||
// if usage is specified, use that
|
||||
if (usage) {
|
||||
usage = sprintf(usage, { prog: this._prog });
|
||||
|
||||
// if no optionals or positionals are available, usage is just prog
|
||||
} else if (!usage && actions.length === 0) {
|
||||
usage = this._prog;
|
||||
|
||||
// if optionals and positionals are available, calculate usage
|
||||
} else if (!usage) {
|
||||
var prog = this._prog;
|
||||
var optionals = [];
|
||||
var positionals = [];
|
||||
var actionUsage;
|
||||
var textWidth;
|
||||
|
||||
// split optionals from positionals
|
||||
actions.forEach(function (action) {
|
||||
if (action.isOptional()) {
|
||||
optionals.push(action);
|
||||
} else {
|
||||
positionals.push(action);
|
||||
}
|
||||
});
|
||||
|
||||
// build full usage string
|
||||
actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
|
||||
usage = [ prog, actionUsage ].join(' ');
|
||||
|
||||
// wrap the usage parts if it's too long
|
||||
textWidth = this._width - this._currentIndent;
|
||||
if ((prefix.length + usage.length) > textWidth) {
|
||||
|
||||
// break usage into wrappable parts
|
||||
var regexpPart = new RegExp('\\(.*?\\)+|\\[.*?\\]+|\\S+', 'g');
|
||||
var optionalUsage = this._formatActionsUsage(optionals, groups);
|
||||
var positionalUsage = this._formatActionsUsage(positionals, groups);
|
||||
|
||||
|
||||
var optionalParts = optionalUsage.match(regexpPart);
|
||||
var positionalParts = positionalUsage.match(regexpPart) || [];
|
||||
|
||||
if (optionalParts.join(' ') !== optionalUsage) {
|
||||
throw new Error('assert "optionalParts.join(\' \') === optionalUsage"');
|
||||
}
|
||||
if (positionalParts.join(' ') !== positionalUsage) {
|
||||
throw new Error('assert "positionalParts.join(\' \') === positionalUsage"');
|
||||
}
|
||||
|
||||
// helper for wrapping lines
|
||||
/*eslint-disable func-style*/ // node 0.10 compat
|
||||
var _getLines = function (parts, indent, prefix) {
|
||||
var lines = [];
|
||||
var line = [];
|
||||
|
||||
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;
|
||||
|
||||
parts.forEach(function (part) {
|
||||
if (lineLength + 1 + part.length > textWidth) {
|
||||
lines.push(indent + line.join(' '));
|
||||
line = [];
|
||||
lineLength = indent.length - 1;
|
||||
}
|
||||
line.push(part);
|
||||
lineLength += part.length + 1;
|
||||
});
|
||||
|
||||
if (line) {
|
||||
lines.push(indent + line.join(' '));
|
||||
}
|
||||
if (prefix) {
|
||||
lines[0] = lines[0].substr(indent.length);
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
|
||||
var lines, indent, parts;
|
||||
// if prog is short, follow it with optionals or positionals
|
||||
if (prefix.length + prog.length <= 0.75 * textWidth) {
|
||||
indent = $$.repeat(' ', (prefix.length + prog.length + 1));
|
||||
if (optionalParts) {
|
||||
lines = [].concat(
|
||||
_getLines([ prog ].concat(optionalParts), indent, prefix),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
} else if (positionalParts) {
|
||||
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
|
||||
} else {
|
||||
lines = [ prog ];
|
||||
}
|
||||
|
||||
// if prog is long, put it on its own line
|
||||
} else {
|
||||
indent = $$.repeat(' ', prefix.length);
|
||||
parts = optionalParts.concat(positionalParts);
|
||||
lines = _getLines(parts, indent);
|
||||
if (lines.length > 1) {
|
||||
lines = [].concat(
|
||||
_getLines(optionalParts, indent),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
}
|
||||
lines = [ prog ].concat(lines);
|
||||
}
|
||||
// join lines into usage
|
||||
usage = lines.join(c.EOL);
|
||||
}
|
||||
}
|
||||
|
||||
// prefix with 'usage:'
|
||||
return prefix + usage + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionsUsage = function (actions, groups) {
|
||||
// find group indices and identify actions in groups
|
||||
var groupActions = [];
|
||||
var inserts = [];
|
||||
var self = this;
|
||||
|
||||
groups.forEach(function (group) {
|
||||
var end;
|
||||
var i;
|
||||
|
||||
var start = actions.indexOf(group._groupActions[0]);
|
||||
if (start >= 0) {
|
||||
end = start + group._groupActions.length;
|
||||
|
||||
//if (actions.slice(start, end) === group._groupActions) {
|
||||
if ($$.arrayEqual(actions.slice(start, end), group._groupActions)) {
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupActions.push(action);
|
||||
});
|
||||
|
||||
if (!group.required) {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' [';
|
||||
} else {
|
||||
inserts[start] = '[';
|
||||
}
|
||||
inserts[end] = ']';
|
||||
} else {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' (';
|
||||
} else {
|
||||
inserts[start] = '(';
|
||||
}
|
||||
inserts[end] = ')';
|
||||
}
|
||||
for (i = start + 1; i < end; i += 1) {
|
||||
inserts[i] = '|';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// collect all actions format strings
|
||||
var parts = [];
|
||||
|
||||
actions.forEach(function (action, actionIndex) {
|
||||
var part;
|
||||
var optionString;
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// suppressed arguments are marked with None
|
||||
// remove | separators for suppressed arguments
|
||||
if (action.help === c.SUPPRESS) {
|
||||
parts.push(null);
|
||||
if (inserts[actionIndex] === '|') {
|
||||
inserts.splice(actionIndex, actionIndex);
|
||||
} else if (inserts[actionIndex + 1] === '|') {
|
||||
inserts.splice(actionIndex + 1, actionIndex + 1);
|
||||
}
|
||||
|
||||
// produce all arg strings
|
||||
} else if (!action.isOptional()) {
|
||||
part = self._formatArgs(action, action.dest);
|
||||
|
||||
// if it's in a group, strip the outer []
|
||||
if (groupActions.indexOf(action) >= 0) {
|
||||
if (part[0] === '[' && part[part.length - 1] === ']') {
|
||||
part = part.slice(1, -1);
|
||||
}
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
|
||||
// produce the first way to invoke the option in brackets
|
||||
} else {
|
||||
optionString = action.optionStrings[0];
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s or --long
|
||||
if (action.nargs === 0) {
|
||||
part = '' + optionString;
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS or --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = self._formatArgs(action, argsDefault);
|
||||
part = optionString + ' ' + argsString;
|
||||
}
|
||||
// make it look optional if it's not required or in a group
|
||||
if (!action.required && groupActions.indexOf(action) < 0) {
|
||||
part = '[' + part + ']';
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
}
|
||||
});
|
||||
|
||||
// insert things at the necessary indices
|
||||
for (var i = inserts.length - 1; i >= 0; --i) {
|
||||
if (inserts[i] !== null) {
|
||||
parts.splice(i, 0, inserts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// join all the action items with spaces
|
||||
var text = parts.filter(function (part) {
|
||||
return !!part;
|
||||
}).join(' ');
|
||||
|
||||
// clean up separators for mutually exclusive groups
|
||||
text = text.replace(/([\[(]) /g, '$1'); // remove spaces
|
||||
text = text.replace(/ ([\])])/g, '$1');
|
||||
text = text.replace(/\[ *\]/g, ''); // remove empty groups
|
||||
text = text.replace(/\( *\)/g, '');
|
||||
text = text.replace(/\(([^|]*)\)/g, '$1'); // remove () from single action groups
|
||||
|
||||
text = text.trim();
|
||||
|
||||
// return the text
|
||||
return text;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatText = function (text) {
|
||||
text = sprintf(text, { prog: this._prog });
|
||||
var textWidth = this._width - this._currentIndent;
|
||||
var indentIncriment = $$.repeat(' ', this._currentIndent);
|
||||
return this._fillText(text, textWidth, indentIncriment) + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
var helpText;
|
||||
var helpLines;
|
||||
var parts;
|
||||
var indentFirst;
|
||||
|
||||
// determine the required width and the entry label
|
||||
var helpPosition = Math.min(this._actionMaxLength + 2, this._maxHelpPosition);
|
||||
var helpWidth = this._width - helpPosition;
|
||||
var actionWidth = helpPosition - this._currentIndent - 2;
|
||||
var actionHeader = this._formatActionInvocation(action);
|
||||
|
||||
// no help; start on same line and add a final newline
|
||||
if (!action.help) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
|
||||
// short action name; start on the same line and pad two spaces
|
||||
} else if (actionHeader.length <= actionWidth) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) +
|
||||
actionHeader +
|
||||
' ' +
|
||||
$$.repeat(' ', actionWidth - actionHeader.length);
|
||||
indentFirst = 0;
|
||||
|
||||
// long action name; start on the next line
|
||||
} else {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
indentFirst = helpPosition;
|
||||
}
|
||||
|
||||
// collect the pieces of the action help
|
||||
parts = [ actionHeader ];
|
||||
|
||||
// if there was help for the action, add lines of help text
|
||||
if (action.help) {
|
||||
helpText = this._expandHelp(action);
|
||||
helpLines = this._splitLines(helpText, helpWidth);
|
||||
parts.push($$.repeat(' ', indentFirst) + helpLines[0] + c.EOL);
|
||||
helpLines.slice(1).forEach(function (line) {
|
||||
parts.push($$.repeat(' ', helpPosition) + line + c.EOL);
|
||||
});
|
||||
|
||||
// or add a newline if the description doesn't end with one
|
||||
} else if (actionHeader.charAt(actionHeader.length - 1) !== c.EOL) {
|
||||
parts.push(c.EOL);
|
||||
}
|
||||
// if there are any sub-actions, add their help as well
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
parts.push(self._formatAction(subaction));
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
// return a single string
|
||||
return this._joinParts(parts);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionInvocation = function (action) {
|
||||
if (!action.isOptional()) {
|
||||
var format_func = this._metavarFormatter(action, action.dest);
|
||||
var metavars = format_func(1);
|
||||
return metavars[0];
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s, --long
|
||||
if (action.nargs === 0) {
|
||||
parts = parts.concat(action.optionStrings);
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS, --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = this._formatArgs(action, argsDefault);
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
parts.push(optionString + ' ' + argsString);
|
||||
});
|
||||
}
|
||||
return parts.join(', ');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._metavarFormatter = function (action, metavarDefault) {
|
||||
var result;
|
||||
|
||||
if (action.metavar || action.metavar === '') {
|
||||
result = action.metavar;
|
||||
} else if (action.choices) {
|
||||
var choices = action.choices;
|
||||
|
||||
if (typeof choices === 'string') {
|
||||
choices = choices.split('').join(', ');
|
||||
} else if (Array.isArray(choices)) {
|
||||
choices = choices.join(',');
|
||||
} else {
|
||||
choices = Object.keys(choices).join(',');
|
||||
}
|
||||
result = '{' + choices + '}';
|
||||
} else {
|
||||
result = metavarDefault;
|
||||
}
|
||||
|
||||
return function (size) {
|
||||
if (Array.isArray(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var metavars = [];
|
||||
for (var i = 0; i < size; i += 1) {
|
||||
metavars.push(result);
|
||||
}
|
||||
return metavars;
|
||||
};
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatArgs = function (action, metavarDefault) {
|
||||
var result;
|
||||
var metavars;
|
||||
|
||||
var buildMetavar = this._metavarFormatter(action, metavarDefault);
|
||||
|
||||
switch (action.nargs) {
|
||||
/*eslint-disable no-undefined*/
|
||||
case undefined:
|
||||
case null:
|
||||
metavars = buildMetavar(1);
|
||||
result = '' + metavars[0];
|
||||
break;
|
||||
case c.OPTIONAL:
|
||||
metavars = buildMetavar(1);
|
||||
result = '[' + metavars[0] + ']';
|
||||
break;
|
||||
case c.ZERO_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '[' + metavars[0] + ' [' + metavars[1] + ' ...]]';
|
||||
break;
|
||||
case c.ONE_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '' + metavars[0] + ' [' + metavars[1] + ' ...]';
|
||||
break;
|
||||
case c.REMAINDER:
|
||||
result = '...';
|
||||
break;
|
||||
case c.PARSER:
|
||||
metavars = buildMetavar(1);
|
||||
result = metavars[0] + ' ...';
|
||||
break;
|
||||
default:
|
||||
metavars = buildMetavar(action.nargs);
|
||||
result = metavars.join(' ');
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._expandHelp = function (action) {
|
||||
var params = { prog: this._prog };
|
||||
|
||||
Object.keys(action).forEach(function (actionProperty) {
|
||||
var actionValue = action[actionProperty];
|
||||
|
||||
if (actionValue !== c.SUPPRESS) {
|
||||
params[actionProperty] = actionValue;
|
||||
}
|
||||
});
|
||||
|
||||
if (params.choices) {
|
||||
if (typeof params.choices === 'string') {
|
||||
params.choices = params.choices.split('').join(', ');
|
||||
} else if (Array.isArray(params.choices)) {
|
||||
params.choices = params.choices.join(', ');
|
||||
} else {
|
||||
params.choices = Object.keys(params.choices).join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(this._getHelpString(action), params);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._splitLines = function (text, width) {
|
||||
var lines = [];
|
||||
var delimiters = [ ' ', '.', ',', '!', '?' ];
|
||||
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
|
||||
|
||||
text = text.replace(/[\n\|\t]/g, ' ');
|
||||
|
||||
text = text.trim();
|
||||
text = text.replace(this._whitespaceMatcher, ' ');
|
||||
|
||||
// Wraps the single paragraph in text (a string) so every line
|
||||
// is at most width characters long.
|
||||
text.split(c.EOL).forEach(function (line) {
|
||||
if (width >= line.length) {
|
||||
lines.push(line);
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapStart = 0;
|
||||
var wrapEnd = width;
|
||||
var delimiterIndex = 0;
|
||||
while (wrapEnd <= line.length) {
|
||||
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
|
||||
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
|
||||
wrapEnd = wrapStart + delimiterIndex + 1;
|
||||
}
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
wrapStart = wrapEnd;
|
||||
wrapEnd += width;
|
||||
}
|
||||
if (wrapStart < line.length) {
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
}
|
||||
});
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = this._splitLines(text, width);
|
||||
lines = lines.map(function (line) {
|
||||
return indent + line;
|
||||
});
|
||||
return lines.join(c.EOL);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._getHelpString = function (action) {
|
||||
return action.help;
|
||||
};
|
76
node_modules/argparse/lib/namespace.js
generated
vendored
76
node_modules/argparse/lib/namespace.js
generated
vendored
@ -1,76 +0,0 @@
|
||||
/**
|
||||
* class Namespace
|
||||
*
|
||||
* Simple object for storing attributes. Implements equality by attribute names
|
||||
* and values, and provides a simple string representation.
|
||||
*
|
||||
* See also [original guide][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
/**
|
||||
* new Namespace(options)
|
||||
* - options(object): predefined propertis for result object
|
||||
*
|
||||
**/
|
||||
var Namespace = module.exports = function Namespace(options) {
|
||||
$$.extend(this, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#isset(key) -> Boolean
|
||||
* - key (string|number): property name
|
||||
*
|
||||
* Tells whenever `namespace` contains given `key` or not.
|
||||
**/
|
||||
Namespace.prototype.isset = function (key) {
|
||||
return $$.has(this, key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#set(key, value) -> self
|
||||
* -key (string|number|object): propery name
|
||||
* -value (mixed): new property value
|
||||
*
|
||||
* Set the property named key with value.
|
||||
* If key object then set all key properties to namespace object
|
||||
**/
|
||||
Namespace.prototype.set = function (key, value) {
|
||||
if (typeof (key) === 'object') {
|
||||
$$.extend(this, key);
|
||||
} else {
|
||||
this[key] = value;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#get(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return the property key or defaulValue if not set
|
||||
**/
|
||||
Namespace.prototype.get = function (key, defaultValue) {
|
||||
return !this[key] ? defaultValue : this[key];
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#unset(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return data[key](and delete it) or defaultValue
|
||||
**/
|
||||
Namespace.prototype.unset = function (key, defaultValue) {
|
||||
var value = this[key];
|
||||
if (value !== null) {
|
||||
delete this[key];
|
||||
return value;
|
||||
}
|
||||
return defaultValue;
|
||||
};
|
57
node_modules/argparse/lib/utils.js
generated
vendored
57
node_modules/argparse/lib/utils.js
generated
vendored
@ -1,57 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
exports.repeat = function (str, num) {
|
||||
var result = '';
|
||||
for (var i = 0; i < num; i++) { result += str; }
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.arrayEqual = function (a, b) {
|
||||
if (a.length !== b.length) { return false; }
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) { return false; }
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.trimChars = function (str, chars) {
|
||||
var start = 0;
|
||||
var end = str.length - 1;
|
||||
while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
|
||||
while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
|
||||
return str.slice(start, end + 1);
|
||||
};
|
||||
|
||||
exports.capitalize = function (str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
exports.arrayUnion = function () {
|
||||
var result = [];
|
||||
for (var i = 0, values = {}; i < arguments.length; i++) {
|
||||
var arr = arguments[i];
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
if (!values[arr[j]]) {
|
||||
values[arr[j]] = true;
|
||||
result.push(arr[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function has(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
exports.has = has;
|
||||
|
||||
exports.extend = function (dest, src) {
|
||||
for (var i in src) {
|
||||
if (has(src, i)) { dest[i] = src[i]; }
|
||||
}
|
||||
};
|
||||
|
||||
exports.trimEnd = function (str) {
|
||||
return str.replace(/\s+$/g, '');
|
||||
};
|
73
node_modules/argparse/package.json
generated
vendored
73
node_modules/argparse/package.json
generated
vendored
@ -1,73 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"argparse@1.0.10",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "argparse@1.0.10",
|
||||
"_id": "argparse@1.0.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"_location": "/argparse",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "argparse@1.0.10",
|
||||
"name": "argparse",
|
||||
"escapedName": "argparse",
|
||||
"rawSpec": "1.0.10",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.10"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/js-yaml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"_spec": "1.0.10",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodeca/argparse/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Eugene Shkuropat"
|
||||
},
|
||||
{
|
||||
"name": "Paul Jacobson"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
},
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/argparse#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
"argparse",
|
||||
"option",
|
||||
"args"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "argparse",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nodeca/argparse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.10"
|
||||
}
|
10
node_modules/argv/.nodelint.json
generated
vendored
10
node_modules/argv/.nodelint.json
generated
vendored
@ -1,10 +0,0 @@
|
||||
{
|
||||
"ignore": [
|
||||
"node_modules/"
|
||||
],
|
||||
"linters": {
|
||||
"jshint": {
|
||||
"boss": true
|
||||
}
|
||||
}
|
||||
}
|
2
node_modules/argv/.npmignore
generated
vendored
2
node_modules/argv/.npmignore
generated
vendored
@ -1,2 +0,0 @@
|
||||
node_modules/
|
||||
build/results/
|
3
node_modules/argv/.travis.yml
generated
vendored
3
node_modules/argv/.travis.yml
generated
vendored
@ -1,3 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
8
node_modules/argv/CHANGELOG.md
generated
vendored
8
node_modules/argv/CHANGELOG.md
generated
vendored
@ -1,8 +0,0 @@
|
||||
## v0.0.2
|
||||
|
||||
* Transfering help and version option after calling clear
|
||||
|
||||
|
||||
## v0.0.1
|
||||
|
||||
Initial Release
|
21
node_modules/argv/LICENSE
generated
vendored
21
node_modules/argv/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2012-2013 Corey Hart
|
||||
|
||||
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.
|
16
node_modules/argv/Makefile
generated
vendored
16
node_modules/argv/Makefile
generated
vendored
@ -1,16 +0,0 @@
|
||||
all: test
|
||||
|
||||
clean:
|
||||
@rm -rf build/results/
|
||||
|
||||
lint:
|
||||
@node build/lint.js
|
||||
|
||||
test: clean lint
|
||||
@node build/test.js
|
||||
|
||||
test-all:
|
||||
@NODE_TEST_NO_SKIP=1 make test
|
||||
|
||||
test-full:
|
||||
@./build/full.sh
|
189
node_modules/argv/README.md
generated
vendored
189
node_modules/argv/README.md
generated
vendored
@ -1,189 +0,0 @@
|
||||
# argv
|
||||
|
||||
argv is a nodejs module that does command line argument parsing.
|
||||
|
||||
[](https://travis-ci.org/codenothing/argv)
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
$ npm install argv
|
||||
```
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
var argv = require( 'argv' );
|
||||
var args = argv.option( options ).run();
|
||||
-> { targets: [], options: {} }
|
||||
```
|
||||
|
||||
|
||||
### Run
|
||||
|
||||
Runs the argument parser on the global arguments. Custom arguments array can be used by passing into this method
|
||||
|
||||
```js
|
||||
// Parses default arguments 'process.argv.slice( 2 )'
|
||||
argv.run();
|
||||
|
||||
// Parses array instead
|
||||
argv.run([ '--option=123', '-o', '123' ]);
|
||||
```
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
argv is a strict argument parser, which means all options must be defined before parsing starts.
|
||||
|
||||
```js
|
||||
argv.option({
|
||||
name: 'option',
|
||||
short: 'o',
|
||||
type: 'string',
|
||||
description: 'Defines an option for your script',
|
||||
example: "'script --opiton=value' or 'script -o value'"
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Modules
|
||||
|
||||
Modules are nested commands for more complicated scripts. Each module has it's own set of options that
|
||||
have to be defined independently of the root options.
|
||||
|
||||
```js
|
||||
argv.mod({
|
||||
mod: 'module',
|
||||
description: 'Description of what the module is used for',
|
||||
options: [ list of options ]
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Types
|
||||
|
||||
Types convert option values to useful js objects. They are defined along with each option.
|
||||
|
||||
* **string**: Ensure values are strings
|
||||
* **path**: Converts value into a fully resolved path.
|
||||
* **int**: Converts value into an integer
|
||||
* **float**: Converts value into a float number
|
||||
* **boolean**: Converts value into a boolean object. 'true' and '1' are converted to true, everything else is false.
|
||||
* **csv**: Converts value into an array by splitting on comma's.
|
||||
* **list**: Allows for option to be defined multiple times, and each value added to an array
|
||||
* **[list|csv],[type]**: Combo type that allows you to create a list or csv and convert each individual value into a type.
|
||||
|
||||
```js
|
||||
argv.option([
|
||||
{
|
||||
name: 'option',
|
||||
type: 'csv,int'
|
||||
},
|
||||
{
|
||||
name: 'path',
|
||||
short: 'p',
|
||||
type: 'list,path'
|
||||
}
|
||||
]);
|
||||
|
||||
// csv and int combo
|
||||
$ script --option=123,456.001,789.01
|
||||
-> option: [ 123, 456, 789 ]
|
||||
|
||||
// list and path combo
|
||||
$ script -p /path/to/file1 -p /path/to/file2
|
||||
-> option: [ '/path/to/file1', '/path/to/file2' ]
|
||||
```
|
||||
|
||||
You can also create your own custom type for special conversions.
|
||||
|
||||
```js
|
||||
argv.type( 'squared', function( value ) {
|
||||
value = parseFloat( value );
|
||||
return value * value;
|
||||
});
|
||||
|
||||
argv.option({
|
||||
name: 'square',
|
||||
short: 's',
|
||||
type: 'squared'
|
||||
});
|
||||
|
||||
$ script -s 2
|
||||
-> 4
|
||||
```
|
||||
|
||||
|
||||
### Version
|
||||
|
||||
Defining the scripts version number will add the version option and print it out when asked.
|
||||
|
||||
```js
|
||||
argv.version( 'v1.0' );
|
||||
|
||||
$ script --version
|
||||
v1.0
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Info
|
||||
|
||||
Custom information can be displayed at the top of the help printout using this method
|
||||
|
||||
```js
|
||||
argv.info( 'Special script info' );
|
||||
|
||||
$ script --help
|
||||
|
||||
Special script info
|
||||
|
||||
... Rest of Help Doc ...
|
||||
```
|
||||
|
||||
|
||||
### Clear
|
||||
|
||||
If you have competing scripts accessing the argv object, you can clear out any previous options that may have been set.
|
||||
|
||||
```js
|
||||
argv.clear().option( [new options] );
|
||||
```
|
||||
|
||||
|
||||
### Help
|
||||
|
||||
argv injects a default help option initially and on clears. The help() method triggers the help printout.
|
||||
|
||||
```js
|
||||
argv.help();
|
||||
```
|
||||
|
||||
----
|
||||
### License
|
||||
|
||||
```
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2012-2013 Corey Hart
|
||||
|
||||
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.
|
||||
```
|
29
node_modules/argv/build/full.sh
generated
vendored
29
node_modules/argv/build/full.sh
generated
vendored
@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd `dirname $0`
|
||||
cd ../
|
||||
SRCROOT=${PWD}
|
||||
|
||||
# Clean out and rebuild before running through each enviorment
|
||||
make clean
|
||||
|
||||
echo "===== NVM DIR::: $NVM_DIR ===="
|
||||
|
||||
# Find each availiable node version and test with that version
|
||||
for i in $( ls $NVM_DIR )
|
||||
do
|
||||
if [[ $i =~ ^v ]]; then
|
||||
echo ""
|
||||
echo ""
|
||||
echo "=== Node $i ==="
|
||||
echo ""
|
||||
|
||||
# Run test suite
|
||||
"$NVM_DIR/$i/bin/node" "$SRCROOT/build/test.js"
|
||||
|
||||
# Any non successful exit should be treated as full error
|
||||
RESULT=$?
|
||||
if [[ $RESULT != 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
1
node_modules/argv/build/lint.js
generated
vendored
1
node_modules/argv/build/lint.js
generated
vendored
@ -1 +0,0 @@
|
||||
require( 'nlint' ).render( __dirname + '/../' );
|
13
node_modules/argv/build/test.js
generated
vendored
13
node_modules/argv/build/test.js
generated
vendored
@ -1,13 +0,0 @@
|
||||
global.munit = require( 'munit' );
|
||||
global.argv = require( '../' );
|
||||
|
||||
// Only stop test suite when running make test
|
||||
if ( ! process.env.NODE_TEST_NO_SKIP ) {
|
||||
munit.defaults.settings.stopOnFail = true;
|
||||
}
|
||||
|
||||
// Render all tests
|
||||
munit.render( __dirname + '/../test/', {
|
||||
junit: __dirname + '/results/',
|
||||
junitPrefix: process.version.replace( /\./g, '_' )
|
||||
});
|
1
node_modules/argv/index.js
generated
vendored
1
node_modules/argv/index.js
generated
vendored
@ -1 +0,0 @@
|
||||
module.exports = require( './lib/argv.js' );
|
465
node_modules/argv/lib/argv.js
generated
vendored
465
node_modules/argv/lib/argv.js
generated
vendored
@ -1,465 +0,0 @@
|
||||
var PATH = require( 'path' ),
|
||||
toString = Object.prototype.toString,
|
||||
rhome = /^\~\//,
|
||||
rroot = /^\//,
|
||||
rlistcsv = /^(list|csv)\,[a-z]+$/,
|
||||
rdash = /^\-/,
|
||||
rddash = /^\-\-/,
|
||||
ristarget = /^[^\-]/,
|
||||
SCRIPT_NAME = ( process.argv[ 1 ] || '' ).split( '/' ).pop(),
|
||||
helpOption = {
|
||||
name: 'help',
|
||||
short: 'h',
|
||||
type: function(){ return true; },
|
||||
description: 'Displays help information about this script',
|
||||
example: "'" + SCRIPT_NAME + " -h' or '" + SCRIPT_NAME + " --help'",
|
||||
onset: function( args ) {
|
||||
self.help( args.mod );
|
||||
process.exit( 0 );
|
||||
}
|
||||
},
|
||||
boolTest = function( value ) {
|
||||
return value == 'true' || value == 'false' || value == '1' || value == '0';
|
||||
},
|
||||
self;
|
||||
|
||||
// argv module
|
||||
module.exports = self = {
|
||||
|
||||
// Default script name
|
||||
name: SCRIPT_NAME,
|
||||
|
||||
// Default description to the triggered script 'node script'
|
||||
description: 'Usage: ' + SCRIPT_NAME + ' [options]',
|
||||
|
||||
// Modules
|
||||
mods: {},
|
||||
|
||||
// Shorthand options
|
||||
short: { h: helpOption },
|
||||
|
||||
// Options
|
||||
options: { help: helpOption },
|
||||
|
||||
// List of common types
|
||||
types: {
|
||||
|
||||
string: function( value ) {
|
||||
return value.toString();
|
||||
},
|
||||
|
||||
path: function( value ) {
|
||||
var end = value[ value.length - 1 ] == '/';
|
||||
|
||||
if ( rhome.exec( value ) ) {
|
||||
value = PATH.normalize( process.env.HOME + '/' + value.replace( rhome, '' ) );
|
||||
}
|
||||
else if ( ! rroot.exec( value ) ) {
|
||||
value = PATH.normalize( process.cwd() + '/' + value );
|
||||
}
|
||||
|
||||
return value + ( end && value[ value.length - 1 ] != '/' ? '/' : '' );
|
||||
},
|
||||
|
||||
'int': function( value ) {
|
||||
return parseInt( value, 10 );
|
||||
},
|
||||
|
||||
'float': function( value ) {
|
||||
return parseFloat( value, 10 );
|
||||
},
|
||||
|
||||
'boolean': function( value ) {
|
||||
return ( value == 'true' || value === '1' );
|
||||
},
|
||||
|
||||
list: function( value, name, options ) {
|
||||
if ( ! options[ name ] ) {
|
||||
options[ name ] = [];
|
||||
}
|
||||
|
||||
options[ name ].push( value );
|
||||
return options[ name ];
|
||||
},
|
||||
|
||||
csv: function( value ) {
|
||||
return value.split( ',' );
|
||||
},
|
||||
|
||||
'listcsv-combo': function( type ) {
|
||||
var parts = type.split( ',' ),
|
||||
primary = parts.shift(),
|
||||
secondary = parts.shift();
|
||||
|
||||
return function( value, name, options, args ) {
|
||||
// Entry is going to be an array
|
||||
if ( ! options[ name ] ) {
|
||||
options[ name ] = [];
|
||||
}
|
||||
|
||||
// Channel to csv or list
|
||||
if ( primary == 'csv' ) {
|
||||
value.split( ',' ).forEach(function( val ) {
|
||||
options[ name ].push( self.types[ secondary ]( val, name, options, args ) );
|
||||
});
|
||||
}
|
||||
else {
|
||||
options[ name ].push( self.types[ secondary ]( value, name, options, args ) );
|
||||
}
|
||||
|
||||
return options[ name ];
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// Creates custom type function
|
||||
type: function( name, callback ) {
|
||||
if ( self.isObject( name ) ) {
|
||||
for ( var i in name ) {
|
||||
if ( self.isFunction( name[ i ] ) ) {
|
||||
self.types[ i ] = name[ i ];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( callback === undefined ) {
|
||||
return self.types[ name ];
|
||||
}
|
||||
else if ( self.isFunction( callback ) ) {
|
||||
self.types[ name ] = callback;
|
||||
}
|
||||
else if ( callback === null && self.types.hasOwnProperty( name ) ) {
|
||||
delete self.types[ name ];
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Setting version number, and auto setting version option
|
||||
version: function( v ) {
|
||||
self.option({
|
||||
_version: v,
|
||||
name: 'version',
|
||||
type: function(){ return true; },
|
||||
description: 'Displays version info',
|
||||
example: self.name + " --version",
|
||||
onset: function( args ) {
|
||||
console.log( v + "\n" );
|
||||
process.exit( 0 );
|
||||
}
|
||||
});
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Adding options to definitions list
|
||||
option: function( mod, object ) {
|
||||
if ( object === undefined ) {
|
||||
object = mod;
|
||||
mod = undefined;
|
||||
}
|
||||
|
||||
// Iterate over array for multi entry
|
||||
if ( self.isArray( object ) ) {
|
||||
object.forEach(function( entry ) {
|
||||
self.option( mod, entry );
|
||||
});
|
||||
}
|
||||
// Handle edge case
|
||||
else if ( ! self.isObject( object ) ) {
|
||||
throw new Error( 'No option definition provided' + ( mod ? ' for module ' + mod : '' ) );
|
||||
}
|
||||
// Handle module definition
|
||||
else if ( object.mod ) {
|
||||
self.mod( object );
|
||||
}
|
||||
// Correct the object
|
||||
else {
|
||||
if ( ! object.name ) {
|
||||
throw new Error( 'No name provided for option' );
|
||||
}
|
||||
else if ( ! object.type ) {
|
||||
throw new Error( 'No type proveded for option' );
|
||||
}
|
||||
|
||||
// Attach tester for value on booleans
|
||||
// to avoid false targets
|
||||
object.test = object.test || ( object.type == 'boolean' ? boolTest : null );
|
||||
object.description = object.description || '';
|
||||
object.type = self.isFunction( object.type ) ? object.type :
|
||||
self.isString( object.type ) && rlistcsv.exec( object.type ) ? self.types[ 'listcsv-combo' ]( object.type ) :
|
||||
self.isString( object.type ) && self.types[ object.type ] ? self.types[ object.type ] :
|
||||
self.types.string;
|
||||
|
||||
// Apply to module
|
||||
if ( mod ) {
|
||||
if ( ! self.mods[ mod ] ) {
|
||||
self.mods[ mod ] = { mod: mod, options: {}, short: {} };
|
||||
}
|
||||
|
||||
// Attach option to submodule
|
||||
mod = self.mods[ mod ];
|
||||
mod.options[ object.name ] = object;
|
||||
|
||||
// Attach shorthand
|
||||
if ( object.short ) {
|
||||
mod.short[ object.short ] = object;
|
||||
}
|
||||
}
|
||||
// Apply to root options
|
||||
else {
|
||||
self.options[ object.name ] = object;
|
||||
|
||||
// Attach shorthand option
|
||||
if ( object.short ) {
|
||||
self.short[ object.short ] = object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Creating module
|
||||
mod: function( object ) {
|
||||
var mod;
|
||||
|
||||
// Allow multi mod setup
|
||||
if ( self.isArray( object ) ) {
|
||||
object.forEach(function( value ) {
|
||||
self.mod( value );
|
||||
});
|
||||
}
|
||||
// Handle edge case
|
||||
else if ( ! self.isObject( object ) ) {
|
||||
throw new Error( 'No mod definition provided' );
|
||||
}
|
||||
// Force mod name
|
||||
else if ( ! object.mod ) {
|
||||
throw new Error( "Expecting 'mod' entry for module" );
|
||||
}
|
||||
// Create object if not already done so
|
||||
else if ( ! self.mods[ object.mod ] ) {
|
||||
self.mods[ object.mod ] = { mod: object.mod, options: {}, short: {} };
|
||||
}
|
||||
|
||||
// Setup
|
||||
mod = self.mods[ object.mod ];
|
||||
mod.description = object.description || mod.description;
|
||||
|
||||
// Attach each option
|
||||
self.option( mod.mod, object.options );
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Cleans out current options
|
||||
clear: function(){
|
||||
var version = self.options.version;
|
||||
|
||||
// Clean out modes and reapply help option
|
||||
self.short = {};
|
||||
self.options = {};
|
||||
self.mods = {};
|
||||
self.option( helpOption );
|
||||
|
||||
// Re-apply version if set
|
||||
if ( version ) {
|
||||
self.option( version );
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Description setup
|
||||
info: function( mod, description ) {
|
||||
if ( description === undefined ) {
|
||||
self.description = mod;
|
||||
}
|
||||
else if ( self.mods[ mod ] ) {
|
||||
self.mods[ mod ] = description;
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
// Prints out the help doc
|
||||
help: function( mod ) {
|
||||
var output = [], name, option;
|
||||
|
||||
// Printing out just a module's definitions
|
||||
if ( mod && ( mod = self.mods[ mod ] ) ) {
|
||||
output = [ '', mod.description, '' ];
|
||||
|
||||
for ( name in mod.options ) {
|
||||
option = mod.options[ name ];
|
||||
|
||||
output.push( "\t--" +option.name + ( option.short ? ', -' + option.short : '' ) );
|
||||
output.push( "\t\t" + option.description );
|
||||
if ( option.example ) {
|
||||
output.push( "\t\t" + option.example );
|
||||
}
|
||||
|
||||
// Spacing
|
||||
output.push( "" );
|
||||
}
|
||||
}
|
||||
// Printing out just the root options
|
||||
else {
|
||||
output = [ '', self.description, '' ];
|
||||
|
||||
for ( name in self.options ) {
|
||||
option = self.options[ name ];
|
||||
|
||||
output.push( "\t--" +option.name + ( option.short ? ', -' + option.short : '' ) );
|
||||
output.push( "\t\t" + option.description );
|
||||
if ( option.example ) {
|
||||
output.push( "\t\t" + option.example );
|
||||
}
|
||||
|
||||
// Spacing
|
||||
output.push( "" );
|
||||
}
|
||||
}
|
||||
|
||||
// Print out the output
|
||||
console.log( output.join( "\n" ) + "\n\n" );
|
||||
return self;
|
||||
},
|
||||
|
||||
// Runs the arguments parser
|
||||
_run: function( argv ) {
|
||||
var args = { targets: [], options: {} },
|
||||
opts = self.options,
|
||||
shortOpts = self.short,
|
||||
skip = false;
|
||||
|
||||
// Allow for passing of arguments list
|
||||
argv = self.isArray( argv ) ? argv : process.argv.slice( 2 );
|
||||
|
||||
// Switch to module's options when used
|
||||
if ( argv.length && ristarget.exec( argv[ 0 ] ) && self.mods[ argv[ 0 ] ] ) {
|
||||
args.mod = argv.shift();
|
||||
opts = self.mods[ args.mod ].options;
|
||||
shortOpts = self.mods[ args.mod ].short;
|
||||
}
|
||||
|
||||
// Iterate over arguments
|
||||
argv.forEach(function( arg, i ) {
|
||||
var peek = argv[ i + 1 ], option, index, value;
|
||||
|
||||
// Allow skipping of arguments
|
||||
if ( skip ) {
|
||||
return ( skip = false );
|
||||
}
|
||||
// Full option '--option'
|
||||
else if ( rddash.exec( arg ) ) {
|
||||
arg = arg.replace( rddash, '' );
|
||||
|
||||
// Default no value to true
|
||||
if ( ( index = arg.indexOf( '=' ) ) !== -1 ) {
|
||||
value = arg.substr( index + 1 );
|
||||
arg = arg.substr( 0, index );
|
||||
}
|
||||
else {
|
||||
value = 'true';
|
||||
}
|
||||
|
||||
// Be strict, if option doesn't exist, throw and error
|
||||
if ( ! ( option = opts[ arg ] ) ) {
|
||||
throw "Option '--" + arg + "' not supported";
|
||||
}
|
||||
|
||||
// Send through type converter
|
||||
args.options[ arg ] = option.type( value, arg, args.options, args );
|
||||
|
||||
// Trigger onset callback when option is set
|
||||
if ( self.isFunction( option.onset ) ) {
|
||||
option.onset( args );
|
||||
}
|
||||
}
|
||||
// Shorthand option '-o'
|
||||
else if ( rdash.exec( arg ) ) {
|
||||
arg = arg.replace( rdash, '' );
|
||||
|
||||
if ( arg.length > 1 ) {
|
||||
arg.split( '' ).forEach(function( character ) {
|
||||
if ( ! ( option = shortOpts[ character ] ) ) {
|
||||
throw "Option '-" + character + "' not supported";
|
||||
}
|
||||
|
||||
args.options[ option.name ] = option.type( 'true', option.name, args.options, args );
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Ensure that an option exists
|
||||
if ( ! ( option = shortOpts[ arg ] ) ) {
|
||||
throw "Option '-" + arg + "' not supported";
|
||||
}
|
||||
|
||||
// Check next option for target association
|
||||
if ( peek && option.test && option.test( peek, option.name, args.options, args ) ) {
|
||||
value = peek;
|
||||
skip = true;
|
||||
}
|
||||
else if ( peek && ! option.test && ristarget.exec( peek ) ) {
|
||||
value = peek;
|
||||
skip = true;
|
||||
}
|
||||
else {
|
||||
value = 'true';
|
||||
}
|
||||
|
||||
// Convert it
|
||||
args.options[ option.name ] = option.type( value, option.name, args.options, args );
|
||||
|
||||
// Trigger onset callback when option is set
|
||||
if ( self.isFunction( option.onset ) ) {
|
||||
option.onset( args );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Targets
|
||||
else {
|
||||
args.targets.push( arg );
|
||||
}
|
||||
});
|
||||
|
||||
return args;
|
||||
},
|
||||
|
||||
run: function( argv ) {
|
||||
try {
|
||||
return self._run( argv );
|
||||
}
|
||||
catch ( e ) {
|
||||
if ( ! self.isString( e ) ) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
console.log( "\n" + e + ". Trigger '" + self.name + " -h' for more details.\n\n" );
|
||||
process.exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Type tests
|
||||
"Boolean Number String Function Array Date RegExp Object Error".split(' ').forEach(function( method ) {
|
||||
if ( method == 'Array' ) {
|
||||
return ( self.isArray = Array.isArray );
|
||||
}
|
||||
else if ( method == 'Error' ) {
|
||||
self.isError = function( object ) {
|
||||
return object && ( object instanceof Error );
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var match = '[object ' + method + ']';
|
||||
self[ 'is' + method ] = function( object ) {
|
||||
return object !== undefined && object !== null && toString.call( object ) == match;
|
||||
};
|
||||
});
|
55
node_modules/argv/package.json
generated
vendored
55
node_modules/argv/package.json
generated
vendored
@ -1,55 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"argv@0.0.2",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "argv@0.0.2",
|
||||
"_id": "argv@0.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-7L0W+JSbFXGDcRsb2jNPN4QBhas=",
|
||||
"_location": "/argv",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "argv@0.0.2",
|
||||
"name": "argv",
|
||||
"escapedName": "argv",
|
||||
"rawSpec": "0.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/codecov"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/argv/-/argv-0.0.2.tgz",
|
||||
"_spec": "0.0.2",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"author": {
|
||||
"name": "Corey Hart",
|
||||
"email": "corey@codenothing.com"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "CLI Argument Parser",
|
||||
"devDependencies": {
|
||||
"munit": "0.0.5",
|
||||
"nlint": "0.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6.10"
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"argv",
|
||||
"options"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"name": "argv",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"url": "http://codenothing.github.com/argv/",
|
||||
"version": "0.0.2"
|
||||
}
|
168
node_modules/argv/test/test-core.js
generated
vendored
168
node_modules/argv/test/test-core.js
generated
vendored
@ -1,168 +0,0 @@
|
||||
munit( 'Root.Options', function( assert ) {
|
||||
argv.clear().option([
|
||||
|
||||
{
|
||||
name: 'bool',
|
||||
short: 'b',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'path',
|
||||
short: 'p',
|
||||
type: 'path'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'int',
|
||||
short: 'i',
|
||||
type: 'int'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'float',
|
||||
short: 'f',
|
||||
type: 'float'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'csv',
|
||||
short: 'c',
|
||||
type: 'csv'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'list',
|
||||
short: 'l',
|
||||
type: 'list'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'listpath',
|
||||
short: 't',
|
||||
type: 'list,path'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'csvcombo',
|
||||
type: 'csv,int'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool2',
|
||||
short: 'x',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool3',
|
||||
short: 'y',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool4',
|
||||
short: 'z',
|
||||
type: 'boolean'
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
// Tests
|
||||
[
|
||||
|
||||
{
|
||||
name: 'basic',
|
||||
args: '-b false --path=/a/b/c -i 123.456 --float=123.456 -c a,b,c -l a -l b -l c',
|
||||
options: {
|
||||
bool: false,
|
||||
path: '/a/b/c',
|
||||
'int': 123,
|
||||
'float': 123.456,
|
||||
csv: [ 'a', 'b', 'c' ],
|
||||
list: [ 'a', 'b', 'c' ]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'path-relative',
|
||||
args: '-p a/b/c',
|
||||
options: {
|
||||
path: process.cwd() + '/a/b/c'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'path-home',
|
||||
args: '-p ~/a/b/c',
|
||||
options: {
|
||||
path: process.env.HOME + '/a/b/c'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'listpath',
|
||||
args: '-t ~/a/b/c -t /a/b/c -t a/b/c',
|
||||
options: {
|
||||
listpath: [
|
||||
process.env.HOME + '/a/b/c',
|
||||
'/a/b/c',
|
||||
process.cwd() + '/a/b/c'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'csvcombo',
|
||||
args: '--csvcombo=123,456.99,0.00001',
|
||||
options: {
|
||||
csvcombo: [ 123, 456, 0 ]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'targets',
|
||||
args: 'targ1 -p /a/b/c targ2 targ3 --bool targ4',
|
||||
targets: [ 'targ1', 'targ2', 'targ3', 'targ4' ],
|
||||
options: {
|
||||
path: '/a/b/c',
|
||||
bool: true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool-target-test',
|
||||
args: 'targ1 -b targ2',
|
||||
targets: [ 'targ1', 'targ2' ],
|
||||
options: {
|
||||
bool: true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool-multi-option',
|
||||
args: 'targ1 -bxy targ2 -z targ3',
|
||||
targets: [ 'targ1', 'targ2', 'targ3' ],
|
||||
options: {
|
||||
bool: true,
|
||||
bool2: true,
|
||||
bool3: true,
|
||||
bool4: true
|
||||
}
|
||||
}
|
||||
|
||||
].forEach(function( object ) {
|
||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
||||
|
||||
// Option parsing
|
||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
||||
|
||||
// Target comparison
|
||||
if ( object.targets ) {
|
||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
||||
}
|
||||
else {
|
||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
||||
}
|
||||
});
|
||||
});
|
65
node_modules/argv/test/test-custom.js
generated
vendored
65
node_modules/argv/test/test-custom.js
generated
vendored
@ -1,65 +0,0 @@
|
||||
munit( 'Custom', function( assert ) {
|
||||
// Add custom types
|
||||
argv.type({
|
||||
|
||||
'special-int': function(){
|
||||
return 777;
|
||||
},
|
||||
|
||||
'special-float': function(){
|
||||
return 777.777;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Setup options
|
||||
argv.clear().option([
|
||||
|
||||
{
|
||||
name: 'foo',
|
||||
type: 'special-int'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bar',
|
||||
type: 'special-float'
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
// Tests
|
||||
[
|
||||
|
||||
{
|
||||
name: 'types',
|
||||
args: '--foo=123 --bar=456',
|
||||
options: {
|
||||
foo: 777,
|
||||
bar: 777.777
|
||||
}
|
||||
}
|
||||
|
||||
].forEach(function( object ) {
|
||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
||||
|
||||
// Option parsing
|
||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
||||
|
||||
// Target comparison
|
||||
if ( object.targets ) {
|
||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
||||
}
|
||||
else {
|
||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Deletion checks
|
||||
assert.ok( 'Int Exists', argv.types[ 'special-int' ] );
|
||||
assert.ok( 'Float Exists', argv.types[ 'special-float' ] );
|
||||
argv.type( 'special-int', null );
|
||||
argv.type( 'special-float', null );
|
||||
assert.ok( 'Delete Int', ! argv.types[ 'special-int' ] );
|
||||
assert.ok( 'Delete Float', ! argv.types[ 'special-float' ] );
|
||||
});
|
118
node_modules/argv/test/test-mods.js
generated
vendored
118
node_modules/argv/test/test-mods.js
generated
vendored
@ -1,118 +0,0 @@
|
||||
munit( 'Modules', function( assert ) {
|
||||
argv.clear().option([
|
||||
|
||||
{
|
||||
name: 'bool',
|
||||
short: 'a',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool2',
|
||||
short: 'b',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool3',
|
||||
short: 'c',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'path',
|
||||
short: 'p',
|
||||
type: 'path'
|
||||
},
|
||||
|
||||
{
|
||||
mod: 'mod',
|
||||
options: [
|
||||
|
||||
{
|
||||
name: 'bool',
|
||||
short: 'a',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool2',
|
||||
short: 'b',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'bool3',
|
||||
short: 'c',
|
||||
type: 'boolean'
|
||||
},
|
||||
|
||||
{
|
||||
name: 'path',
|
||||
short: 'p',
|
||||
type: 'path'
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
[
|
||||
|
||||
{
|
||||
name: 'root',
|
||||
args: 'targ1 -p /a/b/c targ2 -abc targ3',
|
||||
targets: [ 'targ1', 'targ2', 'targ3' ],
|
||||
options: {
|
||||
path: '/a/b/c',
|
||||
bool: true,
|
||||
bool2: true,
|
||||
bool3: true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'mod',
|
||||
args: 'mod targ1 -ab',
|
||||
mod: 'mod',
|
||||
targets: [ 'targ1' ],
|
||||
options: {
|
||||
bool: true,
|
||||
bool2: true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'mod-path',
|
||||
args: 'mod targ1 -p /a/b/c',
|
||||
mod: 'mod',
|
||||
targets: [ 'targ1' ],
|
||||
options: {
|
||||
path: '/a/b/c'
|
||||
}
|
||||
}
|
||||
|
||||
].forEach(function( object ) {
|
||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
||||
|
||||
// Option parsing
|
||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
||||
|
||||
// Mod comparison
|
||||
if ( object.mod ) {
|
||||
assert.equal( object.name + '::mod', args.mod, object.mod );
|
||||
}
|
||||
else {
|
||||
assert.ok( object.name + '::mod', ! args.mod );
|
||||
}
|
||||
|
||||
// Target comparison
|
||||
if ( object.targets ) {
|
||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
||||
}
|
||||
else {
|
||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
||||
}
|
||||
});
|
||||
});
|
12
node_modules/argv/test/test-version.js
generated
vendored
12
node_modules/argv/test/test-version.js
generated
vendored
@ -1,12 +0,0 @@
|
||||
munit( 'Root.version', { priority: munit.PRIORITY_LOW }, function( assert ) {
|
||||
argv.clear();
|
||||
if ( argv.options.version ) {
|
||||
delete argv.options.version;
|
||||
}
|
||||
|
||||
assert.empty( 'Version Start', argv.options.version );
|
||||
argv.version( "1.2.4" );
|
||||
assert.exists( 'Version Option', argv.options.version );
|
||||
argv.clear();
|
||||
assert.exists( 'Version Option after Clear', argv.options.version );
|
||||
});
|
5
node_modules/balanced-match/.npmignore
generated
vendored
5
node_modules/balanced-match/.npmignore
generated
vendored
@ -1,5 +0,0 @@
|
||||
test
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Makefile
|
||||
example.js
|
21
node_modules/balanced-match/LICENSE.md
generated
vendored
21
node_modules/balanced-match/LICENSE.md
generated
vendored
@ -1,21 +0,0 @@
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
91
node_modules/balanced-match/README.md
generated
vendored
91
node_modules/balanced-match/README.md
generated
vendored
@ -1,91 +0,0 @@
|
||||
# balanced-match
|
||||
|
||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||
|
||||
[](http://travis-ci.org/juliangruber/balanced-match)
|
||||
[](https://www.npmjs.org/package/balanced-match)
|
||||
|
||||
[](https://ci.testling.com/juliangruber/balanced-match)
|
||||
|
||||
## Example
|
||||
|
||||
Get the first matching pair of braces:
|
||||
|
||||
```js
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
||||
```
|
||||
|
||||
The matches are:
|
||||
|
||||
```bash
|
||||
$ node example.js
|
||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
||||
{ start: 3,
|
||||
end: 9,
|
||||
pre: 'pre',
|
||||
body: 'first',
|
||||
post: 'between{second}post' }
|
||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### var m = balanced(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
object with those keys:
|
||||
|
||||
* **start** the index of the first match of `a`
|
||||
* **end** the index of the matching `b`
|
||||
* **pre** the preamble, `a` and `b` not included
|
||||
* **body** the match, `a` and `b` not included
|
||||
* **post** the postscript, `a` and `b` not included
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
||||
|
||||
### var r = balanced.range(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
array with indexes: `[ <a index>, <b index> ]`.
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install balanced-match
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
59
node_modules/balanced-match/index.js
generated
vendored
59
node_modules/balanced-match/index.js
generated
vendored
@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
module.exports = balanced;
|
||||
function balanced(a, b, str) {
|
||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||
|
||||
var r = range(a, b, str);
|
||||
|
||||
return r && {
|
||||
start: r[0],
|
||||
end: r[1],
|
||||
pre: str.slice(0, r[0]),
|
||||
body: str.slice(r[0] + a.length, r[1]),
|
||||
post: str.slice(r[1] + b.length)
|
||||
};
|
||||
}
|
||||
|
||||
function maybeMatch(reg, str) {
|
||||
var m = str.match(reg);
|
||||
return m ? m[0] : null;
|
||||
}
|
||||
|
||||
balanced.range = range;
|
||||
function range(a, b, str) {
|
||||
var begs, beg, left, right, result;
|
||||
var ai = str.indexOf(a);
|
||||
var bi = str.indexOf(b, ai + 1);
|
||||
var i = ai;
|
||||
|
||||
if (ai >= 0 && bi > 0) {
|
||||
begs = [];
|
||||
left = str.length;
|
||||
|
||||
while (i >= 0 && !result) {
|
||||
if (i == ai) {
|
||||
begs.push(i);
|
||||
ai = str.indexOf(a, i + 1);
|
||||
} else if (begs.length == 1) {
|
||||
result = [ begs.pop(), bi ];
|
||||
} else {
|
||||
beg = begs.pop();
|
||||
if (beg < left) {
|
||||
left = beg;
|
||||
right = bi;
|
||||
}
|
||||
|
||||
bi = str.indexOf(b, i + 1);
|
||||
}
|
||||
|
||||
i = ai < bi && ai >= 0 ? ai : bi;
|
||||
}
|
||||
|
||||
if (begs.length) {
|
||||
result = [ left, right ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
80
node_modules/balanced-match/package.json
generated
vendored
80
node_modules/balanced-match/package.json
generated
vendored
@ -1,80 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"balanced-match@1.0.0",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "balanced-match@1.0.0",
|
||||
"_id": "balanced-match@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"_location": "/balanced-match",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "balanced-match@1.0.0",
|
||||
"name": "balanced-match",
|
||||
"escapedName": "balanced-match",
|
||||
"rawSpec": "1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/brace-expansion"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"_spec": "1.0.0",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/balanced-match/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||
"keywords": [
|
||||
"match",
|
||||
"regexp",
|
||||
"test",
|
||||
"balanced",
|
||||
"parse"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "balanced-match",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "make bench",
|
||||
"test": "make test"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
21
node_modules/brace-expansion/LICENSE
generated
vendored
21
node_modules/brace-expansion/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user