@alphavishnu2026/chat-cli 1.0.37 → 1.0.38
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/commands/join.d.ts +2 -0
- package/dist/commands/join.d.ts.map +1 -0
- package/dist/commands/join.js +2 -0
- package/dist/commands/join.js.map +1 -0
- package/dist/commands/rooms.d.ts +2 -0
- package/dist/commands/rooms.d.ts.map +1 -0
- package/dist/commands/rooms.js +9 -0
- package/dist/commands/rooms.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +12 -1
- package/dist/shell.js.map +1 -1
- package/dist/utils/handle-commands.d.ts +2 -0
- package/dist/utils/handle-commands.d.ts.map +1 -0
- package/dist/utils/handle-commands.js +20 -0
- package/dist/utils/handle-commands.js.map +1 -0
- package/package.json +7 -2
- package/src/commands/join.ts +0 -0
- package/src/commands/rooms.ts +12 -0
- package/src/index.ts +4 -5
- package/src/shell.ts +10 -2
- package/src/utils/handle-commands.ts +20 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../src/commands/join.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.js","sourceRoot":"","sources":["../../src/commands/join.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.d.ts","sourceRoot":"","sources":["../../src/commands/rooms.ts"],"names":[],"mappings":"AAEA,eAAQ,MAAM,SAAS,qBAStB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createConnection } from "../connection/kafka.js";
|
|
2
|
+
export const listRooms = async () => {
|
|
3
|
+
const kafka = createConnection("localhost:9092");
|
|
4
|
+
const allTopics = await kafka.admin().listTopics();
|
|
5
|
+
const rooms = allTopics;
|
|
6
|
+
console.log("Available rooms:");
|
|
7
|
+
rooms.forEach((room) => console.log(`- ${room}`));
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=rooms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.js","sourceRoot":"","sources":["../../src/commands/rooms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAE,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IACnC,MAAM,KAAK,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAEjD,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,CAAC;IAEnD,MAAM,KAAK,GAAG,SAAS,CAAC;IAExB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { startChat } from "./shell.js";
|
|
4
|
+
import { listRooms } from "./commands/rooms.js";
|
|
4
5
|
const program = new Command();
|
|
5
6
|
program
|
|
6
7
|
.command("join")
|
|
@@ -10,5 +11,6 @@ program
|
|
|
10
11
|
.action(async (options) => {
|
|
11
12
|
await startChat(options.broker, options.user, options.room);
|
|
12
13
|
});
|
|
14
|
+
program.command("rooms").action(listRooms);
|
|
13
15
|
program.parse();
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,cAAc,CAAC,uBAAuB,CAAC;KACvC,cAAc,CAAC,uBAAuB,CAAC;KACvC,cAAc,CAAC,mBAAmB,CAAC;KACnC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE3C,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAKA,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,iBA+Db"}
|
package/dist/shell.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import readline from "readline";
|
|
2
2
|
import { createConnection } from "./connection/kafka.js";
|
|
3
|
+
import { handleCommands } from "./utils/handle-commands.js";
|
|
4
|
+
import boxen from "boxen";
|
|
3
5
|
export async function startChat(broker, username, room) {
|
|
4
6
|
const kafka = createConnection(broker);
|
|
5
7
|
console.log("Connecting to broker...", broker);
|
|
@@ -14,7 +16,7 @@ export async function startChat(broker, username, room) {
|
|
|
14
16
|
eachMessage: async ({ message }) => {
|
|
15
17
|
const msg = message.value?.toString();
|
|
16
18
|
if (msg) {
|
|
17
|
-
const parsed = JSON.parse(msg);
|
|
19
|
+
const parsed = JSON.parse(msg ?? "");
|
|
18
20
|
if (parsed.user !== username) {
|
|
19
21
|
console.log(`\n${parsed.user}: ${parsed.text}`);
|
|
20
22
|
}
|
|
@@ -29,6 +31,15 @@ export async function startChat(broker, username, room) {
|
|
|
29
31
|
output: process.stdout,
|
|
30
32
|
});
|
|
31
33
|
rl.on("line", async (line) => {
|
|
34
|
+
console.log(boxen("Welcome to KChar", {
|
|
35
|
+
title: "Chat CLI",
|
|
36
|
+
titleAlignment: "center",
|
|
37
|
+
}));
|
|
38
|
+
const trimmedInput = line.trim();
|
|
39
|
+
if (trimmedInput.startsWith("/")) {
|
|
40
|
+
await handleCommands(trimmedInput.split("/")[1] ?? "");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
32
43
|
rl.prompt();
|
|
33
44
|
await producer.send({
|
|
34
45
|
topic: room,
|
package/dist/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,MAA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,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,kBAAkB,EAAE;YACxB,KAAK,EAAE,UAAU;YACjB,cAAc,EAAE,QAAQ;SACzB,CAAC,CACH,CAAC;QACF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACvD,OAAO;QACT,CAAC;QACD,EAAE,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,QAAQ,CAAC,IAAI,CAAC;YAClB,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE;gBACR;oBACE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;wBACpB,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,IAAI;wBACV,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;qBACtB,CAAC;iBACH;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-commands.d.ts","sourceRoot":"","sources":["../../src/utils/handle-commands.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,SAAS,MAAM,kBAiBnD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { listRooms } from "../commands/rooms.js";
|
|
2
|
+
export const handleCommands = async (command) => {
|
|
3
|
+
switch (command) {
|
|
4
|
+
case "rooms":
|
|
5
|
+
await listRooms();
|
|
6
|
+
break;
|
|
7
|
+
case "quit":
|
|
8
|
+
console.log("Exiting chat...");
|
|
9
|
+
process.exit(0);
|
|
10
|
+
case "help":
|
|
11
|
+
console.log("Available commands:");
|
|
12
|
+
console.log("/rooms - List available chat rooms");
|
|
13
|
+
console.log("/quit - Exit the chat application");
|
|
14
|
+
console.log("/help - Show this help message");
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
console.log(`Unknown command: ${command}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=handle-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-commands.js","sourceRoot":"","sources":["../../src/utils/handle-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,OAAe,EAAE,EAAE;IACtD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO;YACV,MAAM,SAAS,EAAE,CAAC;YAClB,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;YACjD,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;YAC9C,MAAM;QACR;YACE,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphavishnu2026/chat-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,11 +15,16 @@
|
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"boxen": "^8.0.1",
|
|
19
|
+
"chalk": "^5.6.2",
|
|
18
20
|
"commander": "^14.0.3",
|
|
21
|
+
"figlet": "^1.10.0",
|
|
22
|
+
"inquirer": "^13.2.5",
|
|
19
23
|
"kafkajs": "^2.2.4",
|
|
24
|
+
"ora": "^9.3.0",
|
|
20
25
|
"readline": "^1.3.0"
|
|
21
26
|
},
|
|
22
27
|
"devDependencies": {
|
|
23
28
|
"@types/node": "^25.2.3"
|
|
24
29
|
}
|
|
25
|
-
}
|
|
30
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createConnection } from "../connection/kafka.js";
|
|
2
|
+
|
|
3
|
+
export const listRooms = async () => {
|
|
4
|
+
const kafka = createConnection("localhost:9092");
|
|
5
|
+
|
|
6
|
+
const allTopics = await kafka.admin().listTopics();
|
|
7
|
+
|
|
8
|
+
const rooms = allTopics;
|
|
9
|
+
|
|
10
|
+
console.log("Available rooms:");
|
|
11
|
+
rooms.forEach((room) => console.log(`- ${room}`));
|
|
12
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { startChat } from "./shell.js";
|
|
4
|
+
import { listRooms } from "./commands/rooms.js";
|
|
4
5
|
|
|
5
6
|
const program = new Command();
|
|
6
7
|
|
|
@@ -10,11 +11,9 @@ program
|
|
|
10
11
|
.requiredOption("-u, --user <username>")
|
|
11
12
|
.requiredOption("-r, --room <room>")
|
|
12
13
|
.action(async (options) => {
|
|
13
|
-
await startChat(
|
|
14
|
-
options.broker,
|
|
15
|
-
options.user,
|
|
16
|
-
options.room
|
|
17
|
-
);
|
|
14
|
+
await startChat(options.broker, options.user, options.room);
|
|
18
15
|
});
|
|
19
16
|
|
|
17
|
+
program.command("rooms").action(listRooms);
|
|
18
|
+
|
|
20
19
|
program.parse();
|
package/src/shell.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import readline from "readline";
|
|
2
2
|
import { createConnection } from "./connection/kafka.js";
|
|
3
|
+
import { handleCommands } from "./utils/handle-commands.js";
|
|
4
|
+
import boxen from "boxen";
|
|
3
5
|
|
|
4
6
|
export async function startChat(
|
|
5
7
|
broker: string,
|
|
@@ -20,9 +22,9 @@ export async function startChat(
|
|
|
20
22
|
await consumer.run({
|
|
21
23
|
eachMessage: async ({ message }) => {
|
|
22
24
|
const msg = message.value?.toString();
|
|
23
|
-
if (msg) {
|
|
24
|
-
const parsed = JSON.parse(msg);
|
|
25
25
|
|
|
26
|
+
if (msg) {
|
|
27
|
+
const parsed = JSON.parse(msg ?? "");
|
|
26
28
|
if (parsed.user !== username) {
|
|
27
29
|
console.log(`\n${parsed.user}: ${parsed.text}`);
|
|
28
30
|
}
|
|
@@ -40,6 +42,12 @@ export async function startChat(
|
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
rl.on("line", async (line) => {
|
|
45
|
+
|
|
46
|
+
const trimmedInput = line.trim();
|
|
47
|
+
if (trimmedInput.startsWith("/")) {
|
|
48
|
+
await handleCommands(trimmedInput.split("/")[1] ?? "");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
43
51
|
rl.prompt();
|
|
44
52
|
await producer.send({
|
|
45
53
|
topic: room,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { listRooms } from "../commands/rooms.js";
|
|
2
|
+
|
|
3
|
+
export const handleCommands = async (command: string) => {
|
|
4
|
+
switch (command) {
|
|
5
|
+
case "rooms":
|
|
6
|
+
await listRooms();
|
|
7
|
+
break;
|
|
8
|
+
case "quit":
|
|
9
|
+
console.log("Exiting chat...");
|
|
10
|
+
process.exit(0);
|
|
11
|
+
case "help":
|
|
12
|
+
console.log("Available commands:");
|
|
13
|
+
console.log("/rooms - List available chat rooms");
|
|
14
|
+
console.log("/quit - Exit the chat application");
|
|
15
|
+
console.log("/help - Show this help message");
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
console.log(`Unknown command: ${command}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/shell.ts","./src/connection/kafka.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["./src/index.ts","./src/shell.ts","./src/commands/join.ts","./src/commands/rooms.ts","./src/connection/kafka.ts","./src/utils/handle-commands.ts"],"version":"5.9.3"}
|