node_modules updated, buefy add to lib folder
This commit is contained in:
+2
@@ -33,6 +33,7 @@ inquirer.createPromptModule = function(opt) {
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
promptModule.prompts = {};
|
||||
|
||||
/**
|
||||
@@ -81,6 +82,7 @@ inquirer.prompt = inquirer.createPromptModule();
|
||||
inquirer.registerPrompt = function(name, prompt) {
|
||||
inquirer.prompt.registerPrompt(name, prompt);
|
||||
};
|
||||
|
||||
inquirer.restoreDefaultPrompts = function() {
|
||||
inquirer.prompt.restoreDefaultPrompts();
|
||||
};
|
||||
|
||||
+5
-5
@@ -5,8 +5,8 @@ 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
|
||||
* @param {Number|String|Object} val Choice value. If an object is passed, it should contains
|
||||
* at least one of `value` or `name` property
|
||||
*/
|
||||
|
||||
module.exports = class Choice {
|
||||
@@ -16,10 +16,10 @@ module.exports = class Choice {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (_.isString(val)) {
|
||||
this.name = val;
|
||||
if (_.isString(val) || _.isNumber(val)) {
|
||||
this.name = String(val);
|
||||
this.value = val;
|
||||
this.short = val;
|
||||
this.short = String(val);
|
||||
} else {
|
||||
_.extend(this, val, {
|
||||
name: val.name || val.value,
|
||||
|
||||
+2
@@ -18,8 +18,10 @@ module.exports = class Choices {
|
||||
if (!(val instanceof Separator)) {
|
||||
val = new Separator(val.line);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
return new Choice(val, answers);
|
||||
});
|
||||
|
||||
|
||||
+3
-2
@@ -29,7 +29,6 @@ class CheckboxPrompt extends Base {
|
||||
}
|
||||
|
||||
this.pointer = 0;
|
||||
this.firstRender = true;
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
@@ -87,7 +86,7 @@ class CheckboxPrompt extends Base {
|
||||
var message = this.getQuestion();
|
||||
var bottomContent = '';
|
||||
|
||||
if (this.firstRender) {
|
||||
if (!this.spaceKeyPressed) {
|
||||
message +=
|
||||
'(Press ' +
|
||||
chalk.cyan.bold('<space>') +
|
||||
@@ -162,10 +161,12 @@ class CheckboxPrompt extends Base {
|
||||
this.pointer = input - 1;
|
||||
this.toggleChoice(this.pointer);
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
onSpaceKey() {
|
||||
this.spaceKeyPressed = true;
|
||||
this.toggleChoice(this.pointer);
|
||||
this.render();
|
||||
}
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ class ConfirmPrompt extends Base {
|
||||
if (input != null && input !== '') {
|
||||
value = /^y(es)?/i.test(input);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
+9
@@ -102,6 +102,7 @@ class ExpandPrompt extends Base {
|
||||
if (!input) {
|
||||
input = this.rawDefault;
|
||||
}
|
||||
|
||||
var selected = this.opt.choices.where({ key: input.toLowerCase().trim() })[0];
|
||||
if (!selected) {
|
||||
return null;
|
||||
@@ -130,6 +131,7 @@ class ExpandPrompt extends Base {
|
||||
if (this.selectedKey === choice.key) {
|
||||
choiceStr = chalk.cyan(choiceStr);
|
||||
}
|
||||
|
||||
output += choiceStr;
|
||||
});
|
||||
|
||||
@@ -143,6 +145,7 @@ class ExpandPrompt extends Base {
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
|
||||
this.render(state.isValid);
|
||||
}
|
||||
|
||||
@@ -188,9 +191,11 @@ class ExpandPrompt extends Base {
|
||||
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();
|
||||
});
|
||||
@@ -200,11 +205,13 @@ class ExpandPrompt extends Base {
|
||||
'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: ' +
|
||||
@@ -230,6 +237,7 @@ class ExpandPrompt extends Base {
|
||||
);
|
||||
defIndex = index === -1 ? defIndex : index;
|
||||
}
|
||||
|
||||
var defStr = this.opt.choices.pluck('key');
|
||||
this.rawDefault = defStr[defIndex];
|
||||
defStr[defIndex] = String(defStr[defIndex]).toUpperCase();
|
||||
@@ -258,6 +266,7 @@ function renderChoices(choices, pointer) {
|
||||
if (pointer === choice.key) {
|
||||
choiceStr = chalk.cyan(choiceStr);
|
||||
}
|
||||
|
||||
output += choiceStr;
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -75,6 +75,7 @@ class InputPrompt extends Base {
|
||||
if (!input) {
|
||||
return this.opt.default == null ? '' : this.opt.default;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -140,6 +140,7 @@ class ListPrompt extends Base {
|
||||
if (input <= this.opt.choices.realLength) {
|
||||
this.selected = input - 1;
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
@@ -173,6 +174,7 @@ function listRender(choices, pointer) {
|
||||
if (isSelected) {
|
||||
line = chalk.cyan(line);
|
||||
}
|
||||
|
||||
output += line + ' \n';
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ class NumberPrompt extends Input {
|
||||
return Number(numberMatch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// If the input was invalid return the default value.
|
||||
return this.opt.default == null ? NaN : this.opt.default;
|
||||
}
|
||||
|
||||
+4
-5
@@ -37,11 +37,9 @@ class PasswordPrompt extends Base {
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
if (this.opt.mask) {
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
}
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
|
||||
// Init
|
||||
this.render();
|
||||
@@ -83,6 +81,7 @@ class PasswordPrompt extends Base {
|
||||
if (!input) {
|
||||
return this.opt.default == null ? '' : this.opt.default;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
+36
-1
@@ -67,6 +67,10 @@ class RawListPrompt extends Base {
|
||||
events.keypress
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onKeypress.bind(this));
|
||||
events.normalizedUpKey.pipe(takeUntil(events.line)).forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(events.line))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
this.render();
|
||||
@@ -88,7 +92,8 @@ class RawListPrompt extends Base {
|
||||
message += chalk.cyan(this.answer);
|
||||
} else {
|
||||
var choicesStr = renderChoices(this.opt.choices, this.selected);
|
||||
message += this.paginator.paginate(choicesStr, this.selected, this.opt.pageSize);
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, this.selected, this.opt.pageSize);
|
||||
message += '\n Answer: ';
|
||||
}
|
||||
|
||||
@@ -146,6 +151,35 @@ class RawListPrompt extends Base {
|
||||
|
||||
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) {
|
||||
var index = this.rl.line.length ? Number(this.rl.line) - 1 : 0;
|
||||
if (type === 'up') index = index === 0 ? this.opt.choices.length - 1 : index - 1;
|
||||
else index = index === this.opt.choices.length - 1 ? 0 : index + 1;
|
||||
this.rl.line = String(index + 1);
|
||||
this.onKeypress();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +206,7 @@ function renderChoices(choices, pointer) {
|
||||
if (index === pointer) {
|
||||
display = chalk.cyan(display);
|
||||
}
|
||||
|
||||
output += display;
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ class UI {
|
||||
if (!this.rl) {
|
||||
this.rl = readline.createInterface(setupReadlineOptions(opt));
|
||||
}
|
||||
|
||||
this.rl.resume();
|
||||
|
||||
this.onForceClose = this.onForceClose.bind(this);
|
||||
|
||||
+1
@@ -92,6 +92,7 @@ class BottomBar extends Base {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -95,6 +95,7 @@ class PromptUI extends Base {
|
||||
if (!this.prompts[question.type]) {
|
||||
question.type = 'input';
|
||||
}
|
||||
|
||||
return defer(() => of(question));
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ class Paginator {
|
||||
) {
|
||||
this.pointer = Math.min(middleOfList, this.pointer + active - this.lastIndex);
|
||||
}
|
||||
|
||||
this.lastIndex = active;
|
||||
|
||||
// Duplicate the lines so it give an infinite list look
|
||||
|
||||
+4
@@ -40,6 +40,7 @@ class ScreenManager {
|
||||
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
|
||||
@@ -50,12 +51,14 @@ class ScreenManager {
|
||||
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';
|
||||
}
|
||||
|
||||
var fullContent = content + (bottomContent ? '\n' + bottomContent : '');
|
||||
this.rl.output.write(fullContent);
|
||||
|
||||
@@ -93,6 +96,7 @@ class ScreenManager {
|
||||
if (extraLines > 0) {
|
||||
util.down(this.rl, extraLines);
|
||||
}
|
||||
|
||||
util.clearLine(this.rl, this.height);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user