@praise166/vire 0.1.3 → 0.1.5

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.
Binary file
package/dist/vire.js CHANGED
@@ -4,6 +4,7 @@ import { spawn } from 'node:child_process';
4
4
  import { access, copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
5
5
  import { dirname, join } from 'node:path';
6
6
  import process from 'node:process';
7
+ import { createInterface } from 'node:readline';
7
8
  import { fileURLToPath } from 'node:url';
8
9
  import { input, password, select } from '@inquirer/prompts';
9
10
  import boxen from 'boxen';
@@ -477,16 +478,15 @@ function quoteCommand(parts) {
477
478
  function startBot(binary, token, login) {
478
479
  console.clear();
479
480
  console.log(boxen([
480
- `${chalk.bold.green('vire.self is starting')}`,
481
+ `${chalk.bold.green('warm welcomes from vire ')}`,
481
482
  `${chalk.dim('user:')} ${login.username}`,
482
483
  `${chalk.dim('requests:')} 0`,
483
- `${chalk.dim('safety:')} use ,global all false to disable autonuke`,
484
484
  ].join('\n'), { ...panelOptions, borderColor: 'cyan' }));
485
485
  return new Promise((resolve, reject) => {
486
486
  const child = spawn(binary, [], {
487
487
  cwd: root,
488
488
  shell: false,
489
- stdio: ['inherit', 'pipe', 'pipe'],
489
+ stdio: ['pipe', 'pipe', 'pipe'],
490
490
  env: {
491
491
  ...process.env,
492
492
  DISCORD_TOKEN: token,
@@ -494,7 +494,8 @@ function startBot(binary, token, login) {
494
494
  NO_COLOR: '1',
495
495
  },
496
496
  });
497
- ora().succeed('vire.self is running');
497
+ ora().succeed('vire is online');
498
+ const terminal = attachTerminalCommands(child);
498
499
  let started = true;
499
500
  child.stdout.setEncoding('utf8');
500
501
  child.stderr.setEncoding('utf8');
@@ -515,6 +516,7 @@ function startBot(binary, token, login) {
515
516
  reject(error);
516
517
  });
517
518
  child.on('exit', code => {
519
+ terminal.close();
518
520
  if (!started) {
519
521
  console.log(chalk.red(`vire.self exited before connecting (${code ?? 0})`));
520
522
  }
@@ -525,6 +527,29 @@ function startBot(binary, token, login) {
525
527
  });
526
528
  });
527
529
  }
530
+ function attachTerminalCommands(child) {
531
+ console.log(chalk.dim('terminal commands: /rpc help'));
532
+ const terminal = createInterface({
533
+ input: process.stdin,
534
+ output: process.stdout,
535
+ terminal: true,
536
+ });
537
+ terminal.on('line', line => {
538
+ const input = line.trim();
539
+ if (!input)
540
+ return;
541
+ if (input === '/quit' || input === '/exit') {
542
+ child.kill();
543
+ return;
544
+ }
545
+ if (!input.startsWith('/')) {
546
+ console.log(chalk.dim('use /rpc help for terminal config'));
547
+ return;
548
+ }
549
+ child.stdin?.write(`${input}\n`);
550
+ });
551
+ return terminal;
552
+ }
528
553
  async function main() {
529
554
  banner();
530
555
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praise166/vire",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,6 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@inquirer/prompts": "^7.3.2",
25
- "@praise166/vire": "^0.1.2",
26
25
  "boxen": "^8.0.1",
27
26
  "chalk": "^5.4.1",
28
27
  "dotenv": "^16.4.7",