@meet-sudo/sdk 0.1.1 → 0.1.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/dist/cli.js +166 -0
- package/package.json +4 -1
package/dist/cli.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
var import_crypto = require("crypto");
|
|
6
|
+
var import_os = require("os");
|
|
7
|
+
var VERSION = "0.1.2";
|
|
8
|
+
var API_URL = "https://api.meetsudo.com";
|
|
9
|
+
var colors = {
|
|
10
|
+
reset: "\x1B[0m",
|
|
11
|
+
bold: "\x1B[1m",
|
|
12
|
+
green: "\x1B[32m",
|
|
13
|
+
red: "\x1B[31m",
|
|
14
|
+
yellow: "\x1B[33m",
|
|
15
|
+
cyan: "\x1B[36m",
|
|
16
|
+
dim: "\x1B[2m"
|
|
17
|
+
};
|
|
18
|
+
function log(msg) {
|
|
19
|
+
console.log(msg);
|
|
20
|
+
}
|
|
21
|
+
function success(msg) {
|
|
22
|
+
console.log(`${colors.green}\u2713${colors.reset} ${msg}`);
|
|
23
|
+
}
|
|
24
|
+
function error(msg) {
|
|
25
|
+
console.log(`${colors.red}\u2717${colors.reset} ${msg}`);
|
|
26
|
+
}
|
|
27
|
+
function info(msg) {
|
|
28
|
+
console.log(`${colors.cyan}\u2139${colors.reset} ${msg}`);
|
|
29
|
+
}
|
|
30
|
+
function header(msg) {
|
|
31
|
+
console.log(`
|
|
32
|
+
${colors.bold}${msg}${colors.reset}`);
|
|
33
|
+
}
|
|
34
|
+
function generateInstallId() {
|
|
35
|
+
const data = `${(0, import_os.hostname)()}-${(0, import_os.platform)()}-${(0, import_os.arch)()}-${process.env.USER || "unknown"}`;
|
|
36
|
+
return (0, import_crypto.createHash)("sha256").update(data).digest("hex").substring(0, 12);
|
|
37
|
+
}
|
|
38
|
+
async function checkApiConnectivity() {
|
|
39
|
+
const start = Date.now();
|
|
40
|
+
try {
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
43
|
+
const res = await fetch(`${API_URL}/health`, {
|
|
44
|
+
signal: controller.signal
|
|
45
|
+
});
|
|
46
|
+
clearTimeout(timeout);
|
|
47
|
+
const latency = Date.now() - start;
|
|
48
|
+
if (res.ok) {
|
|
49
|
+
return { ok: true, latency };
|
|
50
|
+
}
|
|
51
|
+
return { ok: false, error: `HTTP ${res.status}` };
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
error: err instanceof Error ? err.message : "Connection failed"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function logInstall(installId, nodeVersion, osInfo) {
|
|
60
|
+
try {
|
|
61
|
+
const res = await fetch(`${API_URL}/sdk/doctor`, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: { "Content-Type": "application/json" },
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
install_id: installId,
|
|
66
|
+
sdk_version: VERSION,
|
|
67
|
+
node_version: nodeVersion,
|
|
68
|
+
os: osInfo,
|
|
69
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
return res.ok;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function doctor() {
|
|
78
|
+
log(`
|
|
79
|
+
${colors.bold}MeetSudo SDK Doctor${colors.reset} ${colors.dim}v${VERSION}${colors.reset}
|
|
80
|
+
`);
|
|
81
|
+
header("Environment");
|
|
82
|
+
const nodeVersion = process.version;
|
|
83
|
+
const osInfo = `${(0, import_os.platform)()} ${(0, import_os.arch)()} (${(0, import_os.release)()})`;
|
|
84
|
+
log(` Node.js: ${nodeVersion}`);
|
|
85
|
+
log(` OS: ${osInfo}`);
|
|
86
|
+
log(` Working dir: ${process.cwd()}`);
|
|
87
|
+
header("API Connectivity");
|
|
88
|
+
const apiCheck = await checkApiConnectivity();
|
|
89
|
+
if (apiCheck.ok) {
|
|
90
|
+
success(`api.meetsudo.com reachable (${apiCheck.latency}ms)`);
|
|
91
|
+
} else {
|
|
92
|
+
error(`api.meetsudo.com unreachable: ${apiCheck.error}`);
|
|
93
|
+
log(`
|
|
94
|
+
${colors.yellow}Possible causes:${colors.reset}`);
|
|
95
|
+
log(" - No internet connection");
|
|
96
|
+
log(" - Firewall blocking outbound requests");
|
|
97
|
+
log(" - API is temporarily down");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
header("Install Registration");
|
|
101
|
+
const installId = generateInstallId();
|
|
102
|
+
const logged = await logInstall(installId, nodeVersion, osInfo);
|
|
103
|
+
if (logged) {
|
|
104
|
+
success(`Install logged: ${colors.cyan}${installId}${colors.reset}`);
|
|
105
|
+
} else {
|
|
106
|
+
info(`Install ID: ${colors.cyan}${installId}${colors.reset} ${colors.dim}(offline)${colors.reset}`);
|
|
107
|
+
}
|
|
108
|
+
header("Next Steps");
|
|
109
|
+
log(`
|
|
110
|
+
1. Get your API key at ${colors.cyan}https://www.meetsudo.com/signup${colors.reset}
|
|
111
|
+
|
|
112
|
+
2. Add to your app:
|
|
113
|
+
|
|
114
|
+
${colors.dim}import { meetsudo } from '@meet-sudo/sdk';
|
|
115
|
+
|
|
116
|
+
meetsudo.init({ apiKey: 'YOUR_API_KEY' });${colors.reset}
|
|
117
|
+
|
|
118
|
+
3. See events in your dashboard at ${colors.cyan}https://www.meetsudo.com/inbox${colors.reset}
|
|
119
|
+
`);
|
|
120
|
+
log(`${colors.green}All checks passed!${colors.reset}
|
|
121
|
+
`);
|
|
122
|
+
}
|
|
123
|
+
function showHelp() {
|
|
124
|
+
log(`
|
|
125
|
+
${colors.bold}MeetSudo SDK CLI${colors.reset} v${VERSION}
|
|
126
|
+
|
|
127
|
+
${colors.bold}Usage:${colors.reset}
|
|
128
|
+
npx @meet-sudo/sdk <command>
|
|
129
|
+
|
|
130
|
+
${colors.bold}Commands:${colors.reset}
|
|
131
|
+
doctor Check environment and API connectivity
|
|
132
|
+
version Show SDK version
|
|
133
|
+
help Show this help message
|
|
134
|
+
|
|
135
|
+
${colors.bold}Examples:${colors.reset}
|
|
136
|
+
npx @meet-sudo/sdk doctor
|
|
137
|
+
npx @meet-sudo/sdk version
|
|
138
|
+
|
|
139
|
+
${colors.bold}Documentation:${colors.reset}
|
|
140
|
+
https://www.meetsudo.com/docs
|
|
141
|
+
`);
|
|
142
|
+
}
|
|
143
|
+
function showVersion() {
|
|
144
|
+
log(`@meet-sudo/sdk v${VERSION}`);
|
|
145
|
+
}
|
|
146
|
+
var args = process.argv.slice(2);
|
|
147
|
+
var command = args[0] || "doctor";
|
|
148
|
+
switch (command) {
|
|
149
|
+
case "doctor":
|
|
150
|
+
doctor();
|
|
151
|
+
break;
|
|
152
|
+
case "version":
|
|
153
|
+
case "-v":
|
|
154
|
+
case "--version":
|
|
155
|
+
showVersion();
|
|
156
|
+
break;
|
|
157
|
+
case "help":
|
|
158
|
+
case "-h":
|
|
159
|
+
case "--help":
|
|
160
|
+
showHelp();
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
error(`Unknown command: ${command}`);
|
|
164
|
+
showHelp();
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meet-sudo/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "MeetSudo SDK - Chat, Analytics, Session Replay",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"meet-sudo": "./dist/cli.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|