1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

refactor: make outdated sdk finding simpler (#6587)

This commit is contained in:
Mateusz Kwasniewski 2024-03-15 15:38:57 +01:00 committed by GitHub
parent 06e2c6e514
commit f45dbc647e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,16 +14,15 @@ const config: SDKConfig = {
'unleash-client-php': '2.3.0',
};
export const isOutdatedSdk = (sdkVersion: string | null) => {
if (sdkVersion == null) return false;
const result = sdkVersion.split(':');
if (result.length !== 2) return false;
const [sdkName, version] = result;
export const isOutdatedSdk = (sdkVersion: string | null): boolean => {
if (!sdkVersion) return false;
const [sdkName, version] = sdkVersion.split(':');
const minVersion = config[sdkName];
if (!minVersion) return false;
if (!semver.valid(version)) return false;
if (semver.lt(version, minVersion)) return true;
return false;
return Boolean(
minVersion && semver.valid(version) && semver.lt(version, minVersion),
);
};
export function findOutdatedSDKs(sdkVersions: (string | null)[]): string[] {