turkiyem 1.7.0 → 1.8.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/commands/menu.js +140 -70
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turkiyem",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Türkiye Toplu Taşıma ve Deprem CLI aracı - AFAD deprem verileri, EGO hat saatleri ve IETT SOAP/GTFS bilgileri",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,86 +1,156 @@
1
+ import chalk from 'chalk';
1
2
  import prompts from 'prompts';
2
3
  import { printBanner } from '../utils/banner.js';
4
+ import { getCity } from '../utils/config.js';
3
5
  import { sehirSec } from './sehir.js';
4
- import { hatSorgula } from './hat.js';
5
- import { depremSon24, deprem7Gun } from './deprem.js';
6
- import { havaGuncel, havaSaatlik } from './hava.js';
6
+ import { hatSorgula, hatCanliSorgula } from './hat.js';
7
+ import { depremSon24, deprem7Gun, depremBuyukluk } from './deprem.js';
8
+ import { havaGuncel, havaSaatlik, havaKalitesi } from './hava.js';
7
9
  import { dovizKurlari } from './doviz.js';
8
10
  import { durakSorgula } from './durak.js';
9
11
 
12
+ function printSessionHeader() {
13
+ const city = getCity();
14
+ const cityLabel = city ? chalk.green.bold(city) : chalk.yellow('seçilmedi');
15
+ console.log('');
16
+ console.log(chalk.gray('─'.repeat(60)));
17
+ console.log(chalk.gray(` 🏙️ Aktif şehir: ${cityLabel} │ ${chalk.gray('Çıkmak için: Ctrl+C veya "Çıkış"')}`));
18
+ console.log(chalk.gray('─'.repeat(60)));
19
+ console.log('');
20
+ }
21
+
10
22
  export async function showMenu() {
11
23
  printBanner();
24
+ console.log(chalk.white.bold(' 🇹🇷 Sürekli oturum modu — İşlem bitince otomatik menüye döner.\n'));
12
25
 
13
- const response = await prompts({
14
- type: 'select',
15
- name: 'action',
16
- message: 'Ne yapmak istersin?',
17
- choices: [
18
- { title: '🌍 Deprem Bilgileri (Son 24 Saat)', value: 'deprem24' },
19
- { title: '🌍 Deprem Bilgileri (Son 7 Gün)', value: 'deprem7' },
20
- { title: '⛅ Güncel Hava Durumu', value: 'havaGuncel' },
21
- { title: '⛅ Saatlik Hava Tahmini', value: 'havaSaatlik' },
22
- { title: '🚌 Toplu Taşıma (Hat Sorgula)', value: 'hat' },
23
- { title: '🚏 Durak Sorgula (Adana/Antalya/Bursa/İzmir)', value: 'durak' },
24
- { title: '₺ Döviz Kurları (TCMB)', value: 'doviz' },
25
- { title: '⚙️ Şehir Değiştir', value: 'sehir' },
26
- { title: '❌ Çıkış', value: 'exit' }
27
- ]
28
- });
26
+ // REPL loop kullanıcı çıkış seçene kadar devam et
27
+ while (true) {
28
+ printSessionHeader();
29
29
 
30
- if (!response.action || response.action === 'exit') {
31
- return;
32
- }
30
+ const response = await prompts({
31
+ type: 'select',
32
+ name: 'action',
33
+ message: 'Ne yapmak istersin?',
34
+ choices: [
35
+ { title: '🚌 Toplu Taşıma (Hat Sorgula)', value: 'hat' },
36
+ { title: '📍 Canlı Araç Takibi', value: 'canli' },
37
+ { title: '🚏 Durak Sorgula', value: 'durak' },
38
+ { title: '🌍 Deprem Bilgileri', value: 'deprem' },
39
+ { title: '⛅ Hava Durumu', value: 'hava' },
40
+ { title: '💱 Döviz Kurları (TCMB)', value: 'doviz' },
41
+ { title: '⚙️ Şehir Değiştir', value: 'sehir' },
42
+ { title: '❌ Çıkış', value: 'exit' }
43
+ ]
44
+ });
33
45
 
34
- switch (response.action) {
35
- case 'deprem24':
36
- await depremSon24();
37
- break;
38
- case 'deprem7':
39
- await deprem7Gun();
40
- break;
41
- case 'havaGuncel':
42
- await havaGuncel();
43
- break;
44
- case 'havaSaatlik':
45
- await havaSaatlik(undefined, 2);
46
- break;
47
- case 'hat': {
48
- const { hatNo } = await prompts({
49
- type: 'text',
50
- name: 'hatNo',
51
- message: 'Sorgulamak istediğiniz hat numarasını/adını girin:'
52
- });
53
- if (hatNo) await hatSorgula(hatNo);
54
- break;
55
- }
56
- case 'durak': {
57
- const { stopId } = await prompts({
58
- type: 'text',
59
- name: 'stopId',
60
- message: 'Durak numarasını (Stop ID / Durak No) girin:'
61
- });
62
- if (stopId) await durakSorgula(stopId);
46
+ // Ctrl+C veya Çıkış
47
+ if (!response.action || response.action === 'exit') {
48
+ console.log('');
49
+ console.log(chalk.cyan(' Görüşmek üzere! 🇹🇷👋'));
50
+ console.log('');
63
51
  break;
64
52
  }
65
- case 'doviz':
66
- await dovizKurlari({ tum: false });
67
- break;
68
- case 'sehir': {
69
- const { sehir } = await prompts({
70
- type: 'select',
71
- name: 'sehir',
72
- message: 'Hangi şehri seçmek istersiniz?',
73
- choices: [
74
- { title: 'Ankara', value: 'ankara' },
75
- { title: 'İstanbul', value: 'istanbul' },
76
- { title: 'Adana', value: 'adana' },
77
- { title: 'Antalya', value: 'antalya' },
78
- { title: 'Bursa', value: 'bursa' },
79
- { title: 'İzmir', value: 'izmir' }
80
- ]
81
- });
82
- if (sehir) sehirSec(sehir);
83
- break;
53
+
54
+ try {
55
+ switch (response.action) {
56
+ case 'hat': {
57
+ const { hatNo } = await prompts({
58
+ type: 'text',
59
+ name: 'hatNo',
60
+ message: 'Hat numarasını/adını girin:'
61
+ });
62
+ if (hatNo) await hatSorgula(hatNo);
63
+ break;
64
+ }
65
+ case 'canli': {
66
+ const { hatNo } = await prompts({
67
+ type: 'text',
68
+ name: 'hatNo',
69
+ message: 'Canlı takip için hat numarasını girin:'
70
+ });
71
+ if (hatNo) await hatCanliSorgula(hatNo, {});
72
+ break;
73
+ }
74
+ case 'durak': {
75
+ const { stopId } = await prompts({
76
+ type: 'text',
77
+ name: 'stopId',
78
+ message: 'Durak numarasını/adını girin:'
79
+ });
80
+ if (stopId) await durakSorgula(stopId);
81
+ break;
82
+ }
83
+ case 'deprem': {
84
+ const { subAction } = await prompts({
85
+ type: 'select',
86
+ name: 'subAction',
87
+ message: 'Hangi deprem verisi?',
88
+ choices: [
89
+ { title: '🕐 Son 24 Saat', value: 'son24' },
90
+ { title: '📅 Son 7 Gün', value: '7gun' },
91
+ { title: '📊 Büyüklüğe Göre Filtrele', value: 'buyukluk' },
92
+ { title: '↩ Geri', value: 'back' }
93
+ ]
94
+ });
95
+ if (subAction === 'son24') await depremSon24();
96
+ else if (subAction === '7gun') await deprem7Gun();
97
+ else if (subAction === 'buyukluk') {
98
+ const { deger } = await prompts({
99
+ type: 'text',
100
+ name: 'deger',
101
+ message: 'Minimum büyüklük değeri (ör: 4.0):'
102
+ });
103
+ if (deger) await depremBuyukluk(deger);
104
+ }
105
+ break;
106
+ }
107
+ case 'hava': {
108
+ const { subAction } = await prompts({
109
+ type: 'select',
110
+ name: 'subAction',
111
+ message: 'Hangi hava verisi?',
112
+ choices: [
113
+ { title: '🌡️ Güncel Hava', value: 'guncel' },
114
+ { title: '⏱️ Saatlik Tahmin', value: 'saatlik' },
115
+ { title: '🏭 Hava Kalitesi', value: 'kalite' },
116
+ { title: '↩ Geri', value: 'back' }
117
+ ]
118
+ });
119
+ if (subAction === 'back') break;
120
+ const { konum } = await prompts({
121
+ type: 'text',
122
+ name: 'konum',
123
+ message: 'Şehir adı veya koordinat (boş bırakırsan seçili şehir):'
124
+ });
125
+ const loc = konum || undefined;
126
+ if (subAction === 'guncel') await havaGuncel(loc);
127
+ else if (subAction === 'saatlik') await havaSaatlik(loc, 2);
128
+ else if (subAction === 'kalite') await havaKalitesi(loc);
129
+ break;
130
+ }
131
+ case 'doviz':
132
+ await dovizKurlari({ tum: false });
133
+ break;
134
+ case 'sehir': {
135
+ const { sehir } = await prompts({
136
+ type: 'select',
137
+ name: 'sehir',
138
+ message: 'Hangi şehri seçmek istersiniz?',
139
+ choices: [
140
+ { title: 'Ankara', value: 'ankara' },
141
+ { title: 'İstanbul', value: 'istanbul' },
142
+ { title: 'Adana', value: 'adana' },
143
+ { title: 'Antalya', value: 'antalya' },
144
+ { title: 'Bursa', value: 'bursa' },
145
+ { title: 'İzmir', value: 'izmir' }
146
+ ]
147
+ });
148
+ if (sehir) sehirSec(sehir);
149
+ break;
150
+ }
151
+ }
152
+ } catch (err) {
153
+ console.log(chalk.red(` Hata: ${err.message}`));
84
154
  }
85
155
  }
86
156
  }