@ducci/jarvis 1.0.49 → 1.0.50

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": "@ducci/jarvis",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -4,24 +4,9 @@ import fs from 'fs';
4
4
  import path from 'path';
5
5
  import os from 'os';
6
6
  import { spawnSync } from 'child_process';
7
- import { createRequire } from 'module';
8
7
  import inquirer from 'inquirer';
9
8
  import chalk from 'chalk';
10
9
 
11
- // Resolve pm2 CLI from local node_modules so it works even when pm2 is not in PATH
12
- // (e.g. when Node is managed by NVM and the shell is not initialised with it).
13
- const _require = createRequire(import.meta.url);
14
- let PM2_BIN;
15
- try {
16
- PM2_BIN = _require.resolve('pm2/bin/pm2');
17
- } catch {
18
- PM2_BIN = null; // will fall back gracefully
19
- }
20
- function pm2(...args) {
21
- if (!PM2_BIN) return { status: 1, error: new Error('pm2 binary not found') };
22
- return spawnSync(process.execPath, [PM2_BIN, ...args], { stdio: 'inherit' });
23
- }
24
-
25
10
  const jarvisDir = path.join(os.homedir(), '.jarvis');
26
11
  const envFile = path.join(jarvisDir, '.env');
27
12
  const configDir = path.join(jarvisDir, 'data', 'config');
@@ -436,7 +421,13 @@ async function run() {
436
421
  }
437
422
  }
438
423
 
439
- // --- LOG ROTATION STEP ---
424
+ // --- PM2 + LOG ROTATION STEP ---
425
+ const pm2Check = spawnSync('pm2', ['--version'], { stdio: 'pipe' });
426
+ if (pm2Check.status !== 0) {
427
+ console.log(chalk.blue('Installing pm2 globally...'));
428
+ spawnSync('npm', ['install', '-g', 'pm2'], { stdio: 'inherit' });
429
+ }
430
+
440
431
  const logrotateModuleDir = path.join(os.homedir(), '.pm2', 'modules', 'pm2-logrotate');
441
432
  const logrotateInstalled = fs.existsSync(logrotateModuleDir);
442
433
 
@@ -454,14 +445,14 @@ async function run() {
454
445
 
455
446
  if (setupLogrotate) {
456
447
  console.log(chalk.blue('Installing pm2-logrotate...'));
457
- const install = pm2('install', 'pm2-logrotate');
448
+ const install = spawnSync('pm2', ['install', 'pm2-logrotate'], { stdio: 'inherit' });
458
449
  if (install.status !== 0) {
459
- console.log(chalk.yellow('Installation failed — try running `pm2 install pm2-logrotate` manually.'));
450
+ console.log(chalk.yellow('Installation failed — make sure pm2 is installed globally (`npm install -g pm2`) and try again.'));
460
451
  } else {
461
- pm2('set', 'pm2-logrotate:max_size', '10M');
462
- pm2('set', 'pm2-logrotate:retain', '5');
463
- pm2('set', 'pm2-logrotate:compress', 'true');
464
- pm2('set', 'pm2-logrotate:rotateInterval', '0 0 * * *');
452
+ spawnSync('pm2', ['set', 'pm2-logrotate:max_size', '10M'], { stdio: 'inherit' });
453
+ spawnSync('pm2', ['set', 'pm2-logrotate:retain', '5'], { stdio: 'inherit' });
454
+ spawnSync('pm2', ['set', 'pm2-logrotate:compress', 'true'], { stdio: 'inherit' });
455
+ spawnSync('pm2', ['set', 'pm2-logrotate:rotateInterval', '0 0 * * *'], { stdio: 'inherit' });
465
456
  console.log(chalk.green('pm2-logrotate installed: 10 MB max, 5 rotated files kept, daily rotation.'));
466
457
  }
467
458
  }