xx-chat 1.0.0 → 1.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xx-chat",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A simple LAN CLI chat tool",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/cli.js CHANGED
@@ -42,7 +42,10 @@ export async function parseCli() {
42
42
  validate: (input) => input.trim() ? true : 'IP cannot be empty',
43
43
  });
44
44
 
45
- const answers = await inquirer.prompt(questions);
45
+ let answers = {};
46
+ if (questions.length > 0) {
47
+ answers = await inquirer.prompt(questions);
48
+ }
46
49
 
47
50
  return {
48
51
  role: answers.role || options.role,
package/src/ui.js CHANGED
@@ -10,11 +10,18 @@ function completer(line) {
10
10
  }
11
11
 
12
12
  export function initUI(onMessage) {
13
+ process.stdin.removeAllListeners('keypress');
14
+ if (process.stdin.isTTY) {
15
+ process.stdin.setRawMode(true);
16
+ }
17
+ process.stdin.resume();
18
+
13
19
  rl = readline.createInterface({
14
20
  input: process.stdin,
15
21
  output: process.stdout,
16
22
  prompt: '> ',
17
- completer
23
+ completer,
24
+ terminal: true
18
25
  });
19
26
 
20
27
  rl.prompt();
@@ -0,0 +1,17 @@
1
+ import inquirer from 'inquirer';
2
+ import readline from 'readline';
3
+
4
+ async function run() {
5
+ await inquirer.prompt([{ type: 'input', name: 'test', message: 'test' }]);
6
+ const rl = readline.createInterface({
7
+ input: process.stdin,
8
+ output: process.stdout,
9
+ prompt: '> '
10
+ });
11
+ rl.prompt();
12
+ rl.on('line', (line) => {
13
+ console.log('You entered:', line);
14
+ rl.prompt();
15
+ });
16
+ }
17
+ run();
package/test-search.js ADDED
@@ -0,0 +1 @@
1
+ console.log("Searching for similar issues");
@@ -0,0 +1,16 @@
1
+ import { exec } from 'child_process';
2
+ const child = exec('xx-chat');
3
+ child.stdout.on('data', d => console.log('OUT:', JSON.stringify(d)));
4
+ child.stderr.on('data', d => console.log('ERR:', JSON.stringify(d)));
5
+ setTimeout(() => {
6
+ child.stdin.write('\r'); // Select server
7
+ }, 500);
8
+ setTimeout(() => {
9
+ child.stdin.write('Host\r'); // Type nickname
10
+ }, 1000);
11
+ setTimeout(() => {
12
+ child.stdin.write('hello\r'); // Chat message
13
+ }, 2000);
14
+ setTimeout(() => {
15
+ child.kill();
16
+ }, 3000);
@@ -0,0 +1,16 @@
1
+ import { exec } from 'child_process';
2
+ const child = exec('xx-chat');
3
+ child.stdout.on('data', d => console.log('OUT:', JSON.stringify(d)));
4
+ child.stderr.on('data', d => console.log('ERR:', JSON.stringify(d)));
5
+ setTimeout(() => {
6
+ child.stdin.write('\r'); // Select server
7
+ }, 500);
8
+ setTimeout(() => {
9
+ child.stdin.write('Host\r'); // Type nickname
10
+ }, 1000);
11
+ setTimeout(() => {
12
+ child.stdin.write('hello\r'); // Chat message
13
+ }, 2000);
14
+ setTimeout(() => {
15
+ child.kill();
16
+ }, 3000);
@@ -0,0 +1,10 @@
1
+ import { exec } from 'child_process';
2
+ const child = exec('xx-chat --role server --nickname Host');
3
+ child.stdout.on('data', d => console.log('OUT:', JSON.stringify(d)));
4
+ child.stderr.on('data', d => console.log('ERR:', JSON.stringify(d)));
5
+ setTimeout(() => {
6
+ child.stdin.write('hello\r');
7
+ }, 1000);
8
+ setTimeout(() => {
9
+ child.kill();
10
+ }, 2000);