jscutlery / semver

Nx plugin to automate semantic versioning and CHANGELOG generation.
MIT License
719 stars 83 forks source link

`{projectName}` interpolation by Nx causes wrong dependencies versions in changelogs #790

Open jsulpis opened 3 months ago

jsulpis commented 3 months ago

Hi, I could not reopen https://github.com/jscutlery/semver/issues/725 but I think the issue is still there, because this interpolation causes wrong dependencies versions in the changelogs:

when setting "tagPrefix": "{projectName}@" in the config file, the versionTagPrefix that comes as argument of the version function is already interpolated as the project name:

https://github.com/jscutlery/semver/blob/885f26d41ad3b388e580f69b7a8071c09488d97d/packages/semver/src/executors/version/index.ts#L240

So all the calls to formatTagPrefix do nothing because the {projectName} has already been interpolated. In particular when searching for the latest version of the dependencies, since the tagPrefix is the one of the parent and not the dependency (as it should be), all dependencies versions get resolved to the one of the parent : https://github.com/jscutlery/semver/blob/885f26d41ad3b388e580f69b7a8071c09488d97d/packages/semver/src/executors/version/utils/try-bump.ts#L332-L346

This causes wrong versions in the changelog: {dependency} updated to version {latest version of parent}.

The easy workaround is to not override the tagPrefix in the config. I guess the fix might not be trivial, if not breaking, but I think at least mentioning the issue in the docs would prevent a few headaches. Thanks !