first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

301
build/node_modules/inquirer/README.md generated vendored Normal file
View File

@@ -0,0 +1,301 @@
Inquirer.js
===========
[![npm](https://badge.fury.io/js/inquirer.svg)](http://badge.fury.io/js/inquirer) [![tests](https://travis-ci.org/SBoudrias/Inquirer.js.svg?branch=master)](http://travis-ci.org/SBoudrias/Inquirer.js) [![dependencies](https://david-dm.org/SBoudrias/Inquirer.js.svg?theme=shields.io)](https://david-dm.org/SBoudrias/Inquirer.js)
A collection of common interactive command line user interfaces.
## Goal and Philosophy
<img align="right" alt="Inquirer Logo" src="/assets/inquirer_readme.png" title="Inquirer.js"/>
**`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/Xanadu_(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.js](https://github.com/visionmedia/commander.js) or [Vorpal.js](https://github.com/dthree/vorpal).
## Documentation
### Installation
``` shell
npm install inquirer
```
```javascript
var inquirer = require("inquirer");
inquirer.prompt([/* Pass your questions in here */], function( answers ) {
// Use user feedback for... whatever!!
});
```
### Examples (Run it and see it)
Checkout the `examples/` folder for code and interface examples.
``` shell
node examples/pizza.js
node examples/checkbox.js
# etc...
```
### Methods
`inquirer.prompt( questions, callback )`
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)
- **callback** (Function) first parameter is the [Answers Object](#answers)
### Objects
#### Question
A question object is a `hash` containing question related values:
- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `confirm`,
`list`, `rawlist`, `password`
- **name**: (String) The name to use when storing the answer 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.
- **default**: (String|Number|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 `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 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 return the filtered value to be used inside the program. The value returned will be added to 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.
`default`, `choices`(if defined as functions), `validate`, `filter` and `when` functions can be called asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option.
``` javascript
{
validate: function(input) {
// Declare function as asynchronous, and save the done callback
var 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");
return;
}
// Pass the return value in the done callback
done(true);
}, 3000);
}
}
```
### Answers
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)
- `rawlist`, `list` : Selected choice value (or name if no value specified) (String)
### Separator
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.
Prompts type
---------------------
> **Note:**: _allowed options written inside square brackets (`[]`) are optional. Others are required._
#### List - `{ type: "list" }`
Take `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that
default must be the choice `index` in the array or a choice `value`)
![List prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/list-prompt.png)
---
#### Raw List - `{ type: "rawlist" }`
Take `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that
default must the choice `index` in the array)
![Raw list prompt](https://i.cloudup.com/LcRGpXI0CX-3000x3000.png)
---
#### Expand - `{ type: "expand" }`
Take `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that
default must be the choice `index` in the array)
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.
![Expand prompt closed](https://dl.dropboxusercontent.com/u/59696254/inquirer/expand-prompt-1.png)
![Expand prompt expanded](https://dl.dropboxusercontent.com/u/59696254/inquirer/expand-prompt-2.png)
---
#### Checkbox - `{ type: "checkbox" }`
Take `type`, `name`, `message`, `choices`[, `filter`, `validate`, `default`] 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.
![Checkbox prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/checkbox-prompt.png)
---
#### Confirm - `{ type: "confirm" }`
Take `type`, `name`, `message`[, `default`] properties. `default` is expected to be a boolean if used.
![Confirm prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/confirm-prompt.png)
---
#### Input - `{ type: "input" }`
Take `type`, `name`, `message`[, `default`, `filter`, `validate`] properties.
![Input prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/input-prompt.png)
---
#### Password - `{ type: "password" }`
Take `type`, `name`, `message`[, `default`, `filter`, `validate`] properties.
![Password prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/password-prompt.png)
## 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
var 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");
```
#### Prompt - `inquirer.ui.Prompt`
This is UI layout used to run prompt. This layout is returned by `inquirer.prompt` and you should probably always use `inquirer.prompt` to interface with this UI.
## Reactive interface
Internally, Inquirer uses the [JS reactive extension](https://github.com/Reactive-Extensions/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
var prompts = Rx.Observable.create(function( obs ) {
obs.onNext({ /* question... */ });
setTimeout(function () {
obs.onNext({ /* question... */ });
obs.onCompleted();
});
});
inquirer.prompt(prompts);
```
And using the `process` property, you have access to more fine grained callbacks:
```js
inquirer.prompt(prompts).process.subscribe(
onEachAnswer,
onError,
onComplete
);
```
## Support (OS Terminals)
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**:
- cmd.exe
- Powershell
- Cygwin
- **Linux (Ubuntu, openSUSE, Arch Linux, etc)**:
- gnome-terminal (Terminal GNOME)
- konsole
## News on the march (Release notes)
Please refer to the [Github releases section for the changelog](https://github.com/SBoudrias/Inquirer.js/releases)
## Contributing
**Style Guide**
Please brief yourself on [Idiomatic.js](https://github.com/rwldrn/idiomatic.js) style guide with two space indent
**Unit test**
Unit test are written in [Mocha](https://mochajs.org/). 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 corrections
or better docs!
**Pull Requests**
Send _fixes_ PR on the `master` branch. Any new features should be send on the `wip`branch.
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) or just add your name to [the wiki](https://github.com/SBoudrias/Inquirer.js/wiki/Testers)
## License
Copyright (c) 2015 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.

79
build/node_modules/inquirer/lib/inquirer.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
/**
* Inquirer.js
* A collection of common interactive command line user interfaces.
*/
var inquirer = module.exports;
/**
* Client interfaces
*/
inquirer.prompts = {};
inquirer.Separator = require('./objects/separator');
inquirer.ui = {
BottomBar: require('./ui/bottom-bar'),
Prompt: require('./ui/prompt')
};
/**
* Create a new self-contained prompt module.
*/
inquirer.createPromptModule = function (opt) {
var promptModule = function (questions, allDone) {
var ui = new inquirer.ui.Prompt(promptModule.prompts, opt);
ui.run(questions, allDone);
return ui;
};
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', require('./prompts/list'));
this.registerPrompt('input', require('./prompts/input'));
this.registerPrompt('confirm', require('./prompts/confirm'));
this.registerPrompt('rawlist', require('./prompts/rawlist'));
this.registerPrompt('expand', require('./prompts/expand'));
this.registerPrompt('checkbox', require('./prompts/checkbox'));
this.registerPrompt('password', require('./prompts/password'));
};
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 {inquirer.ui.Prompt}
*/
inquirer.prompt = inquirer.createPromptModule();
// Expose helper functions on the top level for easiest usage by common users
inquirer.registerPrompt = function (name, prompt) {
inquirer.prompt.registerPrompt(name, prompt);
};
inquirer.restoreDefaultPrompts = function () {
inquirer.prompt.restoreDefaultPrompts();
};

36
build/node_modules/inquirer/lib/objects/choice.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
var _ = require('lodash');
/**
* Choice object
* Normalize input as choice object
* @constructor
* @param {String|Object} val Choice value. If an object is passed, it should contains
* at least one of `value` or `name` property
*/
var Choice = module.exports = function (val, answers) {
// Don't process Choice and Separator object
if (val instanceof Choice || val.type === 'separator') {
return val;
}
if (_.isString(val)) {
this.name = val;
this.value = val;
this.short = val;
} else {
_.extend(this, val, {
name: val.name || val.value,
value: val.hasOwnProperty('value') ? val.value : val.name,
short: val.short || val.name || val.value
});
}
if (_.isFunction(val.disabled)) {
this.disabled = val.disabled(answers);
} else {
this.disabled = val.disabled;
}
};

113
build/node_modules/inquirer/lib/objects/choices.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
'use strict';
var assert = require('assert');
var _ = require('lodash');
var Separator = require('./separator');
var Choice = require('./choice');
/**
* Choices collection
* Collection of multiple `choice` object
* @constructor
* @param {Array} choices All `choice` to keep in the collection
*/
var Choices = module.exports = function (choices, answers) {
this.choices = choices.map(function (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(function (item) {
return !item.disabled;
});
Object.defineProperty(this, 'length', {
get: function () {
return this.choices.length;
},
set: function (val) {
this.choices.length = val;
}
});
Object.defineProperty(this, 'realLength', {
get: function () {
return this.realChoices.length;
},
set: function () {
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
*/
Choices.prototype.getChoice = function (selector) {
assert(_.isNumber(selector));
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
*/
Choices.prototype.get = function (selector) {
assert(_.isNumber(selector));
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
*/
Choices.prototype.where = function (whereClause) {
return _.filter(this.realChoices, whereClause);
};
/**
* Pluck a particular key from the choices
* @param {String} propertyName Property name to select
* @return {Array} Selected properties
*/
Choices.prototype.pluck = function (propertyName) {
return _.map(this.realChoices, propertyName);
};
// Expose usual Array methods
Choices.prototype.indexOf = function () {
return this.choices.indexOf.apply(this.choices, arguments);
};
Choices.prototype.forEach = function () {
return this.choices.forEach.apply(this.choices, arguments);
};
Choices.prototype.filter = function () {
return this.choices.filter.apply(this.choices, arguments);
};
Choices.prototype.push = function () {
var objs = _.map(arguments, function (val) { return new Choice(val); });
this.choices.push.apply(this.choices, objs);
this.realChoices = this.choices.filter(Separator.exclude);
return this.choices;
};

35
build/node_modules/inquirer/lib/objects/separator.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
'use strict';
var chalk = require('chalk');
var figures = require('figures');
/**
* Separator object
* Used to space/separate choices group
* @constructor
* @param {String} line Separation line content (facultative)
*/
var Separator = module.exports = function (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
*/
Separator.exclude = function (obj) {
return obj.type !== 'separator';
};
/**
* Stringify separator
* @return {String} the separator display string
*/
Separator.prototype.toString = function () {
return this.line;
};

175
build/node_modules/inquirer/lib/prompts/base.js generated vendored Normal file
View File

@@ -0,0 +1,175 @@
/**
* Base prompt implementation
* Should be extended by prompt types.
*/
var rx = require('rx-lite');
var _ = require('lodash');
var chalk = require('chalk');
var ansiRegex = require('ansi-regex');
var runAsync = require('run-async');
var Choices = require('../objects/choices');
var ScreenManager = require('../utils/screen-manager');
var Prompt = module.exports = function (question, rl, answers) {
// Setup instance defaults property
_.assign(this, {
answers: answers,
status : 'pending'
});
// Set defaults prompt options
this.opt = _.defaults(_.clone(question), {
validate: function () { return true; },
filter: function (val) { return val; },
when: function () { return true; }
});
// Check to make sure prompt requirements are there
if (!this.opt.message) {
this.throwParamError('message');
}
if (!this.opt.name) {
this.throwParamError('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
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype.run = function( cb ) {
this._run(function (value) {
this.filter(value, cb);
}.bind(this));
};
// default noop (this one should be overwritten in prompts)
Prompt.prototype._run = function (cb) { cb(); };
/**
* Throw an error telling a required parameter is missing
* @param {String} name Name of the missing param
* @return {Throw Error}
*/
Prompt.prototype.throwParamError = function (name) {
throw new Error('You must provide a `' + name + '` parameter');
};
/**
* Validate a given input
* @param {String} value Input string
* @param {Function} callback Pass `true` (if input is valid) or an error message as
* parameter.
* @return {null}
*/
Prompt.prototype.validate = function (input, cb) {
runAsync(this.opt.validate, cb, input);
};
/**
* 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`
*/
Prompt.prototype.handleSubmitEvents = function (submit) {
var self = this;
var validation = submit.flatMap(function (value) {
return rx.Observable.create(function (observer) {
runAsync(self.opt.validate, function (isValid) {
observer.onNext({ isValid: isValid, value: self.getCurrentValue(value) });
observer.onCompleted();
}, self.getCurrentValue(value), self.answers);
});
}).share();
var success = validation
.filter(function (state) { return state.isValid === true; })
.take(1);
var error = validation
.filter(function (state) { return state.isValid !== true; })
.takeUntil(success);
return {
success: success,
error: error
};
};
Prompt.prototype.getCurrentValue = function (value) {
return value;
};
/**
* Filter a given input before sending back
* @param {String} value Input string
* @param {Function} callback Pass the filtered input as parameter.
* @return {null}
*/
Prompt.prototype.filter = function (input, cb) {
runAsync(this.opt.filter, cb, input);
};
/**
* Return the prompt line prefix
* @param {String} [optionnal] String to concatenate to the prefix
* @return {String} prompt prefix
*/
Prompt.prototype.prefix = function (str) {
str || (str = '');
return chalk.green('?') + ' ' + str;
};
/**
* Return the prompt line suffix
* @param {String} [optionnal] String to concatenate to the suffix
* @return {String} prompt suffix
*/
var reStrEnd = new RegExp('(?:' + ansiRegex().source + ')$|$');
Prompt.prototype.suffix = function (str) {
str || (str = '');
// make sure we get the `:` inside the styles
if (str.length < 1 || /[a-z1-9]$/i.test(chalk.stripColor(str))) {
str = str.replace(reStrEnd, ':$&');
}
return str.trim() + ' ';
};
/**
* Generate the prompt question string
* @return {String} prompt question string
*/
Prompt.prototype.getQuestion = function () {
var message = chalk.green('?') + ' ' + chalk.bold(this.opt.message) + ' ';
// Append the default if available, and if question isn't answered
if ( this.opt.default != null && this.status !== 'answered' ) {
message += chalk.dim('('+ this.opt.default + ') ');
}
return message;
};

213
build/node_modules/inquirer/lib/prompts/checkbox.js generated vendored Normal file
View File

@@ -0,0 +1,213 @@
/**
* `list` type prompt
*/
var _ = require("lodash");
var util = require("util");
var chalk = require("chalk");
var cliCursor = require("cli-cursor");
var figures = require("figures");
var Base = require("./base");
var observe = require("../utils/events");
var Paginator = require("../utils/paginator");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
Base.apply( this, arguments );
if (!this.opt.choices) {
this.throwParamError("choices");
}
if ( _.isArray(this.opt.default) ) {
this.opt.choices.forEach(function( choice ) {
if ( this.opt.default.indexOf(choice.value) >= 0 ) {
choice.checked = true;
}
}, this);
}
this.firstRender = true;
this.pointer = 0;
// Make sure no default is set (so it won't be printed)
this.opt.default = null;
this.paginator = new Paginator();
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
var events = observe(this.rl);
var validation = this.handleSubmitEvents( events.line );
validation.success.forEach( this.onEnd.bind(this) );
validation.error.forEach( this.onError.bind(this) );
events.normalizedUpKey.takeUntil( validation.success ).forEach( this.onUpKey.bind(this) );
events.normalizedDownKey.takeUntil( validation.success ).forEach( this.onDownKey.bind(this) );
events.numberKey.takeUntil( validation.success ).forEach( this.onNumberKey.bind(this) );
events.spaceKey.takeUntil( validation.success ).forEach( this.onSpaceKey.bind(this) );
// Init the prompt
cliCursor.hide();
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (error) {
// Render question
var message = this.getQuestion();
var bottomContent = '';
if ( this.firstRender ) {
message += "(Press <space> to select)";
}
// Render choices or answer depending on the state
if ( this.status === "answered" ) {
message += chalk.cyan( this.selection.join(", ") );
} else {
var choicesStr = renderChoices(this.opt.choices, this.pointer);
var indexPosition = this.opt.choices.indexOf(this.opt.choices.getChoice(this.pointer));
message += "\n" + this.paginator.paginate(choicesStr, indexPosition, this.opt.pageSize);
}
if (error) {
bottomContent = chalk.red('>> ') + error;
}
this.firstRender = false;
this.screen.render(message, bottomContent);
};
/**
* When user press `enter` key
*/
Prompt.prototype.onEnd = function( state ) {
this.status = "answered";
// Rerender prompt (and clean subline error)
this.render();
this.screen.done();
cliCursor.show();
this.done( state.value );
};
Prompt.prototype.onError = function ( state ) {
this.render(state.isValid);
};
Prompt.prototype.getCurrentValue = function () {
var choices = this.opt.choices.filter(function( choice ) {
return !!choice.checked && !choice.disabled;
});
this.selection = _.map(choices, "short");
return _.map(choices, "value");
};
Prompt.prototype.onUpKey = function() {
var len = this.opt.choices.realLength;
this.pointer = (this.pointer > 0) ? this.pointer - 1 : len - 1;
this.render();
};
Prompt.prototype.onDownKey = function() {
var len = this.opt.choices.realLength;
this.pointer = (this.pointer < len - 1) ? this.pointer + 1 : 0;
this.render();
};
Prompt.prototype.onNumberKey = function( input ) {
if ( input <= this.opt.choices.realLength ) {
this.pointer = input - 1;
this.toggleChoice( this.pointer );
}
this.render();
};
Prompt.prototype.onSpaceKey = function( input ) {
this.toggleChoice(this.pointer);
this.render();
};
Prompt.prototype.toggleChoice = function( index ) {
var checked = this.opt.choices.getChoice(index).checked;
this.opt.choices.getChoice(index).checked = !checked;
};
/**
* Function for rendering checkbox choices
* @param {Number} pointer Position of the pointer
* @return {String} Rendered content
*/
function renderChoices(choices, pointer) {
var output = '';
var separatorOffset = 0;
choices.forEach(function (choice, i) {
if (choice.type === 'separator') {
separatorOffset++;
output += ' ' + choice + '\n';
return;
}
if (choice.disabled) {
separatorOffset++;
output += ' - ' + choice.name;
output += ' (' + (_.isString(choice.disabled) ? choice.disabled : 'Disabled') + ')';
} else {
var isSelected = (i - separatorOffset === pointer);
output += isSelected ? chalk.cyan(figures.pointer) : ' ';
output += getCheckbox(choice.checked) + ' ' + choice.name;
}
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;
}

110
build/node_modules/inquirer/lib/prompts/confirm.js generated vendored Normal file
View File

@@ -0,0 +1,110 @@
/**
* `confirm` type prompt
*/
var _ = require("lodash");
var util = require("util");
var chalk = require("chalk");
var Base = require("./base");
var observe = require("../utils/events");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
Base.apply( this, arguments );
var rawDefault = true;
_.extend( this.opt, {
filter: function( input ) {
var value = rawDefault;
if ( input != null && input !== "" ) {
value = /^y(es)?/i.test(input);
}
return value;
}.bind(this)
});
if ( _.isBoolean(this.opt.default) ) {
rawDefault = this.opt.default;
}
this.opt.default = rawDefault ? "Y/n" : "y/N";
return this;
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
// Once user confirm (enter key)
var events = observe(this.rl);
events.keypress.takeUntil( events.line ).forEach( this.onKeypress.bind(this) );
events.line.take(1).forEach( this.onEnd.bind(this) );
// Init
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (answer) {
var message = this.getQuestion();
if (typeof answer === "boolean") {
message += chalk.cyan(answer ? "Yes" : "No");
} else {
message += this.rl.line;
}
this.screen.render(message);
return this;
};
/**
* When user press `enter` key
*/
Prompt.prototype.onEnd = function( input ) {
this.status = "answered";
var output = this.opt.filter( input );
this.render( output );
this.screen.done();
this.done( input ); // send "input" because the master class will refilter
};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function() {
this.render();
};

255
build/node_modules/inquirer/lib/prompts/expand.js generated vendored Normal file
View File

@@ -0,0 +1,255 @@
/**
* `rawlist` type prompt
*/
var _ = require("lodash");
var util = require("util");
var chalk = require("chalk");
var Base = require("./base");
var Separator = require("../objects/separator");
var observe = require("../utils/events");
var Paginator = require("../utils/paginator");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
Base.apply( this, arguments );
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"
});
// Setup the default string (capitalize the default key)
this.opt.default = this.generateChoicesString( this.opt.choices, this.opt.default );
this.paginator = new Paginator();
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
// Save user answer and update prompt to show selected option.
var events = observe(this.rl);
this.lineObs = events.line.forEach( this.onSubmit.bind(this) );
this.keypressObs = events.keypress.forEach( this.onKeypress.bind(this) );
// Init the prompt
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (error, hint) {
var message = this.getQuestion();
var bottomContent = '';
if ( this.status === "answered" ) {
message += chalk.cyan( this.selected.short || this.selected.name );
} else if ( this.status === "expanded" ) {
var 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);
};
/**
* Generate the prompt choices string
* @return {String} Choices string
*/
Prompt.prototype.getChoices = function() {
var output = "";
this.opt.choices.forEach(function( choice, i ) {
output += "\n ";
if ( choice.type === "separator" ) {
output += " " + choice;
return;
}
var choiceStr = choice.key + ") " + choice.name;
if ( this.selectedKey === choice.key ) {
choiceStr = chalk.cyan( choiceStr );
}
output += choiceStr;
}.bind(this));
return output;
};
/**
* When user press `enter` key
*/
Prompt.prototype.onSubmit = function( input ) {
if ( input == null || input === "" ) {
input = this.rawDefault;
}
var selected = this.opt.choices.where({ key : input.toLowerCase().trim() })[0];
if ( selected != null && selected.key === "h" ) {
this.selectedKey = "";
this.status = "expanded";
this.render();
return;
}
if ( selected != null ) {
this.status = "answered";
this.selected = selected;
// Re-render prompt
this.render();
this.lineObs.dispose();
this.keypressObs.dispose();
this.screen.done();
this.done( this.selected.value );
return;
}
// Input is invalid
this.render("Please enter a valid command");
};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function( s, key ) {
this.selectedKey = this.rl.line.toLowerCase();
var 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
*/
Prompt.prototype.validateChoices = function( choices ) {
var formatError;
var errors = [];
var keymap = {};
choices.filter(Separator.exclude).map(function( choice ) {
if ( !choice.key || choice.key.length !== 1 ) {
formatError = true;
}
if ( keymap[choice.key] ) {
errors.push(choice.key);
}
keymap[ choice.key ] = true;
choice.key = String( choice.key ).toLowerCase();
});
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: " +
_.uniq(errors).join(", ") );
}
};
/**
* Generate a string out of the choices keys
* @param {Array} choices
* @param {Number} defaultIndex - the choice index to capitalize
* @return {String} The rendered choices key string
*/
Prompt.prototype.generateChoicesString = function( choices, defaultIndex ) {
var defIndex = 0;
if ( _.isNumber(defaultIndex) && this.opt.choices.getChoice(defaultIndex) ) {
defIndex = defaultIndex;
}
var 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) {
var output = '';
choices.forEach(function (choice, i) {
output += '\n ';
if (choice.type === 'separator') {
output += ' ' + choice;
return;
}
var choiceStr = choice.key + ') ' + choice.name;
if (pointer === choice.key) {
choiceStr = chalk.cyan(choiceStr);
}
output += choiceStr;
});
return output;
}

111
build/node_modules/inquirer/lib/prompts/input.js generated vendored Normal file
View File

@@ -0,0 +1,111 @@
/**
* `input` type prompt
*/
var util = require("util");
var chalk = require("chalk");
var Base = require("./base");
var observe = require("../utils/events");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
return Base.apply( this, arguments );
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
// Once user confirm (enter key)
var events = observe(this.rl);
var submit = events.line.map( this.filterInput.bind(this) );
var validation = this.handleSubmitEvents( submit );
validation.success.forEach( this.onEnd.bind(this) );
validation.error.forEach( this.onError.bind(this) );
events.keypress.takeUntil( validation.success ).forEach( this.onKeypress.bind(this) );
// Init
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (error) {
var bottomContent = '';
var message = this.getQuestion();
if (this.status === 'answered') {
message += chalk.cyan(this.answer);
} else {
message += this.rl.line;
}
if (error) {
bottomContent = chalk.red('>> ') + error;
}
this.screen.render(message, bottomContent);
};
/**
* When user press `enter` key
*/
Prompt.prototype.filterInput = function( input ) {
if ( !input ) {
return this.opt.default != null ? this.opt.default : "";
}
return input;
};
Prompt.prototype.onEnd = function( state ) {
this.filter( state.value, function( filteredValue ) {
this.answer = filteredValue;
this.status = "answered";
// Re-render prompt
this.render();
this.screen.done();
this.done( state.value );
}.bind(this));
};
Prompt.prototype.onError = function( state ) {
this.render(state.isValid);
};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function() {
this.render();
};

172
build/node_modules/inquirer/lib/prompts/list.js generated vendored Normal file
View File

@@ -0,0 +1,172 @@
/**
* `list` type prompt
*/
var _ = require("lodash");
var util = require("util");
var chalk = require("chalk");
var figures = require("figures");
var cliCursor = require("cli-cursor");
var Base = require("./base");
var observe = require("../utils/events");
var Paginator = require("../utils/paginator");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
Base.apply( this, arguments );
if (!this.opt.choices) {
this.throwParamError("choices");
}
this.firstRender = true;
this.selected = 0;
var def = this.opt.default;
// Default being a Number
if ( _.isNumber(def) && def >= 0 && def < this.opt.choices.realLength ) {
this.selected = def;
}
// Default being a String
if ( _.isString(def) ) {
this.selected = this.opt.choices.pluck("value").indexOf( def );
}
// Make sure no default is set (so it won't be printed)
this.opt.default = null;
this.paginator = new Paginator();
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
var events = observe(this.rl);
events.normalizedUpKey.takeUntil( events.line ).forEach( this.onUpKey.bind(this) );
events.normalizedDownKey.takeUntil( events.line ).forEach( this.onDownKey.bind(this) );
events.numberKey.takeUntil( events.line ).forEach( this.onNumberKey.bind(this) );
events.line.take(1).forEach( this.onSubmit.bind(this) );
// Init the prompt
cliCursor.hide();
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function() {
// Render question
var 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 {
var choicesStr = listRender(this.opt.choices, this.selected );
var indexPosition = this.opt.choices.indexOf(this.opt.choices.getChoice(this.selected));
message += "\n" + this.paginator.paginate(choicesStr, indexPosition, this.opt.pageSize);
}
this.firstRender = false;
this.screen.render(message);
};
/**
* When user press `enter` key
*/
Prompt.prototype.onSubmit = function() {
var choice = this.opt.choices.getChoice( this.selected );
this.status = "answered";
// Rerender prompt
this.render();
this.screen.done();
cliCursor.show();
this.done( choice.value );
};
/**
* When user press a key
*/
Prompt.prototype.onUpKey = function() {
var len = this.opt.choices.realLength;
this.selected = (this.selected > 0) ? this.selected - 1 : len - 1;
this.render();
};
Prompt.prototype.onDownKey = function() {
var len = this.opt.choices.realLength;
this.selected = (this.selected < len - 1) ? this.selected + 1 : 0;
this.render();
};
Prompt.prototype.onNumberKey = function( 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) {
var output = '';
var separatorOffset = 0;
choices.forEach(function (choice, i) {
if (choice.type === 'separator') {
separatorOffset++;
output += ' ' + choice + '\n';
return;
}
var isSelected = (i - separatorOffset === pointer);
var line = (isSelected ? figures.pointer + ' ' : ' ') + choice.name;
if (isSelected) {
line = chalk.cyan(line);
}
output += line + ' \n';
});
return output.replace(/\n$/, '');
}

118
build/node_modules/inquirer/lib/prompts/password.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
/**
* `password` type prompt
*/
var util = require("util");
var chalk = require("chalk");
var Base = require("./base");
var observe = require("../utils/events");
function mask(input) {
input = String(input);
if (input.length === 0) {
return '';
}
return new Array(input.length + 1).join('*');
}
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
return Base.apply( this, arguments );
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
var events = observe(this.rl);
// Once user confirm (enter key)
var submit = events.line.map( this.filterInput.bind(this) );
var validation = this.handleSubmitEvents( submit );
validation.success.forEach( this.onEnd.bind(this) );
validation.error.forEach( this.onError.bind(this) );
events.keypress.takeUntil( validation.success ).forEach( this.onKeypress.bind(this) );
// Init
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (error) {
var message = this.getQuestion();
var bottomContent = '';
if (this.status === 'answered') {
message += chalk.cyan(mask(this.answer));
} else {
message += mask(this.rl.line || '');
}
if (error) {
bottomContent = '\n' + chalk.red('>> ') + error;
}
this.screen.render(message, bottomContent);
};
/**
* When user press `enter` key
*/
Prompt.prototype.filterInput = function( input ) {
if ( !input ) {
return this.opt.default != null ? this.opt.default : "";
}
return input;
};
Prompt.prototype.onEnd = function( state ) {
this.status = "answered";
this.answer = state.value;
// Re-render prompt
this.render();
this.screen.done();
this.done( state.value );
};
Prompt.prototype.onError = function( state ) {
this.render(state.isValid);
this.rl.output.unmute();
};
/**
* When user type
*/
Prompt.prototype.onKeypress = function() {
this.render();
};

183
build/node_modules/inquirer/lib/prompts/rawlist.js generated vendored Normal file
View File

@@ -0,0 +1,183 @@
/**
* `rawlist` type prompt
*/
var _ = require("lodash");
var util = require("util");
var chalk = require("chalk");
var Base = require("./base");
var Separator = require("../objects/separator");
var observe = require("../utils/events");
var Paginator = require("../utils/paginator");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt() {
Base.apply( this, arguments );
if (!this.opt.choices) {
this.throwParamError("choices");
}
this.opt.validChoices = this.opt.choices.filter(Separator.exclude);
this.selected = 0;
this.rawDefault = 0;
_.extend(this.opt, {
validate: function( index ) {
return this.opt.choices.getChoice( index ) != null;
}.bind(this)
});
var def = this.opt.default;
if ( _.isNumber(def) && def >= 0 && def < this.opt.choices.realLength ) {
this.selected = this.rawDefault = def;
}
// Make sure no default is set (so it won't be printed)
this.opt.default = null;
this.paginator = new Paginator();
}
util.inherits( Prompt, Base );
/**
* Start the Inquiry session
* @param {Function} cb Callback when prompt is done
* @return {this}
*/
Prompt.prototype._run = function( cb ) {
this.done = cb;
// Once user confirm (enter key)
var events = observe(this.rl);
var submit = events.line.map( this.filterInput.bind(this) );
var validation = this.handleSubmitEvents( submit );
validation.success.forEach( this.onEnd.bind(this) );
validation.error.forEach( this.onError.bind(this) );
events.keypress.takeUntil( validation.success ).forEach( this.onKeypress.bind(this) );
// Init the prompt
this.render();
return this;
};
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function (error) {
// Render question
var message = this.getQuestion();
var bottomContent = '';
if ( this.status === "answered" ) {
message += chalk.cyan(this.opt.choices.getChoice(this.selected).name);
} else {
var choicesStr = renderChoices(this.opt.choices, this.selected);
message += 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
*/
Prompt.prototype.filterInput = function( input ) {
if ( input == null || input === "" ) {
return this.rawDefault;
} else {
return input - 1;
}
};
Prompt.prototype.onEnd = function( state ) {
this.status = "answered";
this.selected = state.value;
var selectedChoice = this.opt.choices.getChoice( this.selected );
// Re-render prompt
this.render();
this.screen.done();
this.done( selectedChoice.value );
};
Prompt.prototype.onError = function() {
this.render("Please enter a valid index");
};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function() {
var index = this.rl.line.length ? Number(this.rl.line) - 1 : 0;
if ( this.opt.choices.getChoice(index) ) {
this.selected = index;
} else {
this.selected = undefined;
}
this.render();
};
/**
* Function for rendering list choices
* @param {Number} pointer Position of the pointer
* @return {String} Rendered content
*/
function renderChoices(choices, pointer) {
var output = '';
var separatorOffset = 0;
choices.forEach(function (choice, i) {
output += '\n ';
if (choice.type === 'separator') {
separatorOffset++;
output += ' ' + choice;
return;
}
var index = i - separatorOffset;
var display = (index + 1) + ') ' + choice.name;
if (index === pointer) {
display = chalk.cyan( display );
}
output += display;
});
return output;
}

56
build/node_modules/inquirer/lib/ui/baseUI.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
var _ = require('lodash');
var readlineFacade = require('readline2');
/**
* Base interface class other can inherits from
*/
var UI = module.exports = function (opt) {
// Instantiate the Readline interface
// @Note: Don't reassign if already present (allow test to override the Stream)
if (!this.rl) {
this.rl = readlineFacade.createInterface(_.extend({
terminal: true
}, opt));
}
this.rl.resume();
this.onForceClose = this.onForceClose.bind(this);
// Make sure new prompt start on a newline when closing
this.rl.on('SIGINT', this.onForceClose);
process.on('exit', this.onForceClose);
};
/**
* Handle the ^C exit
* @return {null}
*/
UI.prototype.onForceClose = function () {
this.close();
console.log('\n'); // Line return
};
/**
* Close the interface and cleanup listeners
*/
UI.prototype.close = function () {
// Remove events listeners
this.rl.removeListener('SIGINT', this.onForceClose);
process.removeListener('exit', this.onForceClose);
// Restore prompt functionnalities
this.rl.output.unmute();
// Close the readline
this.rl.output.end();
this.rl.pause();
this.rl.close();
this.rl = null;
};

98
build/node_modules/inquirer/lib/ui/bottom-bar.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
/**
* Sticky bottom bar user interface
*/
var util = require("util");
var through = require("through");
var Base = require("./baseUI");
var rlUtils = require("../utils/readline");
var _ = require("lodash");
/**
* Module exports
*/
module.exports = Prompt;
/**
* Constructor
*/
function Prompt( opt ) {
opt || (opt = {});
Base.apply( this, arguments );
this.log = through( this.writeLog.bind(this) );
this.bottomBar = opt.bottomBar || "";
this.render();
}
util.inherits( Prompt, Base );
/**
* Render the prompt to screen
* @return {Prompt} self
*/
Prompt.prototype.render = function() {
this.write(this.bottomBar);
return this;
};
/**
* Update the bottom bar content and rerender
* @param {String} bottomBar Bottom bar content
* @return {Prompt} self
*/
Prompt.prototype.updateBottomBar = function( bottomBar ) {
this.bottomBar = bottomBar;
rlUtils.clearLine(this.rl, 1);
return this.render();
};
/**
* Rerender the prompt
* @return {Prompt} self
*/
Prompt.prototype.writeLog = function( data ) {
rlUtils.clearLine(this.rl, 1);
this.rl.output.write(this.enforceLF(data.toString()));
return this.render();
};
/**
* Make sure line end on a line feed
* @param {String} str Input string
* @return {String} The input string with a final line feed
*/
Prompt.prototype.enforceLF = function( str ) {
return str.match(/[\r\n]$/) ? str : str + "\n";
};
/**
* Helper for writing message in Prompt
* @param {Prompt} prompt - The Prompt object that extends tty
* @param {String} message - The message to be output
*/
Prompt.prototype.write = function (message) {
var msgLines = message.split(/\n/);
this.height = msgLines.length;
// Write message to screen and setPrompt to control backspace
this.rl.setPrompt( _.last(msgLines) );
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 );
};

126
build/node_modules/inquirer/lib/ui/prompt.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
'use strict';
var _ = require('lodash');
var rx = require('rx-lite');
var util = require('util');
var runAsync = require('run-async');
var utils = require('../utils/utils');
var Base = require('./baseUI');
/**
* Base interface class other can inherits from
*/
var PromptUI = module.exports = function (prompts, opt) {
Base.call(this, opt);
this.prompts = prompts;
};
util.inherits(PromptUI, Base);
PromptUI.prototype.run = function (questions, allDone) {
// Keep global reference to the answers
this.answers = {};
this.completed = allDone;
// Make sure questions is an array.
if (_.isPlainObject(questions)) {
questions = [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.
var obs = _.isArray(questions) ? rx.Observable.from(questions) : questions;
this.process = obs
.concatMap(this.processQuestion.bind(this))
.publish(); // `publish` creates a hot Observable. It prevents duplicating prompts.
this.process.subscribe(
_.noop,
function (err) { throw err; },
this.onCompletion.bind(this)
);
return this.process.connect();
};
/**
* Once all prompt are over
*/
PromptUI.prototype.onCompletion = function () {
this.close();
if (_.isFunction(this.completed)) {
this.completed(this.answers);
}
};
PromptUI.prototype.processQuestion = function (question) {
return rx.Observable.defer(function () {
var obs = rx.Observable.create(function (obs) {
obs.onNext(question);
obs.onCompleted();
});
return obs
.concatMap(this.setDefaultType.bind(this))
.concatMap(this.filterIfRunnable.bind(this))
.concatMap(utils.fetchAsyncQuestionProperty.bind(null, question, 'message', this.answers))
.concatMap(utils.fetchAsyncQuestionProperty.bind(null, question, 'default', this.answers))
.concatMap(utils.fetchAsyncQuestionProperty.bind(null, question, 'choices', this.answers))
.concatMap(this.fetchAnswer.bind(this));
}.bind(this));
};
PromptUI.prototype.fetchAnswer = function (question) {
var Prompt = this.prompts[question.type];
var prompt = new Prompt(question, this.rl, this.answers);
var answers = this.answers;
return utils.createObservableFromAsync(function () {
var done = this.async();
prompt.run(function (answer) {
answers[question.name] = answer;
done({ name: question.name, answer: answer });
});
});
};
PromptUI.prototype.setDefaultType = function (question) {
// Default type to input
if (!this.prompts[question.type]) {
question.type = 'input';
}
return rx.Observable.defer(function () {
return rx.Observable.return(question);
});
};
PromptUI.prototype.filterIfRunnable = function (question) {
if (question.when == null) {
return rx.Observable.return(question);
}
var handleResult = function (obs, shouldRun) {
if (shouldRun) {
obs.onNext(question);
}
obs.onCompleted();
};
var answers = this.answers;
return rx.Observable.defer(function () {
return rx.Observable.create(function (obs) {
if (_.isBoolean(question.when)) {
handleResult(obs, question.when);
return;
}
runAsync(question.when, function (shouldRun) {
handleResult(obs, shouldRun);
}, answers);
});
});
};

37
build/node_modules/inquirer/lib/utils/events.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
var rx = require('rx-lite');
function normalizeKeypressEvents(value, key) {
return { value: value, key: key || {} };
}
module.exports = function (rl) {
var keypress = rx.Observable.fromEvent(rl.input, 'keypress', normalizeKeypressEvents)
.filter(function (e) {
// Ignore `enter` key. On the readline, we only care about the `line` event.
return e.key.name !== 'enter' && e.key.name !== 'return';
});
return {
line: rx.Observable.fromEvent(rl, 'line'),
keypress: keypress,
normalizedUpKey: keypress.filter(function (e) {
return e.key.name === 'up' || e.key.name === 'k' || (e.key.name === 'p' && e.key.ctrl);
}).share(),
normalizedDownKey: keypress.filter(function (e) {
return e.key.name === 'down' || e.key.name === 'j' || (e.key.name === 'n' && e.key.ctrl);
}).share(),
numberKey: keypress.filter(function (e) {
return e.value && '123456789'.indexOf(e.value) >= 0;
}).map(function (e) {
return Number(e.value);
}).share(),
spaceKey: keypress.filter(function (e) {
return e.key && e.key.name === 'space';
}).share()
};
};

38
build/node_modules/inquirer/lib/utils/paginator.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
var _ = require('lodash');
var chalk = require('chalk');
/**
* The paginator keep trakcs of a pointer index in a list and return
* a subset of the choices if the list is too long.
*/
var Paginator = module.exports = function () {
this.pointer = 0;
this.lastIndex = 0;
};
Paginator.prototype.paginate = function (output, active, pageSize) {
var pageSize = pageSize || 7;
var lines = output.split('\n');
// Make sure there's enough lines to paginate
if (lines.length <= pageSize + 2) {
return output;
}
// Move the pointer only when the user go down and limit it to 3
if (this.pointer < 3 && this.lastIndex < active && active - this.lastIndex < 9) {
this.pointer = Math.min(3, this.pointer + active - this.lastIndex);
}
this.lastIndex = active;
// Duplicate the lines so it give an infinite list look
var infinite = _.flatten([lines, lines, lines]);
var topIndex = Math.max(0, active + lines.length - this.pointer);
var section = infinite.splice(topIndex, pageSize).join('\n');
return section + '\n' + chalk.dim('(Move up and down to reveal more choices)');
};

51
build/node_modules/inquirer/lib/utils/readline.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
'use strict';
var ansiEscapes = require('ansi-escapes');
/**
* Move cursor left by `x`
* @param {Readline} rl - Readline instance
* @param {Number} x - How far to go left (default to 1)
*/
exports.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)
*/
exports.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)
*/
exports.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)
*/
exports.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
*/
exports.clearLine = function (rl, len) {
rl.output.write(ansiEscapes.eraseLines(len));
};

129
build/node_modules/inquirer/lib/utils/screen-manager.js generated vendored Normal file
View File

@@ -0,0 +1,129 @@
'use strict';
var _ = require('lodash');
var util = require('./readline');
var cliWidth = require('cli-width');
var stripAnsi = require('strip-ansi');
var stringWidth = require('string-width');
function height(content) {
return content.split('\n').length;
}
function lastLine(content) {
return _.last(content.split('\n'));
}
var ScreenManager = module.exports = function (rl) {
// These variables are keeping information to allow correct prompt re-rendering
this.height = 0;
this.extraLinesUnderPrompt = 0;
this.rl = rl;
};
ScreenManager.prototype.render = function (content, bottomContent) {
this.rl.output.unmute();
this.clean(this.extraLinesUnderPrompt);
/**
* Write message to screen and setPrompt to control backspace
*/
var promptLine = lastLine(content);
var 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.
var prompt = promptLine;
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
var cursorPos = this.rl._getCursorPos();
var width = this.normalizedCliWidth();
content = forceLineReturn(content, width);
if (bottomContent) {
bottomContent = 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 = content + '\n';
}
var 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.
var promptLineUpDiff = Math.floor(rawPromptLine.length / width) - cursorPos.rows;
var 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
util.right(this.rl, cursorPos.cols);
/**
* Set up state for next re-rendering
*/
this.extraLinesUnderPrompt = bottomContentHeight;
this.height = height(fullContent);
this.rl.output.mute();
};
ScreenManager.prototype.clean = function (extraLines) {
if (extraLines > 0) {
util.down(this.rl, extraLines);
}
util.clearLine(this.rl, this.height);
};
ScreenManager.prototype.done = function () {
this.rl.setPrompt('');
this.rl.output.unmute();
this.rl.output.write('\n');
};
ScreenManager.prototype.normalizedCliWidth = function () {
var width = cliWidth({
defaultWidth: 80,
output: this.rl.output
});
if (process.platform === 'win32') {
return width - 1;
}
return width;
};
function breakLines(lines, width) {
// Break lines who're longuer than the cli width so we can normalize the natural line
// returns behavior accross terminals.
var regex = new RegExp(
'(?:(?:\\033\[[0-9;]*m)*.?){1,' + width + '}',
'g'
);
return lines.map(function (line) {
var chunk = line.match(regex);
// last match is always empty
chunk.pop();
return chunk || '';
});
}
function forceLineReturn(content, width) {
return _.flatten(breakLines(content.split('\n'), width)).join('\n');
}

47
build/node_modules/inquirer/lib/utils/utils.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
'use strict';
var _ = require('lodash');
var rx = require('rx-lite');
var runAsync = require('run-async');
/**
* Create an oversable returning the result of a function runned in sync or async mode.
* @param {Function} func Function to run
* @return {rx.Observable} Observable emitting when value is known
*/
exports.createObservableFromAsync = function (func) {
return rx.Observable.defer(function () {
return rx.Observable.create(function (obs) {
runAsync(func, function (value) {
obs.onNext(value);
obs.onCompleted();
});
});
});
};
/**
* 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
* @...rest {Mixed} rest - Arguments to pass to `func`
* @return {rx.Obsersable} - Observable emitting once value is known
*/
exports.fetchAsyncQuestionProperty = function (question, prop, answers) {
if (!_.isFunction(question[prop])) {
return rx.Observable.return(question);
}
return exports.createObservableFromAsync(function () {
var done = this.async();
runAsync(question[prop], function (value) {
question[prop] = value;
done(question);
}, answers);
});
};

View File

@@ -0,0 +1,65 @@
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.

View File

@@ -0,0 +1,90 @@
{
"_from": "ansi-styles@^2.2.1",
"_id": "ansi-styles@2.2.1",
"_inBundle": false,
"_integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
"_location": "/inquirer/ansi-styles",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "ansi-styles@^2.2.1",
"name": "ansi-styles",
"escapedName": "ansi-styles",
"rawSpec": "^2.2.1",
"saveSpec": null,
"fetchSpec": "^2.2.1"
},
"_requiredBy": [
"/inquirer/chalk"
],
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"_shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
"_spec": "ansi-styles@^2.2.1",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/inquirer/node_modules/chalk",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/ansi-styles/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "ANSI escape codes for styling strings in the terminal",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/ansi-styles#readme",
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
}
],
"name": "ansi-styles",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-styles.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.2.1"
}

