CLI command line tool
How to create a package that can be used as cli (and package)?
Folder Structure
use the generator: https://github.com/yeoman/generator-node
create a
bin
folder, create a file called: 'my-cli'Update your package.json:
So the flow is:
We tell package the bin file is in the
bin
folderThe bin file invokes the actual script in
dist
folderWe develop the script in
lib
folder and babel the source ('prepublish') todist
folderTo test locally on dev machine
To publish internally, do
Reference:
Useful Libs
interactive input https://github.com/SBoudrias/Inquirer.js
cli helper: https://www.npmjs.com/package/meow
full blown cli tool: https://github.com/tj/commander.js
isolated cli, similar to REPL: https://github.com/dthree/vorpal
shell commands, and make tool in js: https://github.com/shelljs/shelljs
so you can have a make file like this: https://github.com/madrobby/zepto/blob/master/make
to run, do
coffee make testName
color in cli: https://www.npmjs.com/package/chalk
A list of cli tools: https://github.com/sindresorhus/awesome-nodejs#command-line-apps
Last updated