relayax-cli 0.1.997 → 0.1.998
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/lib/api.d.ts +1 -0
- package/dist/lib/api.js +17 -0
- package/dist/lib/version-check.js +2 -0
- package/package.json +1 -1
package/dist/lib/api.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ export interface ResolvedSlug {
|
|
|
14
14
|
full: string;
|
|
15
15
|
}
|
|
16
16
|
export declare function resolveSlugFromServer(name: string): Promise<ResolvedSlug[]>;
|
|
17
|
+
export declare function sendUsagePing(slug: string): Promise<void>;
|
|
17
18
|
export declare function followBuilder(username: string): Promise<void>;
|
package/dist/lib/api.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.searchTeams = searchTeams;
|
|
|
5
5
|
exports.fetchTeamVersions = fetchTeamVersions;
|
|
6
6
|
exports.reportInstall = reportInstall;
|
|
7
7
|
exports.resolveSlugFromServer = resolveSlugFromServer;
|
|
8
|
+
exports.sendUsagePing = sendUsagePing;
|
|
8
9
|
exports.followBuilder = followBuilder;
|
|
9
10
|
const config_js_1 = require("./config.js");
|
|
10
11
|
async function fetchTeamInfo(slug) {
|
|
@@ -56,6 +57,22 @@ async function resolveSlugFromServer(name) {
|
|
|
56
57
|
const data = (await res.json());
|
|
57
58
|
return data.results;
|
|
58
59
|
}
|
|
60
|
+
async function sendUsagePing(slug) {
|
|
61
|
+
const registrySlug = slug.startsWith('@') ? slug.slice(1) : slug;
|
|
62
|
+
const { createHash } = await import('crypto');
|
|
63
|
+
const { hostname, userInfo } = await import('os');
|
|
64
|
+
const deviceHash = createHash('sha256')
|
|
65
|
+
.update(`${hostname()}:${userInfo().username}`)
|
|
66
|
+
.digest('hex');
|
|
67
|
+
const url = `${config_js_1.API_URL}/api/registry/${registrySlug}/ping`;
|
|
68
|
+
await fetch(url, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: { 'Content-Type': 'application/json' },
|
|
71
|
+
body: JSON.stringify({ device_hash: deviceHash }),
|
|
72
|
+
}).catch(() => {
|
|
73
|
+
// fire-and-forget: ignore errors
|
|
74
|
+
});
|
|
75
|
+
}
|
|
59
76
|
async function followBuilder(username) {
|
|
60
77
|
const token = await (0, config_js_1.getValidToken)();
|
|
61
78
|
const headers = {
|
|
@@ -42,6 +42,8 @@ async function checkTeamVersion(slug, force) {
|
|
|
42
42
|
}
|
|
43
43
|
const team = await (0, api_js_1.fetchTeamInfo)(slug);
|
|
44
44
|
(0, update_cache_js_1.updateCacheTimestamp)(slug);
|
|
45
|
+
// Fire-and-forget usage ping (only when cache expired = actual API call happened)
|
|
46
|
+
(0, api_js_1.sendUsagePing)(slug);
|
|
45
47
|
if (team.version !== entry.version) {
|
|
46
48
|
return {
|
|
47
49
|
type: 'team',
|