Skip to content

Commit

Permalink
Merge branch 'beta-4.52.4' into patch-7
Browse files Browse the repository at this point in the history
  • Loading branch information
mkz212 authored Nov 14, 2023
2 parents 2992064 + 2819f2b commit 7ea6d4c
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down Expand Up @@ -161,4 +161,4 @@
"smart home",
"hb-service"
]
}
}
12 changes: 10 additions & 2 deletions src/bin/platforms/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AuthService {
*/
async signIn(username: string, password: string, otp?: string): Promise<any> {
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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/core/spa/spa.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/modules/accessories/accessories.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion src/modules/backup/backup.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/modules/backup/backup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/modules/config-editor/config-editor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ export class ConfigEditorService {
}

// read source backup
return fs.readFileSync(requestedBackupPath);
try {
return await fs.readFile(requestedBackupPath);
} catch (err) {
throw err;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
18 changes: 15 additions & 3 deletions src/modules/plugins/plugins.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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`);
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/modules/server/server.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,3 @@ export class ServerController {
return this.serverService.setHomebridgeMdnsSetting(body);
}
}

1 change: 0 additions & 1 deletion src/modules/server/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ import { ServerService } from './server.service';
]
})
export class ServerModule { }

20 changes: 12 additions & 8 deletions src/modules/server/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}));
}

Expand Down
12 changes: 10 additions & 2 deletions src/modules/setup-wizard/setup-wizard.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@
"marked": "^5.1.2",
"rxjs": "7.8.1"
}
}
}

0 comments on commit 7ea6d4c

Please sign in to comment.