An npm monorepo
The smallest real npm monorepo release setup: one space of packages, a build and a publish command, and versions computed from your commits.
{
"scripts": {
"build": "npm ci --silent && npm run build --silent",
"publish": "npm publish --access public"
},
"spaces": {
"libs": {
"path": "packages",
"flow": {
"build": "build",
"publish": "publish"
}
}
}
}
Commit work with the package name in the scope, then look at the plan before releasing anything:
$ git commit -m "feat(logger): first version of the logger"
$ dispat status
12:04:05 INF ● changed bump=minor channel=stable dueToProviders=[] ownCommits=1 package=logger reason=direct space=libs version="0.0.0 -> 0.1.0"
12:04:05 INF release plan ready held=0 packages=1 releasing=1
status changes nothing; it shows what a release would do. The release itself:
$ dispat
12:04:05 INF ● changed bump=minor channel=stable dueToProviders=[] ownCommits=1 package=logger reason=direct space=libs version="0.0.0 -> 0.1.0"
12:04:05 INF release plan ready held=0 packages=1 releasing=1
12:04:05 INF build started package=logger stage=build version=0.1.0
12:04:05 INF added 42 packages in 1s package=logger stage=build version=0.1.0
12:04:05 INF build succeeded package=logger stage=build version=0.1.0
12:04:05 INF publish started package=logger stage=publish version=0.1.0
12:04:05 INF + logger@0.1.0 package=logger stage=publish version=0.1.0
12:04:05 INF published package=logger stage=publish tag=logger@0.1.0 version=0.1.0
12:04:05 INF summary channel=stable package=logger status=published tag=logger@0.1.0 took=1.2s version="0.0.0 -> 0.1.0"
12:04:05 INF done cancelled=0 failed=0 held=0 published=1 skipped=0 took=1.2s unchanged=0
$ git tag
logger@0.1.0
The annotated tag is the record that the publish happened. Push it (or let dispat push it, see release records) and the release is done.
One thing to know about versions: your package.json version field does not drive anything. dispat computes the version
from commits and tags, and hands it to your scripts as $DISPAT_NEW_VERSION. A typical build script therefore stamps it
in before packing:
npm version "$DISPAT_NEW_VERSION" --no-git-tag-version && npm ci && npm run build