Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions resources/software.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@
"name": "deno",
"version-command": "--version"
}
},
{
"name": "Bun",
"alias": "bun",
"description": "Incredibly fast JavaScript runtime, bundler, test runner, and package manager - all in one.",
"homepage": "https://bun.com",
"repositories": [
{
"type": "github",
"uri": "oven-sh/bun",
"asset-pattern": "/^bun-(?!.*-profile\\.zip$).*/"
}
],
"binary": {
"name": "bun",
"pattern": "/^bun(?:x)?(?:\\.exe)?$/",
}
}
]
}
4 changes: 2 additions & 2 deletions src/Module/Version/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
class Version implements \Stringable
{
protected const VERSION_SEMVER_PATTERN = 'v?(\d+\.\d+\.\d+(?:\+\d+)?)([-+][\w.-]+)?';
protected const VERSION_FALLBACK_PATTERN = 'v?(\d+(?:\.\d+(?:\.\d+(?:\+\d+)?)?)?)([-+.][\w.-]+)?';
protected const VERSION_SEMVER_PATTERN = '(?:[a-z]+[-_])?v?(\d+\.\d+\.\d+(?:\+\d+)?)([-+][\w.-]+)?';
protected const VERSION_FALLBACK_PATTERN = '(?:[a-z]+[-_])?v?(\d+(?:\.\d+(?:\.\d+(?:\+\d+)?)?)?)([-+.][\w.-]+)?';
protected const VERSION_HASH_SUFFIX_PATTERN = '(?:#([a-f0-9]{6,40}))?';

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/Module/Version/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public static function provideValidVersionStrings(): \Generator
// Case insensitive stability
yield 'version with uppercase stability' => ['1.2.3-BETA', '1.2.3-BETA', '1.2.3', null, Stability::Beta];
yield 'version with mixed case stability' => ['1.2.3-Alpha', '1.2.3-Alpha', '1.2.3', null, Stability::Alpha];

// Versions with a lowercase word prefix, as used in release tags like `bun-v1.4.2`
yield 'prefixed tag with v' => ['bun-v1.4.2', 'bun-v1.4.2', '1.4.2', null, Stability::Stable];
yield 'prefixed tag without v' => ['bun-1.4.2', 'bun-1.4.2', '1.4.2', null, Stability::Stable];
yield 'prefixed tag with underscore separator' => ['tool_1.4.2', 'tool_1.4.2', '1.4.2', null, Stability::Stable];
yield 'prefixed tag with stability suffix' => ['bun-v1.4.2-canary.1', 'bun-v1.4.2-canary.1', '1.4.2', 'canary.1', Stability::Preview];
}

/**
Expand All @@ -65,6 +71,9 @@ public static function provideInvalidVersionStrings(): \Generator
yield 'dev-feature+issue-1' => ['dev-feature+issue-1'];
yield '1.0.0-alpha11+cs-1.1.0' => ['1.0.0-alpha11+cs-1.1.0'];
yield '1.0.0-beta#comment-part' => ['1.0.0-beta#comment-part'];

// Prefixes that must still be rejected: text stuck to the digits without a separator
yield 'text directly before digits' => ['version1.2.3'];
}

/**
Expand Down Expand Up @@ -127,6 +136,8 @@ public static function provideVersionsAndExpectedStability(): \Generator
// Real cases
yield 'real case 2' => ['v1.3.1-nexus-cancellation.0', Stability::Preview, 'Temporal cancellation version'];
yield 'real case 3' => ['v1.3.0', Stability::Stable, 'Stable version'];
yield 'prefixed tag' => ['bun-v1.4.2', Stability::Stable, 'Bun release tag'];
yield 'prefixed tag with canary suffix' => ['bun-v1.4.2-canary.1', Stability::Preview, 'Bun canary tag'];
}

/**
Expand Down
Loading