homebridge-config-ui-x 5.9.1-beta.0 → 5.9.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -2
- package/dist/app.controller.d.ts +1 -1
- package/dist/app.controller.js +14 -12
- package/dist/app.controller.js.map +1 -1
- package/dist/app.gateway.js +7 -10
- package/dist/app.gateway.js.map +1 -1
- package/dist/app.module.js +40 -43
- package/dist/app.module.js.map +1 -1
- package/dist/app.service.js +4 -7
- package/dist/app.service.js.map +1 -1
- package/dist/bin/base-platform.d.ts +1 -1
- package/dist/bin/base-platform.js +11 -17
- package/dist/bin/base-platform.js.map +1 -1
- package/dist/bin/fork.js +7 -45
- package/dist/bin/fork.js.map +1 -1
- package/dist/bin/hb-service.js +224 -243
- package/dist/bin/hb-service.js.map +1 -1
- package/dist/bin/platforms/darwin.d.ts +1 -1
- package/dist/bin/platforms/darwin.js +61 -65
- package/dist/bin/platforms/darwin.js.map +1 -1
- package/dist/bin/platforms/freebsd.d.ts +1 -1
- package/dist/bin/platforms/freebsd.js +42 -47
- package/dist/bin/platforms/freebsd.js.map +1 -1
- package/dist/bin/platforms/linux.d.ts +1 -1
- package/dist/bin/platforms/linux.js +127 -132
- package/dist/bin/platforms/linux.js.map +1 -1
- package/dist/bin/platforms/win32.d.ts +1 -1
- package/dist/bin/platforms/win32.js +30 -36
- package/dist/bin/platforms/win32.js.map +1 -1
- package/dist/bin/standalone.js +15 -53
- package/dist/bin/standalone.js.map +1 -1
- package/dist/core/auth/auth.controller.d.ts +3 -3
- package/dist/core/auth/auth.controller.js +40 -39
- package/dist/core/auth/auth.controller.js.map +1 -1
- package/dist/core/auth/auth.dto.js +17 -18
- package/dist/core/auth/auth.dto.js.map +1 -1
- package/dist/core/auth/auth.module.js +28 -31
- package/dist/core/auth/auth.module.js.map +1 -1
- package/dist/core/auth/auth.service.d.ts +3 -3
- package/dist/core/auth/auth.service.js +65 -62
- package/dist/core/auth/auth.service.js.map +1 -1
- package/dist/core/auth/guards/admin.guard.js +4 -7
- package/dist/core/auth/guards/admin.guard.js.map +1 -1
- package/dist/core/auth/guards/custom.guard.js +6 -9
- package/dist/core/auth/guards/custom.guard.js.map +1 -1
- package/dist/core/auth/guards/ws-admin-guard.d.ts +1 -1
- package/dist/core/auth/guards/ws-admin-guard.js +13 -11
- package/dist/core/auth/guards/ws-admin-guard.js.map +1 -1
- package/dist/core/auth/guards/ws.guard.d.ts +1 -1
- package/dist/core/auth/guards/ws.guard.js +13 -11
- package/dist/core/auth/guards/ws.guard.js.map +1 -1
- package/dist/core/auth/jwt.strategy.d.ts +3 -2
- package/dist/core/auth/jwt.strategy.js +21 -16
- package/dist/core/auth/jwt.strategy.js.map +1 -1
- package/dist/core/config/config.interfaces.js +1 -2
- package/dist/core/config/config.module.js +8 -10
- package/dist/core/config/config.module.js.map +1 -1
- package/dist/core/config/config.service.d.ts +2 -2
- package/dist/core/config/config.service.js +88 -82
- package/dist/core/config/config.service.js.map +1 -1
- package/dist/core/config/config.startup.d.ts +1 -1
- package/dist/core/config/config.startup.js +23 -28
- package/dist/core/config/config.startup.js.map +1 -1
- package/dist/core/feature-flags/feature-flags.registry.js +1 -4
- package/dist/core/feature-flags/feature-flags.registry.js.map +1 -1
- package/dist/core/homebridge-ipc/homebridge-ipc.module.js +11 -14
- package/dist/core/homebridge-ipc/homebridge-ipc.module.js.map +1 -1
- package/dist/core/homebridge-ipc/homebridge-ipc.service.d.ts +2 -2
- package/dist/core/homebridge-ipc/homebridge-ipc.service.js +24 -19
- package/dist/core/homebridge-ipc/homebridge-ipc.service.js.map +1 -1
- package/dist/core/logger/logger.module.js +8 -10
- package/dist/core/logger/logger.module.js.map +1 -1
- package/dist/core/logger/logger.service.js +13 -23
- package/dist/core/logger/logger.service.js.map +1 -1
- package/dist/core/node-pty/node-pty.module.js +7 -10
- package/dist/core/node-pty/node-pty.module.js.map +1 -1
- package/dist/core/node-pty/node-pty.service.js +6 -11
- package/dist/core/node-pty/node-pty.service.js.map +1 -1
- package/dist/core/node-version.constants.js +4 -11
- package/dist/core/node-version.constants.js.map +1 -1
- package/dist/core/scheduler/scheduler.module.js +7 -10
- package/dist/core/scheduler/scheduler.module.js.map +1 -1
- package/dist/core/scheduler/scheduler.service.js +9 -14
- package/dist/core/scheduler/scheduler.service.js.map +1 -1
- package/dist/core/spa/spa-html.service.js +9 -15
- package/dist/core/spa/spa-html.service.js.map +1 -1
- package/dist/core/spa/spa.filter.d.ts +1 -1
- package/dist/core/spa/spa.filter.js +11 -16
- package/dist/core/spa/spa.filter.js.map +1 -1
- package/dist/core/ssl/ssl-cert-generator.service.d.ts +1 -1
- package/dist/core/ssl/ssl-cert-generator.service.js +34 -36
- package/dist/core/ssl/ssl-cert-generator.service.js.map +1 -1
- package/dist/env-setup.d.ts +1 -0
- package/dist/env-setup.js +7 -0
- package/dist/env-setup.js.map +1 -0
- package/dist/globalDefaults.d.ts +1 -0
- package/dist/globalDefaults.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -19
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +5 -3
- package/dist/main.js +44 -51
- package/dist/main.js.map +1 -1
- package/dist/modules/accessories/accessories.controller.d.ts +2 -2
- package/dist/modules/accessories/accessories.controller.js +27 -29
- package/dist/modules/accessories/accessories.controller.js.map +1 -1
- package/dist/modules/accessories/accessories.dto.js +11 -13
- package/dist/modules/accessories/accessories.dto.js.map +1 -1
- package/dist/modules/accessories/accessories.gateway.d.ts +1 -1
- package/dist/modules/accessories/accessories.gateway.js +18 -16
- package/dist/modules/accessories/accessories.gateway.js.map +1 -1
- package/dist/modules/accessories/accessories.module.js +17 -20
- package/dist/modules/accessories/accessories.module.js.map +1 -1
- package/dist/modules/accessories/accessories.service.d.ts +2 -2
- package/dist/modules/accessories/accessories.service.js +37 -35
- package/dist/modules/accessories/accessories.service.js.map +1 -1
- package/dist/modules/backup/backup.controller.d.ts +2 -2
- package/dist/modules/backup/backup.controller.js +68 -67
- package/dist/modules/backup/backup.controller.js.map +1 -1
- package/dist/modules/backup/backup.gateway.d.ts +2 -2
- package/dist/modules/backup/backup.gateway.js +25 -21
- package/dist/modules/backup/backup.gateway.js.map +1 -1
- package/dist/modules/backup/backup.module.js +22 -25
- package/dist/modules/backup/backup.module.js.map +1 -1
- package/dist/modules/backup/backup.service.d.ts +5 -5
- package/dist/modules/backup/backup.service.js +143 -133
- package/dist/modules/backup/backup.service.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.gateway.d.ts +2 -2
- package/dist/modules/child-bridges/child-bridges.gateway.js +23 -21
- package/dist/modules/child-bridges/child-bridges.gateway.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.interfaces.js +1 -2
- package/dist/modules/child-bridges/child-bridges.module.js +19 -22
- package/dist/modules/child-bridges/child-bridges.module.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.service.d.ts +3 -3
- package/dist/modules/child-bridges/child-bridges.service.js +15 -11
- package/dist/modules/child-bridges/child-bridges.service.js.map +1 -1
- package/dist/modules/config-editor/config-editor.controller.d.ts +6 -6
- package/dist/modules/config-editor/config-editor.controller.js +94 -95
- package/dist/modules/config-editor/config-editor.controller.js.map +1 -1
- package/dist/modules/config-editor/config-editor.module.js +21 -24
- package/dist/modules/config-editor/config-editor.module.js.map +1 -1
- package/dist/modules/config-editor/config-editor.service.d.ts +6 -6
- package/dist/modules/config-editor/config-editor.service.js +65 -57
- package/dist/modules/config-editor/config-editor.service.js.map +1 -1
- package/dist/modules/custom-plugins/custom-plugins.module.js +10 -13
- package/dist/modules/custom-plugins/custom-plugins.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.js +21 -19
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.js +14 -17
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.js +18 -15
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.js +21 -19
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.module.js +14 -17
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.js +18 -15
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.js +18 -19
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.d.ts +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.js +15 -13
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.js +18 -21
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.d.ts +4 -4
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.js +47 -41
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.js.map +1 -1
- package/dist/modules/log/log.gateway.d.ts +2 -2
- package/dist/modules/log/log.gateway.js +15 -13
- package/dist/modules/log/log.gateway.js.map +1 -1
- package/dist/modules/log/log.interfaces.js +1 -2
- package/dist/modules/log/log.module.js +14 -17
- package/dist/modules/log/log.module.js.map +1 -1
- package/dist/modules/log/log.service.d.ts +3 -3
- package/dist/modules/log/log.service.js +47 -43
- package/dist/modules/log/log.service.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.controller.d.ts +1 -1
- package/dist/modules/platform-tools/docker/docker.controller.js +24 -25
- package/dist/modules/platform-tools/docker/docker.controller.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.module.js +14 -17
- package/dist/modules/platform-tools/docker/docker.module.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.service.d.ts +2 -2
- package/dist/modules/platform-tools/docker/docker.service.js +20 -16
- package/dist/modules/platform-tools/docker/docker.service.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.controller.d.ts +2 -2
- package/dist/modules/platform-tools/hb-service/hb-service.controller.js +35 -36
- package/dist/modules/platform-tools/hb-service/hb-service.controller.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.dto.js +20 -19
- package/dist/modules/platform-tools/hb-service/hb-service.dto.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.module.js +14 -17
- package/dist/modules/platform-tools/hb-service/hb-service.module.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.service.d.ts +3 -3
- package/dist/modules/platform-tools/hb-service/hb-service.service.js +37 -30
- package/dist/modules/platform-tools/hb-service/hb-service.service.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.controller.d.ts +1 -1
- package/dist/modules/platform-tools/linux/linux.controller.js +23 -21
- package/dist/modules/platform-tools/linux/linux.controller.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.module.js +14 -17
- package/dist/modules/platform-tools/linux/linux.module.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.service.d.ts +2 -2
- package/dist/modules/platform-tools/linux/linux.service.js +18 -14
- package/dist/modules/platform-tools/linux/linux.service.js.map +1 -1
- package/dist/modules/platform-tools/platform-tools.module.js +12 -15
- package/dist/modules/platform-tools/platform-tools.module.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.controller.d.ts +1 -1
- package/dist/modules/platform-tools/terminal/terminal.controller.js +15 -13
- package/dist/modules/platform-tools/terminal/terminal.controller.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.gateway.d.ts +2 -2
- package/dist/modules/platform-tools/terminal/terminal.gateway.js +17 -15
- package/dist/modules/platform-tools/terminal/terminal.gateway.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.interfaces.js +1 -2
- package/dist/modules/platform-tools/terminal/terminal.module.js +18 -21
- package/dist/modules/platform-tools/terminal/terminal.module.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.service.d.ts +4 -4
- package/dist/modules/platform-tools/terminal/terminal.service.js +33 -28
- package/dist/modules/platform-tools/terminal/terminal.service.js.map +1 -1
- package/dist/modules/plugins/plugins.controller.d.ts +6 -6
- package/dist/modules/plugins/plugins.controller.js +51 -52
- package/dist/modules/plugins/plugins.controller.js.map +1 -1
- package/dist/modules/plugins/plugins.dto.js +26 -24
- package/dist/modules/plugins/plugins.dto.js.map +1 -1
- package/dist/modules/plugins/plugins.gateway.d.ts +3 -3
- package/dist/modules/plugins/plugins.gateway.js +38 -34
- package/dist/modules/plugins/plugins.gateway.js.map +1 -1
- package/dist/modules/plugins/plugins.interfaces.js +1 -2
- package/dist/modules/plugins/plugins.module.js +23 -26
- package/dist/modules/plugins/plugins.module.js.map +1 -1
- package/dist/modules/plugins/plugins.service.d.ts +9 -7
- package/dist/modules/plugins/plugins.service.js +231 -202
- package/dist/modules/plugins/plugins.service.js.map +1 -1
- package/dist/modules/server/server.controller.d.ts +34 -4
- package/dist/modules/server/server.controller.js +294 -177
- package/dist/modules/server/server.controller.js.map +1 -1
- package/dist/modules/server/server.dto.js +13 -16
- package/dist/modules/server/server.dto.js.map +1 -1
- package/dist/modules/server/server.module.js +23 -26
- package/dist/modules/server/server.module.js.map +1 -1
- package/dist/modules/server/server.service.d.ts +36 -6
- package/dist/modules/server/server.service.js +406 -150
- package/dist/modules/server/server.service.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.controller.d.ts +2 -2
- package/dist/modules/setup-wizard/setup-wizard.controller.js +19 -20
- package/dist/modules/setup-wizard/setup-wizard.controller.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.gateway.d.ts +2 -2
- package/dist/modules/setup-wizard/setup-wizard.gateway.js +25 -21
- package/dist/modules/setup-wizard/setup-wizard.gateway.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.guard.d.ts +1 -1
- package/dist/modules/setup-wizard/setup-wizard.guard.js +11 -9
- package/dist/modules/setup-wizard/setup-wizard.guard.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.module.js +12 -15
- package/dist/modules/setup-wizard/setup-wizard.module.js.map +1 -1
- package/dist/modules/status/status.controller.d.ts +5 -5
- package/dist/modules/status/status.controller.js +40 -36
- package/dist/modules/status/status.controller.js.map +1 -1
- package/dist/modules/status/status.gateway.d.ts +9 -9
- package/dist/modules/status/status.gateway.js +51 -47
- package/dist/modules/status/status.gateway.js.map +1 -1
- package/dist/modules/status/status.interfaces.js +2 -5
- package/dist/modules/status/status.interfaces.js.map +1 -1
- package/dist/modules/status/status.module.js +26 -29
- package/dist/modules/status/status.module.js.map +1 -1
- package/dist/modules/status/status.service.d.ts +7 -7
- package/dist/modules/status/status.service.js +100 -88
- package/dist/modules/status/status.service.js.map +1 -1
- package/dist/modules/users/users.controller.d.ts +2 -2
- package/dist/modules/users/users.controller.js +59 -60
- package/dist/modules/users/users.controller.js.map +1 -1
- package/dist/modules/users/users.dto.js +51 -45
- package/dist/modules/users/users.dto.js.map +1 -1
- package/dist/modules/users/users.module.js +14 -17
- package/dist/modules/users/users.module.js.map +1 -1
- package/dist/self-check.js +25 -25
- package/dist/self-check.js.map +1 -1
- package/docs/ssl-upload-pr.md +103 -0
- package/package.json +6 -7
- package/public/{chunk-PPA66JI2.js → chunk-2FNQEOXF.js} +1 -1
- package/public/{chunk-HERKNFLL.js → chunk-2SCTALGY.js} +1 -1
- package/public/{chunk-BQTGMLQB.js → chunk-3IJXQMYZ.js} +1 -1
- package/public/chunk-425ZEUU6.js +1 -0
- package/public/{chunk-EHHNHG6Q.js → chunk-4T6CM7M3.js} +1 -1
- package/public/{chunk-IKY3F7MM.js → chunk-7SKTJO5M.js} +1 -1
- package/public/{chunk-E4ZKIFZH.js → chunk-7UDDRMZZ.js} +1 -1
- package/public/{chunk-Y2N6WV2O.js → chunk-ATMY4YI2.js} +1 -1
- package/public/{chunk-UKEKNQEJ.js → chunk-AZIRJR4B.js} +1 -1
- package/public/{chunk-2UQL2OTF.js → chunk-B2XE365J.js} +1 -1
- package/public/{chunk-JWHZQ7YI.js → chunk-BMKJTHFC.js} +1 -1
- package/public/{chunk-R2PMDKTD.js → chunk-CGYD722J.js} +1 -1
- package/public/{chunk-BI2TS6NN.js → chunk-CQREAKPC.js} +4 -4
- package/public/{chunk-WMGV3KS6.js → chunk-CYBDQV2B.js} +1 -1
- package/public/{chunk-TJEQFEML.js → chunk-D5RKKI2A.js} +1 -1
- package/public/{chunk-NUCXRR5D.js → chunk-EAGKQ5OJ.js} +1 -1
- package/public/{chunk-EYO3XCE2.js → chunk-FGNMMSZH.js} +1 -1
- package/public/{chunk-FGS4HIPD.js → chunk-FTKWC2Q2.js} +1 -1
- package/public/{chunk-QU4I4QSX.js → chunk-HFW5E2OW.js} +1 -1
- package/public/chunk-IIDLQ7XY.js +1 -0
- package/public/{chunk-4E4YMHG4.js → chunk-INX52LH2.js} +1 -1
- package/public/{chunk-VFIOPF3O.js → chunk-JD5JQTN5.js} +1 -1
- package/public/{chunk-RLWY3GD4.js → chunk-JFRCT5V7.js} +1 -1
- package/public/{chunk-JWCVCB6V.js → chunk-JJ7TVAIH.js} +4 -4
- package/public/{chunk-JWY7RFE6.js → chunk-JPCV77W6.js} +1 -1
- package/public/{chunk-ISV4M72Q.js → chunk-K7D2P3SM.js} +1 -1
- package/public/chunk-L66ATRVT.js +1 -0
- package/public/{chunk-IXIZVUXX.js → chunk-LARQLRNL.js} +1 -1
- package/public/{chunk-BVTPAZF3.js → chunk-LHCMU3MO.js} +1 -1
- package/public/{chunk-5T6O4JCR.js → chunk-LZQVKA4S.js} +1 -1
- package/public/{chunk-7F6JT34E.js → chunk-M7QUT5ZZ.js} +1 -1
- package/public/{chunk-2MFBHUTD.js → chunk-MDBZMB6Y.js} +1 -1
- package/public/{chunk-HVGUNGBB.js → chunk-MNVUSYOZ.js} +1 -1
- package/public/{chunk-ZC3JEQZ5.js → chunk-N2TWGDNX.js} +1 -1
- package/public/{chunk-XS5JK2LY.js → chunk-NKNWXFAK.js} +1 -1
- package/public/{chunk-SOA3BB36.js → chunk-OS2SEJZU.js} +1 -1
- package/public/{chunk-IEO2AG2N.js → chunk-PXSEH255.js} +1 -1
- package/public/{chunk-QJLKBB62.js → chunk-PZ2ZCCFR.js} +1 -1
- package/public/{chunk-CWTDHTPI.js → chunk-QCZ4VVDL.js} +1 -1
- package/public/{chunk-5W7EKO7F.js → chunk-QSVZNI3M.js} +1 -1
- package/public/{chunk-4H7ODI34.js → chunk-QUA46GZJ.js} +1 -1
- package/public/{chunk-D4LRW76J.js → chunk-QVLCTKQH.js} +1 -1
- package/public/{chunk-DL2QDFLD.js → chunk-RQ4B2IIV.js} +1 -1
- package/public/{chunk-OTOQR5Z2.js → chunk-RQAFAZAK.js} +1 -1
- package/public/{chunk-4AWJ2PWG.js → chunk-S4OE2ITZ.js} +1 -1
- package/public/{chunk-ZF6W5Z5R.js → chunk-SA5C7QVC.js} +1 -1
- package/public/{chunk-USXMCNIE.js → chunk-SSZBNSOM.js} +1 -1
- package/public/{chunk-E7S36RMO.js → chunk-TA6DOQC5.js} +1 -1
- package/public/{chunk-VB4UAZWJ.js → chunk-TC77PFBQ.js} +1 -1
- package/public/{chunk-5WTTTYNS.js → chunk-TKGKVKOW.js} +1 -1
- package/public/{chunk-FOSFENMV.js → chunk-TSFGO3MA.js} +1 -1
- package/public/{chunk-IBO6BDNZ.js → chunk-UEDMHOPK.js} +1 -1
- package/public/{chunk-LI4BZAUI.js → chunk-UOPWP4RR.js} +1 -1
- package/public/chunk-UTFHCUKB.js +1 -0
- package/public/{chunk-SXOLKD36.js → chunk-UTN2R7WG.js} +1 -1
- package/public/chunk-UV24H47X.js +1 -0
- package/public/{chunk-B5Z4M7ZJ.js → chunk-VSBBKD6B.js} +1 -1
- package/public/{chunk-AO7VT6PL.js → chunk-VYC5JLE6.js} +1 -1
- package/public/{chunk-AOALMLGY.js → chunk-W7UNXMCL.js} +1 -1
- package/public/{chunk-NIERW5KT.js → chunk-WVCOONJF.js} +1 -1
- package/public/{chunk-RON3LUMX.js → chunk-WWSLIQVD.js} +1 -1
- package/public/{chunk-4DVF333O.js → chunk-X3IVSHIL.js} +1 -1
- package/public/{chunk-5G7T74GR.js → chunk-XE5VJDQL.js} +1 -1
- package/public/chunk-XMNXI4QP.js +50 -0
- package/public/{chunk-W26VKO62.js → chunk-XX5GWADI.js} +1 -1
- package/public/{chunk-TGX55EFG.js → chunk-Y5XBENWZ.js} +1 -1
- package/public/{chunk-Z6VQEXUS.js → chunk-YNONXMOG.js} +1 -1
- package/public/{chunk-DIWD6B4C.js → chunk-ZEI3HZ6P.js} +1 -1
- package/public/index.html +2 -2
- package/public/{main-QP5R7HI3.js → main-UGYHSCMY.js} +1 -1
- package/public/{styles-CSF457UW.css → styles-WNHDEKE4.css} +1 -1
- package/scripts/extract-plugin-alias.js +8 -4
- package/public/chunk-2ADAW5AD.js +0 -1
- package/public/chunk-2Y63WBU6.js +0 -1
- package/public/chunk-I3QQTGGZ.js +0 -1
- package/public/chunk-LGE6SGDN.js +0 -1
- package/public/chunk-PZD3OMMY.js +0 -1
- package/public/chunk-QOSAHW73.js +0 -50
package/dist/bin/hb-service.js
CHANGED
|
@@ -1,100 +1,82 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const systeminformation_1 = require("systeminformation");
|
|
52
|
-
const tail_1 = require("tail");
|
|
53
|
-
const tar_1 = require("tar");
|
|
54
|
-
const tcp_port_used_1 = require("tcp-port-used");
|
|
55
|
-
const darwin_1 = require("./platforms/darwin");
|
|
56
|
-
const freebsd_1 = require("./platforms/freebsd");
|
|
57
|
-
const linux_1 = require("./platforms/linux");
|
|
58
|
-
const win32_1 = require("./platforms/win32");
|
|
59
|
-
node_process_1.default.title = 'hb-service';
|
|
60
|
-
class HomebridgeServiceHelper {
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import { execSync, fork } from 'node:child_process';
|
|
4
|
+
import { chownSync, createReadStream, createWriteStream, existsSync } from 'node:fs';
|
|
5
|
+
import { mkdtemp, open, readFile, rename, stat } from 'node:fs/promises';
|
|
6
|
+
import { arch, cpus, homedir, platform, release, tmpdir, type } from 'node:os';
|
|
7
|
+
import { dirname, join, resolve } from 'node:path';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import { program } from 'commander';
|
|
12
|
+
import { mkdirp, pathExists, pathExistsSync, readJson, readJsonSync, remove, writeJson } from 'fs-extra/esm';
|
|
13
|
+
import ora from 'ora';
|
|
14
|
+
import { gt, gte, parse } from 'semver';
|
|
15
|
+
import { networkInterfaceDefault, networkInterfaces } from 'systeminformation';
|
|
16
|
+
import { Tail } from 'tail';
|
|
17
|
+
import { extract } from 'tar';
|
|
18
|
+
import { check as tcpCheck } from 'tcp-port-used';
|
|
19
|
+
import { DarwinInstaller } from './platforms/darwin.js';
|
|
20
|
+
import { FreeBSDInstaller } from './platforms/freebsd.js';
|
|
21
|
+
import { LinuxInstaller } from './platforms/linux.js';
|
|
22
|
+
import { Win32Installer } from './platforms/win32.js';
|
|
23
|
+
process.title = 'hb-service';
|
|
24
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
25
|
+
const __dirname = dirname(__filename);
|
|
26
|
+
export class HomebridgeServiceHelper {
|
|
27
|
+
action;
|
|
28
|
+
selfPath = __filename;
|
|
29
|
+
serviceName = 'Homebridge';
|
|
30
|
+
storagePath;
|
|
31
|
+
usingCustomStoragePath = false;
|
|
32
|
+
allowRunRoot = false;
|
|
33
|
+
enableHbServicePluginManagement = false;
|
|
34
|
+
asUser;
|
|
35
|
+
addGroup;
|
|
36
|
+
log;
|
|
37
|
+
homebridgeModulePath;
|
|
38
|
+
homebridgePackage;
|
|
39
|
+
homebridgeBinary;
|
|
40
|
+
homebridge;
|
|
41
|
+
homebridgeOpts = ['-I'];
|
|
42
|
+
homebridgeCustomEnv = {};
|
|
43
|
+
uiBinary;
|
|
44
|
+
stdout;
|
|
45
|
+
docker;
|
|
46
|
+
uid;
|
|
47
|
+
gid;
|
|
48
|
+
uiPort = 8581;
|
|
49
|
+
installer;
|
|
50
|
+
ipcService;
|
|
61
51
|
get logPath() {
|
|
62
|
-
return
|
|
52
|
+
return resolve(this.storagePath, 'homebridge.log');
|
|
63
53
|
}
|
|
64
54
|
constructor() {
|
|
65
|
-
this.selfPath = __filename;
|
|
66
|
-
this.serviceName = 'Homebridge';
|
|
67
|
-
this.usingCustomStoragePath = false;
|
|
68
|
-
this.allowRunRoot = false;
|
|
69
|
-
this.enableHbServicePluginManagement = false;
|
|
70
|
-
this.homebridgeOpts = ['-I'];
|
|
71
|
-
this.homebridgeCustomEnv = {};
|
|
72
|
-
this.uiPort = 8581;
|
|
73
55
|
this.nodeVersionCheck();
|
|
74
|
-
switch (
|
|
56
|
+
switch (platform()) {
|
|
75
57
|
case 'linux':
|
|
76
|
-
this.installer = new
|
|
58
|
+
this.installer = new LinuxInstaller(this);
|
|
77
59
|
break;
|
|
78
60
|
case 'win32':
|
|
79
|
-
this.installer = new
|
|
61
|
+
this.installer = new Win32Installer(this);
|
|
80
62
|
break;
|
|
81
63
|
case 'darwin':
|
|
82
|
-
this.installer = new
|
|
64
|
+
this.installer = new DarwinInstaller(this);
|
|
83
65
|
break;
|
|
84
66
|
case 'freebsd':
|
|
85
|
-
this.installer = new
|
|
67
|
+
this.installer = new FreeBSDInstaller(this);
|
|
86
68
|
break;
|
|
87
69
|
default:
|
|
88
|
-
this.logger(`ERROR: This command is not supported on ${
|
|
89
|
-
|
|
70
|
+
this.logger(`ERROR: This command is not supported on ${platform()}.`, 'fail');
|
|
71
|
+
process.exit(1);
|
|
90
72
|
}
|
|
91
|
-
|
|
73
|
+
program
|
|
92
74
|
.allowUnknownOption()
|
|
93
75
|
.allowExcessArguments()
|
|
94
76
|
.storeOptionsAsProperties(true)
|
|
95
77
|
.arguments('[install|uninstall|start|stop|restart|rebuild|run|logs|view|add|remove]')
|
|
96
78
|
.option('-P, --plugin-path <path>', '', (p) => {
|
|
97
|
-
|
|
79
|
+
process.env.UIX_CUSTOM_PLUGIN_PATH = p;
|
|
98
80
|
this.homebridgeOpts.push('-P', p);
|
|
99
81
|
})
|
|
100
82
|
.option('-U, --user-storage-path <path>', '', (p) => {
|
|
@@ -104,7 +86,7 @@ class HomebridgeServiceHelper {
|
|
|
104
86
|
.option('-S, --service-name <service name>', 'The name of the homebridge service to install or control', p => this.serviceName = p)
|
|
105
87
|
.option('-T, --no-timestamp', '', () => this.homebridgeOpts.push('-T'))
|
|
106
88
|
.option('--strict-plugin-resolution', '', () => {
|
|
107
|
-
|
|
89
|
+
process.env.UIX_STRICT_PLUGIN_RESOLUTION = '1';
|
|
108
90
|
})
|
|
109
91
|
.option('--port <port>', 'The port to set to the Homebridge UI when installing as a service', p => this.uiPort = Number.parseInt(p, 10))
|
|
110
92
|
.option('--user <user>', 'The user account the Homebridge service will be installed as (Linux, FreeBSD, macOS only)', p => this.asUser = p)
|
|
@@ -118,7 +100,7 @@ class HomebridgeServiceHelper {
|
|
|
118
100
|
.action((cmd) => {
|
|
119
101
|
this.action = cmd;
|
|
120
102
|
})
|
|
121
|
-
.parse(
|
|
103
|
+
.parse(process.argv);
|
|
122
104
|
this.setEnv();
|
|
123
105
|
switch (this.action) {
|
|
124
106
|
case 'install': {
|
|
@@ -146,8 +128,8 @@ class HomebridgeServiceHelper {
|
|
|
146
128
|
break;
|
|
147
129
|
}
|
|
148
130
|
case 'rebuild': {
|
|
149
|
-
this.logger(`Rebuilding for Node.js ${
|
|
150
|
-
this.installer.rebuild(
|
|
131
|
+
this.logger(`Rebuilding for Node.js ${process.version}...`);
|
|
132
|
+
this.installer.rebuild(program.args.includes('--all'));
|
|
151
133
|
break;
|
|
152
134
|
}
|
|
153
135
|
case 'run': {
|
|
@@ -163,15 +145,15 @@ class HomebridgeServiceHelper {
|
|
|
163
145
|
break;
|
|
164
146
|
}
|
|
165
147
|
case 'add': {
|
|
166
|
-
this.npmPluginManagement(
|
|
148
|
+
this.npmPluginManagement(program.args);
|
|
167
149
|
break;
|
|
168
150
|
}
|
|
169
151
|
case 'remove': {
|
|
170
|
-
this.npmPluginManagement(
|
|
152
|
+
this.npmPluginManagement(program.args);
|
|
171
153
|
break;
|
|
172
154
|
}
|
|
173
155
|
case 'update-node': {
|
|
174
|
-
this.checkForNodejsUpdates(
|
|
156
|
+
this.checkForNodejsUpdates(program.args.length === 2 ? program.args[1] : null);
|
|
175
157
|
break;
|
|
176
158
|
}
|
|
177
159
|
case 'before-start': {
|
|
@@ -183,7 +165,7 @@ class HomebridgeServiceHelper {
|
|
|
183
165
|
break;
|
|
184
166
|
}
|
|
185
167
|
default: {
|
|
186
|
-
|
|
168
|
+
program.outputHelp();
|
|
187
169
|
console.log('\nThe hb-service command is provided by homebridge-config-ui-x\n');
|
|
188
170
|
console.log('Please provide a command:');
|
|
189
171
|
console.log(' install install homebridge as a service');
|
|
@@ -202,7 +184,7 @@ class HomebridgeServiceHelper {
|
|
|
202
184
|
console.log(' view views the homebridge service logs for 30 seconds');
|
|
203
185
|
console.log(' update-node [version] update Node.js');
|
|
204
186
|
console.log('\nSee the wiki for help with hb-service: https://homebridge.io/w/JTtHK \n');
|
|
205
|
-
|
|
187
|
+
process.exit(1);
|
|
206
188
|
}
|
|
207
189
|
}
|
|
208
190
|
}
|
|
@@ -218,55 +200,55 @@ class HomebridgeServiceHelper {
|
|
|
218
200
|
}
|
|
219
201
|
}
|
|
220
202
|
else {
|
|
221
|
-
(
|
|
203
|
+
ora()[level](msg);
|
|
222
204
|
}
|
|
223
205
|
}
|
|
224
206
|
setEnv() {
|
|
225
207
|
if (!this.serviceName.match(/^[a-z0-9-]+$/i)) {
|
|
226
208
|
this.logger('Service name must not contain spaces or special characters.', 'fail');
|
|
227
|
-
|
|
209
|
+
process.exit(1);
|
|
228
210
|
}
|
|
229
211
|
if (!this.storagePath) {
|
|
230
|
-
if (
|
|
231
|
-
this.storagePath =
|
|
212
|
+
if (platform() === 'linux' || platform() === 'freebsd') {
|
|
213
|
+
this.storagePath = resolve('/var/lib', this.serviceName.toLowerCase());
|
|
232
214
|
}
|
|
233
215
|
else {
|
|
234
|
-
this.storagePath =
|
|
216
|
+
this.storagePath = resolve(homedir(), `.${this.serviceName.toLowerCase()}`);
|
|
235
217
|
}
|
|
236
218
|
}
|
|
237
|
-
if (
|
|
238
|
-
if (
|
|
219
|
+
if (process.env.CONFIG_UI_VERSION && process.env.HOMEBRIDGE_VERSION && process.env.QEMU_ARCH) {
|
|
220
|
+
if (platform() === 'linux' && ['install', 'uninstall', 'start', 'stop', 'restart', 'logs'].includes(this.action)) {
|
|
239
221
|
this.logger(`Sorry, the ${this.action} command is not supported in Docker.`, 'fail');
|
|
240
|
-
|
|
222
|
+
process.exit(1);
|
|
241
223
|
}
|
|
242
224
|
}
|
|
243
|
-
this.enableHbServicePluginManagement = (
|
|
244
|
-
&& (Boolean(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
225
|
+
this.enableHbServicePluginManagement = (process.env.UIX_CUSTOM_PLUGIN_PATH
|
|
226
|
+
&& (Boolean(process.env.HOMEBRIDGE_SYNOLOGY_PACKAGE === '1') || Boolean(process.env.HOMEBRIDGE_APT_PACKAGE === '1')));
|
|
227
|
+
process.env.UIX_STORAGE_PATH = this.storagePath;
|
|
228
|
+
process.env.UIX_CONFIG_PATH = resolve(this.storagePath, 'config.json');
|
|
229
|
+
process.env.UIX_BASE_PATH = process.env.UIX_BASE_PATH_OVERRIDE || resolve(__dirname, '../../');
|
|
230
|
+
process.env.UIX_SERVICE_MODE = '1';
|
|
231
|
+
process.env.UIX_INSECURE_MODE = '1';
|
|
250
232
|
}
|
|
251
233
|
showVersion() {
|
|
252
|
-
const pjson =
|
|
234
|
+
const pjson = readJsonSync(resolve(__dirname, '../../', 'package.json'));
|
|
253
235
|
console.log(`v${pjson.version}`);
|
|
254
|
-
|
|
236
|
+
process.exit(0);
|
|
255
237
|
}
|
|
256
238
|
async startLog() {
|
|
257
239
|
if (this.stdout === true) {
|
|
258
|
-
this.log =
|
|
240
|
+
this.log = process.stdout;
|
|
259
241
|
return;
|
|
260
242
|
}
|
|
261
243
|
this.logger(`Logging to ${this.logPath}.`);
|
|
262
|
-
this.log =
|
|
263
|
-
|
|
244
|
+
this.log = createWriteStream(this.logPath, { flags: 'a' });
|
|
245
|
+
process.stdout.write = process.stderr.write = this.log.write.bind(this.log);
|
|
264
246
|
}
|
|
265
247
|
async readConfig() {
|
|
266
|
-
return
|
|
248
|
+
return readJson(process.env.UIX_CONFIG_PATH);
|
|
267
249
|
}
|
|
268
250
|
async truncateLog() {
|
|
269
|
-
if (!(await
|
|
251
|
+
if (!(await pathExists(this.logPath))) {
|
|
270
252
|
return;
|
|
271
253
|
}
|
|
272
254
|
try {
|
|
@@ -277,30 +259,30 @@ class HomebridgeServiceHelper {
|
|
|
277
259
|
if (maxSize < 0) {
|
|
278
260
|
return;
|
|
279
261
|
}
|
|
280
|
-
const logStats = await
|
|
262
|
+
const logStats = await stat(this.logPath);
|
|
281
263
|
if (logStats.size < maxSize) {
|
|
282
264
|
return;
|
|
283
265
|
}
|
|
284
266
|
const logStartPosition = logStats.size - truncateSize;
|
|
285
|
-
const logBuffer =
|
|
286
|
-
const logFileHandle = await
|
|
287
|
-
await
|
|
288
|
-
await
|
|
289
|
-
await
|
|
290
|
-
await
|
|
267
|
+
const logBuffer = Buffer.alloc(truncateSize);
|
|
268
|
+
const logFileHandle = await open(this.logPath, 'a+');
|
|
269
|
+
await logFileHandle.read(logBuffer, 0, truncateSize, logStartPosition);
|
|
270
|
+
await logFileHandle.truncate();
|
|
271
|
+
await logFileHandle.write(logBuffer);
|
|
272
|
+
await logFileHandle.close();
|
|
291
273
|
}
|
|
292
274
|
catch (e) {
|
|
293
275
|
this.logger(`Failed to truncate log file: ${e.message}.`, 'fail');
|
|
294
276
|
}
|
|
295
277
|
}
|
|
296
278
|
async launch() {
|
|
297
|
-
if (
|
|
279
|
+
if (platform() !== 'win32' && process.getuid() === 0 && !this.allowRunRoot) {
|
|
298
280
|
this.logger('The hb-service run command should not be executed as root.');
|
|
299
281
|
this.logger('Use the --allow-root flag to force the service to run as the root user.');
|
|
300
|
-
|
|
282
|
+
process.exit(0);
|
|
301
283
|
}
|
|
302
284
|
this.logger(`Homebridge storage path: ${this.storagePath}.`);
|
|
303
|
-
this.logger(`Homebridge config path: ${
|
|
285
|
+
this.logger(`Homebridge config path: ${process.env.UIX_CONFIG_PATH}.`);
|
|
304
286
|
setInterval(() => {
|
|
305
287
|
this.truncateLog();
|
|
306
288
|
}, (1000 * 60 * 60) * 2);
|
|
@@ -308,24 +290,24 @@ class HomebridgeServiceHelper {
|
|
|
308
290
|
await this.storagePathCheck();
|
|
309
291
|
await this.startLog();
|
|
310
292
|
await this.configCheck();
|
|
311
|
-
this.logger(`OS: ${
|
|
312
|
-
this.logger(`Node.js ${
|
|
293
|
+
this.logger(`OS: ${type()} ${release()} ${arch()}.`);
|
|
294
|
+
this.logger(`Node.js ${process.version} ${process.execPath}.`);
|
|
313
295
|
this.homebridgeBinary = await this.findHomebridgePath();
|
|
314
296
|
this.logger(`Homebridge path: ${this.homebridgeBinary}.`);
|
|
315
297
|
await this.loadHomebridgeStartupOptions();
|
|
316
|
-
this.uiBinary =
|
|
298
|
+
this.uiBinary = resolve(process.env.UIX_BASE_PATH, 'dist', 'bin', 'standalone.js');
|
|
317
299
|
this.logger(`UI path: ${this.uiBinary}.`);
|
|
318
300
|
}
|
|
319
301
|
catch (e) {
|
|
320
302
|
this.logger(e.message);
|
|
321
|
-
|
|
303
|
+
process.exit(1);
|
|
322
304
|
}
|
|
323
305
|
this.startExitHandler();
|
|
324
306
|
await this.runUi();
|
|
325
307
|
if (this.ipcService && this.homebridgePackage) {
|
|
326
308
|
this.ipcService.setHomebridgeVersion(this.homebridgePackage.version);
|
|
327
309
|
}
|
|
328
|
-
if (
|
|
310
|
+
if (cpus().length === 1 && arch() === 'arm') {
|
|
329
311
|
this.logger('Delaying Homebridge startup by 20 seconds on low powered server.');
|
|
330
312
|
setTimeout(() => {
|
|
331
313
|
this.runHomebridge();
|
|
@@ -347,19 +329,19 @@ class HomebridgeServiceHelper {
|
|
|
347
329
|
this.homebridge.kill('SIGKILL');
|
|
348
330
|
}
|
|
349
331
|
catch (e) { }
|
|
350
|
-
|
|
332
|
+
process.exit(1282);
|
|
351
333
|
}, 7000);
|
|
352
334
|
};
|
|
353
|
-
|
|
354
|
-
|
|
335
|
+
process.on('SIGTERM', exitHandler);
|
|
336
|
+
process.on('SIGINT', exitHandler);
|
|
355
337
|
}
|
|
356
338
|
runHomebridge() {
|
|
357
|
-
if (!this.homebridgeBinary || !
|
|
339
|
+
if (!this.homebridgeBinary || !pathExistsSync(this.homebridgeBinary)) {
|
|
358
340
|
this.logger('Could not find Homebridge. Make sure you have installed Homebridge using the -g flag then restart.', 'fail');
|
|
359
341
|
this.logger('npm install -g --unsafe-perm homebridge', 'fail');
|
|
360
342
|
return;
|
|
361
343
|
}
|
|
362
|
-
if (
|
|
344
|
+
if (process.env.UIX_STRICT_PLUGIN_RESOLUTION === '1') {
|
|
363
345
|
if (!this.homebridgeOpts.includes('--strict-plugin-resolution')) {
|
|
364
346
|
this.homebridgeOpts.push('--strict-plugin-resolution');
|
|
365
347
|
}
|
|
@@ -371,7 +353,7 @@ class HomebridgeServiceHelper {
|
|
|
371
353
|
this.logger(`Starting Homebridge with custom env: ${JSON.stringify(this.homebridgeCustomEnv)}.`);
|
|
372
354
|
}
|
|
373
355
|
const env = {};
|
|
374
|
-
Object.assign(env,
|
|
356
|
+
Object.assign(env, process.env);
|
|
375
357
|
Object.assign(env, this.homebridgeCustomEnv);
|
|
376
358
|
const childProcessOpts = {
|
|
377
359
|
env,
|
|
@@ -384,7 +366,7 @@ class HomebridgeServiceHelper {
|
|
|
384
366
|
if (this.docker) {
|
|
385
367
|
this.fixDockerPermissions();
|
|
386
368
|
}
|
|
387
|
-
this.homebridge =
|
|
369
|
+
this.homebridge = fork(this.homebridgeBinary, [
|
|
388
370
|
'-C',
|
|
389
371
|
'-Q',
|
|
390
372
|
'-U',
|
|
@@ -417,7 +399,7 @@ class HomebridgeServiceHelper {
|
|
|
417
399
|
}
|
|
418
400
|
async runUi() {
|
|
419
401
|
try {
|
|
420
|
-
const main = await
|
|
402
|
+
const main = await import('../main.js');
|
|
421
403
|
const ui = await main.app;
|
|
422
404
|
this.ipcService = ui.get(main.HomebridgeIpcService);
|
|
423
405
|
}
|
|
@@ -425,7 +407,7 @@ class HomebridgeServiceHelper {
|
|
|
425
407
|
this.logger('The user interface threw an unhandled error.');
|
|
426
408
|
console.error(e);
|
|
427
409
|
setTimeout(() => {
|
|
428
|
-
|
|
410
|
+
process.exit(1);
|
|
429
411
|
}, 4500);
|
|
430
412
|
if (this.homebridge) {
|
|
431
413
|
this.homebridge.kill();
|
|
@@ -434,38 +416,38 @@ class HomebridgeServiceHelper {
|
|
|
434
416
|
}
|
|
435
417
|
async getNpmGlobalModulesDirectory() {
|
|
436
418
|
try {
|
|
437
|
-
const npmPrefix =
|
|
419
|
+
const npmPrefix = execSync('npm -g prefix', {
|
|
438
420
|
env: Object.assign({
|
|
439
421
|
npm_config_loglevel: 'silent',
|
|
440
422
|
npm_update_notifier: 'false',
|
|
441
|
-
},
|
|
423
|
+
}, process.env),
|
|
442
424
|
}).toString('utf8').trim();
|
|
443
|
-
return
|
|
425
|
+
return platform() === 'win32' ? join(npmPrefix, 'node_modules') : join(npmPrefix, 'lib', 'node_modules');
|
|
444
426
|
}
|
|
445
427
|
catch (e) {
|
|
446
428
|
return null;
|
|
447
429
|
}
|
|
448
430
|
}
|
|
449
431
|
async findHomebridgePath() {
|
|
450
|
-
const nodeModules =
|
|
451
|
-
if (await
|
|
452
|
-
this.homebridgeModulePath =
|
|
432
|
+
const nodeModules = resolve(process.env.UIX_BASE_PATH, '..');
|
|
433
|
+
if (await pathExists(resolve(nodeModules, 'homebridge', 'package.json'))) {
|
|
434
|
+
this.homebridgeModulePath = resolve(nodeModules, 'homebridge');
|
|
453
435
|
}
|
|
454
|
-
if (!this.homebridgeModulePath && !(
|
|
436
|
+
if (!this.homebridgeModulePath && !(process.env.UIX_STRICT_PLUGIN_RESOLUTION === '1' && process.env.UIX_CUSTOM_PLUGIN_PATH)) {
|
|
455
437
|
const globalModules = await this.getNpmGlobalModulesDirectory();
|
|
456
|
-
if (globalModules && await
|
|
457
|
-
this.homebridgeModulePath =
|
|
438
|
+
if (globalModules && await pathExists(resolve(globalModules, 'homebridge'))) {
|
|
439
|
+
this.homebridgeModulePath = resolve(globalModules, 'homebridge');
|
|
458
440
|
}
|
|
459
441
|
}
|
|
460
|
-
if (!this.homebridgeModulePath &&
|
|
461
|
-
if (await
|
|
462
|
-
this.homebridgeModulePath =
|
|
442
|
+
if (!this.homebridgeModulePath && process.env.UIX_CUSTOM_PLUGIN_PATH) {
|
|
443
|
+
if (await pathExists(resolve(process.env.UIX_CUSTOM_PLUGIN_PATH, 'homebridge', 'package.json'))) {
|
|
444
|
+
this.homebridgeModulePath = resolve(process.env.UIX_CUSTOM_PLUGIN_PATH, 'homebridge');
|
|
463
445
|
}
|
|
464
446
|
}
|
|
465
447
|
if (this.homebridgeModulePath) {
|
|
466
448
|
try {
|
|
467
449
|
await this.refreshHomebridgePackage();
|
|
468
|
-
return
|
|
450
|
+
return resolve(this.homebridgeModulePath, this.homebridgePackage.bin.homebridge);
|
|
469
451
|
}
|
|
470
452
|
catch (e) {
|
|
471
453
|
console.log(e);
|
|
@@ -475,8 +457,8 @@ class HomebridgeServiceHelper {
|
|
|
475
457
|
}
|
|
476
458
|
async refreshHomebridgePackage() {
|
|
477
459
|
try {
|
|
478
|
-
if (await
|
|
479
|
-
this.homebridgePackage = await
|
|
460
|
+
if (await pathExists(this.homebridgeModulePath)) {
|
|
461
|
+
this.homebridgePackage = await readJson(join(this.homebridgeModulePath, 'package.json'));
|
|
480
462
|
}
|
|
481
463
|
else {
|
|
482
464
|
this.logger(`Homebridge not longer found at ${this.homebridgeModulePath}.`, 'fail');
|
|
@@ -490,13 +472,13 @@ class HomebridgeServiceHelper {
|
|
|
490
472
|
}
|
|
491
473
|
}
|
|
492
474
|
nodeVersionCheck() {
|
|
493
|
-
if (Number.parseInt(
|
|
494
|
-
this.logger(`Node.js v10.13.0 or greater is required, current: ${
|
|
495
|
-
|
|
475
|
+
if (Number.parseInt(process.versions.modules, 10) < 64) {
|
|
476
|
+
this.logger(`Node.js v10.13.0 or greater is required, current: ${process.version}.`, 'fail');
|
|
477
|
+
process.exit(1);
|
|
496
478
|
}
|
|
497
479
|
}
|
|
498
480
|
nvmCheck() {
|
|
499
|
-
if (
|
|
481
|
+
if (process.execPath.includes('nvm') && platform() === 'linux') {
|
|
500
482
|
this.logger('WARNING: It looks like you are running Node.js via NVM (Node Version Manager).\n'
|
|
501
483
|
+ ' Using hb-service with NVM may not work unless you have configured NVM for the\n'
|
|
502
484
|
+ ' user this service will run as. See https://homebridge.io/w/JUZ2g for instructions on how\n'
|
|
@@ -504,8 +486,8 @@ class HomebridgeServiceHelper {
|
|
|
504
486
|
}
|
|
505
487
|
}
|
|
506
488
|
async printPostInstallInstructions() {
|
|
507
|
-
const defaultAdapter = await
|
|
508
|
-
const defaultInterface = (await
|
|
489
|
+
const defaultAdapter = await networkInterfaceDefault();
|
|
490
|
+
const defaultInterface = (await networkInterfaces()).find((x) => x.iface === defaultAdapter);
|
|
509
491
|
console.log('\nManage Homebridge by going to one of the following in your browser:\n');
|
|
510
492
|
console.log(`* http://localhost:${this.uiPort}`);
|
|
511
493
|
if (defaultInterface && defaultInterface.ip4) {
|
|
@@ -518,30 +500,30 @@ class HomebridgeServiceHelper {
|
|
|
518
500
|
this.logger('Homebridge setup complete.', 'succeed');
|
|
519
501
|
}
|
|
520
502
|
async portCheck() {
|
|
521
|
-
const inUse = await (
|
|
503
|
+
const inUse = await tcpCheck(this.uiPort);
|
|
522
504
|
if (inUse) {
|
|
523
505
|
this.logger(`Port ${this.uiPort} is already in use by another process on this host.`, 'fail');
|
|
524
506
|
this.logger('You can specify another port using the --port flag, e.g.:', 'fail');
|
|
525
507
|
this.logger(`hb-service ${this.action} --port 8581`, 'fail');
|
|
526
|
-
|
|
508
|
+
process.exit(1);
|
|
527
509
|
}
|
|
528
510
|
}
|
|
529
511
|
async storagePathCheck() {
|
|
530
|
-
if (
|
|
531
|
-
this.logger(`Cannot create Homebridge storage directory, base path does not exist: ${
|
|
532
|
-
|
|
512
|
+
if (platform() === 'darwin' && !await pathExists(dirname(this.storagePath))) {
|
|
513
|
+
this.logger(`Cannot create Homebridge storage directory, base path does not exist: ${dirname(this.storagePath)}.`, 'fail');
|
|
514
|
+
process.exit(1);
|
|
533
515
|
}
|
|
534
|
-
if (!await
|
|
516
|
+
if (!await pathExists(this.storagePath)) {
|
|
535
517
|
this.logger(`Creating Homebridge directory: ${this.storagePath}.`);
|
|
536
|
-
await
|
|
518
|
+
await mkdirp(this.storagePath);
|
|
537
519
|
await this.chownPath(this.storagePath);
|
|
538
520
|
}
|
|
539
521
|
}
|
|
540
522
|
async configCheck() {
|
|
541
523
|
let saveRequired = false;
|
|
542
524
|
let restartRequired = false;
|
|
543
|
-
if (!await
|
|
544
|
-
this.logger(`Creating default config.json: ${
|
|
525
|
+
if (!await pathExists(process.env.UIX_CONFIG_PATH)) {
|
|
526
|
+
this.logger(`Creating default config.json: ${process.env.UIX_CONFIG_PATH}.`);
|
|
545
527
|
await this.createDefaultConfig();
|
|
546
528
|
restartRequired = true;
|
|
547
529
|
}
|
|
@@ -552,7 +534,7 @@ class HomebridgeServiceHelper {
|
|
|
552
534
|
}
|
|
553
535
|
let uiConfigBlock = currentConfig.platforms.find((x) => x.platform === 'config');
|
|
554
536
|
if (!uiConfigBlock) {
|
|
555
|
-
this.logger(`Adding missing UI platform block to ${
|
|
537
|
+
this.logger(`Adding missing UI platform block to ${process.env.UIX_CONFIG_PATH}.`, 'info');
|
|
556
538
|
uiConfigBlock = await this.createDefaultUiConfig();
|
|
557
539
|
currentConfig.platforms.push(uiConfigBlock);
|
|
558
540
|
saveRequired = true;
|
|
@@ -567,7 +549,7 @@ class HomebridgeServiceHelper {
|
|
|
567
549
|
if (this.action === 'install') {
|
|
568
550
|
if (uiConfigBlock.port !== this.uiPort) {
|
|
569
551
|
uiConfigBlock.port = this.uiPort;
|
|
570
|
-
this.logger(`Homebridge UI port in ${
|
|
552
|
+
this.logger(`Homebridge UI port in ${process.env.UIX_CONFIG_PATH} changed to: ${this.uiPort}.`, 'warn');
|
|
571
553
|
}
|
|
572
554
|
delete uiConfigBlock.restart;
|
|
573
555
|
delete uiConfigBlock.sudo;
|
|
@@ -603,31 +585,31 @@ class HomebridgeServiceHelper {
|
|
|
603
585
|
}
|
|
604
586
|
}
|
|
605
587
|
if (saveRequired) {
|
|
606
|
-
await
|
|
588
|
+
await writeJson(process.env.UIX_CONFIG_PATH, currentConfig, { spaces: 4 });
|
|
607
589
|
}
|
|
608
590
|
}
|
|
609
591
|
catch (e) {
|
|
610
|
-
const backupFile =
|
|
611
|
-
this.logger(`${
|
|
592
|
+
const backupFile = resolve(this.storagePath, `config.json.invalid.${new Date().getTime().toString()}`);
|
|
593
|
+
this.logger(`${process.env.UIX_CONFIG_PATH} does not contain valid JSON.`, 'warn');
|
|
612
594
|
this.logger(`Invalid config.json file has been backed up to ${backupFile}.`, 'warn');
|
|
613
|
-
await
|
|
595
|
+
await rename(process.env.UIX_CONFIG_PATH, backupFile);
|
|
614
596
|
await this.createDefaultConfig();
|
|
615
597
|
restartRequired = true;
|
|
616
598
|
}
|
|
617
599
|
if (restartRequired && this.action === 'run' && await this.isRaspbianImage()) {
|
|
618
600
|
this.logger('Restarting process after port number update.', 'info');
|
|
619
|
-
|
|
601
|
+
process.exit(1);
|
|
620
602
|
}
|
|
621
603
|
}
|
|
622
604
|
async createDefaultConfig() {
|
|
623
|
-
await
|
|
605
|
+
await writeJson(process.env.UIX_CONFIG_PATH, {
|
|
624
606
|
bridge: await this.generateBridgeConfig(),
|
|
625
607
|
accessories: [],
|
|
626
608
|
platforms: [
|
|
627
609
|
await this.createDefaultUiConfig(),
|
|
628
610
|
],
|
|
629
611
|
}, { spaces: 4 });
|
|
630
|
-
await this.chownPath(
|
|
612
|
+
await this.chownPath(process.env.UIX_CONFIG_PATH);
|
|
631
613
|
}
|
|
632
614
|
async generateBridgeConfig() {
|
|
633
615
|
const username = this.generateUsername();
|
|
@@ -651,16 +633,16 @@ class HomebridgeServiceHelper {
|
|
|
651
633
|
};
|
|
652
634
|
}
|
|
653
635
|
async isRaspbianImage() {
|
|
654
|
-
return
|
|
636
|
+
return platform() === 'linux' && await pathExists('/etc/hb-ui-port');
|
|
655
637
|
}
|
|
656
638
|
async getLastKnownUiPort() {
|
|
657
639
|
if (await this.isRaspbianImage()) {
|
|
658
|
-
const lastPort = Number.parseInt((await
|
|
640
|
+
const lastPort = Number.parseInt((await readFile('/etc/hb-ui-port', 'utf8')), 10);
|
|
659
641
|
if (!Number.isNaN(lastPort) && lastPort <= 65535) {
|
|
660
642
|
return lastPort;
|
|
661
643
|
}
|
|
662
644
|
}
|
|
663
|
-
const envPort = Number.parseInt(
|
|
645
|
+
const envPort = Number.parseInt(process.env.HOMEBRIDGE_CONFIG_UI_PORT, 10);
|
|
664
646
|
if (!Number.isNaN(envPort) && envPort <= 65535) {
|
|
665
647
|
return envPort;
|
|
666
648
|
}
|
|
@@ -689,25 +671,25 @@ class HomebridgeServiceHelper {
|
|
|
689
671
|
async generatePort() {
|
|
690
672
|
const randomPort = () => Math.floor(Math.random() * (52000 - 51000 + 1) + 51000);
|
|
691
673
|
let port = randomPort();
|
|
692
|
-
while (await (
|
|
674
|
+
while (await tcpCheck(port)) {
|
|
693
675
|
port = randomPort();
|
|
694
676
|
}
|
|
695
677
|
return port;
|
|
696
678
|
}
|
|
697
679
|
async isAvahiDaemonRunning() {
|
|
698
|
-
if (
|
|
680
|
+
if (platform() !== 'linux') {
|
|
699
681
|
return false;
|
|
700
682
|
}
|
|
701
|
-
if (!await
|
|
683
|
+
if (!await pathExists('/etc/avahi/avahi-daemon.conf') || !await pathExists('/usr/bin/systemctl')) {
|
|
702
684
|
return false;
|
|
703
685
|
}
|
|
704
686
|
try {
|
|
705
|
-
if (await
|
|
706
|
-
|
|
687
|
+
if (await pathExists('/usr/lib/systemd/system/avahi.service')) {
|
|
688
|
+
execSync('systemctl is-active --quiet avahi 2> /dev/null');
|
|
707
689
|
return true;
|
|
708
690
|
}
|
|
709
|
-
else if (await
|
|
710
|
-
|
|
691
|
+
else if (await pathExists('/lib/systemd/system/avahi-daemon.service')) {
|
|
692
|
+
execSync('systemctl is-active --quiet avahi-daemon 2> /dev/null');
|
|
711
693
|
return true;
|
|
712
694
|
}
|
|
713
695
|
else {
|
|
@@ -719,13 +701,13 @@ class HomebridgeServiceHelper {
|
|
|
719
701
|
}
|
|
720
702
|
}
|
|
721
703
|
async chownPath(pathToChown) {
|
|
722
|
-
if (
|
|
704
|
+
if (platform() !== 'win32' && process.getuid() === 0) {
|
|
723
705
|
const { uid, gid } = await this.installer.getId();
|
|
724
|
-
|
|
706
|
+
chownSync(pathToChown, uid, gid);
|
|
725
707
|
}
|
|
726
708
|
}
|
|
727
709
|
async checkForStaleHomebridgeProcess() {
|
|
728
|
-
if (
|
|
710
|
+
if (platform() === 'win32') {
|
|
729
711
|
return;
|
|
730
712
|
}
|
|
731
713
|
try {
|
|
@@ -733,7 +715,7 @@ class HomebridgeServiceHelper {
|
|
|
733
715
|
if (!currentConfig.bridge || !currentConfig.bridge.port) {
|
|
734
716
|
return;
|
|
735
717
|
}
|
|
736
|
-
if (!await (
|
|
718
|
+
if (!await tcpCheck(Number.parseInt(currentConfig.bridge.port.toString(), 10))) {
|
|
737
719
|
return;
|
|
738
720
|
}
|
|
739
721
|
const pid = Number.parseInt(this.installer.getPidOfPort(Number.parseInt(currentConfig.bridge.port.toString(), 10)), 10);
|
|
@@ -741,26 +723,26 @@ class HomebridgeServiceHelper {
|
|
|
741
723
|
return;
|
|
742
724
|
}
|
|
743
725
|
this.logger(`Found stale Homebridge process running on port: ${currentConfig.bridge.port}, with PID: ${pid}, killing...`);
|
|
744
|
-
|
|
726
|
+
process.kill(pid, 'SIGKILL');
|
|
745
727
|
}
|
|
746
728
|
catch (e) {
|
|
747
729
|
}
|
|
748
730
|
}
|
|
749
731
|
async tailLogs() {
|
|
750
|
-
if (!
|
|
732
|
+
if (!existsSync(this.logPath)) {
|
|
751
733
|
this.logger(`Log file does not exist at expected location: ${this.logPath}.`, 'fail');
|
|
752
|
-
|
|
734
|
+
process.exit(1);
|
|
753
735
|
}
|
|
754
|
-
const logStats = await
|
|
736
|
+
const logStats = await stat(this.logPath);
|
|
755
737
|
const logStartPosition = logStats.size <= 200000 ? 0 : logStats.size - 200000;
|
|
756
|
-
const logStream =
|
|
738
|
+
const logStream = createReadStream(this.logPath, { start: logStartPosition });
|
|
757
739
|
logStream.on('data', (buffer) => {
|
|
758
|
-
|
|
740
|
+
process.stdout.write(buffer);
|
|
759
741
|
});
|
|
760
742
|
logStream.on('end', () => {
|
|
761
743
|
logStream.close();
|
|
762
744
|
});
|
|
763
|
-
const tail = new
|
|
745
|
+
const tail = new Tail(this.logPath, {
|
|
764
746
|
fromBeginning: false,
|
|
765
747
|
useWatchFile: true,
|
|
766
748
|
fsWatchOptions: {
|
|
@@ -771,20 +753,20 @@ class HomebridgeServiceHelper {
|
|
|
771
753
|
}
|
|
772
754
|
async viewLogs() {
|
|
773
755
|
this.installer.viewLogs();
|
|
774
|
-
if (!
|
|
756
|
+
if (!existsSync(this.logPath)) {
|
|
775
757
|
this.logger(`Log file does not exist at expected location: ${this.logPath}.`, 'fail');
|
|
776
|
-
|
|
758
|
+
process.exit(1);
|
|
777
759
|
}
|
|
778
|
-
const logStats = await
|
|
760
|
+
const logStats = await stat(this.logPath);
|
|
779
761
|
const logStartPosition = logStats.size <= 200000 ? 0 : logStats.size - 200000;
|
|
780
|
-
const logStream =
|
|
762
|
+
const logStream = createReadStream(this.logPath, { start: logStartPosition });
|
|
781
763
|
logStream.on('data', (buffer) => {
|
|
782
|
-
|
|
764
|
+
process.stdout.write(buffer);
|
|
783
765
|
});
|
|
784
766
|
logStream.on('end', () => {
|
|
785
767
|
logStream.close();
|
|
786
768
|
});
|
|
787
|
-
const tail = new
|
|
769
|
+
const tail = new Tail(this.logPath, {
|
|
788
770
|
fromBeginning: false,
|
|
789
771
|
useWatchFile: true,
|
|
790
772
|
fsWatchOptions: {
|
|
@@ -797,12 +779,12 @@ class HomebridgeServiceHelper {
|
|
|
797
779
|
}, 30000);
|
|
798
780
|
}
|
|
799
781
|
get homebridgeStartupOptionsPath() {
|
|
800
|
-
return
|
|
782
|
+
return resolve(this.storagePath, '.uix-hb-service-homebridge-startup.json');
|
|
801
783
|
}
|
|
802
784
|
async loadHomebridgeStartupOptions() {
|
|
803
785
|
try {
|
|
804
|
-
if (await
|
|
805
|
-
const homebridgeStartupOptions = await
|
|
786
|
+
if (await pathExists(this.homebridgeStartupOptionsPath)) {
|
|
787
|
+
const homebridgeStartupOptions = await readJson(this.homebridgeStartupOptionsPath);
|
|
806
788
|
if (homebridgeStartupOptions.debugMode && !this.homebridgeOpts.includes('-D')) {
|
|
807
789
|
this.homebridgeOpts.push('-D');
|
|
808
790
|
}
|
|
@@ -811,17 +793,17 @@ class HomebridgeServiceHelper {
|
|
|
811
793
|
}
|
|
812
794
|
if (homebridgeStartupOptions.insecureMode === false && this.homebridgeOpts.includes('-I')) {
|
|
813
795
|
this.homebridgeOpts.splice(this.homebridgeOpts.findIndex(x => x === '-I'), 1);
|
|
814
|
-
|
|
796
|
+
process.env.UIX_INSECURE_MODE = '0';
|
|
815
797
|
}
|
|
816
798
|
Object.assign(this.homebridgeCustomEnv, homebridgeStartupOptions.env);
|
|
817
799
|
}
|
|
818
800
|
else if (this.docker) {
|
|
819
|
-
if (
|
|
801
|
+
if (process.env.HOMEBRIDGE_DEBUG === '1' && !this.homebridgeOpts.includes('-D')) {
|
|
820
802
|
this.homebridgeOpts.push('-D');
|
|
821
803
|
}
|
|
822
|
-
if (
|
|
804
|
+
if (process.env.HOMEBRIDGE_INSECURE !== '1' && this.homebridgeOpts.includes('-I')) {
|
|
823
805
|
this.homebridgeOpts.splice(this.homebridgeOpts.findIndex(x => x === '-I'), 1);
|
|
824
|
-
|
|
806
|
+
process.env.UIX_INSECURE_MODE = '0';
|
|
825
807
|
}
|
|
826
808
|
}
|
|
827
809
|
}
|
|
@@ -831,13 +813,13 @@ class HomebridgeServiceHelper {
|
|
|
831
813
|
}
|
|
832
814
|
fixDockerPermissions() {
|
|
833
815
|
try {
|
|
834
|
-
|
|
816
|
+
execSync(`chown -R ${this.uid}:${this.gid} "${this.storagePath}"`);
|
|
835
817
|
}
|
|
836
818
|
catch (e) {
|
|
837
819
|
}
|
|
838
820
|
}
|
|
839
821
|
async checkForNodejsUpdates(requestedVersion) {
|
|
840
|
-
const versionList = (await
|
|
822
|
+
const versionList = (await axios.get('https://nodejs.org/dist/index.json')).data;
|
|
841
823
|
if (!Array.isArray(versionList)) {
|
|
842
824
|
this.logger('Failed to check for Node.js updates.', 'fail');
|
|
843
825
|
return { update: false };
|
|
@@ -846,14 +828,14 @@ class HomebridgeServiceHelper {
|
|
|
846
828
|
if (requestedVersion) {
|
|
847
829
|
const wantedVersion = versionList.find(x => x.version.startsWith(`v${requestedVersion}`));
|
|
848
830
|
if (wantedVersion) {
|
|
849
|
-
if (!
|
|
831
|
+
if (!gte(wantedVersion.version, '20.19.0')) {
|
|
850
832
|
this.logger('Refusing to install Node.js version lower than v20.19.0.', 'fail');
|
|
851
833
|
return { update: false };
|
|
852
834
|
}
|
|
853
|
-
this.logger(`Installing Node.js ${wantedVersion.version} over ${
|
|
835
|
+
this.logger(`Installing Node.js ${wantedVersion.version} over ${process.version}...`, 'info');
|
|
854
836
|
return this.installer.updateNodejs({
|
|
855
837
|
target: wantedVersion.version,
|
|
856
|
-
rebuild: wantedVersion.modules !==
|
|
838
|
+
rebuild: wantedVersion.modules !== process.versions.modules,
|
|
857
839
|
});
|
|
858
840
|
}
|
|
859
841
|
else {
|
|
@@ -861,32 +843,32 @@ class HomebridgeServiceHelper {
|
|
|
861
843
|
return { update: false };
|
|
862
844
|
}
|
|
863
845
|
}
|
|
864
|
-
if (
|
|
865
|
-
this.logger(`Updating Node.js from ${
|
|
846
|
+
if (gt(currentLts.version, process.version)) {
|
|
847
|
+
this.logger(`Updating Node.js from ${process.version} to ${currentLts.version}...`, 'info');
|
|
866
848
|
return this.installer.updateNodejs({
|
|
867
849
|
target: currentLts.version,
|
|
868
|
-
rebuild: currentLts.modules !==
|
|
850
|
+
rebuild: currentLts.modules !== process.versions.modules,
|
|
869
851
|
});
|
|
870
852
|
}
|
|
871
|
-
const currentMajor =
|
|
872
|
-
const latestVersion = versionList.filter(x =>
|
|
873
|
-
if (
|
|
874
|
-
this.logger(`Updating Node.js from ${
|
|
853
|
+
const currentMajor = parse(process.version).major;
|
|
854
|
+
const latestVersion = versionList.filter(x => parse(x.version).major === currentMajor)[0];
|
|
855
|
+
if (gt(latestVersion.version, process.version)) {
|
|
856
|
+
this.logger(`Updating Node.js from ${process.version} to ${latestVersion.version}...`, 'info');
|
|
875
857
|
return this.installer.updateNodejs({
|
|
876
858
|
target: latestVersion.version,
|
|
877
|
-
rebuild: latestVersion.modules !==
|
|
859
|
+
rebuild: latestVersion.modules !== process.versions.modules,
|
|
878
860
|
});
|
|
879
861
|
}
|
|
880
|
-
this.logger(`Node.js ${
|
|
862
|
+
this.logger(`Node.js ${process.version} already up-to-date.`);
|
|
881
863
|
return { update: false };
|
|
882
864
|
}
|
|
883
865
|
async downloadNodejs(downloadUrl) {
|
|
884
|
-
const spinner = (
|
|
866
|
+
const spinner = ora(`Downloading ${downloadUrl}`).start();
|
|
885
867
|
try {
|
|
886
|
-
const tempDir = await
|
|
887
|
-
const tempFilePath =
|
|
888
|
-
const tempFile =
|
|
889
|
-
await
|
|
868
|
+
const tempDir = await mkdtemp(join(tmpdir(), 'node'));
|
|
869
|
+
const tempFilePath = join(tempDir, 'node.tar.gz');
|
|
870
|
+
const tempFile = createWriteStream(tempFilePath);
|
|
871
|
+
await axios.get(downloadUrl, { responseType: 'stream' })
|
|
890
872
|
.then((response) => {
|
|
891
873
|
return new Promise((res, rej) => {
|
|
892
874
|
response.data.pipe(tempFile).on('finish', () => {
|
|
@@ -901,27 +883,27 @@ class HomebridgeServiceHelper {
|
|
|
901
883
|
}
|
|
902
884
|
catch (e) {
|
|
903
885
|
spinner.fail(e.message);
|
|
904
|
-
|
|
886
|
+
process.exit(1);
|
|
905
887
|
}
|
|
906
888
|
}
|
|
907
889
|
async extractNodejs(targetVersion, extractConfig) {
|
|
908
|
-
const spinner = (
|
|
890
|
+
const spinner = ora(`Installing Node.js ${targetVersion}`).start();
|
|
909
891
|
try {
|
|
910
|
-
await
|
|
892
|
+
await extract(extractConfig);
|
|
911
893
|
spinner.succeed(`Installed Node.js ${targetVersion}`);
|
|
912
894
|
}
|
|
913
895
|
catch (e) {
|
|
914
896
|
spinner.fail(e.message);
|
|
915
|
-
|
|
897
|
+
process.exit(1);
|
|
916
898
|
}
|
|
917
899
|
}
|
|
918
900
|
async removeNpmPackage(npmInstallPath) {
|
|
919
|
-
if (!await
|
|
901
|
+
if (!await pathExists(npmInstallPath)) {
|
|
920
902
|
return;
|
|
921
903
|
}
|
|
922
|
-
const spinner = (
|
|
904
|
+
const spinner = ora(`Cleaning up npm at ${npmInstallPath}...`).start();
|
|
923
905
|
try {
|
|
924
|
-
await
|
|
906
|
+
await remove(npmInstallPath);
|
|
925
907
|
spinner.succeed(`Cleaned up npm at ${npmInstallPath}`);
|
|
926
908
|
}
|
|
927
909
|
catch (e) {
|
|
@@ -931,18 +913,18 @@ class HomebridgeServiceHelper {
|
|
|
931
913
|
async checkStatus() {
|
|
932
914
|
this.logger(`Testing hb-service is running on port ${this.uiPort}...`);
|
|
933
915
|
try {
|
|
934
|
-
const res = await
|
|
916
|
+
const res = await axios.get(`http://localhost:${this.uiPort}/api`);
|
|
935
917
|
if (res.data === 'Hello World!') {
|
|
936
918
|
this.logger('Homebridge UI running.', 'succeed');
|
|
937
919
|
}
|
|
938
920
|
else {
|
|
939
921
|
this.logger('Unexpected response.', 'fail');
|
|
940
|
-
|
|
922
|
+
process.exit(1);
|
|
941
923
|
}
|
|
942
924
|
}
|
|
943
925
|
catch (e) {
|
|
944
926
|
this.logger('Homebridge UI not running.', 'fail');
|
|
945
|
-
|
|
927
|
+
process.exit(1);
|
|
946
928
|
}
|
|
947
929
|
}
|
|
948
930
|
parseNpmPackageString(input) {
|
|
@@ -951,7 +933,7 @@ class HomebridgeServiceHelper {
|
|
|
951
933
|
const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);
|
|
952
934
|
if (!m) {
|
|
953
935
|
this.logger('Invalid plugin name.', 'fail');
|
|
954
|
-
|
|
936
|
+
process.exit(1);
|
|
955
937
|
}
|
|
956
938
|
return {
|
|
957
939
|
name: m[1] || '',
|
|
@@ -962,24 +944,24 @@ class HomebridgeServiceHelper {
|
|
|
962
944
|
async npmPluginManagement(args) {
|
|
963
945
|
if (!this.enableHbServicePluginManagement) {
|
|
964
946
|
this.logger('Plugin management is not supported on your platform using hb-service.', 'fail');
|
|
965
|
-
|
|
947
|
+
process.exit(1);
|
|
966
948
|
}
|
|
967
949
|
if (args.length === 1) {
|
|
968
950
|
this.logger('Plugin name required.', 'fail');
|
|
969
|
-
|
|
951
|
+
process.exit(1);
|
|
970
952
|
}
|
|
971
953
|
const action = args[0];
|
|
972
954
|
const target = this.parseNpmPackageString(args[args.length - 1]);
|
|
973
955
|
if (!target.name) {
|
|
974
956
|
this.logger('Invalid plugin name.', 'fail');
|
|
975
|
-
|
|
957
|
+
process.exit(1);
|
|
976
958
|
}
|
|
977
959
|
if (!target.name.match(/^(@[\w-]+(\.[\w-]+)*\/)?homebridge-[\w-]+$/)) {
|
|
978
960
|
this.logger('Invalid plugin name.', 'fail');
|
|
979
|
-
|
|
961
|
+
process.exit(1);
|
|
980
962
|
}
|
|
981
|
-
const cwd =
|
|
982
|
-
if (!await
|
|
963
|
+
const cwd = dirname(process.env.UIX_CUSTOM_PLUGIN_PATH);
|
|
964
|
+
if (!await pathExists(cwd)) {
|
|
983
965
|
this.logger(`Path does not exist: ${cwd}.`, 'fail');
|
|
984
966
|
}
|
|
985
967
|
let cmd = `npm --prefix "${cwd}" ${action} ${target.name}`;
|
|
@@ -988,7 +970,7 @@ class HomebridgeServiceHelper {
|
|
|
988
970
|
}
|
|
989
971
|
this.logger(`CMD: ${cmd}`, 'info');
|
|
990
972
|
try {
|
|
991
|
-
|
|
973
|
+
execSync(cmd, {
|
|
992
974
|
cwd,
|
|
993
975
|
stdio: 'inherit',
|
|
994
976
|
});
|
|
@@ -999,7 +981,6 @@ class HomebridgeServiceHelper {
|
|
|
999
981
|
}
|
|
1000
982
|
}
|
|
1001
983
|
}
|
|
1002
|
-
exports.HomebridgeServiceHelper = HomebridgeServiceHelper;
|
|
1003
984
|
function bootstrap() {
|
|
1004
985
|
return new HomebridgeServiceHelper();
|
|
1005
986
|
}
|