I really enjoy publishing my Node packages through semantic-release
service. Now I don't have to update the package version, rebuild, tag, run
npm publish, etc. Most importantly, I don't have to think anymore what kind of
change it is: breaking (major number increment), new API feature (minor number increment)
or a bug fix (patch increment). The semantic-release inspects the commit messages to
figure out if a new version needs to be published. A commit message validator
like commitizen or pre-git will do the trick.
To start the process, install the CLI tool and go
npm install --global semantic-release-cli
Then inside any package folder run the setup
Most of the times, the tool will start by asking you if the repo is private or public
$ semantic-release-cli setup git url https:[email protected]:bahmutov/lazy-ass.git ? Is the GitHub repository private? (y/N)
But for some of my public repos hosted on GitHub the question was different
Are you using GitHub Enterprise? (Y/n)
The semantic release setup then failed. Finally, I found where in the version 1.3.2 the problem happened.
var parsedUrl = parseGhUrl(rurl);
For some reason a valid repository url from my
package.json was converted incorrectly
var parseGhUrl = require('parse-github-repo-url');
The module is tiny - single function parsing GitHub urls (including
The project is clean, with good unit tests covering different edge cases. But the
code and unit tests did not handle urls like
With the little utility module broken, what is my alternative at the moment?
I want to get
[email protected] to work - I just need to run it once per
repository. Can I use my own patched parsing repo instead of the broken one?
Turns out it is very simple to do. Here is how to patch the CLI tool installed as a global module by NPM
jump into the global module using
npm explore -g command
$ npm explore -g semantic-release-cli
parse-github-repo-url is there inside the
install my patched module right from GitHub
$ npm install https://github.com/bahmutov/parse-github-repo-url.git
finish by going back from the CLI folder using
Now I can use the setup command and everything is parsed correctly.
Except, now it was the semantic release code that started failing because
it does not know how to parse
git@ urls :)
Error: Invalid URI "https:[email protected]:bahmutov/lazy-ass.git"
As a solution I went back and removed using url from the package.json,
instead using the one from the
.git/config - it seems to work reliably.