nps
nps copied to clipboard
[Feature]: provide --interactive (-i) option
-
nps
version: 5.10.0 -
node
version: 18.10.0 -
npm
version: 8.19.2
Problem description:
The nps does a great job organizing scripts. But even then the scripts might grow to the extent where it's hard to remember exactly the command you need to run. I see the nps provides autocomplete feature, but it's currently buggy and also would not provide the experience I'm after.
Suggested solution:
I'd like to propose --interactive
option. When used, the nps would traverse the top-level scripts and use inquirer (probably) or commander to present these scripts as options to select from. Once one option is selected, if there are sub-options, these are presented. Otherwise, nps would execute the associated command.
Scripts file (or at least the relevant bits):
module.exports = {
scripts: {
default: "node index.js",
lint: "eslint .",
test: {
default: "jest",
watch: {
script: "jest --watch",
description: "run in the amazingly intelligent Jest watch mode"
}
},
build: {
default: "webpack",
prod: "webpack -p"
},
validate: npsUtils.concurrent.nps("lint", "test", "build")
}
};
The command executed:
nps -i
The output:
> default: node index.js
lint: eslint .
test...
build...
validate: npsUtils.concurrent.nps("lint", "test", "build")