inquirerer 2.4.0 → 3.0.1
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/README.md +43 -1023
- package/esm/index.d.ts +10 -0
- package/esm/index.js +12 -4
- package/index.d.ts +10 -4
- package/index.js +14 -4
- package/package.json +12 -13
- package/commander.d.ts +0 -21
- package/commander.js +0 -57
- package/esm/commander.js +0 -50
- package/esm/keypress.js +0 -95
- package/esm/prompt.js +0 -1024
- package/esm/question/index.js +0 -1
- package/esm/question/types.js +0 -1
- package/esm/resolvers/date.js +0 -11
- package/esm/resolvers/git.js +0 -26
- package/esm/resolvers/index.js +0 -103
- package/esm/resolvers/npm.js +0 -24
- package/esm/resolvers/types.js +0 -1
- package/esm/resolvers/workspace.js +0 -141
- package/esm/utils.js +0 -12
- package/keypress.d.ts +0 -45
- package/keypress.js +0 -99
- package/prompt.d.ts +0 -116
- package/prompt.js +0 -1032
- package/question/index.d.ts +0 -1
- package/question/index.js +0 -17
- package/question/types.d.ts +0 -65
- package/question/types.js +0 -2
- package/resolvers/date.d.ts +0 -5
- package/resolvers/date.js +0 -14
- package/resolvers/git.d.ts +0 -11
- package/resolvers/git.js +0 -30
- package/resolvers/index.d.ts +0 -63
- package/resolvers/index.js +0 -111
- package/resolvers/npm.d.ts +0 -10
- package/resolvers/npm.js +0 -28
- package/resolvers/types.d.ts +0 -12
- package/resolvers/types.js +0 -2
- package/resolvers/workspace.d.ts +0 -6
- package/resolvers/workspace.js +0 -144
- package/utils.d.ts +0 -2
- package/utils.js +0 -16
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inquirerer - Backwards compatibility package
|
|
3
|
+
*
|
|
4
|
+
* This package has been renamed to 'genomic'.
|
|
5
|
+
* Please migrate to 'genomic' for the latest features and updates.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.npmjs.com/package/genomic
|
|
8
|
+
*/
|
|
9
|
+
export * from 'genomic';
|
|
10
|
+
export { Prompter as Inquirerer, PrompterOptions as InquirererOptions } from 'genomic';
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* inquirerer - Backwards compatibility package
|
|
3
|
+
*
|
|
4
|
+
* This package has been renamed to 'genomic'.
|
|
5
|
+
* Please migrate to 'genomic' for the latest features and updates.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.npmjs.com/package/genomic
|
|
8
|
+
*/
|
|
9
|
+
// Re-export everything from genomic
|
|
10
|
+
export * from 'genomic';
|
|
11
|
+
// Re-export with old names for backwards compatibility
|
|
12
|
+
export { Prompter as Inquirerer } from 'genomic';
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* inquirerer - Backwards compatibility package
|
|
3
|
+
*
|
|
4
|
+
* This package has been renamed to 'genomic'.
|
|
5
|
+
* Please migrate to 'genomic' for the latest features and updates.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.npmjs.com/package/genomic
|
|
8
|
+
*/
|
|
9
|
+
export * from 'genomic';
|
|
10
|
+
export { Prompter as Inquirerer, PrompterOptions as InquirererOptions } from 'genomic';
|
package/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* inquirerer - Backwards compatibility package
|
|
4
|
+
*
|
|
5
|
+
* This package has been renamed to 'genomic'.
|
|
6
|
+
* Please migrate to 'genomic' for the latest features and updates.
|
|
7
|
+
*
|
|
8
|
+
* @see https://www.npmjs.com/package/genomic
|
|
9
|
+
*/
|
|
2
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
11
|
if (k2 === undefined) k2 = k;
|
|
4
12
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,7 +22,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
23
|
};
|
|
16
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__exportStar(require("
|
|
20
|
-
|
|
25
|
+
exports.Inquirerer = void 0;
|
|
26
|
+
// Re-export everything from genomic
|
|
27
|
+
__exportStar(require("genomic"), exports);
|
|
28
|
+
// Re-export with old names for backwards compatibility
|
|
29
|
+
var genomic_1 = require("genomic");
|
|
30
|
+
Object.defineProperty(exports, "Inquirerer", { enumerable: true, get: function () { return genomic_1.Prompter; } });
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirerer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
|
-
"description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts",
|
|
5
|
+
"description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts (now maintained as 'genomic')",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "esm/index.js",
|
|
8
8
|
"types": "index.d.ts",
|
|
@@ -24,22 +24,21 @@
|
|
|
24
24
|
"clean": "makage clean",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
26
|
"build": "makage build",
|
|
27
|
-
"
|
|
28
|
-
"test": "jest",
|
|
27
|
+
"test": "jest --passWithNoTests",
|
|
29
28
|
"test:watch": "jest --watch"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"find-and-require-package-json": "0.8.2",
|
|
34
|
-
"js-yaml": "^4.1.0",
|
|
35
|
-
"minimist": "^1.2.8",
|
|
36
|
-
"yanse": "0.1.8"
|
|
31
|
+
"genomic": "4.0.2"
|
|
37
32
|
},
|
|
38
|
-
"keywords": [
|
|
33
|
+
"keywords": [
|
|
34
|
+
"cli",
|
|
35
|
+
"prompt",
|
|
36
|
+
"interactive",
|
|
37
|
+
"terminal",
|
|
38
|
+
"inquirer"
|
|
39
|
+
],
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@types/minimist": "^1.2.5",
|
|
41
|
-
"clean-ansi": "0.1.5",
|
|
42
41
|
"makage": "0.1.8"
|
|
43
42
|
},
|
|
44
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "30a9dccc809431a7406aef9a838a5b8c0278742f"
|
|
45
44
|
}
|
package/commander.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Opts, ParsedArgs } from 'minimist';
|
|
2
|
-
import { Readable, Writable } from 'stream';
|
|
3
|
-
import { Inquirerer } from './prompt';
|
|
4
|
-
export type CommandHandler = (argv: ParsedArgs, prompter: Inquirerer, options: CLIOptions) => void;
|
|
5
|
-
export interface CLIOptions {
|
|
6
|
-
noTty: boolean;
|
|
7
|
-
input: Readable;
|
|
8
|
-
output: Writable;
|
|
9
|
-
minimistOpts: Opts;
|
|
10
|
-
version: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const defaultCLIOptions: CLIOptions;
|
|
13
|
-
export declare class CLI {
|
|
14
|
-
private argv;
|
|
15
|
-
private prompter;
|
|
16
|
-
private commandHandler;
|
|
17
|
-
private options;
|
|
18
|
-
constructor(commandHandler: CommandHandler, options: Partial<CLIOptions>, argv?: any);
|
|
19
|
-
run(): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export default CLI;
|
package/commander.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CLI = exports.defaultCLIOptions = void 0;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
9
|
-
const prompt_1 = require("./prompt");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
exports.defaultCLIOptions = {
|
|
12
|
-
version: `inquirerer@${(0, utils_1.getVersion)()}`,
|
|
13
|
-
noTty: false,
|
|
14
|
-
input: process.stdin,
|
|
15
|
-
output: process.stdout,
|
|
16
|
-
minimistOpts: {
|
|
17
|
-
alias: {
|
|
18
|
-
v: 'version'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
class CLI {
|
|
23
|
-
argv;
|
|
24
|
-
prompter;
|
|
25
|
-
commandHandler;
|
|
26
|
-
options;
|
|
27
|
-
constructor(commandHandler, options, argv) {
|
|
28
|
-
const { input, output, ...optionsWithoutIO } = options;
|
|
29
|
-
const { input: defaultInput, output: defaultOutput, ...defaultOptionsWithoutIO } = exports.defaultCLIOptions;
|
|
30
|
-
const mergedOptions = (0, deepmerge_1.default)(defaultOptionsWithoutIO, optionsWithoutIO);
|
|
31
|
-
mergedOptions.input = input || defaultInput;
|
|
32
|
-
mergedOptions.output = output || defaultOutput;
|
|
33
|
-
this.options = mergedOptions;
|
|
34
|
-
this.argv = argv ? argv : (0, minimist_1.default)(process.argv.slice(2), this.options.minimistOpts);
|
|
35
|
-
this.prompter = new prompt_1.Inquirerer({
|
|
36
|
-
noTty: this.options.noTty,
|
|
37
|
-
input: this.options.input,
|
|
38
|
-
output: this.options.output
|
|
39
|
-
});
|
|
40
|
-
this.commandHandler = commandHandler;
|
|
41
|
-
}
|
|
42
|
-
async run() {
|
|
43
|
-
if (!('tty' in this.argv)) {
|
|
44
|
-
this.argv.tty = true;
|
|
45
|
-
}
|
|
46
|
-
if (this.argv.version) {
|
|
47
|
-
console.log(this.options.version);
|
|
48
|
-
process.exit(0);
|
|
49
|
-
}
|
|
50
|
-
const args = await this.commandHandler(this.argv, this.prompter, this.options);
|
|
51
|
-
// this.prompter.exit();
|
|
52
|
-
this.prompter.close();
|
|
53
|
-
return args;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.CLI = CLI;
|
|
57
|
-
exports.default = CLI;
|
package/esm/commander.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import deepmerge from 'deepmerge';
|
|
2
|
-
import minimist from 'minimist';
|
|
3
|
-
import { Inquirerer } from './prompt';
|
|
4
|
-
import { getVersion } from './utils';
|
|
5
|
-
export const defaultCLIOptions = {
|
|
6
|
-
version: `inquirerer@${getVersion()}`,
|
|
7
|
-
noTty: false,
|
|
8
|
-
input: process.stdin,
|
|
9
|
-
output: process.stdout,
|
|
10
|
-
minimistOpts: {
|
|
11
|
-
alias: {
|
|
12
|
-
v: 'version'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export class CLI {
|
|
17
|
-
argv;
|
|
18
|
-
prompter;
|
|
19
|
-
commandHandler;
|
|
20
|
-
options;
|
|
21
|
-
constructor(commandHandler, options, argv) {
|
|
22
|
-
const { input, output, ...optionsWithoutIO } = options;
|
|
23
|
-
const { input: defaultInput, output: defaultOutput, ...defaultOptionsWithoutIO } = defaultCLIOptions;
|
|
24
|
-
const mergedOptions = deepmerge(defaultOptionsWithoutIO, optionsWithoutIO);
|
|
25
|
-
mergedOptions.input = input || defaultInput;
|
|
26
|
-
mergedOptions.output = output || defaultOutput;
|
|
27
|
-
this.options = mergedOptions;
|
|
28
|
-
this.argv = argv ? argv : minimist(process.argv.slice(2), this.options.minimistOpts);
|
|
29
|
-
this.prompter = new Inquirerer({
|
|
30
|
-
noTty: this.options.noTty,
|
|
31
|
-
input: this.options.input,
|
|
32
|
-
output: this.options.output
|
|
33
|
-
});
|
|
34
|
-
this.commandHandler = commandHandler;
|
|
35
|
-
}
|
|
36
|
-
async run() {
|
|
37
|
-
if (!('tty' in this.argv)) {
|
|
38
|
-
this.argv.tty = true;
|
|
39
|
-
}
|
|
40
|
-
if (this.argv.version) {
|
|
41
|
-
console.log(this.options.version);
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
const args = await this.commandHandler(this.argv, this.prompter, this.options);
|
|
45
|
-
// this.prompter.exit();
|
|
46
|
-
this.prompter.close();
|
|
47
|
-
return args;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export default CLI;
|
package/esm/keypress.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const defaultProcessWrapper = {
|
|
2
|
-
exit: (code) => process.exit(code)
|
|
3
|
-
};
|
|
4
|
-
export const KEY_CODES = {
|
|
5
|
-
UP_ARROW: '\u001b[A',
|
|
6
|
-
DOWN_ARROW: '\u001b[B',
|
|
7
|
-
RIGHT_ARROW: '\u001b[C',
|
|
8
|
-
LEFT_ARROW: '\u001b[D',
|
|
9
|
-
ENTER: '\r',
|
|
10
|
-
SPACE: ' ',
|
|
11
|
-
CTRL_C: '\u0003',
|
|
12
|
-
BACKSPACE: '\x7f', // Commonly used BACKSPACE key in Unix-like systems
|
|
13
|
-
BACKSPACE_LEGACY: '\x08' // For compatibility with some systems
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Handles keyboard input for interactive prompts.
|
|
17
|
-
*
|
|
18
|
-
* **Important**: Only one TerminalKeypress instance should be actively listening
|
|
19
|
-
* on a given input stream at a time. If you need multiple Inquirerer instances,
|
|
20
|
-
* call `close()` on the first instance before using the second, or reuse a single
|
|
21
|
-
* instance for all prompts.
|
|
22
|
-
*
|
|
23
|
-
* Multiple instances sharing the same input stream (e.g., process.stdin) will
|
|
24
|
-
* each receive all keypresses, which can cause duplicate or unexpected behavior.
|
|
25
|
-
*/
|
|
26
|
-
export class TerminalKeypress {
|
|
27
|
-
listeners = {};
|
|
28
|
-
active = true;
|
|
29
|
-
noTty;
|
|
30
|
-
input;
|
|
31
|
-
proc;
|
|
32
|
-
dataHandler = null;
|
|
33
|
-
constructor(noTty = false, input = process.stdin, proc = defaultProcessWrapper) {
|
|
34
|
-
this.noTty = noTty;
|
|
35
|
-
this.input = input;
|
|
36
|
-
this.proc = proc;
|
|
37
|
-
if (this.isTTY()) {
|
|
38
|
-
this.input.resume();
|
|
39
|
-
this.input.setEncoding('utf8');
|
|
40
|
-
}
|
|
41
|
-
this.setupListeners();
|
|
42
|
-
}
|
|
43
|
-
isTTY() {
|
|
44
|
-
return !this.noTty;
|
|
45
|
-
}
|
|
46
|
-
setupListeners() {
|
|
47
|
-
this.dataHandler = (key) => {
|
|
48
|
-
if (!this.active)
|
|
49
|
-
return;
|
|
50
|
-
const handlers = this.listeners[key];
|
|
51
|
-
handlers?.forEach(handler => handler());
|
|
52
|
-
if (key === KEY_CODES.CTRL_C) {
|
|
53
|
-
this.proc.exit(0);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.input.on('data', this.dataHandler);
|
|
57
|
-
}
|
|
58
|
-
on(key, callback) {
|
|
59
|
-
if (!this.listeners[key]) {
|
|
60
|
-
this.listeners[key] = [];
|
|
61
|
-
}
|
|
62
|
-
this.listeners[key].push(callback);
|
|
63
|
-
}
|
|
64
|
-
off(key, callback) {
|
|
65
|
-
if (this.listeners[key]) {
|
|
66
|
-
const index = this.listeners[key].indexOf(callback);
|
|
67
|
-
if (index !== -1) {
|
|
68
|
-
this.listeners[key].splice(index, 1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
clearHandlers() {
|
|
73
|
-
this.listeners = {};
|
|
74
|
-
}
|
|
75
|
-
pause() {
|
|
76
|
-
this.active = false;
|
|
77
|
-
this.clearHandlers();
|
|
78
|
-
}
|
|
79
|
-
resume() {
|
|
80
|
-
this.active = true;
|
|
81
|
-
if (this.isTTY() && typeof this.input.setRawMode === 'function') {
|
|
82
|
-
this.input.setRawMode(true);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
destroy() {
|
|
86
|
-
if (typeof this.input.setRawMode === 'function') {
|
|
87
|
-
this.input.setRawMode(false);
|
|
88
|
-
}
|
|
89
|
-
this.input.pause();
|
|
90
|
-
if (this.dataHandler) {
|
|
91
|
-
this.input.removeListener('data', this.dataHandler);
|
|
92
|
-
this.dataHandler = null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|