ez-publish
v1.0.0-alpha.16
Published
Command line tool for publishing js libraries
Downloads
6
Readme
ez-publish
Opinionated command line tool for publishing javascript libraries
Publishing javascript libraries to bower can be very difficult. Bower expects that distribution files (babelified, uglified, webpackyfied, blubberyfied, ..) are present in the tagged commits. At least our users expect that. Having distribution files in the commit history sucks. This is why some projects (e.g. quill) don't even publish distribution files in the tagged commits. This sucks for the user (not everyone wants to use 99 transpilation tools). Other projects (e.g. ace) have a dedicated project for publishing distribution files. This sucks for the developer. I think this approach sucks less.
What it does
We use a nifty trick to tag distribution files without fucking up our commit history:
git checkout --detach
We detach the head. This means we no longer track any branchgit add -f ./dist project-name*
We force to add all distribution filesgit commit -am 'Publish vX.Y.Z -- with dist files'
Commit dist filesgit tag vX.Y.Z
Tag release with dist filesgit push origin vX.Y.Z
Push taggit checkout master
Revert to tracking master branch (dist files are no longer tracked / in the git history)
What it also does
- Adds that release message to
./CHANGELOG.md
, and to the tag description - OPTIONAL: You can work on
./.releaseMessage
before you publish usingez-publish
Checklist
This tool is for you if.. (all of the following must be true)
- [x] You have a
package.json
. - [x] All files you want to distribute are in
./dist
or match./PROJECTNAME*
.WherePROJECTNAME
is given byrequire(package.json).name
- [x] You understand what it does
- [x] You work in a unix-ish environment (Linux | Mac (untested) | Windows with Cygwin (untested))
Tutorial
$ npm i -g ez-publish
$ publish
It is a good idea to write a prepublish
script in your package.json
(overwrites default behavior of npm publish
)
..
"scripts": {
..
"prepublish": "npm run dist && npm run lint",
"postpublish": "publish"
}
Then you can just run npm publish
, and automatically create tags etc..