Skip to content

Commit

Permalink
Merge branch 'beta-4.52.2' into child-bridge-start-stop-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
mkz212 committed Nov 9, 2023
2 parents 4abed9e + 2fc09ca commit 02b4f42
Show file tree
Hide file tree
Showing 112 changed files with 1,701 additions and 907 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to homebridge-config-ui-x will be documented in this file.

## Beta-4.52.2 (2023-11-XX)

### Notable Changes

- Prevent the UI from updating when running an unsupported version of Node.js
- This mimics the behaviour of updating Homebridge itself
- The option of 'Update Anyway' will still appear for other plugins when running an unsupported version of Node.js

### Other Changes

- **i18n:** Update pl.json ([1633](https://github.com/homebridge/homebridge-config-ui-x/pull/1633))
- **i18n:** Update fr.json ([1629](https://github.com/homebridge/homebridge-config-ui-x/pull/1629))
- **i18n:** Update es.json (Improves Spanish localization) ([1632](https://github.com/homebridge/homebridge-config-ui-x/pull/1632))
- Updated dependencies, including `@homebridge/node-pty-prebuilt-multiarch` to `0.11.10`

## 4.52.1 (2023-11-04)

### Other Changes
Expand Down
2 changes: 1 addition & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"pluginAlias": "config",
"pluginType": "platform",
"singular": true,
"footerDisplay": "[REST API Documentation <i class='fas fa-external-link-alt'></i>](/swagger)",
"footerDisplay": "[REST API Documentation <i class='fas fa-fw fa-external-link-alt'></i>](/swagger)",
"schema": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
],
"exec": "sleep 2 && UIX_INSECURE_MODE=1 UIX_SERVICE_MODE=1 HOMEBRIDGE_CONFIG_UI_TERMINAL=1 ts-node -r tsconfig-paths/register src/bin/hb-service.ts run --stdout",
"signal": "SIGTERM"
}
}
473 changes: 308 additions & 165 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 19 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"start": "ts-node -r tsconfig-paths/register src/main.ts",
"serve": "npm run watch",
"lint": "npm run lint:server && npm run lint:ui",
"lint:server": "eslint \"{src,test}/**/*.ts\" --max-warnings=0 --fix",
"lint:ui": "npm run lint --prefix ui --fix",
"lint:server": "eslint \"{src,test}/**/*.ts\" --max-warnings=0",
"lint:ui": "npm run lint --prefix ui",
"webpack": "webpack --config webpack.config.js",
"install:ui": "npm install --prefix ui",
"test": "jest --forceExit --detectOpenHandles --verbose=true --silent --config ./test/jest-e2e.json",
Expand All @@ -56,25 +56,25 @@
"@fastify/multipart": "8.0.0",
"@fastify/static": "6.12.0",
"@fastify/swagger": "8.12.0",
"@homebridge/node-pty-prebuilt-multiarch": "0.11.8",
"@homebridge/node-pty-prebuilt-multiarch": "0.11.10",
"@nestjs/axios": "3.0.1",
"@nestjs/common": "10.2.8",
"@nestjs/core": "10.2.8",
"@nestjs/jwt": "10.1.1",
"@nestjs/passport": "10.0.2",
"@nestjs/platform-fastify": "10.2.8",
"@nestjs/platform-socket.io": "10.2.8",
"@nestjs/swagger": "7.1.14",
"@nestjs/swagger": "7.1.15",
"@nestjs/websockets": "10.2.8",
"@oznu/hap-client": "1.9.0",
"axios": "1.6.0",
"axios": "1.6.1",
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"commander": "7.2.0",
"commander": "11.1.0",
"dayjs": "1.11.10",
"emoji-js": "3.7.0",
"fastify": "4.24.3",
"fs-extra": "10.1.0",
"fs-extra": "11.1.1",
"node-cache": "5.1.2",
"node-schedule": "2.1.1",
"ora": "5.4.1",
Expand All @@ -92,15 +92,18 @@
},
"devDependencies": {
"@nestjs/testing": "^10.2.7",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^29.5.7",
"@types/node": "^18.18.8",
"@types/node-schedule": "^2.1.2",
"@types/semver": "^7.5.4",
"@types/tar": "^6.1.7",
"@types/unzipper": "^0.10.8",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.8",
"@types/node": "^18.18.9",
"@types/node-schedule": "^2.1.3",
"@types/passport-jwt": "^3.0.13",
"@types/semver": "^7.5.5",
"@types/tail": "^2.2.3",
"@types/tar": "^6.1.8",
"@types/tcp-port-used": "^1.0.4",
"@types/unzipper": "^0.10.9",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"babel-jest": "^29.7.0",
"bash-color": "^0.0.4",
"buffer-shims": "^1.0.0",
Expand Down
46 changes: 21 additions & 25 deletions src/bin/hb-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as child_process from 'child_process';
import * as os from 'os';
import * as path from 'path';
import axios from 'axios';
import * as commander from 'commander';
import { program } from 'commander';
import * as fs from 'fs-extra';
import * as ora from 'ora';
import * as semver from 'semver';
Expand All @@ -29,18 +29,17 @@ export class HomebridgeServiceHelper {
public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'add' | 'remove' | 'logs' | 'view' | 'update-node' | 'before-start' | 'status';
public selfPath = __filename;
public serviceName = 'Homebridge';
public storagePath;
public storagePath: string;
public usingCustomStoragePath = false;
public allowRunRoot = false;
public enableHbServicePluginManagement = false;
public asUser;
public asUser: string;
public addGroup: string;
private log: fs.WriteStream | NodeJS.WriteStream;
private homebridgeModulePath: string;
private homebridgePackage: { version: string; bin: { homebridge: string } };
private homebridgeBinary: string;
private homebridge: child_process.ChildProcessWithoutNullStreams;
private homebridgeStopped = true;
private homebridgeOpts = ['-I'];
private homebridgeCustomEnv = {};
private uiBinary: string;
Expand Down Expand Up @@ -87,7 +86,7 @@ export class HomebridgeServiceHelper {
process.exit(1);
}

commander
program
.allowUnknownOption()
.storeOptionsAsProperties(true)
.arguments('[install|uninstall|start|stop|restart|rebuild|run|logs|view|add|remove]')
Expand Down Expand Up @@ -139,7 +138,7 @@ export class HomebridgeServiceHelper {
}
case 'rebuild': {
this.logger(`Rebuilding for Node.js ${process.version}...`);
this.installer.rebuild(commander.args.includes('--all'));
this.installer.rebuild(program.args.includes('--all'));
break;
}
case 'run': {
Expand All @@ -155,15 +154,15 @@ export class HomebridgeServiceHelper {
break;
}
case 'add': {
this.npmPluginManagement(commander.args);
this.npmPluginManagement(program.args);
break;
}
case 'remove': {
this.npmPluginManagement(commander.args);
this.npmPluginManagement(program.args);
break;
}
case 'update-node': {
this.checkForNodejsUpdates(commander.args.length === 2 ? commander.args[1] : null);
this.checkForNodejsUpdates(program.args.length === 2 ? program.args[1] : null);
break;
}
case 'before-start': {
Expand All @@ -175,7 +174,7 @@ export class HomebridgeServiceHelper {
break;
}
default: {
commander.outputHelp();
program.outputHelp();

console.log('\nThe hb-service command is provided by homebridge-config-ui-x\n');
console.log('Please provide a command:');
Expand Down Expand Up @@ -204,7 +203,7 @@ export class HomebridgeServiceHelper {
/**
* Logger function, log to homebridge.log file when possible
*/
public logger(msg, type: 'info' | 'succeed' | 'fail' | 'warn' = 'info') {
public logger(msg: string, type: 'info' | 'succeed' | 'fail' | 'warn' = 'info') {
if (this.action === 'run') {
msg = `\x1b[37m[${new Date().toLocaleString()}]\x1b[0m ` +
'\x1b[36m[HB Supervisor]\x1b[0m ' + msg;
Expand Down Expand Up @@ -374,7 +373,7 @@ export class HomebridgeServiceHelper {
// start the ui
await this.runUi();

// tell the ui what homebridge we are running initialy (this is refreshed when Homebridge is restarted)
// tell the ui what homebridge we are running initially (this is refreshed when Homebridge is restarted)
if (this.ipcService && this.homebridgePackage) {
this.ipcService.setHomebridgeVersion(this.homebridgePackage.version);
}
Expand Down Expand Up @@ -416,8 +415,6 @@ export class HomebridgeServiceHelper {
* Starts homebridge as a child process, sending the log output to the homebridge.log
*/
private runHomebridge() {
this.homebridgeStopped = false;

if (!this.homebridgeBinary || !fs.pathExistsSync(this.homebridgeBinary)) {
this.logger('Could not find Homebridge. Make sure you have installed homebridge using the -g flag then restart.', 'fail');
this.logger('npm install -g --unsafe-perm homebridge', 'fail');
Expand Down Expand Up @@ -509,7 +506,6 @@ export class HomebridgeServiceHelper {
* @param signal
*/
private handleHomebridgeClose(code: number, signal: string) {
this.homebridgeStopped = true;
this.logger(`Homebridge Process Ended. Code: ${code}, Signal: ${signal}`);

this.checkForStaleHomebridgeProcess();
Expand Down Expand Up @@ -655,7 +651,7 @@ export class HomebridgeServiceHelper {
// See https://github.com/sebhildebrandt/systeminformation/issues/775#issuecomment-1741836906
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const defaultInterface = (await si.networkInterfaces()).find(x => x.iface === defaultAdapter);
const defaultInterface = (await si.networkInterfaces()).find((x: any) => x.iface === defaultAdapter);

console.log('\nManage Homebridge by going to one of the following in your browser:\n');

Expand Down Expand Up @@ -724,7 +720,7 @@ export class HomebridgeServiceHelper {
if (!Array.isArray(currentConfig.platforms)) {
currentConfig.platforms = [];
}
let uiConfigBlock = currentConfig.platforms.find((x) => x.platform === 'config');
let uiConfigBlock = currentConfig.platforms.find((x: any) => x.platform === 'config');

// if the config block does not exist, then create it
if (!uiConfigBlock) {
Expand All @@ -743,7 +739,7 @@ export class HomebridgeServiceHelper {
restartRequired = true;
}

// if doing an install, make sure the port number matches the value passed in by the user
// if doing an installation, make sure the port number matches the value passed in by the user
if (this.action === 'install') {
// correct the port
if (uiConfigBlock.port !== this.uiPort) {
Expand Down Expand Up @@ -861,7 +857,7 @@ export class HomebridgeServiceHelper {
}

/**
* Returns true if running on the Homebridge Rasbpian Image
* Returns true if running on the Homebridge Raspbian Image
*/
private async isRaspbianImage(): Promise<boolean> {
return os.platform() === 'linux' && await fs.pathExists('/etc/hb-ui-port');
Expand All @@ -886,7 +882,7 @@ export class HomebridgeServiceHelper {
return envPort;
}

// otherwise return the defaul port
// otherwise return the default port
return this.uiPort;
}

Expand Down Expand Up @@ -1225,7 +1221,7 @@ export class HomebridgeServiceHelper {
const spinner = ora(`Installing Node.js ${targetVersion}`).start();

try {
await tar.x(extractConfig);
tar.x(extractConfig);
spinner.succeed(`Installed Node.js ${targetVersion}`);
} catch (e) {
spinner.fail(e.message);
Expand All @@ -1252,7 +1248,7 @@ export class HomebridgeServiceHelper {
}

/**
* Check the current status of the Homebridge UI by calling it's API
* Check the current status of the Homebridge UI by calling its API
*/
private async checkStatus() {
this.logger(`Testing hb-service is running on port ${this.uiPort}...`);
Expand All @@ -1272,7 +1268,7 @@ export class HomebridgeServiceHelper {
}

/**
* Parse an npm package and version string
* Parse an NPM package and version string
* Based on: https://github.com/egoist/parse-package-name
*/
private parseNpmPackageString(input: string) {
Expand All @@ -1296,7 +1292,7 @@ export class HomebridgeServiceHelper {
/**
* Install / Remove a plugin using pnpm (supported platforms only)
*/
private async npmPluginManagement(args) {
private async npmPluginManagement(args: any[]) {
if (!this.enableHbServicePluginManagement) {
this.logger('Plugin management is not supported on your platform using hb-service.', 'fail');
process.exit(1);
Expand Down Expand Up @@ -1326,7 +1322,7 @@ export class HomebridgeServiceHelper {
this.logger(`Path does not exist: "${cwd}"`, 'fail');
}

let cmd;
let cmd: string;

if (process.env.UIX_USE_PNPM === '1') {
cmd = `pnpm -C "${cwd}" ${action} ${target.name}`;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/platforms/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class DarwinInstaller extends BasePlatform {
}

/**
* Resolves the target user home directory when running the install command as SUDO
* Resolves the target user home directory when running the installation command as SUDO
*/
private getUserHomeDir() {
try {
Expand Down Expand Up @@ -253,7 +253,7 @@ export class DarwinInstaller extends BasePlatform {
const downloadUrl = `https://nodejs.org/dist/${job.target}/node-${job.target}-darwin-${process.arch}.tar.gz`;
const targetPath = path.dirname(path.dirname(process.execPath));

// only allow updates when installed using the offical Node.js installer / Homebridge package
// only allow updates when installed using the official Node.js installer / Homebridge package
if (targetPath !== '/usr/local' && !targetPath.startsWith('/Library/Application Support/Homebridge/node-')) {
this.hbService.logger(`Cannot update Node.js on your system. Non-standard installation path detected: ${targetPath}`, 'fail');
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/platforms/freebsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class FreeBSDInstaller extends BasePlatform {
}

/**
* Allows the homebridge user to shutdown and restart the server from the UI
* Allows the homebridge user to shut down and restart the server from the UI
* There is no need for full sudo access when running using hb-service
*/
private setupSudo() {
Expand Down
6 changes: 3 additions & 3 deletions src/bin/platforms/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class LinuxInstaller extends BasePlatform {
'/usr/local/lib/node_modules',
'/usr/lib/node_modules'
].includes(path.dirname(process.env.UIX_BASE_PATH))) {
// systemd has a 90 second default timeout in the pre-start jobs
// systemd has a 90-second default timeout in the pre-start jobs
// terminate this task after 60 seconds to be safe
setTimeout(() => {
process.exit(0);
Expand Down Expand Up @@ -553,7 +553,7 @@ export class LinuxInstaller extends BasePlatform {
}

/**
* Allows the homebridge user to shutdown and restart the server from the UI
* Allows the homebridge user to shut down and restart the server from the UI
* There is no need for full sudo access when running using hb-service
*/
private setupSudo() {
Expand Down Expand Up @@ -689,7 +689,7 @@ export class LinuxInstaller extends BasePlatform {
}

/**
* Setup the run-parts path and scripts
* Set up the run-parts path and scripts
* This allows users to define their own scripts to run before Homebridge starts/restarts
* The default script will ensure the homebridge storage path has the correct permissions each time Homebridge starts
*/
Expand Down
2 changes: 1 addition & 1 deletion src/bin/platforms/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class Win32Installer extends BasePlatform {
.on('finish', () => {
return resolve(nssmPath);
})
.on('error', (err) => {
.on('error', (err: any) => {
return reject(err);
});
}).catch(async (e) => {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ process.title = 'homebridge-config-ui-x';

import * as os from 'os';
import * as path from 'path';
import * as commander from 'commander';
import { program } from 'commander';

commander
program
.allowUnknownOption()
.option('-U, --user-storage-path [path]', '', (p) => process.env.UIX_STORAGE_PATH = p)
.option('-P, --plugin-path [path]', '', (p) => process.env.UIX_CUSTOM_PLUGIN_PATH = p)
Expand Down
Loading

0 comments on commit 02b4f42

Please sign in to comment.