@@ -132,14 +132,31 @@ function getVersions(format: number, type: PackType = 'resource'): VersionsResul
132132 }
133133 if ( ! format || format > LATEST [ type ] || ( type === 'data' && format < 4 ) ) return output
134134
135+ const getVersionBelow = function ( ver : VersionName , minVer : VersionName ) : VersionName {
136+ const formatVer = ( [ x , y , z ] : Array < string | number > ) => [ x , y , z ] . join ( '.' ) as VersionName
137+ const [ minX , minY , minZ ] = minVer . split ( '.' )
138+ const [ x , y , z ] = ver . split ( '.' )
139+ // (1.X.a) vs 1.X.b
140+ if ( minY === y ) {
141+ if ( z === 'x' ) return formatVer ( [ x , y , z ] )
142+ else return formatVer ( [ x , y , + z - 1 ] )
143+ }
144+ // (1.X.a) vs 1.Y.b
145+ else {
146+ if ( z === 'x' ) return formatVer ( [ x , + y - 1 , z ] )
147+ else return formatVer ( [ x , y , + z - 1 ] )
148+ }
149+ }
150+
135151 // Min and max releases
136152 const startReleases = Object . entries ( START_RELEASES )
137153 const relIndex = startReleases . findIndex ( ( [ , data ] ) => data [ type ] === format )
138154 if ( relIndex >= 0 ) {
139- const minRelease = startReleases [ relIndex ] [ 0 ]
140- const maxRelease = startReleases [ relIndex + 1 ] [ 0 ] . replace ( / \. ( \d + ) \. / , ( _ , major ) => `.${ major - 1 } .` )
141- output . releases . min = minRelease as VersionName
142- output . releases . max = maxRelease as VersionName
155+ const lastWithFormat = startReleases . find ( ( [ , obj ] ) => ( obj [ type ] ?? 0 ) > format ) ?? [ ]
156+ const minRelease = startReleases [ relIndex ] [ 0 ] as VersionName
157+ const maxRelease = getVersionBelow ( lastWithFormat [ 0 ] as VersionName , minRelease )
158+ output . releases . min = minRelease
159+ output . releases . max = maxRelease
143160 }
144161
145162 // Min and max snapshots
0 commit comments