inquirerer 4.4.0 → 4.5.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 +1 -2
- package/esm/prompt.js +43 -0
- package/package.json +5 -5
- package/prompt.d.ts +2 -1
- package/prompt.js +43 -0
- package/question/types.d.ts +5 -1
package/README.md
CHANGED
|
@@ -1605,8 +1605,7 @@ pnpm test:watch
|
|
|
1605
1605
|
|
|
1606
1606
|
## Credits
|
|
1607
1607
|
|
|
1608
|
-
Built for
|
|
1609
|
-
👉 https://launchql.com | https://hyperweb.io
|
|
1608
|
+
**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
|
|
1610
1609
|
|
|
1611
1610
|
## Disclaimer
|
|
1612
1611
|
|
package/esm/prompt.js
CHANGED
|
@@ -628,6 +628,8 @@ export class Inquirerer {
|
|
|
628
628
|
return this.autocomplete(question, ctx);
|
|
629
629
|
case 'number':
|
|
630
630
|
return this.number(question, ctx);
|
|
631
|
+
case 'password':
|
|
632
|
+
return this.password(question, ctx);
|
|
631
633
|
case 'text':
|
|
632
634
|
return this.text(question, ctx);
|
|
633
635
|
default:
|
|
@@ -707,6 +709,47 @@ export class Inquirerer {
|
|
|
707
709
|
});
|
|
708
710
|
});
|
|
709
711
|
}
|
|
712
|
+
async password(question, ctx) {
|
|
713
|
+
if (this.noTty || !this.rl || !this.keypress) {
|
|
714
|
+
return null; // Password input requires interactive terminal
|
|
715
|
+
}
|
|
716
|
+
this.keypress.resume();
|
|
717
|
+
const mask = question.mask ?? '*';
|
|
718
|
+
let input = '';
|
|
719
|
+
// Display the prompt with masked input
|
|
720
|
+
const display = () => {
|
|
721
|
+
this.clearScreen();
|
|
722
|
+
const maskedInput = mask.repeat(input.length);
|
|
723
|
+
this.displayPrompt(question, ctx, maskedInput);
|
|
724
|
+
};
|
|
725
|
+
display();
|
|
726
|
+
// Handle backspace
|
|
727
|
+
this.keypress.on(KEY_CODES.BACKSPACE, () => {
|
|
728
|
+
if (input.length > 0) {
|
|
729
|
+
input = input.slice(0, -1);
|
|
730
|
+
display();
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
// Register alphanumeric, symbols, and space keypresses
|
|
734
|
+
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !@#$%^&*()_+-=[]{}|;:\'",.<>?/`~\\';
|
|
735
|
+
chars.split('').forEach(char => {
|
|
736
|
+
this.keypress.on(char, () => {
|
|
737
|
+
input += char;
|
|
738
|
+
display();
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
return new Promise((resolve) => {
|
|
742
|
+
this.keypress.on(KEY_CODES.ENTER, () => {
|
|
743
|
+
this.keypress.pause();
|
|
744
|
+
if (input.trim() !== '') {
|
|
745
|
+
resolve(input);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
resolve(null);
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
}
|
|
710
753
|
async checkbox(question, ctx) {
|
|
711
754
|
if (this.noTty || !this.rl) {
|
|
712
755
|
const options = this.sanitizeOptions(question);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirerer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts",
|
|
6
6
|
"main": "index.js",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"deepmerge": "^4.3.1",
|
|
38
|
-
"find-and-require-package-json": "0.9.
|
|
38
|
+
"find-and-require-package-json": "0.9.1",
|
|
39
39
|
"minimist": "^1.2.8",
|
|
40
|
-
"yanse": "0.2.
|
|
40
|
+
"yanse": "0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [],
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
|
-
"clean-ansi": "0.2.
|
|
45
|
+
"clean-ansi": "0.2.1",
|
|
46
46
|
"makage": "0.1.10",
|
|
47
47
|
"string-width": "4.2.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "1d2795da97e2217a7df24b2942a0b4e5879ac16f"
|
|
50
50
|
}
|
package/prompt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable, Writable } from 'stream';
|
|
2
|
-
import { AutocompleteQuestion, CheckboxQuestion, ConfirmQuestion, ListQuestion, NumberQuestion, OptionValue, Question, TextQuestion, Validation } from './question';
|
|
2
|
+
import { AutocompleteQuestion, CheckboxQuestion, ConfirmQuestion, ListQuestion, NumberQuestion, OptionValue, PasswordQuestion, Question, TextQuestion, Validation } from './question';
|
|
3
3
|
import { DefaultResolverRegistry } from './resolvers';
|
|
4
4
|
export interface ManPageInfo {
|
|
5
5
|
commandName: string;
|
|
@@ -110,6 +110,7 @@ export declare class Inquirerer {
|
|
|
110
110
|
confirm(question: ConfirmQuestion, ctx: PromptContext): Promise<boolean>;
|
|
111
111
|
text(question: TextQuestion, ctx: PromptContext): Promise<string | null>;
|
|
112
112
|
number(question: NumberQuestion, ctx: PromptContext): Promise<number | null>;
|
|
113
|
+
password(question: PasswordQuestion, ctx: PromptContext): Promise<string | null>;
|
|
113
114
|
checkbox(question: CheckboxQuestion, ctx: PromptContext): Promise<OptionValue[]>;
|
|
114
115
|
autocomplete(question: AutocompleteQuestion, ctx: PromptContext): Promise<any>;
|
|
115
116
|
list(question: ListQuestion, ctx: PromptContext): Promise<any>;
|
package/prompt.js
CHANGED
|
@@ -635,6 +635,8 @@ class Inquirerer {
|
|
|
635
635
|
return this.autocomplete(question, ctx);
|
|
636
636
|
case 'number':
|
|
637
637
|
return this.number(question, ctx);
|
|
638
|
+
case 'password':
|
|
639
|
+
return this.password(question, ctx);
|
|
638
640
|
case 'text':
|
|
639
641
|
return this.text(question, ctx);
|
|
640
642
|
default:
|
|
@@ -714,6 +716,47 @@ class Inquirerer {
|
|
|
714
716
|
});
|
|
715
717
|
});
|
|
716
718
|
}
|
|
719
|
+
async password(question, ctx) {
|
|
720
|
+
if (this.noTty || !this.rl || !this.keypress) {
|
|
721
|
+
return null; // Password input requires interactive terminal
|
|
722
|
+
}
|
|
723
|
+
this.keypress.resume();
|
|
724
|
+
const mask = question.mask ?? '*';
|
|
725
|
+
let input = '';
|
|
726
|
+
// Display the prompt with masked input
|
|
727
|
+
const display = () => {
|
|
728
|
+
this.clearScreen();
|
|
729
|
+
const maskedInput = mask.repeat(input.length);
|
|
730
|
+
this.displayPrompt(question, ctx, maskedInput);
|
|
731
|
+
};
|
|
732
|
+
display();
|
|
733
|
+
// Handle backspace
|
|
734
|
+
this.keypress.on(keypress_1.KEY_CODES.BACKSPACE, () => {
|
|
735
|
+
if (input.length > 0) {
|
|
736
|
+
input = input.slice(0, -1);
|
|
737
|
+
display();
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
// Register alphanumeric, symbols, and space keypresses
|
|
741
|
+
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !@#$%^&*()_+-=[]{}|;:\'",.<>?/`~\\';
|
|
742
|
+
chars.split('').forEach(char => {
|
|
743
|
+
this.keypress.on(char, () => {
|
|
744
|
+
input += char;
|
|
745
|
+
display();
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
return new Promise((resolve) => {
|
|
749
|
+
this.keypress.on(keypress_1.KEY_CODES.ENTER, () => {
|
|
750
|
+
this.keypress.pause();
|
|
751
|
+
if (input.trim() !== '') {
|
|
752
|
+
resolve(input);
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
resolve(null);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
}
|
|
717
760
|
async checkbox(question, ctx) {
|
|
718
761
|
if (this.noTty || !this.rl) {
|
|
719
762
|
const options = this.sanitizeOptions(question);
|
package/question/types.d.ts
CHANGED
|
@@ -63,4 +63,8 @@ export interface NumberQuestion extends BaseQuestion {
|
|
|
63
63
|
type: 'number';
|
|
64
64
|
default?: number;
|
|
65
65
|
}
|
|
66
|
-
export
|
|
66
|
+
export interface PasswordQuestion extends BaseQuestion {
|
|
67
|
+
type: 'password';
|
|
68
|
+
mask?: string;
|
|
69
|
+
}
|
|
70
|
+
export type Question = ConfirmQuestion | ListQuestion | AutocompleteQuestion | CheckboxQuestion | TextQuestion | NumberQuestion | PasswordQuestion;
|