@listr2/prompt-adapter-inquirer 1.0.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Cenk Kilic <cenk@kilic.dev> (https://srcs.kilic.dev)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @listr2/prompt-adapter-inquirer
2
+
3
+ [![Pipeline](https://gitlab.kilic.dev/libraries/listr2/badges/master/pipeline.svg?style=flat-square&ignore_skipped=true)](https://gitlab.kilic.dev/libraries/listr2/-/commits/master) [![Version](https://img.shields.io/npm/v/listr2.svg?style=flat-square&logo=npm)](https://www.npmjs.com/package/listr2?activeTab=versions) [![Downloads](https://img.shields.io/npm/dm/listr2.svg?style=flat-square&logo=npm)](https://www.npmjs.com/package/listr2) [![Size](https://img.shields.io/bundlephobia/min/listr2?style=flat-square&logo=npm)](https://www.npmjs.com/package/listr2) [![Dependencies](https://img.shields.io/librariesio/release/npm/listr2?style=flat-square&logo=npm)](https://www.npmjs.com/package/listr2?activeTab=dependencies) [![codecov](https://codecov.io/gh/listr2/listr2/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/listr2/listr2)
4
+
5
+ [![github sponsors](https://img.shields.io/github/sponsors/cenk1cenk2?style=flat-square&logo=github)](https://github.com/sponsors/cenk1cenk2) [![opencollective](https://img.shields.io/opencollective/sponsors/listr2?label=open%20collective&logo=opencollective)](https://opencollective.com/listr2)
6
+
7
+ **Create beautiful CLI interfaces via easy and logical to-implement task lists that feel alive and interactive.**
8
+
9
+ ---
10
+
11
+ ## Documentation
12
+
13
+ This is an extension to [`listr2`](https://listr2.kilic.dev/) to create prompts with [`@inquirer/prompts`](https://github.com/SBoudrias/Inquirer.js/blob/master/packages/prompts/README.md).
14
+
15
+ **[Read the documentation...](https://listr2.kilic.dev/task/prompts.html#inquirer)**
package/dist/index.cjs ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ ListrInquirerPromptAdapter: () => ListrInquirerPromptAdapter
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/prompt.ts
29
+ var import_listr2 = require("listr2");
30
+ var _ListrInquirerPromptAdapter = class _ListrInquirerPromptAdapter extends import_listr2.ListrPromptAdapter {
31
+ /**
32
+ * Get the current running instance of `inquirer`.
33
+ */
34
+ get instance() {
35
+ return this.prompt;
36
+ }
37
+ /**
38
+ * Create a new prompt with `inquirer`.
39
+ */
40
+ async run(prompt, ...[config, context]) {
41
+ context ??= {};
42
+ context.output ??= this.wrapper.stdout(import_listr2.ListrTaskEventType.PROMPT);
43
+ this.reportStarted();
44
+ this.task.on(import_listr2.ListrTaskEventType.STATE, (event) => {
45
+ if (event === import_listr2.ListrTaskState.SKIPPED && this.prompt) {
46
+ this.cancel();
47
+ }
48
+ });
49
+ this.prompt = prompt(config, context);
50
+ let result;
51
+ try {
52
+ result = await this.prompt;
53
+ this.reportCompleted();
54
+ } catch (e) {
55
+ this.reportFailed();
56
+ throw e;
57
+ }
58
+ return result;
59
+ }
60
+ /**
61
+ * Cancel the ongoing prompt.
62
+ */
63
+ cancel() {
64
+ if (!this.prompt) {
65
+ return;
66
+ }
67
+ this.reportFailed();
68
+ this.prompt.cancel();
69
+ }
70
+ };
71
+ __name(_ListrInquirerPromptAdapter, "ListrInquirerPromptAdapter");
72
+ var ListrInquirerPromptAdapter = _ListrInquirerPromptAdapter;
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ ListrInquirerPromptAdapter
76
+ });
@@ -0,0 +1,20 @@
1
+ import { CancelablePromise, Prompt } from '@inquirer/type';
2
+ import { ListrPromptAdapter } from 'listr2';
3
+
4
+ declare class ListrInquirerPromptAdapter extends ListrPromptAdapter {
5
+ private prompt;
6
+ /**
7
+ * Get the current running instance of `inquirer`.
8
+ */
9
+ get instance(): CancelablePromise<any>;
10
+ /**
11
+ * Create a new prompt with `inquirer`.
12
+ */
13
+ run<T extends Prompt<any, any> = Prompt<any, any>>(prompt: T, ...[config, context]: Parameters<T>): Promise<ReturnType<T>>;
14
+ /**
15
+ * Cancel the ongoing prompt.
16
+ */
17
+ cancel(): void;
18
+ }
19
+
20
+ export { ListrInquirerPromptAdapter };
@@ -0,0 +1,20 @@
1
+ import { CancelablePromise, Prompt } from '@inquirer/type';
2
+ import { ListrPromptAdapter } from 'listr2';
3
+
4
+ declare class ListrInquirerPromptAdapter extends ListrPromptAdapter {
5
+ private prompt;
6
+ /**
7
+ * Get the current running instance of `inquirer`.
8
+ */
9
+ get instance(): CancelablePromise<any>;
10
+ /**
11
+ * Create a new prompt with `inquirer`.
12
+ */
13
+ run<T extends Prompt<any, any> = Prompt<any, any>>(prompt: T, ...[config, context]: Parameters<T>): Promise<ReturnType<T>>;
14
+ /**
15
+ * Cancel the ongoing prompt.
16
+ */
17
+ cancel(): void;
18
+ }
19
+
20
+ export { ListrInquirerPromptAdapter };
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/prompt.ts
5
+ import { ListrPromptAdapter, ListrTaskEventType, ListrTaskState } from "listr2";
6
+ var _ListrInquirerPromptAdapter = class _ListrInquirerPromptAdapter extends ListrPromptAdapter {
7
+ /**
8
+ * Get the current running instance of `inquirer`.
9
+ */
10
+ get instance() {
11
+ return this.prompt;
12
+ }
13
+ /**
14
+ * Create a new prompt with `inquirer`.
15
+ */
16
+ async run(prompt, ...[config, context]) {
17
+ context ??= {};
18
+ context.output ??= this.wrapper.stdout(ListrTaskEventType.PROMPT);
19
+ this.reportStarted();
20
+ this.task.on(ListrTaskEventType.STATE, (event) => {
21
+ if (event === ListrTaskState.SKIPPED && this.prompt) {
22
+ this.cancel();
23
+ }
24
+ });
25
+ this.prompt = prompt(config, context);
26
+ let result;
27
+ try {
28
+ result = await this.prompt;
29
+ this.reportCompleted();
30
+ } catch (e) {
31
+ this.reportFailed();
32
+ throw e;
33
+ }
34
+ return result;
35
+ }
36
+ /**
37
+ * Cancel the ongoing prompt.
38
+ */
39
+ cancel() {
40
+ if (!this.prompt) {
41
+ return;
42
+ }
43
+ this.reportFailed();
44
+ this.prompt.cancel();
45
+ }
46
+ };
47
+ __name(_ListrInquirerPromptAdapter, "ListrInquirerPromptAdapter");
48
+ var ListrInquirerPromptAdapter = _ListrInquirerPromptAdapter;
49
+ export {
50
+ ListrInquirerPromptAdapter
51
+ };
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@listr2/prompt-adapter-inquirer",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Listr2 prompt adapter for inquirer.",
5
+ "license": "MIT",
6
+ "repository": "https://github.com/listr2/listr2",
7
+ "type": "module",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ },
17
+ "import": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "author": {
25
+ "name": "Cenk Kilic",
26
+ "email": "cenk@kilic.dev",
27
+ "url": "https://cenk.kilic.dev"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "engines": {
33
+ "node": ">=16.0.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup-node",
37
+ "dev:start": "tsup-node --watch",
38
+ "format": "prettier --log-level warn --write src/ tests/ && pnpm run lint --fix",
39
+ "lint": "eslint --ext .ts,.js,.tsx,.jsx src/ tests/",
40
+ "test": "NO_COLOR=1 TS_NODE_PROJECT=tests/tsconfig.json NODE_OPTIONS='--no-warnings --experimental-specifier-resolution=node --experimental-vm-modules' jest --config tests/jest.config.ts",
41
+ "test:cov": "pnpm run test --coverage",
42
+ "test:dev": "NODE_OPTIONS='--no-warnings --experimental-specifier-resolution=node --experimental-vm-modules --inspect=0.0.0.0:9229' pnpm run test --verbose --watchAll"
43
+ },
44
+ "lint-staged": {
45
+ "{src,tests}/**/*.{ts,js,tsx,jsx,spec.ts}": [
46
+ "prettier --log-level warn --write",
47
+ "eslint --fix"
48
+ ],
49
+ "*.{json,md}": [
50
+ "prettier --log-level warn --write"
51
+ ]
52
+ },
53
+ "keywords": [
54
+ "listr",
55
+ "listr2",
56
+ "cli",
57
+ "task",
58
+ "list",
59
+ "tasklist",
60
+ "terminal",
61
+ "term",
62
+ "console",
63
+ "ascii",
64
+ "unicode",
65
+ "loading",
66
+ "indicator",
67
+ "progress",
68
+ "busy",
69
+ "wait",
70
+ "idle"
71
+ ],
72
+ "dependencies": {
73
+ "@inquirer/type": "^1.1.4"
74
+ },
75
+ "devDependencies": {
76
+ "@inquirer/input": "^1.2.11",
77
+ "@inquirer/prompts": "^3.1.1",
78
+ "listr2": "7.0.0-beta.5"
79
+ },
80
+ "peerDependencies": {
81
+ "@inquirer/prompts": ">= 3 < 4"
82
+ }
83
+ }