diff --git a/src/bin/hb-service.ts b/src/bin/hb-service.ts index ec9cc7e93..1c516fc85 100644 --- a/src/bin/hb-service.ts +++ b/src/bin/hb-service.ts @@ -430,7 +430,7 @@ export class HomebridgeServiceHelper { if ( this.homebridgePackage && process.env.UIX_STRICT_PLUGIN_RESOLUTION === '1' && - semver.gtr(this.homebridgePackage.version, '1.4.1-beta.1', { includePrerelease: true }) + semver.satisfies(this.homebridgePackage.version, '1.4.1-beta.1', { includePrerelease: true }) ) { if (!this.homebridgeOpts.includes('--strict-plugin-resolution')) { this.homebridgeOpts.push('--strict-plugin-resolution'); @@ -1093,7 +1093,7 @@ export class HomebridgeServiceHelper { } // check if keep orphans should be enabled, only for Homebridge v1.0.2 and later - if (this.homebridgePackage && semver.gtr(this.homebridgePackage.version, '1.0.2', { includePrerelease: true })) { + if (this.homebridgePackage && semver.satisfies(this.homebridgePackage.version, '1.0.2', { includePrerelease: true })) { if (homebridgeStartupOptions.keepOrphans && !this.homebridgeOpts.includes('-K')) { this.homebridgeOpts.push('-K'); } diff --git a/src/modules/plugins/plugins.service.ts b/src/modules/plugins/plugins.service.ts index 7b1dae551..95e7f146d 100755 --- a/src/modules/plugins/plugins.service.ts +++ b/src/modules/plugins/plugins.service.ts @@ -482,7 +482,7 @@ export class PluginsService { if ( homebridgeVersion.major === 1 && homebridgeVersion.minor === 2 && - semver.gtr(homebridge.installedVersion, homebridge.latestVersion, { includePrerelease: true }) + semver.satisfies(homebridge.installedVersion, homebridge.latestVersion, { includePrerelease: true }) ) { const versions = await this.getAvailablePluginVersions('homebridge'); if (versions.tags['release-1.2.x'] && semver.gt(versions.tags['release-1.2.x'], homebridge.installedVersion)) { @@ -495,10 +495,10 @@ export class PluginsService { // show beta updates if the user is currently running a beta release if ( homebridgeVersion.prerelease[0] === 'beta' && - semver.gtr(homebridge.installedVersion, homebridge.latestVersion, { includePrerelease: true }) + semver.satisfies(homebridge.installedVersion, homebridge.latestVersion, { includePrerelease: true }) ) { const versions = await this.getAvailablePluginVersions('homebridge'); - if (versions.tags['beta'] && semver.gtr(versions.tags['beta'], homebridge.installedVersion, { includePrerelease: true })) { + if (versions.tags['beta'] && semver.satisfies(versions.tags['beta'], homebridge.installedVersion, { includePrerelease: true })) { homebridge.updateAvailable = true; homebridge.latestVersion = versions.tags['beta']; } diff --git a/src/modules/status/status.service.ts b/src/modules/status/status.service.ts index 3eb45f021..46bbce676 100644 --- a/src/modules/status/status.service.ts +++ b/src/modules/status/status.service.ts @@ -286,7 +286,7 @@ export class StatusService { client.emit('homebridge-status', await this.getHomebridgeStats()); // ipc status events are only available in Homebridge 1.3.3 or later - and when running in service mode - if (this.configService.serviceMode && this.configService.homebridgeVersion && semver.gtr(this.configService.homebridgeVersion, '1.3.3-beta.5', { includePrerelease: true })) { + if (this.configService.serviceMode && this.configService.homebridgeVersion && semver.satisfies(this.configService.homebridgeVersion, '1.3.3-beta.5', { includePrerelease: true })) { homebridgeStatusChangeSub = this.homebridgeStatusChange.subscribe(async (status) => { client.emit('homebridge-status', await this.getHomebridgeStats()); }); @@ -332,7 +332,7 @@ export class StatusService { * Check if homebridge is running on the local system */ public async checkHomebridgeStatus() { - if (this.configService.serviceMode && this.configService.homebridgeVersion && semver.gtr(this.configService.homebridgeVersion, '1.3.3-beta.5', { includePrerelease: true })) { + if (this.configService.serviceMode && this.configService.homebridgeVersion && semver.satisfies(this.configService.homebridgeVersion, '1.3.3-beta.5', { includePrerelease: true })) { return this.homebridgeStatus; } diff --git a/ui/src/app/core/manage-plugins/manage-plugins.service.ts b/ui/src/app/core/manage-plugins/manage-plugins.service.ts index fbf186d30..c78806b60 100644 --- a/ui/src/app/core/manage-plugins/manage-plugins.service.ts +++ b/ui/src/app/core/manage-plugins/manage-plugins.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { gtr } from 'semver'; +import { satisfies } from 'semver'; import { ToastrService } from 'ngx-toastr'; import { SettingsService } from '@/app/core/settings.service'; @@ -190,7 +190,7 @@ export class ManagePluginsService { private async checkNodeVersion(plugin): Promise { if (plugin.engines && plugin.engines.node) { - if (gtr(this.$settings.env.nodeVersion, plugin.engines.node, { includePrerelease: true })) { + if (satisfies(this.$settings.env.nodeVersion, plugin.engines.node, { includePrerelease: true })) { return true; } diff --git a/ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts b/ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts index 4381246da..29b77646f 100644 --- a/ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts +++ b/ui/src/app/modules/plugins/plugin-card/plugin-card.component.ts @@ -51,15 +51,15 @@ export class PluginCardComponent implements OnInit { ngOnInit(): void { // check if the homebridge version supports disabled plugins this.canDisablePlugins = this.$settings.env.homebridgeVersion ? - gtr(this.$settings.env.homebridgeVersion, '1.3.0-beta.46', { includePrerelease: true }) : false; + satisfies(this.$settings.env.homebridgeVersion, '1.3.0-beta.46', { includePrerelease: true }) : false; // check if the homebridge version supports external bridges this.canManageBridgeSettings = this.$settings.env.homebridgeVersion ? - gtr(this.$settings.env.homebridgeVersion, '1.3.0-beta.47', { includePrerelease: true }) : false; + satisfies(this.$settings.env.homebridgeVersion, '1.3.0-beta.47', { includePrerelease: true }) : false; // check if the homebridge version supports stopping / starting child bridges this.canStopStartChildBridges = this.$settings.env.homebridgeVersion ? - gtr(this.$settings.env.homebridgeVersion, '1.5.0-beta.1', { includePrerelease: true }) : false; + satisfies(this.$settings.env.homebridgeVersion, '1.5.0-beta.1', { includePrerelease: true }) : false; } @Input() set childBridges(childBridges) { diff --git a/ui/src/app/modules/plugins/plugins.component.ts b/ui/src/app/modules/plugins/plugins.component.ts index e3dc41b0c..9f597c5c8 100644 --- a/ui/src/app/modules/plugins/plugins.component.ts +++ b/ui/src/app/modules/plugins/plugins.component.ts @@ -4,7 +4,7 @@ import { Router, NavigationEnd, ActivatedRoute } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { ToastrService } from 'ngx-toastr'; import { take } from 'rxjs/operators'; -import { gtr } from 'semver'; +import { satisfies } from 'semver'; import { SettingsService } from '@/app/core/settings.service'; import { ApiService } from '@/app/core/api.service'; @@ -133,7 +133,7 @@ export class PluginsComponent implements OnInit, OnDestroy { if ( this.$settings.env.recommendChildBridges && this.$settings.env.serviceMode && - gtr(this.$settings.env.homebridgeVersion, '1.5.0-beta.1', { includePrerelease: true }) && + satisfies(this.$settings.env.homebridgeVersion, '1.5.0-beta.1', { includePrerelease: true }) && schema && schema.pluginType === 'platform' ) { diff --git a/ui/src/app/modules/settings/settings.component.ts b/ui/src/app/modules/settings/settings.component.ts index a0d595b7b..53cc82442 100644 --- a/ui/src/app/modules/settings/settings.component.ts +++ b/ui/src/app/modules/settings/settings.component.ts @@ -120,7 +120,7 @@ export class SettingsComponent implements OnInit { async initNetworkingOptions() { try { const homebridgePackage = await this.$api.get('/status/homebridge-version').toPromise(); - if (semver.gtr(homebridgePackage.installedVersion, '1.3.0-beta.0', { includePrerelease: true })) { + if (semver.satisfies(homebridgePackage.installedVersion, '1.3.0-beta.0', { includePrerelease: true })) { this.showNetworking = true; await this.getNetworkSettings(); } @@ -130,12 +130,12 @@ export class SettingsComponent implements OnInit { this.$settings.env.runningInSynologyPackage || this.$settings.env.runningInPackageMode ); - if (semver.gtr(homebridgePackage.installedVersion, '1.4.0-beta.0', { includePrerelease: true })) { + if (semver.satisfies(homebridgePackage.installedVersion, '1.4.0-beta.0', { includePrerelease: true })) { if (onLinux) { this.showAvahiMdnsOption = true; } } - if (semver.gtr(homebridgePackage.installedVersion, '1.6.0-beta.0', { includePrerelease: true })) { + if (semver.satisfies(homebridgePackage.installedVersion, '1.6.0-beta.0', { includePrerelease: true })) { if (onLinux) { this.showResolvedMdnsOption = true; } diff --git a/ui/src/app/shared/layout/layout.component.ts b/ui/src/app/shared/layout/layout.component.ts index 000329b81..e83308e82 100644 --- a/ui/src/app/shared/layout/layout.component.ts +++ b/ui/src/app/shared/layout/layout.component.ts @@ -2,7 +2,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { ltr } from 'semver'; +import { satisfies } from 'semver'; import { throttleTime } from 'rxjs/operators'; import { environment } from '@/environments/environment'; @@ -123,7 +123,7 @@ export class LayoutComponent implements OnInit { await this.$settings.onSettingsLoaded.toPromise(); } - if (ltr(this.$settings.uiVersion, environment.serverTarget, { includePrerelease: true })) { + if (!satisfies(this.$settings.uiVersion, environment.serverTarget, { includePrerelease: true })) { console.log(`Server restart required. UI Version: ${environment.serverTarget} - Server Version: ${this.$settings.uiVersion} `); const ref = this.$modal.open(ConfirmComponent);