Skip to content

Commit

Permalink
try fix semver types
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Sep 30, 2023
1 parent 4dd62a8 commit 29d7020
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/bin/hb-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/plugins/plugins.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/status/status.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/core/manage-plugins/manage-plugins.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -190,7 +190,7 @@ export class ManagePluginsService {

private async checkNodeVersion(plugin): Promise<boolean> {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/modules/plugins/plugins.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'
) {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/modules/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 29d7020

Please sign in to comment.