@neuledge/graph 0.3.2 → 0.3.3
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/bin/cli.js +36 -39
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -5,41 +5,39 @@ const [, , command, ...args] = process.argv;
|
|
|
5
5
|
const NEULEDGE_API_BASE_URL = "https://api.graph.neuledge.com/v1";
|
|
6
6
|
|
|
7
7
|
(async () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.log("Signing up…");
|
|
8
|
+
switch (command) {
|
|
9
|
+
case "sign-up": {
|
|
10
|
+
const email = args[0];
|
|
11
|
+
if (!email) {
|
|
12
|
+
console.error("Usage: sign-up <email>");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
console.log("Signing up…");
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
if (result?.message) {
|
|
23
|
-
console.log(result.message);
|
|
24
|
-
}
|
|
18
|
+
const result = await signUp(email);
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
console.log("✅ Signed up successfully");
|
|
21
|
+
if (result?.message) {
|
|
22
|
+
console.log(result.message);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
case "help":
|
|
31
|
-
printHelp();
|
|
32
|
-
break;
|
|
33
|
-
|
|
34
|
-
default:
|
|
35
|
-
console.error(`Unknown command: ${command}`);
|
|
36
|
-
process.exit(1);
|
|
25
|
+
break;
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
|
|
28
|
+
case undefined:
|
|
29
|
+
case "help":
|
|
30
|
+
printHelp();
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
console.error(`Unknown command: ${command}`);
|
|
35
|
+
process.exit(1);
|
|
41
36
|
}
|
|
42
|
-
})()
|
|
37
|
+
})().catch((err) => {
|
|
38
|
+
console.error("❌", err.message);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
43
41
|
|
|
44
42
|
function printHelp() {
|
|
45
43
|
console.log(`
|
|
@@ -75,17 +73,16 @@ async function signUp(email) {
|
|
|
75
73
|
});
|
|
76
74
|
|
|
77
75
|
if (!res.ok) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.catch(() => res.text());
|
|
76
|
+
let text = await res.text().catch(() => "No additional detail provided");
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const body = JSON.parse(text);
|
|
80
|
+
const message = body?.error?.message;
|
|
81
|
+
if (message) {
|
|
82
|
+
text = message;
|
|
83
|
+
}
|
|
84
|
+
} catch (_e) {}
|
|
85
|
+
|
|
89
86
|
throw new Error(`Sign-up failed (${res.status}): ${text}`);
|
|
90
87
|
}
|
|
91
88
|
|