git-as-npm
v0.0.3
Published
git-as-npm ===
Downloads
4
Readme
git-as-npm
A quick and dirty (for now) script that gets git to behave a little more like NPM at times when we'd like it to. publish
is the only command that currently works. Like so:
git-as-npm publish
Why?
NPM is great for managing JS modules. However, private modules aren't free, and maintaining your own registry isn't, either. Thankfully, you can install NPM dependencies directly from Git, like so:
"blah-lib": "git+ssh://[email protected]/blah/blah-lib.git"
You can also install specific tags or commits, by appending #
on the end, like so:
git+ssh://[email protected]/blah/blah-lib.git#0.0.3
But the process by which you tag these releases is entirely manual.
Making it not manual
So what does this script do?
- Checks out a branch called
release
(or creates it if it doesn't exist). - Merges your current branch into
release
. - Pulls down a remote copy of the
release
branch, to sync up which version numbers have already been released. - Runs
npm prepublish
, if that script exists. - Creates a tag with your current
package.json
version number, throwing an error if that release already exists. - Adds a new remote, as specified in the
repository
field of package.json - Pushes this up to git
- Tidies up after itself, deleting the remote and returning you to your original branch.
Ta-da
It doesn't handle everything - you still need to specify the version when doing an npm install
and so on, but hopefully it makes things a little easier.