Skip to content

fix: align caret includePrerelease lower bounds#872

Merged
owlstronaut merged 1 commit into
npm:mainfrom
wayyoungboy:fix-caret-include-prerelease-557
Jun 8, 2026
Merged

fix: align caret includePrerelease lower bounds#872
owlstronaut merged 1 commit into
npm:mainfrom
wayyoungboy:fix-caret-include-prerelease-557

Conversation

@wayyoungboy

Copy link
Copy Markdown
Contributor

Summary

  • keep exact caret lower bounds at the release version when includePrerelease is enabled
  • add regression fixtures for ^0.0.3 and ^0.2.3 prerelease versions matching the existing ^1.0.0 behavior

Root Cause

For exact 0.x caret ranges without an explicit prerelease, replaceCaret appended -0 to the lower bound when includePrerelease was enabled. That turned ^0.0.3 into >=0.0.3-0 <0.0.4-0, allowing 0.0.3-alpha while exact 1.x caret ranges kept >=1.2.3 and rejected 1.2.3-alpha.

Test Plan

  • RED: Node assert script confirmed satisfies('0.0.3-alpha', '^0.0.3', { includePrerelease: true }) returned true before the fix
  • GREEN: Node assert script for 0.0.3-alpha, 0.2.3-alpha, and 1.2.3-alpha all returning false
  • node fixture script covering range include/exclude fixtures: 121 include and 98 exclude cases
  • broader node range verification script: 1348 checks across range parsing, intersects, outside/gtr/ltr, min/max satisfying, and toComparators
  • git diff --check HEAD^ HEAD

Fixes #557

@wayyoungboy wayyoungboy requested a review from a team as a code owner June 6, 2026 21:53

@mbtools mbtools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix! LGTM 👍

@owlstronaut owlstronaut merged commit 046da7f into npm:main Jun 8, 2026
35 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 8, 2026
owlstronaut pushed a commit that referenced this pull request Jun 8, 2026
🤖 I have created a release *beep* *boop*
---


## [7.8.3](v7.8.2...v7.8.3)
(2026-06-08)
### Bug Fixes
*
[`046da7f`](046da7f)
[#872](#872) align caret
includePrerelease lower bounds (#872) (@wayyoungboy)
### Chores
*
[`3485dda`](3485dda)
[#866](#866) bump
@npmcli/eslint-config from 6.0.1 to 7.0.0 (#866) (@dependabot[bot])

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
felipesauer added a commit to felipesauer/mnema that referenced this pull request Jun 19, 2026
…pat fix) (#19)

Integra as 4 PRs abertas do Dependabot (#15, #16, #17, #18) numa única
mudança validada — regenerando o lockfile **uma vez** e rodando o
pipeline completo — para não reintroduzir a corrupção de lockfile dos
merges concorrentes.

## Bumps

| Pacote | De | Para | PR |
|---|---|---|---|
| `@types/node` | 25.9.3 | **26.0.0** (major) | #18 |
| `@inquirer/prompts` | 8.4.2 | 8.5.2 | #16 |
| `semver` | 7.7.4 | 7.8.4 | #16 |
| `@vitest/coverage-v8` + `vitest` | 4.1.5 | 4.1.9 | #17 |
| `actions/checkout` | v6 | v7 (major) | #15 |

## Fix de código necessário (PR #16 estava vermelha)

A #16 quebrava o teste `version-check` — **não** por causa do
`@inquirer/prompts`, mas do bump de `semver`:

- `semver@7.8.3` corrigiu (PR npm/node-semver#872) os "caret
includePrerelease lower bounds".
- Consequência: `0.4.2-alpha.0` **deixou de satisfazer** `^0.4.2` mesmo
com `includePrerelease: true` (uma prerelease sorteia *abaixo* da versão
base). Bisect confirmou: muda exatamente em 7.8.3.
- O `checkVersion` dependia involuntariamente do comportamento bugado
antigo.

Correção em [src/utils/version-check.ts](src/utils/version-check.ts):
além da versão completa, testa também a **versão base coerced**
(`0.4.2`) contra o range — assim um alpha da mesma linha continua
compatível com projetos fixados num range estável. Sem reverter o bump.

## Validação local (pipeline completo do CI, estado limpo)

- ✅ `pnpm install --frozen-lockfile`
- ✅ `pnpm lint` (biome)
- ✅ `pnpm build` (tsc com `@types/node@26` — sem erros de tipo)
- ✅ `pnpm test` — 436/436 (inclui `version-check` 4/4)
- ✅ `pnpm smoke:mcp` — 8/8 tools

## Encaminhamento

Ao mergear esta PR, fecho as 4 PRs do Dependabot (#15#18) com
comentário apontando para cá.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Inconsistent behaviour of caret versions with includePrerelease

3 participants