I'd like to publish to NPM within my CI/build system, so I found libnpmpublish which seems to be the correct tool, but explicitly states that it doesn't pack your code into a tarball, although the publish
API requires that you pass it a tarball (as compared to, say, a folder or a path).
Their suggested solution is
Since
libnpmpublish
does not generate tarballs itself, one way to build your own tarball for publishing is to do npm pack in the directory you wish to pack. You can thenfs.createReadStream('my-proj-1.0.0.tgz'
) and pass that tolibnpmpublish
, along withrequire('./package.json')
.
Is there a programmatic (in Node) way to script this process? I looked around the NPM repositories and couldn't find a package that is dedicated to packaging, though I can find this code which seems to implement packing, but is in an archived repository- namely, it's not in libnpm
.
The closest I can find is npm-packlist which, when given a folder, creates a list of files which can be forwarded to the NPM tar
package, as demonstrated in the README for npm-packlist
.