JamieMason / JamieMason/syncpack

feat(semver): enforce specifiers like ^1 or ~1.2

Open
#320 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: Medium Type: Feat
Dominant language
Rust
Stars
2.1k
Forks
72
PR merge metrics
No merged PRs in 30d

Description

### Question

## Context

Currently, when using `semverGroups` with `"range": "^"`, syncpack always produces the full `^x.y.z` format (e.g. `^1.0.0`).
Node-semver also considers `^1` and `^1.2` as valid caret ranges — they're semantically equivalent to `^1.0.0` and `^1.2.0` respectively, but some teams prefer the shorter forms.

## Request

Would it be possible to support a range value like `"^.x"` or similar that formats versions as caret + major only?

For example:
| Current (`"range": "^"`) | Requested |
|---|---|
| `^1.0.0` | `^1` |
| `^2.0.0` | `^2` |

## Use case

For internal monorepo packages where the intent is "any compatible version within this major", the shorter `^1` form communicates that intent more directly, it says "I don't care about a specific minor or patch floor, just keep me on major 1". The full `^1.0.0` can imply a deliberate choice of `1.0.0` as the minimum, when in practice the consumer just wants major-level compatibility.

I'd love your take on whether this is even a good idea.

### Code of Conduct

- [x] I agree to follow the [Code of Conduct](https://github.com/JamieMason/syncpack/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the semverGroups range handling and the tests covering existing "^" formatting. Clarify the configuration syntax and expected behavior for major-only and major-minor forms, then add coverage showing that the selected format is emitted consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.