Start by creating a new directory, moving into it, and initializing a Git repository.
This repo will eventually need to be on GitHub so Knope can create releases for it.
You can do that with the GitHub CLI:
Create a Knope config file
Knope requires a config file to support multiple packages.
You could use knope --generate to create the default config,
but it wouldn’t be quite right for multiple packages.
Instead, create this by hand:
Those referenced files must exist as well:
Commit this to serve as a baseline for the rest of the tutorial:
Use the arrow keys and space bar to select pizza and calzone, then press enter.
Next, select patch as the change type for each:
Finally, summarize the change:
This will create a change file that looks like this:
It includes the name of each package that the change impacts,
the type of change for each of those packages, and the summary.
At this point,
you could add as much Markdown as you want to the bottom of the file to describe the change more fully.
Knope can show you a preview of the upcoming release:
Knope updates the versions and changelogs of each package independently.
Because there are no changes to toppings, nothing will happen to it.
Conventional commits
Changesets work great for monorepos by default, but conventional commits require a bit more care.
A basic conventional commit will apply to all packages:
You can limit commits to specific packages using scopes:
Now, conventional commits which have the pizza scope will only affect the pizza package,
and calzone commits will only affect the calzone package.
Commits without scopes (like the one you just created) will still affect all packages,
you can verify that with knope release --dry-run again.
It’s possible to recreate the changeset results using two commits:
But the point of conventional commits is to document the changes made within the commit,
so one change should be in one commit, not two.
It’s better to have a new scope that impacts both packages:
Now a single commit can impact both pizza and calzone, without impacting toppings:
This is the same result as the changeset, but with a single commit message instead.
Time to try it out for real:
If you don’t have a GitHub token set, Knope will prompt you to create one and paste it into the terminal.
Once you do, you’ll see some output from Git.
If there are no errors, your releases should exist!
Open your repo in GitHub (you can use gh repo view --web), and click on “Releases” on the side.
You should see something like this:
Knope creates one release on GitHub per package so that it’s easy for consumers to see
what’s changed in only the packages they care about!
Wrapping up
In this tutorial, you:
Configured Knope for a monorepo
Documented changes using both changesets and conventional commits