gonzofish / angular-librarian

An Angular 2+ scaffolding setup for creating libraries
https://www.npmjs.com/package/angular-librarian
MIT License
91 stars 9 forks source link

tagVersion/publish does not bump package.json version #53

Closed gonzofish closed 7 years ago

gonzofish commented 7 years ago

Noticed in my testes that my project's package.json version isn't getting publish. I also noticed that no Git tags were being created either.

This is because we're using np, which is a great library. However, because of the way it works, as part of tagVersion, we cd into dist. When we do this, the dist version of package.json does get bumped, but the real package.json does not.

Also, because we're in dist, no tags are being created or pushed.

gonzofish commented 7 years ago

Ok, I believe I've figured this out--it involved changes to the build process. The use of np was not added by me and I didn't know enough about it. So I did a little research and, instead of running the build step as part of preTagVersion step, we're doing it at prepublish. By doing this, np will go about business as usual and build the package into dist right before publishing. We then change into the dist directory before np runs npm publish and it should work.

This also required another change: the package.json's peerDependencies need to go back to dependencies so that we can effectively test. At build time we change it to peerDependencies so consumers will have a better dev experience.

gonzofish commented 7 years ago

Still working it out: https://github.com/sindresorhus/np/issues/175

gonzofish commented 7 years ago

I believe I've "solved" it, until I get an answer back from the np team/community.

Instead of letting np do the npm publish, we pass it a --no-publish flag and then do npm run build && npm publish dist as a posttagVersion script.

gonzofish commented 7 years ago

The np team isn't going to provide a way of doing this, so for now we'll keep using np --no-publish + npm run build && npm publish dist to accomplish this