Skip to content

feat(js-rattler): export MatchSpec and BuildNumberSpec#2164

Open
ayushman1210 wants to merge 4 commits intoconda:mainfrom
ayushman1210:fix/1142
Open

feat(js-rattler): export MatchSpec and BuildNumberSpec#2164
ayushman1210 wants to merge 4 commits intoconda:mainfrom
ayushman1210:fix/1142

Conversation

@ayushman1210
Copy link
Contributor

@ayushman1210 ayushman1210 commented Mar 5, 2026

Description

This PR adds MatchSpec bindings to js-rattler, exposing the conda match specification type to JavaScript/TypeScript consumers of the WASM package.

Key Features:

  • Idiomatic JS API: Implemented a MatchSpec.fromOptions() static method and full getters/setters for all
  • MatchSpec fields, making it easy to create and modify specs programmatically.
  • WASM Compatibility Fix: Fixed a panic in the core rattler-conda-types parser where std::env::current_dir() was called unconditionally. It now falls back to / in environments where filesystem access is restricted (e.g., browsers).
  • Match Support: Exposed .matches(packageRecord) to allow checking if a PackageRecord satisfies a specification.
  • BuildNumberSpec: Proper wrapper type for build number constraints.

Code Example

import { MatchSpec, PackageRecord } from "@conda-org/rattler";

// Create from string
const spec = new MatchSpec("python >=3.10");

// Or create from options
const specFromOptions = MatchSpec.fromOptions({
    name: "python",
    version: ">=3.10",
    build: "py310*"
});

// Check if a record matches
const isMatch = spec.matches(packageRecord);

Fixes #1142

How Has This Been Tested?

I have added a comprehensive test suite in js-rattler/src/MatchSpec.test.ts covering parsing, options-based construction, mutations via setters, and matching logic.

AI Disclosure

  • [ ✅] This PR contains AI-generated content.
    • [ ✅] I have tested any AI-generated content in my PR.
    • [ ✅] I take responsibility for any AI-generated content in my PR.
      Tools: {e.g. GitHub Copilot, ChatGPT, etc.}

Checklist:

  • [✅] I have performed a self-review of my own code
  • [ ✅] I have commented my code, particularly in hard-to-understand areas
  • [ ✅] I have made corresponding changes to the documentation
  • [ ✅] I have added sufficient tests to cover my changes.

@ayushman1210
Copy link
Contributor Author

ayushman1210 commented Mar 5, 2026

hey @baszalmstra please review this pr when you have some free time
thanks !!

@baszalmstra
Copy link
Collaborator

baszalmstra commented Mar 5, 2026

This includes changes from another PR.

I have performed a self-review of my own code

Clearly not, or you would have caught this.

This is also a duplicate of #2146

@ayushman1210
Copy link
Contributor Author

@baszalmstra Thanks for the feedback.
I have removed the changes from other branch and updated the pr .I noticed #2146 earlier, but since there had been no activity on it for some time, I went ahead and attempted an implementation. I agree that this overlaps with that PR.
If you'd prefer, I can close this PR or coordinate with the author of #2146. Please let me know what would be best for the project.

@baszalmstra
Copy link
Collaborator

Yes please coordinate, its only open for 6 days which is not a long time

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.

export MatchSpec in js-rattler

2 participants