A reworking of npm's init-package-json to make reusable prompt-based CLIs for making config.json files.
A reworking of init-package-json to make reusable prompt-based CLIs for making config.json files.
This package generalizes npm's
npm init interface so you can require it as its own module and set your project-specific prompts in your project -- where they belong -- in a file called
This package assumes that in your project root folder you have
default-input.js files that contain any default options or examples of what users could input.
It bakes out a
config.json file in
~/.conf/, so your project should look to load that file by default.
config.sample.json example with example or default values:
exportsname = prompt'Name' packagenameexportsdescription = prompt'Description' packagedescriptionexportsawesome = prompt'Is it awesome?' packageawesometoStringreturn JSONparseresponse
Note: Cast booleans to string so they show up in the interface as text and parse them with JSON so they don't end up as strings. See Promzard for more info about
In the gif above, this is what
main.js looks like.
var config_tree = require'config-tree';config_treesprout__dirname 'name-prefix';
.sprout takes two arguments: