Skip to content

Commit

Permalink
refactor: make outdated sdk finding simpler (#6587)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Mar 15, 2024
1 parent 06e2c6e commit f45dbc6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib/features/metrics/instance/findOutdatedSdks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down

0 comments on commit f45dbc6

Please sign in to comment.