@inquirer/confirm 0.0.17-alpha.0 → 0.0.20-alpha.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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Simon Boudrias
1
+ Copyright (c) 2022 Simon Boudrias
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
19
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
22
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Simple interactive command line prompt to gather boolean input from users.
4
4
 
5
+ ![Confirm prompt](https://cdn.rawgit.com/SBoudrias/Inquirer.js/28ae8337ba51d93e359ef4f7ee24e79b69898962/assets/screenshots/confirm.svg)
6
+
5
7
  # Installation
6
8
 
7
9
  ```sh
@@ -27,5 +29,5 @@ const answer = await confirm({ message: 'Enter your name' });
27
29
 
28
30
  # License
29
31
 
30
- Copyright (c) 2019 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))
32
+ Copyright (c) 2022 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))
31
33
  Licensed under the MIT license.
package/demo.ts ADDED
@@ -0,0 +1,18 @@
1
+ import confirm from './src/index.js';
2
+
3
+ (async () => {
4
+ console.log(
5
+ 'Answer:',
6
+ await confirm({
7
+ message: 'Confirm?',
8
+ })
9
+ );
10
+
11
+ console.log(
12
+ 'Answer:',
13
+ await confirm({
14
+ message: 'Confirm with default to no?',
15
+ default: false,
16
+ })
17
+ );
18
+ })();
@@ -0,0 +1,8 @@
1
+ declare const _default: (options: {
2
+ message: string;
3
+ default?: boolean | undefined;
4
+ }, stdio?: {
5
+ input?: NodeJS.ReadableStream | undefined;
6
+ output?: NodeJS.WritableStream | undefined;
7
+ } | undefined) => Promise<boolean>;
8
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import chalk from 'chalk';
2
+ import { createPrompt, useState, useKeypress, isEnterKey, usePrefix, } from '@inquirer/core';
3
+ export default createPrompt((config, done) => {
4
+ const [status, setStatus] = useState('pending');
5
+ const [value, setValue] = useState('');
6
+ const prefix = usePrefix();
7
+ useKeypress((key, rl) => {
8
+ if (isEnterKey(key)) {
9
+ const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
10
+ setValue(answer ? 'yes' : 'no');
11
+ setStatus('done');
12
+ done(answer);
13
+ }
14
+ else {
15
+ setValue(rl.line);
16
+ }
17
+ });
18
+ let formattedValue = value;
19
+ let defaultValue = '';
20
+ if (status === 'done') {
21
+ formattedValue = chalk.cyan(value);
22
+ }
23
+ else {
24
+ defaultValue = chalk.dim(config.default === false ? ' (y/N)' : ' (Y/n)');
25
+ }
26
+ const message = chalk.bold(config.message);
27
+ return `${prefix} ${message}${defaultValue} ${formattedValue}`;
28
+ });
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@inquirer/confirm",
3
- "version": "0.0.17-alpha.0",
3
+ "type": "module",
4
+ "version": "0.0.20-alpha.0",
4
5
  "description": "Inquirer confirm prompt",
6
+ "main": "dist/index.js",
7
+ "typings": "dist/index.d.ts",
8
+ "repository": "SBoudrias/Inquirer.js",
5
9
  "keywords": [
6
10
  "cli",
7
11
  "command",
@@ -12,17 +16,18 @@
12
16
  "terminal"
13
17
  ],
14
18
  "author": "Simon Boudrias <admin@simonboudrias.com>",
15
- "homepage": "https://github.com/SBoudrias/Inquirer.js#readme",
16
19
  "license": "MIT",
17
- "main": "index.js",
18
- "repository": "SBoudrias/Inquirer.js",
20
+ "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/confirm/README.md",
19
21
  "dependencies": {
20
- "@inquirer/core": "^0.0.18-alpha.0",
21
- "@inquirer/input": "^0.0.18-alpha.0",
22
- "chalk": "^4.1.1"
22
+ "@inquirer/core": "^0.0.21-alpha.0",
23
+ "@inquirer/input": "^0.0.21-alpha.0",
24
+ "chalk": "^5.0.1"
25
+ },
26
+ "scripts": {
27
+ "tsc": "tsc"
23
28
  },
24
29
  "publishConfig": {
25
30
  "access": "public"
26
31
  },
27
- "gitHead": "e71313db1a6e26f501b58d75a9d3acf53dab5da7"
32
+ "gitHead": "cd0d1465327c0e98a89c937a80b7c473b6d00f74"
28
33
  }
package/src/index.ts ADDED
@@ -0,0 +1,38 @@
1
+ import chalk from 'chalk';
2
+ import {
3
+ createPrompt,
4
+ useState,
5
+ useKeypress,
6
+ isEnterKey,
7
+ usePrefix,
8
+ } from '@inquirer/core';
9
+
10
+ export default createPrompt<boolean, { message: string; default?: boolean }>(
11
+ (config, done) => {
12
+ const [status, setStatus] = useState('pending');
13
+ const [value, setValue] = useState('');
14
+ const prefix = usePrefix();
15
+
16
+ useKeypress((key, rl) => {
17
+ if (isEnterKey(key)) {
18
+ const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
19
+ setValue(answer ? 'yes' : 'no');
20
+ setStatus('done');
21
+ done(answer);
22
+ } else {
23
+ setValue(rl.line);
24
+ }
25
+ });
26
+
27
+ let formattedValue = value;
28
+ let defaultValue = '';
29
+ if (status === 'done') {
30
+ formattedValue = chalk.cyan(value);
31
+ } else {
32
+ defaultValue = chalk.dim(config.default === false ? ' (y/N)' : ' (Y/n)');
33
+ }
34
+
35
+ const message = chalk.bold(config.message);
36
+ return `${prefix} ${message}${defaultValue} ${formattedValue}`;
37
+ }
38
+ );
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist"
5
+ },
6
+ "include": ["./src"]
7
+ }
package/demo.js DELETED
@@ -1,16 +0,0 @@
1
- const confirm = require('.');
2
-
3
- (async () => {
4
- let answer;
5
-
6
- answer = await confirm({
7
- message: 'Confirm?',
8
- });
9
- console.log('Answer:', answer);
10
-
11
- answer = await confirm({
12
- message: 'Confirm with default to no?',
13
- default: false,
14
- });
15
- console.log('Answer:', answer);
16
- })();
package/index.js DELETED
@@ -1,32 +0,0 @@
1
- const chalk = require('chalk');
2
- const { createPrompt, useState, useKeypress } = require('@inquirer/core/hooks');
3
- const { isEnterKey } = require('@inquirer/core/lib/key');
4
- const { usePrefix } = require('@inquirer/core/lib/prefix');
5
-
6
- module.exports = createPrompt((config, done) => {
7
- const [status, setStatus] = useState('pending');
8
- const [value, setValue] = useState('');
9
- const prefix = usePrefix();
10
-
11
- useKeypress((key, rl) => {
12
- if (isEnterKey(key)) {
13
- const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
14
- setValue(answer ? 'yes' : 'no');
15
- setStatus('done');
16
- done(answer);
17
- } else {
18
- setValue(rl.line);
19
- }
20
- });
21
-
22
- let formattedValue = value;
23
- let defaultValue = '';
24
- if (status === 'done') {
25
- formattedValue = chalk.cyan(value);
26
- } else {
27
- defaultValue = chalk.dim(config.default === false ? ' (y/N)' : ' (Y/n)');
28
- }
29
-
30
- const message = chalk.bold(config.message);
31
- return `${prefix} ${message}${defaultValue} ${formattedValue}`;
32
- });