tag-dist-files v0.1.6
tag-dist-files
Tag distribution files without messing up your git history - sort of fixes bower - awesome for publishing js libraries
Publishing javascript libraries to bower can be very difficult. Bower expects that distribution files (babelified & uglified & webpackyfied & blubberyfied, .. whatever we do these days..) exist in the tagged commits. At least our users expect that. But 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 messing up our commit history:
git checkout --detachWe detach the head. This means we no longer track any branchgit add -f filesWe force to add all distribution files specified in package.json'sfilesattributegit commit -am 'Publish vX.Y.Z -- with dist files'Commit dist files.vX.Y.Zis given by package.json's version attributegit tag vX.Y.ZTag release with dist filesgit push origin vX.Y.ZPush taggit checkout masterRevert to tracking master branch (dist files are no longer tracked / in the git history)
Checklist
This tool is for you if..
- You have a
package.json. - You understand what it does
- You work in a unix-ish environment (Linux | Mac (untested) | Windows with Cygwin (untested))
Tutorial
$ npm i -g tag-dist-files
$ tag-dist-filesThis tool works really well with npm publish (or even better: np).
..
"scripts": {
..
"postversion": "npm run dist",
"postpublish": "tag-dist-files --overwrite-existing-tag"
}Then you can just run np. The difference is that all files specified in package.json's files attribute are added to your tagged commit. Therefore, bower i your-package installs distribution files too!