versionBranches throws when version is set to "independent" in lerna.json
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 221
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When `versionBranches` has a value in `.autorc` and `"version"` is set to `"independent"` in `lerna.json`, the version produced [here](https://github.com/intuit/auto/blob/43dad64aba18628711efdbea06b5581e2a77e276/packages/core/src/auto.ts#L464-L466) is an empty string (from [this ternary](https://github.com/intuit/auto/blob/43dad64aba18628711efdbea06b5581e2a77e276/plugins/npm/src/index.ts#L303-L306)), causing SemVer to throw `TypeError: Invalid Version: `.
**To Reproduce**
- Set `versionBranches` to any string value in your `autorc`.
- Set `"version": "independent"` in your `lerna.json`.
- Run `auto shipit` in ci by merging a PR with the `major` version label to the `baseBranch`.
**Expected behavior**
`shipit` is successful and a branch is created to version the major release.
**Screenshots**
.autorc
```.yml
# only publish/release if a PR has the 'release' label
onlyPublishWithReleaseLabel: true
# when a major version is released, a branch prefixed 'release/' will be created and the release tag created from it
versionBranches: 'release/'
```
lerna.json
```.json
{
"packages": ["core", "hotkeys", "ui", "timestamps"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": "true"
}
```
Stack Trace:
```.txt
info Using monorepo to calculate previous release
ℹ info NPM: Got previous version from package.json
ℹ info Adding new changes to changelog.
ℹ info Old changelog exists, prepending changes.
ℹ info Wrote new changelog to filesystem.
ℹ info Using monorepo to calculate previous release
ℹ info NPM: Got previous version from package.json
TypeError: Invalid Version:
at new SemVer (/home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/node_modules/semver/classes/semver.js:38:13)
at Object.major (/home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/node_modules/semver/functions/major.js:2:29)
at /home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/src/auto.ts:464:59
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
```
**Additional context**
As I linked in the description, [this ternary](https://github.com/intuit/auto/blob/43dad64aba18628711efdbea06b5581e2a77e276/plugins/npm/src/index.ts#L303-L306) seems very suspicious. Why does it produces the package list on new lines in `dryrun` and an empty string otherwise?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.