Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lerna version - "%s" does not work in independent mode #185

Closed
Zamiell opened this issue May 29, 2022 · 5 comments · Fixed by #203
Closed

lerna version - "%s" does not work in independent mode #185

Zamiell opened this issue May 29, 2022 · 5 comments · Fixed by #203
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Zamiell
Copy link

Zamiell commented May 29, 2022

Hello and thanks for the software.

This issue is with respect to lerna version.

1) Version in the Commit

Is there a way to put the version in the commit message, in independent mode? I'm aware that the "%s" and "%v" magic strings exist, but those seem to do nothing in independent mode.

2) Package in the Commit

Furthermore, I also want to put the package name of the thing that is being released in the commit message.
Thus, a magic string of "%p" would be a really nice feature and probably easy to add.

3) Conventional Commit Messages

From the source code, it seems that lerna-lite does not use conventional commit messages by default. In 2022, most of the ecosystem has embraced conventional commit messages, and even this repository uses them. Thus, I believe that lerna-lite should produce conventional commit messages by default. Specifically, it just needs to add a "chore:" prefix to the existing default, or something along those lines.

@ghiscoding
Copy link
Member

ghiscoding commented May 29, 2022

Lerna-Lite's code is roughly the same as the original Lerna but Pull Request are welcome if you want to look at adding it. You can try the --git-dry-run mode to see what Git command are to be executed (without executing them). I would also suggest to look at Lerna issues to see if you find anything related to what you describe that is not working in independent mode, I never used that mode myself so I would have to look at the code just the same as you. By the way, conventional commits can simply be enabled via --conventional-commits and even though you and I love it, it doesn't mean that everyone will want it and that is why it was created as an option in Lerna and Lerna-Lite follows the same flags and defaults, so it is disabled by default, just passing an extra flag is easy enough so I don't see that as a problem and I prefer to stay close to what Lerna provides (Lerna-Lite was created as a drop-in replacement to Lerna).

@ghiscoding ghiscoding added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 29, 2022
@Zamiell
Copy link
Author

Zamiell commented May 30, 2022

By the way, conventional commits can simply be enabled via --conventional-commits and even though you and I love it, it doesn't mean that everyone will want it and that is why it was created as an option in Lerna

Correct me if I am wrong, but the --conventional-commits flag doesn't have anything to do with the commit message. It only has to do with finding out what the version should be. Even if you specify the --conventional-commits flag, the commit message still won't be in the conventional commit format, which is a bug as far as I am concerned.

@ghiscoding
Copy link
Member

ghiscoding commented May 30, 2022

hmm what? I'm not sure that I fully understand what you mean, the --conventional-commits flag exists to read commits that follows Conventional Commits and automatically create changelog (and optionally github releasess) following those commits. However commits have to be formatted and follow the Conventional Commits standard and that's to the user's responsibility, I follow the standard in Lerna-Lite and you can see that in Lerna-Lite's releases... Unless you mean other tools like Husky which I never used neither implemented (yet), which does help to enforce conventions, but that's a task to the project author's to implement. The conventional flag also uses conventional-recommended-bump to find which bump to apply (major, minor, patch). The --conventional-commits flag was created by Lerna's author, I didn't create that flag, I didn't choose the name neither choose what it does.

Also as a reminder, I created Lerna-Lite mainly because Lerna wasn't being maintained for more than a year and I also wanted to make it smaller but even then it's mostly all the same code as the original Lerna, it was created to be a drop-in replacement... However I don't fully understand all the entire library, I also mention that in the main readme as well, so if you're asking about changing the library in a big way then I'm sorry to say that it probably will not happen. The only big feature that I added was the workspace: protocol which looked at in a PR but never finished in Lerna itself, but apart from that it's a bit hard for me to add any large features and/or refactoring.

@Zamiell
Copy link
Author

Zamiell commented May 30, 2022

However commits have to be formatted and follow the Conventional Commits standard and that's to the user's responsibility

No. The commit message is created by lerna-lite, not the user. And the commit message that is created does not follow the conventional commit rules.

Try it for yourself and see:

mkdir monorepo
cd monorepo
npm init --yes
git init
echo "node_modules" > .gitignore
npm install @lerna-lite/cli --save-dev
npx lerna init --independent
mkdir packages/foo
touch packages/foo/main.ts
git add -A && git commit -a -m "feat: adding foo"
git remote add origin git@github.com:Zamiell/test3.git
git push --set-upstream origin main

# Somehow get lerna to pick up that something has changed ???
echo "// changes" >> packages/foo/main.ts
git add -A && git commit -a -m "fix: foo"
# This doesn't actually work for some reason, but you get the idea.

npx lerna version --conventional-commits --no-changelog
git log

@ghiscoding
Copy link
Member

ghiscoding commented May 30, 2022

Ok I didn't understand that you were talking about lerna version command commit, I thought you were talking about commits in general. I think you're simply missing the --message option, I always use it to format it with my own message that is following conventional commit, I've set it up in Lerna-Lite's lerna.json

https://github.com/ghiscoding/lerna-lite/blob/adcccdc2bb759efdfdecf6b20e4dd18cb4456e81/lerna.json#L15

and this produced the following message on the last release which follows Contentional Commits

chore(release): publish new version 1.3.0

Anyway, the code is all here, so if you want to some new flag or something, you can create a PR, however make sure that it's not changing regular format. I don't wish to introduce breaking changes even if you don't like the format. I still think using --message is simply what you should use. I'd be more willing to accept a PR for the original question you had about adding %p token

https://github.com/ghiscoding/lerna-lite/blob/adcccdc2bb759efdfdecf6b20e4dd18cb4456e81/packages/version/src/version-command.ts#L689-L711

ghiscoding added a commit that referenced this issue Jun 6, 2022
…-message

fix(version): improve default git publish message, closes #185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants