Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a yarn version-tag-prefix and version-git-message per project?

Tags:

Yarn has a handy versioning config which allows you to configure git when a tag is created during versioning:

yarn config set version-tag-prefix "v"
yarn config set version-git-message "v%s"

However, I have a project with multiple npm projects inside of it and I want to version each with project-vn.n.n and the above seems to be a global setting.

Is there a way to configure the prefix and message per package.json (without having to manually specify it)?

like image 638
typeoneerror Avatar asked Nov 16 '19 20:11

typeoneerror


1 Answers

So, I just faced that exact same issue and found a way to fix it.

The short answer is that you can create a file .yarnrc in each project directory, with the following content:

# example of myrepo/workspace1/.yarnrc

version-tag-prefix workspace-1-v
version-git-message "workspace-1 v%s"

That way when running yarn publish from the workspace directory, or yarn workspaces run publish from the root of the repository yarn use workspace1/.yarnrc configuration.

A way to see where yarn is looking for config files is to run yarn <command> --verbose.

enter image description here

like image 95
dgellow Avatar answered Oct 05 '22 23:10

dgellow