Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
22
my-app/node_modules/inquirer/LICENSE
generated
vendored
Executable file
22
my-app/node_modules/inquirer/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2023 Simon Boudrias
|
||||
|
||||
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.
|
524
my-app/node_modules/inquirer/README.md
generated
vendored
Executable file
524
my-app/node_modules/inquirer/README.md
generated
vendored
Executable file
|
@ -0,0 +1,524 @@
|
|||
<img width="75px" height="75px" align="right" alt="Inquirer Logo" src="https://raw.githubusercontent.com/SBoudrias/Inquirer.js/master/assets/inquirer_readme.svg?sanitize=true" title="Inquirer.js"/>
|
||||
|
||||
# Inquirer.js
|
||||
|
||||
[](https://www.npmjs.com/package/inquirer)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2FSBoudrias%2FInquirer.js?ref=badge_shield)
|
||||
|
||||
A collection of common interactive command line user interfaces.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Documentation](#documentation)
|
||||
1. [Installation](#installation)
|
||||
2. [Examples](#examples)
|
||||
3. [Methods](#methods)
|
||||
4. [Objects](#objects)
|
||||
5. [Question](#question)
|
||||
6. [Answers](#answers)
|
||||
7. [Separator](#separator)
|
||||
8. [Prompt Types](#prompt-types)
|
||||
2. [User Interfaces and Layouts](#user-interfaces-and-layouts)
|
||||
1. [Reactive Interface](#reactive-interface)
|
||||
3. [Support](#support)
|
||||
4. [Known issues](#issues)
|
||||
5. [News](#news)
|
||||
6. [Contributing](#contributing)
|
||||
7. [License](#license)
|
||||
8. [Plugins](#plugins)
|
||||
|
||||
## Goal and Philosophy
|
||||
|
||||
**`Inquirer.js`** strives to be an easily embeddable and beautiful command line interface for [Node.js](https://nodejs.org/) (and perhaps the "CLI [Xanadu](https://en.wikipedia.org/wiki/Citizen_Kane)").
|
||||
|
||||
**`Inquirer.js`** should ease the process of
|
||||
|
||||
- providing _error feedback_
|
||||
- _asking questions_
|
||||
- _parsing_ input
|
||||
- _validating_ answers
|
||||
- managing _hierarchical prompts_
|
||||
|
||||
> **Note:** **`Inquirer.js`** provides the user interface and the inquiry session flow. If you're searching for a full blown command line program utility, then check out [commander](https://github.com/visionmedia/commander.js), [vorpal](https://github.com/dthree/vorpal) or [args](https://github.com/leo/args).
|
||||
|
||||
## [Documentation](#documentation)
|
||||
|
||||
<a name="documentation"></a>
|
||||
|
||||
### Installation
|
||||
|
||||
<a name="installation"></a>
|
||||
|
||||
```shell
|
||||
npm install --save inquirer
|
||||
```
|
||||
|
||||
```javascript
|
||||
import inquirer from 'inquirer';
|
||||
|
||||
inquirer
|
||||
.prompt([
|
||||
/* Pass your questions in here */
|
||||
])
|
||||
.then((answers) => {
|
||||
// Use user feedback for... whatever!!
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.isTtyError) {
|
||||
// Prompt couldn't be rendered in the current environment
|
||||
} else {
|
||||
// Something else went wrong
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inquirer v9 and higher are native esm modules, this mean you cannot use the commonjs syntax `require('inquirer')` anymore. If you want to learn more about using native esm in Node, I'd recommend reading [the following guide](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). Alternatively, you can rely on an older version until you're ready to upgrade your environment:
|
||||
|
||||
```sh
|
||||
npm install --save inquirer@^8.0.0
|
||||
```
|
||||
|
||||
This will then allow import inquirer with the commonjs `require`:
|
||||
|
||||
```js
|
||||
const inquirer = require('inquirer');
|
||||
```
|
||||
|
||||
<a name="examples"></a>
|
||||
|
||||
### Examples (Run it and see it)
|
||||
|
||||
Check out the [`packages/inquirer/examples/`](https://github.com/SBoudrias/Inquirer.js/tree/master/packages/inquirer/examples) folder for code and interface examples.
|
||||
|
||||
```shell
|
||||
node packages/inquirer/examples/pizza.js
|
||||
node packages/inquirer/examples/checkbox.js
|
||||
# etc...
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
<a name="methods"></a>
|
||||
|
||||
#### `inquirer.prompt(questions, answers) -> promise`
|
||||
|
||||
Launch the prompt interface (inquiry session)
|
||||
|
||||
- **questions** (Array) containing [Question Object](#question) (using the [reactive interface](#reactive-interface), you can also pass a `Rx.Observable` instance)
|
||||
- **answers** (object) contains values of already answered questions. Inquirer will avoid asking answers already provided here. Defaults `{}`.
|
||||
- returns a **Promise**
|
||||
|
||||
#### `inquirer.registerPrompt(name, prompt)`
|
||||
|
||||
Register prompt plugins under `name`.
|
||||
|
||||
- **name** (string) name of the this new prompt. (used for question `type`)
|
||||
- **prompt** (object) the prompt object itself (the plugin)
|
||||
|
||||
#### `inquirer.createPromptModule() -> prompt function`
|
||||
|
||||
Create a self contained inquirer module. If you don't want to affect other libraries that also rely on inquirer when you overwrite or add new prompt types.
|
||||
|
||||
```js
|
||||
const prompt = inquirer.createPromptModule();
|
||||
|
||||
prompt(questions).then(/* ... */);
|
||||
```
|
||||
|
||||
### Objects
|
||||
|
||||
<a name="objects"></a>
|
||||
|
||||
#### Question
|
||||
|
||||
<a name="questions"></a>
|
||||
A question object is a `hash` containing question related values:
|
||||
|
||||
- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `number`, `confirm`, `list`, `rawlist`, `expand`, `checkbox`, `password`, `editor`
|
||||
- **name**: (String) The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.
|
||||
- **message**: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers. Defaults to the value of `name` (followed by a colon).
|
||||
- **default**: (String|Number|Boolean|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.
|
||||
- **choices**: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers.
|
||||
Array values can be simple `numbers`, `strings`, or `objects` containing a `name` (to display in list), a `value` (to save in the answers hash), and a `short` (to display after selection) properties. The choices array can also contain [a `Separator`](#separator).
|
||||
- **validate**: (Function) Receive the user input and answers hash. Should return `true` if the value is valid, and an error message (`String`) otherwise. If `false` is returned, a default error message is provided.
|
||||
- **filter**: (Function) Receive the user input and answers hash. Returns the filtered value to be used inside the program. The value returned will be added to the _Answers_ hash.
|
||||
- **transformer**: (Function) Receive the user input, answers hash and option flags, and return a transformed value to display to the user. The transformation only impacts what is shown while editing. It does not modify the answers hash.
|
||||
- **when**: (Function, Boolean) Receive the current user answers hash and should return `true` or `false` depending on whether or not this question should be asked. The value can also be a simple boolean.
|
||||
- **pageSize**: (Number) Change the number of lines that will be rendered when using `list`, `rawList`, `expand` or `checkbox`.
|
||||
- **prefix**: (String) Change the default _prefix_ message.
|
||||
- **suffix**: (String) Change the default _suffix_ message.
|
||||
- **askAnswered**: (Boolean) Force to prompt the question if the answer already exists.
|
||||
- **loop**: (Boolean) Enable list looping. Defaults: `true`
|
||||
- **waitUserInput**: (Boolean) Flag to enable/disable wait for user input before opening system editor - Defaults: `true`
|
||||
|
||||
`default`, `choices`(if defined as functions), `validate`, `filter` and `when` functions can be called asynchronously. Either return a promise or use `this.async()` to get a callback you'll call with the final value.
|
||||
|
||||
```javascript
|
||||
{
|
||||
/* Preferred way: with promise */
|
||||
filter() {
|
||||
return new Promise(/* etc... */);
|
||||
},
|
||||
|
||||
/* Legacy way: with this.async */
|
||||
validate: function (input) {
|
||||
// Declare function as asynchronous, and save the done callback
|
||||
const done = this.async();
|
||||
|
||||
// Do async stuff
|
||||
setTimeout(function() {
|
||||
if (typeof input !== 'number') {
|
||||
// Pass the return value in the done callback
|
||||
done('You need to provide a number');
|
||||
} else {
|
||||
// Pass the return value in the done callback
|
||||
done(null, true);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Answers
|
||||
|
||||
<a name="answers"></a>
|
||||
A key/value hash containing the client answers in each prompt.
|
||||
|
||||
- **Key** The `name` property of the _question_ object
|
||||
- **Value** (Depends on the prompt)
|
||||
- `confirm`: (Boolean)
|
||||
- `input` : User input (filtered if `filter` is defined) (String)
|
||||
- `number`: User input (filtered if `filter` is defined) (Number)
|
||||
- `rawlist`, `list` : Selected choice value (or name if no value specified) (String)
|
||||
|
||||
### Separator
|
||||
|
||||
<a name="separator"></a>
|
||||
A separator can be added to any `choices` array:
|
||||
|
||||
```
|
||||
// In the question object
|
||||
choices: [ "Choice A", new inquirer.Separator(), "choice B" ]
|
||||
|
||||
// Which'll be displayed this way
|
||||
[?] What do you want to do?
|
||||
> Order a pizza
|
||||
Make a reservation
|
||||
--------
|
||||
Ask opening hours
|
||||
Talk to the receptionist
|
||||
```
|
||||
|
||||
The constructor takes a facultative `String` value that'll be use as the separator. If omitted, the separator will be `--------`.
|
||||
|
||||
Separator instances have a property `type` equal to `separator`. This should allow tools façading Inquirer interface from detecting separator types in lists.
|
||||
|
||||
<a name="prompt"></a>
|
||||
|
||||
### Prompt types
|
||||
|
||||
---
|
||||
|
||||
> **Note:**: _allowed options written inside square brackets (`[]`) are optional. Others are required._
|
||||
|
||||
#### List - `{type: 'list'}`
|
||||
|
||||
Take `type`, `name`, `message`, `choices`[, `default`, `filter`, `loop`] properties.
|
||||
(Note: `default` must be set to the `index` or `value` of one of the entries in `choices`)
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Raw List - `{type: 'rawlist'}`
|
||||
|
||||
Take `type`, `name`, `message`, `choices`[, `default`, `filter`, `loop`] properties.
|
||||
(Note: `default` must be set to the `index` of one of the entries in `choices`)
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Expand - `{type: 'expand'}`
|
||||
|
||||
Take `type`, `name`, `message`, `choices`[, `default`] properties.
|
||||
Note: `default` must be the `index` of the desired default selection of the array. If `default` key not provided, then `help` will be used as default choice
|
||||
|
||||
Note that the `choices` object will take an extra parameter called `key` for the `expand` prompt. This parameter must be a single (lowercased) character. The `h` option is added by the prompt and shouldn't be defined by the user.
|
||||
|
||||
See `examples/expand.js` for a running example.
|
||||
|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Checkbox - `{type: 'checkbox'}`
|
||||
|
||||
Take `type`, `name`, `message`, `choices`[, `filter`, `validate`, `default`, `loop`] properties. `default` is expected to be an Array of the checked choices value.
|
||||
|
||||
Choices marked as `{checked: true}` will be checked by default.
|
||||
|
||||
Choices whose property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to `"Disabled"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Confirm - `{type: 'confirm'}`
|
||||
|
||||
Take `type`, `name`, `message`, [`default`, `transformer`] properties. `default` is expected to be a boolean if used.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Input - `{type: 'input'}`
|
||||
|
||||
Take `type`, `name`, `message`[, `default`, `filter`, `validate`, `transformer`] properties.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Input - `{type: 'number'}`
|
||||
|
||||
Take `type`, `name`, `message`[, `default`, `filter`, `validate`, `transformer`] properties.
|
||||
|
||||
---
|
||||
|
||||
#### Password - `{type: 'password'}`
|
||||
|
||||
Take `type`, `name`, `message`, `mask`,[, `default`, `filter`, `validate`] properties.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
Note that `mask` is required to hide the actual user input.
|
||||
|
||||
#### Editor - `{type: 'editor'}`
|
||||
|
||||
Take `type`, `name`, `message`[, `default`, `filter`, `validate`, `postfix`, `waitUserInput`] properties
|
||||
|
||||
Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the contents of the temporary file are read in as the result. The editor to use is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.
|
||||
|
||||
The `postfix` property is useful if you want to provide an extension.
|
||||
|
||||
<a name="layouts"></a>
|
||||
|
||||
### Use in Non-Interactive Environments
|
||||
|
||||
`prompt()` requires that it is run in an interactive environment. (I.e. [One where `process.stdin.isTTY` is `true`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_a_note_on_process_i_o)). If `prompt()` is invoked outside of such an environment, then `prompt()` will return a rejected promise with an error. For convenience, the error will have a `isTtyError` property to programmatically indicate the cause.
|
||||
|
||||
## User Interfaces and layouts
|
||||
|
||||
Along with the prompts, Inquirer offers some basic text UI.
|
||||
|
||||
#### Bottom Bar - `inquirer.ui.BottomBar`
|
||||
|
||||
This UI present a fixed text at the bottom of a free text zone. This is useful to keep a message to the bottom of the screen while outputting command outputs on the higher section.
|
||||
|
||||
```javascript
|
||||
const ui = new inquirer.ui.BottomBar();
|
||||
|
||||
// pipe a Stream to the log zone
|
||||
outputStream.pipe(ui.log);
|
||||
|
||||
// Or simply write output
|
||||
ui.log.write('something just happened.');
|
||||
ui.log.write('Almost over, standby!');
|
||||
|
||||
// During processing, update the bottom bar content to display a loader
|
||||
// or output a progress bar, etc
|
||||
ui.updateBottomBar('new bottom bar content');
|
||||
```
|
||||
|
||||
<a name="reactive"></a>
|
||||
|
||||
## Reactive interface
|
||||
|
||||
Internally, Inquirer uses the [JS reactive extension](https://github.com/ReactiveX/rxjs) to handle events and async flows.
|
||||
|
||||
This mean you can take advantage of this feature to provide more advanced flows. For example, you can dynamically add questions to be asked:
|
||||
|
||||
```js
|
||||
const prompts = new Rx.Subject();
|
||||
inquirer.prompt(prompts);
|
||||
|
||||
// At some point in the future, push new questions
|
||||
prompts.next({
|
||||
/* question... */
|
||||
});
|
||||
prompts.next({
|
||||
/* question... */
|
||||
});
|
||||
|
||||
// When you're done
|
||||
prompts.complete();
|
||||
```
|
||||
|
||||
And using the return value `process` property, you can access more fine grained callbacks:
|
||||
|
||||
```js
|
||||
inquirer.prompt(prompts).ui.process.subscribe(onEachAnswer, onError, onComplete);
|
||||
```
|
||||
|
||||
## Support (OS Terminals)
|
||||
|
||||
<a name="support"></a>
|
||||
|
||||
You should expect mostly good support for the CLI below. This does not mean we won't
|
||||
look at issues found on other command line - feel free to report any!
|
||||
|
||||
- **Mac OS**:
|
||||
- Terminal.app
|
||||
- iTerm
|
||||
- **Windows ([Known issues](#issues))**:
|
||||
- [Windows Terminal](https://github.com/microsoft/terminal)
|
||||
- [ConEmu](https://conemu.github.io/)
|
||||
- cmd.exe
|
||||
- Powershell
|
||||
- Cygwin
|
||||
- **Linux (Ubuntu, openSUSE, Arch Linux, etc)**:
|
||||
- gnome-terminal (Terminal GNOME)
|
||||
- konsole
|
||||
|
||||
## Known issues
|
||||
|
||||
<a name="issues"></a>
|
||||
|
||||
- **nodemon** - Makes the arrow keys print gibrish on list prompts.
|
||||
Workaround: Add `{ stdin : false }` in the configuration file or pass `--no-stdin` in the CLI.
|
||||
Please refer to [this issue](https://github.com/SBoudrias/Inquirer.js/issues/844#issuecomment-736675867)
|
||||
|
||||
- **grunt-exec** - Calling a node script that uses Inquirer from grunt-exec can cause the program to crash. To fix this, add to your grunt-exec config `stdio: 'inherit'`.
|
||||
Please refer to [this issue](https://github.com/jharding/grunt-exec/issues/85)
|
||||
|
||||
- **Windows network streams** - Running Inquirer together with network streams in Windows platform inside some terminals can result in process hang.
|
||||
Workaround: run inside another terminal.
|
||||
Please refer to [this issue](https://github.com/nodejs/node/issues/21771)
|
||||
|
||||
## News on the march (Release notes)
|
||||
|
||||
<a name="news"></a>
|
||||
|
||||
Please refer to the [GitHub releases section for the changelog](https://github.com/SBoudrias/Inquirer.js/releases)
|
||||
|
||||
## Contributing
|
||||
|
||||
<a name="contributing"></a>
|
||||
|
||||
**Unit test**
|
||||
Please add a unit test for every new feature or bug fix. `npm test` to run the test suite.
|
||||
|
||||
**Documentation**
|
||||
Add documentation for every API change. Feel free to send typo fixes and better docs!
|
||||
|
||||
We're looking to offer good support for multiple prompts and environments. If you want to
|
||||
help, we'd like to keep a list of testers for each terminal/OS so we can contact you and
|
||||
get feedback before release. Let us know if you want to be added to the list (just tweet
|
||||
to [@vaxilart](https://twitter.com/Vaxilart)) or just add your name to [the wiki](https://github.com/SBoudrias/Inquirer.js/wiki/Testers)
|
||||
|
||||
## License
|
||||
|
||||
<a name="license"></a>
|
||||
|
||||
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
|
||||
Licensed under the MIT license.
|
||||
|
||||
## Plugins
|
||||
|
||||
<a name="plugins"></a>
|
||||
|
||||
### Prompts
|
||||
|
||||
[**autocomplete**](https://github.com/mokkabonna/inquirer-autocomplete-prompt)<br>
|
||||
Presents a list of options as the user types, compatible with other packages such as fuzzy (for search)<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**checkbox-plus**](https://github.com/faressoft/inquirer-checkbox-plus-prompt)<br>
|
||||
Checkbox list with autocomplete and other additions<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-date-prompt**](https://github.com/haversnail/inquirer-date-prompt)<br>
|
||||
Customizable date/time selector with localization support<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**datetime**](https://github.com/DerekTBrown/inquirer-datepicker-prompt)<br>
|
||||
Customizable date/time selector using both number pad and arrow keys<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-select-line**](https://github.com/adam-golab/inquirer-select-line)<br>
|
||||
Prompt for selecting index in array where add new element<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**command**](https://github.com/sullof/inquirer-command-prompt)<br>
|
||||
Simple prompt with command history and dynamic autocomplete<br>
|
||||
|
||||
[**inquirer-fuzzy-path**](https://github.com/adelsz/inquirer-fuzzy-path)<br>
|
||||
Prompt for fuzzy file/directory selection.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-emoji**](https://github.com/tannerntannern/inquirer-emoji)<br>
|
||||
Prompt for inputting emojis.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-chalk-pipe**](https://github.com/LitoMore/inquirer-chalk-pipe)<br>
|
||||
Prompt for input chalk-pipe style strings<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-search-checkbox**](https://github.com/clinyong/inquirer-search-checkbox)<br>
|
||||
Searchable Inquirer checkbox<br>
|
||||

|
||||
|
||||
[**inquirer-search-list**](https://github.com/robin-rpr/inquirer-search-list)<br>
|
||||
Searchable Inquirer list<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-prompt-suggest**](https://github.com/olistic/inquirer-prompt-suggest)<br>
|
||||
Inquirer prompt for your less creative users.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-s3**](https://github.com/HQarroum/inquirer-s3)<br>
|
||||
An S3 object selector for Inquirer.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-autosubmit-prompt**](https://github.com/yaodingyd/inquirer-autosubmit-prompt)<br>
|
||||
Auto submit based on your current input, saving one extra enter<br>
|
||||
|
||||
[**inquirer-file-tree-selection-prompt**](https://github.com/anc95/inquirer-file-tree-selection)<br>
|
||||
Inquirer prompt for to select a file or directory in file tree<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-tree-prompt**](https://github.com/insightfuls/inquirer-tree-prompt)<br>
|
||||
Inquirer prompt to select from a tree<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-table-prompt**](https://github.com/eduardoboucas/inquirer-table-prompt)<br>
|
||||
A table-like prompt for Inquirer.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-interrupted-prompt**](https://github.com/lnquy065/inquirer-interrupted-prompt)<br>
|
||||
Turning any existing inquirer and its plugin prompts into prompts that can be interrupted with a custom key.<br>
|
||||
<br>
|
||||

|
||||
|
||||
[**inquirer-press-to-continue**](https://github.com/leonzalion/inquirer-press-to-continue)<br>
|
||||
A "press any key to continue" prompt for Inquirer.js<br>
|
||||
<br>
|
||||

|
106
my-app/node_modules/inquirer/lib/inquirer.js
generated
vendored
Executable file
106
my-app/node_modules/inquirer/lib/inquirer.js
generated
vendored
Executable file
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* Inquirer.js
|
||||
* A collection of common interactive command line user interfaces.
|
||||
*/
|
||||
|
||||
import { default as List } from './prompts/list.js';
|
||||
import { default as Input } from './prompts/input.js';
|
||||
import { default as Number } from './prompts/number.js';
|
||||
import { default as Confirm } from './prompts/confirm.js';
|
||||
import { default as RawList } from './prompts/rawlist.js';
|
||||
import { default as Expand } from './prompts/expand.js';
|
||||
import { default as Checkbox } from './prompts/checkbox.js';
|
||||
import { default as Password } from './prompts/password.js';
|
||||
import { default as Editor } from './prompts/editor.js';
|
||||
|
||||
import { default as BottomBar } from './ui/bottom-bar.js';
|
||||
import { default as Prompt } from './ui/prompt.js';
|
||||
|
||||
import { default as Separator } from './objects/separator.js';
|
||||
|
||||
/**
|
||||
* Create a new self-contained prompt module.
|
||||
*/
|
||||
export function createPromptModule(opt) {
|
||||
const promptModule = function (questions, answers) {
|
||||
let uiInstance;
|
||||
try {
|
||||
uiInstance = new Prompt(promptModule.prompts, opt);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
const promise = uiInstance.run(questions, answers);
|
||||
|
||||
// Monkey patch the UI on the promise object so
|
||||
// that it remains publicly accessible.
|
||||
promise.ui = uiInstance;
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
promptModule.prompts = {};
|
||||
|
||||
/**
|
||||
* Register a prompt type
|
||||
* @param {String} name Prompt type name
|
||||
* @param {Function} prompt Prompt constructor
|
||||
* @return {inquirer}
|
||||
*/
|
||||
|
||||
promptModule.registerPrompt = function (name, prompt) {
|
||||
promptModule.prompts[name] = prompt;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register the defaults provider prompts
|
||||
*/
|
||||
|
||||
promptModule.restoreDefaultPrompts = function () {
|
||||
this.registerPrompt('list', List);
|
||||
this.registerPrompt('input', Input);
|
||||
this.registerPrompt('number', Number);
|
||||
this.registerPrompt('confirm', Confirm);
|
||||
this.registerPrompt('rawlist', RawList);
|
||||
this.registerPrompt('expand', Expand);
|
||||
this.registerPrompt('checkbox', Checkbox);
|
||||
this.registerPrompt('password', Password);
|
||||
this.registerPrompt('editor', Editor);
|
||||
};
|
||||
|
||||
promptModule.restoreDefaultPrompts();
|
||||
|
||||
return promptModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public CLI helper interface
|
||||
* @param {Array|Object|Rx.Observable} questions - Questions settings array
|
||||
* @param {Function} cb - Callback being passed the user answers
|
||||
* @return {ui.Prompt}
|
||||
*/
|
||||
|
||||
const prompt = createPromptModule();
|
||||
|
||||
// Expose helper functions on the top level for easiest usage by common users
|
||||
function registerPrompt(name, newPrompt) {
|
||||
prompt.registerPrompt(name, newPrompt);
|
||||
}
|
||||
|
||||
function restoreDefaultPrompts() {
|
||||
prompt.restoreDefaultPrompts();
|
||||
}
|
||||
|
||||
const inquirer = {
|
||||
prompt,
|
||||
ui: {
|
||||
BottomBar,
|
||||
Prompt,
|
||||
},
|
||||
createPromptModule,
|
||||
registerPrompt,
|
||||
restoreDefaultPrompts,
|
||||
Separator,
|
||||
};
|
||||
|
||||
export default inquirer;
|
35
my-app/node_modules/inquirer/lib/objects/choice.js
generated
vendored
Executable file
35
my-app/node_modules/inquirer/lib/objects/choice.js
generated
vendored
Executable file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Choice object
|
||||
* Normalize input as choice object
|
||||
* @constructor
|
||||
* @param {Number|String|Object} val Choice value. If an object is passed, it should contains
|
||||
* at least one of `value` or `name` property
|
||||
*/
|
||||
|
||||
export default class Choice {
|
||||
constructor(val, answers) {
|
||||
// Don't process Choice and Separator object
|
||||
if (val instanceof Choice || val.type === 'separator') {
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return val;
|
||||
}
|
||||
|
||||
if (typeof val === 'string' || typeof val === 'number') {
|
||||
this.name = String(val);
|
||||
this.value = val;
|
||||
this.short = String(val);
|
||||
} else {
|
||||
Object.assign(this, val, {
|
||||
name: val.name || val.value,
|
||||
value: 'value' in val ? val.value : val.name,
|
||||
short: val.short || val.name || val.value,
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof val.disabled === 'function') {
|
||||
this.disabled = val.disabled(answers);
|
||||
} else {
|
||||
this.disabled = val.disabled;
|
||||
}
|
||||
}
|
||||
}
|
117
my-app/node_modules/inquirer/lib/objects/choices.js
generated
vendored
Executable file
117
my-app/node_modules/inquirer/lib/objects/choices.js
generated
vendored
Executable file
|
@ -0,0 +1,117 @@
|
|||
import assert from 'node:assert';
|
||||
import filter from 'lodash/filter.js';
|
||||
import map from 'lodash/map.js';
|
||||
|
||||
import Separator from './separator.js';
|
||||
import Choice from './choice.js';
|
||||
|
||||
/**
|
||||
* Choices collection
|
||||
* Collection of multiple `choice` object
|
||||
*/
|
||||
export default class Choices {
|
||||
/** @param {Array} choices All `choice` to keep in the collection */
|
||||
constructor(choices, answers) {
|
||||
this.choices = choices.map((val) => {
|
||||
if (val.type === 'separator') {
|
||||
if (!(val instanceof Separator)) {
|
||||
val = new Separator(val.line);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
return new Choice(val, answers);
|
||||
});
|
||||
|
||||
this.realChoices = this.choices
|
||||
.filter(Separator.exclude)
|
||||
.filter((item) => !item.disabled);
|
||||
|
||||
Object.defineProperty(this, 'length', {
|
||||
get() {
|
||||
return this.choices.length;
|
||||
},
|
||||
set(val) {
|
||||
this.choices.length = val;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(this, 'realLength', {
|
||||
get() {
|
||||
return this.realChoices.length;
|
||||
},
|
||||
set() {
|
||||
throw new Error('Cannot set `realLength` of a Choices collection');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a valid choice from the collection
|
||||
* @param {Number} selector The selected choice index
|
||||
* @return {Choice|Undefined} Return the matched choice or undefined
|
||||
*/
|
||||
getChoice(selector) {
|
||||
assert(typeof selector === 'number');
|
||||
return this.realChoices[selector];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a raw element from the collection
|
||||
* @param {Number} selector The selected index value
|
||||
* @return {Choice|Undefined} Return the matched choice or undefined
|
||||
*/
|
||||
get(selector) {
|
||||
assert(typeof selector === 'number');
|
||||
return this.choices[selector];
|
||||
}
|
||||
|
||||
/**
|
||||
* Match the valid choices against a where clause
|
||||
* @param {Object} whereClause Lodash `where` clause
|
||||
* @return {Array} Matching choices or empty array
|
||||
*/
|
||||
where(whereClause) {
|
||||
return filter(this.realChoices, whereClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluck a particular key from the choices
|
||||
* @param {String} propertyName Property name to select
|
||||
* @return {Array} Selected properties
|
||||
*/
|
||||
pluck(propertyName) {
|
||||
return map(this.realChoices, propertyName);
|
||||
}
|
||||
|
||||
// Expose usual Array methods
|
||||
indexOf(...args) {
|
||||
return this.choices.indexOf(...args);
|
||||
}
|
||||
|
||||
forEach(...args) {
|
||||
return this.choices.forEach(...args);
|
||||
}
|
||||
|
||||
filter(...args) {
|
||||
return this.choices.filter(...args);
|
||||
}
|
||||
|
||||
reduce(...args) {
|
||||
return this.choices.reduce(...args);
|
||||
}
|
||||
|
||||
find(func) {
|
||||
return this.choices.find(func);
|
||||
}
|
||||
|
||||
push(...args) {
|
||||
const objs = args.map((val) => new Choice(val));
|
||||
this.choices.push(...objs);
|
||||
this.realChoices = this.choices
|
||||
.filter(Separator.exclude)
|
||||
.filter((item) => !item.disabled);
|
||||
return this.choices;
|
||||
}
|
||||
}
|
33
my-app/node_modules/inquirer/lib/objects/separator.js
generated
vendored
Executable file
33
my-app/node_modules/inquirer/lib/objects/separator.js
generated
vendored
Executable file
|
@ -0,0 +1,33 @@
|
|||
import chalk from 'chalk';
|
||||
import figures from 'figures';
|
||||
|
||||
/**
|
||||
* Separator object
|
||||
* Used to space/separate choices group
|
||||
* @constructor
|
||||
* @param {String} line Separation line content (facultative)
|
||||
*/
|
||||
|
||||
export default class Separator {
|
||||
constructor(line) {
|
||||
this.type = 'separator';
|
||||
this.line = chalk.dim(line || new Array(15).join(figures.line));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function returning false if object is a separator
|
||||
* @param {Object} obj object to test against
|
||||
* @return {Boolean} `false` if object is a separator
|
||||
*/
|
||||
static exclude(obj) {
|
||||
return obj.type !== 'separator';
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringify separator
|
||||
* @return {String} the separator display string
|
||||
*/
|
||||
toString() {
|
||||
return this.line;
|
||||
}
|
||||
}
|
181
my-app/node_modules/inquirer/lib/prompts/base.js
generated
vendored
Executable file
181
my-app/node_modules/inquirer/lib/prompts/base.js
generated
vendored
Executable file
|
@ -0,0 +1,181 @@
|
|||
import defaults from 'lodash/defaults.js';
|
||||
import clone from 'lodash/clone.js';
|
||||
/**
|
||||
* Base prompt implementation
|
||||
* Should be extended by prompt types.
|
||||
*/
|
||||
const _ = {
|
||||
defaults,
|
||||
clone,
|
||||
};
|
||||
|
||||
import chalk from 'chalk';
|
||||
import runAsync from 'run-async';
|
||||
import { filter, flatMap, share, take, takeUntil } from 'rxjs';
|
||||
import Choices from '../objects/choices.js';
|
||||
import ScreenManager from '../utils/screen-manager.js';
|
||||
|
||||
export default class Prompt {
|
||||
constructor(question, rl, answers) {
|
||||
// Setup instance defaults property
|
||||
Object.assign(this, {
|
||||
answers,
|
||||
status: 'pending',
|
||||
});
|
||||
|
||||
// Set defaults prompt options
|
||||
this.opt = _.defaults(_.clone(question), {
|
||||
validate: () => true,
|
||||
validatingText: '',
|
||||
filter: (val) => val,
|
||||
filteringText: '',
|
||||
when: () => true,
|
||||
suffix: '',
|
||||
prefix: chalk.green('?'),
|
||||
transformer: (val) => val,
|
||||
});
|
||||
|
||||
// Make sure name is present
|
||||
if (!this.opt.name) {
|
||||
this.throwParamError('name');
|
||||
}
|
||||
|
||||
// Set default message if no message defined
|
||||
if (!this.opt.message) {
|
||||
this.opt.message = this.opt.name + ':';
|
||||
}
|
||||
|
||||
// Normalize choices
|
||||
if (Array.isArray(this.opt.choices)) {
|
||||
this.opt.choices = new Choices(this.opt.choices, answers);
|
||||
}
|
||||
|
||||
this.rl = rl;
|
||||
this.screen = new ScreenManager(this.rl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session and manage output value filtering
|
||||
* @return {Promise}
|
||||
*/
|
||||
|
||||
run() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._run(
|
||||
(value) => resolve(value),
|
||||
(error) => reject(error),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Default noop (this one should be overwritten in prompts)
|
||||
_run(cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error telling a required parameter is missing
|
||||
* @param {String} name Name of the missing param
|
||||
* @return {Throw Error}
|
||||
*/
|
||||
|
||||
throwParamError(name) {
|
||||
throw new Error('You must provide a `' + name + '` parameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the UI closes. Override to do any specific cleanup necessary
|
||||
*/
|
||||
close() {
|
||||
this.screen.releaseCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the provided validation method each time a submit event occur.
|
||||
* @param {Rx.Observable} submit - submit event flow
|
||||
* @return {Object} Object containing two observables: `success` and `error`
|
||||
*/
|
||||
handleSubmitEvents(submit) {
|
||||
const self = this;
|
||||
const validate = runAsync(this.opt.validate);
|
||||
const asyncFilter = runAsync(this.opt.filter);
|
||||
const validation = submit.pipe(
|
||||
flatMap((value) => {
|
||||
this.startSpinner(value, this.opt.filteringText);
|
||||
return asyncFilter(value, self.answers).then(
|
||||
(filteredValue) => {
|
||||
this.startSpinner(filteredValue, this.opt.validatingText);
|
||||
return validate(filteredValue, self.answers).then(
|
||||
(isValid) => ({ isValid, value: filteredValue }),
|
||||
(err) => ({ isValid: err, value: filteredValue }),
|
||||
);
|
||||
},
|
||||
(err) => ({ isValid: err }),
|
||||
);
|
||||
}),
|
||||
share(),
|
||||
);
|
||||
|
||||
const success = validation.pipe(
|
||||
filter((state) => state.isValid === true),
|
||||
take(1),
|
||||
);
|
||||
const error = validation.pipe(
|
||||
filter((state) => state.isValid !== true),
|
||||
takeUntil(success),
|
||||
);
|
||||
|
||||
return {
|
||||
success,
|
||||
error,
|
||||
};
|
||||
}
|
||||
|
||||
startSpinner(value, bottomContent) {
|
||||
value = this.getSpinningValue(value);
|
||||
// If the question will spin, cut off the prefix (for layout purposes)
|
||||
const content = bottomContent
|
||||
? this.getQuestion() + value
|
||||
: this.getQuestion().slice(this.opt.prefix.length + 1) + value;
|
||||
|
||||
this.screen.renderWithSpinner(content, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow override, e.g. for password prompts
|
||||
* See: https://github.com/SBoudrias/Inquirer.js/issues/1022
|
||||
*
|
||||
* @return {String} value to display while spinning
|
||||
*/
|
||||
getSpinningValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the prompt question string
|
||||
* @return {String} prompt question string
|
||||
*/
|
||||
getQuestion() {
|
||||
let message =
|
||||
(this.opt.prefix ? this.opt.prefix + ' ' : '') +
|
||||
chalk.bold(this.opt.message) +
|
||||
this.opt.suffix +
|
||||
chalk.reset(' ');
|
||||
|
||||
// Append the default if available, and if question isn't touched/answered
|
||||
if (
|
||||
this.opt.default != null &&
|
||||
this.status !== 'touched' &&
|
||||
this.status !== 'answered'
|
||||
) {
|
||||
// If default password is supplied, hide it
|
||||
if (this.opt.type === 'password') {
|
||||
message += chalk.italic.dim('[hidden] ');
|
||||
} else {
|
||||
message += chalk.dim('(' + this.opt.default + ') ');
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
272
my-app/node_modules/inquirer/lib/prompts/checkbox.js
generated
vendored
Executable file
272
my-app/node_modules/inquirer/lib/prompts/checkbox.js
generated
vendored
Executable file
|
@ -0,0 +1,272 @@
|
|||
/**
|
||||
* `list` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import cliCursor from 'cli-cursor';
|
||||
import figures from 'figures';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Paginator from '../utils/paginator.js';
|
||||
import incrementListIndex from '../utils/incrementListIndex.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class CheckboxPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
if (Array.isArray(this.opt.default)) {
|
||||
this.opt.choices.forEach(function (choice) {
|
||||
if (this.opt.default.indexOf(choice.value) >= 0) {
|
||||
choice.checked = true;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
this.pointer = 0;
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
const events = observe(this.rl);
|
||||
|
||||
const validation = this.handleSubmitEvents(
|
||||
events.line.pipe(map(this.getCurrentValue.bind(this))),
|
||||
);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
events.normalizedUpKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
events.numberKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onNumberKey.bind(this));
|
||||
events.spaceKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onSpaceKey.bind(this));
|
||||
events.aKey.pipe(takeUntil(validation.success)).forEach(this.onAllKey.bind(this));
|
||||
events.iKey.pipe(takeUntil(validation.success)).forEach(this.onInverseKey.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
cliCursor.hide();
|
||||
this.render();
|
||||
this.firstRender = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {CheckboxPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
// Render question
|
||||
let message = this.getQuestion();
|
||||
let bottomContent = '';
|
||||
|
||||
if (!this.dontShowHints) {
|
||||
message +=
|
||||
'(Press ' +
|
||||
chalk.cyan.bold('<space>') +
|
||||
' to select, ' +
|
||||
chalk.cyan.bold('<a>') +
|
||||
' to toggle all, ' +
|
||||
chalk.cyan.bold('<i>') +
|
||||
' to invert selection, and ' +
|
||||
chalk.cyan.bold('<enter>') +
|
||||
' to proceed)';
|
||||
}
|
||||
|
||||
// Render choices or answer depending on the state
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.selection.join(', '));
|
||||
} else {
|
||||
const choicesStr = renderChoices(this.opt.choices, this.pointer);
|
||||
const indexPosition = this.opt.choices.indexOf(
|
||||
this.opt.choices.getChoice(this.pointer),
|
||||
);
|
||||
const realIndexPosition =
|
||||
this.opt.choices.reduce((acc, value, i) => {
|
||||
// Dont count lines past the choice we are looking at
|
||||
if (i > indexPosition) {
|
||||
return acc;
|
||||
}
|
||||
// Add line if it's a separator
|
||||
if (value.type === 'separator') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
let l = value.name;
|
||||
// Non-strings take up one line
|
||||
if (typeof l !== 'string') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
// Calculate lines taken up by string
|
||||
l = l.split('\n');
|
||||
return acc + l.length;
|
||||
}, 0) - 1;
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
bottomContent = chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onEnd(state) {
|
||||
this.status = 'answered';
|
||||
this.dontShowHints = true;
|
||||
// Rerender prompt (and clean subline error)
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
cliCursor.show();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
onError(state) {
|
||||
this.render(state.isValid);
|
||||
}
|
||||
|
||||
getCurrentValue() {
|
||||
const choices = this.opt.choices.filter(
|
||||
(choice) => Boolean(choice.checked) && !choice.disabled,
|
||||
);
|
||||
|
||||
this.selection = choices.map((choice) => choice.short);
|
||||
return choices.map((choice) => choice.value);
|
||||
}
|
||||
|
||||
onUpKey() {
|
||||
this.pointer = incrementListIndex(this.pointer, 'up', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onDownKey() {
|
||||
this.pointer = incrementListIndex(this.pointer, 'down', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onNumberKey(input) {
|
||||
if (input <= this.opt.choices.realLength) {
|
||||
this.pointer = input - 1;
|
||||
this.toggleChoice(this.pointer);
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
onSpaceKey() {
|
||||
this.toggleChoice(this.pointer);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onAllKey() {
|
||||
const shouldBeChecked = Boolean(
|
||||
this.opt.choices.find((choice) => choice.type !== 'separator' && !choice.checked),
|
||||
);
|
||||
|
||||
this.opt.choices.forEach((choice) => {
|
||||
if (choice.type !== 'separator') {
|
||||
choice.checked = shouldBeChecked;
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
onInverseKey() {
|
||||
this.opt.choices.forEach((choice) => {
|
||||
if (choice.type !== 'separator') {
|
||||
choice.checked = !choice.checked;
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
toggleChoice(index) {
|
||||
const item = this.opt.choices.getChoice(index);
|
||||
if (item !== undefined) {
|
||||
this.opt.choices.getChoice(index).checked = !item.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering checkbox choices
|
||||
* @param {Number} pointer Position of the pointer
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
|
||||
function renderChoices(choices, pointer) {
|
||||
let output = '';
|
||||
let separatorOffset = 0;
|
||||
|
||||
choices.forEach((choice, i) => {
|
||||
if (choice.type === 'separator') {
|
||||
separatorOffset++;
|
||||
output += ' ' + choice + '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
if (choice.disabled) {
|
||||
separatorOffset++;
|
||||
output += ' - ' + choice.name;
|
||||
output += ` (${
|
||||
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
|
||||
})`;
|
||||
} else {
|
||||
const line = getCheckbox(choice.checked) + ' ' + choice.name;
|
||||
if (i - separatorOffset === pointer) {
|
||||
output += chalk.cyan(figures.pointer + line);
|
||||
} else {
|
||||
output += ' ' + line;
|
||||
}
|
||||
}
|
||||
|
||||
output += '\n';
|
||||
});
|
||||
|
||||
return output.replace(/\n$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the checkbox
|
||||
* @param {Boolean} checked - add a X or not to the checkbox
|
||||
* @return {String} Composited checkbox string
|
||||
*/
|
||||
|
||||
function getCheckbox(checked) {
|
||||
return checked ? chalk.green(figures.radioOn) : figures.radioOff;
|
||||
}
|
99
my-app/node_modules/inquirer/lib/prompts/confirm.js
generated
vendored
Executable file
99
my-app/node_modules/inquirer/lib/prompts/confirm.js
generated
vendored
Executable file
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* `confirm` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { take, takeUntil } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class ConfirmPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
let rawDefault = true;
|
||||
|
||||
Object.assign(this.opt, {
|
||||
filter(input) {
|
||||
if (input != null && input !== '') {
|
||||
if (/^y(es)?/i.test(input)) return true;
|
||||
if (/^n(o)?/i.test(input)) return false;
|
||||
}
|
||||
return rawDefault;
|
||||
},
|
||||
});
|
||||
|
||||
if (this.opt.default != null) {
|
||||
rawDefault = Boolean(this.opt.default);
|
||||
}
|
||||
|
||||
this.opt.default = rawDefault ? 'Y/n' : 'y/N';
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
// Once user confirm (enter key)
|
||||
const events = observe(this.rl);
|
||||
events.keypress.pipe(takeUntil(events.line)).forEach(this.onKeypress.bind(this));
|
||||
|
||||
events.line.pipe(take(1)).forEach(this.onEnd.bind(this));
|
||||
|
||||
// Init
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {ConfirmPrompt} self
|
||||
*/
|
||||
|
||||
render(answer) {
|
||||
let message = this.getQuestion();
|
||||
|
||||
if (typeof answer === 'boolean') {
|
||||
message += chalk.cyan(answer ? 'Yes' : 'No');
|
||||
} else if (answer) {
|
||||
message += answer;
|
||||
} else {
|
||||
message += this.rl.line;
|
||||
}
|
||||
|
||||
this.screen.render(message);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onEnd(input) {
|
||||
this.status = 'answered';
|
||||
|
||||
let output = this.opt.filter(input);
|
||||
if (this.opt.transformer) {
|
||||
output = this.opt.transformer(output);
|
||||
}
|
||||
this.render(output);
|
||||
|
||||
this.screen.done();
|
||||
this.done(output);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
|
||||
onKeypress() {
|
||||
this.render();
|
||||
}
|
||||
}
|
105
my-app/node_modules/inquirer/lib/prompts/editor.js
generated
vendored
Executable file
105
my-app/node_modules/inquirer/lib/prompts/editor.js
generated
vendored
Executable file
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
* `editor` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { editAsync } from 'external-editor';
|
||||
import { Subject } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class EditorPrompt extends Base {
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
this.editorResult = new Subject();
|
||||
|
||||
// Open Editor on "line" (Enter Key)
|
||||
const events = observe(this.rl);
|
||||
this.lineSubscription = events.line.subscribe(this.startExternalEditor.bind(this));
|
||||
const waitUserInput =
|
||||
this.opt.waitUserInput === undefined ? true : this.opt.waitUserInput;
|
||||
|
||||
if (!waitUserInput) {
|
||||
this.startExternalEditor();
|
||||
}
|
||||
|
||||
// Trigger Validation when editor closes
|
||||
const validation = this.handleSubmitEvents(this.editorResult);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
// Prevents default from being printed on screen (can look weird with multiple lines)
|
||||
this.currentText = this.opt.default;
|
||||
this.opt.default = null;
|
||||
|
||||
// Init
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {EditorPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
let bottomContent = '';
|
||||
let message = this.getQuestion();
|
||||
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.dim('Received');
|
||||
} else {
|
||||
message += chalk.dim('Press <enter> to launch your preferred editor.');
|
||||
}
|
||||
|
||||
if (error) {
|
||||
bottomContent = chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch $EDITOR on user press enter
|
||||
*/
|
||||
|
||||
startExternalEditor() {
|
||||
// Pause Readline to prevent stdin and stdout from being modified while the editor is showing
|
||||
this.rl.pause();
|
||||
editAsync(this.currentText, this.endExternalEditor.bind(this), {
|
||||
postfix: this.opt.postfix ?? '.txt',
|
||||
});
|
||||
}
|
||||
|
||||
endExternalEditor(error, result) {
|
||||
this.rl.resume();
|
||||
if (error) {
|
||||
this.editorResult.error(error);
|
||||
} else {
|
||||
this.editorResult.next(result);
|
||||
}
|
||||
}
|
||||
|
||||
onEnd(state) {
|
||||
this.editorResult.unsubscribe();
|
||||
this.lineSubscription.unsubscribe();
|
||||
this.answer = state.value;
|
||||
this.status = 'answered';
|
||||
// Re-render prompt
|
||||
this.render();
|
||||
this.screen.done();
|
||||
this.done(this.answer);
|
||||
}
|
||||
|
||||
onError(state) {
|
||||
this.render(state.isValid);
|
||||
}
|
||||
}
|
270
my-app/node_modules/inquirer/lib/prompts/expand.js
generated
vendored
Executable file
270
my-app/node_modules/inquirer/lib/prompts/expand.js
generated
vendored
Executable file
|
@ -0,0 +1,270 @@
|
|||
/**
|
||||
* `rawlist` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import Separator from '../objects/separator.js';
|
||||
import observe from '../utils/events.js';
|
||||
import Paginator from '../utils/paginator.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class ExpandPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
this.validateChoices(this.opt.choices);
|
||||
|
||||
// Add the default `help` (/expand) option
|
||||
this.opt.choices.push({
|
||||
key: 'h',
|
||||
name: 'Help, list all options',
|
||||
value: 'help',
|
||||
});
|
||||
|
||||
this.opt.validate = (choice) => {
|
||||
if (choice == null) {
|
||||
return 'Please enter a valid command';
|
||||
}
|
||||
|
||||
return choice !== 'help';
|
||||
};
|
||||
|
||||
// Setup the default string (capitalize the default key)
|
||||
this.opt.default = this.generateChoicesString(this.opt.choices, this.opt.default);
|
||||
|
||||
this.paginator = new Paginator(this.screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
// Save user answer and update prompt to show selected option.
|
||||
const events = observe(this.rl);
|
||||
const validation = this.handleSubmitEvents(
|
||||
events.line.pipe(map(this.getCurrentValue.bind(this))),
|
||||
);
|
||||
validation.success.forEach(this.onSubmit.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
this.keypressObs = events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {ExpandPrompt} self
|
||||
*/
|
||||
|
||||
render(error, hint) {
|
||||
let message = this.getQuestion();
|
||||
let bottomContent = '';
|
||||
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.answer);
|
||||
} else if (this.status === 'expanded') {
|
||||
const choicesStr = renderChoices(this.opt.choices, this.selectedKey);
|
||||
message += this.paginator.paginate(choicesStr, this.selectedKey, this.opt.pageSize);
|
||||
message += '\n Answer: ';
|
||||
}
|
||||
|
||||
message += this.rl.line;
|
||||
|
||||
if (error) {
|
||||
bottomContent = chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
if (hint) {
|
||||
bottomContent = chalk.cyan('>> ') + hint;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
getCurrentValue(input) {
|
||||
if (!input) {
|
||||
input = this.rawDefault;
|
||||
}
|
||||
|
||||
const selected = this.opt.choices.where({ key: input.toLowerCase().trim() })[0];
|
||||
if (!selected) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return selected.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the prompt choices string
|
||||
* @return {String} Choices string
|
||||
*/
|
||||
|
||||
getChoices() {
|
||||
let output = '';
|
||||
|
||||
this.opt.choices.forEach((choice) => {
|
||||
output += '\n ';
|
||||
|
||||
if (choice.type === 'separator') {
|
||||
output += ' ' + choice;
|
||||
return;
|
||||
}
|
||||
|
||||
let choiceStr = choice.key + ') ' + choice.name;
|
||||
if (this.selectedKey === choice.key) {
|
||||
choiceStr = chalk.cyan(choiceStr);
|
||||
}
|
||||
|
||||
output += choiceStr;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
onError(state) {
|
||||
if (state.value === 'help') {
|
||||
this.selectedKey = '';
|
||||
this.status = 'expanded';
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
|
||||
this.render(state.isValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onSubmit(state) {
|
||||
this.status = 'answered';
|
||||
const choice = this.opt.choices.where({ value: state.value })[0];
|
||||
this.answer = choice.short || choice.name;
|
||||
|
||||
// Re-render prompt
|
||||
this.render();
|
||||
this.screen.done();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
|
||||
onKeypress() {
|
||||
this.selectedKey = this.rl.line.toLowerCase();
|
||||
const selected = this.opt.choices.where({ key: this.selectedKey })[0];
|
||||
if (this.status === 'expanded') {
|
||||
this.render();
|
||||
} else {
|
||||
this.render(null, selected ? selected.name : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the choices
|
||||
* @param {Array} choices
|
||||
*/
|
||||
|
||||
validateChoices(choices) {
|
||||
let formatError;
|
||||
const errors = [];
|
||||
const keymap = {};
|
||||
choices.filter(Separator.exclude).forEach((choice) => {
|
||||
if (!choice.key || choice.key.length !== 1) {
|
||||
formatError = true;
|
||||
}
|
||||
|
||||
choice.key = String(choice.key).toLowerCase();
|
||||
|
||||
if (keymap[choice.key]) {
|
||||
errors.push(choice.key);
|
||||
}
|
||||
|
||||
keymap[choice.key] = true;
|
||||
});
|
||||
|
||||
if (formatError) {
|
||||
throw new Error(
|
||||
'Format error: `key` param must be a single letter and is required.',
|
||||
);
|
||||
}
|
||||
|
||||
if (keymap.h) {
|
||||
throw new Error(
|
||||
'Reserved key error: `key` param cannot be `h` - this value is reserved.',
|
||||
);
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
throw new Error(
|
||||
'Duplicate key error: `key` param must be unique. Duplicates: ' +
|
||||
[...new Set(errors)].join(','),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a string out of the choices keys
|
||||
* @param {Array} choices
|
||||
* @param {Number|String} default - the choice index or name to capitalize
|
||||
* @return {String} The rendered choices key string
|
||||
*/
|
||||
generateChoicesString(choices, defaultChoice) {
|
||||
let defIndex = choices.realLength - 1;
|
||||
if (typeof defaultChoice === 'number' && this.opt.choices.getChoice(defaultChoice)) {
|
||||
defIndex = defaultChoice;
|
||||
} else if (typeof defaultChoice === 'string') {
|
||||
const index = choices.realChoices.findIndex(({ value }) => value === defaultChoice);
|
||||
defIndex = index === -1 ? defIndex : index;
|
||||
}
|
||||
|
||||
const defStr = this.opt.choices.pluck('key');
|
||||
this.rawDefault = defStr[defIndex];
|
||||
defStr[defIndex] = String(defStr[defIndex]).toUpperCase();
|
||||
return defStr.join('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering checkbox choices
|
||||
* @param {String} pointer Selected key
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
|
||||
function renderChoices(choices, pointer) {
|
||||
let output = '';
|
||||
|
||||
choices.forEach((choice) => {
|
||||
output += '\n ';
|
||||
|
||||
if (choice.type === 'separator') {
|
||||
output += ' ' + choice;
|
||||
return;
|
||||
}
|
||||
|
||||
let choiceStr = choice.key + ') ' + choice.name;
|
||||
if (pointer === choice.key) {
|
||||
choiceStr = chalk.cyan(choiceStr);
|
||||
}
|
||||
|
||||
output += choiceStr;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
107
my-app/node_modules/inquirer/lib/prompts/input.js
generated
vendored
Executable file
107
my-app/node_modules/inquirer/lib/prompts/input.js
generated
vendored
Executable file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* `input` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class InputPrompt extends Base {
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
// Once user confirm (enter key)
|
||||
const events = observe(this.rl);
|
||||
const submit = events.line.pipe(map(this.filterInput.bind(this)));
|
||||
|
||||
const validation = this.handleSubmitEvents(submit);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
|
||||
// Init
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {InputPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
let bottomContent = '';
|
||||
let appendContent = '';
|
||||
let message = this.getQuestion();
|
||||
const { transformer } = this.opt;
|
||||
const isFinal = this.status === 'answered';
|
||||
|
||||
if (isFinal) {
|
||||
appendContent = this.answer;
|
||||
} else {
|
||||
appendContent = this.rl.line;
|
||||
}
|
||||
|
||||
if (transformer) {
|
||||
message += transformer(appendContent, this.answers, { isFinal });
|
||||
} else {
|
||||
message += isFinal ? chalk.cyan(appendContent) : appendContent;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
bottomContent = chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
filterInput(input) {
|
||||
if (!input) {
|
||||
return this.opt.default == null ? '' : this.opt.default;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
onEnd(state) {
|
||||
this.answer = state.value;
|
||||
this.status = 'answered';
|
||||
|
||||
// Re-render prompt
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
onError({ value = '', isValid }) {
|
||||
this.rl.line += value;
|
||||
this.rl.cursor += value.length;
|
||||
this.render(isValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
|
||||
onKeypress() {
|
||||
this.status = 'touched';
|
||||
|
||||
this.render();
|
||||
}
|
||||
}
|
205
my-app/node_modules/inquirer/lib/prompts/list.js
generated
vendored
Executable file
205
my-app/node_modules/inquirer/lib/prompts/list.js
generated
vendored
Executable file
|
@ -0,0 +1,205 @@
|
|||
/**
|
||||
* `list` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import figures from 'figures';
|
||||
import cliCursor from 'cli-cursor';
|
||||
import runAsync from 'run-async';
|
||||
import { flatMap, map, take, takeUntil } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Paginator from '../utils/paginator.js';
|
||||
import incrementListIndex from '../utils/incrementListIndex.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class ListPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
this.firstRender = true;
|
||||
this.selected = 0;
|
||||
|
||||
const def = this.opt.default;
|
||||
|
||||
// If def is a Number, then use as index. Otherwise, check for value.
|
||||
if (typeof def === 'number' && def >= 0 && def < this.opt.choices.realLength) {
|
||||
this.selected = def;
|
||||
} else if (typeof def !== 'number' && def != null) {
|
||||
const index = this.opt.choices.realChoices.findIndex(({ value }) => value === def);
|
||||
this.selected = Math.max(index, 0);
|
||||
}
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
const self = this;
|
||||
|
||||
const events = observe(this.rl);
|
||||
events.normalizedUpKey.pipe(takeUntil(events.line)).forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(events.line))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
events.numberKey.pipe(takeUntil(events.line)).forEach(this.onNumberKey.bind(this));
|
||||
events.line
|
||||
.pipe(
|
||||
take(1),
|
||||
map(this.getCurrentValue.bind(this)),
|
||||
flatMap((value) =>
|
||||
runAsync(self.opt.filter)(value, self.answers).catch((err) => err),
|
||||
),
|
||||
)
|
||||
.forEach(this.onSubmit.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
cliCursor.hide();
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {ListPrompt} self
|
||||
*/
|
||||
|
||||
render() {
|
||||
// Render question
|
||||
let message = this.getQuestion();
|
||||
|
||||
if (this.firstRender) {
|
||||
message += chalk.dim('(Use arrow keys)');
|
||||
}
|
||||
|
||||
// Render choices or answer depending on the state
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.opt.choices.getChoice(this.selected).short);
|
||||
} else {
|
||||
const choicesStr = listRender(this.opt.choices, this.selected);
|
||||
const indexPosition = this.opt.choices.indexOf(
|
||||
this.opt.choices.getChoice(this.selected),
|
||||
);
|
||||
const realIndexPosition =
|
||||
this.opt.choices.reduce((acc, value, i) => {
|
||||
// Dont count lines past the choice we are looking at
|
||||
if (i > indexPosition) {
|
||||
return acc;
|
||||
}
|
||||
// Add line if it's a separator
|
||||
if (value.type === 'separator') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
let l = value.name;
|
||||
// Non-strings take up one line
|
||||
if (typeof l !== 'string') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
// Calculate lines taken up by string
|
||||
l = l.split('\n');
|
||||
return acc + l.length;
|
||||
}, 0) - 1;
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
|
||||
}
|
||||
|
||||
this.firstRender = false;
|
||||
|
||||
this.screen.render(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onSubmit(value) {
|
||||
this.status = 'answered';
|
||||
|
||||
// Rerender prompt
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
cliCursor.show();
|
||||
this.done(value);
|
||||
}
|
||||
|
||||
getCurrentValue() {
|
||||
return this.opt.choices.getChoice(this.selected).value;
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
onUpKey() {
|
||||
this.selected = incrementListIndex(this.selected, 'up', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onDownKey() {
|
||||
this.selected = incrementListIndex(this.selected, 'down', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onNumberKey(input) {
|
||||
if (input <= this.opt.choices.realLength) {
|
||||
this.selected = input - 1;
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering list choices
|
||||
* @param {Number} pointer Position of the pointer
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
function listRender(choices, pointer) {
|
||||
let output = '';
|
||||
let separatorOffset = 0;
|
||||
|
||||
choices.forEach((choice, i) => {
|
||||
if (choice.type === 'separator') {
|
||||
separatorOffset++;
|
||||
output += ' ' + choice + '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
if (choice.disabled) {
|
||||
separatorOffset++;
|
||||
output += ' - ' + choice.name;
|
||||
output += ` (${
|
||||
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
|
||||
})`;
|
||||
output += '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
const isSelected = i - separatorOffset === pointer;
|
||||
let line = (isSelected ? figures.pointer + ' ' : ' ') + choice.name;
|
||||
if (isSelected) {
|
||||
line = chalk.cyan(line);
|
||||
}
|
||||
|
||||
output += line + ' \n';
|
||||
});
|
||||
|
||||
return output.replace(/\n$/, '');
|
||||
}
|
26
my-app/node_modules/inquirer/lib/prompts/number.js
generated
vendored
Executable file
26
my-app/node_modules/inquirer/lib/prompts/number.js
generated
vendored
Executable file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* `input` type prompt
|
||||
*/
|
||||
|
||||
import Input from './input.js';
|
||||
|
||||
/**
|
||||
* Extention of the Input prompt specifically for use with number inputs.
|
||||
*/
|
||||
|
||||
export default class NumberPrompt extends Input {
|
||||
filterInput(input) {
|
||||
if (input && typeof input === 'string') {
|
||||
input = input.trim();
|
||||
// Match a number in the input
|
||||
const numberMatch = input.match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);
|
||||
// If a number is found, return that input.
|
||||
if (numberMatch) {
|
||||
return Number(numberMatch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// If the input was invalid return the default value.
|
||||
return this.opt.default == null ? NaN : this.opt.default;
|
||||
}
|
||||
}
|
124
my-app/node_modules/inquirer/lib/prompts/password.js
generated
vendored
Executable file
124
my-app/node_modules/inquirer/lib/prompts/password.js
generated
vendored
Executable file
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* `password` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import observe from '../utils/events.js';
|
||||
import Base from './base.js';
|
||||
|
||||
function mask(input, maskChar) {
|
||||
input = String(input);
|
||||
maskChar = typeof maskChar === 'string' ? maskChar : '*';
|
||||
if (input.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return new Array(input.length + 1).join(maskChar);
|
||||
}
|
||||
|
||||
export default class PasswordPrompt extends Base {
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
const events = observe(this.rl);
|
||||
|
||||
// Once user confirm (enter key)
|
||||
const submit = events.line.pipe(map(this.filterInput.bind(this)));
|
||||
|
||||
const validation = this.handleSubmitEvents(submit);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
|
||||
// Init
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {PasswordPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
let message = this.getQuestion();
|
||||
let bottomContent = '';
|
||||
|
||||
if (this.status === 'answered') {
|
||||
message += this.getMaskedValue(this.answer);
|
||||
} else {
|
||||
message += this.getMaskedValue(this.rl.line || '');
|
||||
}
|
||||
|
||||
if (error) {
|
||||
bottomContent = '\n' + chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
getMaskedValue(value) {
|
||||
if (this.status === 'answered') {
|
||||
return this.opt.mask
|
||||
? chalk.cyan(mask(value, this.opt.mask))
|
||||
: chalk.italic.dim('[hidden]');
|
||||
}
|
||||
return this.opt.mask
|
||||
? mask(value, this.opt.mask)
|
||||
: chalk.italic.dim('[input is hidden] ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mask value during async filter/validation.
|
||||
*/
|
||||
getSpinningValue(value) {
|
||||
return this.getMaskedValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
filterInput(input) {
|
||||
if (!input) {
|
||||
return this.opt.default == null ? '' : this.opt.default;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
onEnd(state) {
|
||||
this.status = 'answered';
|
||||
this.answer = state.value;
|
||||
|
||||
// Re-render prompt
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
onError(state) {
|
||||
this.render(state.isValid);
|
||||
}
|
||||
|
||||
onKeypress() {
|
||||
// If user press a key, just clear the default value
|
||||
if (this.opt.default) {
|
||||
this.opt.default = undefined;
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
}
|
225
my-app/node_modules/inquirer/lib/prompts/rawlist.js
generated
vendored
Executable file
225
my-app/node_modules/inquirer/lib/prompts/rawlist.js
generated
vendored
Executable file
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* `rawlist` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import Separator from '../objects/separator.js';
|
||||
import observe from '../utils/events.js';
|
||||
import Paginator from '../utils/paginator.js';
|
||||
import incrementListIndex from '../utils/incrementListIndex.js';
|
||||
import Base from './base.js';
|
||||
|
||||
export default class RawListPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
this.hiddenLine = '';
|
||||
this.lastKey = '';
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
this.opt.validChoices = this.opt.choices.filter(Separator.exclude);
|
||||
|
||||
this.selected = 0;
|
||||
this.rawDefault = 0;
|
||||
|
||||
Object.assign(this.opt, {
|
||||
validate(val) {
|
||||
return val != null;
|
||||
},
|
||||
});
|
||||
|
||||
const def = this.opt.default;
|
||||
if (typeof def === 'number' && def >= 0 && def < this.opt.choices.realLength) {
|
||||
this.selected = def;
|
||||
this.rawDefault = def;
|
||||
} else if (typeof def !== 'number' && def != null) {
|
||||
const index = this.opt.choices.realChoices.findIndex(({ value }) => value === def);
|
||||
const safeIndex = Math.max(index, 0);
|
||||
this.selected = safeIndex;
|
||||
this.rawDefault = safeIndex;
|
||||
}
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(undefined, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
// Once user confirm (enter key)
|
||||
const events = observe(this.rl);
|
||||
const submit = events.line.pipe(map(this.getCurrentValue.bind(this)));
|
||||
|
||||
const validation = this.handleSubmitEvents(submit);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
events.normalizedUpKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
// Init the prompt
|
||||
this.render();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {RawListPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
// Render question
|
||||
let message = this.getQuestion();
|
||||
let bottomContent = '';
|
||||
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.opt.choices.getChoice(this.selected).short);
|
||||
} else {
|
||||
const choicesStr = renderChoices(this.opt.choices, this.selected);
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, this.selected, this.opt.pageSize);
|
||||
message += '\n Answer: ';
|
||||
}
|
||||
message += this.rl.line;
|
||||
|
||||
if (error) {
|
||||
bottomContent = '\n' + chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
getCurrentValue(index) {
|
||||
if (index == null) {
|
||||
index = this.rawDefault;
|
||||
} else if (index === '') {
|
||||
this.selected = this.selected === undefined ? -1 : this.selected;
|
||||
index = this.selected;
|
||||
} else {
|
||||
index -= 1;
|
||||
}
|
||||
|
||||
const choice = this.opt.choices.getChoice(index);
|
||||
return choice ? choice.value : null;
|
||||
}
|
||||
|
||||
onEnd(state) {
|
||||
this.status = 'answered';
|
||||
this.answer = state.value;
|
||||
|
||||
// Re-render prompt
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
onError() {
|
||||
this.render('Please enter a valid index');
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press a key
|
||||
*/
|
||||
|
||||
onKeypress() {
|
||||
let index;
|
||||
|
||||
if (this.lastKey === 'arrow') {
|
||||
index = this.hiddenLine.length ? Number(this.hiddenLine) - 1 : 0;
|
||||
} else {
|
||||
index = this.rl.line.length ? Number(this.rl.line) - 1 : 0;
|
||||
}
|
||||
this.lastKey = '';
|
||||
|
||||
if (this.opt.choices.getChoice(index)) {
|
||||
this.selected = index;
|
||||
} else {
|
||||
this.selected = undefined;
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press up key
|
||||
*/
|
||||
|
||||
onUpKey() {
|
||||
this.onArrowKey('up');
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press down key
|
||||
*/
|
||||
|
||||
onDownKey() {
|
||||
this.onArrowKey('down');
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press up or down key
|
||||
* @param {String} type Arrow type: up or down
|
||||
*/
|
||||
|
||||
onArrowKey(type) {
|
||||
this.selected = incrementListIndex(this.selected, type, this.opt) || 0;
|
||||
this.hiddenLine = String(this.selected + 1);
|
||||
this.rl.line = '';
|
||||
this.lastKey = 'arrow';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering list choices
|
||||
* @param {Number} pointer Position of the pointer
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
|
||||
function renderChoices(choices, pointer) {
|
||||
let output = '';
|
||||
let separatorOffset = 0;
|
||||
|
||||
choices.forEach((choice, i) => {
|
||||
output += output ? '\n ' : ' ';
|
||||
|
||||
if (choice.type === 'separator') {
|
||||
separatorOffset++;
|
||||
output += ' ' + choice;
|
||||
return;
|
||||
}
|
||||
|
||||
const index = i - separatorOffset;
|
||||
let display = index + 1 + ') ' + choice.name;
|
||||
if (index === pointer) {
|
||||
display = chalk.cyan(display);
|
||||
}
|
||||
|
||||
output += display;
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
89
my-app/node_modules/inquirer/lib/ui/baseUI.js
generated
vendored
Executable file
89
my-app/node_modules/inquirer/lib/ui/baseUI.js
generated
vendored
Executable file
|
@ -0,0 +1,89 @@
|
|||
import readline from 'node:readline';
|
||||
import MuteStream from 'mute-stream';
|
||||
|
||||
/**
|
||||
* Base interface class other can inherits from
|
||||
*/
|
||||
|
||||
export default class UI {
|
||||
constructor(opt) {
|
||||
// Instantiate the Readline interface
|
||||
// @Note: Don't reassign if already present (allow test to override the Stream)
|
||||
if (!this.rl) {
|
||||
this.rl = readline.createInterface(setupReadlineOptions(opt));
|
||||
}
|
||||
|
||||
this.rl.resume();
|
||||
|
||||
this.onForceClose = this.onForceClose.bind(this);
|
||||
|
||||
// Make sure new prompt start on a newline when closing
|
||||
process.on('exit', this.onForceClose);
|
||||
|
||||
// Terminate process on SIGINT (which will call process.on('exit') in return)
|
||||
this.rl.on('SIGINT', this.onForceClose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the ^C exit
|
||||
* @return {null}
|
||||
*/
|
||||
|
||||
onForceClose() {
|
||||
this.close();
|
||||
process.kill(process.pid, 'SIGINT');
|
||||
console.log('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the interface and cleanup listeners
|
||||
*/
|
||||
|
||||
close() {
|
||||
// Remove events listeners
|
||||
this.rl.removeListener('SIGINT', this.onForceClose);
|
||||
process.removeListener('exit', this.onForceClose);
|
||||
|
||||
this.rl.output.unmute();
|
||||
|
||||
if (this.activePrompt && typeof this.activePrompt.close === 'function') {
|
||||
this.activePrompt.close();
|
||||
}
|
||||
|
||||
// Close the readline
|
||||
this.rl.output.end();
|
||||
this.rl.pause();
|
||||
this.rl.close();
|
||||
}
|
||||
}
|
||||
|
||||
function setupReadlineOptions(opt = {}) {
|
||||
// Inquirer 8.x:
|
||||
// opt.skipTTYChecks = opt.skipTTYChecks === undefined ? opt.input !== undefined : opt.skipTTYChecks;
|
||||
opt.skipTTYChecks = opt.skipTTYChecks === undefined ? true : opt.skipTTYChecks;
|
||||
|
||||
// Default `input` to stdin
|
||||
const input = opt.input || process.stdin;
|
||||
|
||||
// Check if prompt is being called in TTY environment
|
||||
// If it isn't return a failed promise
|
||||
if (!opt.skipTTYChecks && !input.isTTY) {
|
||||
const nonTtyError = new Error(
|
||||
'Prompts can not be meaningfully rendered in non-TTY environments',
|
||||
);
|
||||
nonTtyError.isTtyError = true;
|
||||
throw nonTtyError;
|
||||
}
|
||||
|
||||
// Add mute capabilities to the output
|
||||
const ms = new MuteStream();
|
||||
ms.pipe(opt.output || process.stdout);
|
||||
const output = ms;
|
||||
|
||||
return {
|
||||
terminal: true,
|
||||
...opt,
|
||||
input,
|
||||
output,
|
||||
};
|
||||
}
|
93
my-app/node_modules/inquirer/lib/ui/bottom-bar.js
generated
vendored
Executable file
93
my-app/node_modules/inquirer/lib/ui/bottom-bar.js
generated
vendored
Executable file
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Sticky bottom bar user interface
|
||||
*/
|
||||
|
||||
import through from '@ljharb/through';
|
||||
import * as rlUtils from '../utils/readline.js';
|
||||
import Base from './baseUI.js';
|
||||
|
||||
export default class BottomBar extends Base {
|
||||
constructor(opt = {}) {
|
||||
super(opt);
|
||||
|
||||
this.log = through(this.writeLog.bind(this));
|
||||
this.bottomBar = opt.bottomBar || '';
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
render() {
|
||||
this.write(this.bottomBar);
|
||||
return this;
|
||||
}
|
||||
|
||||
clean() {
|
||||
rlUtils.clearLine(this.rl, this.bottomBar.split('\n').length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the bottom bar content and rerender
|
||||
* @param {String} bottomBar Bottom bar content
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
updateBottomBar(bottomBar) {
|
||||
rlUtils.clearLine(this.rl, 1);
|
||||
this.rl.output.unmute();
|
||||
this.clean();
|
||||
this.bottomBar = bottomBar;
|
||||
this.render();
|
||||
this.rl.output.mute();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out log data
|
||||
* @param {String} data - The log data to be output
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
writeLog(data) {
|
||||
this.rl.output.unmute();
|
||||
this.clean();
|
||||
this.rl.output.write(this.enforceLF(data.toString()));
|
||||
this.render();
|
||||
this.rl.output.mute();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure line end on a line feed
|
||||
* @param {String} str Input string
|
||||
* @return {String} The input string with a final line feed
|
||||
*/
|
||||
|
||||
enforceLF(str) {
|
||||
return str.match(/[\r\n]$/) ? str : str + '\n';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for writing message in Prompt
|
||||
* @param {String} message - The message to be output
|
||||
*/
|
||||
write(message) {
|
||||
const msgLines = message.split(/\n/);
|
||||
this.height = msgLines.length;
|
||||
|
||||
// Write message to screen and setPrompt to control backspace
|
||||
this.rl.setPrompt(msgLines[msgLines.length - 1]);
|
||||
|
||||
if (this.rl.output.rows === 0 && this.rl.output.columns === 0) {
|
||||
/* When it's a tty through serial port there's no terminal info and the render will malfunction,
|
||||
so we need enforce the cursor to locate to the leftmost position for rendering. */
|
||||
rlUtils.left(this.rl, message.length + this.rl.line.length);
|
||||
}
|
||||
|
||||
this.rl.output.write(message);
|
||||
}
|
||||
}
|
145
my-app/node_modules/inquirer/lib/ui/prompt.js
generated
vendored
Executable file
145
my-app/node_modules/inquirer/lib/ui/prompt.js
generated
vendored
Executable file
|
@ -0,0 +1,145 @@
|
|||
import isPlainObject from 'lodash/isPlainObject.js';
|
||||
import get from 'lodash/get.js';
|
||||
import set from 'lodash/set.js';
|
||||
|
||||
const _ = {
|
||||
isPlainObject,
|
||||
set,
|
||||
get,
|
||||
};
|
||||
import { defer, empty, from, of, concatMap, filter, publish, reduce } from 'rxjs';
|
||||
import runAsync from 'run-async';
|
||||
import * as utils from '../utils/utils.js';
|
||||
import Base from './baseUI.js';
|
||||
|
||||
/**
|
||||
* Base interface class other can inherits from
|
||||
*/
|
||||
export default class PromptUI extends Base {
|
||||
constructor(prompts, opt) {
|
||||
super(opt);
|
||||
this.prompts = prompts;
|
||||
}
|
||||
|
||||
run(questions, answers) {
|
||||
// Keep global reference to the answers
|
||||
if (_.isPlainObject(answers)) {
|
||||
this.answers = { ...answers };
|
||||
} else {
|
||||
this.answers = {};
|
||||
}
|
||||
|
||||
// Make sure questions is an array.
|
||||
if (_.isPlainObject(questions)) {
|
||||
// It's either an object of questions or a single question
|
||||
questions = Object.values(questions).every(
|
||||
(v) => _.isPlainObject(v) && v.name === undefined,
|
||||
)
|
||||
? Object.entries(questions).map(([name, question]) => ({ name, ...question }))
|
||||
: [questions];
|
||||
}
|
||||
|
||||
// Create an observable, unless we received one as parameter.
|
||||
// Note: As this is a public interface, we cannot do an instanceof check as we won't
|
||||
// be using the exact same object in memory.
|
||||
const obs = Array.isArray(questions) ? from(questions) : questions;
|
||||
|
||||
this.process = obs.pipe(
|
||||
concatMap(this.processQuestion.bind(this)),
|
||||
publish(), // Creates a hot Observable. It prevents duplicating prompts.
|
||||
);
|
||||
|
||||
this.process.connect();
|
||||
|
||||
return this.process
|
||||
.pipe(
|
||||
reduce((answersObj, answer) => {
|
||||
_.set(answersObj, answer.name, answer.answer);
|
||||
return answersObj;
|
||||
}, this.answers),
|
||||
)
|
||||
.toPromise(Promise)
|
||||
.then(this.onCompletion.bind(this), this.onError.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Once all prompt are over
|
||||
*/
|
||||
onCompletion() {
|
||||
this.close();
|
||||
|
||||
return this.answers;
|
||||
}
|
||||
|
||||
onError(error) {
|
||||
this.close();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
processQuestion(question) {
|
||||
question = { ...question };
|
||||
return defer(() => {
|
||||
const obs = of(question);
|
||||
|
||||
return obs.pipe(
|
||||
concatMap(this.setDefaultType.bind(this)),
|
||||
concatMap(this.filterIfRunnable.bind(this)),
|
||||
concatMap(() =>
|
||||
utils.fetchAsyncQuestionProperty(question, 'message', this.answers),
|
||||
),
|
||||
concatMap(() =>
|
||||
utils.fetchAsyncQuestionProperty(question, 'default', this.answers),
|
||||
),
|
||||
concatMap(() =>
|
||||
utils.fetchAsyncQuestionProperty(question, 'choices', this.answers),
|
||||
),
|
||||
concatMap(this.fetchAnswer.bind(this)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
fetchAnswer(question) {
|
||||
const Prompt = this.prompts[question.type];
|
||||
this.activePrompt = new Prompt(question, this.rl, this.answers);
|
||||
return defer(() =>
|
||||
from(this.activePrompt.run().then((answer) => ({ name: question.name, answer }))),
|
||||
);
|
||||
}
|
||||
|
||||
setDefaultType(question) {
|
||||
// Default type to input
|
||||
if (!this.prompts[question.type]) {
|
||||
question.type = 'input';
|
||||
}
|
||||
|
||||
return defer(() => of(question));
|
||||
}
|
||||
|
||||
filterIfRunnable(question) {
|
||||
if (
|
||||
question.askAnswered !== true &&
|
||||
_.get(this.answers, question.name) !== undefined
|
||||
) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
if (question.when === false) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
if (typeof question.when !== 'function') {
|
||||
return of(question);
|
||||
}
|
||||
|
||||
const { answers } = this;
|
||||
return defer(() =>
|
||||
from(
|
||||
runAsync(question.when)(answers).then((shouldRun) => {
|
||||
if (shouldRun) {
|
||||
return question;
|
||||
}
|
||||
}),
|
||||
).pipe(filter((val) => val != null)),
|
||||
);
|
||||
}
|
||||
}
|
52
my-app/node_modules/inquirer/lib/utils/events.js
generated
vendored
Executable file
52
my-app/node_modules/inquirer/lib/utils/events.js
generated
vendored
Executable file
|
@ -0,0 +1,52 @@
|
|||
import { fromEvent, filter, map, share, takeUntil } from 'rxjs';
|
||||
|
||||
function normalizeKeypressEvents(value, key) {
|
||||
return { value, key: key || {} };
|
||||
}
|
||||
|
||||
export default function (rl) {
|
||||
const keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents)
|
||||
.pipe(takeUntil(fromEvent(rl, 'close')))
|
||||
// Ignore `enter` key. On the readline, we only care about the `line` event.
|
||||
.pipe(filter(({ key }) => key.name !== 'enter' && key.name !== 'return'));
|
||||
|
||||
return {
|
||||
line: fromEvent(rl, 'line'),
|
||||
keypress,
|
||||
|
||||
normalizedUpKey: keypress.pipe(
|
||||
filter(
|
||||
({ key }) =>
|
||||
key.name === 'up' || key.name === 'k' || (key.name === 'p' && key.ctrl),
|
||||
),
|
||||
share(),
|
||||
),
|
||||
|
||||
normalizedDownKey: keypress.pipe(
|
||||
filter(
|
||||
({ key }) =>
|
||||
key.name === 'down' || key.name === 'j' || (key.name === 'n' && key.ctrl),
|
||||
),
|
||||
share(),
|
||||
),
|
||||
|
||||
numberKey: keypress.pipe(
|
||||
filter((e) => e.value && '123456789'.indexOf(e.value) >= 0),
|
||||
map((e) => Number(e.value)),
|
||||
share(),
|
||||
),
|
||||
|
||||
spaceKey: keypress.pipe(
|
||||
filter(({ key }) => key && key.name === 'space'),
|
||||
share(),
|
||||
),
|
||||
aKey: keypress.pipe(
|
||||
filter(({ key }) => key && key.name === 'a'),
|
||||
share(),
|
||||
),
|
||||
iKey: keypress.pipe(
|
||||
filter(({ key }) => key && key.name === 'i'),
|
||||
share(),
|
||||
),
|
||||
};
|
||||
}
|
17
my-app/node_modules/inquirer/lib/utils/incrementListIndex.js
generated
vendored
Executable file
17
my-app/node_modules/inquirer/lib/utils/incrementListIndex.js
generated
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
export default function incrementListIndex(current, dir, opt) {
|
||||
const len = opt.choices.realLength;
|
||||
const shouldLoop = 'loop' in opt ? Boolean(opt.loop) : true;
|
||||
if (dir === 'up') {
|
||||
if (current > 0) {
|
||||
return current - 1;
|
||||
}
|
||||
return shouldLoop ? len - 1 : current;
|
||||
}
|
||||
if (dir === 'down') {
|
||||
if (current < len - 1) {
|
||||
return current + 1;
|
||||
}
|
||||
return shouldLoop ? 0 : current;
|
||||
}
|
||||
throw new Error('dir must be up or down');
|
||||
}
|
77
my-app/node_modules/inquirer/lib/utils/paginator.js
generated
vendored
Executable file
77
my-app/node_modules/inquirer/lib/utils/paginator.js
generated
vendored
Executable file
|
@ -0,0 +1,77 @@
|
|||
import chalk from 'chalk';
|
||||
|
||||
/**
|
||||
* The paginator returns a subset of the choices if the list is too long.
|
||||
*/
|
||||
|
||||
export default class Paginator {
|
||||
/**
|
||||
* @param {import("./screen-manager")} [screen]
|
||||
* @param {{isInfinite?: boolean}} [options]
|
||||
*/
|
||||
constructor(screen, options = {}) {
|
||||
const { isInfinite = true } = options;
|
||||
this.lastIndex = 0;
|
||||
this.screen = screen;
|
||||
this.isInfinite = isInfinite;
|
||||
}
|
||||
|
||||
paginate(output, active, pageSize) {
|
||||
pageSize = pageSize || 7;
|
||||
let lines = output.split('\n');
|
||||
|
||||
if (this.screen) {
|
||||
lines = this.screen.breakLines(lines);
|
||||
active = lines
|
||||
.map((lineParts) => lineParts.length)
|
||||
.splice(0, active)
|
||||
.reduce((a, b) => a + b, 0);
|
||||
lines = lines.flat();
|
||||
}
|
||||
|
||||
// Make sure there's enough lines to paginate
|
||||
if (lines.length <= pageSize) {
|
||||
return output;
|
||||
}
|
||||
const visibleLines = this.isInfinite
|
||||
? this.getInfiniteLines(lines, active, pageSize)
|
||||
: this.getFiniteLines(lines, active, pageSize);
|
||||
this.lastIndex = active;
|
||||
return (
|
||||
visibleLines.join('\n') +
|
||||
'\n' +
|
||||
chalk.dim('(Move up and down to reveal more choices)')
|
||||
);
|
||||
}
|
||||
|
||||
getInfiniteLines(lines, active, pageSize) {
|
||||
if (this.pointer === undefined) {
|
||||
this.pointer = 0;
|
||||
}
|
||||
const middleOfList = Math.floor(pageSize / 2);
|
||||
// Move the pointer only when the user go down and limit it to the middle of the list
|
||||
if (
|
||||
this.pointer < middleOfList &&
|
||||
this.lastIndex < active &&
|
||||
active - this.lastIndex < pageSize
|
||||
) {
|
||||
this.pointer = Math.min(middleOfList, this.pointer + active - this.lastIndex);
|
||||
}
|
||||
|
||||
// Duplicate the lines so it give an infinite list look
|
||||
const infinite = [lines, lines, lines].flat();
|
||||
const topIndex = Math.max(0, active + lines.length - this.pointer);
|
||||
|
||||
return infinite.splice(topIndex, pageSize);
|
||||
}
|
||||
|
||||
getFiniteLines(lines, active, pageSize) {
|
||||
let topIndex = active - pageSize / 2;
|
||||
if (topIndex < 0) {
|
||||
topIndex = 0;
|
||||
} else if (topIndex + pageSize > lines.length) {
|
||||
topIndex = lines.length - pageSize;
|
||||
}
|
||||
return lines.splice(topIndex, pageSize);
|
||||
}
|
||||
}
|
50
my-app/node_modules/inquirer/lib/utils/readline.js
generated
vendored
Executable file
50
my-app/node_modules/inquirer/lib/utils/readline.js
generated
vendored
Executable file
|
@ -0,0 +1,50 @@
|
|||
import ansiEscapes from 'ansi-escapes';
|
||||
|
||||
/**
|
||||
* Move cursor left by `x`
|
||||
* @param {Readline} rl - Readline instance
|
||||
* @param {Number} x - How far to go left (default to 1)
|
||||
*/
|
||||
|
||||
export const left = function (rl, x) {
|
||||
rl.output.write(ansiEscapes.cursorBackward(x));
|
||||
};
|
||||
|
||||
/**
|
||||
* Move cursor right by `x`
|
||||
* @param {Readline} rl - Readline instance
|
||||
* @param {Number} x - How far to go left (default to 1)
|
||||
*/
|
||||
|
||||
export const right = function (rl, x) {
|
||||
rl.output.write(ansiEscapes.cursorForward(x));
|
||||
};
|
||||
|
||||
/**
|
||||
* Move cursor up by `x`
|
||||
* @param {Readline} rl - Readline instance
|
||||
* @param {Number} x - How far to go up (default to 1)
|
||||
*/
|
||||
|
||||
export const up = function (rl, x) {
|
||||
rl.output.write(ansiEscapes.cursorUp(x));
|
||||
};
|
||||
|
||||
/**
|
||||
* Move cursor down by `x`
|
||||
* @param {Readline} rl - Readline instance
|
||||
* @param {Number} x - How far to go down (default to 1)
|
||||
*/
|
||||
|
||||
export const down = function (rl, x) {
|
||||
rl.output.write(ansiEscapes.cursorDown(x));
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear current line
|
||||
* @param {Readline} rl - Readline instance
|
||||
* @param {Number} len - number of line to delete
|
||||
*/
|
||||
export const clearLine = function (rl, len) {
|
||||
rl.output.write(ansiEscapes.eraseLines(len));
|
||||
};
|
173
my-app/node_modules/inquirer/lib/utils/screen-manager.js
generated
vendored
Executable file
173
my-app/node_modules/inquirer/lib/utils/screen-manager.js
generated
vendored
Executable file
|
@ -0,0 +1,173 @@
|
|||
import cliWidth from 'cli-width';
|
||||
import wrapAnsi from 'wrap-ansi';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import stringWidth from 'string-width';
|
||||
import ora from 'ora';
|
||||
import * as util from './readline.js';
|
||||
|
||||
function height(content) {
|
||||
return content.split('\n').length;
|
||||
}
|
||||
|
||||
/** @param {string} content */
|
||||
function lastLine(content) {
|
||||
return content.split('\n').pop();
|
||||
}
|
||||
|
||||
export default class ScreenManager {
|
||||
constructor(rl) {
|
||||
// These variables are keeping information to allow correct prompt re-rendering
|
||||
this.height = 0;
|
||||
this.extraLinesUnderPrompt = 0;
|
||||
|
||||
this.rl = rl;
|
||||
}
|
||||
|
||||
renderWithSpinner(content, bottomContent) {
|
||||
if (this.spinnerId) {
|
||||
clearInterval(this.spinnerId);
|
||||
}
|
||||
|
||||
let spinner;
|
||||
let contentFunc;
|
||||
let bottomContentFunc;
|
||||
|
||||
if (bottomContent) {
|
||||
spinner = ora(bottomContent);
|
||||
contentFunc = () => content;
|
||||
bottomContentFunc = () => spinner.frame();
|
||||
} else {
|
||||
spinner = ora(content);
|
||||
contentFunc = () => spinner.frame();
|
||||
bottomContentFunc = () => '';
|
||||
}
|
||||
|
||||
this.spinnerId = setInterval(
|
||||
() => this.render(contentFunc(), bottomContentFunc(), true),
|
||||
spinner.interval,
|
||||
);
|
||||
}
|
||||
|
||||
render(content, bottomContent, spinning = false) {
|
||||
if (this.spinnerId && !spinning) {
|
||||
clearInterval(this.spinnerId);
|
||||
}
|
||||
|
||||
this.rl.output.unmute();
|
||||
this.clean(this.extraLinesUnderPrompt);
|
||||
|
||||
/**
|
||||
* Write message to screen and setPrompt to control backspace
|
||||
*/
|
||||
|
||||
const promptLine = lastLine(content);
|
||||
const rawPromptLine = stripAnsi(promptLine);
|
||||
|
||||
// Remove the rl.line from our prompt. We can't rely on the content of
|
||||
// rl.line (mainly because of the password prompt), so just rely on it's
|
||||
// length.
|
||||
let prompt = rawPromptLine;
|
||||
if (this.rl.line.length) {
|
||||
prompt = prompt.slice(0, -this.rl.line.length);
|
||||
}
|
||||
|
||||
this.rl.setPrompt(prompt);
|
||||
|
||||
// SetPrompt will change cursor position, now we can get correct value
|
||||
const cursorPos = this.rl._getCursorPos();
|
||||
const width = this.normalizedCliWidth();
|
||||
|
||||
content = this.forceLineReturn(content, width);
|
||||
if (bottomContent) {
|
||||
bottomContent = this.forceLineReturn(bottomContent, width);
|
||||
}
|
||||
|
||||
// Manually insert an extra line if we're at the end of the line.
|
||||
// This prevent the cursor from appearing at the beginning of the
|
||||
// current line.
|
||||
if (rawPromptLine.length % width === 0) {
|
||||
content += '\n';
|
||||
}
|
||||
|
||||
const fullContent = content + (bottomContent ? '\n' + bottomContent : '');
|
||||
this.rl.output.write(fullContent);
|
||||
|
||||
/**
|
||||
* Re-adjust the cursor at the correct position.
|
||||
*/
|
||||
|
||||
// We need to consider parts of the prompt under the cursor as part of the bottom
|
||||
// content in order to correctly cleanup and re-render.
|
||||
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - cursorPos.rows;
|
||||
const bottomContentHeight =
|
||||
promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
||||
if (bottomContentHeight > 0) {
|
||||
util.up(this.rl, bottomContentHeight);
|
||||
}
|
||||
|
||||
// Reset cursor at the beginning of the line
|
||||
util.left(this.rl, stringWidth(lastLine(fullContent)));
|
||||
|
||||
// Adjust cursor on the right
|
||||
if (cursorPos.cols > 0) {
|
||||
util.right(this.rl, cursorPos.cols);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up state for next re-rendering
|
||||
*/
|
||||
this.extraLinesUnderPrompt = bottomContentHeight;
|
||||
this.height = height(fullContent);
|
||||
|
||||
this.rl.output.mute();
|
||||
}
|
||||
|
||||
clean(extraLines) {
|
||||
if (extraLines > 0) {
|
||||
util.down(this.rl, extraLines);
|
||||
}
|
||||
|
||||
util.clearLine(this.rl, this.height);
|
||||
}
|
||||
|
||||
done() {
|
||||
this.rl.setPrompt('');
|
||||
this.rl.output.unmute();
|
||||
this.rl.output.write('\n');
|
||||
}
|
||||
|
||||
releaseCursor() {
|
||||
if (this.extraLinesUnderPrompt > 0) {
|
||||
util.down(this.rl, this.extraLinesUnderPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
normalizedCliWidth() {
|
||||
const width = cliWidth({
|
||||
defaultWidth: 80,
|
||||
output: this.rl.output,
|
||||
});
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} lines
|
||||
*/
|
||||
breakLines(lines, width = this.normalizedCliWidth()) {
|
||||
// Break lines who're longer than the cli width so we can normalize the natural line
|
||||
// returns behavior across terminals.
|
||||
// re: trim: false; by default, `wrap-ansi` trims whitespace, which
|
||||
// is not what we want.
|
||||
// re: hard: true; by default', `wrap-ansi` does soft wrapping
|
||||
return lines.map((line) =>
|
||||
wrapAnsi(line, width, { trim: false, hard: true }).split('\n'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} content
|
||||
*/
|
||||
forceLineReturn(content, width = this.normalizedCliWidth()) {
|
||||
return this.breakLines(content.split('\n'), width).flat().join('\n');
|
||||
}
|
||||
}
|
24
my-app/node_modules/inquirer/lib/utils/utils.js
generated
vendored
Executable file
24
my-app/node_modules/inquirer/lib/utils/utils.js
generated
vendored
Executable file
|
@ -0,0 +1,24 @@
|
|||
import { from, of } from 'rxjs';
|
||||
import runAsync from 'run-async';
|
||||
|
||||
/**
|
||||
* Resolve a question property value if it is passed as a function.
|
||||
* This method will overwrite the property on the question object with the received value.
|
||||
* @param {Object} question - Question object
|
||||
* @param {String} prop - Property to fetch name
|
||||
* @param {Object} answers - Answers object
|
||||
* @return {Rx.Observable} - Observable emitting once value is known
|
||||
*/
|
||||
|
||||
export const fetchAsyncQuestionProperty = function (question, prop, answers) {
|
||||
if (typeof question[prop] !== 'function') {
|
||||
return of(question);
|
||||
}
|
||||
|
||||
return from(
|
||||
runAsync(question[prop])(answers).then((value) => {
|
||||
question[prop] = value;
|
||||
return question;
|
||||
}),
|
||||
);
|
||||
};
|
9
my-app/node_modules/inquirer/node_modules/chalk/license
generated
vendored
Executable file
9
my-app/node_modules/inquirer/node_modules/chalk/license
generated
vendored
Executable file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
83
my-app/node_modules/inquirer/node_modules/chalk/package.json
generated
vendored
Executable file
83
my-app/node_modules/inquirer/node_modules/chalk/package.json
generated
vendored
Executable file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"name": "chalk",
|
||||
"version": "5.3.0",
|
||||
"description": "Terminal string styling done right",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/chalk",
|
||||
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
||||
"type": "module",
|
||||
"main": "./source/index.js",
|
||||
"exports": "./source/index.js",
|
||||
"imports": {
|
||||
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
||||
"#supports-color": {
|
||||
"node": "./source/vendor/supports-color/index.js",
|
||||
"default": "./source/vendor/supports-color/browser.js"
|
||||
}
|
||||
},
|
||||
"types": "./source/index.d.ts",
|
||||
"engines": {
|
||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && c8 ava && tsd",
|
||||
"bench": "matcha benchmark.js"
|
||||
},
|
||||
"files": [
|
||||
"source",
|
||||
"!source/index.test-d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"ansi",
|
||||
"style",
|
||||
"styles",
|
||||
"tty",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.10",
|
||||
"ava": "^3.15.0",
|
||||
"c8": "^7.10.0",
|
||||
"color-convert": "^2.0.1",
|
||||
"execa": "^6.0.0",
|
||||
"log-update": "^5.0.0",
|
||||
"matcha": "^0.7.0",
|
||||
"tsd": "^0.19.0",
|
||||
"xo": "^0.53.0",
|
||||
"yoctodelay": "^2.0.0"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"@typescript-eslint/consistent-type-imports": "off",
|
||||
"@typescript-eslint/consistent-type-exports": "off",
|
||||
"@typescript-eslint/consistent-type-definitions": "off",
|
||||
"unicorn/expiring-todo-comments": "off"
|
||||
}
|
||||
},
|
||||
"c8": {
|
||||
"reporter": [
|
||||
"text",
|
||||
"lcov"
|
||||
],
|
||||
"exclude": [
|
||||
"source/vendor"
|
||||
]
|
||||
}
|
||||
}
|
325
my-app/node_modules/inquirer/node_modules/chalk/readme.md
generated
vendored
Executable file
325
my-app/node_modules/inquirer/node_modules/chalk/readme.md
generated
vendored
Executable file
|
@ -0,0 +1,325 @@
|
|||
<h1 align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img width="320" src="media/logo.svg" alt="Chalk">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://codecov.io/gh/chalk/chalk)
|
||||
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
||||
[](https://www.npmjs.com/package/chalk)
|
||||
[](https://repl.it/github/chalk/chalk)
|
||||
|
||||

|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<p>
|
||||
<sup>
|
||||
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a>
|
||||
</sup>
|
||||
</p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://standardresume.co/tech">
|
||||
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160">
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
||||
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230">
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://strapi.io/?ref=sindresorhus">
|
||||
<div>
|
||||
<img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="220" alt="Strapi">
|
||||
</div>
|
||||
<b>Strapi is the leading open-source headless CMS.</b>
|
||||
<div>
|
||||
<sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
|
||||
</div>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://www.stackaid.us/?utm_campaign=sindre">
|
||||
<div>
|
||||
<img src="https://sindresorhus.com/assets/thanks/stackaid-logo.png" width="230" alt="StackAid">
|
||||
</div>
|
||||
<b>Fund your open source dependencies</b>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
## Highlights
|
||||
|
||||
- Expressive API
|
||||
- Highly performant
|
||||
- No dependencies
|
||||
- Ability to nest styles
|
||||
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
||||
- Auto-detects color support
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~86,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 4, 2022
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install chalk
|
||||
```
|
||||
|
||||
**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
console.log(chalk.blue('Hello world!'));
|
||||
```
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const log = console.log;
|
||||
|
||||
// Combine styled and normal strings
|
||||
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
||||
|
||||
// Compose multiple styles using the chainable API
|
||||
log(chalk.blue.bgRed.bold('Hello world!'));
|
||||
|
||||
// Pass in multiple arguments
|
||||
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
||||
|
||||
// Nest styles
|
||||
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
||||
|
||||
// Nest styles of the same type even (color, underline, background)
|
||||
log(chalk.green(
|
||||
'I am a green line ' +
|
||||
chalk.blue.underline.bold('with a blue substring') +
|
||||
' that becomes green again!'
|
||||
));
|
||||
|
||||
// ES2015 template literal
|
||||
log(`
|
||||
CPU: ${chalk.red('90%')}
|
||||
RAM: ${chalk.green('40%')}
|
||||
DISK: ${chalk.yellow('70%')}
|
||||
`);
|
||||
|
||||
// Use RGB colors in terminal emulators that support it.
|
||||
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
||||
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
||||
```
|
||||
|
||||
Easily define your own themes:
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const error = chalk.bold.red;
|
||||
const warning = chalk.hex('#FFA500'); // Orange color
|
||||
|
||||
console.log(error('Error!'));
|
||||
console.log(warning('Warning!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const name = 'Sindre';
|
||||
console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
### chalk.level
|
||||
|
||||
Specifies the level of color support.
|
||||
|
||||
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
import {Chalk} from 'chalk';
|
||||
|
||||
const customChalk = new Chalk({level: 0});
|
||||
```
|
||||
|
||||
| Level | Description |
|
||||
| :---: | :--- |
|
||||
| `0` | All colors disabled |
|
||||
| `1` | Basic color support (16 colors) |
|
||||
| `2` | 256 color support |
|
||||
| `3` | Truecolor support (16 million colors) |
|
||||
|
||||
### supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
### chalkStderr and supportsColorStderr
|
||||
|
||||
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
||||
|
||||
### modifierNames, foregroundColorNames, backgroundColorNames, and colorNames
|
||||
|
||||
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
||||
|
||||
This can be useful if you wrap Chalk and need to validate input:
|
||||
|
||||
```js
|
||||
import {modifierNames, foregroundColorNames} from 'chalk';
|
||||
|
||||
console.log(modifierNames.includes('bold'));
|
||||
//=> true
|
||||
|
||||
console.log(foregroundColorNames.includes('pink'));
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset` - Reset the current style.
|
||||
- `bold` - Make the text bold.
|
||||
- `dim` - Make the text have lower opacity.
|
||||
- `italic` - Make the text italic. *(Not widely supported)*
|
||||
- `underline` - Put a horizontal line below the text. *(Not widely supported)*
|
||||
- `overline` - Put a horizontal line above the text. *(Not widely supported)*
|
||||
- `inverse`- Invert background and foreground colors.
|
||||
- `hidden` - Print the text but make it invisible.
|
||||
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps.
|
||||
|
||||
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
||||
|
||||
Examples:
|
||||
|
||||
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).
|
||||
|
||||
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
The following color models can be used:
|
||||
|
||||
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
||||
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
||||
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
||||
|
||||
## Browser support
|
||||
|
||||
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
||||
|
||||
## Origin story
|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
||||
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
||||
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
||||
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
||||
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
320
my-app/node_modules/inquirer/node_modules/chalk/source/index.d.ts
generated
vendored
Executable file
320
my-app/node_modules/inquirer/node_modules/chalk/source/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,320 @@
|
|||
// TODO: Make it this when TS suports that.
|
||||
// import {ModifierName, ForegroundColor, BackgroundColor, ColorName} from '#ansi-styles';
|
||||
// import {ColorInfo, ColorSupportLevel} from '#supports-color';
|
||||
import {ModifierName, ForegroundColorName, BackgroundColorName, ColorName} from './vendor/ansi-styles/index.js';
|
||||
import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js';
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
Specify the color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
readonly level?: ColorSupportLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
export const Chalk: new (options?: Options) => ChalkInstance; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
|
||||
export interface ChalkInstance {
|
||||
(...text: unknown[]): string;
|
||||
|
||||
/**
|
||||
The color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
level: ColorSupportLevel;
|
||||
|
||||
/**
|
||||
Use RGB values to set text color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.rgb(222, 173, 237);
|
||||
```
|
||||
*/
|
||||
rgb: (red: number, green: number, blue: number) => this;
|
||||
|
||||
/**
|
||||
Use HEX value to set text color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.hex('#DEADED');
|
||||
```
|
||||
*/
|
||||
hex: (color: string) => this;
|
||||
|
||||
/**
|
||||
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.ansi256(201);
|
||||
```
|
||||
*/
|
||||
ansi256: (index: number) => this;
|
||||
|
||||
/**
|
||||
Use RGB values to set background color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgRgb(222, 173, 237);
|
||||
```
|
||||
*/
|
||||
bgRgb: (red: number, green: number, blue: number) => this;
|
||||
|
||||
/**
|
||||
Use HEX value to set background color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgHex('#DEADED');
|
||||
```
|
||||
*/
|
||||
bgHex: (color: string) => this;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgAnsi256(201);
|
||||
```
|
||||
*/
|
||||
bgAnsi256: (index: number) => this;
|
||||
|
||||
/**
|
||||
Modifier: Reset the current style.
|
||||
*/
|
||||
readonly reset: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text bold.
|
||||
*/
|
||||
readonly bold: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text have lower opacity.
|
||||
*/
|
||||
readonly dim: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text italic. *(Not widely supported)*
|
||||
*/
|
||||
readonly italic: this;
|
||||
|
||||
/**
|
||||
Modifier: Put a horizontal line below the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly underline: this;
|
||||
|
||||
/**
|
||||
Modifier: Put a horizontal line above the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly overline: this;
|
||||
|
||||
/**
|
||||
Modifier: Invert background and foreground colors.
|
||||
*/
|
||||
readonly inverse: this;
|
||||
|
||||
/**
|
||||
Modifier: Print the text but make it invisible.
|
||||
*/
|
||||
readonly hidden: this;
|
||||
|
||||
/**
|
||||
Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly strikethrough: this;
|
||||
|
||||
/**
|
||||
Modifier: Print the text only when Chalk has a color level above zero.
|
||||
|
||||
Can be useful for things that are purely cosmetic.
|
||||
*/
|
||||
readonly visible: this;
|
||||
|
||||
readonly black: this;
|
||||
readonly red: this;
|
||||
readonly green: this;
|
||||
readonly yellow: this;
|
||||
readonly blue: this;
|
||||
readonly magenta: this;
|
||||
readonly cyan: this;
|
||||
readonly white: this;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: this;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: this;
|
||||
|
||||
readonly blackBright: this;
|
||||
readonly redBright: this;
|
||||
readonly greenBright: this;
|
||||
readonly yellowBright: this;
|
||||
readonly blueBright: this;
|
||||
readonly magentaBright: this;
|
||||
readonly cyanBright: this;
|
||||
readonly whiteBright: this;
|
||||
|
||||
readonly bgBlack: this;
|
||||
readonly bgRed: this;
|
||||
readonly bgGreen: this;
|
||||
readonly bgYellow: this;
|
||||
readonly bgBlue: this;
|
||||
readonly bgMagenta: this;
|
||||
readonly bgCyan: this;
|
||||
readonly bgWhite: this;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: this;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: this;
|
||||
|
||||
readonly bgBlackBright: this;
|
||||
readonly bgRedBright: this;
|
||||
readonly bgGreenBright: this;
|
||||
readonly bgYellowBright: this;
|
||||
readonly bgBlueBright: this;
|
||||
readonly bgMagentaBright: this;
|
||||
readonly bgCyanBright: this;
|
||||
readonly bgWhiteBright: this;
|
||||
}
|
||||
|
||||
/**
|
||||
Main Chalk object that allows to chain styles together.
|
||||
|
||||
Call the last one as a method with a string argument.
|
||||
|
||||
Order doesn't matter, and later styles take precedent in case of a conflict.
|
||||
|
||||
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
*/
|
||||
declare const chalk: ChalkInstance;
|
||||
|
||||
export const supportsColor: ColorInfo;
|
||||
|
||||
export const chalkStderr: typeof chalk;
|
||||
export const supportsColorStderr: typeof supportsColor;
|
||||
|
||||
export {
|
||||
ModifierName, ForegroundColorName, BackgroundColorName, ColorName,
|
||||
modifierNames, foregroundColorNames, backgroundColorNames, colorNames,
|
||||
// } from '#ansi-styles';
|
||||
} from './vendor/ansi-styles/index.js';
|
||||
|
||||
export {
|
||||
ColorInfo,
|
||||
ColorSupport,
|
||||
ColorSupportLevel,
|
||||
// } from '#supports-color';
|
||||
} from './vendor/supports-color/index.js';
|
||||
|
||||
// TODO: Remove these aliases in the next major version
|
||||
/**
|
||||
@deprecated Use `ModifierName` instead.
|
||||
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type Modifiers = ModifierName;
|
||||
|
||||
/**
|
||||
@deprecated Use `ForegroundColorName` instead.
|
||||
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColor = ForegroundColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `BackgroundColorName` instead.
|
||||
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColor = BackgroundColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `ColorName` instead.
|
||||
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type Color = ColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `modifierNames` instead.
|
||||
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifiers: readonly Modifiers[];
|
||||
|
||||
/**
|
||||
@deprecated Use `foregroundColorNames` instead.
|
||||
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColors: readonly ForegroundColor[];
|
||||
|
||||
/**
|
||||
@deprecated Use `backgroundColorNames` instead.
|
||||
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColors: readonly BackgroundColor[];
|
||||
|
||||
/**
|
||||
@deprecated Use `colorNames` instead.
|
||||
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colors: readonly Color[];
|
||||
|
||||
export default chalk;
|
225
my-app/node_modules/inquirer/node_modules/chalk/source/index.js
generated
vendored
Executable file
225
my-app/node_modules/inquirer/node_modules/chalk/source/index.js
generated
vendored
Executable file
|
@ -0,0 +1,225 @@
|
|||
import ansiStyles from '#ansi-styles';
|
||||
import supportsColor from '#supports-color';
|
||||
import { // eslint-disable-line import/order
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex,
|
||||
} from './utilities.js';
|
||||
|
||||
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
||||
|
||||
const GENERATOR = Symbol('GENERATOR');
|
||||
const STYLER = Symbol('STYLER');
|
||||
const IS_EMPTY = Symbol('IS_EMPTY');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = [
|
||||
'ansi',
|
||||
'ansi',
|
||||
'ansi256',
|
||||
'ansi16m',
|
||||
];
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
const applyOptions = (object, options = {}) => {
|
||||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
||||
throw new Error('The `level` option should be an integer from 0 to 3');
|
||||
}
|
||||
|
||||
// Detect level if not set manually
|
||||
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
object.level = options.level === undefined ? colorLevel : options.level;
|
||||
};
|
||||
|
||||
export class Chalk {
|
||||
constructor(options) {
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return chalkFactory(options);
|
||||
}
|
||||
}
|
||||
|
||||
const chalkFactory = options => {
|
||||
const chalk = (...strings) => strings.join(' ');
|
||||
applyOptions(chalk, options);
|
||||
|
||||
Object.setPrototypeOf(chalk, createChalk.prototype);
|
||||
|
||||
return chalk;
|
||||
};
|
||||
|
||||
function createChalk(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
||||
|
||||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||||
styles[styleName] = {
|
||||
get() {
|
||||
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
||||
Object.defineProperty(this, styleName, {value: builder});
|
||||
return builder;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
const builder = createBuilder(this, this[STYLER], true);
|
||||
Object.defineProperty(this, 'visible', {value: builder});
|
||||
return builder;
|
||||
},
|
||||
};
|
||||
|
||||
const getModelAnsi = (model, level, type, ...arguments_) => {
|
||||
if (model === 'rgb') {
|
||||
if (level === 'ansi16m') {
|
||||
return ansiStyles[type].ansi16m(...arguments_);
|
||||
}
|
||||
|
||||
if (level === 'ansi256') {
|
||||
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
||||
}
|
||||
|
||||
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
||||
}
|
||||
|
||||
if (model === 'hex') {
|
||||
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
||||
}
|
||||
|
||||
return ansiStyles[type][model](...arguments_);
|
||||
};
|
||||
|
||||
const usedModels = ['rgb', 'hex', 'ansi256'];
|
||||
|
||||
for (const model of usedModels) {
|
||||
styles[model] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
||||
return createBuilder(this, styler, this[IS_EMPTY]);
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
||||
return createBuilder(this, styler, this[IS_EMPTY]);
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, {
|
||||
...styles,
|
||||
level: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this[GENERATOR].level;
|
||||
},
|
||||
set(level) {
|
||||
this[GENERATOR].level = level;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const createStyler = (open, close, parent) => {
|
||||
let openAll;
|
||||
let closeAll;
|
||||
if (parent === undefined) {
|
||||
openAll = open;
|
||||
closeAll = close;
|
||||
} else {
|
||||
openAll = parent.openAll + open;
|
||||
closeAll = close + parent.closeAll;
|
||||
}
|
||||
|
||||
return {
|
||||
open,
|
||||
close,
|
||||
openAll,
|
||||
closeAll,
|
||||
parent,
|
||||
};
|
||||
};
|
||||
|
||||
const createBuilder = (self, _styler, _isEmpty) => {
|
||||
// Single argument is hot path, implicit coercion is faster than anything
|
||||
// eslint-disable-next-line no-implicit-coercion
|
||||
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
||||
|
||||
// We alter the prototype because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
Object.setPrototypeOf(builder, proto);
|
||||
|
||||
builder[GENERATOR] = self;
|
||||
builder[STYLER] = _styler;
|
||||
builder[IS_EMPTY] = _isEmpty;
|
||||
|
||||
return builder;
|
||||
};
|
||||
|
||||
const applyStyle = (self, string) => {
|
||||
if (self.level <= 0 || !string) {
|
||||
return self[IS_EMPTY] ? '' : string;
|
||||
}
|
||||
|
||||
let styler = self[STYLER];
|
||||
|
||||
if (styler === undefined) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const {openAll, closeAll} = styler;
|
||||
if (string.includes('\u001B')) {
|
||||
while (styler !== undefined) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
string = stringReplaceAll(string, styler.close, styler.open);
|
||||
|
||||
styler = styler.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// We can move both next actions out of loop, because remaining actions in loop won't have
|
||||
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
||||
const lfIndex = string.indexOf('\n');
|
||||
if (lfIndex !== -1) {
|
||||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
||||
}
|
||||
|
||||
return openAll + string + closeAll;
|
||||
};
|
||||
|
||||
Object.defineProperties(createChalk.prototype, styles);
|
||||
|
||||
const chalk = createChalk();
|
||||
export const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
|
||||
|
||||
export {
|
||||
modifierNames,
|
||||
foregroundColorNames,
|
||||
backgroundColorNames,
|
||||
colorNames,
|
||||
|
||||
// TODO: Remove these aliases in the next major version
|
||||
modifierNames as modifiers,
|
||||
foregroundColorNames as foregroundColors,
|
||||
backgroundColorNames as backgroundColors,
|
||||
colorNames as colors,
|
||||
} from './vendor/ansi-styles/index.js';
|
||||
|
||||
export {
|
||||
stdoutColor as supportsColor,
|
||||
stderrColor as supportsColorStderr,
|
||||
};
|
||||
|
||||
export default chalk;
|
33
my-app/node_modules/inquirer/node_modules/chalk/source/utilities.js
generated
vendored
Executable file
33
my-app/node_modules/inquirer/node_modules/chalk/source/utilities.js
generated
vendored
Executable file
|
@ -0,0 +1,33 @@
|
|||
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
||||
export function stringReplaceAll(string, substring, replacer) {
|
||||
let index = string.indexOf(substring);
|
||||
if (index === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const substringLength = substring.length;
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
returnValue += string.slice(endIndex, index) + substring + replacer;
|
||||
endIndex = index + substringLength;
|
||||
index = string.indexOf(substring, endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.slice(endIndex);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
const gotCR = string[index - 1] === '\r';
|
||||
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
||||
endIndex = index + 1;
|
||||
index = string.indexOf('\n', endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.slice(endIndex);
|
||||
return returnValue;
|
||||
}
|
236
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/ansi-styles/index.d.ts
generated
vendored
Executable file
236
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/ansi-styles/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,236 @@
|
|||
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
/**
|
||||
The ANSI terminal control sequence for starting this style.
|
||||
*/
|
||||
readonly open: string;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this style.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
export interface ColorBase {
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this color.
|
||||
*/
|
||||
readonly close: string;
|
||||
|
||||
ansi(code: number): string;
|
||||
|
||||
ansi256(code: number): string;
|
||||
|
||||
ansi16m(red: number, green: number, blue: number): string;
|
||||
}
|
||||
|
||||
export interface Modifier {
|
||||
/**
|
||||
Resets the current color chain.
|
||||
*/
|
||||
readonly reset: CSPair;
|
||||
|
||||
/**
|
||||
Make text bold.
|
||||
*/
|
||||
readonly bold: CSPair;
|
||||
|
||||
/**
|
||||
Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: CSPair;
|
||||
|
||||
/**
|
||||
Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: CSPair;
|
||||
|
||||
/**
|
||||
Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: CSPair;
|
||||
|
||||
/**
|
||||
Make text overline.
|
||||
|
||||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
|
||||
*/
|
||||
readonly overline: CSPair;
|
||||
|
||||
/**
|
||||
Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: CSPair;
|
||||
|
||||
/**
|
||||
Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: CSPair;
|
||||
|
||||
/**
|
||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: CSPair;
|
||||
}
|
||||
|
||||
export interface ForegroundColor {
|
||||
readonly black: CSPair;
|
||||
readonly red: CSPair;
|
||||
readonly green: CSPair;
|
||||
readonly yellow: CSPair;
|
||||
readonly blue: CSPair;
|
||||
readonly cyan: CSPair;
|
||||
readonly magenta: CSPair;
|
||||
readonly white: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: CSPair;
|
||||
|
||||
readonly blackBright: CSPair;
|
||||
readonly redBright: CSPair;
|
||||
readonly greenBright: CSPair;
|
||||
readonly yellowBright: CSPair;
|
||||
readonly blueBright: CSPair;
|
||||
readonly cyanBright: CSPair;
|
||||
readonly magentaBright: CSPair;
|
||||
readonly whiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface BackgroundColor {
|
||||
readonly bgBlack: CSPair;
|
||||
readonly bgRed: CSPair;
|
||||
readonly bgGreen: CSPair;
|
||||
readonly bgYellow: CSPair;
|
||||
readonly bgBlue: CSPair;
|
||||
readonly bgCyan: CSPair;
|
||||
readonly bgMagenta: CSPair;
|
||||
readonly bgWhite: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: CSPair;
|
||||
|
||||
readonly bgBlackBright: CSPair;
|
||||
readonly bgRedBright: CSPair;
|
||||
readonly bgGreenBright: CSPair;
|
||||
readonly bgYellowBright: CSPair;
|
||||
readonly bgBlueBright: CSPair;
|
||||
readonly bgCyanBright: CSPair;
|
||||
readonly bgMagentaBright: CSPair;
|
||||
readonly bgWhiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface ConvertColor {
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 256 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi256(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the RGB color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToRgb(hex: string): [red: number, green: number, blue: number];
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 256 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi256(hex: string): number;
|
||||
|
||||
/**
|
||||
Convert from the ANSI 256 color space to the ANSI 16 color space.
|
||||
|
||||
@param code - A number representing the ANSI 256 color.
|
||||
*/
|
||||
ansi256ToAnsi(code: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 16 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 16 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi(hex: string): number;
|
||||
}
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type ModifierName = keyof Modifier;
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColorName = keyof ForegroundColor;
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColorName = keyof BackgroundColor;
|
||||
|
||||
/**
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ColorName = ForegroundColorName | BackgroundColorName;
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifierNames: readonly ModifierName[];
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColorNames: readonly ForegroundColorName[];
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColorNames: readonly BackgroundColorName[];
|
||||
|
||||
/*
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colorNames: readonly ColorName[];
|
||||
|
||||
declare const ansiStyles: {
|
||||
readonly modifier: Modifier;
|
||||
readonly color: ColorBase & ForegroundColor;
|
||||
readonly bgColor: ColorBase & BackgroundColor;
|
||||
readonly codes: ReadonlyMap<number, number>;
|
||||
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
|
||||
|
||||
export default ansiStyles;
|
223
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/ansi-styles/index.js
generated
vendored
Executable file
223
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/ansi-styles/index.js
generated
vendored
Executable file
|
@ -0,0 +1,223 @@
|
|||
const ANSI_BACKGROUND_OFFSET = 10;
|
||||
|
||||
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
||||
|
||||
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
||||
|
||||
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
||||
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
overline: [53, 55],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29],
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
|
||||
// Bright color
|
||||
blackBright: [90, 39],
|
||||
gray: [90, 39], // Alias of `blackBright`
|
||||
grey: [90, 39], // Alias of `blackBright`
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39],
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgGray: [100, 49], // Alias of `bgBlackBright`
|
||||
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49],
|
||||
},
|
||||
};
|
||||
|
||||
export const modifierNames = Object.keys(styles.modifier);
|
||||
export const foregroundColorNames = Object.keys(styles.color);
|
||||
export const backgroundColorNames = Object.keys(styles.bgColor);
|
||||
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
|
||||
for (const [groupName, group] of Object.entries(styles)) {
|
||||
for (const [styleName, style] of Object.entries(group)) {
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`,
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false,
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
styles.color.ansi = wrapAnsi16();
|
||||
styles.color.ansi256 = wrapAnsi256();
|
||||
styles.color.ansi16m = wrapAnsi16m();
|
||||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
||||
|
||||
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
||||
Object.defineProperties(styles, {
|
||||
rgbToAnsi256: {
|
||||
value(red, green, blue) {
|
||||
// We use the extended greyscale palette here, with the exception of
|
||||
// black and white. normal palette only has 4 greyscale shades.
|
||||
if (red === green && green === blue) {
|
||||
if (red < 8) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (red > 248) {
|
||||
return 231;
|
||||
}
|
||||
|
||||
return Math.round(((red - 8) / 247) * 24) + 232;
|
||||
}
|
||||
|
||||
return 16
|
||||
+ (36 * Math.round(red / 255 * 5))
|
||||
+ (6 * Math.round(green / 255 * 5))
|
||||
+ Math.round(blue / 255 * 5);
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToRgb: {
|
||||
value(hex) {
|
||||
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
||||
if (!matches) {
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
let [colorString] = matches;
|
||||
|
||||
if (colorString.length === 3) {
|
||||
colorString = [...colorString].map(character => character + character).join('');
|
||||
}
|
||||
|
||||
const integer = Number.parseInt(colorString, 16);
|
||||
|
||||
return [
|
||||
/* eslint-disable no-bitwise */
|
||||
(integer >> 16) & 0xFF,
|
||||
(integer >> 8) & 0xFF,
|
||||
integer & 0xFF,
|
||||
/* eslint-enable no-bitwise */
|
||||
];
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi256: {
|
||||
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
ansi256ToAnsi: {
|
||||
value(code) {
|
||||
if (code < 8) {
|
||||
return 30 + code;
|
||||
}
|
||||
|
||||
if (code < 16) {
|
||||
return 90 + (code - 8);
|
||||
}
|
||||
|
||||
let red;
|
||||
let green;
|
||||
let blue;
|
||||
|
||||
if (code >= 232) {
|
||||
red = (((code - 232) * 10) + 8) / 255;
|
||||
green = red;
|
||||
blue = red;
|
||||
} else {
|
||||
code -= 16;
|
||||
|
||||
const remainder = code % 36;
|
||||
|
||||
red = Math.floor(code / 36) / 5;
|
||||
green = Math.floor(remainder / 6) / 5;
|
||||
blue = (remainder % 6) / 5;
|
||||
}
|
||||
|
||||
const value = Math.max(red, green, blue) * 2;
|
||||
|
||||
if (value === 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
||||
|
||||
if (value === 2) {
|
||||
result += 60;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
rgbToAnsi: {
|
||||
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi: {
|
||||
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
});
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
const ansiStyles = assembleStyles();
|
||||
|
||||
export default ansiStyles;
|
1
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/browser.d.ts
generated
vendored
Executable file
1
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/browser.d.ts
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
export {default} from './index.js';
|
30
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/browser.js
generated
vendored
Executable file
30
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/browser.js
generated
vendored
Executable file
|
@ -0,0 +1,30 @@
|
|||
/* eslint-env browser */
|
||||
|
||||
const level = (() => {
|
||||
if (navigator.userAgentData) {
|
||||
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
||||
if (brand && brand.version > 93) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
})();
|
||||
|
||||
const colorSupport = level !== 0 && {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
|
||||
const supportsColor = {
|
||||
stdout: colorSupport,
|
||||
stderr: colorSupport,
|
||||
};
|
||||
|
||||
export default supportsColor;
|
55
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/index.d.ts
generated
vendored
Executable file
55
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,55 @@
|
|||
import type {WriteStream} from 'node:tty';
|
||||
|
||||
export type Options = {
|
||||
/**
|
||||
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly sniffFlags?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
export type ColorSupportLevel = 0 | 1 | 2 | 3;
|
||||
|
||||
/**
|
||||
Detect whether the terminal supports color.
|
||||
*/
|
||||
export type ColorSupport = {
|
||||
/**
|
||||
The color level.
|
||||
*/
|
||||
level: ColorSupportLevel;
|
||||
|
||||
/**
|
||||
Whether basic 16 colors are supported.
|
||||
*/
|
||||
hasBasic: boolean;
|
||||
|
||||
/**
|
||||
Whether ANSI 256 colors are supported.
|
||||
*/
|
||||
has256: boolean;
|
||||
|
||||
/**
|
||||
Whether Truecolor 16 million colors are supported.
|
||||
*/
|
||||
has16m: boolean;
|
||||
};
|
||||
|
||||
export type ColorInfo = ColorSupport | false;
|
||||
|
||||
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
||||
|
||||
declare const supportsColor: {
|
||||
stdout: ColorInfo;
|
||||
stderr: ColorInfo;
|
||||
};
|
||||
|
||||
export default supportsColor;
|
182
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/index.js
generated
vendored
Executable file
182
my-app/node_modules/inquirer/node_modules/chalk/source/vendor/supports-color/index.js
generated
vendored
Executable file
|
@ -0,0 +1,182 @@
|
|||
import process from 'node:process';
|
||||
import os from 'node:os';
|
||||
import tty from 'node:tty';
|
||||
|
||||
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
||||
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
||||
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
}
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let flagForceColor;
|
||||
if (
|
||||
hasFlag('no-color')
|
||||
|| hasFlag('no-colors')
|
||||
|| hasFlag('color=false')
|
||||
|| hasFlag('color=never')
|
||||
) {
|
||||
flagForceColor = 0;
|
||||
} else if (
|
||||
hasFlag('color')
|
||||
|| hasFlag('colors')
|
||||
|| hasFlag('color=true')
|
||||
|| hasFlag('color=always')
|
||||
) {
|
||||
flagForceColor = 1;
|
||||
}
|
||||
|
||||
function envForceColor() {
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === 'true') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (env.FORCE_COLOR === 'false') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
}
|
||||
|
||||
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
||||
const noFlagForceColor = envForceColor();
|
||||
if (noFlagForceColor !== undefined) {
|
||||
flagForceColor = noFlagForceColor;
|
||||
}
|
||||
|
||||
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
||||
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sniffFlags) {
|
||||
if (hasFlag('color=16m')
|
||||
|| hasFlag('color=full')
|
||||
|| hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Azure DevOps pipelines.
|
||||
// Has to be above the `!streamIsTTY` check.
|
||||
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
||||
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(osRelease[0]) >= 10
|
||||
&& Number(osRelease[2]) >= 10_586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (env.TERM === 'xterm-kitty') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app': {
|
||||
return version >= 3 ? 3 : 2;
|
||||
}
|
||||
|
||||
case 'Apple_Terminal': {
|
||||
return 2;
|
||||
}
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
export function createSupportsColor(stream, options = {}) {
|
||||
const level = _supportsColor(stream, {
|
||||
streamIsTTY: stream && stream.isTTY,
|
||||
...options,
|
||||
});
|
||||
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
const supportsColor = {
|
||||
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
||||
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
||||
};
|
||||
|
||||
export default supportsColor;
|
80
my-app/node_modules/inquirer/package.json
generated
vendored
Executable file
80
my-app/node_modules/inquirer/package.json
generated
vendored
Executable file
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"name": "inquirer",
|
||||
"type": "module",
|
||||
"version": "9.2.12",
|
||||
"description": "A collection of common interactive command line user interfaces.",
|
||||
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"main": "lib/inquirer.js",
|
||||
"keywords": [
|
||||
"answer",
|
||||
"answers",
|
||||
"ask",
|
||||
"base",
|
||||
"cli",
|
||||
"command",
|
||||
"command-line",
|
||||
"confirm",
|
||||
"enquirer",
|
||||
"generate",
|
||||
"generator",
|
||||
"hyper",
|
||||
"input",
|
||||
"inquire",
|
||||
"inquirer",
|
||||
"interface",
|
||||
"iterm",
|
||||
"javascript",
|
||||
"menu",
|
||||
"node",
|
||||
"nodejs",
|
||||
"prompt",
|
||||
"promptly",
|
||||
"prompts",
|
||||
"question",
|
||||
"readline",
|
||||
"scaffold",
|
||||
"scaffolder",
|
||||
"scaffolding",
|
||||
"stdin",
|
||||
"stdout",
|
||||
"terminal",
|
||||
"tty",
|
||||
"ui",
|
||||
"yeoman",
|
||||
"yo",
|
||||
"zsh"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"terminal-link": "^3.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ljharb/through": "^2.3.11",
|
||||
"ansi-escapes": "^4.3.2",
|
||||
"chalk": "^5.3.0",
|
||||
"cli-cursor": "^3.1.0",
|
||||
"cli-width": "^4.1.0",
|
||||
"external-editor": "^3.1.0",
|
||||
"figures": "^5.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mute-stream": "1.0.0",
|
||||
"ora": "^5.4.1",
|
||||
"run-async": "^3.0.0",
|
||||
"rxjs": "^7.8.1",
|
||||
"string-width": "^4.2.3",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wrap-ansi": "^6.2.0"
|
||||
},
|
||||
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/inquirer/README.md",
|
||||
"gitHead": "a318aec57d33b53131c0b03cc8dd6ab4efae3e50"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue