@clawcard/cli 1.0.9 → 1.1.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/package.json +1 -1
- package/src/commands/login.js +23 -0
- package/src/commands/referral.js +1 -1
package/package.json
CHANGED
package/src/commands/login.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import open from "open";
|
|
3
4
|
import crypto from "crypto";
|
|
4
5
|
import { saveConfig, isLoggedIn, getConfig, BASE_URL } from "../config.js";
|
|
5
6
|
|
|
7
|
+
const orange = chalk.hex("#FF6B35");
|
|
8
|
+
|
|
6
9
|
export async function loginCommand() {
|
|
7
10
|
if (isLoggedIn()) {
|
|
8
11
|
const config = getConfig();
|
|
@@ -31,6 +34,26 @@ export async function loginCommand() {
|
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
p.log.success(`Logged in as ${result.email}`);
|
|
37
|
+
|
|
38
|
+
// Show referral banner
|
|
39
|
+
try {
|
|
40
|
+
const meRes = await fetch(`${BASE_URL}/api/me`, {
|
|
41
|
+
headers: { Authorization: `Bearer ${result.token}` },
|
|
42
|
+
});
|
|
43
|
+
const me = await meRes.json();
|
|
44
|
+
if (me.referralCode) {
|
|
45
|
+
p.note(
|
|
46
|
+
[
|
|
47
|
+
`Your invite code: ${orange.bold(me.referralCode)}`,
|
|
48
|
+
"",
|
|
49
|
+
chalk.dim("Share it — you both get $5 in credits when they top up!"),
|
|
50
|
+
].join("\n"),
|
|
51
|
+
"Earn $5"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
// non-critical
|
|
56
|
+
}
|
|
34
57
|
} catch (err) {
|
|
35
58
|
s.stop("Login failed");
|
|
36
59
|
p.log.error(err.message);
|
package/src/commands/referral.js
CHANGED
|
@@ -19,7 +19,7 @@ export async function referralCommand() {
|
|
|
19
19
|
[
|
|
20
20
|
`Your code: ${orange.bold(me.referralCode || "N/A")}`,
|
|
21
21
|
"",
|
|
22
|
-
chalk.dim("Share this code — you both get $
|
|
22
|
+
chalk.dim("Share this code — you both get $5 when they top up!"),
|
|
23
23
|
].join("\n"),
|
|
24
24
|
"Referral"
|
|
25
25
|
);
|