natureco-cli 5.55.0 → 5.57.0

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.
@@ -1,4 +1,6 @@
1
1
  const chalk = require('chalk');
2
+ const { getLang: _gl } = require('../utils/i18n');
3
+ const L = (tr, en) => (_gl() === 'en' ? en : tr);
2
4
  const inquirer = require('../utils/inquirer-wrapper');
3
5
  const qrcode = require('qrcode-terminal');
4
6
  const QRCode = require('qrcode');
@@ -33,8 +35,8 @@ async function whatsapp(action, number) {
33
35
 
34
36
  if (action === 'allow') {
35
37
  if (!number) {
36
- console.log(chalk.red('\n❌ Numara belirtmelisiniz\n'));
37
- console.log(chalk.gray('Kullanım: natureco whatsapp allow <numara>\n'));
38
+ console.log(chalk.red(L('\n❌ Numara belirtmelisiniz\n', '\n❌ You must specify a number\n')));
39
+ console.log(chalk.gray(L('Kullanım: natureco whatsapp allow <numara>\n', 'Usage: natureco whatsapp allow <number>\n')));
38
40
  process.exit(1);
39
41
  }
40
42
  return allowNumber(number);
@@ -49,18 +51,18 @@ async function connectWhatsApp() {
49
51
  const config = getConfig();
50
52
 
51
53
  if (!config.providerUrl) {
52
- console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
54
+ console.log(chalk.red(L('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n', '\n❌ Setup not done. Run "natureco setup" first.\n')));
53
55
  process.exit(1);
54
56
  }
55
57
 
56
- console.log(chalk.yellow('\n⏳ WhatsApp bağlantısı hazırlanıyor...\n'));
58
+ console.log(chalk.yellow(L('\n⏳ WhatsApp bağlantısı hazırlanıyor...\n', '\n⏳ Preparing WhatsApp connection...\n')));
57
59
 
58
60
  // WhatsApp için bot ID oluştur (timestamp-based)
59
61
  const botId = `whatsapp_${Date.now()}`;
60
62
  const selectedBot = { name: 'WhatsApp Bot', id: botId };
61
63
 
62
- console.log(chalk.cyan('\n📱 WhatsApp bağlantısı başlatılıyor...'));
63
- console.log(chalk.gray('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n'));
64
+ console.log(chalk.cyan(L('\n📱 WhatsApp bağlantısı başlatılıyor...', '\n📱 Starting WhatsApp connection...')));
65
+ console.log(chalk.gray(L('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n', 'Open WhatsApp on your phone and scan the QR code.\n')));
64
66
 
65
67
  // Create session directory
66
68
  const sessionDir = path.join(WHATSAPP_SESSION_DIR, botId);
@@ -82,7 +84,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
82
84
  // Get latest Baileys version
83
85
  const { version } = await fetchLatestBaileysVersion();
84
86
 
85
- console.log(chalk.yellow('⏳ WhatsApp client başlatılıyor...\n'));
87
+ console.log(chalk.yellow(L('⏳ WhatsApp client başlatılıyor...\n', '⏳ Starting WhatsApp client...\n')));
86
88
 
87
89
  // Create socket
88
90
  const sock = makeWASocket({
@@ -105,7 +107,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
105
107
  const { connection, lastDisconnect, qr } = update;
106
108
 
107
109
  if (qr && !qrDisplayed) {
108
- console.log(chalk.green('✅ QR kod hazır!\n'));
110
+ console.log(chalk.green(L('✅ QR kod hazır!\n', '✅ QR code ready!\n')));
109
111
 
110
112
  // Display QR code in terminal
111
113
  qrcode.generate(qr, { small: true });
@@ -119,17 +121,17 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
119
121
  margin: 4,
120
122
  color: { dark: '#000000', light: '#FFFFFF' }
121
123
  });
122
- console.log(chalk.green('\n📸 QR PNG kaydedildi: ' + qrPngPath));
123
- console.log(chalk.cyan('🔗 Browserda acmak icin: open ' + qrPngPath));
124
+ console.log(chalk.green(L('\n📸 QR PNG kaydedildi: ', '\n📸 QR PNG saved: ') + qrPngPath));
125
+ console.log(chalk.cyan(L('🔗 Browserda acmak icin: open ', '🔗 To open in browser: open ') + qrPngPath));
124
126
  } catch (e) {
125
127
  // Sessizce gec, terminal QR yeterli
126
128
  }
127
129
 
128
130
  console.log('');
129
- console.log(chalk.gray('1. WhatsApp\'ı açın'));
130
- console.log(chalk.gray('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla'));
131
- console.log(chalk.gray('3. Bu QR kodu taratın\n'));
132
- console.log(chalk.yellow('⏳ QR kod taranması bekleniyor...\n'));
131
+ console.log(chalk.gray(L('1. WhatsApp\'ı açın', '1. Open WhatsApp')));
132
+ console.log(chalk.gray(L('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla', '2. Settings > Linked Devices > Link a Device')));
133
+ console.log(chalk.gray(L('3. Bu QR kodu taratın\n', '3. Scan this QR code\n')));
134
+ console.log(chalk.yellow(L('⏳ QR kod taranması bekleniyor...\n', '⏳ Waiting for QR code scan...\n')));
133
135
 
134
136
  qrDisplayed = true;
135
137
  }
@@ -139,29 +141,29 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
139
141
 
140
142
  if (statusCode === 515 || statusCode === 408) {
141
143
  // Normal — yeniden bağlan, logout değil
142
- console.log(chalk.yellow('🔄 Yeniden bağlanıyor...'));
144
+ console.log(chalk.yellow(L('🔄 Yeniden bağlanıyor...', '🔄 Reconnecting...')));
143
145
  setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config), 2000);
144
146
  return;
145
147
  } else if (statusCode === 401) {
146
- console.log(chalk.red('❌ Oturum sonlandı, tekrar bağlanın.'));
148
+ console.log(chalk.red(L('❌ Oturum sonlandı, tekrar bağlanın.', '❌ Session ended, reconnect.')));
147
149
  process.exit(1);
148
150
  } else if (statusCode === DisconnectReason.loggedOut) {
149
- console.log(chalk.red('\n❌ WhatsApp oturumu kapatıldı\n'));
151
+ console.log(chalk.red(L('\n❌ WhatsApp oturumu kapatıldı\n', '\n❌ WhatsApp session logged out\n')));
150
152
  process.exit(0);
151
153
  } else if (!isConnected) {
152
- console.log(chalk.red('\n❌ Bağlantı başarısız\n'));
153
- console.log(chalk.gray(`Hata kodu: ${statusCode}\n`));
154
+ console.log(chalk.red(L('\n❌ Bağlantı başarısız\n', '\n❌ Connection failed\n')));
155
+ console.log(chalk.gray(`${L('Hata kodu', 'Error code')}: ${statusCode}\n`));
154
156
  process.exit(1);
155
157
  } else {
156
- console.log(chalk.red(`❌ Bağlantı kesildi: ${statusCode}\n`));
158
+ console.log(chalk.red(`❌ ${L('Bağlantı kesildi', 'Connection lost')}: ${statusCode}\n`));
157
159
  process.exit(1);
158
160
  }
