diff --git a/CHANGELOG.md b/CHANGELOG.md index 13306a9e3..7f809f684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to homebridge-config-ui-x will be documented in this file. +## 4.52.3 (2023-11-14) + +### Bug Fixes + +- Fixes for #1698, update-node failing with npm not found + ## 4.52.2 (2023-11-11) ### Notable Changes diff --git a/package-lock.json b/package-lock.json index 9454d6f2b..a84798742 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-config-ui-x", - "version": "4.52.2", + "version": "4.52.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-config-ui-x", - "version": "4.52.2", + "version": "4.52.3", "funding": [ { "type": "github", diff --git a/package.json b/package.json index 92619586e..1b376a7b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebridge-config-ui-x", "displayName": "Homebridge UI", - "version": "4.52.2", + "version": "4.52.3", "description": "A web based management, configuration and control platform for Homebridge.", "license": "MIT", "author": "oznu ", @@ -161,4 +161,4 @@ "smart home", "hb-service" ] -} +} \ No newline at end of file diff --git a/src/bin/platforms/linux.ts b/src/bin/platforms/linux.ts index adec8d6b8..33e30ef5f 100644 --- a/src/bin/platforms/linux.ts +++ b/src/bin/platforms/linux.ts @@ -616,12 +616,20 @@ export class LinuxInstaller extends BasePlatform { private async createFirewallRules() { // check ufw is present on the system (debian based linux) if (await fs.pathExists('/usr/sbin/ufw')) { - return this.createUfwRules(); + try { + return await this.createUfwRules(); + } catch (err) { + throw err; + } } // check firewall-cmd is present on the system (enterprise linux) if (await fs.pathExists('/usr/bin/firewall-cmd')) { - return this.createFirewallCmdRules(); + try { + return await this.createFirewallCmdRules(); + } catch (err) { + throw err; + } } } diff --git a/src/core/auth/auth.service.ts b/src/core/auth/auth.service.ts index e6a87a9a0..d987d92c6 100644 --- a/src/core/auth/auth.service.ts +++ b/src/core/auth/auth.service.ts @@ -91,7 +91,7 @@ export class AuthService { */ async signIn(username: string, password: string, otp?: string): Promise { const user = await this.authenticate(username, password, otp); - const token = this.jwtService.sign(user); + const token = await this.jwtService.sign(user); return { access_token: token, @@ -130,7 +130,7 @@ export class AuthService { const user = users.find(x => x.admin === true); // generate a token - const token = this.jwtService.sign({ + const token = await this.jwtService.sign({ username: user.username, name: user.name, admin: user.admin, @@ -226,7 +226,7 @@ export class AuthService { } // generate a token - const token = this.jwtService.sign({ + const token = await this.jwtService.sign({ username: 'setup-wizard', name: 'setup-wizard', admin: true, @@ -310,7 +310,11 @@ export class AuthService { */ private async saveUserFile(users: UserDto[]) { // update the auth.json - return fs.writeJsonSync(this.configService.authPath, users, { spaces: 4 }); + try { + return await fs.writeJson(this.configService.authPath, users, { spaces: 4 }); + } catch (err) { + throw err; + } } /** diff --git a/src/core/spa/spa.filter.ts b/src/core/spa/spa.filter.ts index aafd7a887..245076a25 100644 --- a/src/core/spa/spa.filter.ts +++ b/src/core/spa/spa.filter.ts @@ -8,7 +8,6 @@ import { } from '@nestjs/common'; import * as fs from 'fs-extra'; - @Catch(NotFoundException) export class SpaFilter implements ExceptionFilter { catch(_exception: HttpException, host: ArgumentsHost) { diff --git a/src/modules/accessories/accessories.gateway.ts b/src/modules/accessories/accessories.gateway.ts index eb1434515..b9b54fe47 100644 --- a/src/modules/accessories/accessories.gateway.ts +++ b/src/modules/accessories/accessories.gateway.ts @@ -22,7 +22,11 @@ export class AccessoriesGateway { @SubscribeMessage('get-layout') async getAccessoryLayout(client: any, payload: any) { - return this.accessoriesService.getAccessoryLayout(payload.user); + try { + return await this.accessoriesService.getAccessoryLayout(payload.user); + } catch (err) { + throw err; + } } @SubscribeMessage('save-layout') diff --git a/src/modules/backup/backup.controller.ts b/src/modules/backup/backup.controller.ts index 5c0db441c..aaad9d583 100644 --- a/src/modules/backup/backup.controller.ts +++ b/src/modules/backup/backup.controller.ts @@ -105,7 +105,11 @@ export class BackupController { description: 'Logs to stdout / stderr.', }) async restoreBackupTrigger() { - return this.backupService.triggerHeadlessRestore(); + try { + return await this.backupService.triggerHeadlessRestore(); + } catch (err) { + throw err; + } } @UseGuards(AdminGuard) diff --git a/src/modules/backup/backup.service.ts b/src/modules/backup/backup.service.ts index 1d1bd0b6b..2840b23dd 100644 --- a/src/modules/backup/backup.service.ts +++ b/src/modules/backup/backup.service.ts @@ -175,7 +175,11 @@ export class BackupService { } } else { // when not using a custom backup path, just ensure it exists - return fs.ensureDirSync(this.configService.instanceBackupPath); + try { + return await fs.ensureDir(this.configService.instanceBackupPath); + } catch (err) { + throw err; + } } } @@ -337,7 +341,11 @@ export class BackupService { */ async removeRestoreDirectory() { if (this.restoreDirectory) { - return fs.removeSync(this.restoreDirectory); + try { + return await fs.remove(this.restoreDirectory); + } catch (err) { + throw err; + } } } diff --git a/src/modules/config-editor/config-editor.service.ts b/src/modules/config-editor/config-editor.service.ts index 26bbbe1b7..e32616d5e 100644 --- a/src/modules/config-editor/config-editor.service.ts +++ b/src/modules/config-editor/config-editor.service.ts @@ -333,7 +333,11 @@ export class ConfigEditorService { } // read source backup - return fs.readFileSync(requestedBackupPath); + try { + return await fs.readFile(requestedBackupPath); + } catch (err) { + throw err; + } } /** diff --git a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.ts b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.ts index acf611589..36668064f 100644 --- a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.ts +++ b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.ts @@ -20,7 +20,11 @@ export class PluginsSettingsUiController { @ApiOperation({ summary: 'Returns the HTML assets for a plugin\'s custom UI' }) @ApiParam({ name: 'pluginName', type: 'string' }) async serveCustomUiAsset(@Res() reply, @Param('pluginName') pluginName, @Param('*') file, @Query('origin') origin: string, @Query('v') v?: string) { - return this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v); + try { + return await this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v); + } catch (err) { + throw err; + } } } diff --git a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.ts b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.ts index fe62d3b08..d40266e9e 100644 --- a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.ts +++ b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.ts @@ -117,7 +117,11 @@ export class PluginsSettingsUiService { // dev server is only enabled for private plugins return (await this.httpService.get(pluginUi.devServer, { responseType: 'text' }).toPromise()).data; } else { - return fs.readFileSync(path.join(pluginUi.publicPath, 'index.html'), 'utf8'); + try { + return await fs.readFile(path.join(pluginUi.publicPath, 'index.html'), 'utf8'); + } catch (err) { + throw err; + } } } diff --git a/src/modules/plugins/plugins.service.ts b/src/modules/plugins/plugins.service.ts index 920cce846..2d25d7879 100755 --- a/src/modules/plugins/plugins.service.ts +++ b/src/modules/plugins/plugins.service.ts @@ -266,7 +266,11 @@ export class PluginsService { && (query.indexOf('homebridge-') === 0 || this.isScopedPlugin(query)) && !this.searchResultBlacklist.includes(query.toLowerCase()) ) { - return this.searchNpmRegistrySingle(query.toLowerCase()); + try { + return await this.searchNpmRegistrySingle(query.toLowerCase()); + } catch (err) { + throw err; + } } return _.orderBy(result, ['verifiedPlugin'], ['desc']); @@ -455,7 +459,11 @@ export class PluginsService { if (this.configService.ui.homebridgePackagePath) { const pjsonPath = path.join(this.configService.ui.homebridgePackagePath, 'package.json'); if (await fs.pathExists(pjsonPath)) { - return this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath); + try { + return await this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath); + } catch (err) { + throw err; + } } else { this.logger.error(`"homebridgePath" (${this.configService.ui.homebridgePackagePath}) does not exist`); } @@ -724,7 +732,11 @@ export class PluginsService { const schemaPath = path.resolve(plugin.installPath, pluginName, 'config.schema.json'); if (this.miscSchemas[pluginName] && !await fs.pathExists(schemaPath)) { - return fs.readJsonSync(this.miscSchemas[pluginName]); + try { + return await fs.readJson(this.miscSchemas[pluginName]); + } catch (err) { + throw err; + } } let configSchema = await fs.readJson(schemaPath); diff --git a/src/modules/server/server.controller.ts b/src/modules/server/server.controller.ts index c3fe7c271..13586dc01 100644 --- a/src/modules/server/server.controller.ts +++ b/src/modules/server/server.controller.ts @@ -171,4 +171,3 @@ export class ServerController { return this.serverService.setHomebridgeMdnsSetting(body); } } - diff --git a/src/modules/server/server.module.ts b/src/modules/server/server.module.ts index b7ea59b64..155d5491f 100644 --- a/src/modules/server/server.module.ts +++ b/src/modules/server/server.module.ts @@ -30,4 +30,3 @@ import { ServerService } from './server.service'; ] }) export class ServerModule { } - diff --git a/src/modules/server/server.service.ts b/src/modules/server/server.service.ts index 965b0816a..434f41601 100644 --- a/src/modules/server/server.service.ts +++ b/src/modules/server/server.service.ts @@ -7,18 +7,18 @@ import { NotFoundException, ServiceUnavailableException } from '@nestjs/common'; -import {Categories} from '@oznu/hap-client/dist/hap-types'; +import { Categories } from '@oznu/hap-client/dist/hap-types'; import * as bufferShim from 'buffer-shims'; import * as fs from 'fs-extra'; import * as NodeCache from 'node-cache'; import * as si from 'systeminformation'; import * as tcpPortUsed from 'tcp-port-used'; -import {ConfigService, HomebridgeConfig} from '../../core/config/config.service'; -import {HomebridgeIpcService} from '../../core/homebridge-ipc/homebridge-ipc.service'; -import {Logger} from '../../core/logger/logger.service'; -import {AccessoriesService} from '../accessories/accessories.service'; -import {ConfigEditorService} from '../config-editor/config-editor.service'; -import {HomebridgeMdnsSettingDto} from './server.dto'; +import { ConfigService, HomebridgeConfig } from '../../core/config/config.service'; +import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service'; +import { Logger } from '../../core/logger/logger.service'; +import { AccessoriesService } from '../accessories/accessories.service'; +import { ConfigEditorService } from '../config-editor/config-editor.service'; +import { HomebridgeMdnsSettingDto } from './server.dto'; @Injectable() export class ServerService { @@ -108,7 +108,11 @@ export class ServerService { .filter(x => x.match(/AccessoryInfo\.([A-F,a-f0-9]+)\.json/)); return Promise.all(devices.map(async (x) => { - return this.getDevicePairingById(x.split('.')[1]); + try { + return await this.getDevicePairingById(x.split('.')[1]); + } catch (err) { + throw err; + } })); } diff --git a/src/modules/setup-wizard/setup-wizard.controller.ts b/src/modules/setup-wizard/setup-wizard.controller.ts index af49162b5..e87a84af6 100644 --- a/src/modules/setup-wizard/setup-wizard.controller.ts +++ b/src/modules/setup-wizard/setup-wizard.controller.ts @@ -24,7 +24,11 @@ export class SetupWizardController { description: 'This endpoint is not available after the Homebridge setup wizard is complete.', }) async setupFirstUser(@Body() body: UserDto) { - return this.authService.setupFirstUser(body); + try { + return await this.authService.setupFirstUser(body); + } catch (err) { + throw err; + } } @Get('/get-setup-wizard-token') @@ -33,6 +37,10 @@ export class SetupWizardController { description: 'This endpoint is not available after the Homebridge setup wizard is complete.', }) async generateSetupWizardToken() { - return this.authService.generateSetupWizardToken(); + try { + return await this.authService.generateSetupWizardToken(); + } catch (err) { + throw err; + } } } diff --git a/ui/package.json b/ui/package.json index 689a09068..7eb85a8ab 100644 --- a/ui/package.json +++ b/ui/package.json @@ -95,4 +95,4 @@ "marked": "^5.1.2", "rxjs": "7.8.1" } -} +} \ No newline at end of file