create-openclaw-bot 5.0.3 → 5.0.4
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/cli.js +46 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { input, select, checkbox, confirm } from '@inquirer/prompts';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import os from 'os';
|
|
6
7
|
import chalk from 'chalk';
|
|
7
8
|
import { spawn, execSync } from 'child_process';
|
|
8
9
|
const TELEGRAM_RELAY_PLUGIN_ID = 'openclaw-telegram-multibot-relay';
|
|
@@ -1622,11 +1623,55 @@ fi
|
|
|
1622
1623
|
if (isMultiBot && channelKey === 'telegram') {
|
|
1623
1624
|
console.log(chalk.yellow(`\n${isVi ? '📋 Xem hướng dẫn sau cài:' : '📋 Read post-install guide:'} ${path.join(projectDir, 'TELEGRAM-POST-INSTALL.md')}`));
|
|
1624
1625
|
}
|
|
1625
|
-
|
|
1626
|
+
// ── Auto-install openclaw binary if not present ──────────────────────────
|
|
1627
|
+
const isOpenClawInstalled = () => { try { execSync('openclaw --version', { stdio: 'ignore' }); return true; } catch { return false; } };
|
|
1628
|
+
if (!isOpenClawInstalled()) {
|
|
1629
|
+
console.log(chalk.cyan(isVi
|
|
1630
|
+
? '\n📦 Đang cài openclaw binary (npm install -g openclaw)...'
|
|
1631
|
+
: '\n📦 Installing openclaw binary (npm install -g openclaw)...'));
|
|
1632
|
+
try {
|
|
1633
|
+
execSync('npm install -g openclaw', { stdio: 'inherit' });
|
|
1634
|
+
console.log(chalk.green(isVi ? '✅ openclaw đã cài xong!' : '✅ openclaw installed!'));
|
|
1635
|
+
} catch {
|
|
1636
|
+
console.log(chalk.yellow(isVi
|
|
1637
|
+
? '⚠️ Không tự cài được. Chạy thủ công: sudo npm install -g openclaw'
|
|
1638
|
+
: '⚠️ Could not auto-install. Run manually: sudo npm install -g openclaw'));
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// ── Auto-sync generated config to ~/.openclaw so `openclaw` picks it up ──
|
|
1643
|
+
|
|
1644
|
+
const homedir = os.homedir();
|
|
1645
|
+
const globalClawDir = path.join(homedir, '.openclaw');
|
|
1646
|
+
const localClawDir = path.join(projectDir, '.openclaw');
|
|
1647
|
+
try {
|
|
1648
|
+
await fs.ensureDir(globalClawDir);
|
|
1649
|
+
await fs.copy(localClawDir, globalClawDir, { overwrite: true });
|
|
1650
|
+
console.log(chalk.green(`\n✅ ${isVi
|
|
1651
|
+
? `Config đã được sync vào ~/.openclaw/ — openclaw sẵn sàng!`
|
|
1652
|
+
: `Config synced to ~/.openclaw/ — openclaw is ready!`}`));
|
|
1653
|
+
} catch (syncErr) {
|
|
1654
|
+
console.log(chalk.yellow(`\n⚠️ ${isVi
|
|
1655
|
+
? `Không thể tự sync config. Chạy thủ công:\n cp -rn ${localClawDir}/. ${globalClawDir}/`
|
|
1656
|
+
: `Could not auto-sync config. Run manually:\n cp -rn ${localClawDir}/. ${globalClawDir}/`}`));
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1626
1659
|
console.log(chalk.cyan(`\n👉 ${isVi ? 'Đã tạo xong file cấu hình native.' : 'Native config files are ready.'}`));
|
|
1627
1660
|
console.log(chalk.gray(isVi
|
|
1628
1661
|
? ` Cấu trúc config: ${isMultiBot && channelKey === 'telegram' ? '.openclaw/ dùng chung + agents/workspace-*' : (isMultiBot ? 'bot1/, bot2/, ...' : '.openclaw/')}`
|
|
1629
1662
|
: ` Config layout: ${isMultiBot && channelKey === 'telegram' ? 'shared .openclaw/ with agents/workspace-*' : (isMultiBot ? 'bot1/, bot2/, ...' : '.openclaw/')}`));
|
|
1663
|
+
|
|
1664
|
+
// Print exact run commands
|
|
1665
|
+
console.log(chalk.bold.white(`\n🚀 ${isVi ? 'Chạy bot ngay:' : 'Start the bot now:'}`));
|
|
1666
|
+
if (isMultiBot && channelKey === 'telegram') {
|
|
1667
|
+
console.log(chalk.white(` pm2 start ${path.join(projectDir, 'ecosystem.config.js')}`));
|
|
1668
|
+
} else {
|
|
1669
|
+
console.log(chalk.white(` openclaw gateway`));
|
|
1670
|
+
}
|
|
1671
|
+
console.log(chalk.gray(isVi
|
|
1672
|
+
? `\n Chạy background (PM2):\n npm install -g pm2\n pm2 start "openclaw gateway" --name "${botName || 'openclaw-bot'}" --cwd ${projectDir}\n pm2 save && pm2 startup`
|
|
1673
|
+
: `\n Run in background (PM2):\n npm install -g pm2\n pm2 start "openclaw gateway" --name "${botName || 'openclaw-bot'}" --cwd ${projectDir}\n pm2 save && pm2 startup`));
|
|
1674
|
+
|
|
1630
1675
|
if (isMultiBot && channelKey === 'telegram') {
|
|
1631
1676
|
console.log(chalk.yellow(`\n${isVi ? '📋 Xem hướng dẫn sau cài:' : '📋 Read post-install guide:'} ${path.join(projectDir, 'TELEGRAM-POST-INSTALL.md')}`));
|
|
1632
1677
|
}
|