CLI: npm token create could be easier to automate.

(Public Tech Admin) #1

NPM is awesome - thanks for all the hard work so far.

I’m automating a deployment and I’d like to generate an npm token for each deploy.
I’ve a couple of enhancement requests for the npm token create cli command, which at the moment is difficult to automate.

  1. When running npm token create the output lists all the properties of the created token in ascii table format.
    Would it be possible to provide an option to just return the token value, so you could redirect the output into a variable or similar? Currently, I’d have to parse the returned table of properties.

  2. When running npm token create would it be possible to provide the npm password as a parameter? Currently this can be navigated around using an expect script in bash or similar, but thats a hack. An alternative to a parameter would be to use an ENV_VAR I guess.

(Lars Willighagen) #2

There’s --json but you’d still need to parse.

There’s also a Node API for creating tokens documented here. It’s available through both the npm-profile and libnpm packages. I don’t know of any CLI params.