smart-home-engine 0.19.8 → 0.19.9
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/dist/web/assets/{index-ves1PGl3.js → index-BMmVmcNK.js} +60 -60
- package/dist/web/assets/{index-CtuJWQQl.css → index-ChpDowYT.css} +1 -1
- package/dist/web/assets/{tsMode-B_oQbMWr.js → tsMode-CFaMfW0s.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +3 -2
- package/service/install.sh +7 -3
- package/src/web/server.js +34 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-BMmVmcNK.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
}
|
|
156
156
|
})();
|
|
157
157
|
</script>
|
|
158
|
-
<script type="module" crossorigin src="/assets/index-
|
|
158
|
+
<script type="module" crossorigin src="/assets/index-BMmVmcNK.js"></script>
|
|
159
159
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
|
|
160
160
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
161
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
161
|
+
<link rel="stylesheet" crossorigin href="/assets/index-ChpDowYT.css">
|
|
162
162
|
</head>
|
|
163
163
|
<body>
|
|
164
164
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-home-engine",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.9",
|
|
4
4
|
"description": "Node.js based script runner for use in MQTT based Smart Home environments",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"author": "Sebastian 'hobbyquaker' Raff <hobbyquaker@gmail.com>",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"bcryptjs": "^2.4.3",
|
|
32
31
|
"@elastic/elasticsearch": "^9.4.2",
|
|
33
32
|
"@influxdata/influxdb-client": "^1.35.0",
|
|
34
33
|
"@matter/main": "^0.17.0",
|
|
34
|
+
"bcryptjs": "^2.4.3",
|
|
35
35
|
"chokidar": "^4.0.0",
|
|
36
36
|
"express": "^5.2.1",
|
|
37
37
|
"ioredis": "^5.11.0",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"node-schedule": "^2.0.0",
|
|
40
40
|
"pino": "^9.0.0",
|
|
41
41
|
"pino-pretty": "^13.0.0",
|
|
42
|
+
"semantic-compare": "^1.0.2",
|
|
42
43
|
"suncalc": "^1.9.0",
|
|
43
44
|
"ws": "^8.21.0",
|
|
44
45
|
"yargs": "^17.0.0"
|
package/service/install.sh
CHANGED
|
@@ -12,7 +12,7 @@ SHE_USER=she
|
|
|
12
12
|
SERVICE_SRC="$(npm root -g)/smart-home-engine/service/smart-home-engine.service"
|
|
13
13
|
SERVICE_DST=/etc/systemd/system/smart-home-engine.service
|
|
14
14
|
|
|
15
|
-
# --- ensure sudo is installed (required for web UI restart
|
|
15
|
+
# --- ensure sudo is installed (required for web UI restart/update buttons) -
|
|
16
16
|
if ! command -v sudo &>/dev/null; then
|
|
17
17
|
echo "sudo not found, installing..."
|
|
18
18
|
apt-get install -y sudo
|
|
@@ -35,9 +35,13 @@ fi
|
|
|
35
35
|
# --- state directory (required by ReadWritePaths before first start) ------
|
|
36
36
|
install -d -o "$SHE_USER" -g "$SHE_USER" -m 700 /home/she/.she
|
|
37
37
|
|
|
38
|
-
# --- sudoers
|
|
38
|
+
# --- sudoers rules -------------------------------------------------------
|
|
39
|
+
NPM_BIN="$(command -v npm)"
|
|
39
40
|
SUDOERS_FILE=/etc/sudoers.d/she
|
|
40
|
-
|
|
41
|
+
cat > "$SUDOERS_FILE" <<EOF
|
|
42
|
+
she ALL=(root) NOPASSWD: /usr/bin/systemctl restart smart-home-engine
|
|
43
|
+
she ALL=(root) NOPASSWD: $NPM_BIN install -g smart-home-engine
|
|
44
|
+
EOF
|
|
41
45
|
chmod 440 "$SUDOERS_FILE"
|
|
42
46
|
echo "created $SUDOERS_FILE"
|
|
43
47
|
|
package/src/web/server.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const express = require('express');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const { spawnSync, spawn } = require('child_process');
|
|
6
|
+
const semverCompare = require('semantic-compare');
|
|
7
|
+
const pkg = require('../../package.json');
|
|
5
8
|
const { router: configRouter } = require('./config-api');
|
|
6
9
|
const { router: scriptsRouter } = require('./scripts-api');
|
|
7
10
|
const { router: shedbRouter } = require('./shedb-api');
|
|
@@ -56,19 +59,37 @@ app.use('/she/ai', aiRouter);
|
|
|
56
59
|
// When running under systemd, delegate to `sudo systemctl restart` so the
|
|
57
60
|
// service actually comes back up. Otherwise fall back to exit(0) and let
|
|
58
61
|
// whatever process manager is in use handle it.
|
|
62
|
+
function _systemdRestart() {
|
|
63
|
+
if (process.env.INVOCATION_ID) {
|
|
64
|
+
spawn('sudo', ['systemctl', 'restart', 'smart-home-engine'], { detached: true, stdio: 'ignore' }).unref();
|
|
65
|
+
} else {
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
app.post('/she/restart', (req, res) => {
|
|
71
|
+
res.json({ ok: true });
|
|
72
|
+
setTimeout(_systemdRestart, 200);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// npm version check — poll once on startup and every hour
|
|
76
|
+
let _latestNpmVersion = null;
|
|
77
|
+
async function _checkNpmVersion() {
|
|
78
|
+
try {
|
|
79
|
+
const res = await fetch('https://registry.npmjs.org/smart-home-engine/latest');
|
|
80
|
+
const data = await res.json();
|
|
81
|
+
_latestNpmVersion = (data.version && semverCompare(pkg.version, data.version) < 0) ? data.version : null;
|
|
82
|
+
} catch { /* best-effort */ }
|
|
83
|
+
}
|
|
84
|
+
_checkNpmVersion();
|
|
85
|
+
setInterval(_checkNpmVersion, 60 * 60 * 1000);
|
|
86
|
+
|
|
87
|
+
// Update — install latest npm package, then restart
|
|
88
|
+
app.post('/she/update', (req, res) => {
|
|
60
89
|
res.json({ ok: true });
|
|
61
90
|
setTimeout(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
require('child_process').spawn(
|
|
65
|
-
'sudo',
|
|
66
|
-
['systemctl', 'restart', 'smart-home-engine'],
|
|
67
|
-
{ detached: true, stdio: 'ignore' },
|
|
68
|
-
).unref();
|
|
69
|
-
} else {
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
91
|
+
spawnSync('sudo', ['npm', 'install', '-g', 'smart-home-engine'], { stdio: 'inherit' });
|
|
92
|
+
_systemdRestart();
|
|
72
93
|
}, 200);
|
|
73
94
|
});
|
|
74
95
|
|
|
@@ -78,7 +99,9 @@ function setStatsProvider(fn) {
|
|
|
78
99
|
_getStats = fn;
|
|
79
100
|
}
|
|
80
101
|
app.get('/she/status', (req, res) => {
|
|
81
|
-
|
|
102
|
+
const s = _getStats ? _getStats() : { scripts: 0, topics: 0 };
|
|
103
|
+
if (_latestNpmVersion) s.latestVersion = _latestNpmVersion;
|
|
104
|
+
res.json(s);
|
|
82
105
|
});
|
|
83
106
|
|
|
84
107
|
// Serve the built Svelte SPA from dist/web/
|