diff --git a/.eslintrc.js b/.eslintrc.js index 98985892f..fac7e65be 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,11 +10,11 @@ module.exports = { 'dist/**/*', '.eslintrc.js' ], - plugins: ['@typescript-eslint/eslint-plugin'], + plugins: ['@typescript-eslint/eslint-plugin', 'import', 'prettier', 'import-newlines', 'sort-exports'], extends: [ - 'plugin:@typescript-eslint/eslint-recommended', + 'airbnb-typescript/base', 'plugin:@typescript-eslint/recommended', - 'prettier' + 'prettier', ], root: true, env: { @@ -22,19 +22,25 @@ module.exports = { jest: true, }, rules: { - 'quotes': ['error', 'single'], 'comma-dangle': ['error', 'only-multiline'], - 'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 0 }], 'eol-last': ['error', 'always'], - 'space-before-function-paren': ['error', { named: 'never' }], - '@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterOverload: true, exceptAfterSingleLine: true }], - '@typescript-eslint/interface-name-prefix': 'off', + 'import-newlines/enforce': ['error', 3], + 'import/no-extraneous-dependencies': 'off', + 'import/order': ['warn', { alphabetize: { order: 'asc' }, 'newlines-between': 'never' }], + 'indent': ['error', 2, { SwitchCase: 1 }], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/semi': ['warn'], + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterOverload: true, exceptAfterSingleLine: true }], '@typescript-eslint/member-delimiter-style': ['warn'], + '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unused-vars': ['warn', { args: 'none', vars: 'local', varsIgnorePattern: 'key' }], + '@typescript-eslint/semi': ['warn'], + 'quotes': ['error', 'single'], + 'sort-exports/sort-exports': ['warn', { sortDir: 'asc' }], + 'sort-imports': ['warn', { ignoreDeclarationSort: true }], + 'space-before-function-paren': ['error', { named: 'never' }], + }, overrides: [ { diff --git a/package-lock.json b/package-lock.json index ea17967f4..9f8e1a14c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,14 +25,14 @@ "@fastify/swagger": "8.12.0", "@homebridge/node-pty-prebuilt-multiarch": "0.11.8", "@nestjs/axios": "3.0.1", - "@nestjs/common": "10.2.7", - "@nestjs/core": "10.2.7", + "@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.7", - "@nestjs/platform-socket.io": "10.2.7", + "@nestjs/platform-fastify": "10.2.8", + "@nestjs/platform-socket.io": "10.2.8", "@nestjs/swagger": "7.1.14", - "@nestjs/websockets": "10.2.7", + "@nestjs/websockets": "10.2.8", "@oznu/hap-client": "1.9.0", "axios": "1.6.0", "class-transformer": "0.5.1", @@ -40,7 +40,7 @@ "commander": "7.2.0", "dayjs": "1.11.10", "emoji-js": "3.7.0", - "fastify": "4.23.2", + "fastify": "4.24.3", "fs-extra": "10.1.0", "node-cache": "5.1.2", "node-schedule": "2.1.1", @@ -77,9 +77,13 @@ "buffer-shims": "^1.0.0", "concurrently": "^8.2.2", "eslint": "^8.53.0", + "eslint-config-airbnb-typescript": "^17.1.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.29.0", + "eslint-plugin-import-newlines": "^1.3.4", "eslint-plugin-jest": "^27.6.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-sort-exports": "^0.8.0", "form-data": "^4.0.0", "jest": "^29.7.0", "lodash": "^4.17.21", @@ -1874,9 +1878,9 @@ } }, "node_modules/@nestjs/common": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.2.7.tgz", - "integrity": "sha512-cUtCRXiUstDmh4bSBhVbq4cI439Gngp4LgLGLBmd5dqFQodfXKnSD441ldYfFiLz4rbUsnoMJz/8ZjuIEI+B7A==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.2.8.tgz", + "integrity": "sha512-rmpwcdvq2IWMmsUVP8rsdKub6uDWk7dwCYo0aif50JTwcvcxzaP3iKVFKoSgvp0RKYu8h15+/AEOfaInmPpl0Q==", "dependencies": { "iterare": "1.2.1", "tslib": "2.6.2", @@ -1902,9 +1906,9 @@ } }, "node_modules/@nestjs/core": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.2.7.tgz", - "integrity": "sha512-5GSu53QUUcwX17sNmlJPa1I0wIeAZOKbedyVuQx0ZAwWVa9g0wJBbsNP+R4EJ+j5Dkdzt/8xkiZvnKt8RFRR8g==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.2.8.tgz", + "integrity": "sha512-9+MZ2s8ixfY9Bl/M9ofChiyYymcwdK9ZWNH4GDMF7Am7XRAQ1oqde6MYGG05rhQwiVXuTwaYLlXciJKfsrg5qg==", "hasInstallScript": true, "dependencies": { "@nuxtjs/opencollective": "0.3.2", @@ -1979,14 +1983,14 @@ } }, "node_modules/@nestjs/platform-fastify": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/platform-fastify/-/platform-fastify-10.2.7.tgz", - "integrity": "sha512-m/OADHxB7yY6TyADLmXJ3BCadG110g/O0nLj2LQDNRiNLiYrgpV3D/cGOcMqlQOG30GZ7BKl8Cq8CsKVtMhzZA==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/platform-fastify/-/platform-fastify-10.2.8.tgz", + "integrity": "sha512-ZeqIHeGLD7YgJ22K9AkyjcFv/yH/LH+HmujukBq/yDLFlJuurKCgbDPfL0PHq0RRMZu5CeB0dhs8+qihw96yjA==", "dependencies": { "@fastify/cors": "8.4.0", "@fastify/formbody": "7.4.0", "@fastify/middie": "8.3.0", - "fastify": "4.23.2", + "fastify": "4.24.3", "light-my-request": "5.11.0", "path-to-regexp": "3.2.0", "tslib": "2.6.2" @@ -2011,9 +2015,9 @@ } }, "node_modules/@nestjs/platform-socket.io": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/platform-socket.io/-/platform-socket.io-10.2.7.tgz", - "integrity": "sha512-P+xDyjz6FwST01elqZDFTxo250ALozGTnx01yvc5t30F6kJFIqeziuHzdrqTLfsEWpZLrjNIs4pi0UpAovawmw==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/platform-socket.io/-/platform-socket.io-10.2.8.tgz", + "integrity": "sha512-P/Olw9alAaKD7Q1vS/ol7K81x1l7Bmi+AXthBNUPGMmG/W8kxO1krerW4rEhtF3BKJ0qJIa5bhDlb80p4lZcNA==", "dependencies": { "socket.io": "4.7.2", "tslib": "2.6.2" @@ -2087,9 +2091,9 @@ } }, "node_modules/@nestjs/websockets": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-10.2.7.tgz", - "integrity": "sha512-NKJMubkwpUBsudbiyjuLZDT/W68K+fS/pe3vG5Ur8QoPn+fkI9SFCiQw27Cv4K0qVX2eGJ41yNmVfu61zGa4CQ==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-10.2.8.tgz", + "integrity": "sha512-oZN1VJFApN7d2eftr65a36QrV0IJNGba4znqyjFnyGvtDWTDcQwzDcnEfvJBTTYhOSBNS7KDfVhne0ythkl6tg==", "dependencies": { "iterare": "1.2.1", "object-hash": "3.0.0", @@ -2302,6 +2306,26 @@ "node": ">=14" } }, + "node_modules/@pkgr/utils": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz", + "integrity": "sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "fast-glob": "^3.3.0", + "is-glob": "^4.0.3", + "open": "^9.1.0", + "picocolors": "^1.0.0", + "tslib": "^2.6.0" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3591,6 +3615,18 @@ "multicast-dns": "^7.2.5" } }, + "node_modules/bplist-parser": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", + "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", + "dev": true, + "dependencies": { + "big-integer": "^1.6.44" + }, + "engines": { + "node": ">= 5.10.0" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3720,6 +3756,21 @@ "node": ">=0.2.0" } }, + "node_modules/bundle-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz", + "integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==", + "dev": true, + "dependencies": { + "run-applescript": "^5.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/call-bind": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", @@ -4129,6 +4180,12 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/confusing-browser-globals": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", + "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", + "dev": true + }, "node_modules/consola": { "version": "2.15.3", "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", @@ -4406,6 +4463,150 @@ "node": ">=0.10.0" } }, + "node_modules/default-browser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz", + "integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==", + "dev": true, + "dependencies": { + "bundle-name": "^3.0.0", + "default-browser-id": "^3.0.0", + "execa": "^7.1.1", + "titleize": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz", + "integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==", + "dev": true, + "dependencies": { + "bplist-parser": "^0.2.0", + "untildify": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/execa": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", + "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^4.3.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": "^14.18.0 || ^16.14.0 || >=18.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/default-browser/node_modules/human-signals": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", + "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", + "dev": true, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/default-browser/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -4439,6 +4640,18 @@ "node": ">= 0.4" } }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -4893,6 +5106,49 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-airbnb-base": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", + "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", + "dev": true, + "dependencies": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.5", + "semver": "^6.3.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "peerDependencies": { + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.2" + } + }, + "node_modules/eslint-config-airbnb-base/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-config-airbnb-typescript": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-17.1.0.tgz", + "integrity": "sha512-GPxI5URre6dDpJ0CtcthSZVBAfI+Uw7un5OYNVxP2EYi3H81Jw701yFP7AU+/vCE7xBtFmjge7kfhhk4+RAiig==", + "dev": true, + "dependencies": { + "eslint-config-airbnb-base": "^15.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^5.13.0 || ^6.0.0", + "@typescript-eslint/parser": "^5.0.0 || ^6.0.0", + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.3" + } + }, "node_modules/eslint-config-prettier": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", @@ -4982,6 +5238,21 @@ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" } }, + "node_modules/eslint-plugin-import-newlines": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-import-newlines/-/eslint-plugin-import-newlines-1.3.4.tgz", + "integrity": "sha512-Lmf/BbK+EQKUfjKPcZpslE/KTGYlgaI8ZJ/sYzdbb3BVTg5+GmLBLHBjsUKNEVRM1SEhDTF/didtOSYKi4tSnQ==", + "dev": true, + "bin": { + "import-linter": "lib/index.js" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, "node_modules/eslint-plugin-import/node_modules/debug": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", @@ -5192,6 +5463,44 @@ "node": ">=4.0" } }, + "node_modules/eslint-plugin-prettier": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.1.tgz", + "integrity": "sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.8.5" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-sort-exports": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-sort-exports/-/eslint-plugin-sort-exports-0.8.0.tgz", + "integrity": "sha512-5x7kJNjIS5bSyehFJ6Gk2gh2wUPt/rmhwDHF8JPDicSH7bvrLRFdlkhHu74YqYBjEySHYaOZVoKNP90TjI0v6w==", + "dev": true, + "peerDependencies": { + "eslint": ">=5.0.0" + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -5534,6 +5843,12 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "node_modules/fast-glob": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", @@ -5644,26 +5959,26 @@ } }, "node_modules/fastify": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.23.2.tgz", - "integrity": "sha512-WFSxsHES115svC7NrerNqZwwM0UOxbC/P6toT9LRHgAAFvG7o2AN5W+H4ihCtOGuYXjZf4z+2jXC89rVEoPWOA==", + "version": "4.24.3", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.24.3.tgz", + "integrity": "sha512-6HHJ+R2x2LS3y1PqxnwEIjOTZxFl+8h4kSC/TuDPXtA+v2JnV9yEtOsNSKK1RMD7sIR2y1ZsA4BEFaid/cK5pg==", "dependencies": { "@fastify/ajv-compiler": "^3.5.0", - "@fastify/error": "^3.2.0", + "@fastify/error": "^3.4.0", "@fastify/fast-json-stringify-compiler": "^4.3.0", "abstract-logging": "^2.0.1", "avvio": "^8.2.1", - "fast-content-type-parse": "^1.0.0", - "fast-json-stringify": "^5.7.0", - "find-my-way": "^7.6.0", - "light-my-request": "^5.9.1", - "pino": "^8.12.0", + "fast-content-type-parse": "^1.1.0", + "fast-json-stringify": "^5.8.0", + "find-my-way": "^7.7.0", + "light-my-request": "^5.11.0", + "pino": "^8.16.0", "process-warning": "^2.2.0", "proxy-addr": "^2.0.7", "rfdc": "^1.3.0", - "secure-json-parse": "^2.5.0", - "semver": "^7.5.0", - "toad-cache": "^3.2.0" + "secure-json-parse": "^2.7.0", + "semver": "^7.5.4", + "toad-cache": "^3.3.0" } }, "node_modules/fastify-plugin": { @@ -6602,6 +6917,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -6641,6 +6971,24 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -6819,6 +7167,33 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-wsl/node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is2": { "version": "2.0.9", "resolved": "https://registry.npmjs.org/is2/-/is2-2.0.9.tgz", @@ -9342,6 +9717,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object.entries": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.7.tgz", + "integrity": "sha512-jCBs/0plmPsOnrKAfFQXRG2NFjlhZgjjcBLSmTnEhU8U6vVTsVe8ANeQJCHTl3gSsI4J+0emOoCgoKlmQPMgmA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/object.fromentries": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.7.tgz", @@ -9423,6 +9812,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/open": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz", + "integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==", + "dev": true, + "dependencies": { + "default-browser": "^4.0.0", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/openapi-types": { "version": "12.1.3", "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", @@ -9902,6 +10309,18 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -10320,6 +10739,21 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/run-applescript": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", + "integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==", + "dev": true, + "dependencies": { + "execa": "^5.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -10957,6 +11391,22 @@ "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.9.0.tgz", "integrity": "sha512-NUHSYoe5XRTk/Are8jPJ6phzBh3l9l33nEyXosM17QInoV95/jng8+PuSGtbD407QoPf93MH3Bkh773OgesJpA==" }, + "node_modules/synckit": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", + "integrity": "sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==", + "dev": true, + "dependencies": { + "@pkgr/utils": "^2.3.1", + "tslib": "^2.5.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/systeminformation": { "version": "5.21.15", "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.21.15.tgz", @@ -11247,6 +11697,18 @@ "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" }, + "node_modules/titleize": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/titleize/-/titleize-3.0.0.tgz", + "integrity": "sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -11737,6 +12199,15 @@ "node": ">= 10.0.0" } }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/unzipper": { "version": "0.10.14", "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.14.tgz", diff --git a/package.json b/package.json index f9ef9ce07..43adf93fb 100644 --- a/package.json +++ b/package.json @@ -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", - "lint:ui": "npm run lint --prefix ui", + "lint:server": "eslint \"{src,test}/**/*.ts\" --max-warnings=0 --fix", + "lint:ui": "npm run lint --prefix ui --fix", "webpack": "webpack --config webpack.config.js", "install:ui": "npm install --prefix ui", "test": "jest --forceExit --detectOpenHandles --verbose=true --silent --config ./test/jest-e2e.json", @@ -58,14 +58,14 @@ "@fastify/swagger": "8.12.0", "@homebridge/node-pty-prebuilt-multiarch": "0.11.8", "@nestjs/axios": "3.0.1", - "@nestjs/common": "10.2.7", - "@nestjs/core": "10.2.7", + "@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.7", - "@nestjs/platform-socket.io": "10.2.7", + "@nestjs/platform-fastify": "10.2.8", + "@nestjs/platform-socket.io": "10.2.8", "@nestjs/swagger": "7.1.14", - "@nestjs/websockets": "10.2.7", + "@nestjs/websockets": "10.2.8", "@oznu/hap-client": "1.9.0", "axios": "1.6.0", "class-transformer": "0.5.1", @@ -73,7 +73,7 @@ "commander": "7.2.0", "dayjs": "1.11.10", "emoji-js": "3.7.0", - "fastify": "4.23.2", + "fastify": "4.24.3", "fs-extra": "10.1.0", "node-cache": "5.1.2", "node-schedule": "2.1.1", @@ -106,9 +106,13 @@ "buffer-shims": "^1.0.0", "concurrently": "^8.2.2", "eslint": "^8.53.0", + "eslint-config-airbnb-typescript": "^17.1.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.29.0", + "eslint-plugin-import-newlines": "^1.3.4", "eslint-plugin-jest": "^27.6.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-sort-exports": "^0.8.0", "form-data": "^4.0.0", "jest": "^29.7.0", "lodash": "^4.17.21", @@ -153,4 +157,4 @@ "smart home", "hb-service" ] -} \ No newline at end of file +} diff --git a/src/app.module.ts b/src/app.module.ts index 4b9c043a6..f1e640848 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,22 +1,22 @@ import { Module } from '@nestjs/common'; -import { LoggerModule } from './core/logger/logger.module'; import { AppController } from './app.controller'; -import { AppService } from './app.service'; import { AppGateway } from './app.gateway'; +import { AppService } from './app.service'; +import { AuthModule } from './core/auth/auth.module'; import { ConfigModule } from './core/config/config.module'; -import { PluginsModule } from './modules/plugins/plugins.module'; -import { CustomPluginsModule } from './modules/custom-plugins/custom-plugins.module'; -import { UsersModule } from './modules/users/users.module'; -import { StatusModule } from './modules/status/status.module'; -import { LogModule } from './modules/log/log.module'; +import { LoggerModule } from './core/logger/logger.module'; import { AccessoriesModule } from './modules/accessories/accessories.module'; +import { BackupModule } from './modules/backup/backup.module'; +import { ChildBridgesModule } from './modules/child-bridges/child-bridges.module'; import { ConfigEditorModule } from './modules/config-editor/config-editor.module'; -import { AuthModule } from './core/auth/auth.module'; -import { ServerModule } from './modules/server/server.module'; +import { CustomPluginsModule } from './modules/custom-plugins/custom-plugins.module'; +import { LogModule } from './modules/log/log.module'; import { PlatformToolsModule } from './modules/platform-tools/platform-tools.module'; -import { BackupModule } from './modules/backup/backup.module'; +import { PluginsModule } from './modules/plugins/plugins.module'; +import { ServerModule } from './modules/server/server.module'; import { SetupWizardModule } from './modules/setup-wizard/setup-wizard.module'; -import { ChildBridgesModule } from './modules/child-bridges/child-bridges.module'; +import { StatusModule } from './modules/status/status.module'; +import { UsersModule } from './modules/users/users.module'; @Module({ imports: [ diff --git a/src/bin/hb-service.ts b/src/bin/hb-service.ts index 78d5ec3e9..bc432ddc9 100644 --- a/src/bin/hb-service.ts +++ b/src/bin/hb-service.ts @@ -6,26 +6,24 @@ process.title = 'hb-service'; +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 * as child_process from 'child_process'; import * as fs from 'fs-extra'; -import * as tcpPortUsed from 'tcp-port-used'; -import * as si from 'systeminformation'; -import * as semver from 'semver'; import * as ora from 'ora'; -import * as tar from 'tar'; -import axios from 'axios'; +import * as semver from 'semver'; +import * as si from 'systeminformation'; import { Tail } from 'tail'; - +import * as tar from 'tar'; +import * as tcpPortUsed from 'tcp-port-used'; +import type { HomebridgeIpcService } from '../core/homebridge-ipc/homebridge-ipc.service'; import { BasePlatform } from './base-platform'; -import { Win32Installer } from './platforms/win32'; -import { LinuxInstaller } from './platforms/linux'; import { DarwinInstaller } from './platforms/darwin'; import { FreeBSDInstaller } from './platforms/freebsd'; - -import type { HomebridgeIpcService } from '../core/homebridge-ipc/homebridge-ipc.service'; +import { LinuxInstaller } from './platforms/linux'; +import { Win32Installer } from './platforms/win32'; export class HomebridgeServiceHelper { public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'add' | 'remove' | 'logs' | 'view' | 'update-node' | 'before-start' | 'status'; diff --git a/src/bin/platforms/darwin.ts b/src/bin/platforms/darwin.ts index 0997fe183..30fe5514f 100644 --- a/src/bin/platforms/darwin.ts +++ b/src/bin/platforms/darwin.ts @@ -1,19 +1,13 @@ +import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import * as child_process from 'child_process'; import * as fs from 'fs-extra'; import * as semver from 'semver'; - -import { HomebridgeServiceHelper } from '../hb-service'; import { BasePlatform } from '../base-platform'; export class DarwinInstaller extends BasePlatform { private user: string; - constructor(hbService: HomebridgeServiceHelper) { - super(hbService); - } - private get plistName() { return `com.${this.hbService.serviceName.toLowerCase()}.server`; } diff --git a/src/bin/platforms/freebsd.ts b/src/bin/platforms/freebsd.ts index d68140c86..7aabf142c 100644 --- a/src/bin/platforms/freebsd.ts +++ b/src/bin/platforms/freebsd.ts @@ -1,16 +1,10 @@ +import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import * as child_process from 'child_process'; import * as fs from 'fs-extra'; - -import { HomebridgeServiceHelper } from '../hb-service'; import { BasePlatform } from '../base-platform'; export class FreeBSDInstaller extends BasePlatform { - constructor(hbService: HomebridgeServiceHelper) { - super(hbService); - } - private get rcServiceName() { return this.hbService.serviceName.toLowerCase(); } diff --git a/src/bin/platforms/linux.ts b/src/bin/platforms/linux.ts index 0825ff687..7476a1884 100644 --- a/src/bin/platforms/linux.ts +++ b/src/bin/platforms/linux.ts @@ -1,18 +1,12 @@ +import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import * as child_process from 'child_process'; import * as fs from 'fs-extra'; -import * as si from 'systeminformation'; import * as semver from 'semver'; - -import { HomebridgeServiceHelper } from '../hb-service'; +import * as si from 'systeminformation'; import { BasePlatform } from '../base-platform'; export class LinuxInstaller extends BasePlatform { - constructor(hbService: HomebridgeServiceHelper) { - super(hbService); - } - private get systemdServiceName() { return this.hbService.serviceName.toLowerCase(); } @@ -622,12 +616,12 @@ 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 await this.createUfwRules(); + return this.createUfwRules(); } // check firewall-cmd is present on the system (enterprise linux) if (await fs.pathExists('/usr/bin/firewall-cmd')) { - return await this.createFirewallCmdRules(); + return this.createFirewallCmdRules(); } } diff --git a/src/bin/platforms/win32.ts b/src/bin/platforms/win32.ts index 648435a6e..c307aac90 100644 --- a/src/bin/platforms/win32.ts +++ b/src/bin/platforms/win32.ts @@ -1,17 +1,11 @@ +import * as child_process from 'child_process'; import * as os from 'os'; -import axios from 'axios'; import * as path from 'path'; -import * as child_process from 'child_process'; +import axios from 'axios'; import * as fs from 'fs-extra'; - -import { HomebridgeServiceHelper } from '../hb-service'; import { BasePlatform } from '../base-platform'; export class Win32Installer extends BasePlatform { - constructor(hbService: HomebridgeServiceHelper) { - super(hbService); - } - /** * Installs the Windows 10 Homebridge Service */ diff --git a/src/core/auth/auth.controller.ts b/src/core/auth/auth.controller.ts index 3ecfc2e49..53d4c90fa 100644 --- a/src/core/auth/auth.controller.ts +++ b/src/core/auth/auth.controller.ts @@ -1,9 +1,21 @@ -import { Controller, Post, Body, Get, UseGuards, Header } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Header, + Post, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiExcludeEndpoint, ApiOperation } from '@nestjs/swagger'; -import { AuthService } from './auth.service'; -import { AuthDto } from './auth.dto'; +import { + ApiBearerAuth, + ApiExcludeEndpoint, + ApiOperation, + ApiTags +} from '@nestjs/swagger'; import { ConfigService } from '../config/config.service'; +import { AuthDto } from './auth.dto'; +import { AuthService } from './auth.service'; @ApiTags('Authentication') @Controller('auth') diff --git a/src/core/auth/auth.dto.ts b/src/core/auth/auth.dto.ts index 6e1cdb095..26d4bc03b 100644 --- a/src/core/auth/auth.dto.ts +++ b/src/core/auth/auth.dto.ts @@ -1,5 +1,10 @@ -import { IsString, IsNotEmpty, IsOptional, IsDefined } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; +import { + IsDefined, + IsNotEmpty, + IsOptional, + IsString +} from 'class-validator'; export class AuthDto { @IsDefined() diff --git a/src/core/auth/auth.module.ts b/src/core/auth/auth.module.ts index 3ed415291..1f09fab51 100644 --- a/src/core/auth/auth.module.ts +++ b/src/core/auth/auth.module.ts @@ -1,15 +1,15 @@ import { Module } from '@nestjs/common'; -import { PassportModule } from '@nestjs/passport'; import { JwtModule } from '@nestjs/jwt'; -import { LoggerModule } from '../logger/logger.module'; +import { PassportModule } from '@nestjs/passport'; import { ConfigModule } from '../config/config.module'; import { ConfigService } from '../config/config.service'; -import { JwtStrategy } from './jwt.strategy'; +import { LoggerModule } from '../logger/logger.module'; import { AuthController } from './auth.controller'; import { AuthService } from './auth.service'; -import { WsGuard } from './guards/ws.guard'; import { AdminGuard } from './guards/admin.guard'; import { WsAdminGuard } from './guards/ws-admin-guard'; +import { WsGuard } from './guards/ws.guard'; +import { JwtStrategy } from './jwt.strategy'; @Module({ imports: [ diff --git a/src/core/auth/auth.service.ts b/src/core/auth/auth.service.ts index e33ef90cd..24617feed 100644 --- a/src/core/auth/auth.service.ts +++ b/src/core/auth/auth.service.ts @@ -1,14 +1,22 @@ -import * as fs from 'fs-extra'; import * as crypto from 'crypto'; -import * as jwt from 'jsonwebtoken'; -import { authenticator } from 'otplib'; +import { + BadRequestException, + ConflictException, + ForbiddenException, + HttpException, + Injectable, + NotFoundException, + UnauthorizedException +} from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; -import { Injectable, ForbiddenException, BadRequestException, UnauthorizedException, ConflictException, NotFoundException, HttpException } from '@nestjs/common'; import { WsException } from '@nestjs/websockets'; +import * as fs from 'fs-extra'; +import * as jwt from 'jsonwebtoken'; import * as NodeCache from 'node-cache'; +import { authenticator } from 'otplib'; +import { UserDto } from '../../modules/users/users.dto'; import { ConfigService } from '../config/config.service'; import { Logger } from '../logger/logger.service'; -import { UserDto } from '../../modules/users/users.dto'; @Injectable() export class AuthService { @@ -302,7 +310,7 @@ export class AuthService { */ private async saveUserFile(users: UserDto[]) { // update the auth.json - return await fs.writeJson(this.configService.authPath, users, { spaces: 4 }); + return fs.writeJson(this.configService.authPath, users, { spaces: 4 }); } /** diff --git a/src/core/auth/guards/admin.guard.ts b/src/core/auth/guards/admin.guard.ts index ee0ec9ffe..93f056832 100644 --- a/src/core/auth/guards/admin.guard.ts +++ b/src/core/auth/guards/admin.guard.ts @@ -1,4 +1,4 @@ -import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; +import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; @Injectable() export class AdminGuard implements CanActivate { diff --git a/src/core/auth/guards/ws-admin-guard.ts b/src/core/auth/guards/ws-admin-guard.ts index f5bdce61a..4afc0b444 100644 --- a/src/core/auth/guards/ws-admin-guard.ts +++ b/src/core/auth/guards/ws-admin-guard.ts @@ -1,7 +1,7 @@ import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; import * as jwt from 'jsonwebtoken'; -import { ConfigService } from '../../config/config.service'; import { UserDto } from '../../../modules/users/users.dto'; +import { ConfigService } from '../../config/config.service'; @Injectable() export class WsAdminGuard implements CanActivate { diff --git a/src/core/auth/guards/ws.guard.ts b/src/core/auth/guards/ws.guard.ts index abe0ccf64..abf793ddb 100644 --- a/src/core/auth/guards/ws.guard.ts +++ b/src/core/auth/guards/ws.guard.ts @@ -1,8 +1,8 @@ import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; import * as jwt from 'jsonwebtoken'; -import { ConfigService } from '../../config/config.service'; import { UserDto } from '../../../modules/users/users.dto'; +import { ConfigService } from '../../config/config.service'; @Injectable() export class WsGuard implements CanActivate { diff --git a/src/core/auth/jwt.strategy.ts b/src/core/auth/jwt.strategy.ts index aa4e3e3b6..03af2488f 100644 --- a/src/core/auth/jwt.strategy.ts +++ b/src/core/auth/jwt.strategy.ts @@ -1,8 +1,8 @@ -import { ExtractJwt, Strategy } from 'passport-jwt'; -import { AuthService } from './auth.service'; -import { PassportStrategy } from '@nestjs/passport'; import { Injectable, UnauthorizedException } from '@nestjs/common'; +import { PassportStrategy } from '@nestjs/passport'; +import { ExtractJwt, Strategy } from 'passport-jwt'; import { ConfigService } from '../config/config.service'; +import { AuthService } from './auth.service'; @Injectable() export class JwtStrategy extends PassportStrategy(Strategy) { diff --git a/src/core/config/config.service.ts b/src/core/config/config.service.ts index 4a03be91e..e791a7b14 100644 --- a/src/core/config/config.service.ts +++ b/src/core/config/config.service.ts @@ -1,28 +1,10 @@ -import { Injectable } from '@nestjs/common'; +import * as crypto from 'crypto'; import * as os from 'os'; import * as path from 'path'; +import { Injectable } from '@nestjs/common'; import * as fs from 'fs-extra'; -import * as crypto from 'crypto'; -import * as semver from 'semver'; import * as _ from 'lodash'; - -export interface HomebridgeConfig { - bridge: { - username: string; - pin: string; - name: string; - port: number; - advertiser?: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; - bind?: string | string[]; - }; - mdns?: { - interface?: string | string[]; - }; - platforms: Record[]; - accessories: Record[]; - plugins?: string[]; - disabledPlugins?: string[]; -} +import * as semver from 'semver'; @Injectable() export class ConfigService { @@ -373,3 +355,21 @@ export class ConfigService { } } + +export interface HomebridgeConfig { + bridge: { + username: string; + pin: string; + name: string; + port: number; + advertiser?: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; + bind?: string | string[]; + }; + mdns?: { + interface?: string | string[]; + }; + platforms: Record[]; + accessories: Record[]; + plugins?: string[]; + disabledPlugins?: string[]; +} diff --git a/src/core/config/config.startup.ts b/src/core/config/config.startup.ts index 242db18fa..76465eee0 100644 --- a/src/core/config/config.startup.ts +++ b/src/core/config/config.startup.ts @@ -1,7 +1,6 @@ import * as os from 'os'; import * as path from 'path'; import * as fs from 'fs-extra'; - import { Logger } from '../logger/logger.service'; /** diff --git a/src/core/homebridge-ipc/homebridge-ipc.service.ts b/src/core/homebridge-ipc/homebridge-ipc.service.ts index cd2b058ac..d5dc083c7 100644 --- a/src/core/homebridge-ipc/homebridge-ipc.service.ts +++ b/src/core/homebridge-ipc/homebridge-ipc.service.ts @@ -1,6 +1,6 @@ -import { Injectable, ServiceUnavailableException } from '@nestjs/common'; import { ChildProcess } from 'child_process'; import { EventEmitter } from 'events'; +import { Injectable, ServiceUnavailableException } from '@nestjs/common'; import { ConfigService } from '../config/config.service'; import { Logger } from '../logger/logger.service'; @@ -55,6 +55,7 @@ export class HomebridgeIpcService extends EventEmitter { public async requestResponse(requestEvent: string, responseEvent: string) { return new Promise((resolve, reject) => { const actionTimeout = setTimeout(() => { + // eslint-disable-next-line @typescript-eslint/no-use-before-define this.removeListener(responseEvent, listener); reject('The Homebridge service did not respond'); }, 3000); diff --git a/src/core/node-pty/node-pty.service.ts b/src/core/node-pty/node-pty.service.ts index ed5d69b8e..7db78a666 100644 --- a/src/core/node-pty/node-pty.service.ts +++ b/src/core/node-pty/node-pty.service.ts @@ -1,5 +1,5 @@ -import { Injectable } from '@nestjs/common'; import * as pty from '@homebridge/node-pty-prebuilt-multiarch'; +import { Injectable } from '@nestjs/common'; @Injectable() export class NodePtyService { diff --git a/src/core/spa/spa.filter.ts b/src/core/spa/spa.filter.ts index 492da587b..2e8211c21 100644 --- a/src/core/spa/spa.filter.ts +++ b/src/core/spa/spa.filter.ts @@ -1,7 +1,13 @@ import * as path from 'path'; +import { + ArgumentsHost, + Catch, + ExceptionFilter, + HttpException, + NotFoundException +} from '@nestjs/common'; import * as fs from 'fs-extra'; -import { Catch, NotFoundException, ExceptionFilter, HttpException, ArgumentsHost } from '@nestjs/common'; @Catch(NotFoundException) export class SpaFilter implements ExceptionFilter { diff --git a/src/index.ts b/src/index.ts index 300e77685..cd5d21c47 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,22 +2,13 @@ * Homebridge Entry Point */ -import * as path from 'path'; import * as child_process from 'child_process'; +import * as path from 'path'; import * as commander from 'commander'; import * as semver from 'semver'; let homebridge; -export = (api) => { - homebridge = api; - homebridge.registerPlatform('homebridge-config-ui-x', 'config', HomebridgeConfigUi); - - if (process.env.UIX_SERVICE_MODE === '1' && process.connected) { - HomebridgeConfigUi.serviceMode(); - } -}; - class HomebridgeConfigUi { log; @@ -99,3 +90,12 @@ class HomebridgeConfigUi { callback(accessories); } } + +export = (api) => { + homebridge = api; + homebridge.registerPlatform('homebridge-config-ui-x', 'config', HomebridgeConfigUi); + + if (process.env.UIX_SERVICE_MODE === '1' && process.connected) { + HomebridgeConfigUi.serviceMode(); + } +}; diff --git a/src/main.ts b/src/main.ts index 65431f0eb..7e8596486 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,20 +1,19 @@ import './self-check'; import * as path from 'path'; -import { FastifyReply, FastifyRequest } from 'fastify'; -import fastifyMultipart from '@fastify/multipart'; import helmet from '@fastify/helmet'; -import * as fs from 'fs-extra'; -import { NestFactory } from '@nestjs/core'; +import fastifyMultipart from '@fastify/multipart'; import { ValidationPipe } from '@nestjs/common'; +import { NestFactory } from '@nestjs/core'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; -import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; - +import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; +import { FastifyReply, FastifyRequest } from 'fastify'; +import * as fs from 'fs-extra'; import { AppModule } from './app.module'; -import { Logger } from './core/logger/logger.service'; -import { SpaFilter } from './core/spa/spa.filter'; import { ConfigService } from './core/config/config.service'; import { getStartupConfig } from './core/config/config.startup'; +import { Logger } from './core/logger/logger.service'; +import { SpaFilter } from './core/spa/spa.filter'; export { HomebridgeIpcService } from './core/homebridge-ipc/homebridge-ipc.service'; diff --git a/src/modules/accessories/accessories.controller.ts b/src/modules/accessories/accessories.controller.ts index 60f524288..2e4396a86 100644 --- a/src/modules/accessories/accessories.controller.ts +++ b/src/modules/accessories/accessories.controller.ts @@ -1,8 +1,21 @@ -import { Controller, UseGuards, Get, Put, Param, Body, Req } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Param, + Put, + Req, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation, ApiParam } from '@nestjs/swagger'; -import { AccessoriesService } from './accessories.service'; +import { + ApiBearerAuth, + ApiOperation, + ApiParam, + ApiTags +} from '@nestjs/swagger'; import { AccessorySetCharacteristicDto } from './accessories.dto'; +import { AccessoriesService } from './accessories.service'; @ApiTags('Accessories') @ApiBearerAuth() diff --git a/src/modules/accessories/accessories.dto.ts b/src/modules/accessories/accessories.dto.ts index 5d2063b70..2f8dd0af8 100644 --- a/src/modules/accessories/accessories.dto.ts +++ b/src/modules/accessories/accessories.dto.ts @@ -1,14 +1,14 @@ -import { IsString, IsNotEmpty, IsDefined } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; +import { IsDefined, IsNotEmpty, IsString } from 'class-validator'; export class AccessorySetCharacteristicDto { @ApiProperty({ required: true }) @IsDefined() @IsString() - characteristicType: string; + characteristicType: string; @ApiProperty({ required: true, type: 'string', title: 'Accepts a string, boolean, or integer value.' }) @IsDefined() @IsNotEmpty() - value: string | boolean | number; + value: string | boolean | number; } diff --git a/src/modules/accessories/accessories.gateway.ts b/src/modules/accessories/accessories.gateway.ts index 9ae8eaee8..eb1434515 100644 --- a/src/modules/accessories/accessories.gateway.ts +++ b/src/modules/accessories/accessories.gateway.ts @@ -1,5 +1,5 @@ -import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; import { UseGuards } from '@nestjs/common'; +import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; import { WsGuard } from '../../core/auth/guards/ws.guard'; import { AccessoriesService } from './accessories.service'; @@ -22,7 +22,7 @@ export class AccessoriesGateway { @SubscribeMessage('get-layout') async getAccessoryLayout(client: any, payload: any) { - return await this.accessoriesService.getAccessoryLayout(payload.user); + return this.accessoriesService.getAccessoryLayout(payload.user); } @SubscribeMessage('save-layout') diff --git a/src/modules/accessories/accessories.module.ts b/src/modules/accessories/accessories.module.ts index 902910674..9d7488227 100644 --- a/src/modules/accessories/accessories.module.ts +++ b/src/modules/accessories/accessories.module.ts @@ -1,10 +1,10 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; -import { AccessoriesService } from './accessories.service'; -import { AccessoriesGateway } from './accessories.gateway'; -import { AccessoriesController } from './accessories.controller'; import { ConfigModule } from '../../core/config/config.module'; import { LoggerModule } from '../../core/logger/logger.module'; +import { AccessoriesController } from './accessories.controller'; +import { AccessoriesGateway } from './accessories.gateway'; +import { AccessoriesService } from './accessories.service'; @Module({ imports: [ diff --git a/src/modules/accessories/accessories.service.ts b/src/modules/accessories/accessories.service.ts index ae459b991..77c735ba0 100644 --- a/src/modules/accessories/accessories.service.ts +++ b/src/modules/accessories/accessories.service.ts @@ -1,9 +1,8 @@ import * as path from 'path'; +import { BadRequestException, Injectable } from '@nestjs/common'; +import { HapClient, ServiceType } from '@oznu/hap-client'; import * as fs from 'fs-extra'; import * as NodeCache from 'node-cache'; -import { Injectable, BadRequestException } from '@nestjs/common'; -import { HapClient, ServiceType } from '@oznu/hap-client'; - import { ConfigService } from '../../core/config/config.service'; import { Logger } from '../../core/logger/logger.service'; diff --git a/src/modules/backup/backup.controller.ts b/src/modules/backup/backup.controller.ts index 1f6e08395..5c0db441c 100644 --- a/src/modules/backup/backup.controller.ts +++ b/src/modules/backup/backup.controller.ts @@ -1,11 +1,28 @@ -import { Controller, Get, Post, Put, UseGuards, Res, Req, InternalServerErrorException, Param, StreamableFile } from '@nestjs/common'; +import { + Controller, + Get, + InternalServerErrorException, + Param, + Post, + Put, + Req, + Res, + StreamableFile, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation, ApiBody, ApiConsumes, ApiParam } from '@nestjs/swagger'; +import { + ApiBearerAuth, + ApiBody, + ApiConsumes, + ApiOperation, + ApiParam, + ApiTags +} from '@nestjs/swagger'; import { FastifyRequest } from 'fastify'; - -import { BackupService } from './backup.service'; import { AdminGuard } from '../../core/auth/guards/admin.guard'; import { Logger } from '../../core/logger/logger.service'; +import { BackupService } from './backup.service'; @ApiTags('Backup & Restore') @ApiBearerAuth() @@ -88,7 +105,7 @@ export class BackupController { description: 'Logs to stdout / stderr.', }) async restoreBackupTrigger() { - return await this.backupService.triggerHeadlessRestore(); + return this.backupService.triggerHeadlessRestore(); } @UseGuards(AdminGuard) diff --git a/src/modules/backup/backup.gateway.ts b/src/modules/backup/backup.gateway.ts index e303b9088..986296f65 100644 --- a/src/modules/backup/backup.gateway.ts +++ b/src/modules/backup/backup.gateway.ts @@ -1,10 +1,9 @@ -import * as color from 'bash-color'; import { EventEmitter } from 'events'; import { UseGuards } from '@nestjs/common'; -import { WebSocketGateway, SubscribeMessage, WsException } from '@nestjs/websockets'; - -import { Logger } from '../../core/logger/logger.service'; +import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; +import * as color from 'bash-color'; import { WsAdminGuard } from '../../core/auth/guards/ws-admin-guard'; +import { Logger } from '../../core/logger/logger.service'; import { BackupService } from './backup.service'; @UseGuards(WsAdminGuard) diff --git a/src/modules/backup/backup.module.ts b/src/modules/backup/backup.module.ts index 6101ac3bf..d0d3d76dd 100644 --- a/src/modules/backup/backup.module.ts +++ b/src/modules/backup/backup.module.ts @@ -1,14 +1,13 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - import { ConfigModule } from '../../core/config/config.module'; +import { HomebridgeIpcModule } from '../../core/homebridge-ipc/homebridge-ipc.module'; import { LoggerModule } from '../../core/logger/logger.module'; import { SchedulerModule } from '../../core/scheduler/scheduler.module'; -import { HomebridgeIpcModule } from '../../core/homebridge-ipc/homebridge-ipc.module'; -import { BackupService } from './backup.service'; -import { BackupGateway } from './backup.gateway'; -import { BackupController } from './backup.controller'; import { PluginsModule } from '../plugins/plugins.module'; +import { BackupController } from './backup.controller'; +import { BackupGateway } from './backup.gateway'; +import { BackupService } from './backup.service'; @Module({ imports: [ diff --git a/src/modules/backup/backup.service.ts b/src/modules/backup/backup.service.ts index c11e8afee..065b0d3b0 100644 --- a/src/modules/backup/backup.service.ts +++ b/src/modules/backup/backup.service.ts @@ -1,23 +1,28 @@ +import * as child_process from 'child_process'; +import { EventEmitter } from 'events'; import * as os from 'os'; -import * as tar from 'tar'; import * as path from 'path'; +import { pipeline } from 'stream'; import * as util from 'util'; -import * as fs from 'fs-extra'; +import { MultipartFile } from '@fastify/multipart'; +import { + BadRequestException, + Injectable, + InternalServerErrorException, + NotFoundException, + StreamableFile +} from '@nestjs/common'; import * as color from 'bash-color'; -import * as unzipper from 'unzipper'; -import * as child_process from 'child_process'; import * as dayjs from 'dayjs'; -import { pipeline } from 'stream'; -import { EventEmitter } from 'events'; -import { Injectable, BadRequestException, NotFoundException, InternalServerErrorException, StreamableFile } from '@nestjs/common'; import { FastifyReply } from 'fastify'; -import { MultipartFile } from '@fastify/multipart'; - -import { PluginsService } from '../plugins/plugins.service'; -import { SchedulerService } from '../../core/scheduler/scheduler.service'; +import * as fs from 'fs-extra'; +import * as tar from 'tar'; +import * as unzipper from 'unzipper'; 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 { SchedulerService } from '../../core/scheduler/scheduler.service'; +import { PluginsService } from '../plugins/plugins.service'; import { HomebridgePlugin } from '../plugins/types'; const pump = util.promisify(pipeline); @@ -170,7 +175,7 @@ export class BackupService { } } else { // when not using a custom backup path, just ensure it exists - return await fs.ensureDir(this.configService.instanceBackupPath); + return fs.ensureDir(this.configService.instanceBackupPath); } } @@ -332,7 +337,7 @@ export class BackupService { */ async removeRestoreDirectory() { if (this.restoreDirectory) { - return await fs.remove(this.restoreDirectory); + return fs.remove(this.restoreDirectory); } } diff --git a/src/modules/child-bridges/child-bridges.gateway.ts b/src/modules/child-bridges/child-bridges.gateway.ts index 0de603db2..26038e512 100644 --- a/src/modules/child-bridges/child-bridges.gateway.ts +++ b/src/modules/child-bridges/child-bridges.gateway.ts @@ -1,6 +1,5 @@ import { UseGuards } from '@nestjs/common'; import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; - import { WsGuard } from '../../core/auth/guards/ws.guard'; import { ChildBridgesService } from './child-bridges.service'; @@ -33,7 +32,7 @@ export class ChildBridgesGateway { @SubscribeMessage('restart-child-bridge') async restartChildBridge(client, payload) { try { - return await this.childBridgesService.restartChildBridge(payload); + return this.childBridgesService.restartChildBridge(payload); } catch (e) { return new WsException(e.message); } @@ -42,7 +41,7 @@ export class ChildBridgesGateway { @SubscribeMessage('stop-child-bridge') async stopChildBridge(client, payload) { try { - return await this.childBridgesService.stopChildBridge(payload); + return this.childBridgesService.stopChildBridge(payload); } catch (e) { return new WsException(e.message); } @@ -51,7 +50,7 @@ export class ChildBridgesGateway { @SubscribeMessage('start-child-bridge') async startChildBridge(client, payload) { try { - return await this.childBridgesService.startChildBridge(payload); + return this.childBridgesService.startChildBridge(payload); } catch (e) { return new WsException(e.message); } diff --git a/src/modules/child-bridges/child-bridges.module.ts b/src/modules/child-bridges/child-bridges.module.ts index 6aff8d29b..08ca4dd40 100644 --- a/src/modules/child-bridges/child-bridges.module.ts +++ b/src/modules/child-bridges/child-bridges.module.ts @@ -1,9 +1,8 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - -import { LoggerModule } from '../../core/logger/logger.module'; import { ConfigModule } from '../../core/config/config.module'; import { HomebridgeIpcModule } from '../../core/homebridge-ipc/homebridge-ipc.module'; +import { LoggerModule } from '../../core/logger/logger.module'; import { AccessoriesModule } from '../accessories/accessories.module'; import { ChildBridgesGateway } from './child-bridges.gateway'; import { ChildBridgesService } from './child-bridges.service'; diff --git a/src/modules/child-bridges/child-bridges.service.ts b/src/modules/child-bridges/child-bridges.service.ts index f1d63e49b..94eab6229 100644 --- a/src/modules/child-bridges/child-bridges.service.ts +++ b/src/modules/child-bridges/child-bridges.service.ts @@ -1,9 +1,8 @@ import { BadRequestException, Injectable } from '@nestjs/common'; import * as semver from 'semver'; - -import { Logger } from '../../core/logger/logger.service'; import { ConfigService } 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'; @Injectable() diff --git a/src/modules/config-editor/config-editor.controller.ts b/src/modules/config-editor/config-editor.controller.ts index 0112d5c73..30f6ba9d5 100644 --- a/src/modules/config-editor/config-editor.controller.ts +++ b/src/modules/config-editor/config-editor.controller.ts @@ -1,8 +1,24 @@ -import { Controller, UseGuards, Get, Post, Body, Param, Delete, ParseIntPipe, Put } from '@nestjs/common'; +import { + Body, + Controller, + Delete, + Get, + Param, + ParseIntPipe, + Post, + Put, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation, ApiBody, ApiParam } from '@nestjs/swagger'; -import { ConfigEditorService } from './config-editor.service'; +import { + ApiBearerAuth, + ApiBody, + ApiOperation, + ApiParam, + ApiTags +} from '@nestjs/swagger'; import { AdminGuard } from '../../core/auth/guards/admin.guard'; +import { ConfigEditorService } from './config-editor.service'; @ApiTags('Homebridge Config Editor') @ApiBearerAuth() diff --git a/src/modules/config-editor/config-editor.module.ts b/src/modules/config-editor/config-editor.module.ts index 18bbd2e32..3c1b34efa 100644 --- a/src/modules/config-editor/config-editor.module.ts +++ b/src/modules/config-editor/config-editor.module.ts @@ -1,11 +1,11 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; -import { ConfigEditorService } from './config-editor.service'; -import { ConfigEditorController } from './config-editor.controller'; import { ConfigModule } from '../../core/config/config.module'; import { LoggerModule } from '../../core/logger/logger.module'; import { SchedulerModule } from '../../core/scheduler/scheduler.module'; import { PluginsModule } from '../plugins/plugins.module'; +import { ConfigEditorController } from './config-editor.controller'; +import { ConfigEditorService } from './config-editor.service'; @Module({ imports: [ diff --git a/src/modules/config-editor/config-editor.service.ts b/src/modules/config-editor/config-editor.service.ts index f8ffc8883..cb139f90f 100644 --- a/src/modules/config-editor/config-editor.service.ts +++ b/src/modules/config-editor/config-editor.service.ts @@ -1,9 +1,9 @@ -import * as fs from 'fs-extra'; import * as path from 'path'; -import * as dayjs from 'dayjs'; import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common'; -import { Logger } from '../../core/logger/logger.service'; +import * as dayjs from 'dayjs'; +import * as fs from 'fs-extra'; import { ConfigService, HomebridgeConfig } from '../../core/config/config.service'; +import { Logger } from '../../core/logger/logger.service'; import { SchedulerService } from '../../core/scheduler/scheduler.service'; import { PluginsService } from '../plugins/plugins.service'; @@ -333,7 +333,7 @@ export class ConfigEditorService { } // read source backup - return await fs.readFile(requestedBackupPath); + return fs.readFile(requestedBackupPath); } /** diff --git a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.ts b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.ts index 5dcb80c79..7f9b08888 100644 --- a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.ts +++ b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.ts @@ -1,6 +1,12 @@ -import { Controller, UseGuards, Get, Header, StreamableFile } from '@nestjs/common'; +import { + Controller, + Get, + Header, + StreamableFile, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; +import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { AdminGuard } from '../../../core/auth/guards/admin.guard'; import { HomebridgeDeconzService } from './homebridge-deconz.service'; diff --git a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.ts b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.ts index f87163d53..65f5b5ffd 100644 --- a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.ts +++ b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; -import { LoggerModule } from '../../../core/logger/logger.module'; import { ConfigModule } from '../../../core/config/config.module'; +import { LoggerModule } from '../../../core/logger/logger.module'; import { HomebridgeDeconzController } from './homebridge-deconz.controller'; import { HomebridgeDeconzService } from './homebridge-deconz.service'; diff --git a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.ts b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.ts index 6200e1d14..2fc394417 100644 --- a/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.ts +++ b/src/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.ts @@ -1,6 +1,6 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { Injectable, NotFoundException, StreamableFile } from '@nestjs/common'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../../core/config/config.service'; @Injectable() diff --git a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.ts b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.ts index 7d53039aa..9467e70e7 100644 --- a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.ts +++ b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.ts @@ -1,6 +1,12 @@ -import { Controller, UseGuards, Get, Header, StreamableFile } from '@nestjs/common'; +import { + Controller, + Get, + Header, + StreamableFile, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; +import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { AdminGuard } from '../../../core/auth/guards/admin.guard'; import { HomebridgeHueService } from './homebridge-hue.service'; diff --git a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.module.ts b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.module.ts index bf8aca426..a444f30fe 100644 --- a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.module.ts +++ b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; -import { LoggerModule } from '../../../core/logger/logger.module'; import { ConfigModule } from '../../../core/config/config.module'; +import { LoggerModule } from '../../../core/logger/logger.module'; import { HomebridgeHueController } from './homebridge-hue.controller'; import { HomebridgeHueService } from './homebridge-hue.service'; diff --git a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.service.ts b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.service.ts index e12c4c8e9..73b4f8de5 100644 --- a/src/modules/custom-plugins/homebridge-hue/homebridge-hue.service.ts +++ b/src/modules/custom-plugins/homebridge-hue/homebridge-hue.service.ts @@ -1,6 +1,6 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { Injectable, NotFoundException, StreamableFile } from '@nestjs/common'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../../core/config/config.service'; @Injectable() 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 784bd2d02..acf611589 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 @@ -1,6 +1,11 @@ -import { Controller, Get, Param, Query, Res } from '@nestjs/common'; +import { + Controller, + Get, + Param, + Query, + Res +} from '@nestjs/common'; import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; - import { PluginsSettingsUiService } from './plugins-settings-ui.service'; @ApiTags('Plugins') @@ -15,7 +20,7 @@ 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 await this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v); + return this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, origin, v); } } diff --git a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.ts b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.ts index c46fc7d60..24af368dc 100644 --- a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.ts +++ b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.ts @@ -1,7 +1,6 @@ -import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; -import { UseGuards } from '@nestjs/common'; import { EventEmitter } from 'events'; - +import { UseGuards } from '@nestjs/common'; +import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; import { WsAdminGuard } from '../../../core/auth/guards/ws-admin-guard'; import { PluginsSettingsUiService } from './plugins-settings-ui.service'; diff --git a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.ts b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.ts index dc4e84df7..235cddfa2 100644 --- a/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.ts +++ b/src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.ts @@ -1,6 +1,5 @@ -import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; - +import { Module } from '@nestjs/common'; import { ConfigModule } from '../../../core/config/config.module'; import { LoggerModule } from '../../../core/logger/logger.module'; import { PluginsModule } from '../../plugins/plugins.module'; 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 ecc571606..d90053495 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 @@ -1,16 +1,15 @@ +import * as child_process from 'child_process'; +import { EventEmitter } from 'events'; import * as path from 'path'; +import { HttpService } from '@nestjs/axios'; +import { Injectable, NotFoundException } from '@nestjs/common'; import * as fs from 'fs-extra'; import * as NodeCache from 'node-cache'; -import * as child_process from 'child_process'; -import { Injectable, NotFoundException } from '@nestjs/common'; -import { HttpService } from '@nestjs/axios'; - -import { Logger } from '../../../core/logger/logger.service'; import { ConfigService } from '../../../core/config/config.service'; +import { Logger } from '../../../core/logger/logger.service'; import { PluginsService } from '../../plugins/plugins.service'; import { HomebridgePluginUiMetadata } from '../../plugins/types'; -import { EventEmitter } from 'events'; @Injectable() export class PluginsSettingsUiService { @@ -49,7 +48,7 @@ export class PluginsSettingsUiService { return reply.code(404).send('Not Found'); } - // this will severely limit the ability for this page to do anything if loaded outside of the UI + // this will severely limit the ability for this page to do anything if loaded outside the UI reply.header('Content-Security-Policy', ''); if (assetPath === 'index.html') { @@ -59,7 +58,7 @@ export class PluginsSettingsUiService { } if (pluginUi.devServer) { - return this.serveAssetsFromDevServer(reply, pluginUi, assetPath); + return await this.serveAssetsFromDevServer(reply, pluginUi, assetPath); } // fallback path (to serve static assets from the plugin ui public folder) @@ -74,9 +73,8 @@ export class PluginsSettingsUiService { return reply.code(404).send('Not Found'); } } catch (e) { - e.message === 'Not Found' ? reply.code(404) : reply.code(500); this.loggerService.error(`[${pluginName}]`, e.message); - return reply.send(e.message); + return e.message === 'Not Found' ? reply.code(404).send(e.message) : reply.code(500).send(e.message); } } @@ -119,7 +117,7 @@ export class PluginsSettingsUiService { // dev server is only enabled for private plugins return (await this.httpService.get(pluginUi.devServer, { responseType: 'text' }).toPromise()).data; } else { - return await fs.readFile(path.join(pluginUi.publicPath, 'index.html'), 'utf8'); + return fs.readFile(path.join(pluginUi.publicPath, 'index.html'), 'utf8'); } } diff --git a/src/modules/log/log.gateway.ts b/src/modules/log/log.gateway.ts index a3d7f6abc..efc2d3e78 100644 --- a/src/modules/log/log.gateway.ts +++ b/src/modules/log/log.gateway.ts @@ -1,7 +1,6 @@ import { EventEmitter } from 'events'; import { UseGuards } from '@nestjs/common'; import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; - import { WsGuard } from '../../core/auth/guards/ws.guard'; import { LogService, LogTermSize } from './log.service'; diff --git a/src/modules/log/log.module.ts b/src/modules/log/log.module.ts index 42f984538..5b2d3c488 100644 --- a/src/modules/log/log.module.ts +++ b/src/modules/log/log.module.ts @@ -1,10 +1,9 @@ import { Module } from '@nestjs/common'; -import { LogService } from './log.service'; -import { LogGateway } from './log.gateway'; - import { ConfigModule } from '../../core/config/config.module'; import { LoggerModule } from '../../core/logger/logger.module'; import { NodePtyModule } from '../../core/node-pty/node-pty.module'; +import { LogGateway } from './log.gateway'; +import { LogService } from './log.service'; @Module({ imports: [ diff --git a/src/modules/log/log.service.ts b/src/modules/log/log.service.ts index ef904db4a..fce9bf94c 100644 --- a/src/modules/log/log.service.ts +++ b/src/modules/log/log.service.ts @@ -1,17 +1,14 @@ -import * as os from 'os'; -import * as color from 'bash-color'; -import * as semver from 'semver'; import * as child_process from 'child_process'; -import * as fs from 'fs-extra'; import { EventEmitter } from 'events'; +import * as os from 'os'; import { Injectable } from '@nestjs/common'; +import * as color from 'bash-color'; +import * as fs from 'fs-extra'; +import * as semver from 'semver'; import { Tail } from 'tail'; - import { ConfigService } from '../../core/config/config.service'; import { NodePtyService } from '../../core/node-pty/node-pty.service'; -export type LogTermSize = { cols: number; rows: number }; - @Injectable() export class LogService { private command: string[]; @@ -250,10 +247,12 @@ export class LogService { } /** - * Logs are not configued + * Logs are not configured */ private logNotConfigured() { this.command = null; } } + +export type LogTermSize = { cols: number; rows: number }; diff --git a/src/modules/platform-tools/docker/docker.controller.ts b/src/modules/platform-tools/docker/docker.controller.ts index c6a74f899..30036f033 100644 --- a/src/modules/platform-tools/docker/docker.controller.ts +++ b/src/modules/platform-tools/docker/docker.controller.ts @@ -1,7 +1,12 @@ -import { Controller, UseGuards, Get, Put, Body } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Put, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; - +import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; import { AdminGuard } from '../../../core/auth/guards/admin.guard'; import { DockerService } from './docker.service'; diff --git a/src/modules/platform-tools/docker/docker.module.ts b/src/modules/platform-tools/docker/docker.module.ts index 5e2c4efe9..36d014970 100644 --- a/src/modules/platform-tools/docker/docker.module.ts +++ b/src/modules/platform-tools/docker/docker.module.ts @@ -2,8 +2,8 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; import { ConfigModule } from '../../../core/config/config.module'; import { LoggerModule } from '../../../core/logger/logger.module'; -import { DockerService } from './docker.service'; import { DockerController } from './docker.controller'; +import { DockerService } from './docker.service'; @Module({ imports: [ diff --git a/src/modules/platform-tools/docker/docker.service.ts b/src/modules/platform-tools/docker/docker.service.ts index 73ad38046..17e694482 100644 --- a/src/modules/platform-tools/docker/docker.service.ts +++ b/src/modules/platform-tools/docker/docker.service.ts @@ -1,7 +1,6 @@ -import * as fs from 'fs-extra'; import * as child_process from 'child_process'; import { Injectable } from '@nestjs/common'; - +import * as fs from 'fs-extra'; import { ConfigService } from '../../../core/config/config.service'; import { Logger } from '../../../core/logger/logger.service'; diff --git a/src/modules/platform-tools/hb-service/hb-service.controller.ts b/src/modules/platform-tools/hb-service/hb-service.controller.ts index d8ee9cab6..1012c9a96 100644 --- a/src/modules/platform-tools/hb-service/hb-service.controller.ts +++ b/src/modules/platform-tools/hb-service/hb-service.controller.ts @@ -1,9 +1,22 @@ -import { Controller, UseGuards, Get, Put, Body, Req, Query } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Put, + Query, + Req, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiQuery, ApiOperation } from '@nestjs/swagger'; +import { + ApiBearerAuth, + ApiOperation, + ApiQuery, + ApiTags +} from '@nestjs/swagger'; import { AdminGuard } from '../../../core/auth/guards/admin.guard'; -import { HbServiceService } from './hb-service.service'; import { HbServiceStartupSettings } from './hb-service.dto'; +import { HbServiceService } from './hb-service.service'; @ApiTags('Platform - HB Service') @ApiBearerAuth() diff --git a/src/modules/platform-tools/hb-service/hb-service.dto.ts b/src/modules/platform-tools/hb-service/hb-service.dto.ts index 626816ef7..ba57258ce 100644 --- a/src/modules/platform-tools/hb-service/hb-service.dto.ts +++ b/src/modules/platform-tools/hb-service/hb-service.dto.ts @@ -1,26 +1,26 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsString, IsBoolean, IsOptional } from 'class-validator'; +import { IsBoolean, IsOptional, IsString } from 'class-validator'; export class HbServiceStartupSettings { @IsBoolean() @ApiProperty({ default: false, required: true }) - HOMEBRIDGE_DEBUG: boolean; + HOMEBRIDGE_DEBUG: boolean; @IsBoolean() @ApiProperty({ default: false, required: true }) - HOMEBRIDGE_KEEP_ORPHANS: boolean; + HOMEBRIDGE_KEEP_ORPHANS: boolean; @IsBoolean() @IsOptional() @ApiProperty({ default: true, required: true }) - HOMEBRIDGE_INSECURE: boolean; + HOMEBRIDGE_INSECURE: boolean; @IsString() @ApiProperty({ required: false }) - ENV_DEBUG?: string; + ENV_DEBUG?: string; @IsString() @IsOptional() @ApiProperty({ required: false }) - ENV_NODE_OPTIONS?: string; + ENV_NODE_OPTIONS?: string; } diff --git a/src/modules/platform-tools/hb-service/hb-service.module.ts b/src/modules/platform-tools/hb-service/hb-service.module.ts index 1478a785c..37fdc5c3b 100644 --- a/src/modules/platform-tools/hb-service/hb-service.module.ts +++ b/src/modules/platform-tools/hb-service/hb-service.module.ts @@ -2,8 +2,8 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; import { ConfigModule } from '../../../core/config/config.module'; import { LoggerModule } from '../../../core/logger/logger.module'; -import { HbServiceService } from './hb-service.service'; import { HbServiceController } from './hb-service.controller'; +import { HbServiceService } from './hb-service.service'; @Module({ imports: [ diff --git a/src/modules/platform-tools/hb-service/hb-service.service.ts b/src/modules/platform-tools/hb-service/hb-service.service.ts index a72c4f412..ae65900ee 100644 --- a/src/modules/platform-tools/hb-service/hb-service.service.ts +++ b/src/modules/platform-tools/hb-service/hb-service.service.ts @@ -1,7 +1,7 @@ -import * as fs from 'fs-extra'; import * as path from 'path'; import * as stream from 'stream'; -import { Injectable, BadRequestException } from '@nestjs/common'; +import { BadRequestException, Injectable } from '@nestjs/common'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../../core/config/config.service'; import { Logger } from '../../../core/logger/logger.service'; diff --git a/src/modules/platform-tools/linux/linux.controller.ts b/src/modules/platform-tools/linux/linux.controller.ts index 0f4455444..0754f389b 100644 --- a/src/modules/platform-tools/linux/linux.controller.ts +++ b/src/modules/platform-tools/linux/linux.controller.ts @@ -1,8 +1,8 @@ -import { Controller, UseGuards, Put } from '@nestjs/common'; +import { Controller, Put, UseGuards } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; -import { LinuxService } from './linux.service'; +import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; import { AdminGuard } from '../../../core/auth/guards/admin.guard'; +import { LinuxService } from './linux.service'; @ApiTags('Platform - Linux') @ApiBearerAuth() diff --git a/src/modules/platform-tools/linux/linux.module.ts b/src/modules/platform-tools/linux/linux.module.ts index cfa36de72..20189f212 100644 --- a/src/modules/platform-tools/linux/linux.module.ts +++ b/src/modules/platform-tools/linux/linux.module.ts @@ -2,8 +2,8 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; import { ConfigModule } from '../../../core/config/config.module'; import { LoggerModule } from '../../../core/logger/logger.module'; -import { LinuxService } from './linux.service'; import { LinuxController } from './linux.controller'; +import { LinuxService } from './linux.service'; @Module({ imports: [ diff --git a/src/modules/platform-tools/platform-tools.module.ts b/src/modules/platform-tools/platform-tools.module.ts index a8514c64b..0d4e4c9bd 100644 --- a/src/modules/platform-tools/platform-tools.module.ts +++ b/src/modules/platform-tools/platform-tools.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; -import { LinuxModule } from './linux/linux.module'; import { DockerModule } from './docker/docker.module'; -import { TerminalModule } from './terminal/terminal.module'; import { HbServiceModule } from './hb-service/hb-service.module'; +import { LinuxModule } from './linux/linux.module'; +import { TerminalModule } from './terminal/terminal.module'; @Module({ imports: [ diff --git a/src/modules/platform-tools/terminal/terminal.gateway.ts b/src/modules/platform-tools/terminal/terminal.gateway.ts index e1f9cb473..588e9cbdb 100644 --- a/src/modules/platform-tools/terminal/terminal.gateway.ts +++ b/src/modules/platform-tools/terminal/terminal.gateway.ts @@ -1,8 +1,7 @@ -import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; import { UseGuards } from '@nestjs/common'; - +import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; import { WsAdminGuard } from '../../../core/auth/guards/ws-admin-guard'; -import { TerminalService, WsEventEmitter, TermSize } from './terminal.service'; +import { TermSize, TerminalService, WsEventEmitter } from './terminal.service'; @UseGuards(WsAdminGuard) @WebSocketGateway({ diff --git a/src/modules/platform-tools/terminal/terminal.module.ts b/src/modules/platform-tools/terminal/terminal.module.ts index 6bb8e92d9..5a9ea7640 100644 --- a/src/modules/platform-tools/terminal/terminal.module.ts +++ b/src/modules/platform-tools/terminal/terminal.module.ts @@ -1,11 +1,10 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - -import { TerminalService } from './terminal.service'; -import { TerminalGateway } from './terminal.gateway'; import { ConfigModule } from '../../../core/config/config.module'; import { LoggerModule } from '../../../core/logger/logger.module'; import { NodePtyModule } from '../../../core/node-pty/node-pty.module'; +import { TerminalGateway } from './terminal.gateway'; +import { TerminalService } from './terminal.service'; @Module({ imports: [ diff --git a/src/modules/platform-tools/terminal/terminal.service.ts b/src/modules/platform-tools/terminal/terminal.service.ts index 61fb4ea25..f114db264 100644 --- a/src/modules/platform-tools/terminal/terminal.service.ts +++ b/src/modules/platform-tools/terminal/terminal.service.ts @@ -1,17 +1,12 @@ import { EventEmitter } from 'events'; -import * as fs from 'fs-extra'; import { Injectable } from '@nestjs/common'; - +import * as fs from 'fs-extra'; import { ConfigService } from '../../../core/config/config.service'; import { Logger } from '../../../core/logger/logger.service'; import { NodePtyService } from '../../../core/node-pty/node-pty.service'; export type TermSize = { cols: number; rows: number }; -export interface WsEventEmitter extends EventEmitter { - disconnect: () => void; -} - @Injectable() export class TerminalService { private ending = false; @@ -97,3 +92,7 @@ export class TerminalService { client.on('disconnect', onEnd.bind(this)); } } + +export interface WsEventEmitter extends EventEmitter { + disconnect: () => void; +} diff --git a/src/modules/plugins/plugins.controller.ts b/src/modules/plugins/plugins.controller.ts index ba632e2a3..e4645863f 100644 --- a/src/modules/plugins/plugins.controller.ts +++ b/src/modules/plugins/plugins.controller.ts @@ -1,8 +1,18 @@ -import { Controller, Get, Param, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Param, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiParam, ApiOperation } from '@nestjs/swagger'; -import { PluginsService } from './plugins.service'; +import { + ApiBearerAuth, + ApiOperation, + ApiParam, + ApiTags +} from '@nestjs/swagger'; import { AdminGuard } from '../../core/auth/guards/admin.guard'; +import { PluginsService } from './plugins.service'; @ApiTags('Plugins') @ApiBearerAuth() diff --git a/src/modules/plugins/plugins.dto.ts b/src/modules/plugins/plugins.dto.ts index c243d8db3..1f053629b 100644 --- a/src/modules/plugins/plugins.dto.ts +++ b/src/modules/plugins/plugins.dto.ts @@ -1,35 +1,42 @@ -import { IsDefined, IsNotEmpty, IsNumber, IsOptional, IsString, Matches } from 'class-validator'; - -export class PluginActionDto { - @IsDefined() - @IsNotEmpty() - @IsString() - @Matches(/^((@[\w-]*)\/)?(homebridge-[\w-]*)$/) - name: string; +import { + IsDefined, + IsNotEmpty, + IsNumber, + IsOptional, + IsString, + Matches +} from 'class-validator'; +export class HomebridgeUpdateActionDto { @IsOptional() @IsString() - version?: string; + version?: string; @IsOptional() @IsNumber() - termCols?: number; + termCols?: number; @IsOptional() @IsNotEmpty() - termRows?: number; + termRows?: number; } -export class HomebridgeUpdateActionDto { +export class PluginActionDto { + @IsDefined() + @IsNotEmpty() + @IsString() + @Matches(/^((@[\w-]*)\/)?(homebridge-[\w-]*)$/) + name: string; + @IsOptional() @IsString() - version?: string; + version?: string; @IsOptional() @IsNumber() - termCols?: number; + termCols?: number; @IsOptional() @IsNotEmpty() - termRows?: number; + termRows?: number; } diff --git a/src/modules/plugins/plugins.gateway.ts b/src/modules/plugins/plugins.gateway.ts index 3f2ecbab9..8c85b5277 100644 --- a/src/modules/plugins/plugins.gateway.ts +++ b/src/modules/plugins/plugins.gateway.ts @@ -2,11 +2,10 @@ import { EventEmitter } from 'events'; import { UseGuards, UsePipes, ValidationPipe } from '@nestjs/common'; import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; import * as color from 'bash-color'; - -import { PluginsService } from './plugins.service'; -import { PluginActionDto, HomebridgeUpdateActionDto } from './plugins.dto'; -import { Logger } from '../../core/logger/logger.service'; import { WsAdminGuard } from '../../core/auth/guards/ws-admin-guard'; +import { Logger } from '../../core/logger/logger.service'; +import { HomebridgeUpdateActionDto, PluginActionDto } from './plugins.dto'; +import { PluginsService } from './plugins.service'; @UseGuards(WsAdminGuard) @WebSocketGateway({ diff --git a/src/modules/plugins/plugins.module.ts b/src/modules/plugins/plugins.module.ts index c2f78e9bc..0e525e4d5 100644 --- a/src/modules/plugins/plugins.module.ts +++ b/src/modules/plugins/plugins.module.ts @@ -1,14 +1,13 @@ import * as https from 'https'; -import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; +import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - -import { PluginsService } from './plugins.service'; +import { ConfigModule } from '../../core/config/config.module'; import { LoggerModule } from '../../core/logger/logger.module'; +import { NodePtyModule } from '../../core/node-pty/node-pty.module'; import { PluginsController } from './plugins.controller'; import { PluginsGateway } from './plugins.gateway'; -import { ConfigModule } from '../../core/config/config.module'; -import { NodePtyModule } from '../../core/node-pty/node-pty.module'; +import { PluginsService } from './plugins.service'; @Module({ imports: [ diff --git a/src/modules/plugins/plugins.service.ts b/src/modules/plugins/plugins.service.ts index bfcb2af7a..2328984b3 100755 --- a/src/modules/plugins/plugins.service.ts +++ b/src/modules/plugins/plugins.service.ts @@ -1,23 +1,32 @@ +import * as child_process from 'child_process'; import { EventEmitter } from 'events'; -import { Injectable, NotFoundException, InternalServerErrorException, BadRequestException } from '@nestjs/common'; -import { HttpService } from '@nestjs/axios'; -import { HomebridgePlugin, IPackageJson, INpmSearchResults, INpmRegistryModule } from './types'; -import { HomebridgePluginVersions, HomebridgePluginUiMetadata, PluginAlias } from './types'; -import axios from 'axios'; import * as os from 'os'; -import * as _ from 'lodash'; import * as path from 'path'; -import * as fs from 'fs-extra'; -import * as child_process from 'child_process'; -import * as semver from 'semver'; +import { HttpService } from '@nestjs/axios'; +import { + BadRequestException, + Injectable, + InternalServerErrorException, + NotFoundException +} from '@nestjs/common'; +import axios from 'axios'; import * as color from 'bash-color'; +import * as fs from 'fs-extra'; +import * as _ from 'lodash'; import * as NodeCache from 'node-cache'; import * as pLimit from 'p-limit'; - -import { Logger } from '../../core/logger/logger.service'; +import * as semver from 'semver'; import { ConfigService, HomebridgeConfig } from '../../core/config/config.service'; +import { Logger } from '../../core/logger/logger.service'; import { NodePtyService } from '../../core/node-pty/node-pty.service'; import { HomebridgeUpdateActionDto, PluginActionDto } from './plugins.dto'; +import { + HomebridgePlugin, + INpmRegistryModule, + INpmSearchResults, + IPackageJson +} from './types'; +import { HomebridgePluginUiMetadata, HomebridgePluginVersions, PluginAlias } from './types'; @Injectable() export class PluginsService { @@ -257,7 +266,7 @@ export class PluginsService { && (query.indexOf('homebridge-') === 0 || this.isScopedPlugin(query)) && !this.searchResultBlacklist.includes(query.toLowerCase()) ) { - return await this.searchNpmRegistrySingle(query.toLowerCase()); + return this.searchNpmRegistrySingle(query.toLowerCase()); } return _.orderBy(result, ['verifiedPlugin'], ['desc']); @@ -446,7 +455,7 @@ export class PluginsService { if (this.configService.ui.homebridgePackagePath) { const pjsonPath = path.join(this.configService.ui.homebridgePackagePath, 'package.json'); if (await fs.pathExists(pjsonPath)) { - return await this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath); + return this.parsePackageJson(await fs.readJson(pjsonPath), this.configService.ui.homebridgePackagePath); } else { this.logger.error(`"homebridgePath" (${this.configService.ui.homebridgePackagePath}) does not exist`); } @@ -499,10 +508,10 @@ export class PluginsService { semver.gt(homebridge.installedVersion, homebridge.latestVersion) ) { const versions = await this.getAvailablePluginVersions('homebridge'); - if (versions.tags['beta'] && semver.gt(versions.tags['beta'], homebridge.installedVersion)) { + if (versions.tags.beta && semver.gt(versions.tags.beta, homebridge.installedVersion)) { homebridge.updateAvailable = false; homebridge.betaUpdateAvailable = true; - homebridge.latestVersion = versions.tags['beta']; + homebridge.latestVersion = versions.tags.beta; } } @@ -714,7 +723,7 @@ export class PluginsService { const schemaPath = path.resolve(plugin.installPath, pluginName, 'config.schema.json'); if (this.miscSchemas[pluginName] && !await fs.pathExists(schemaPath)) { - return await fs.readJson(this.miscSchemas[pluginName]); + return fs.readJson(this.miscSchemas[pluginName]); } let configSchema = await fs.readJson(schemaPath); @@ -1223,9 +1232,9 @@ export class PluginsService { semver.gt(plugin.installedVersion, plugin.latestVersion) ) { const versions = await this.getAvailablePluginVersions(plugin.name); - if (versions.tags['beta'] && semver.gt(versions.tags['beta'], plugin.installedVersion)) { + if (versions.tags.beta && semver.gt(versions.tags.beta, plugin.installedVersion)) { plugin.betaUpdateAvailable = true; - plugin.latestVersion = versions.tags['beta']; + plugin.latestVersion = versions.tags.beta; } } } diff --git a/src/modules/plugins/types.d.ts b/src/modules/plugins/types.d.ts index 44ed7604a..7610da543 100644 --- a/src/modules/plugins/types.d.ts +++ b/src/modules/plugins/types.d.ts @@ -26,42 +26,18 @@ export interface HomebridgePlugin { funding?: NpmFunding; } +export type HomebridgePluginUiMetadata = { + devServer: null | string; + publicPath: string; + serverPath: string; + plugin: HomebridgePlugin; +}; + export interface HomebridgePluginVersions { tags: Record; versions: Array; } -export interface IPackageJson { - name: string; - displayName?: string; - version?: string; - description?: string; - keywords?: string[]; - homepage?: string; - bugs?: string | { email?: string; url?: string }; - license?: string; - author?: string | INpmPerson; - maintainers?: INpmPerson[]; - contributors?: string[] | INpmPerson[]; - funding?: NpmFunding; - files?: string[]; - main?: string; - bin?: string | { [key: string]: string }; - repository?: string | { type: string; url: string }; - scripts?: { [key: string]: string }; - dependencies?: { [key: string]: string }; - devDependencies?: { [key: string]: string }; - peerDependencies?: { [key: string]: string }; - optionalDependencies?: { [key: string]: string }; - bundledDependencies?: string[]; - engines?: { [key: string]: string }; - os?: string[]; - cpu?: string[]; - preferGlobal?: boolean; - private?: boolean; - publishConfig?: { registry?: string }; -} - export interface INpmPerson { name?: string; email?: string; @@ -70,6 +46,34 @@ export interface INpmPerson { url?: string; } +export interface INpmRegistryModule { + _id: string; + _rev: string; + name: string; + 'dist-tags': { + latest: string; + [key: string]: string; + }; + versions: { + [key: string]: IPackageJson; + }; + time: { + created: string; + modified: string; + [key: string]: string; + }; + maintainers: INpmPerson[]; + description: string; + homepage: string; + keywords: string[]; + repository: { type: string; url: string }; + author: INpmPerson; + bugs: { email?: string; url?: string }; + license: string; + readme: string; + readmeFilename: string; +} + export interface INpmSearchResultItem { package: { name: string; @@ -102,46 +106,42 @@ export interface INpmSearchResultItem { searchScore: number; } -export interface INpmRegistryModule { - _id: string; - _rev: string; - name: string; - 'dist-tags': { - latest: string; - [key: string]: string; - }; - versions: { - [key: string]: IPackageJson; - }; - time: { - created: string; - modified: string; - [key: string]: string; - }; - maintainers: INpmPerson[]; - description: string; - homepage: string; - keywords: string[]; - repository: { type: string; url: string }; - author: INpmPerson; - bugs: { email?: string; url?: string }; - license: string; - readme: string; - readmeFilename: string; -} - export interface INpmSearchResults { objects: INpmSearchResultItem[]; } -export type NpmFunding = { type: string; url: string } | string | Array<{ type: string; url: string } | string>; +export interface IPackageJson { + name: string; + displayName?: string; + version?: string; + description?: string; + keywords?: string[]; + homepage?: string; + bugs?: string | { email?: string; url?: string }; + license?: string; + author?: string | INpmPerson; + maintainers?: INpmPerson[]; + contributors?: string[] | INpmPerson[]; + funding?: NpmFunding; + files?: string[]; + main?: string; + bin?: string | { [key: string]: string }; + repository?: string | { type: string; url: string }; + scripts?: { [key: string]: string }; + dependencies?: { [key: string]: string }; + devDependencies?: { [key: string]: string }; + peerDependencies?: { [key: string]: string }; + optionalDependencies?: { [key: string]: string }; + bundledDependencies?: string[]; + engines?: { [key: string]: string }; + os?: string[]; + cpu?: string[]; + preferGlobal?: boolean; + private?: boolean; + publishConfig?: { registry?: string }; +} -export type HomebridgePluginUiMetadata = { - devServer: null | string; - publicPath: string; - serverPath: string; - plugin: HomebridgePlugin; -}; +export type NpmFunding = { type: string; url: string } | string | Array<{ type: string; url: string } | string>; export type PluginAlias = { pluginAlias: null | string; diff --git a/src/modules/server/server.controller.ts b/src/modules/server/server.controller.ts index 8af1a235a..13586dc01 100644 --- a/src/modules/server/server.controller.ts +++ b/src/modules/server/server.controller.ts @@ -1,11 +1,26 @@ -import { Controller, Get, UseGuards, Put, Delete, Param, HttpCode, Body, Query } from '@nestjs/common'; +import { + Body, + Controller, + Delete, + Get, + HttpCode, + Param, + Put, + Query, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiParam, ApiOperation, ApiQuery } from '@nestjs/swagger'; - +import { + ApiBearerAuth, + ApiOperation, + ApiParam, + ApiQuery, + ApiTags +} from '@nestjs/swagger'; import { AdminGuard } from '../../core/auth/guards/admin.guard'; import { ChildBridgesService } from '../child-bridges/child-bridges.service'; -import { ServerService } from './server.service'; import { HomebridgeMdnsSettingDto, HomebridgeNetworkInterfacesDto } from './server.dto'; +import { ServerService } from './server.service'; @ApiTags('Homebridge') @ApiBearerAuth() diff --git a/src/modules/server/server.dto.ts b/src/modules/server/server.dto.ts index b8e4eaaf4..bbbe4585a 100644 --- a/src/modules/server/server.dto.ts +++ b/src/modules/server/server.dto.ts @@ -1,17 +1,22 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsArray, IsDefined, IsIn, IsString } from 'class-validator'; - -export class HomebridgeNetworkInterfacesDto { - @IsArray() - @IsString({ each: true }) - @ApiProperty() - adapters: string[]; -} +import { + IsArray, + IsDefined, + IsIn, + IsString +} from 'class-validator'; export class HomebridgeMdnsSettingDto { @IsString() @IsDefined() @IsIn(['avahi', 'resolved', 'ciao', 'bonjour-hap']) @ApiProperty() - advertiser: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; + advertiser: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; +} + +export class HomebridgeNetworkInterfacesDto { + @IsArray() + @IsString({ each: true }) + @ApiProperty() + adapters: string[]; } diff --git a/src/modules/server/server.module.ts b/src/modules/server/server.module.ts index 5b1ff4c72..155d5491f 100644 --- a/src/modules/server/server.module.ts +++ b/src/modules/server/server.module.ts @@ -1,14 +1,13 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - import { ConfigModule } from '../../core/config/config.module'; -import { LoggerModule } from '../../core/logger/logger.module'; import { HomebridgeIpcModule } from '../../core/homebridge-ipc/homebridge-ipc.module'; -import { ConfigEditorModule } from '../config-editor/config-editor.module'; -import { ChildBridgesModule } from '../child-bridges/child-bridges.module'; +import { LoggerModule } from '../../core/logger/logger.module'; import { AccessoriesModule } from '../accessories/accessories.module'; -import { ServerService } from './server.service'; +import { ChildBridgesModule } from '../child-bridges/child-bridges.module'; +import { ConfigEditorModule } from '../config-editor/config-editor.module'; import { ServerController } from './server.controller'; +import { ServerService } from './server.service'; @Module({ imports: [ diff --git a/src/modules/server/server.service.ts b/src/modules/server/server.service.ts index 3e7bd0eaf..55ee36e80 100644 --- a/src/modules/server/server.service.ts +++ b/src/modules/server/server.service.ts @@ -1,18 +1,23 @@ -import * as fs from 'fs-extra'; +import * as child_process from 'child_process'; import * as path from 'path'; +import { + BadRequestException, + Injectable, + InternalServerErrorException, + NotFoundException, + ServiceUnavailableException +} from '@nestjs/common'; +import { Categories } from '@oznu/hap-client/dist/hap-types'; import * as bufferShim from 'buffer-shims'; -import * as si from 'systeminformation'; +import * as fs from 'fs-extra'; import * as NodeCache from 'node-cache'; -import * as child_process from 'child_process'; +import * as si from 'systeminformation'; import * as tcpPortUsed from 'tcp-port-used'; -import { Injectable, NotFoundException, BadRequestException, ServiceUnavailableException, InternalServerErrorException } from '@nestjs/common'; -import { Categories } from '@oznu/hap-client/dist/hap-types'; - -import { Logger } from '../../core/logger/logger.service'; import { ConfigService, HomebridgeConfig } from '../../core/config/config.service'; import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service'; -import { ConfigEditorService } from '../config-editor/config-editor.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() @@ -103,7 +108,7 @@ export class ServerService { .filter(x => x.match(/AccessoryInfo\.([A-F,a-f,0-9]+)\.json/)); return Promise.all(devices.map(async (x) => { - return await this.getDevicePairingById(x.split('.')[1]); + return this.getDevicePairingById(x.split('.')[1]); })); } @@ -256,10 +261,10 @@ export class ServerService { try { this.logger.log('Clearing Cached Homebridge Accessories...'); - for (const cachedAccessoriesPath of cachedAccessoryPaths) { - if (await fs.pathExists(cachedAccessoriesPath)) { - await fs.unlink(cachedAccessoriesPath); - this.logger.warn(`Removed ${cachedAccessoriesPath}`); + for (const thisCachedAccessoriesPath of cachedAccessoryPaths) { + if (await fs.pathExists(thisCachedAccessoriesPath)) { + await fs.unlink(thisCachedAccessoriesPath); + this.logger.warn(`Removed ${thisCachedAccessoriesPath}`); } } } catch (e) { diff --git a/src/modules/setup-wizard/setup-wizard.controller.ts b/src/modules/setup-wizard/setup-wizard.controller.ts index 0f1714ad7..af49162b5 100644 --- a/src/modules/setup-wizard/setup-wizard.controller.ts +++ b/src/modules/setup-wizard/setup-wizard.controller.ts @@ -1,8 +1,13 @@ -import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Post, + UseGuards +} from '@nestjs/common'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; - -import { UserDto } from '../users/users.dto'; import { AuthService } from '../../core/auth/auth.service'; +import { UserDto } from '../users/users.dto'; import { SetupWizardGuard } from './setup-wizard.guard'; @ApiTags('Setup Wizard') @@ -19,7 +24,7 @@ export class SetupWizardController { description: 'This endpoint is not available after the Homebridge setup wizard is complete.', }) async setupFirstUser(@Body() body: UserDto) { - return await this.authService.setupFirstUser(body); + return this.authService.setupFirstUser(body); } @Get('/get-setup-wizard-token') @@ -28,6 +33,6 @@ export class SetupWizardController { description: 'This endpoint is not available after the Homebridge setup wizard is complete.', }) async generateSetupWizardToken() { - return await this.authService.generateSetupWizardToken(); + return this.authService.generateSetupWizardToken(); } } diff --git a/src/modules/setup-wizard/setup-wizard.gateway.ts b/src/modules/setup-wizard/setup-wizard.gateway.ts index a065a4c66..7d27f5cc0 100644 --- a/src/modules/setup-wizard/setup-wizard.gateway.ts +++ b/src/modules/setup-wizard/setup-wizard.gateway.ts @@ -1,10 +1,9 @@ -import * as color from 'bash-color'; import { EventEmitter } from 'events'; import { UseGuards } from '@nestjs/common'; -import { WebSocketGateway, SubscribeMessage, WsException } from '@nestjs/websockets'; - -import { Logger } from '../../core/logger/logger.service'; +import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; +import * as color from 'bash-color'; import { WsAdminGuard } from '../../core/auth/guards/ws-admin-guard'; +import { Logger } from '../../core/logger/logger.service'; import { BackupService } from '../backup/backup.service'; @UseGuards(WsAdminGuard) diff --git a/src/modules/setup-wizard/setup-wizard.guard.ts b/src/modules/setup-wizard/setup-wizard.guard.ts index 8cfda4786..076633148 100644 --- a/src/modules/setup-wizard/setup-wizard.guard.ts +++ b/src/modules/setup-wizard/setup-wizard.guard.ts @@ -1,6 +1,5 @@ import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; import { Observable } from 'rxjs'; - import { ConfigService } from '../../core/config/config.service'; @Injectable() diff --git a/src/modules/setup-wizard/setup-wizard.module.ts b/src/modules/setup-wizard/setup-wizard.module.ts index 8a0c83835..e8289cdaf 100644 --- a/src/modules/setup-wizard/setup-wizard.module.ts +++ b/src/modules/setup-wizard/setup-wizard.module.ts @@ -1,9 +1,8 @@ import { Module } from '@nestjs/common'; - -import { SetupWizardController } from './setup-wizard.controller'; import { AuthModule } from '../../core/auth/auth.module'; -import { LoggerModule } from '../../core/logger/logger.module'; import { ConfigModule } from '../../core/config/config.module'; +import { LoggerModule } from '../../core/logger/logger.module'; +import { SetupWizardController } from './setup-wizard.controller'; @Module({ imports: [ diff --git a/src/modules/status/status.controller.ts b/src/modules/status/status.controller.ts index fb1da2360..bce4ae15a 100644 --- a/src/modules/status/status.controller.ts +++ b/src/modules/status/status.controller.ts @@ -1,9 +1,8 @@ -import { Controller, UseGuards, Get } from '@nestjs/common'; +import { Controller, Get, UseGuards } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; - -import { StatusService } from './status.service'; +import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger'; import { ChildBridgesService } from '../child-bridges/child-bridges.service'; +import { StatusService } from './status.service'; @ApiTags('Server Status') @ApiBearerAuth() diff --git a/src/modules/status/status.gateway.ts b/src/modules/status/status.gateway.ts index 44c2df2e6..3e6cc7ddb 100644 --- a/src/modules/status/status.gateway.ts +++ b/src/modules/status/status.gateway.ts @@ -1,10 +1,9 @@ import { UseGuards } from '@nestjs/common'; import { SubscribeMessage, WebSocketGateway, WsException } from '@nestjs/websockets'; - -import { PluginsService } from '../plugins/plugins.service'; -import { StatusService } from './status.service'; import { WsGuard } from '../../core/auth/guards/ws.guard'; import { ChildBridgesService } from '../child-bridges/child-bridges.service'; +import { PluginsService } from '../plugins/plugins.service'; +import { StatusService } from './status.service'; @UseGuards(WsGuard) @WebSocketGateway({ diff --git a/src/modules/status/status.module.ts b/src/modules/status/status.module.ts index 335920c96..f12c5ca05 100644 --- a/src/modules/status/status.module.ts +++ b/src/modules/status/status.module.ts @@ -1,16 +1,15 @@ -import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; +import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - -import { PluginsModule } from '../plugins/plugins.module'; import { ConfigModule } from '../../core/config/config.module'; -import { LoggerModule } from '../../core/logger/logger.module'; import { HomebridgeIpcModule } from '../../core/homebridge-ipc/homebridge-ipc.module'; +import { LoggerModule } from '../../core/logger/logger.module'; import { ChildBridgesModule } from '../child-bridges/child-bridges.module'; +import { PluginsModule } from '../plugins/plugins.module'; import { ServerModule } from '../server/server.module'; -import { StatusService } from './status.service'; -import { StatusGateway } from './status.gateway'; import { StatusController } from './status.controller'; +import { StatusGateway } from './status.gateway'; +import { StatusService } from './status.service'; @Module({ imports: [ diff --git a/src/modules/status/status.service.ts b/src/modules/status/status.service.ts index 54faae533..14f48ebfb 100644 --- a/src/modules/status/status.service.ts +++ b/src/modules/status/status.service.ts @@ -1,18 +1,17 @@ +import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import * as child_process from 'child_process'; import * as util from 'util'; +import { HttpService } from '@nestjs/axios'; +import { BadRequestException, Injectable } from '@nestjs/common'; import * as fs from 'fs-extra'; -import * as si from 'systeminformation'; -import * as semver from 'semver'; import * as NodeCache from 'node-cache'; import { Subject, Subscription } from 'rxjs'; -import { Injectable, BadRequestException } from '@nestjs/common'; -import { HttpService } from '@nestjs/axios'; - -import { Logger } from '../../core/logger/logger.service'; +import * as semver from 'semver'; +import * as si from 'systeminformation'; import { ConfigService } from '../../core/config/config.service'; import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service'; +import { Logger } from '../../core/logger/logger.service'; import { PluginsService } from '../plugins/plugins.service'; import { ServerService } from '../server/server.service'; @@ -178,11 +177,11 @@ export class StatusService { const net = await si.networkStats(defaultInterfaceName); // TODO: be able to specify in the ui the unit size (i.e. bytes, megabytes, gigabytes) - const tx_rx_sec = (net[0].tx_sec + net[0].rx_sec) / 1024 / 1024; + const txRxSec = (net[0].tx_sec + net[0].rx_sec) / 1024 / 1024; // TODO: break out the sent and received figures to two separate stacked graphs - // (these should ideally be positive/negative mirrored linecharts) - return { net: net[0], point: tx_rx_sec }; + // (these should ideally be positive/negative mirrored line charts) + return { net: net[0], point: txRxSec }; } /** @@ -452,7 +451,7 @@ export class StatusService { } /** - * Returns infomation about the current state of the Raspberry Pi + * Returns information about the current state of the Raspberry Pi */ public async getRaspberryPiThrottledStatus() { if (!this.configService.runningOnRaspberryPi) { diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index e51eaf499..fe18cdbf5 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -1,9 +1,32 @@ -import { Controller, UseGuards, Body, Post, Get, Param, Delete, Patch, ParseIntPipe, Req } from '@nestjs/common'; +import { + Body, + Controller, + Delete, + Get, + Param, + ParseIntPipe, + Patch, + Post, + Req, + UseGuards +} from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { ApiTags, ApiBearerAuth, ApiBody, ApiResponse, ApiOperation, ApiParam } from '@nestjs/swagger'; +import { + ApiBearerAuth, + ApiBody, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags +} from '@nestjs/swagger'; import { AuthService } from '../../core/auth/auth.service'; import { AdminGuard } from '../../core/auth/guards/admin.guard'; -import { UserDto, UserUpdatePasswordDto, UserActivateOtpDto, UserDeactivateOtpDto } from './users.dto'; +import { + UserActivateOtpDto, + UserDeactivateOtpDto, + UserDto, + UserUpdatePasswordDto +} from './users.dto'; @ApiTags('User Management') @ApiBearerAuth() diff --git a/src/modules/users/users.dto.ts b/src/modules/users/users.dto.ts index 20268938c..17d201287 100644 --- a/src/modules/users/users.dto.ts +++ b/src/modules/users/users.dto.ts @@ -1,68 +1,76 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsString, IsNumber, IsNotEmpty, IsBoolean, IsOptional, Equals, IsDefined } from 'class-validator'; +import { + Equals, + IsBoolean, + IsDefined, + IsNotEmpty, + IsNumber, + IsOptional, + IsString +} from 'class-validator'; + +export class UserActivateOtpDto { + @IsString() + @IsNotEmpty() + @ApiProperty() + code: string; +} + +export class UserDeactivateOtpDto { + @IsString() + @IsNotEmpty() + @ApiProperty() + password: string; +} export class UserDto { @IsNumber() @ApiProperty({ readOnly: true }) - id?: number; + id?: number; @IsString() @IsNotEmpty() @IsDefined() @ApiProperty() - name: string; + name: string; @IsString() @IsNotEmpty() @IsDefined() @ApiProperty() - username: string; + username: string; @ApiProperty() @IsBoolean() - admin: boolean; + admin: boolean; @IsString() @IsOptional() @ApiProperty({ writeOnly: true }) - password?: string; + password?: string; @Equals(undefined) - hashedPassword?: string; + hashedPassword?: string; @Equals(undefined) - salt?: string; + salt?: string; @Equals(undefined) - otpSecret?: string; + otpSecret?: string; @Equals(undefined) @ApiProperty({ readOnly: true }) - otpActive?: boolean; + otpActive?: boolean; } export class UserUpdatePasswordDto { @IsString() @IsNotEmpty() @ApiProperty() - currentPassword: string; + currentPassword: string; @IsString() @IsNotEmpty() @ApiProperty() - newPassword: string; -} - -export class UserActivateOtpDto { - @IsString() - @IsNotEmpty() - @ApiProperty() - code: string; -} - -export class UserDeactivateOtpDto { - @IsString() - @IsNotEmpty() - @ApiProperty() - password: string; + newPassword: string; } diff --git a/src/modules/users/users.module.ts b/src/modules/users/users.module.ts index 9aad9c295..d23e6b796 100644 --- a/src/modules/users/users.module.ts +++ b/src/modules/users/users.module.ts @@ -1,10 +1,9 @@ import { Module } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; - -import { UsersController } from './users.controller'; +import { AuthModule } from '../../core/auth/auth.module'; import { ConfigModule } from '../../core/config/config.module'; import { LoggerModule } from '../../core/logger/logger.module'; -import { AuthModule } from '../../core/auth/auth.module'; +import { UsersController } from './users.controller'; @Module({ imports: [ diff --git a/src/self-check.ts b/src/self-check.ts index 4fc6e7fa0..6c3456cfa 100644 --- a/src/self-check.ts +++ b/src/self-check.ts @@ -1,18 +1,48 @@ /** - * Pollyfill for Node.js 11.x that does not support `globalThis` + * Polyfill for Node.js 11.x that does not support `globalThis` * This should be removed when support for < Node.js 12 is dropped */ if (!global.globalThis && (process.versions.modules === '67' || process.versions.modules === '64')) { (global as any).globalThis = global; } +import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; -import * as child_process from 'child_process'; import { Logger } from './core/logger/logger.service'; const logger = new Logger(); +function tryRebuildNodePtyModule() { + // using eval('require') here so it does not break with webpack + const modulePath = path.dirname(path.dirname(eval('require').resolve('@homebridge/node-pty-prebuilt-multiarch'))); + + logger.warn('[node-pty] Trying to rebuild automatically...'); + logger.warn(`[node-pty] Path: ${modulePath}`); + try { + if (process.env.UIX_USE_PNPM === '1' && process.env.UIX_CUSTOM_PLUGIN_PATH) { + child_process.execSync('pnpm rebuild @homebridge/node-pty-prebuilt-multiarch', { + cwd: process.env.UIX_CUSTOM_PLUGIN_PATH, + stdio: 'ignore', + }); + } else { + child_process.execSync('npm run install --unsafe-perm', { + cwd: modulePath, + stdio: 'ignore', + }); + } + } catch (e) { + if (os.platform() !== 'win32') { + child_process.execSync('sudo -E -n run install --unsafe-perm', { + cwd: modulePath, + stdio: 'ignore', + }); + } else { + throw e; + } + } +} + /** * The purpose of this script is to check the environment before launching the UI */ @@ -66,36 +96,6 @@ function main() { } -function tryRebuildNodePtyModule() { - // using eval('require') here so it does not break with webpack - const modulePath = path.dirname(path.dirname(eval('require').resolve('@homebridge/node-pty-prebuilt-multiarch'))); - - logger.warn('[node-pty] Trying to rebuild automatically...'); - logger.warn(`[node-pty] Path: ${modulePath}`); - try { - if (process.env.UIX_USE_PNPM === '1' && process.env.UIX_CUSTOM_PLUGIN_PATH) { - child_process.execSync('pnpm rebuild @homebridge/node-pty-prebuilt-multiarch', { - cwd: process.env.UIX_CUSTOM_PLUGIN_PATH, - stdio: 'ignore', - }); - } else { - child_process.execSync('npm run install --unsafe-perm', { - cwd: modulePath, - stdio: 'ignore', - }); - } - } catch (e) { - if (os.platform() !== 'win32') { - child_process.execSync('sudo -E -n run install --unsafe-perm', { - cwd: modulePath, - stdio: 'ignore', - }); - } else { - throw e; - } - } -} - main(); /** diff --git a/test/e2e/accessories.e2e-spec.ts b/test/e2e/accessories.e2e-spec.ts index 0df73c1d6..c05af9c42 100644 --- a/test/e2e/accessories.e2e-spec.ts +++ b/test/e2e/accessories.e2e-spec.ts @@ -1,12 +1,11 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; -import { AccessoriesModule } from '../../src/modules/accessories/accessories.module'; import { ConfigService } from '../../src/core/config/config.service'; +import { AccessoriesModule } from '../../src/modules/accessories/accessories.module'; import { AccessoriesService } from '../../src/modules/accessories/accessories.service'; describe('AccessoriesController (e2e)', () => { diff --git a/test/e2e/app.e2e-spec.ts b/test/e2e/app.e2e-spec.ts index fdf39a3c2..c8fda035b 100644 --- a/test/e2e/app.e2e-spec.ts +++ b/test/e2e/app.e2e-spec.ts @@ -1,9 +1,8 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { Test, TestingModule } from '@nestjs/testing'; import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AppModule } from '../../src/app.module'; describe('AppController (e2e)', () => { diff --git a/test/e2e/auth.e2e-spec.ts b/test/e2e/auth.e2e-spec.ts index 900a4043c..1cba8313b 100644 --- a/test/e2e/auth.e2e-spec.ts +++ b/test/e2e/auth.e2e-spec.ts @@ -1,12 +1,11 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; -import { ConfigService } from '../../src/core/config/config.service'; import { AuthService } from '../../src/core/auth/auth.service'; +import { ConfigService } from '../../src/core/config/config.service'; describe('AuthController (e2e)', () => { let app: NestFastifyApplication; @@ -58,8 +57,8 @@ describe('AuthController (e2e)', () => { afterEach(async () => { // restore auth mode after each test - const configService: ConfigService = app.get(ConfigService); - configService.ui.auth = 'form'; + const thisConfigService: ConfigService = app.get(ConfigService); + thisConfigService.ui.auth = 'form'; }); it('should .uix-secrets on launch', async () => { @@ -147,8 +146,8 @@ describe('AuthController (e2e)', () => { it('POST /auth/noauth (auth disabled)', async () => { // set auth mode to none - const configService: ConfigService = app.get(ConfigService); - configService.ui.auth = 'none'; + const thisConfigService: ConfigService = app.get(ConfigService); + thisConfigService.ui.auth = 'none'; const res = await app.inject({ method: 'POST', diff --git a/test/e2e/backup.e2e-spec.ts b/test/e2e/backup.e2e-spec.ts index e50fb3e59..99c35eeec 100644 --- a/test/e2e/backup.e2e-spec.ts +++ b/test/e2e/backup.e2e-spec.ts @@ -1,20 +1,19 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; -import * as dayjs from 'dayjs'; import { EventEmitter } from 'events'; +import * as path from 'path'; +import fastifyMultipart from '@fastify/multipart'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; -import fastifyMultipart from '@fastify/multipart'; +import { Test, TestingModule } from '@nestjs/testing'; +import * as dayjs from 'dayjs'; import * as FormData from 'form-data'; - +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; +import { ConfigService } from '../../src/core/config/config.service'; +import { SchedulerService } from '../../src/core/scheduler/scheduler.service'; +import { BackupGateway } from '../../src/modules/backup/backup.gateway'; import { BackupModule } from '../../src/modules/backup/backup.module'; import { BackupService } from '../../src/modules/backup/backup.service'; -import { BackupGateway } from '../../src/modules/backup/backup.gateway'; import { PluginsService } from '../../src/modules/plugins/plugins.service'; -import { ConfigService } from '../../src/core/config/config.service'; -import { SchedulerService } from '../../src/core/scheduler/scheduler.service'; describe('BackupController (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/config-editor.e2e-spec.ts b/test/e2e/config-editor.e2e-spec.ts index 6108806ec..527efcaae 100644 --- a/test/e2e/config-editor.e2e-spec.ts +++ b/test/e2e/config-editor.e2e-spec.ts @@ -1,14 +1,13 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import * as dayjs from 'dayjs'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as dayjs from 'dayjs'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; -import { ConfigEditorModule } from '../../src/modules/config-editor/config-editor.module'; import { HomebridgeConfig } from '../../src/core/config/config.service'; import { SchedulerService } from '../../src/core/scheduler/scheduler.service'; +import { ConfigEditorModule } from '../../src/modules/config-editor/config-editor.module'; import { ConfigEditorService } from '../../src/modules/config-editor/config-editor.service'; describe('ConfigEditorController (e2e)', () => { diff --git a/test/e2e/custom-plugins.e2e-spec.ts b/test/e2e/custom-plugins.e2e-spec.ts index fef952db1..3d1ac7a0b 100644 --- a/test/e2e/custom-plugins.e2e-spec.ts +++ b/test/e2e/custom-plugins.e2e-spec.ts @@ -1,10 +1,9 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { ValidationPipe } from '@nestjs/common'; import { HttpService } from '@nestjs/axios'; -import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; import { CustomPluginsModule } from '../../src/modules/custom-plugins/custom-plugins.module'; diff --git a/test/e2e/fastify.e2e-spec.ts b/test/e2e/fastify.e2e-spec.ts index 06144521f..0c1d56d44 100644 --- a/test/e2e/fastify.e2e-spec.ts +++ b/test/e2e/fastify.e2e-spec.ts @@ -1,11 +1,10 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; +import fastifyMultipart from '@fastify/multipart'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; +import { Test, TestingModule } from '@nestjs/testing'; import { fastify } from 'fastify'; -import fastifyMultipart from '@fastify/multipart'; - +import * as fs from 'fs-extra'; import { AppModule } from '../../src/app.module'; describe('FastifyOptions (e2e)', () => { diff --git a/test/e2e/log.gateway.e2e-spec.ts b/test/e2e/log.gateway.e2e-spec.ts index 3a489a93f..5c60620ca 100644 --- a/test/e2e/log.gateway.e2e-spec.ts +++ b/test/e2e/log.gateway.e2e-spec.ts @@ -1,14 +1,13 @@ +import { EventEmitter } from 'events'; import * as os from 'os'; import * as path from 'path'; -import * as fs from 'fs-extra'; -import { EventEmitter } from 'events'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - -import { LogModule } from '../../src/modules/log/log.module'; +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; +import { ConfigService } from '../../src/core/config/config.service'; import { LogGateway } from '../../src/modules/log/log.gateway'; +import { LogModule } from '../../src/modules/log/log.module'; import { LogService } from '../../src/modules/log/log.service'; -import { ConfigService } from '../../src/core/config/config.service'; describe('LogGateway (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/platform-tools-docker.e2e-spec.ts b/test/e2e/platform-tools-docker.e2e-spec.ts index 2353e52d9..d8436e26f 100644 --- a/test/e2e/platform-tools-docker.e2e-spec.ts +++ b/test/e2e/platform-tools-docker.e2e-spec.ts @@ -1,12 +1,11 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; -import { DockerService } from '../../src/modules/platform-tools/docker/docker.service'; import { DockerModule } from '../../src/modules/platform-tools/docker/docker.module'; +import { DockerService } from '../../src/modules/platform-tools/docker/docker.service'; describe('PlatformToolsDocker (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/platform-tools-hb-service.e2e-spec.ts b/test/e2e/platform-tools-hb-service.e2e-spec.ts index dbe8026ea..b67809db7 100644 --- a/test/e2e/platform-tools-hb-service.e2e-spec.ts +++ b/test/e2e/platform-tools-hb-service.e2e-spec.ts @@ -1,12 +1,11 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; -import { HbServiceModule } from '../../src/modules/platform-tools/hb-service/hb-service.module'; import { ConfigService } from '../../src/core/config/config.service'; +import { HbServiceModule } from '../../src/modules/platform-tools/hb-service/hb-service.module'; describe('PlatformToolsHbService (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/platform-tools-linux.e2e-spec.ts b/test/e2e/platform-tools-linux.e2e-spec.ts index 4867e7bd8..a875c38b5 100644 --- a/test/e2e/platform-tools-linux.e2e-spec.ts +++ b/test/e2e/platform-tools-linux.e2e-spec.ts @@ -1,9 +1,8 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; import { LinuxModule } from '../../src/modules/platform-tools/linux/linux.module'; import { LinuxService } from '../../src/modules/platform-tools/linux/linux.service'; diff --git a/test/e2e/platform-tools-terminal.e2e-spec.ts b/test/e2e/platform-tools-terminal.e2e-spec.ts index 50eee02db..d6799f86a 100644 --- a/test/e2e/platform-tools-terminal.e2e-spec.ts +++ b/test/e2e/platform-tools-terminal.e2e-spec.ts @@ -1,22 +1,17 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; import { EventEmitter } from 'events'; -import { Test, TestingModule } from '@nestjs/testing'; -import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; +import * as path from 'path'; import type { IPty } from '@homebridge/node-pty-prebuilt-multiarch'; - +import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../src/core/config/config.service'; +import { NodePtyService } from '../../src/core/node-pty/node-pty.service'; +import { TerminalGateway } from '../../src/modules/platform-tools/terminal/terminal.gateway'; import { TerminalModule } from '../../src/modules/platform-tools/terminal/terminal.module'; import { WsEventEmitter } from '../../src/modules/platform-tools/terminal/terminal.service'; -import { TerminalGateway } from '../../src/modules/platform-tools/terminal/terminal.gateway'; -import { NodePtyService } from '../../src/core/node-pty/node-pty.service'; // create mock websocket client -class MockWsEventEmmiter extends EventEmitter implements WsEventEmitter { - constructor() { - super(); - } - +class MockWsEventEmitter extends EventEmitter implements WsEventEmitter { disconnect = jest.fn(); } @@ -74,7 +69,7 @@ describe('PlatformToolsTerminal (e2e)', () => { jest.resetAllMocks(); // create client - client = new MockWsEventEmmiter(); + client = new MockWsEventEmitter(); jest.spyOn(client, 'emit'); jest.spyOn(client, 'on'); diff --git a/test/e2e/plugin-settings-ui.e2e-spec.ts b/test/e2e/plugin-settings-ui.e2e-spec.ts index 151f6a78e..392a2cd88 100644 --- a/test/e2e/plugin-settings-ui.e2e-spec.ts +++ b/test/e2e/plugin-settings-ui.e2e-spec.ts @@ -1,10 +1,9 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { ValidationPipe } from '@nestjs/common'; import { HttpService } from '@nestjs/axios'; -import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; import { PluginsSettingsUiModule } from '../../src/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module'; diff --git a/test/e2e/plugins.e2e-spec.ts b/test/e2e/plugins.e2e-spec.ts index 5615f39da..f422ce38a 100644 --- a/test/e2e/plugins.e2e-spec.ts +++ b/test/e2e/plugins.e2e-spec.ts @@ -1,10 +1,9 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { ValidationPipe } from '@nestjs/common'; import { HttpService } from '@nestjs/axios'; -import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; import { PluginsModule } from '../../src/modules/plugins/plugins.module'; import { HomebridgePlugin } from '../../src/modules/plugins/types'; diff --git a/test/e2e/plugins.gateway.e2e-spec.ts b/test/e2e/plugins.gateway.e2e-spec.ts index f2ce8d52b..e7f33099a 100644 --- a/test/e2e/plugins.gateway.e2e-spec.ts +++ b/test/e2e/plugins.gateway.e2e-spec.ts @@ -1,15 +1,14 @@ +import { EventEmitter } from 'events'; import * as os from 'os'; import * as path from 'path'; -import * as fs from 'fs-extra'; -import { EventEmitter } from 'events'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../src/core/config/config.service'; +import { NodePtyService } from '../../src/core/node-pty/node-pty.service'; +import { PluginsGateway } from '../../src/modules/plugins/plugins.gateway'; import { PluginsModule } from '../../src/modules/plugins/plugins.module'; import { PluginsService } from '../../src/modules/plugins/plugins.service'; -import { PluginsGateway } from '../../src/modules/plugins/plugins.gateway'; -import { NodePtyService } from '../../src/core/node-pty/node-pty.service'; describe('PluginsGateway (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/server.e2e-spec.ts b/test/e2e/server.e2e-spec.ts index a2e608930..07e333647 100644 --- a/test/e2e/server.e2e-spec.ts +++ b/test/e2e/server.e2e-spec.ts @@ -1,13 +1,12 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { AuthModule } from '../../src/core/auth/auth.module'; +import { ConfigService, HomebridgeConfig } from '../../src/core/config/config.service'; import { ServerModule } from '../../src/modules/server/server.module'; import { ServerService } from '../../src/modules/server/server.service'; -import { ConfigService, HomebridgeConfig } from '../../src/core/config/config.service'; describe('ServerController (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/setup-wizard.e2e-spec.ts b/test/e2e/setup-wizard.e2e-spec.ts index d98d51c13..abecc843b 100644 --- a/test/e2e/setup-wizard.e2e-spec.ts +++ b/test/e2e/setup-wizard.e2e-spec.ts @@ -1,9 +1,8 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; import { ConfigService } from '../../src/core/config/config.service'; import { SetupWizardModule } from '../../src/modules/setup-wizard/setup-wizard.module'; import { UserDto } from '../../src/modules/users/users.dto'; diff --git a/test/e2e/status.e2e-spec.ts b/test/e2e/status.e2e-spec.ts index 86fc3e877..f6f1a9794 100644 --- a/test/e2e/status.e2e-spec.ts +++ b/test/e2e/status.e2e-spec.ts @@ -1,14 +1,13 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios'; -import { of, throwError } from 'rxjs'; -import { ValidationPipe } from '@nestjs/common'; import { HttpService } from '@nestjs/axios'; -import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - -import { StatusModule } from '../../src/modules/status/status.module'; +import { Test, TestingModule } from '@nestjs/testing'; +import { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios'; +import * as fs from 'fs-extra'; +import { of, throwError } from 'rxjs'; import { AuthModule } from '../../src/core/auth/auth.module'; +import { StatusModule } from '../../src/modules/status/status.module'; describe('StatusController (e2e)', () => { let app: NestFastifyApplication; diff --git a/test/e2e/users.e2e-spec.ts b/test/e2e/users.e2e-spec.ts index b3eb32aa8..f00443380 100644 --- a/test/e2e/users.e2e-spec.ts +++ b/test/e2e/users.e2e-spec.ts @@ -1,12 +1,16 @@ import * as path from 'path'; -import * as fs from 'fs-extra'; -import { authenticator } from 'otplib'; import { ValidationPipe } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify'; - +import { Test, TestingModule } from '@nestjs/testing'; +import * as fs from 'fs-extra'; +import { authenticator } from 'otplib'; +import { + UserActivateOtpDto, + UserDeactivateOtpDto, + UserDto, + UserUpdatePasswordDto +} from '../../src/modules/users/users.dto'; import { UsersModule } from '../../src/modules/users/users.module'; -import { UserDto, UserUpdatePasswordDto, UserActivateOtpDto, UserDeactivateOtpDto } from '../../src/modules/users/users.dto'; describe('UsersController (e2e)', () => { let app: NestFastifyApplication; diff --git a/ui/src/app/core/manage-plugins/node-update-required-modal/node-update-required-modal.component.html b/ui/src/app/core/manage-plugins/node-update-required-modal/node-update-required-modal.component.html index f44f7f7fc..6a380b257 100644 --- a/ui/src/app/core/manage-plugins/node-update-required-modal/node-update-required-modal.component.html +++ b/ui/src/app/core/manage-plugins/node-update-required-modal/node-update-required-modal.component.html @@ -9,7 +9,7 @@ \ No newline at end of file + diff --git a/ui/src/i18n/bg.json b/ui/src/i18n/bg.json index b1c984acd..70f10182b 100644 --- a/ui/src/i18n/bg.json +++ b/ui/src/i18n/bg.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "The {{ pluginName }} plugin recommends running on Node.js v{{ minVersion }} or later. You are currently running Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Update Anyway", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge.", "plugins.placeholder_search_plugin": "Търсете добавки, които да инсталирате…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Account Linked", diff --git a/ui/src/i18n/ca.json b/ui/src/i18n/ca.json index 06629da5c..593b70a35 100644 --- a/ui/src/i18n/ca.json +++ b/ui/src/i18n/ca.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "El plugin {{pluginName}} recomana executar-se en Node.js v{{ minVersion }} o superior. Actualment estàs executant Node.js v{{installedVersion}}.", "plugins.node_update.title": "Versió de Node.js", "plugins.node_update.update_anyway": "Actualitzar de totes maneres", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Si us plau actualitza Node.js abans d'actualitzar Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Si us plau actualitza Node.js abans d'actualitzar Homebridge.", "plugins.placeholder_search_plugin": "Cercar plugins per instal·lar…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Compte vinculada", diff --git a/ui/src/i18n/cs.json b/ui/src/i18n/cs.json index 7889eb041..a1b706586 100644 --- a/ui/src/i18n/cs.json +++ b/ui/src/i18n/cs.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Plugin {{ pluginName }} vyžaduje pro běh Node.js ve verzi {{ minVersion }} nebo vyšší. Vaše aktuálně běžící verze Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js verze", "plugins.node_update.update_anyway": "Přesto aktualizovat", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Před aktualizací Homebridge UI aktualizujte Node.js.", "plugins.node_update_homebridge_upgrade_and_try_again": "Před aktualizací Homebridge aktualizujte Node.js.", "plugins.placeholder_search_plugin": "Vyhledejte pluginy k instalaci…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Účet propojen", diff --git a/ui/src/i18n/de.json b/ui/src/i18n/de.json index f49c961ab..31abc368a 100644 --- a/ui/src/i18n/de.json +++ b/ui/src/i18n/de.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Das {{ pluginName }}-Plugin empfiehlt Node.js v{{ minVersion }} oder neuer. Du nutzt derzeit Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Dennoch updaten", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Bitte update Node.js, bevor du Homebridge UI updatest.", "plugins.node_update_homebridge_upgrade_and_try_again": "Bitte update Node.js, bevor du Homebridge updatest.", "plugins.placeholder_search_plugin": "Suche nach installierbaren Plugins …", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Konto verbunden", diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json index 41f6f3fa9..f30416521 100644 --- a/ui/src/i18n/en.json +++ b/ui/src/i18n/en.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "The {{ pluginName }} plugin recommends running on Node.js v{{ minVersion }} or later. You are currently running Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Update Anyway", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge.", "plugins.placeholder_search_plugin": "Search for plugins to install…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Account Linked", diff --git a/ui/src/i18n/es.json b/ui/src/i18n/es.json index da1b8615c..f1b76a484 100644 --- a/ui/src/i18n/es.json +++ b/ui/src/i18n/es.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "El plugin {{ pluginName }} recomienda ejecutarse en Node.js v{{ minVersion }} o superior. Actualmente estás ejecutando Node.js {{ installedVersion }}.", "plugins.node_update.title": "Versión de Node.js", "plugins.node_update.update_anyway": "Actualizar de todas formas", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Por favor actualiza Node.js antes de actualizar Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Por favor actualiza Node.js antes de actualizar Homebridge.", "plugins.placeholder_search_plugin": "Buscar plugins disponibles para instalar…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Cuenta vinculada", diff --git a/ui/src/i18n/fr.json b/ui/src/i18n/fr.json index ebdf43990..60c14cc33 100644 --- a/ui/src/i18n/fr.json +++ b/ui/src/i18n/fr.json @@ -180,8 +180,8 @@ "plugins.manage.label_installed": "Installé", "plugins.manage.label_manual_update_required": "Mise à jour manuelle requise", "plugins.manage.label_online_updates_not_supported_on_windows": "Les mises à jour en ligne ne sont pas supportées sous Windows. Vous devrez mettre à jour Homebridge UI manuellement après avoir arrêté le service Homebridge.", - "plugins.manage.label_release_notes": "Release Notes", - "plugins.manage.label_release_notes_beta": "Beta Information", + "plugins.manage.label_release_notes": "Notes de Version", + "plugins.manage.label_release_notes_beta": "Notes de la Version Bêta", "plugins.manage.label_uninstall": "Désinstaller", "plugins.manage.label_uninstalled": "Désinstallé", "plugins.manage.label_update": "Mettre à jour", @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Le plugin {{ pluginName }} recommande l'utilisation de Node.js v{{ minVersion }} ou ultérieur. La version actuellement installée est Node.js {{ installedVersion }}.", "plugins.node_update.title": "Version de Node.js", "plugins.node_update.update_anyway": "Forcer la mise à jour", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Mettez à niveau Node.js avant de mettre à jour Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Mettez à niveau Node.js avant de mettre à jour Homebridge.", "plugins.placeholder_search_plugin": "Rechercher des plugins à installer…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Compte associé", @@ -218,7 +219,7 @@ "plugins.status_installed": "Installé", "plugins.status_not_installed": "Non installé", "plugins.status_update_available": "Mise à jour disponible", - "plugins.status_update_beta_available": "Beta Update Available", + "plugins.status_update_beta_available": "Mise à jour version Bêta disponible", "plugins.toast_failed_to_load_plugins": "Erreur de chargement des plugins", "plugins.tooltip_update_plugin_to": "Mettre à jour le plugin vers v{{latestVersion}}", "reset.accessories_will_may_need_to_be_reconfigured": "Après la réalisation de cette action, certains accessoires devront peut-être être reconfigurés dans HomeKit ou de nouveau ajoutés à vos Automatisations.", diff --git a/ui/src/i18n/he.json b/ui/src/i18n/he.json index ed767ca34..773416f5f 100644 --- a/ui/src/i18n/he.json +++ b/ui/src/i18n/he.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "The {{ pluginName }} plugin recommends running on Node.js v{{ minVersion }} or later. You are currently running Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js גרסאת", "plugins.node_update.update_anyway": "עדכן בכל זאת", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "אנא עדכן את גרסאת הNode.js לפני שדרוג ההומברידג'", "plugins.placeholder_search_plugin": "חפש תוספים להתקנה…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "חשבון קושר", diff --git a/ui/src/i18n/hu.json b/ui/src/i18n/hu.json index 27783cffe..87e9c8e39 100644 --- a/ui/src/i18n/hu.json +++ b/ui/src/i18n/hu.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "The {{ pluginName }} plugin recommends running on Node.js v{{ minVersion }} or later. You are currently running Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Update Anyway", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge.", "plugins.placeholder_search_plugin": "Pluginek keresése…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Account Linked", diff --git a/ui/src/i18n/id.json b/ui/src/i18n/id.json index 740ab12f5..cf70b47aa 100644 --- a/ui/src/i18n/id.json +++ b/ui/src/i18n/id.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Plugin {{ pluginName }} merekomendasikan Node.js v{{ minVersion }} atau lebih baru. Saat ini anda menjalankan Node.js {{ installedVersion }}.", "plugins.node_update.title": "Versi Node.js", "plugins.node_update.update_anyway": "Tetap Perbarui", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Harap tingkatkan Node.js sebelum memperbaharui Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Harap tingkatkan Node.js sebelum memperbaharui Homebridge.", "plugins.placeholder_search_plugin": "Cari plugin untuk dipasang…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Akun Terhubung", diff --git a/ui/src/i18n/it.json b/ui/src/i18n/it.json index b7af63e1e..499e2a387 100644 --- a/ui/src/i18n/it.json +++ b/ui/src/i18n/it.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Il plugin {{ pluginName }} raccomanda l'esecuzione su Node.js v{{ minVersion }} o successivo. Stai attualmente eseguendo Node.js {{ installedVersion }}.", "plugins.node_update.title": "Versione di Node.js", "plugins.node_update.update_anyway": "Aggiorna comunque", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Per piacere aggiornare Node.js prima di aggiornare Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Per piacere aggiornare Node.js prima di aggiornare Homebridge.", "plugins.placeholder_search_plugin": "Cerca plugin da installare…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Account collegato", diff --git a/ui/src/i18n/ja.json b/ui/src/i18n/ja.json index 2b8307abc..a17af2bdd 100644 --- a/ui/src/i18n/ja.json +++ b/ui/src/i18n/ja.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "プラグイン {{ pluginName }} Node.js v{{ minVersion }} 以降での稼働を推奨しています。現在、Node.js {{ installedVersion }} を実行しています。", "plugins.node_update.title": "Node.js バージョン", "plugins.node_update.update_anyway": "強制的に更新", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Homebridge UIを更新する前にNode.jsを更新してください。", "plugins.node_update_homebridge_upgrade_and_try_again": "Homebridgeを更新する前にNode.jsを更新してください。", "plugins.placeholder_search_plugin": "インストールするプラグインを検索…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "アカウント連携済み", diff --git a/ui/src/i18n/ko.json b/ui/src/i18n/ko.json index 53db6bdf1..f553fac8a 100644 --- a/ui/src/i18n/ko.json +++ b/ui/src/i18n/ko.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} 플러그인은 Node.js v{{ minVersion }} 이상 버전에서 실행이 권장됩니다. 현재 실행 중인 Node.js 버전은 {{ installedVersion }} 입니다.", "plugins.node_update.title": "Node.js 버전", "plugins.node_update.update_anyway": "무시하고 업데이트", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Homebridge UI를 업데이트하기 전에 Node.js를 업그레이드 해주세요.", "plugins.node_update_homebridge_upgrade_and_try_again": "Homebridge를 업데이트하기 전에 Node.js를 업그레이드 해주세요.", "plugins.placeholder_search_plugin": "설치할 플러그인 검색…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "계정 연결됨", diff --git a/ui/src/i18n/mk.json b/ui/src/i18n/mk.json index 9ac7a51f0..e97f53b9c 100644 --- a/ui/src/i18n/mk.json +++ b/ui/src/i18n/mk.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Плагинот {{ pluginName }} препорачува да се извршува на Node.js v{{ minVersion }} или понов. Моментално имате Node.js {{ installedVersion }}.", "plugins.node_update.title": "Верзија на Node.js", "plugins.node_update.update_anyway": "Сепак ажурирај", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Ве молиме аурирајте го Node.js пред да го ажурирате Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Ве молиме аурирајте го Node.js пред да го ажурирате Homebridge.", "plugins.placeholder_search_plugin": "Барајте плагини достапни за инсталација…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Поврзана корисничка сметка", diff --git a/ui/src/i18n/nl.json b/ui/src/i18n/nl.json index 6ffd224ed..1b486db4e 100644 --- a/ui/src/i18n/nl.json +++ b/ui/src/i18n/nl.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "De {{ pluginName }} plugin adviseert het gebruik van Node.js v{{ minVersion }} of nieuwer. Je draait momenteel Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Versie", "plugins.node_update.update_anyway": "Update Alsnog", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Update Node.js voordat je Homebridge UI update.", "plugins.node_update_homebridge_upgrade_and_try_again": "Update Node.js voordat je Homebridge update.", "plugins.placeholder_search_plugin": "Zoeken naar plug-ins om te installeren…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Account Gekoppeld", diff --git a/ui/src/i18n/no.json b/ui/src/i18n/no.json index 17daf48e6..bcfe933a3 100644 --- a/ui/src/i18n/no.json +++ b/ui/src/i18n/no.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "The {{ pluginName }} plugin recommends running on Node.js v{{ minVersion }} or later. You are currently running Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Update Anyway", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Please upgrade Node.js before updating Homebridge.", "plugins.placeholder_search_plugin": "Søk etter plugins å installere…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Konto tilknyttet", diff --git a/ui/src/i18n/pl.json b/ui/src/i18n/pl.json index 0449c8810..c901b9e4a 100644 --- a/ui/src/i18n/pl.json +++ b/ui/src/i18n/pl.json @@ -180,8 +180,8 @@ "plugins.manage.label_installed": "Zainstalowano", "plugins.manage.label_manual_update_required": "Wymagana ręczna aktualizacja", "plugins.manage.label_online_updates_not_supported_on_windows": "Aktualizacje online w systemie Windows nie są wspierane. Musisz zaktualizować Config UI X ręcznie po zatrzymaniu Homebridge.", - "plugins.manage.label_release_notes": "Release Notes", - "plugins.manage.label_release_notes_beta": "Beta Information", + "plugins.manage.label_release_notes": "Opis zmian", + "plugins.manage.label_release_notes_beta": "Opis zmian beta", "plugins.manage.label_uninstall": "Odinstaluj", "plugins.manage.label_uninstalled": "Odinstalowano", "plugins.manage.label_update": "Aktualizuj", @@ -191,7 +191,7 @@ "plugins.manage.message_install_alternate_version": "Zainstaluj inną wersję", "plugins.manage.message_select_version_to_install": "Wybierz wersję do instalacji", "plugins.manage.message_thanks_for_updating": "Dziękujemy za zainstalowanie najnowszej wersji interfejsu {{ pluginName }}.", - "plugins.manage.message_thanks_for_updating_restart": "Please restart Homebridge for the changes to apply. Alternatively, if you have this plugin running in child bridges, you can close this modal and restart these instead.", + "plugins.manage.message_thanks_for_updating_restart": "Zrestartuj Homebridge aby zastosować zmiany. Alternatywnie, jeśli ta wtyczka pracuje jako mostek podżędny, możesz zamknąć to okno i zrestartować sam mostek.", "plugins.manage.message_uninstall_remove_config_required": "Jeśli całkowicie usunąłeś tę wtyczkę, upewnij się, że usunąłeś jej konfigurację w pliku config.json przed zrestartowaniem Homebridge.", "plugins.manage.message_uninstall_remove_confirmation": "Jesteś pewny że chcesz odinstalować {{ pluginName }}?", "plugins.manage.message_uninstall_remove_plugin_config": "Usunąć również konfigurację tej wtyczki?", @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Wtyczka {{ pluginName }} powinna być instalowana używając Node.js w wersji {{ minVersion }} lub nowszej. Aktualnie używasz Node.js w wersji {{ installedVersion }}.", "plugins.node_update.title": "Wersja Node.js", "plugins.node_update.update_anyway": "Zaktualizuj mimo to", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Zaktualizuj Node.js przed aktualizacją Homebridge UI i spróbuj ponownie.", "plugins.node_update_homebridge_upgrade_and_try_again": "Zaktualizuj Node.js przed aktualizacją Homebridge i spróbuj ponownie.", "plugins.placeholder_search_plugin": "Wyszukaj dostępne wtyczki…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Konto podłączone", @@ -218,7 +219,7 @@ "plugins.status_installed": "Zainstalowany", "plugins.status_not_installed": "Niezainstalowany", "plugins.status_update_available": "Dostępna aktualizacja", - "plugins.status_update_beta_available": "Beta Update Available", + "plugins.status_update_beta_available": "Dostępna aktualizacja beta", "plugins.toast_failed_to_load_plugins": "Nie udało się załadować wtyczek", "plugins.tooltip_update_plugin_to": "Zaktualizuj wtyczkę do wersji {{latestVersion}}", "reset.accessories_will_may_need_to_be_reconfigured": "Po wykonaniu tej czynności dla niektórych akcesoriów może być wymagana ponowna ich konfiguracja w HomeKit lub ponowne dodanie do automatyzacji.", diff --git a/ui/src/i18n/pt-BR.json b/ui/src/i18n/pt-BR.json index 7abadb40e..65a389131 100644 --- a/ui/src/i18n/pt-BR.json +++ b/ui/src/i18n/pt-BR.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "É recomendado executar o plugin {{ pluginName }} na versão do Node.js v{{ minVersion }} ou posterior. Você está utilizando o Node.js {{ installedVersion }}.", "plugins.node_update.title": "Versão do Node.js", "plugins.node_update.update_anyway": "Forçar Atualização", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Por favor atualize o Node.js antes de atualizar o Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Por favor atualize o Node.js antes de atualizar o Homebridge.", "plugins.placeholder_search_plugin": "Procurar plugins para instalação…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Conta Vinculada", diff --git a/ui/src/i18n/pt.json b/ui/src/i18n/pt.json index 841bdb5e6..afbce3e74 100644 --- a/ui/src/i18n/pt.json +++ b/ui/src/i18n/pt.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "É recomendado executar o plugin {{ pluginName }} na versão do Node.js v{{ minVersion }} ou posterior. Neste momento encontra-se na versão Node.js {{ installedVersion }}.", "plugins.node_update.title": "Versão Node.js", "plugins.node_update.update_anyway": "Forçar Atualização", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Por favor atualize o Node.js antes de atualizar o Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Por favor atualize o Node.js antes de atualizar o Homebridge.", "plugins.placeholder_search_plugin": "Procurar plugins para instalação…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Conta Vinculada", diff --git a/ui/src/i18n/ru.json b/ui/src/i18n/ru.json index ac0c075c7..5e53fefe6 100644 --- a/ui/src/i18n/ru.json +++ b/ui/src/i18n/ru.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Плагин {{ pluginName }} рекомендуется запускать используя Node.js v{{ minVersion }} или новее. В настоящее время Вы используете Node.js {{ installedVersion }}.", "plugins.node_update.title": "Версия Node.js", "plugins.node_update.update_anyway": "Обновить в любом случае", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Пожалуйста, обновите Node.js перед обновлением Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Пожалуйста, обновите Node.js перед обновлением Homebridge.", "plugins.placeholder_search_plugin": "Поиск плагинов для установки…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Аккаунт привязан", diff --git a/ui/src/i18n/sl.json b/ui/src/i18n/sl.json index 716c5d396..89345ab4d 100644 --- a/ui/src/i18n/sl.json +++ b/ui/src/i18n/sl.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} vtičnik zahteva Node.js v{{ minVersion }} ali novejši. Trenutno se izvaja Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Verzija", "plugins.node_update.update_anyway": "Posodobite vseeno", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Pred posodobitvijo Homebridga UI nadgradite Node.js.", "plugins.node_update_homebridge_upgrade_and_try_again": "Pred posodobitvijo Homebridga nadgradite Node.js.", "plugins.placeholder_search_plugin": "Poiščite vtičnike za namestitev …", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Račun povezan", diff --git a/ui/src/i18n/sv.json b/ui/src/i18n/sv.json index 989ffdbcf..cad7a33a2 100644 --- a/ui/src/i18n/sv.json +++ b/ui/src/i18n/sv.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} plugin rekomenderas att köras med Node.js v{{ minVersion }} eller senare. Du kör just nu Node.js {{ installedVersion }}.", "plugins.node_update.title": "Node.js Version", "plugins.node_update.update_anyway": "Uppdatera ändå", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Uppgradera Node.js innan du uppdaterar Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Uppgradera Node.js innan du uppdaterar Homebridge.", "plugins.placeholder_search_plugin": "Sök efter plugins att installera…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Konto länkad", diff --git a/ui/src/i18n/th.json b/ui/src/i18n/th.json index 1b5a23415..7b7de6249 100644 --- a/ui/src/i18n/th.json +++ b/ui/src/i18n/th.json @@ -200,7 +200,8 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} ปลั๊กอินแนะนำให้ทำงานบน Node.js รุ่น{{ minVersion }} หรือใหม่กว่า. โดยที่คุณกำลังใช้ Node.js {{ installedVersion }}.", "plugins.node_update.title": "รุ่นของ Node.js", "plugins.node_update.update_anyway": "อัปเดตต่อไป", - "plugins.node_update_homebridge_upgrade_and_try_again": "โปรดอัปเกรด Node.js ก่อนอัปเดต Homebridge", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "โปรดอัปเกรด Node.js ก่อนอัปเดต Homebridge UI.", + "plugins.node_update_homebridge_upgrade_and_try_again": "โปรดอัปเกรด Node.js ก่อนอัปเดต Homebridge.", "plugins.placeholder_search_plugin": "ค้นหาปลั๊กอินที่จะติดตั้ง…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "เชื่อมโยงบัญชีแล้ว", "plugins.settings.custom.homebridge-gsh.label_link_account": "เชื่อมโยงบัญชี", diff --git a/ui/src/i18n/tr.json b/ui/src/i18n/tr.json index 8b1387f30..01b4460d0 100644 --- a/ui/src/i18n/tr.json +++ b/ui/src/i18n/tr.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} eklentisi Node.js v{{ minVersion }} veya daha üst sürümünü çalıştırmanızı tavsiye ediyor. Mevutta Node.js v{{ installedVersion }} çalıştırıyorsunuz.", "plugins.node_update.title": "Node.js Sürümü", "plugins.node_update.update_anyway": "Yine de Güncelle", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Lütfen Homebridge UI'i güncellemeden önce Node.js sürümünü yükseltin.", "plugins.node_update_homebridge_upgrade_and_try_again": "Lütfen Homebridge'i güncellemeden önce Node.js sürümünü yükseltin.", "plugins.placeholder_search_plugin": "Yüklemek için eklentiler arayın…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Hesap Bağlandı", diff --git a/ui/src/i18n/uk.json b/ui/src/i18n/uk.json index 0d8f74313..5412c174b 100644 --- a/ui/src/i18n/uk.json +++ b/ui/src/i18n/uk.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "Плагін {{ pluginName }} рекомендовано запускати використовуючи Node.js v{{ minVersion }} або новіше. На даний час Ви використовуєте Node.js {{ installedVersion }}.", "plugins.node_update.title": "Версія Node.js", "plugins.node_update.update_anyway": "Оновити в будь-якому випадку", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "Будь ласка, оновіть Node.js перед оновленням Homebridge UI.", "plugins.node_update_homebridge_upgrade_and_try_again": "Будь ласка, оновіть Node.js перед оновленням Homebridge.", "plugins.placeholder_search_plugin": "Пошук плагінів для встановлення…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "Аккаунт прив'язаний", diff --git a/ui/src/i18n/zh-CN.json b/ui/src/i18n/zh-CN.json index 41642dbc3..d7d26b657 100644 --- a/ui/src/i18n/zh-CN.json +++ b/ui/src/i18n/zh-CN.json @@ -200,12 +200,13 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} 插件推荐使用 Node.js {{ minVersion }} 或者更新版本。 您现在的 Node.js 版本是 {{ installedVersion }}。", "plugins.node_update.title": "Node.js 版本", "plugins.node_update.update_anyway": "继续升级", - "plugins.node_update_homebridge_upgrade_and_try_again": "请在升级 Homebridge 前先升级 Node.js", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "请在升级 Homebridge UI 前先升级 Node.js。", + "plugins.node_update_homebridge_upgrade_and_try_again": "请在升级 Homebridge 前先升级 Node.js。", "plugins.placeholder_search_plugin": "搜索插件…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "已绑定", "plugins.settings.custom.homebridge-gsh.label_link_account": "绑定账号", "plugins.settings.custom.homebridge-gsh.label_unlink_account": "解绑账号", - "plugins.settings.custom.homebridge-gsh.message_about": "Homebridge 谷歌智能家庭 插件将允许您通过支持谷歌家庭的智能音箱或者手机上的谷歌家庭软件上操作 Homebridge ", + "plugins.settings.custom.homebridge-gsh.message_about": "Homebridge 谷歌智能家庭 插件将允许您通过支持谷歌家庭的智能音箱或者手机上的谷歌家庭软件上操作 Homebridge。", "plugins.settings.custom.homebridge-gsh.message_account_link_required": "若要使用该功能您需要使用您的谷歌账号或者 GitHub 账号登陆; 请确保您在设备间登陆的为同一账号。", "plugins.settings.custom.homebridge-gsh.message_homebridge_restart_required": "Homebridge 需要重启以生效", "plugins.settings.label_open_config_editor": "打开配置编辑器", diff --git a/ui/src/i18n/zh-TW.json b/ui/src/i18n/zh-TW.json index cd7d68a13..282931828 100644 --- a/ui/src/i18n/zh-TW.json +++ b/ui/src/i18n/zh-TW.json @@ -200,6 +200,7 @@ "plugins.node_update.node_version_too_low": "{{ pluginName }} Plugin 建議以 Node.js v{{ minVersion }} 或更新版本執行。目前所使用的 Node.js 版本為 {{ installedVersion }}。", "plugins.node_update.title": "Node.js 版本", "plugins.node_update.update_anyway": "依舊更新", + "plugins.node_update_homebridge_ui_upgrade_and_try_again": "於更新 Homebridge UI 前、請先更新 Node.js。", "plugins.node_update_homebridge_upgrade_and_try_again": "於更新 Homebridge 前、請先更新 Node.js。", "plugins.placeholder_search_plugin": "搜尋 Plugin 並且安裝…", "plugins.settings.custom.homebridge-gsh.label_account_linked": "帳號已連結",