3.0.8 • Published 14 days ago

@sap-devx/inquirer-gui v3.0.8

Weekly downloads
91
License
Apache-2.0
Repository
github
Last release
14 days ago

CircleCI Coverage Status Language grade: JavaScript Commitizen friendly GitHub license REUSE status dependentbot

Inquirer GUI

alt text

Description

inquirer-gui is a UI component that displays Inquirer.js-compliant questions in an interactive HTML form.

Requirements

Installation and Usage

There are several use-cases for the consuming inquirer-gui component:

  • You can use it in another Vue application or in a non-Vue application
  • You can use it in a browser or in Visual Studio Code
  • You can provide the questions in the frontend or in the backend (providing questions in the backend implies more flexibility in composing questions)

We provide examples for some of the above use-cases.

First, clone this directory:

git clone https://github.com/SAP/inquirer-gui

Run in Browser (Frontend Questions)

Use the provided sample-app:

npm install
cd sample-app
npm install
npm run serve

This will run the web server on localhost on an available port. Open the provided link in the browser.

Run in Browser (Backend Questions)

Use the provided sample-app and websocket-server:

npm install
cd websocket-server
npm install

If using Visual Studio Code, run the WebSocket Server debug configuration. This will start the sample WebSocket server that listens for requests on port 8081.

cd sample-app
npm install
npm run serve

This will run the web server on localhost on an available port. Open the provided link in the browser.

Usage

If writing a Vue application, simply add the following line to your <template> tag:

   <Form ref="form" :questions="questions" @answered="onAnswered" />

The questions property is an inquirer.js-compliant array of questions. E.g.:

[
  {
    type: "input",
    name: "name",
    message: "Your name (frontend)",
    default: "Joe",
    validate: function (input) {
      if (input.length >= 2) {
        return true;
      } else {
            return "Name must be at least 2 characters long";
      }
    }
  }
]

The answered event is fired when any answer is changed:

  • The first parameter to the event handler, answers, contains all answers.
  • The second parameter, issues, can be used to, for example, enable or disable a Next button.

Custom form elements

inquirer-gui provides built-in form elements for all built-in inquirer.js question types:

  • list, rawlist
  • expand
  • checkbox
  • confirm
  • input (number, password and input)
  • editor

inquirer-gui supports custom form elements via its plugin mechanism (see more here).

Creating a custom form element

A form element plugin is a javascript object with this structure:

{
  questionType: '<inquirer-question-type>';
  component: <MyVueComponent>;
}

Where questionType is the string provided in the question's type property, and component is a Vue component that renders questions of the given type.

There is example of a custom form element in the /sample-plugin folder. It is defined as a Vue plugin and was published as @sap-devx/inquirer-gui-date-plugin on npm.

Consuming a custom form element

Consume a custom form element as a Vue plugin using the Vue.use() method. The plugin is returned in the method's options parameter. For example, refer to /sample-app/src/App.vue:

import DatePlugin from "@sap-devx/inquirer-gui-date-plugin";

const options = {};
// use the Vue plugin
Vue.use(DatePlugin, options);
// register the inquirer-gui plugin with your form instance
form.registerPlugin(options.plugin);

How to obtain support

To get more help, support and information please open a github issue.

Contributing

Contributing information can be found in the CONTRIBUTING.md file.

3.0.8

14 days ago

3.0.7

23 days ago

3.0.6

24 days ago

3.0.5

2 months ago

3.0.4

3 months ago

3.0.3

3 months ago

3.0.2

8 months ago

3.0.1

8 months ago

3.0.0

9 months ago

0.8.0

10 months ago

0.7.0

11 months ago

0.6.1

11 months ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.24

4 years ago

0.0.26

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago