Skip to content

fix: order versions before applying limit - #67

Merged
oritwoen merged 1 commit into
mainfrom
fix/versions-limit-order
Aug 15, 2026
Merged

fix: order versions before applying limit#67
oritwoen merged 1 commit into
mainfrom
fix/versions-limit-order

Conversation

@oritwoen

@oritwoen oritwoen commented Aug 15, 2026

Copy link
Copy Markdown
Member

Sorts registry versions by publishedAt before applying --limit, so npm no longer returns the oldest releases. Versions without publication dates stay at the end in adapter order.

Closes #63

Review in cubic

@oritwoen oritwoen self-assigned this Aug 15, 2026
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e1dc176e-d45b-4923-833a-1c39948aca4a

📥 Commits

Reviewing files that changed from the base of the PR and between 199d762 and 54edd6d.

📒 Files selected for processing (2)
  • src/commands/versions.ts
  • test/unit/versions-command.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (3)
src/commands/versions.ts (2)

3-14: LGTM!


40-46: LGTM!

test/unit/versions-command.test.ts (1)

1-45: LGTM!


📝 Walkthrough

Walkthrough

The versions command now sorts versions by publication date before applying --limit. Undated versions appear after dated versions. The exported selectRecentVersions helper is covered by unit tests for ordering, limiting, and input preservation.

Changes

Recent version selection

Layer / File(s) Summary
Selection helper and validation
src/commands/versions.ts, test/unit/versions-command.test.ts
selectRecentVersions sorts dated versions newest-first, places undated versions last, applies the limit, and does not mutate the input array. Unit tests cover these behaviors.
Command output integration
src/commands/versions.ts
JSON and formatted output now use the selected recent versions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 54edd

This localized change reorders versions before applying the limit; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

I’m a rabbit with versions in line,
Newest releases now clearly shine.
Undated ones wait at the rear,
Limits select what should appear.
Hop, test, and ship—everything’s fine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes ordering versions before applying the limit, which is the primary change.
Description check ✅ Passed The description accurately explains recency sorting, limit application, undated-version handling, and the linked issue.
Linked Issues check ✅ Passed The implementation sorts versions by publication date, places undated versions last, then applies the limit as required by issue #63.
Out of Scope Changes check ✅ Passed The changes are limited to the version-selection helper and focused unit tests required by issue #63.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/versions-limit-order

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant CLI as CLI Entry
    participant Cmd as versions Command
    participant Selector as selectRecentVersions
    participant Registry as Registry Adapter
    participant Output as Console Output

    Note over CLI,Output: Registry Version Listing Flow (Current State)

    CLI->>Cmd: Run versions command
    Cmd->>Cmd: Parse args (--limit, --json)
    Cmd->>Registry: fetchVersions(name)
    Registry-->>Cmd: Version[] (adapter order)
    
    Note over Cmd,Selector: Version Sorting & Limiting
    Cmd->>Selector: selectRecentVersions(versions, limit)
    Selector->>Selector: Sort by publishedAt (descending)
    Selector->>Selector: Null dates moved to end
    Selector->>Selector: Slice to limit
    Selector-->>Cmd: Recent versions

    alt JSON output mode
        Cmd->>Output: JSON.stringify(shown)
    else Table output mode
        Cmd->>Output: Format table with counts
    end
    Output-->>CLI: Display results
Loading

Auto-approved: Fixes incorrect version selection by sorting by publishedAt before applying the limit, keeping undated versions last; the added test pins the corrected ordering.

Re-trigger cubic

@oritwoen
oritwoen merged commit 9a4514e into main Aug 15, 2026
3 checks passed
@oritwoen
oritwoen deleted the fix/versions-limit-order branch August 15, 2026 14:01
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.

versions applies --limit before ordering versions by recency

1 participant