smart-home-engine 0.20.2 → 0.21.0
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-Ba5-h6tq.js +225 -0
- package/dist/web/assets/{index-pFtY_ZRn.css → index-c8FUuDqy.css} +1 -1
- package/dist/web/assets/{tsMode-B10T-QUc.js → tsMode-LQxUxkOW.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/src/web/deps-api.js +57 -1
- package/dist/web/assets/index-He-obaow.js +0 -225
|
@@ -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-Ba5-h6tq.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-Ba5-h6tq.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-c8FUuDqy.css">
|
|
162
162
|
</head>
|
|
163
163
|
<body>
|
|
164
164
|
<div id="app"></div>
|
package/package.json
CHANGED
package/src/web/deps-api.js
CHANGED
|
@@ -7,6 +7,39 @@ const path = require('path');
|
|
|
7
7
|
const https = require('https');
|
|
8
8
|
const { STORAGE_ROOT } = require('../lib/storage');
|
|
9
9
|
|
|
10
|
+
/** Cache of outdated packages: { [name]: { current, latest } } or null while unchecked. */
|
|
11
|
+
let _outdated = null;
|
|
12
|
+
/** In-flight promise for the current outdated check, to avoid duplicate runs. */
|
|
13
|
+
let _outdatedPromise = null;
|
|
14
|
+
|
|
15
|
+
function _checkOutdated() {
|
|
16
|
+
if (_outdatedPromise) return _outdatedPromise;
|
|
17
|
+
const pkg = readPackageJson();
|
|
18
|
+
if (!pkg.dependencies || Object.keys(pkg.dependencies).length === 0) {
|
|
19
|
+
_outdated = {};
|
|
20
|
+
return Promise.resolve({});
|
|
21
|
+
}
|
|
22
|
+
_outdatedPromise = new Promise((resolve) => {
|
|
23
|
+
execFile('npm', ['outdated', '--json'], { cwd: STORAGE_ROOT, timeout: 60_000 }, (err, stdout) => {
|
|
24
|
+
_outdatedPromise = null;
|
|
25
|
+
// npm exits with code 1 when packages are outdated — not a real error
|
|
26
|
+
if (err && err.code !== 1) {
|
|
27
|
+
resolve(_outdated ?? {});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const data = JSON.parse(stdout || '{}');
|
|
32
|
+
_outdated = {};
|
|
33
|
+
for (const [name, info] of Object.entries(data)) {
|
|
34
|
+
_outdated[name] = { current: info.current, latest: info.latest };
|
|
35
|
+
}
|
|
36
|
+
} catch { /* ignore parse errors */ }
|
|
37
|
+
resolve(_outdated ?? {});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return _outdatedPromise;
|
|
41
|
+
}
|
|
42
|
+
|
|
10
43
|
const router = express.Router();
|
|
11
44
|
|
|
12
45
|
/** Ensure ~/.she/package.json exists so npm commands work. */
|
|
@@ -52,6 +85,10 @@ function isValidVersion(v) {
|
|
|
52
85
|
return typeof v === 'string' && v.length > 0 && v.length <= 50 && /^[a-z0-9_\-.*^~>=<|]+$/i.test(v);
|
|
53
86
|
}
|
|
54
87
|
|
|
88
|
+
// Start background outdated check on module load + refresh every 24 h
|
|
89
|
+
_checkOutdated();
|
|
90
|
+
setInterval(_checkOutdated, 24 * 60 * 60 * 1000);
|
|
91
|
+
|
|
55
92
|
// GET /she/deps — list installed packages from ~/.she/package.json
|
|
56
93
|
router.get('/', (req, res) => {
|
|
57
94
|
const pkg = readPackageJson();
|
|
@@ -59,8 +96,10 @@ router.get('/', (req, res) => {
|
|
|
59
96
|
res.json(
|
|
60
97
|
Object.entries(deps).map(([name, version]) => {
|
|
61
98
|
let url = `https://www.npmjs.com/package/${encodeURIComponent(name)}`;
|
|
99
|
+
let installedVersion;
|
|
62
100
|
try {
|
|
63
101
|
const meta = JSON.parse(fs.readFileSync(path.join(STORAGE_ROOT, 'node_modules', name, 'package.json'), 'utf8'));
|
|
102
|
+
installedVersion = meta.version;
|
|
64
103
|
if (meta.homepage && /^https?:\/\//.test(meta.homepage)) {
|
|
65
104
|
url = meta.homepage;
|
|
66
105
|
} else {
|
|
@@ -80,11 +119,28 @@ router.get('/', (req, res) => {
|
|
|
80
119
|
} catch {
|
|
81
120
|
/* not installed or no metadata */
|
|
82
121
|
}
|
|
83
|
-
return { name, version, url };
|
|
122
|
+
return { name, version, installedVersion, url };
|
|
84
123
|
}),
|
|
85
124
|
);
|
|
86
125
|
});
|
|
87
126
|
|
|
127
|
+
// GET /she/deps/outdated — return cached outdated map { [name]: { current, latest } }
|
|
128
|
+
router.get('/outdated', (req, res) => {
|
|
129
|
+
res.json(_outdated ?? {});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// POST /she/deps/check-outdated — force a fresh check and return result
|
|
133
|
+
router.post('/check-outdated', async (req, res) => {
|
|
134
|
+
_outdated = null;
|
|
135
|
+
_outdatedPromise = null;
|
|
136
|
+
try {
|
|
137
|
+
const result = await _checkOutdated();
|
|
138
|
+
res.json(result);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
res.status(500).json({ error: e.message });
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
88
144
|
// GET /she/deps/search?q=term — search the npm registry
|
|
89
145
|
router.get('/search', (req, res) => {
|
|
90
146
|
const q = String(req.query.q ?? '').trim();
|