(versions: string[], target: string, preid: string)
| 27 | * Only exact `<target>-<preid>.<N>` versions count — other preids and targets are ignored. |
| 28 | */ |
| 29 | export function extractPrereleaseCounters(versions: string[], target: string, preid: string): number[] { |
| 30 | const counters: number[] = []; |
| 31 | for (const v of versions) { |
| 32 | const parsed = semver.parse(v); |
| 33 | if (!parsed) continue; |
| 34 | if (`${parsed.major}.${parsed.minor}.${parsed.patch}` !== target) continue; |
| 35 | if (parsed.prerelease.length !== 2) continue; |
| 36 | if (parsed.prerelease[0] !== preid) continue; |
| 37 | const n = parsed.prerelease[1]; |
| 38 | if (typeof n === 'number') counters.push(n); |
| 39 | } |
| 40 | return counters; |
| 41 | } |
| 42 | |
| 43 | /** Compute the next prerelease version: `<target>-<preid>.<max existing counter + 1>` */ |
| 44 | export function nextPrereleaseVersion(target: string, preid: string, existingCounters: number[]): string { |
no outgoing calls
no test coverage detected
searching dependent graphs…