View File

@@ -0,0 +1,86 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
![](screenshot.png)
## Install
```
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## Advanced usage
By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `ansi.modifiers`
- `ansi.colors`
- `ansi.bgColors`
###### Example
```js
console.log(ansi.colors.green.open);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

116
build/node_modules/inquirer/node_modules/chalk/index.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function build(_styles) {
var builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/* eslint-disable no-proto */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
var nestedStyles = this._styles;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// 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'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;

21
build/node_modules/inquirer/node_modules/chalk/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.

View File

@@ -0,0 +1,114 @@
{
"_from": "chalk@^1.0.0",
"_id": "chalk@1.1.3",
"_inBundle": false,
"_integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"_location": "/inquirer/chalk",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "chalk@^1.0.0",
"name": "chalk",
"escapedName": "chalk",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/inquirer"
],
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"_shasum": "a8115c55e4a702fe4d150abd3872822a7e09fc98",
"_spec": "chalk@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/inquirer",
"bugs": {
"url": "https://github.com/chalk/chalk/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
},
"deprecated": false,
"description": "Terminal string styling done right. Much color.",
"devDependencies": {
"coveralls": "^2.11.2",
"matcha": "^0.6.0",
"mocha": "*",
"nyc": "^3.0.0",
"require-uncached": "^1.0.2",
"resolve-from": "^1.0.0",
"semver": "^4.3.3",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/chalk#readme",
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
},
{
"name": "JD Ballard",
"email": "i.am.qix@gmail.com",
"url": "github.com/qix-"
}
],
"name": "chalk",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/chalk.git"
},
"scripts": {
"bench": "matcha benchmark.js",
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"test": "xo && mocha"
},
"version": "1.1.3",
"xo": {
"envs": [
"node",
"mocha"
]
}
}

