anl 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/bin/an-cli.js +3 -0
- package/lib/_virtual/_cloneBuffer.js +7 -0
- package/lib/_virtual/_commonjsHelpers.js +7 -0
- package/lib/_virtual/_nodeUtil.js +7 -0
- package/lib/_virtual/argument.js +7 -0
- package/lib/_virtual/command.js +7 -0
- package/lib/_virtual/eastasianwidth.js +7 -0
- package/lib/_virtual/error.js +7 -0
- package/lib/_virtual/help.js +7 -0
- package/lib/_virtual/index.js +7 -0
- package/lib/_virtual/index2.js +7 -0
- package/lib/_virtual/index3.js +7 -0
- package/lib/_virtual/isBuffer.js +7 -0
- package/lib/_virtual/lodash.js +7 -0
- package/lib/_virtual/option.js +7 -0
- package/lib/_virtual/signals.js +7 -0
- package/lib/_virtual/suggestSimilar.js +7 -0
- package/lib/node_modules/ansi-escapes/index.js +166 -0
- package/lib/node_modules/ansi-styles/index.js +229 -0
- package/lib/node_modules/cli-cursor/index.js +47 -0
- package/lib/node_modules/cli-width/index.js +59 -0
- package/lib/node_modules/commander/esm.mjs.js +32 -0
- package/lib/node_modules/commander/index.js +49 -0
- package/lib/node_modules/commander/lib/argument.js +157 -0
- package/lib/node_modules/commander/lib/command.js +2208 -0
- package/lib/node_modules/commander/lib/error.js +53 -0
- package/lib/node_modules/commander/lib/help.js +474 -0
- package/lib/node_modules/commander/lib/option.js +336 -0
- package/lib/node_modules/commander/lib/suggestSimilar.js +108 -0
- package/lib/node_modules/eastasianwidth/eastasianwidth.js +321 -0
- package/lib/node_modules/figures/index.js +304 -0
- package/lib/node_modules/inquirer/lib/inquirer.js +109 -0
- package/lib/node_modules/inquirer/lib/objects/choice.js +41 -0
- package/lib/node_modules/inquirer/lib/objects/choices.js +125 -0
- package/lib/node_modules/inquirer/lib/objects/separator.js +43 -0
- package/lib/node_modules/inquirer/lib/prompts/base.js +194 -0
- package/lib/node_modules/inquirer/lib/prompts/checkbox.js +283 -0
- package/lib/node_modules/inquirer/lib/prompts/confirm.js +106 -0
- package/lib/node_modules/inquirer/lib/prompts/editor.js +113 -0
- package/lib/node_modules/inquirer/lib/prompts/expand.js +281 -0
- package/lib/node_modules/inquirer/lib/prompts/input.js +118 -0
- package/lib/node_modules/inquirer/lib/prompts/list.js +218 -0
- package/lib/node_modules/inquirer/lib/prompts/number.js +32 -0
- package/lib/node_modules/inquirer/lib/prompts/password.js +135 -0
- package/lib/node_modules/inquirer/lib/prompts/rawlist.js +236 -0
- package/lib/node_modules/inquirer/lib/ui/baseUI.js +99 -0
- package/lib/node_modules/inquirer/lib/ui/bottom-bar.js +103 -0
- package/lib/node_modules/inquirer/lib/ui/prompt.js +158 -0
- package/lib/node_modules/inquirer/lib/utils/events.js +62 -0
- package/lib/node_modules/inquirer/lib/utils/incrementListIndex.js +23 -0
- package/lib/node_modules/inquirer/lib/utils/paginator.js +87 -0
- package/lib/node_modules/inquirer/lib/utils/readline.js +60 -0
- package/lib/node_modules/inquirer/lib/utils/screen-manager.js +183 -0
- package/lib/node_modules/inquirer/lib/utils/utils.js +31 -0
- package/lib/node_modules/inquirer/node_modules/ansi-regex/index.js +14 -0
- package/lib/node_modules/inquirer/node_modules/strip-ansi/index.js +15 -0
- package/lib/node_modules/is-unicode-supported/index.js +27 -0
- package/lib/node_modules/lodash/_DataView.js +16 -0
- package/lib/node_modules/lodash/_Hash.js +44 -0
- package/lib/node_modules/lodash/_ListCache.js +44 -0
- package/lib/node_modules/lodash/_Map.js +16 -0
- package/lib/node_modules/lodash/_MapCache.js +44 -0
- package/lib/node_modules/lodash/_Promise.js +16 -0
- package/lib/node_modules/lodash/_Set.js +16 -0
- package/lib/node_modules/lodash/_Stack.js +40 -0
- package/lib/node_modules/lodash/_Symbol.js +14 -0
- package/lib/node_modules/lodash/_Uint8Array.js +14 -0
- package/lib/node_modules/lodash/_WeakMap.js +16 -0
- package/lib/node_modules/lodash/_apply.js +28 -0
- package/lib/node_modules/lodash/_arrayEach.js +29 -0
- package/lib/node_modules/lodash/_arrayFilter.js +32 -0
- package/lib/node_modules/lodash/_arrayLikeKeys.js +63 -0
- package/lib/node_modules/lodash/_arrayMap.js +28 -0
- package/lib/node_modules/lodash/_arrayPush.js +27 -0
- package/lib/node_modules/lodash/_assignValue.js +37 -0
- package/lib/node_modules/lodash/_assocIndexOf.js +29 -0
- package/lib/node_modules/lodash/_baseAssign.js +26 -0
- package/lib/node_modules/lodash/_baseAssignIn.js +26 -0
- package/lib/node_modules/lodash/_baseAssignValue.js +33 -0
- package/lib/node_modules/lodash/_baseClone.js +197 -0
- package/lib/node_modules/lodash/_baseCreate.js +38 -0
- package/lib/node_modules/lodash/_baseGet.js +33 -0
- package/lib/node_modules/lodash/_baseGetAllKeys.js +29 -0
- package/lib/node_modules/lodash/_baseGetTag.js +38 -0
- package/lib/node_modules/lodash/_baseIsArguments.js +27 -0
- package/lib/node_modules/lodash/_baseIsMap.js +27 -0
- package/lib/node_modules/lodash/_baseIsNative.js +58 -0
- package/lib/node_modules/lodash/_baseIsSet.js +27 -0
- package/lib/node_modules/lodash/_baseIsTypedArray.js +70 -0
- package/lib/node_modules/lodash/_baseKeys.js +39 -0
- package/lib/node_modules/lodash/_baseKeysIn.js +43 -0
- package/lib/node_modules/lodash/_baseRest.js +27 -0
- package/lib/node_modules/lodash/_baseSet.js +63 -0
- package/lib/node_modules/lodash/_baseSetToString.js +32 -0
- package/lib/node_modules/lodash/_baseTimes.js +27 -0
- package/lib/node_modules/lodash/_baseToString.js +48 -0
- package/lib/node_modules/lodash/_baseUnary.js +21 -0
- package/lib/node_modules/lodash/_castPath.js +32 -0
- package/lib/node_modules/lodash/_cloneArrayBuffer.js +24 -0
- package/lib/node_modules/lodash/_cloneBuffer.js +42 -0
- package/lib/node_modules/lodash/_cloneDataView.js +24 -0
- package/lib/node_modules/lodash/_cloneRegExp.js +24 -0
- package/lib/node_modules/lodash/_cloneSymbol.js +26 -0
- package/lib/node_modules/lodash/_cloneTypedArray.js +24 -0
- package/lib/node_modules/lodash/_copyArray.js +27 -0
- package/lib/node_modules/lodash/_copyObject.js +49 -0
- package/lib/node_modules/lodash/_copySymbols.js +25 -0
- package/lib/node_modules/lodash/_copySymbolsIn.js +25 -0
- package/lib/node_modules/lodash/_coreJsData.js +14 -0
- package/lib/node_modules/lodash/_defineProperty.js +19 -0
- package/lib/node_modules/lodash/_freeGlobal.js +13 -0
- package/lib/node_modules/lodash/_getAllKeys.js +26 -0
- package/lib/node_modules/lodash/_getAllKeysIn.js +27 -0
- package/lib/node_modules/lodash/_getMapData.js +26 -0
- package/lib/node_modules/lodash/_getNative.js +26 -0
- package/lib/node_modules/lodash/_getPrototype.js +14 -0
- package/lib/node_modules/lodash/_getRawTag.js +54 -0
- package/lib/node_modules/lodash/_getSymbols.js +39 -0
- package/lib/node_modules/lodash/_getSymbolsIn.js +36 -0
- package/lib/node_modules/lodash/_getTag.js +72 -0
- package/lib/node_modules/lodash/_getValue.js +20 -0
- package/lib/node_modules/lodash/_hashClear.js +23 -0
- package/lib/node_modules/lodash/_hashDelete.js +24 -0
- package/lib/node_modules/lodash/_hashGet.js +38 -0
- package/lib/node_modules/lodash/_hashHas.js +31 -0
- package/lib/node_modules/lodash/_hashSet.js +31 -0
- package/lib/node_modules/lodash/_initCloneArray.js +33 -0
- package/lib/node_modules/lodash/_initCloneByTag.js +89 -0
- package/lib/node_modules/lodash/_initCloneObject.js +28 -0
- package/lib/node_modules/lodash/_isIndex.js +32 -0
- package/lib/node_modules/lodash/_isIterateeCall.js +41 -0
- package/lib/node_modules/lodash/_isKey.js +38 -0
- package/lib/node_modules/lodash/_isKeyable.js +22 -0
- package/lib/node_modules/lodash/_isMasked.js +28 -0
- package/lib/node_modules/lodash/_isPrototype.js +25 -0
- package/lib/node_modules/lodash/_listCacheClear.js +20 -0
- package/lib/node_modules/lodash/_listCacheDelete.js +43 -0
- package/lib/node_modules/lodash/_listCacheGet.js +27 -0
- package/lib/node_modules/lodash/_listCacheHas.js +24 -0
- package/lib/node_modules/lodash/_listCacheSet.js +34 -0
- package/lib/node_modules/lodash/_mapCacheClear.js +31 -0
- package/lib/node_modules/lodash/_mapCacheDelete.js +26 -0
- package/lib/node_modules/lodash/_mapCacheGet.js +24 -0
- package/lib/node_modules/lodash/_mapCacheHas.js +24 -0
- package/lib/node_modules/lodash/_mapCacheSet.js +30 -0
- package/lib/node_modules/lodash/_memoizeCapped.js +34 -0
- package/lib/node_modules/lodash/_nativeCreate.js +14 -0
- package/lib/node_modules/lodash/_nativeKeys.js +14 -0
- package/lib/node_modules/lodash/_nativeKeysIn.js +27 -0
- package/lib/node_modules/lodash/_nodeUtil.js +37 -0
- package/lib/node_modules/lodash/_objectToString.js +29 -0
- package/lib/node_modules/lodash/_overArg.js +22 -0
- package/lib/node_modules/lodash/_overRest.js +44 -0
- package/lib/node_modules/lodash/_root.js +17 -0
- package/lib/node_modules/lodash/_setToString.js +23 -0
- package/lib/node_modules/lodash/_shortOut.js +44 -0
- package/lib/node_modules/lodash/_stackClear.js +23 -0
- package/lib/node_modules/lodash/_stackDelete.js +25 -0
- package/lib/node_modules/lodash/_stackGet.js +21 -0
- package/lib/node_modules/lodash/_stackHas.js +21 -0
- package/lib/node_modules/lodash/_stackSet.js +44 -0
- package/lib/node_modules/lodash/_stringToPath.js +35 -0
- package/lib/node_modules/lodash/_toKey.js +29 -0
- package/lib/node_modules/lodash/_toSource.js +33 -0
- package/lib/node_modules/lodash/clone.js +44 -0
- package/lib/node_modules/lodash/constant.js +33 -0
- package/lib/node_modules/lodash/defaults.js +75 -0
- package/lib/node_modules/lodash/eq.js +44 -0
- package/lib/node_modules/lodash/get.js +41 -0
- package/lib/node_modules/lodash/identity.js +28 -0
- package/lib/node_modules/lodash/isArguments.js +45 -0
- package/lib/node_modules/lodash/isArray.js +33 -0
- package/lib/node_modules/lodash/isArrayLike.js +42 -0
- package/lib/node_modules/lodash/isBuffer.js +46 -0
- package/lib/node_modules/lodash/isFunction.js +46 -0
- package/lib/node_modules/lodash/isLength.js +42 -0
- package/lib/node_modules/lodash/isMap.js +38 -0
- package/lib/node_modules/lodash/isObject.js +38 -0
- package/lib/node_modules/lodash/isObjectLike.js +36 -0
- package/lib/node_modules/lodash/isPlainObject.js +72 -0
- package/lib/node_modules/lodash/isSet.js +38 -0
- package/lib/node_modules/lodash/isSymbol.js +38 -0
- package/lib/node_modules/lodash/isTypedArray.js +38 -0
- package/lib/node_modules/lodash/keys.js +47 -0
- package/lib/node_modules/lodash/keysIn.js +42 -0
- package/lib/node_modules/lodash/lodash.js +17209 -0
- package/lib/node_modules/lodash/memoize.js +81 -0
- package/lib/node_modules/lodash/set.js +43 -0
- package/lib/node_modules/lodash/stubArray.js +30 -0
- package/lib/node_modules/lodash/stubFalse.js +25 -0
- package/lib/node_modules/lodash/toString.js +36 -0
- package/lib/node_modules/mute-stream/mute.js +157 -0
- package/lib/node_modules/restore-cursor/index.js +20 -0
- package/lib/node_modules/run-async/index.js +106 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/Observable.js +107 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/Subject.js +167 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/Subscriber.js +174 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/Subscription.js +150 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/config.js +13 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/ConnectableObservable.js +68 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/defer.js +14 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/empty.js +16 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/from.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/fromEvent.js +65 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/fromSubscribable.js +11 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js +155 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/observable/of.js +17 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js +67 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/concatMap.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/connect.js +23 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/filter.js +15 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/flatMap.js +9 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/map.js +17 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js +67 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js +22 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/multicast.js +19 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/observeOn.js +16 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/publish.js +13 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/reduce.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/refCount.js +32 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js +28 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/share.js +91 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js +14 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/take.js +26 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js +17 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js +24 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js +29 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js +38 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js +13 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js +13 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js +43 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +21 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/symbol/iterator.js +14 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +7 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js +15 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +18 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/args.js +14 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +16 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +11 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js +23 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/identity.js +9 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js +7 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js +11 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +9 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isIterable.js +12 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isPromise.js +11 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js +45 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/isScheduler.js +11 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/lift.js +27 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js +16 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/noop.js +7 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/pipe.js +19 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +15 -0
- package/lib/node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js +9 -0
- package/lib/node_modules/signal-exit/index.js +222 -0
- package/lib/node_modules/signal-exit/signals.js +59 -0
- package/lib/node_modules/string-width/index.js +64 -0
- package/lib/node_modules/string-width/node_modules/ansi-regex/index.js +14 -0
- package/lib/node_modules/string-width/node_modules/strip-ansi/index.js +15 -0
- package/lib/node_modules/tslib/tslib.es6.js +145 -0
- package/lib/node_modules/wrap-ansi/index.js +220 -0
- package/lib/node_modules/wrap-ansi/node_modules/ansi-regex/index.js +14 -0
- package/lib/node_modules/wrap-ansi/node_modules/strip-ansi/index.js +15 -0
- package/lib/package.json.js +94 -0
- package/lib/src/index.js +12 -0
- package/lib/src/install-eslint.js +32 -0
- package/lib/src/lint-init.js +31 -0
- package/lib/src/utils.js +37 -0
- package/package.json +62 -0
- package/template/.eslintignore +3 -0
- package/template/.eslintrc.js +22 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var base = require('./base.js');
|
|
7
|
+
var separator = require('../objects/separator.js');
|
|
8
|
+
var events = require('../utils/events.js');
|
|
9
|
+
var paginator = require('../utils/paginator.js');
|
|
10
|
+
var map = require('../../../rxjs/dist/esm5/internal/operators/map.js');
|
|
11
|
+
var takeUntil = require('../../../rxjs/dist/esm5/internal/operators/takeUntil.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `rawlist` type prompt
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
class ExpandPrompt extends base["default"] {
|
|
22
|
+
constructor(questions, rl, answers) {
|
|
23
|
+
super(questions, rl, answers);
|
|
24
|
+
|
|
25
|
+
if (!this.opt.choices) {
|
|
26
|
+
this.throwParamError('choices');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.validateChoices(this.opt.choices);
|
|
30
|
+
|
|
31
|
+
// Add the default `help` (/expand) option
|
|
32
|
+
this.opt.choices.push({
|
|
33
|
+
key: 'h',
|
|
34
|
+
name: 'Help, list all options',
|
|
35
|
+
value: 'help',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.opt.validate = (choice) => {
|
|
39
|
+
if (choice == null) {
|
|
40
|
+
return 'Please enter a valid command';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return choice !== 'help';
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Setup the default string (capitalize the default key)
|
|
47
|
+
this.opt.default = this.generateChoicesString(this.opt.choices, this.opt.default);
|
|
48
|
+
|
|
49
|
+
this.paginator = new paginator["default"](this.screen);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Start the Inquiry session
|
|
54
|
+
* @param {Function} cb Callback when prompt is done
|
|
55
|
+
* @return {this}
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
_run(cb) {
|
|
59
|
+
this.done = cb;
|
|
60
|
+
|
|
61
|
+
// Save user answer and update prompt to show selected option.
|
|
62
|
+
const events$1 = events["default"](this.rl);
|
|
63
|
+
const validation = this.handleSubmitEvents(
|
|
64
|
+
events$1.line.pipe(map.map(this.getCurrentValue.bind(this)))
|
|
65
|
+
);
|
|
66
|
+
validation.success.forEach(this.onSubmit.bind(this));
|
|
67
|
+
validation.error.forEach(this.onError.bind(this));
|
|
68
|
+
this.keypressObs = events$1.keypress
|
|
69
|
+
.pipe(takeUntil.takeUntil(validation.success))
|
|
70
|
+
.forEach(this.onKeypress.bind(this));
|
|
71
|
+
|
|
72
|
+
// Init the prompt
|
|
73
|
+
this.render();
|
|
74
|
+
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Render the prompt to screen
|
|
80
|
+
* @return {ExpandPrompt} self
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
render(error, hint) {
|
|
84
|
+
let message = this.getQuestion();
|
|
85
|
+
let bottomContent = '';
|
|
86
|
+
|
|
87
|
+
if (this.status === 'answered') {
|
|
88
|
+
message += chalk__default["default"].cyan(this.answer);
|
|
89
|
+
} else if (this.status === 'expanded') {
|
|
90
|
+
const choicesStr = renderChoices(this.opt.choices, this.selectedKey);
|
|
91
|
+
message += this.paginator.paginate(choicesStr, this.selectedKey, this.opt.pageSize);
|
|
92
|
+
message += '\n Answer: ';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message += this.rl.line;
|
|
96
|
+
|
|
97
|
+
if (error) {
|
|
98
|
+
bottomContent = chalk__default["default"].red('>> ') + error;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (hint) {
|
|
102
|
+
bottomContent = chalk__default["default"].cyan('>> ') + hint;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.screen.render(message, bottomContent);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getCurrentValue(input) {
|
|
109
|
+
if (!input) {
|
|
110
|
+
input = this.rawDefault;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const selected = this.opt.choices.where({ key: input.toLowerCase().trim() })[0];
|
|
114
|
+
if (!selected) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return selected.value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Generate the prompt choices string
|
|
123
|
+
* @return {String} Choices string
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
getChoices() {
|
|
127
|
+
let output = '';
|
|
128
|
+
|
|
129
|
+
this.opt.choices.forEach((choice) => {
|
|
130
|
+
output += '\n ';
|
|
131
|
+
|
|
132
|
+
if (choice.type === 'separator') {
|
|
133
|
+
output += ' ' + choice;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let choiceStr = choice.key + ') ' + choice.name;
|
|
138
|
+
if (this.selectedKey === choice.key) {
|
|
139
|
+
choiceStr = chalk__default["default"].cyan(choiceStr);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
output += choiceStr;
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return output;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onError(state) {
|
|
149
|
+
if (state.value === 'help') {
|
|
150
|
+
this.selectedKey = '';
|
|
151
|
+
this.status = 'expanded';
|
|
152
|
+
this.render();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
this.render(state.isValid);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* When user press `enter` key
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
onSubmit(state) {
|
|
164
|
+
this.status = 'answered';
|
|
165
|
+
const choice = this.opt.choices.where({ value: state.value })[0];
|
|
166
|
+
this.answer = choice.short || choice.name;
|
|
167
|
+
|
|
168
|
+
// Re-render prompt
|
|
169
|
+
this.render();
|
|
170
|
+
this.screen.done();
|
|
171
|
+
this.done(state.value);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* When user press a key
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
onKeypress() {
|
|
179
|
+
this.selectedKey = this.rl.line.toLowerCase();
|
|
180
|
+
const selected = this.opt.choices.where({ key: this.selectedKey })[0];
|
|
181
|
+
if (this.status === 'expanded') {
|
|
182
|
+
this.render();
|
|
183
|
+
} else {
|
|
184
|
+
this.render(null, selected ? selected.name : null);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Validate the choices
|
|
190
|
+
* @param {Array} choices
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
validateChoices(choices) {
|
|
194
|
+
let formatError;
|
|
195
|
+
const errors = [];
|
|
196
|
+
const keymap = {};
|
|
197
|
+
choices.filter(separator["default"].exclude).forEach((choice) => {
|
|
198
|
+
if (!choice.key || choice.key.length !== 1) {
|
|
199
|
+
formatError = true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
choice.key = String(choice.key).toLowerCase();
|
|
203
|
+
|
|
204
|
+
if (keymap[choice.key]) {
|
|
205
|
+
errors.push(choice.key);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
keymap[choice.key] = true;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
if (formatError) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
'Format error: `key` param must be a single letter and is required.'
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (keymap.h) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
'Reserved key error: `key` param cannot be `h` - this value is reserved.'
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (errors.length) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
'Duplicate key error: `key` param must be unique. Duplicates: ' +
|
|
226
|
+
[...new Set(errors)].join(',')
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Generate a string out of the choices keys
|
|
233
|
+
* @param {Array} choices
|
|
234
|
+
* @param {Number|String} default - the choice index or name to capitalize
|
|
235
|
+
* @return {String} The rendered choices key string
|
|
236
|
+
*/
|
|
237
|
+
generateChoicesString(choices, defaultChoice) {
|
|
238
|
+
let defIndex = choices.realLength - 1;
|
|
239
|
+
if (typeof defaultChoice === 'number' && this.opt.choices.getChoice(defaultChoice)) {
|
|
240
|
+
defIndex = defaultChoice;
|
|
241
|
+
} else if (typeof defaultChoice === 'string') {
|
|
242
|
+
const index = choices.realChoices.findIndex(({ value }) => value === defaultChoice);
|
|
243
|
+
defIndex = index === -1 ? defIndex : index;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const defStr = this.opt.choices.pluck('key');
|
|
247
|
+
this.rawDefault = defStr[defIndex];
|
|
248
|
+
defStr[defIndex] = String(defStr[defIndex]).toUpperCase();
|
|
249
|
+
return defStr.join('');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Function for rendering checkbox choices
|
|
255
|
+
* @param {String} pointer Selected key
|
|
256
|
+
* @return {String} Rendered content
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
function renderChoices(choices, pointer) {
|
|
260
|
+
let output = '';
|
|
261
|
+
|
|
262
|
+
choices.forEach((choice) => {
|
|
263
|
+
output += '\n ';
|
|
264
|
+
|
|
265
|
+
if (choice.type === 'separator') {
|
|
266
|
+
output += ' ' + choice;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
let choiceStr = choice.key + ') ' + choice.name;
|
|
271
|
+
if (pointer === choice.key) {
|
|
272
|
+
choiceStr = chalk__default["default"].cyan(choiceStr);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
output += choiceStr;
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return output;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
exports["default"] = ExpandPrompt;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var base = require('./base.js');
|
|
7
|
+
var events = require('../utils/events.js');
|
|
8
|
+
var map = require('../../../rxjs/dist/esm5/internal/operators/map.js');
|
|
9
|
+
var takeUntil = require('../../../rxjs/dist/esm5/internal/operators/takeUntil.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `input` type prompt
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
class InputPrompt extends base["default"] {
|
|
20
|
+
/**
|
|
21
|
+
* Start the Inquiry session
|
|
22
|
+
* @param {Function} cb Callback when prompt is done
|
|
23
|
+
* @return {this}
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
_run(cb) {
|
|
27
|
+
this.done = cb;
|
|
28
|
+
|
|
29
|
+
// Once user confirm (enter key)
|
|
30
|
+
const events$1 = events["default"](this.rl);
|
|
31
|
+
const submit = events$1.line.pipe(map.map(this.filterInput.bind(this)));
|
|
32
|
+
|
|
33
|
+
const validation = this.handleSubmitEvents(submit);
|
|
34
|
+
validation.success.forEach(this.onEnd.bind(this));
|
|
35
|
+
validation.error.forEach(this.onError.bind(this));
|
|
36
|
+
|
|
37
|
+
events$1.keypress
|
|
38
|
+
.pipe(takeUntil.takeUntil(validation.success))
|
|
39
|
+
.forEach(this.onKeypress.bind(this));
|
|
40
|
+
|
|
41
|
+
// Init
|
|
42
|
+
this.render();
|
|
43
|
+
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Render the prompt to screen
|
|
49
|
+
* @return {InputPrompt} self
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
render(error) {
|
|
53
|
+
let bottomContent = '';
|
|
54
|
+
let appendContent = '';
|
|
55
|
+
let message = this.getQuestion();
|
|
56
|
+
const { transformer } = this.opt;
|
|
57
|
+
const isFinal = this.status === 'answered';
|
|
58
|
+
|
|
59
|
+
if (isFinal) {
|
|
60
|
+
appendContent = this.answer;
|
|
61
|
+
} else {
|
|
62
|
+
appendContent = this.rl.line;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (transformer) {
|
|
66
|
+
message += transformer(appendContent, this.answers, { isFinal });
|
|
67
|
+
} else {
|
|
68
|
+
message += isFinal ? chalk__default["default"].cyan(appendContent) : appendContent;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (error) {
|
|
72
|
+
bottomContent = chalk__default["default"].red('>> ') + error;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.screen.render(message, bottomContent);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* When user press `enter` key
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
filterInput(input) {
|
|
83
|
+
if (!input) {
|
|
84
|
+
return this.opt.default == null ? '' : this.opt.default;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return input;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onEnd(state) {
|
|
91
|
+
this.answer = state.value;
|
|
92
|
+
this.status = 'answered';
|
|
93
|
+
|
|
94
|
+
// Re-render prompt
|
|
95
|
+
this.render();
|
|
96
|
+
|
|
97
|
+
this.screen.done();
|
|
98
|
+
this.done(state.value);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onError({ value = '', isValid }) {
|
|
102
|
+
this.rl.line += value;
|
|
103
|
+
this.rl.cursor += value.length;
|
|
104
|
+
this.render(isValid);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* When user press a key
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
onKeypress() {
|
|
112
|
+
this.status = 'touched';
|
|
113
|
+
|
|
114
|
+
this.render();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
exports["default"] = InputPrompt;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var index$1 = require('../../../figures/index.js');
|
|
7
|
+
var index = require('../../../cli-cursor/index.js');
|
|
8
|
+
var index$2 = require('../../../run-async/index.js');
|
|
9
|
+
var base = require('./base.js');
|
|
10
|
+
var events = require('../utils/events.js');
|
|
11
|
+
var paginator = require('../utils/paginator.js');
|
|
12
|
+
var incrementListIndex = require('../utils/incrementListIndex.js');
|
|
13
|
+
var takeUntil = require('../../../rxjs/dist/esm5/internal/operators/takeUntil.js');
|
|
14
|
+
var take = require('../../../rxjs/dist/esm5/internal/operators/take.js');
|
|
15
|
+
var map = require('../../../rxjs/dist/esm5/internal/operators/map.js');
|
|
16
|
+
var flatMap = require('../../../rxjs/dist/esm5/internal/operators/flatMap.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `list` type prompt
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
class ListPrompt extends base["default"] {
|
|
27
|
+
constructor(questions, rl, answers) {
|
|
28
|
+
super(questions, rl, answers);
|
|
29
|
+
|
|
30
|
+
if (!this.opt.choices) {
|
|
31
|
+
this.throwParamError('choices');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.firstRender = true;
|
|
35
|
+
this.selected = 0;
|
|
36
|
+
|
|
37
|
+
const def = this.opt.default;
|
|
38
|
+
|
|
39
|
+
// If def is a Number, then use as index. Otherwise, check for value.
|
|
40
|
+
if (typeof def === 'number' && def >= 0 && def < this.opt.choices.realLength) {
|
|
41
|
+
this.selected = def;
|
|
42
|
+
} else if (typeof def !== 'number' && def != null) {
|
|
43
|
+
const index = this.opt.choices.realChoices.findIndex(({ value }) => value === def);
|
|
44
|
+
this.selected = Math.max(index, 0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Make sure no default is set (so it won't be printed)
|
|
48
|
+
this.opt.default = null;
|
|
49
|
+
|
|
50
|
+
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
|
51
|
+
this.paginator = new paginator["default"](this.screen, { isInfinite: shouldLoop });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Start the Inquiry session
|
|
56
|
+
* @param {Function} cb Callback when prompt is done
|
|
57
|
+
* @return {this}
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
_run(cb) {
|
|
61
|
+
this.done = cb;
|
|
62
|
+
|
|
63
|
+
const self = this;
|
|
64
|
+
|
|
65
|
+
const events$1 = events["default"](this.rl);
|
|
66
|
+
events$1.normalizedUpKey.pipe(takeUntil.takeUntil(events$1.line)).forEach(this.onUpKey.bind(this));
|
|
67
|
+
events$1.normalizedDownKey
|
|
68
|
+
.pipe(takeUntil.takeUntil(events$1.line))
|
|
69
|
+
.forEach(this.onDownKey.bind(this));
|
|
70
|
+
events$1.numberKey.pipe(takeUntil.takeUntil(events$1.line)).forEach(this.onNumberKey.bind(this));
|
|
71
|
+
events$1.line
|
|
72
|
+
.pipe(
|
|
73
|
+
take.take(1),
|
|
74
|
+
map.map(this.getCurrentValue.bind(this)),
|
|
75
|
+
flatMap.flatMap((value) =>
|
|
76
|
+
index$2["default"](self.opt.filter)(value, self.answers).catch((err) => err)
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
.forEach(this.onSubmit.bind(this));
|
|
80
|
+
|
|
81
|
+
// Init the prompt
|
|
82
|
+
index["default"].hide();
|
|
83
|
+
this.render();
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Render the prompt to screen
|
|
90
|
+
* @return {ListPrompt} self
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
render() {
|
|
94
|
+
// Render question
|
|
95
|
+
let message = this.getQuestion();
|
|
96
|
+
|
|
97
|
+
if (this.firstRender) {
|
|
98
|
+
message += chalk__default["default"].dim('(Use arrow keys)');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Render choices or answer depending on the state
|
|
102
|
+
if (this.status === 'answered') {
|
|
103
|
+
message += chalk__default["default"].cyan(this.opt.choices.getChoice(this.selected).short);
|
|
104
|
+
} else {
|
|
105
|
+
const choicesStr = listRender(this.opt.choices, this.selected);
|
|
106
|
+
const indexPosition = this.opt.choices.indexOf(
|
|
107
|
+
this.opt.choices.getChoice(this.selected)
|
|
108
|
+
);
|
|
109
|
+
const realIndexPosition =
|
|
110
|
+
this.opt.choices.reduce((acc, value, i) => {
|
|
111
|
+
// Dont count lines past the choice we are looking at
|
|
112
|
+
if (i > indexPosition) {
|
|
113
|
+
return acc;
|
|
114
|
+
}
|
|
115
|
+
// Add line if it's a separator
|
|
116
|
+
if (value.type === 'separator') {
|
|
117
|
+
return acc + 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let l = value.name;
|
|
121
|
+
// Non-strings take up one line
|
|
122
|
+
if (typeof l !== 'string') {
|
|
123
|
+
return acc + 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Calculate lines taken up by string
|
|
127
|
+
l = l.split('\n');
|
|
128
|
+
return acc + l.length;
|
|
129
|
+
}, 0) - 1;
|
|
130
|
+
message +=
|
|
131
|
+
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
this.firstRender = false;
|
|
135
|
+
|
|
136
|
+
this.screen.render(message);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* When user press `enter` key
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
onSubmit(value) {
|
|
144
|
+
this.status = 'answered';
|
|
145
|
+
|
|
146
|
+
// Rerender prompt
|
|
147
|
+
this.render();
|
|
148
|
+
|
|
149
|
+
this.screen.done();
|
|
150
|
+
index["default"].show();
|
|
151
|
+
this.done(value);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getCurrentValue() {
|
|
155
|
+
return this.opt.choices.getChoice(this.selected).value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* When user press a key
|
|
160
|
+
*/
|
|
161
|
+
onUpKey() {
|
|
162
|
+
this.selected = incrementListIndex["default"](this.selected, 'up', this.opt);
|
|
163
|
+
this.render();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onDownKey() {
|
|
167
|
+
this.selected = incrementListIndex["default"](this.selected, 'down', this.opt);
|
|
168
|
+
this.render();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onNumberKey(input) {
|
|
172
|
+
if (input <= this.opt.choices.realLength) {
|
|
173
|
+
this.selected = input - 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.render();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Function for rendering list choices
|
|
182
|
+
* @param {Number} pointer Position of the pointer
|
|
183
|
+
* @return {String} Rendered content
|
|
184
|
+
*/
|
|
185
|
+
function listRender(choices, pointer) {
|
|
186
|
+
let output = '';
|
|
187
|
+
let separatorOffset = 0;
|
|
188
|
+
|
|
189
|
+
choices.forEach((choice, i) => {
|
|
190
|
+
if (choice.type === 'separator') {
|
|
191
|
+
separatorOffset++;
|
|
192
|
+
output += ' ' + choice + '\n';
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (choice.disabled) {
|
|
197
|
+
separatorOffset++;
|
|
198
|
+
output += ' - ' + choice.name;
|
|
199
|
+
output += ` (${
|
|
200
|
+
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
|
|
201
|
+
})`;
|
|
202
|
+
output += '\n';
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const isSelected = i - separatorOffset === pointer;
|
|
207
|
+
let line = (isSelected ? index$1["default"].pointer + ' ' : ' ') + choice.name;
|
|
208
|
+
if (isSelected) {
|
|
209
|
+
line = chalk__default["default"].cyan(line);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
output += line + ' \n';
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
return output.replace(/\n$/, '');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
exports["default"] = ListPrompt;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var input = require('./input.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `input` type prompt
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extention of the Input prompt specifically for use with number inputs.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class NumberPrompt extends input["default"] {
|
|
16
|
+
filterInput(input) {
|
|
17
|
+
if (input && typeof input === 'string') {
|
|
18
|
+
input = input.trim();
|
|
19
|
+
// Match a number in the input
|
|
20
|
+
const numberMatch = input.match(/(^-?\d+|^-?\d+\.\d*|^\d*\.\d+)(e\d+)?$/);
|
|
21
|
+
// If a number is found, return that input.
|
|
22
|
+
if (numberMatch) {
|
|
23
|
+
return Number(numberMatch[0]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// If the input was invalid return the default value.
|
|
28
|
+
return this.opt.default == null ? NaN : this.opt.default;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports["default"] = NumberPrompt;
|