semver
semver copied to clipboard
Option to use package.json name instead of Nx project name for tagging
Similar to this issue: https://github.com/jscutlery/semver/issues/215
When using Nx with "publishable" packages, you specify an "importPath" which corresponds to the name of the projects in package.json files. This name is not necessarily the same as the "nx" project name.
For example, I have a repo where every package is under an org, so the package.json package name is @org/my-package
while the Nx project name is just my-package
.
I would like to configure the release tagging so that it uses the name in the package.json and not the Nx project name (which is how Lerna currently works). So in this scenario, I'd want the tag to include @org/my-package
and not just my-package
. It seems that the current implementation of "tagPrefix" only allows you to substitute in the Nx project name.
Is it possible to add another interpolation option to "tagPrefix" like "packageName" that would read the value of the target's package.json name?
Hi @ajwootto, in your case you can achieve this using --tagPrefix='@org/${projectName}-'
, I think it's unnecessary to add stuff to consume the name from the package.json as you can already customize the tag prefix. What do you think?
Hi @edbzn , you are correct that with my stated example I could just do that, however I should have mentioned that my Nx project names also do not line up with the published packaged names either. Nx convention seems to be to name things according to the organizational folder structure you put them in, and in my case I have a structure like this:
lib/
shared/
package-1/
package-1/
some-other-namespace
package-3/
With that structure, Nx will name things like shared-package-1
when using the code generators. The --publishable
flag on the generators also makes you set the --importPath
which in my case is just "@org/package-1".
The reason I think this would make sense in the context of publishable packages is that it sort of follows the conventions Nx is already using, where the publicly published name is different than the internal Nx one. I ran into this when trying to use this plugin as a replacement for Lerna to handle package versioning, since Lerna always does things based on the actual public names. Basically if using this tool in the context of publishing NPM packages, it would make more sense to me for the package name to be used as the tag.
Just wanted to bring this up again because I'm doing another re-evaluation of how to version my packages with Nx. Currently using Lerna with a sketchy glue script that feeds it the list of packages that have changed from nx affected
, because lerna itself doesn't understand the Nx project graph.
I went with that approach solely because of this issue, because it's currently not possible to tag the version commits based on the publishable name of the project rather than the internal nx project name.
I think even adding the ability to interpolate a variable like {packageName}
rather than {projectName}
in the tagPrefix option would basically solve for this.