View File

@@ -0,0 +1,213 @@
<h1 align="center">
<br>
<br>
<img width="360" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
<br>
<br>
<br>
</h1>
> Terminal string styling done right
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk)
[![Coverage Status](https://coveralls.io/repos/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/r/chalk/chalk?branch=master)
[![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4)
[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). Although there are other ones, they either do too much or not enough.
**Chalk is a clean and focused alternative.**
![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)
## Why
- Highly performant
- Doesn't extend `String.prototype`
- Expressive API
- Ability to nest styles
- Clean and focused
- Auto-detects color support
- Actively maintained
- [Used by ~4500 modules](https://www.npmjs.com/browse/depended/chalk) as of July 15, 2015
## Install
```
$ npm install --save chalk
```
## Usage
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
var chalk = require('chalk');
// style a string
chalk.blue('Hello world!');
// combine styled and normal strings
chalk.blue('Hello') + 'World' + chalk.red('!');
// compose multiple styles using the chainable API
chalk.blue.bgRed.bold('Hello world!');
// pass in multiple arguments
chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz');
// nest styles
chalk.red('Hello', chalk.underline.bgBlue('world') + '!');
// nest styles of the same type even (color, underline, background)
chalk.green(
'I am a green line ' +
chalk.blue.underline.bold('with a blue substring') +
' that becomes green again!'
);
```
Easily define your own themes.
```js
var chalk = require('chalk');
var error = chalk.bold.red;
console.log(error('Error!'));
```
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
```js
var 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.enabled
Color support is automatically detected, but you can override it by setting the `enabled` 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
var ctx = new chalk.constructor({enabled: false});
```
### chalk.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, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
### chalk.styles
Exposes the styles as [ANSI escape codes](https://github.com/chalk/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.
```js
var chalk = require('chalk');
console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'}
console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
```
### chalk.hasColor(string)
Check whether a string [has color](https://github.com/chalk/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/chalk/strip-ansi) from a string.
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
Example:
```js
var chalk = require('chalk');
var styledString = getText();
if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString);
}
```
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue` *(on Windows the bright version is used as normal blue is illegible)*
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## 256-colors
Chalk does not support anything other than the base eight colors, which guarantees it will work on all terminals and systems. Some terminals, specifically `xterm` compliant ones, will support the full range of 8-bit colors. For this the lower level [ansi-256-colors](https://github.com/jbnicolai/ansi-256-colors) package can be used.
## Windows
If you're on Windows, do yourself a favor and use [`cmder`](http://bliker.github.io/cmder/) instead of `cmd.exe`.
## Related
- [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
- [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
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,50 @@
'use strict';
var argv = process.argv;
var terminator = argv.indexOf('--');
var hasFlag = function (flag) {
flag = '--' + flag;
var pos = argv.indexOf(flag);
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
};
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return false;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.

View File

@@ -0,0 +1,89 @@
{
"_from": "supports-color@^2.0.0",
"_id": "supports-color@2.0.0",
"_inBundle": false,
"_integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"_location": "/inquirer/supports-color",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "supports-color@^2.0.0",
"name": "supports-color",
"escapedName": "supports-color",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/inquirer/chalk"
],
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"_shasum": "535d045ce6b6363fa40117084629995e9df324c7",
"_spec": "supports-color@^2.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/inquirer/node_modules/chalk",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/supports-color/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect whether a terminal supports color",
"devDependencies": {
"mocha": "*",
"require-uncached": "^1.0.2"
},
"engines": {
"node": ">=0.8.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/supports-color#readme",
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
}
],
"name": "supports-color",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/supports-color.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.0.0"
}

View File

@@ -0,0 +1,36 @@
# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
> Detect whether a terminal supports color
## Install
```
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
```
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

88
build/node_modules/inquirer/package.json generated vendored Normal file
View File

@@ -0,0 +1,88 @@
{
"_from": "inquirer@^0.12.0",
"_id": "inquirer@0.12.0",
"_inBundle": false,
"_integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=",
"_location": "/inquirer",
"_phantomChildren": {
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "inquirer@^0.12.0",
"name": "inquirer",
"escapedName": "inquirer",
"rawSpec": "^0.12.0",
"saveSpec": null,
"fetchSpec": "^0.12.0"
},
"_requiredBy": [
"/pwa-manifest"
],
"_resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz",
"_shasum": "1ef2bfd63504df0bc75785fff8c2c41df12f077e",
"_spec": "inquirer@^0.12.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/pwa-manifest",
"author": {
"name": "Simon Boudrias",
"email": "admin@simonboudrias.com"
},
"bugs": {
"url": "https://github.com/SBoudrias/Inquirer.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-escapes": "^1.1.0",
"ansi-regex": "^2.0.0",
"chalk": "^1.0.0",
"cli-cursor": "^1.0.1",
"cli-width": "^2.0.0",
"figures": "^1.3.5",
"lodash": "^4.3.0",
"readline2": "^1.0.1",
"run-async": "^0.1.0",
"rx-lite": "^3.1.2",
"string-width": "^1.0.1",
"strip-ansi": "^3.0.0",
"through": "^2.3.6"
},
"deprecated": false,
"description": "A collection of common interactive command line user interfaces.",
"devDependencies": {
"chai": "^3.0.0",
"cmdify": "^0.0.4",
"grunt": "^0.4.1",
"grunt-cli": "^0.1.8",
"grunt-contrib-jshint": "^0.11.1",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.2.1",
"mockery": "^1.4.0",
"sinon": "^1.12.1"
},
"files": [
"lib"
],
"homepage": "https://github.com/SBoudrias/Inquirer.js#readme",
"keywords": [
"command",
"prompt",
"stdin",
"cli",
"tty",
"menu"
],
"license": "MIT",
"main": "lib/inquirer.js",
"name": "inquirer",
"repository": {
"type": "git",
"url": "git+https://github.com/SBoudrias/Inquirer.js.git"
},
"scripts": {
"test": "grunt --verbose"
},
"version": "0.12.0"
}