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

fix: local dependencies correct bump from release to prerelease #34

Merged
merged 19 commits into from
Jan 5, 2021
Merged

fix: local dependencies correct bump from release to prerelease #34

merged 19 commits into from
Jan 5, 2021

Conversation

davikawasaki
Copy link
Contributor

Fixes bug #27. Tried to cover most of edge cases I've imagined, reusing code from semantic-release repository.

@antongolub
Copy link
Member

antongolub commented Jan 4, 2021

@davikawasaki,

Wow! Outstanding improvement! But I need some time to sober up and be ready for review (10-12 hours). I'll take a look next morning.

CC @oljekechoro, @pismenskiy

@davikawasaki
Copy link
Contributor Author

@antongolub np. Fixing the code complexity rn.

lib/git.js Outdated
let isSubstrInside = true;
l.forEach((f) => {
if (!str.includes(f)) isSubstrInside = false;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Could be shortened with find.
  2. lfilters
const matchToAny = (tag, filters) => !!filters.find(v => tag.includes(v))


return lastVersion ? semver.inc(lastVersion, "prerelease", pkg._preRelease) : `1.0.0-${pkg._preRelease}.1`;
if (pkg.name) tagFilters.push(pkg.name);
if (!tags || !tags.length) tags = getTags(pkg._branch || "master", { cwd: "." }, tagFilters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fallback value necessary for pkg._branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need. Removing it.

lib/utils.js Outdated
* @internal
*/
function tagsToVersions(tags) {
if (!tags) tags = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "fail fast"?

if (!tags) {
  return []
}

lib/utils.js Outdated
* @returns {string|undefined} Highest or lowest version.
* @internal
*/
function getHighestLowest(version1, version2, type = 1) {
Copy link
Member

@antongolub antongolub Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confusing to me. Let's separate?

const selectVersionBy = (predicate, version1, version2) => {

if (predicate && version1 && version2) {
   return predicate(version1, version2) ? version1 : version2
}

return version1 || version2
}

const getHighestVersion = selectVersionBy.bind(null, gt)
const getLowestVersion = selectVersionBy.bind(null, lt)

Copy link
Member

@antongolub antongolub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davikawasaki,

LGTM. I'm going to merge. If everything is ok, once again I ask you to push these changes to the parent repo so that I don't have to "steal" your PR ))

@antongolub antongolub merged commit 6481a59 into qiwi:master Jan 5, 2021
qiwibot added a commit that referenced this pull request Jan 5, 2021
## [3.12.2](v3.12.1...v3.12.2) (2021-01-05)

### Bug Fixes

* local dependencies correct bump from release to prerelease ([#34](#34)) ([6481a59](6481a59))
@qiwibot
Copy link
Member

qiwibot commented Jan 5, 2021

🎉 This PR is included in version 3.12.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@davikawasaki
Copy link
Contributor Author

@antongolub great. I'll just add a PR refactor to reduce code complexity in a bit.

prisis referenced this pull request in anolilab/semantic-release Sep 28, 2023
### ⚠ BREAKING CHANGES

* semantic-release/semantic-release@v19.0.5...v21.0.5
* drop support for cycled monorepos
* require Node.js v12
* sequentialPrepare is set to true, to disable pass `--no-sequential-prepare` option
* semrel npm plugin calls local npm version semantic-release/npm#445
* **engine:** the latest semantic-release requires Node.js 10.18
* drop nodejs v8

### Features

* add --tag-version-format flag ([259864c](259864c))
* add debugger ([d2c090d](d2c090d))
* add dependencies updating controller ([0c9b040](0c9b040))
* add execa queued hook ([042933e](042933e))
* add execasync CLI flag to make execa calls be always synchronous ([693438c](693438c)), closes [#1](#1)
* add meow as cli provider ([6de93b9](6de93b9))
* add pnpm and bolt support ([91465de](91465de))
* add process.spawn arg watcher ([7699b6f](7699b6f))
* add sequential-init flag to avoid hypothetical concurrent initialization collisions ([348678e](348678e))
* add some debug messages ([ec792e1](ec792e1))
* added declarative config support ([c98ff10](c98ff10))
* allow to run prepare steps sequentially ([299748a](299748a))
* apply --first-parent filter to commits ([14a896b](14a896b))
* apply queuefy to plugin methods instead of execa ([9ae7d0d](9ae7d0d))
* bump semrel to v19 ([e6b8acb](e6b8acb))
* check that sequentialPrepare is not enabled on cyclic projects ([68c1198](68c1198))
* **debug:** attach pkg prefixes to debug notes ([25e111f](25e111f))
* **debug:** log manifest deps changes ([88b4077](88b4077)), closes [#27](#27)
* **debug:** print passed cli flags ([d720cd7](d720cd7))
* drop nodejs v8 support ([80f0a24](80f0a24))
* enable `sequentialPrepare` flag by default ([ad7e81f](ad7e81f))
* enable first-parent commits filtering by cli flag ([33306cc](33306cc))
* **engine:** up nodejs version ([10af385](10af385))
* handle .cjs configs ([38f657a](38f657a))
* ignore packages to be released with workspaces and CLI ([#42](#42)) ([b98e181](b98e181))
* Initial commit ([942ef94](942ef94))
* introduce `deps.prefix` flag to inject carets ([c3f4529](c3f4529))
* introduce `ignorePrivate` flag ([e4891c9](e4891c9)), closes [#66](#66)
* introduce `log-level` config option ([3fb6584](3fb6584))
* introduce a silent mode([#88](#88)) ([47a27d8](47a27d8))
* let publish step run in parallel ([4d5c451](4d5c451))
* log filtered commits in debug ([c64b8e1](c64b8e1))
* log manifest path ([db451e8](db451e8))
* new updated version of the multi-semantic-release lib ([54be8b7](54be8b7))
* prefer nested CLI flags ([1bf08cc](1bf08cc))
* provide pre-release flow ([6a9ce16](6a9ce16)), closes [#25](#25)
* replace synchronizer with @semrel-extra/topo ([ddd1032](ddd1032))
* support `${version}+${name}` tag format ([c53fefb](c53fefb)), closes [#71](#71)
* support `release.config.cjs` ([a6b9370](a6b9370))
* support workspace.packages notation ([4a606b2](4a606b2))
* tech release ([828a82d](828a82d))
* update semver from v19 to v21 ([6e4c378](6e4c378))
* uphold the prev package.json indents ([ac5832f](ac5832f))

### Bug Fixes

* add flag to enable sequentialPrepare mode ([70c2dc5](70c2dc5))
* add sync point for publish step ([adc823e](adc823e))
* allow any `todo` package to run the `generateNotes` queue ([26a87d7](26a87d7)), closes [#9](#9)
* apply deps update before npm's plugin prepare ([77b6ee2](77b6ee2))
* avoid non-updated local dependencies bump ([#33](#33)) ([9faeef6](9faeef6))
* beautify log labels ([78cbc8a](78cbc8a))
* bump-up of pre-version  ([02ef270](02ef270))
* **cli:** fix inner spawnhook call ([70aa292](70aa292))
* **cli:** restore watchspawn context ([56145aa](56145aa))
* **config:** fix `options` and `plugins` resolver ([56e974c](56e974c))
* correct global config use ([8e5fb99](8e5fb99))
* dont fetch tags if tags arg is empty array ([3a79558](3a79558))
* ensure msr cli flags take precedence over their semrel equivalents ([2be75fa](2be75fa))
* filter only tags that are valid ([59b61ad](59b61ad))
* filter queued packages on generateNotes stage ([e0625ce](e0625ce)), closes [#6](#6)
* fix cascade bumping when some dep belongs to several levels of the dep tree ([cf20dea](cf20dea))
* fix debug logging ([71527b2](71527b2))
* fix export point ([cf31425](cf31425))
* fix getNextVersion resolver ([7275ae7](7275ae7))
* fix globbing on Windows ([#57](#57)) ([1d71d21](1d71d21))
* fix internal flag ref filterParent → firstParent ([8c7400f](8c7400f))
* fix logger path ([232d2dc](232d2dc))
* fix nextType resolver ([606914b](606914b))
* fix pkgOptions resolver ([2a2f0cf](2a2f0cf))
* force a release ([1e3ece5](1e3ece5))
* getVersionFromTag tests to fix release process ([e7f1646](e7f1646))
* local dependencies correct bump from release to prerelease ([#34](#34)) ([6481a59](6481a59))
* make logger to be singleton ([1790794](1790794))
* missing @ in tagFormat ([3faa0f1](3faa0f1))
* more robust stream rescoping (to fix bug in npm module) ([34c7c62](34c7c62))
* override env.TRAVIS_PULL_REQUEST_BRANCH to fix PR checks on travis-ci ([e4b1929](e4b1929)), closes [#11](#11)
* **package:** add missed sem-rel plugins ([f3c9318](f3c9318))
* **package:** up deps, fix some vuls ([d8905b0](d8905b0))
* **package:** up deps, fix vulns ([5a4d91e](5a4d91e))
* **package:** update execa to be compatible with sem-rel 15.13.28 ([069bb4e](069bb4e)), closes [#7](#7)
* pass stderr and stdout into semantic's getConfig (bug in npm) ([cf596cb](cf596cb))
* pin npm as peer dep ([67d8b80](67d8b80))
* pin npm version to v8.4.1 ([22c89d1](22c89d1)), closes [#60](#60)
* preserve trailing whitespace in manifest ([06426ec](06426ec))
* print queued pkg count instead of total ([d893a7f](d893a7f))
* process optional deps during manifest update ([4b7066c](4b7066c))
* provide partial release ([898998a](898998a))
* publish updated deps ([791f55a](791f55a)), closes [#1](#1)
* rm npm from peer deps ([307e505](307e505))
* **sequential-prepare:** do not wait forever when a child package has no change ([713046a](713046a))
* specify used but forgotten dependencies ([73def7f](73def7f))
* sync pkg version after running the npm plugin ([1d24e45](1d24e45))
* trigger next pkg `prepare` after the prev `publish` ([f74d185](f74d185))
* try to prevent deps update rollback ([9108350](9108350))
* up deps, fix some vuls ([2d5cf86](2d5cf86))
* update deps, fix some vuls ([f3cafc8](f3cafc8))
* update manifest version before npm plugin prepare step ([a1ae4c3](a1ae4c3)), closes [#58](#58)
* **update-deps:** properly resolve next pre-versions ([62b348e](62b348e))
* wrong context.commits when have multiple releases commit ([f82f125](f82f125))

### Performance Improvements

* deps revision ([4f62817](4f62817))
* log improvements ([c45dccc](c45dccc))
* log multi-sem-rel flags ([75389e0](75389e0))
* log yarn paths ([3896d5c](3896d5c))
* **package:** up deps ([506a0e8](506a0e8))
* **package:** up deps ([6b903a7](6b903a7))
* **package:** up deps & tech release ([bf00b41](bf00b41))
* refactor nextPreVersion to reduce cognitive complexity ([#35](#35)) ([601bbd3](601bbd3))
* straighten plugins execution pipeline ([e57fe2f](e57fe2f)), closes [#4](#4)
* up deps ([f9e0c8a](f9e0c8a))
* up deps, minor code improvements ([a7aa625](a7aa625))
* various synchronizer optimizations ([87a7602](87a7602))

### Code Refactoring

* move to ESM ([99fffa9](99fffa9))
prisis referenced this pull request in anolilab/semantic-release Sep 28, 2023
### ⚠ BREAKING CHANGES

* semantic-release/semantic-release@v19.0.5...v21.0.5
* drop support for cycled monorepos
* require Node.js v12
* sequentialPrepare is set to true, to disable pass `--no-sequential-prepare` option
* semrel npm plugin calls local npm version semantic-release/npm#445
* **engine:** the latest semantic-release requires Node.js 10.18
* drop nodejs v8

### Features

* add --tag-version-format flag ([259864c](259864c))
* add debugger ([d2c090d](d2c090d))
* add dependencies updating controller ([0c9b040](0c9b040))
* add execa queued hook ([042933e](042933e))
* add execasync CLI flag to make execa calls be always synchronous ([693438c](693438c)), closes [#1](#1)
* add meow as cli provider ([6de93b9](6de93b9))
* add pnpm and bolt support ([91465de](91465de))
* add process.spawn arg watcher ([7699b6f](7699b6f))
* add sequential-init flag to avoid hypothetical concurrent initialization collisions ([348678e](348678e))
* add some debug messages ([ec792e1](ec792e1))
* added declarative config support ([c98ff10](c98ff10))
* allow to run prepare steps sequentially ([299748a](299748a))
* apply --first-parent filter to commits ([14a896b](14a896b))
* apply queuefy to plugin methods instead of execa ([9ae7d0d](9ae7d0d))
* bump semrel to v19 ([e6b8acb](e6b8acb))
* check that sequentialPrepare is not enabled on cyclic projects ([68c1198](68c1198))
* **debug:** attach pkg prefixes to debug notes ([25e111f](25e111f))
* **debug:** log manifest deps changes ([88b4077](88b4077)), closes [#27](#27)
* **debug:** print passed cli flags ([d720cd7](d720cd7))
* drop nodejs v8 support ([80f0a24](80f0a24))
* enable `sequentialPrepare` flag by default ([ad7e81f](ad7e81f))
* enable first-parent commits filtering by cli flag ([33306cc](33306cc))
* **engine:** up nodejs version ([10af385](10af385))
* handle .cjs configs ([38f657a](38f657a))
* ignore packages to be released with workspaces and CLI ([#42](#42)) ([b98e181](b98e181))
* Initial commit ([942ef94](942ef94))
* introduce `deps.prefix` flag to inject carets ([c3f4529](c3f4529))
* introduce `ignorePrivate` flag ([e4891c9](e4891c9)), closes [#66](#66)
* introduce `log-level` config option ([3fb6584](3fb6584))
* introduce a silent mode([#88](#88)) ([47a27d8](47a27d8))
* let publish step run in parallel ([4d5c451](4d5c451))
* log filtered commits in debug ([c64b8e1](c64b8e1))
* log manifest path ([db451e8](db451e8))
* new updated version of the multi-semantic-release lib ([8bdc8be](8bdc8be))
* prefer nested CLI flags ([1bf08cc](1bf08cc))
* provide pre-release flow ([6a9ce16](6a9ce16)), closes [#25](#25)
* replace synchronizer with @semrel-extra/topo ([ddd1032](ddd1032))
* support `${version}+${name}` tag format ([c53fefb](c53fefb)), closes [#71](#71)
* support `release.config.cjs` ([a6b9370](a6b9370))
* support workspace.packages notation ([4a606b2](4a606b2))
* tech release ([828a82d](828a82d))
* update semver from v19 to v21 ([6e4c378](6e4c378))
* uphold the prev package.json indents ([ac5832f](ac5832f))

### Bug Fixes

* add flag to enable sequentialPrepare mode ([70c2dc5](70c2dc5))
* add sync point for publish step ([adc823e](adc823e))
* added missing publishConfig ([f00ea9a](f00ea9a))
* allow any `todo` package to run the `generateNotes` queue ([26a87d7](26a87d7)), closes [#9](#9)
* apply deps update before npm's plugin prepare ([77b6ee2](77b6ee2))
* avoid non-updated local dependencies bump ([#33](#33)) ([9faeef6](9faeef6))
* beautify log labels ([78cbc8a](78cbc8a))
* bump-up of pre-version  ([02ef270](02ef270))
* **cli:** fix inner spawnhook call ([70aa292](70aa292))
* **cli:** restore watchspawn context ([56145aa](56145aa))
* **config:** fix `options` and `plugins` resolver ([56e974c](56e974c))
* correct global config use ([8e5fb99](8e5fb99))
* dont fetch tags if tags arg is empty array ([3a79558](3a79558))
* ensure msr cli flags take precedence over their semrel equivalents ([2be75fa](2be75fa))
* filter only tags that are valid ([59b61ad](59b61ad))
* filter queued packages on generateNotes stage ([e0625ce](e0625ce)), closes [#6](#6)
* fix cascade bumping when some dep belongs to several levels of the dep tree ([cf20dea](cf20dea))
* fix debug logging ([71527b2](71527b2))
* fix export point ([cf31425](cf31425))
* fix getNextVersion resolver ([7275ae7](7275ae7))
* fix globbing on Windows ([#57](#57)) ([1d71d21](1d71d21))
* fix internal flag ref filterParent → firstParent ([8c7400f](8c7400f))
* fix logger path ([232d2dc](232d2dc))
* fix nextType resolver ([606914b](606914b))
* fix pkgOptions resolver ([2a2f0cf](2a2f0cf))
* force a release ([1e3ece5](1e3ece5))
* getVersionFromTag tests to fix release process ([e7f1646](e7f1646))
* local dependencies correct bump from release to prerelease ([#34](#34)) ([6481a59](6481a59))
* make logger to be singleton ([1790794](1790794))
* missing @ in tagFormat ([3faa0f1](3faa0f1))
* more robust stream rescoping (to fix bug in npm module) ([34c7c62](34c7c62))
* override env.TRAVIS_PULL_REQUEST_BRANCH to fix PR checks on travis-ci ([e4b1929](e4b1929)), closes [#11](#11)
* **package:** add missed sem-rel plugins ([f3c9318](f3c9318))
* **package:** up deps, fix some vuls ([d8905b0](d8905b0))
* **package:** up deps, fix vulns ([5a4d91e](5a4d91e))
* **package:** update execa to be compatible with sem-rel 15.13.28 ([069bb4e](069bb4e)), closes [#7](#7)
* pass stderr and stdout into semantic's getConfig (bug in npm) ([cf596cb](cf596cb))
* pin npm as peer dep ([67d8b80](67d8b80))
* pin npm version to v8.4.1 ([22c89d1](22c89d1)), closes [#60](#60)
* preserve trailing whitespace in manifest ([06426ec](06426ec))
* print queued pkg count instead of total ([d893a7f](d893a7f))
* process optional deps during manifest update ([4b7066c](4b7066c))
* provide partial release ([898998a](898998a))
* publish updated deps ([791f55a](791f55a)), closes [#1](#1)
* rm npm from peer deps ([307e505](307e505))
* **sequential-prepare:** do not wait forever when a child package has no change ([713046a](713046a))
* specify used but forgotten dependencies ([73def7f](73def7f))
* sync pkg version after running the npm plugin ([1d24e45](1d24e45))
* trigger next pkg `prepare` after the prev `publish` ([f74d185](f74d185))
* try to prevent deps update rollback ([9108350](9108350))
* up deps, fix some vuls ([2d5cf86](2d5cf86))
* update deps, fix some vuls ([f3cafc8](f3cafc8))
* update manifest version before npm plugin prepare step ([a1ae4c3](a1ae4c3)), closes [#58](#58)
* **update-deps:** properly resolve next pre-versions ([62b348e](62b348e))
* wrong context.commits when have multiple releases commit ([f82f125](f82f125))

### Performance Improvements

* deps revision ([4f62817](4f62817))
* log improvements ([c45dccc](c45dccc))
* log multi-sem-rel flags ([75389e0](75389e0))
* log yarn paths ([3896d5c](3896d5c))
* **package:** up deps ([506a0e8](506a0e8))
* **package:** up deps ([6b903a7](6b903a7))
* **package:** up deps & tech release ([bf00b41](bf00b41))
* refactor nextPreVersion to reduce cognitive complexity ([#35](#35)) ([601bbd3](601bbd3))
* straighten plugins execution pipeline ([e57fe2f](e57fe2f)), closes [#4](#4)
* up deps ([f9e0c8a](f9e0c8a))
* up deps, minor code improvements ([a7aa625](a7aa625))
* various synchronizer optimizations ([87a7602](87a7602))

### Code Refactoring

* move to ESM ([99fffa9](99fffa9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants