Skip to content

Add Composer and Pub version support - #34

Open
andrew wants to merge 1 commit into
mainfrom
codex/composer-pub
Open

Add Composer and Pub version support#34
andrew wants to merge 1 commit into
mainfrom
codex/composer-pub

Conversation

@andrew

@andrew andrew commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Adds native Composer and Pub constraint parsing to ParseNative, with scheme-aware validation, normalization, and version comparison.

Composer support includes caret, tilde, wildcard and hyphen ranges, AND/OR constraints, aliases, stability flags, and Composer’s prerelease boundary rules. It also preserves OR branches containing aliases and accepts shorthand stability suffixes.

Pub support includes any, exact versions, comparator intersections, caret ranges, Pub build ordering, pre-1.0 compatibility rules, and exclusive prerelease upper bounds. README examples and VERS round-trip coverage are included.

Copilot AI 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.

Pull request overview

Adds first-class Composer and Pub support to VERS native parsing and scheme-aware comparison/normalization, expanding ParseNative to understand these ecosystems’ constraint syntaxes and version ordering rules.

Changes:

  • Introduces composer and pub schemes with scheme-specific comparison, validation, and normalization.
  • Adds Composer constraint parsing (OR/AND, caret/tilde/wildcards/hyphens, stability flags, aliases) and Pub constraint parsing (any, caret, comparator intersections, Pub build ordering adjustments).
  • Updates README and adds round-trip/unit tests for Composer/Pub parsing, comparison, and VERS output.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
version.go Adds composer/pub schemes and wires scheme-specific compare functions.
vers.go Documents new supported schemes in ParseNative docs.
README.md Adds usage examples and scheme table entries for Composer and Pub.
parser.go Routes ParseNative to Composer/Pub parsers; includes schemes in version normalization.
normalization.go Adds scheme-aware validation/normalization hooks for Composer/Pub.
composer_pub.go Implements Composer and Pub parsing/validation/normalization/comparison logic.
composer_pub_test.go Adds tests for Composer/Pub parsing behavior, comparisons, normalization, and VERS round-trips.
Suppressed comments (1)

composer_pub_test.go:208

  • Expected VERS output for Pub caret ^0.0.3 uses an upper bound of <0.1.0-0, but Pub caret semantics for 0.0.z are patch-only, so the upper bound should be <0.0.4-0.
		{constraint: "^0.0.3", scheme: schemePub, want: "vers:pub/>=0.0.3|<0.1.0-0"},

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread composer_pub.go
Comment on lines +564 to +580
// parsePubCaretRange expands Pub's compatible-with operator. Pub treats all
// pre-1.0 releases in the same minor series as compatible.
func parsePubCaretRange(version string) (*Range, error) {
parsed, ok := parseSemverValue(version)
if !ok {
return nil, fmt.Errorf("invalid pub caret version: %s", version)
}
var upper string
if cmpNumStr(parsed.core[0], "0") == 0 {
upper = "0." + incNumStr(parsed.core[1]) + ".0-0"
} else {
upper = incNumStr(parsed.core[0]) + ".0.0-0"
}
return rangeWithScheme(NewRange([]Interval{
NewInterval(version, upper, true, false),
}), schemePub), nil
}
Comment thread composer_pub_test.go
{name: "caret excludes next major prerelease", constraint: "^1.2.3", version: "2.0.0-alpha", want: false},
{name: "caret zero includes compatible patch", constraint: "^0.1.2", version: "0.1.9", want: true},
{name: "caret zero excludes next minor", constraint: "^0.1.2", version: "0.2.0", want: false},
{name: "caret zero zero includes later patch", constraint: "^0.0.3", version: "0.0.9", want: true},
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.

2 participants