npm-git

Use git-repo(such as gitlab/bitbucket) for publish private package

Usage no npm install needed!

<script type="module">
  import npmGit from 'https://cdn.skypack.dev/npm-git';
</script>

README

npm-git

NPM Version NPM Downloads Build Status

  • use private git(gitLab,bitbucket,etc) instead of npm
  • use npmgit publish instead of npm publish command line, compile & push to your git repo

Install

npm install npm-git -g

Why?

想实现私有的npm,通常是2种方案:

  1. npmjs.com即将推出的:npm private modules & npm Enterprise

    • npm private modules 可指定有权使用package的用户,也就是你可以npm publish @mycorp/mypkg,而mypkg源码可以放在任何git仓库。
    • npm Enterprise 结合GitHub企业版,更完美了。
  2. 自建npm服务器,维护比较复杂,不推荐。

而以上2种方案,都还是需要自行管理源码:git仓库,即开发者至少需要2步才能完成1个package的发布:

  1. git commit && git push
  2. npm publish

除此之外,就是用npm本身对Git URLs的支持了(《关于commit-ish》):

dependencies: {
  "mypkg": "git+https://mycopr/mypkg.git#commit-ish"
}

这样成本较低,但看不了依赖、被依赖、安装量等等

Usage

package.json:

{
  "version": "0.1.8"
}
npmgit publish 'bug fix'
// -> git+git@mycorp:/mypkg.git#0.1.8 is published.

if git tag is package version,auto increment semver's patch to 0.1.9

npmgit publish
// -> git+git@mycorp:/mypkg.git#0.1.9 is published.

Todo

License

MIT