smart-home-engine 1.45.0 → 1.46.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.
@@ -1,4 +1,4 @@
1
- import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-IEG5HdGq.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-BhEvCzQ6.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -172,10 +172,10 @@
172
172
  }
173
173
  })();
174
174
  </script>
175
- <script type="module" crossorigin src="/assets/index-IEG5HdGq.js"></script>
175
+ <script type="module" crossorigin src="/assets/index-BhEvCzQ6.js"></script>
176
176
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-DKJI_o9J.js">
177
177
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
178
- <link rel="stylesheet" crossorigin href="/assets/index-C3PWzLWR.css">
178
+ <link rel="stylesheet" crossorigin href="/assets/index--6OfYbIN.css">
179
179
  </head>
180
180
  <body>
181
181
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
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": {
@@ -20,6 +20,7 @@ const path = require('path');
20
20
 
21
21
  const CORE = 'mqtt-interfaces-core';
22
22
  const REGISTRY = 'https://registry.npmjs.org';
23
+ const GITHUB_API = 'https://api.github.com';
23
24
  const TTL = 24 * 60 * 60 * 1000;
24
25
 
25
26
  let _fetch = (...args) => fetch(...args);
@@ -101,6 +102,33 @@ async function details(name, version) {
101
102
  };
102
103
  }
103
104
 
105
+ /** owner/repo of a GitHub repository URL, or null for anything else (GitLab, a tarball, …). */
106
+ function githubSlug(repository) {
107
+ if (typeof repository !== 'string') return null;
108
+ const m = repository.match(/github\.com[/:]([^/]+)\/([^/#?]+)/i);
109
+ return m ? { owner: m[1], repo: m[2].replace(/\.git$/, '') } : null;
110
+ }
111
+
112
+ /**
113
+ * Stars and the owner's profile for a package's GitHub repository. One unauthenticated API
114
+ * call per adapter, and only during the daily sweep — best effort: a rate limit or a moved
115
+ * repository simply leaves the star count out, it never fails the catalog.
116
+ */
117
+ async function githubInfo(repository) {
118
+ const slug = githubSlug(repository);
119
+ if (!slug) return { stars: null, owner: null, ownerUrl: null };
120
+ try {
121
+ const data = await getJson(`${GITHUB_API}/repos/${slug.owner}/${slug.repo}`, { accept: 'application/vnd.github+json' });
122
+ return {
123
+ stars: typeof data.stargazers_count === 'number' ? data.stargazers_count : null,
124
+ owner: (data.owner && data.owner.login) || slug.owner,
125
+ ownerUrl: (data.owner && data.owner.html_url) || `https://github.com/${slug.owner}`,
126
+ };
127
+ } catch {
128
+ return { stars: null, owner: slug.owner, ownerUrl: `https://github.com/${slug.owner}` };
129
+ }
130
+ }
131
+
104
132
  /**
105
133
  * Sweep the registry for the trusted publishers' adapters.
106
134
  * @param {string[]} publishers
@@ -124,7 +152,8 @@ async function sweep(publishers, now) {
124
152
  if (!dep) continue;
125
153
  const d = await details(p.name, dep.version);
126
154
  if (d.deprecated) continue;
127
- seen.set(p.name, { name: p.name, version: dep.version, coreRange: dep.range, publisher, ...d });
155
+ const gh = await githubInfo(d.repository);
156
+ seen.set(p.name, { name: p.name, version: dep.version, coreRange: dep.range, publisher, ...d, ...gh });
128
157
  } catch (err) {
129
158
  errors.push({ package: p.name, error: err.message });
130
159
  }
@@ -187,4 +216,21 @@ function refreshing() {
187
216
  return Boolean(_cache && _cache.promise);
188
217
  }
189
218
 
190
- module.exports = { catalog, sweep, packagesOf, coreDependency, details, validPublisher, setFetch, clearCache, init, refreshing, CORE, REGISTRY, TTL };
219
+ module.exports = {
220
+ catalog,
221
+ sweep,
222
+ packagesOf,
223
+ coreDependency,
224
+ details,
225
+ githubInfo,
226
+ githubSlug,
227
+ validPublisher,
228
+ setFetch,
229
+ clearCache,
230
+ init,
231
+ refreshing,
232
+ CORE,
233
+ REGISTRY,
234
+ GITHUB_API,
235
+ TTL,
236
+ };