npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

easywizard

v0.2.0

Published

NodeJs module for console wizard creation based in json files

Readme

easyWizard

easyWizard is a utility module wich provides easy way to build console wizards using a simple JSON property file, and collecting user answers to JSON object that you can use.

How Install

Easy again:

npm install easywizard

Quick Example

{
	"steps": [	{
					"id": "1"
				,	"question": "Your name: "
				,	"defaultAnswer": "popo"	
				,	"firstStep": true
				,	"type": "string"
				,	"property": "name"
				,	"nextStep": "2"
				,	"clearScreen": true
				}
			 ,  	{
			 		"id": "2"
				,	"question" : "Your surname: "	
				,	"type": "string"
				,	"allowNulls": true
				,	"property": "surname"
				,	"nextStep": "3"
			 	}
			, 	{
			 		"id": "3"
				,	"question" : "Age: "	
				,	"type": "numeric"
				,	"limits": { "min": 5, "max": 100}
				,	"property": "age"
				,	"nextStep": "4"
				,	"pause": true
			 	}
			 ,	{
			 		"id": "4"
				,	"question" : "Repeat? [y,n]:"	
				,	"type": "options"
				,	"options": { "y": { "nextStep": "1" , "value": "YES" }
							, "n": { "nextStep": null, "value": "NO" }
							}
			 	}
			 ]
}

This is a simple (but complete) JSON file to build a wizard Mainly, is a steps array. Each step must contais this fields:

  • id: A id field. Two differents step can not contains same id value
  • question: What do you want to ask to user?
  • type: What type of value are you expecting? ["string", "numeric", "option"]
  • nextStep: id of the next step. If type is option, each option can contain a own 'next step' value
  • options: if type is option you must add this field with options that user can choose

Then, you can add optional fields:

  • defaultAnswer: if user set blank value will be default value
  • property: name of property that resultant object will content with value that user will set
  • clearScreen: clear screen before ask question to user
  • firstStep: define what step will be the first. If this property never is defined, firtStep will be the first step in array
  • limits: max and min limits value for numeric type value
  • allowNulls: allow a null answer
  • value: in a optional question you can convert user answer in another one with a 'value' field into each option JSON object
  • pause: very interesting property! If you set this to true, you will pause wizard in this step for make what you want, and when you finish, you can continue emitting event 'continue'.

See, the next example:

// __ Modules _____________________________________________________________

var util = require("util")

// __ Main Object _________________________________________________________

var EasyWizard = require("../lib/easyWizard.js")
var ew = new EasyWizard()

// __ Test 01 _____________________________________________________________

var file1 = "../examples/basic.wizard"
ew.emitter.once('end', function() { console.log("\nResult:\n" +  util.inspect(ew.getObject())) })
ew.emitter.once('paused', function() {
	var o = ew.getObject()
	console.log("Adding 10 years to the age")
	o.age = parseInt(o.age) + 10
	ew.emitter.emit('continue')
})
ew.run(file1)

This example builds a wizard with the previous wizard JSON file and when 'age' step ends, wizard is paused (event 'paused'), test is going to add 10 years to age property, and then continue wizard. When wizard ends (event 'end'), resultant object is showed in console.

You can use this public methods also:

  • getObject(): return a object with all info of the wizards (responses of user)
  • resetObject(): reset object clearing all of properties
  • getCurrentStep(): return current step id of wizard at this moment
  • getNextStep(): return current next step id (if exists) of wizard at this moment
  • setNextStep(stepId): force the next step
  • setStdInOut(stdInput, stdOutput): set standard input/output

Contributors