159
161
  } else if (connection === 'open') {
160
162
  isConnected = true;
161
- console.log(chalk.green('✅ WhatsApp bağlandı!\n'));
163
+ console.log(chalk.green(L('✅ WhatsApp bağlandı!\n', '✅ WhatsApp connected!\n')));
162
164
  console.log(chalk.cyan('Bot:'), chalk.white(selectedBot.name));
163
- console.log(chalk.cyan('Telefon:'), chalk.white(sock.user?.id || 'Unknown'));
164
- console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/'));
165
+ console.log(chalk.cyan(L('Telefon:', 'Phone:')), chalk.white(sock.user?.id || 'Unknown'));
166
+ console.log(chalk.gray(L('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/', '\nSession saved: ~/.natureco/whatsapp-sessions/')));
165
167
 
166
168
  // Extract own number and add to allowed list
167
169
  const ownNumber = sock.user?.id?.split(':')[0].replace('@s.whatsapp.net', '') || '';
@@ -174,12 +176,12 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
174
176
  config.whatsappAllowedNumbers = allowedNumbers;
175
177
  saveConfig(config);
176
178
 
177
- console.log(chalk.cyan('\nİzin verilen numara:'), chalk.white(`+${ownNumber} (kendi numaranız)`));
178
- console.log(chalk.gray('Başka numara eklemek için: natureco whatsapp allow <numara>'));
179
+ console.log(chalk.cyan(L('\nİzin verilen numara:', '\nAllowed number:')), chalk.white(`+${ownNumber} ${L('(kendi numaranız)', '(your own number)')}`));
180
+ console.log(chalk.gray(L('Başka numara eklemek için: natureco whatsapp allow <numara>', 'To add another number: natureco whatsapp allow <number>')));
179
181
 
180
- console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
181
- console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
182
- console.log(chalk.gray('Gateway, WhatsApp\'ı otomatik olarak başlatacak.\n'));
182
+ console.log(chalk.green(L('\n✅ Kurulum tamamlandı!\n', '\n✅ Setup complete!\n')));
183
+ console.log(chalk.yellow(L('Gateway ile başlatmak için:', 'To start with the gateway:')), chalk.cyan('natureco gateway start'));
184
+ console.log(chalk.gray(L('Gateway, WhatsApp\'ı otomatik olarak başlatacak.\n', 'The gateway will start WhatsApp automatically.\n')));
183
185
 
184
186
  // Exit after setup
185
187
  setTimeout(() => {
@@ -195,7 +197,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
195
197
 
196
198
  // Handle Ctrl+C
197
199
  process.on('SIGINT', () => {
198
- console.log(chalk.yellow('\n\n⚠️ Bağlantı iptal edildi\n'));
200
+ console.log(chalk.yellow(L('\n\n⚠️ Bağlantı iptal edildi\n', '\n\n⚠️ Connection cancelled\n')));
199
201
  process.exit(0);
200
202
  });
201
203
 
@@ -203,8 +205,8 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
203
205
  const msg = err instanceof NatureCoError ? err.message : err?.message ?? 'Unknown error';
204
206
  console.log(chalk.red(`\n❌ Connection failed: ${msg}\n`));
205
207
  if (err?.message?.includes('Cannot find module')) {
206
- console.log(chalk.yellow('⚠️ Baileys paketi yüklü değil. Yükleniyor...\n'));
207
- console.log(chalk.gray('Lütfen şu komutu çalıştırın:\n'));
208
+ console.log(chalk.yellow(L('⚠️ Baileys paketi yüklü değil. Yükleniyor...\n', '⚠️ Baileys package not installed. Installing...\n')));
209
+ console.log(chalk.gray(L('Lütfen şu komutu çalıştırın:\n', 'Please run this command:\n')));
208
210
  console.log(chalk.cyan('npm install -g @whiskeysockets/baileys pino\n'));
209
211
  }
210
212
  process.exit(1);
@@ -240,7 +242,7 @@ async function disconnectWhatsApp() {
240
242
  const sessionDir = path.join(WHATSAPP_SESSION_DIR, config.whatsappBotId);
241
243
  if (fs.existsSync(sessionDir)) {
242
244
  fs.rmSync(sessionDir, { recursive: true, force: true });
243
- console.log(chalk.green('\n✅ Session dosyaları silindi\n'));
245
+ console.log(chalk.green(L('\n✅ Session dosyaları silindi\n', '\n✅ Session files deleted\n')));
244
246
  }
245
247
 
246
248
  // Remove from config
@@ -278,9 +280,9 @@ function statusWhatsApp() {
278
280
  // Show allowed numbers
279
281
  const allowedNumbers = config.whatsappAllowedNumbers || [];
280
282
  if (allowedNumbers.length === 0) {
281
- console.log(chalk.cyan('İzin listesi:'), chalk.gray('Boş (herkesten mesaj kabul edilir)'));
283
+ console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')), chalk.gray(L('Boş (herkesten mesaj kabul edilir)', 'Empty (accepts messages from anyone)')));
282
284
  } else {
283
- console.log(chalk.cyan('İzin listesi:'));
285
+ console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')));
284
286
  allowedNumbers.forEach(num => console.log(chalk.white(` - +${num}`)));
285
287
  }
286
288
 
@@ -309,15 +311,15 @@ function allowNumber(number) {
309
311
  const normalized = number.replace(/[\s\+\-\(\)]/g, '');
310
312
 
311
313
  if (!/^\d+$/.test(normalized)) {
312
- console.log(chalk.red('\n❌ Geçersiz numara formatı\n'));
313
- console.log(chalk.gray('Örnek: natureco whatsapp allow 905551234567\n'));
314
+ console.log(chalk.red(L('\n❌ Geçersiz numara formatı\n', '\n❌ Invalid number format\n')));
315
+ console.log(chalk.gray(L('Örnek: natureco whatsapp allow 905551234567\n', 'Example: natureco whatsapp allow 905551234567\n')));
314
316
  process.exit(1);
315
317
  }
316
318
 
317
319
  const allowedNumbers = config.whatsappAllowedNumbers || [];
318
320
 
319
321
  if (allowedNumbers.includes(normalized)) {
320
- console.log(chalk.yellow('\n⚠️ Bu numara zaten izin listesinde\n'));
322
+ console.log(chalk.yellow(L('\n⚠️ Bu numara zaten izin listesinde\n', '\n⚠️ This number is already in the allowlist\n')));
321
323
  return;
322
324
  }
323
325
 
@@ -325,10 +327,10 @@ function allowNumber(number) {
325
327
  config.whatsappAllowedNumbers = allowedNumbers;
326
328
  saveConfig(config);
327
329
 
328
- console.log(chalk.green('\n✅ Numara izin listesine eklendi\n'));
329
- console.log(chalk.cyan('Numara:'), chalk.white(`+${normalized}`));
330
- console.log(chalk.cyan('Toplam:'), chalk.white(`${allowedNumbers.length} numara`));
331
- console.log(chalk.gray('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n'));
330
+ console.log(chalk.green(L('\n✅ Numara izin listesine eklendi\n', '\n✅ Number added to allowlist\n')));
331
+ console.log(chalk.cyan(L('Numara:', 'Number:')), chalk.white(`+${normalized}`));
332
+ console.log(chalk.cyan(L('Toplam:', 'Total:')), chalk.white(`${allowedNumbers.length} numara`));
333
+ console.log(chalk.gray(L('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n', '\nRestart the gateway: natureco gateway stop && natureco gateway start\n')));
332
334
  }
333
335
 
334
336
  module.exports = whatsapp;
@@ -1,4 +1,6 @@
1
1
  const chalk = require('chalk');
2
+ const { getLang: _gl } = require('../utils/i18n');
3
+ const L = (tr, en) => (_gl() === 'en' ? en : tr);
2
4
  const fs = require('fs');
3
5
  const path = require('path');
4
6
  const os = require('os');
@@ -33,8 +35,8 @@ function workboard(args) {
33
35
  if (action === 'export') return exportBoard();
34
36
  if (action === 'import') return importBoard(params[0]);
35
37
 
36
- console.log(chalk.red(`\n ❌ Bilinmeyen komut: ${action}\n`));
37
- console.log(chalk.gray(' Kullanım: natureco workboard [show|add|move|remove|clear|columns|export|import]\n'));
38
+ console.log(chalk.red(`\n ❌ ${L('Bilinmeyen komut', 'Unknown command')}: ${action}\n`));
39
+ console.log(chalk.gray(L(' Kullanım: natureco workboard [show|add|move|remove|clear|columns|export|import]\n', ' Usage: natureco workboard [show|add|move|remove|clear|columns|export|import]\n')));
38
40
  process.exit(1);
39
41
  }
40
42
 
@@ -80,7 +82,7 @@ function showBoard() {
80
82
 
81
83
  function addItem(text) {
82
84
  if (!text) {
83
- console.log(chalk.red('\n ❌ Text gerekli\n'));
85
+ console.log(chalk.red(L('\n ❌ Text gerekli\n', '\n ❌ Text required\n')));
84
86
  console.log(chalk.cyan(' natureco workboard add "Task description"\n'));
85
87
  process.exit(1);
86
88
  }
@@ -100,7 +102,7 @@ function addItem(text) {
100
102
 
101
103
  function moveItem(id, column) {
102
104
  if (!id || !column) {
103
- console.log(chalk.red('\n ❌ id ve column gerekli\n'));
105
+ console.log(chalk.red(L('\n ❌ id ve column gerekli\n', '\n ❌ id and column required\n')));
104
106
  console.log(chalk.cyan(' natureco workboard move <id> done\n'));
105
107
  process.exit(1);
106
108
  }
@@ -108,7 +110,7 @@ function moveItem(id, column) {
108
110
  const board = loadBoard();
109
111
  const item = board.items.find(i => i.id === id);
110
112
  if (!item) {
111
- console.log(chalk.red(`\n ❌ Item bulunamadı: ${id}\n`));
113
+ console.log(chalk.red(`\n ❌ ${L('Item bulunamadı', 'Item not found')}: ${id}\n`));
112
114
  process.exit(1);
113
115
  }
114
116
 
@@ -120,14 +122,14 @@ function moveItem(id, column) {
120
122
 
121
123
  function removeItem(id) {
122
124
  if (!id) {
123
- console.log(chalk.red('\n ❌ id gerekli\n'));
125
+ console.log(chalk.red(L('\n ❌ id gerekli\n', '\n ❌ id required\n')));
124
126
  process.exit(1);
125
127
  }
126
128
 
127
129
  const board = loadBoard();
128
130
  const idx = board.items.findIndex(i => i.id === id);
129
131
  if (idx === -1) {
130
- console.log(chalk.red(`\n ❌ Item bulunamadı: ${id}\n`));
132
+ console.log(chalk.red(`\n ❌ ${L('Item bulunamadı', 'Item not found')}: ${id}\n`));
131
133
  process.exit(1);
132
134
  }
133
135
 
@@ -140,7 +142,7 @@ function clearBoard() {
140
142
  const board = loadBoard();
141
143
  board.items = [];
142
144
  saveBoard(board);
143
- console.log(chalk.gray('\n 🗑️ Board temizlendi\n'));
145
+ console.log(chalk.gray(L('\n 🗑️ Board temizlendi\n', '\n 🗑️ Board cleared\n')));
144
146
  }
145
147
 
146
148
  function manageColumns(params) {
@@ -150,7 +152,7 @@ function manageColumns(params) {
150
152
  if (params[0] === 'set') {
151
153
  const cols = params.slice(1);
152
154
  if (cols.length === 0) {
153
- console.log(chalk.red('\n ❌ En az bir kolon gerekli\n'));
155
+ console.log(chalk.red(L('\n ❌ En az bir kolon gerekli\n', '\n ❌ At least one column required\n')));
154
156
  process.exit(1);
155
157
  }
156
158
  config.workboard.columns = cols;
@@ -180,26 +182,26 @@ function exportBoard() {
180
182
 
181
183
  function importBoard(filePath) {
182
184
  if (!filePath) {
183
- console.log(chalk.red('\n ❌ Dosya gerekli\n'));
185
+ console.log(chalk.red(L('\n ❌ Dosya gerekli\n', '\n ❌ File required\n')));
184
186
  process.exit(1);
185
187
  }
186
188
 
187
189
  if (!fs.existsSync(filePath)) {
188
- console.log(chalk.red(`\n ❌ Dosya bulunamadı: ${filePath}\n`));
190
+ console.log(chalk.red(`\n ❌ ${L('Dosya bulunamadı', 'File not found')}: ${filePath}\n`));
189
191
  process.exit(1);
190
192
  }
191
193
 
192
194
  try {
193
195
  const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
194
196
  if (!data.items || !Array.isArray(data.items)) {
195
- console.log(chalk.red('\n ❌ Geçersiz board JSON (items array gerekli)\n'));
197
+ console.log(chalk.red(L('\n ❌ Geçersiz board JSON (items array gerekli)\n', '\n ❌ Invalid board JSON (items array required)\n')));
196
198
  process.exit(1);
197
199
  }
198
200
 
199
201
  saveBoard(data);
200
202
  console.log(chalk.green(`\n ✅ Board imported: ${data.items.length} items\n`));
201
203
  } catch (err) {
202
- console.log(chalk.red(`\n ❌ Import hatası: ${err.message}\n`));
204
+ console.log(chalk.red(`\n ❌ ${L('Import hatası', 'Import error')}: ${err.message}\n`));
203
205
  process.exit(1);
204
206
  }
205
207
  }