clapp-pm 1.0.9__py3-none-any.whl → 1.0.11__py3-none-any.whl
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.
- backup_current/build_index.py +132 -0
- backup_current/check_env.py +133 -0
- backup_current/clapp_core.py +61 -0
- backup_current/clean_command.py +214 -0
- backup_current/cli_commands.py +404 -0
- backup_current/dependency_resolver.py +272 -0
- backup_current/doctor_command.py +239 -0
- backup_current/info_command.py +194 -0
- backup_current/install_command.py +236 -0
- backup_current/installer.py +323 -0
- backup_current/list_command.py +262 -0
- backup_current/main.py +294 -0
- backup_current/manifest_schema.py +84 -0
- backup_current/manifest_validator.py +245 -0
- backup_current/package_registry.py +127 -0
- backup_current/package_runner.py +85 -0
- backup_current/post_install_hint.py +144 -0
- backup_current/publish_command.py +253 -0
- backup_current/remote_registry.py +285 -0
- backup_current/setup.py +160 -0
- backup_current/system_test.py +477 -0
- backup_current/uninstall_command.py +215 -0
- backup_current/validate_command.py +225 -0
- backup_current/version.py +8 -0
- backup_current/version_command.py +145 -0
- backup_current/where_command.py +207 -0
- check_env.py +1 -8
- clapp-packages-repo/packages/hello-python/main.py +0 -49
- clapp-packages-repo/packages/hello-python/manifest.json +0 -8
- {clapp_pm-1.0.9.data → clapp_pm-1.0.11.data}/data/version.json +1 -1
- {clapp_pm-1.0.9.dist-info → clapp_pm-1.0.11.dist-info}/METADATA +1 -1
- clapp_pm-1.0.11.dist-info/RECORD +71 -0
- {clapp_pm-1.0.9.dist-info → clapp_pm-1.0.11.dist-info}/top_level.txt +2 -0
- doctor_command.py +0 -1
- install_command.py +3 -0
- version.py +8 -0
- clapp_pm-1.0.9.dist-info/RECORD +0 -44
- {clapp_pm-1.0.9.dist-info → clapp_pm-1.0.11.dist-info}/WHEEL +0 -0
- {clapp_pm-1.0.9.dist-info → clapp_pm-1.0.11.dist-info}/entry_points.txt +0 -0
- {clapp_pm-1.0.9.dist-info → clapp_pm-1.0.11.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,404 @@
|
|
1
|
+
import os
|
2
|
+
import argparse
|
3
|
+
from remote_registry import get_package_info, list_remote_packages, search_packages
|
4
|
+
from installer import install_package, uninstall_package, create_package_from_directory
|
5
|
+
from package_registry import list_packages, get_manifest
|
6
|
+
from dependency_resolver import get_dependency_report, get_system_dependency_report
|
7
|
+
from manifest_validator import validate_manifest_file, get_validation_summary
|
8
|
+
|
9
|
+
# Yeni komut modüllerini import et
|
10
|
+
from publish_command import publish_app
|
11
|
+
from install_command import install_app
|
12
|
+
from uninstall_command import uninstall_app
|
13
|
+
from list_command import list_apps
|
14
|
+
|
15
|
+
def install_from_remote(app_name, force=False):
|
16
|
+
"""
|
17
|
+
Uzak paket deposundan uygulama yükler.
|
18
|
+
|
19
|
+
Args:
|
20
|
+
app_name (str): Yüklenecek uygulama adı
|
21
|
+
force (bool): Mevcut uygulamanın üzerine yazılmasına izin ver
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
tuple: (success: bool, message: str)
|
25
|
+
"""
|
26
|
+
# Yeni install_command modülünü kullan
|
27
|
+
return install_app(app_name)
|
28
|
+
|
29
|
+
def install_from_remote_legacy(app_name, force=False):
|
30
|
+
"""
|
31
|
+
Uzak paket deposundan uygulama yükler (eski sistem).
|
32
|
+
|
33
|
+
Args:
|
34
|
+
app_name (str): Yüklenecek uygulama adı
|
35
|
+
force (bool): Mevcut uygulamanın üzerine yazılmasına izin ver
|
36
|
+
|
37
|
+
Returns:
|
38
|
+
tuple: (success: bool, message: str)
|
39
|
+
"""
|
40
|
+
print(f"'{app_name}' uzak paket deposunda aranıyor...")
|
41
|
+
|
42
|
+
# Uzak paket bilgilerini al
|
43
|
+
package_info = get_package_info(app_name)
|
44
|
+
|
45
|
+
if not package_info:
|
46
|
+
return False, f"'{app_name}' uzak paket deposunda bulunamadı"
|
47
|
+
|
48
|
+
# İndirme URL'sini al
|
49
|
+
download_url = package_info.get('download_url')
|
50
|
+
if not download_url:
|
51
|
+
return False, f"'{app_name}' için indirme URL'si bulunamadı"
|
52
|
+
|
53
|
+
print(f"📦 {app_name} v{package_info.get('version', '0.0.0')}")
|
54
|
+
print(f"📝 {package_info.get('description', 'Açıklama yok')}")
|
55
|
+
print(f"💻 Dil: {package_info.get('language', 'Bilinmiyor')}")
|
56
|
+
|
57
|
+
# Bağımlılıkları göster
|
58
|
+
dependencies = package_info.get('dependencies', [])
|
59
|
+
if dependencies:
|
60
|
+
print(f"🔗 Bağımlılıklar: {', '.join(dependencies)}")
|
61
|
+
|
62
|
+
print(f"⬇️ İndiriliyor: {download_url}")
|
63
|
+
|
64
|
+
# Paketi yükle
|
65
|
+
success, message = install_package(download_url, force)
|
66
|
+
|
67
|
+
if success:
|
68
|
+
print(f"✅ {message}")
|
69
|
+
|
70
|
+
# Bağımlılık kontrolü
|
71
|
+
print("\n🔍 Bağımlılıklar kontrol ediliyor...")
|
72
|
+
dep_report = get_dependency_report(app_name)
|
73
|
+
print(dep_report)
|
74
|
+
|
75
|
+
else:
|
76
|
+
print(f"❌ {message}")
|
77
|
+
|
78
|
+
return success, message
|
79
|
+
|
80
|
+
def uninstall_from_local(app_name, skip_confirmation=False):
|
81
|
+
"""
|
82
|
+
Yerel uygulamayı kaldırır.
|
83
|
+
|
84
|
+
Args:
|
85
|
+
app_name (str): Kaldırılacak uygulama adı
|
86
|
+
skip_confirmation (bool): Onay sorma
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
tuple: (success: bool, message: str)
|
90
|
+
"""
|
91
|
+
# Yeni uninstall_command modülünü kullan
|
92
|
+
return uninstall_app(app_name, skip_confirmation)
|
93
|
+
|
94
|
+
def publish_to_repository(app_path):
|
95
|
+
"""
|
96
|
+
Uygulamayı repository'e publish eder.
|
97
|
+
|
98
|
+
Args:
|
99
|
+
app_path (str): Uygulama dizini
|
100
|
+
|
101
|
+
Returns:
|
102
|
+
tuple: (success: bool, message: str)
|
103
|
+
"""
|
104
|
+
# Yeni publish_command modülünü kullan
|
105
|
+
return publish_app(app_path)
|
106
|
+
|
107
|
+
def list_installed_apps(format_type="table", language_filter=None, search_term=None):
|
108
|
+
"""
|
109
|
+
Kurulu uygulamaları listeler.
|
110
|
+
|
111
|
+
Args:
|
112
|
+
format_type (str): Çıktı formatı (table, simple, json, detailed)
|
113
|
+
language_filter (str): Dil filtresi
|
114
|
+
search_term (str): Arama terimi
|
115
|
+
|
116
|
+
Returns:
|
117
|
+
tuple: (success: bool, message: str)
|
118
|
+
"""
|
119
|
+
try:
|
120
|
+
output = list_apps(format_type, language_filter, search_term)
|
121
|
+
print(output)
|
122
|
+
return True, "Liste gösterildi"
|
123
|
+
except Exception as e:
|
124
|
+
return False, f"Liste hatası: {e}"
|
125
|
+
|
126
|
+
def upgrade_package(app_name):
|
127
|
+
"""
|
128
|
+
Uygulamayı günceller.
|
129
|
+
|
130
|
+
Args:
|
131
|
+
app_name (str): Güncellenecek uygulama adı
|
132
|
+
|
133
|
+
Returns:
|
134
|
+
tuple: (success: bool, message: str)
|
135
|
+
"""
|
136
|
+
# Yerel sürümü kontrol et
|
137
|
+
local_manifest = get_manifest(app_name)
|
138
|
+
if not local_manifest:
|
139
|
+
return False, f"'{app_name}' yerel olarak yüklü değil"
|
140
|
+
|
141
|
+
local_version = local_manifest.get('version', '0.0.0')
|
142
|
+
|
143
|
+
# Uzak sürümü kontrol et
|
144
|
+
remote_package = get_package_info(app_name)
|
145
|
+
if not remote_package:
|
146
|
+
return False, f"'{app_name}' uzak paket deposunda bulunamadı"
|
147
|
+
|
148
|
+
remote_version = remote_package.get('version', '0.0.0')
|
149
|
+
|
150
|
+
print(f"📦 {app_name}")
|
151
|
+
print(f"📱 Yerel sürüm: {local_version}")
|
152
|
+
print(f"🌐 Uzak sürüm: {remote_version}")
|
153
|
+
|
154
|
+
# Sürüm karşılaştırması (basit string karşılaştırması)
|
155
|
+
if local_version == remote_version:
|
156
|
+
return True, f"'{app_name}' zaten güncel (v{local_version})"
|
157
|
+
|
158
|
+
print(f"🔄 Güncelleme mevcut: {local_version} → {remote_version}")
|
159
|
+
|
160
|
+
# Güncelleme için yeniden yükle
|
161
|
+
return install_from_remote(app_name, force=True)
|
162
|
+
|
163
|
+
def publish_package(app_path):
|
164
|
+
"""
|
165
|
+
Uygulama paketini yayınlamak için hazırlar.
|
166
|
+
|
167
|
+
Args:
|
168
|
+
app_path (str): Uygulama dizini
|
169
|
+
|
170
|
+
Returns:
|
171
|
+
tuple: (success: bool, message: str)
|
172
|
+
"""
|
173
|
+
if not os.path.exists(app_path):
|
174
|
+
return False, f"Dizin bulunamadı: {app_path}"
|
175
|
+
|
176
|
+
if not os.path.isdir(app_path):
|
177
|
+
return False, f"'{app_path}' bir dizin değil"
|
178
|
+
|
179
|
+
print(f"📁 Paket hazırlanıyor: {app_path}")
|
180
|
+
|
181
|
+
# Manifest doğrulama
|
182
|
+
manifest_path = os.path.join(app_path, "manifest.json")
|
183
|
+
is_valid, errors = validate_manifest_file(manifest_path)
|
184
|
+
|
185
|
+
print("🔍 Manifest doğrulanıyor...")
|
186
|
+
print(get_validation_summary(errors))
|
187
|
+
|
188
|
+
if not is_valid:
|
189
|
+
return False, "Manifest doğrulama başarısız"
|
190
|
+
|
191
|
+
# Paketi oluştur
|
192
|
+
success, message, output_file = create_package_from_directory(app_path)
|
193
|
+
|
194
|
+
if success:
|
195
|
+
print(f"✅ {message}")
|
196
|
+
print("\n📋 Yayınlama talimatları:")
|
197
|
+
print("1. Oluşturulan .clapp.zip dosyasını GitHub'a yükleyin")
|
198
|
+
print("2. packages.json dosyasını güncelleyin")
|
199
|
+
print("3. Pull request oluşturun")
|
200
|
+
print(f"\n📁 Paket dosyası: {output_file}")
|
201
|
+
|
202
|
+
else:
|
203
|
+
print(f"❌ {message}")
|
204
|
+
|
205
|
+
return success, message
|
206
|
+
|
207
|
+
def search_remote_packages(query):
|
208
|
+
"""
|
209
|
+
Uzak paket deposunda arama yapar.
|
210
|
+
|
211
|
+
Args:
|
212
|
+
query (str): Arama terimi
|
213
|
+
|
214
|
+
Returns:
|
215
|
+
tuple: (success: bool, message: str)
|
216
|
+
"""
|
217
|
+
print(f"🔍 Arama yapılıyor: '{query}'")
|
218
|
+
|
219
|
+
results = search_packages(query)
|
220
|
+
|
221
|
+
if not results:
|
222
|
+
return False, f"'{query}' için sonuç bulunamadı"
|
223
|
+
|
224
|
+
print(f"✅ {len(results)} sonuç bulundu:\n")
|
225
|
+
|
226
|
+
for package in results:
|
227
|
+
name = package.get('name', 'Bilinmiyor')
|
228
|
+
version = package.get('version', '0.0.0')
|
229
|
+
description = package.get('description', 'Açıklama yok')
|
230
|
+
language = package.get('language', 'Bilinmiyor')
|
231
|
+
|
232
|
+
print(f"📦 {name} (v{version})")
|
233
|
+
print(f" 💻 Dil: {language}")
|
234
|
+
print(f" 📝 {description}")
|
235
|
+
print()
|
236
|
+
|
237
|
+
return True, f"{len(results)} paket bulundu"
|
238
|
+
|
239
|
+
def show_package_info(app_name, remote=False):
|
240
|
+
"""
|
241
|
+
Paket bilgilerini gösterir.
|
242
|
+
|
243
|
+
Args:
|
244
|
+
app_name (str): Uygulama adı
|
245
|
+
remote (bool): Uzak paket deposundan bilgi al
|
246
|
+
|
247
|
+
Returns:
|
248
|
+
tuple: (success: bool, message: str)
|
249
|
+
"""
|
250
|
+
if remote:
|
251
|
+
# Uzak paket bilgisi
|
252
|
+
package = get_package_info(app_name)
|
253
|
+
if not package:
|
254
|
+
return False, f"'{app_name}' uzak paket deposunda bulunamadı"
|
255
|
+
|
256
|
+
print(f"🌐 Uzak Paket Bilgisi: {app_name}")
|
257
|
+
print("=" * 40)
|
258
|
+
|
259
|
+
else:
|
260
|
+
# Yerel paket bilgisi
|
261
|
+
package = get_manifest(app_name)
|
262
|
+
if not package:
|
263
|
+
return False, f"'{app_name}' yerel olarak yüklü değil"
|
264
|
+
|
265
|
+
print(f"📱 Yerel Paket Bilgisi: {app_name}")
|
266
|
+
print("=" * 40)
|
267
|
+
|
268
|
+
# Paket bilgilerini göster
|
269
|
+
print(f"📦 Ad: {package.get('name', 'Bilinmiyor')}")
|
270
|
+
print(f"🔢 Sürüm: {package.get('version', '0.0.0')}")
|
271
|
+
print(f"💻 Dil: {package.get('language', 'Bilinmiyor')}")
|
272
|
+
print(f"📝 Açıklama: {package.get('description', 'Açıklama yok')}")
|
273
|
+
print(f"🚀 Giriş: {package.get('entry', 'Bilinmiyor')}")
|
274
|
+
|
275
|
+
# Bağımlılıklar
|
276
|
+
dependencies = package.get('dependencies', [])
|
277
|
+
if dependencies:
|
278
|
+
print(f"🔗 Bağımlılıklar: {', '.join(dependencies)}")
|
279
|
+
else:
|
280
|
+
print("🔗 Bağımlılık yok")
|
281
|
+
|
282
|
+
# Uzak paket için ek bilgiler
|
283
|
+
if remote and 'download_url' in package:
|
284
|
+
print(f"⬇️ İndirme: {package['download_url']}")
|
285
|
+
|
286
|
+
# Yerel paket için bağımlılık raporu
|
287
|
+
if not remote:
|
288
|
+
print("\n" + get_dependency_report(app_name))
|
289
|
+
|
290
|
+
return True, "Bilgi gösterildi"
|
291
|
+
|
292
|
+
def list_all_packages():
|
293
|
+
"""
|
294
|
+
Hem yerel hem uzak paketleri listeler.
|
295
|
+
|
296
|
+
Returns:
|
297
|
+
tuple: (success: bool, message: str)
|
298
|
+
"""
|
299
|
+
print("📱 Yerel Paketler:")
|
300
|
+
print("=" * 30)
|
301
|
+
|
302
|
+
# Yerel paketler - yeni list_command kullan
|
303
|
+
success, message = list_installed_apps("simple")
|
304
|
+
|
305
|
+
print(f"\n🌐 Uzak Paketler:")
|
306
|
+
print("=" * 30)
|
307
|
+
|
308
|
+
# Uzak paketler
|
309
|
+
remote_list = list_remote_packages()
|
310
|
+
print(remote_list)
|
311
|
+
|
312
|
+
return True, "Paket listesi gösterildi"
|
313
|
+
|
314
|
+
def check_system_health():
|
315
|
+
"""
|
316
|
+
Sistem sağlığını kontrol eder.
|
317
|
+
|
318
|
+
Returns:
|
319
|
+
tuple: (success: bool, message: str)
|
320
|
+
"""
|
321
|
+
print("🏥 Sistem Sağlık Kontrolü")
|
322
|
+
print("=" * 40)
|
323
|
+
|
324
|
+
# Bağımlılık kontrolü
|
325
|
+
print("🔍 Bağımlılıklar kontrol ediliyor...")
|
326
|
+
dep_report = get_system_dependency_report()
|
327
|
+
print(dep_report)
|
328
|
+
|
329
|
+
# Uzak bağlantı kontrolü
|
330
|
+
print("🌐 Uzak bağlantı kontrol ediliyor...")
|
331
|
+
from remote_registry import check_remote_connectivity
|
332
|
+
|
333
|
+
if check_remote_connectivity():
|
334
|
+
print("✅ Uzak paket deposuna bağlantı başarılı")
|
335
|
+
else:
|
336
|
+
print("❌ Uzak paket deposuna bağlantı kurulamadı")
|
337
|
+
|
338
|
+
# Manifest doğrulama
|
339
|
+
print("\n🔍 Tüm manifest'ler doğrulanıyor...")
|
340
|
+
local_packages = list_packages()
|
341
|
+
invalid_count = 0
|
342
|
+
|
343
|
+
for package in local_packages:
|
344
|
+
app_name = package['name']
|
345
|
+
app_path = os.path.join("apps", app_name)
|
346
|
+
manifest_path = os.path.join(app_path, "manifest.json")
|
347
|
+
|
348
|
+
is_valid, errors = validate_manifest_file(manifest_path)
|
349
|
+
if not is_valid:
|
350
|
+
print(f"❌ {app_name}: Geçersiz manifest")
|
351
|
+
invalid_count += 1
|
352
|
+
|
353
|
+
if invalid_count == 0:
|
354
|
+
print("✅ Tüm manifest'ler geçerli")
|
355
|
+
else:
|
356
|
+
print(f"❌ {invalid_count} geçersiz manifest bulundu")
|
357
|
+
|
358
|
+
return True, "Sistem sağlık kontrolü tamamlandı"
|
359
|
+
|
360
|
+
# Yeni komut fonksiyonları
|
361
|
+
def handle_publish_command(args):
|
362
|
+
"""Publish komutunu işler"""
|
363
|
+
if not args.folder:
|
364
|
+
print("❌ Hata: Publish edilecek klasör belirtilmedi")
|
365
|
+
print("Kullanım: clapp publish <folder>")
|
366
|
+
return False, "Klasör belirtilmedi"
|
367
|
+
|
368
|
+
return publish_to_repository(args.folder)
|
369
|
+
|
370
|
+
def handle_install_command(args):
|
371
|
+
"""Install komutunu işler"""
|
372
|
+
if not args.app_name:
|
373
|
+
print("❌ Hata: Kurulacak uygulama adı belirtilmedi")
|
374
|
+
print("Kullanım: clapp install <app_name>")
|
375
|
+
return False, "Uygulama adı belirtilmedi"
|
376
|
+
|
377
|
+
return install_from_remote(args.app_name)
|
378
|
+
|
379
|
+
def handle_uninstall_command(args):
|
380
|
+
"""Uninstall komutunu işler"""
|
381
|
+
if not args.app_name:
|
382
|
+
print("❌ Hata: Kaldırılacak uygulama adı belirtilmedi")
|
383
|
+
print("Kullanım: clapp uninstall <app_name>")
|
384
|
+
return False, "Uygulama adı belirtilmedi"
|
385
|
+
|
386
|
+
return uninstall_from_local(args.app_name, args.yes)
|
387
|
+
|
388
|
+
def handle_list_command(args):
|
389
|
+
"""List komutunu işler"""
|
390
|
+
format_type = getattr(args, 'format', 'table')
|
391
|
+
language_filter = getattr(args, 'language', None)
|
392
|
+
search_term = getattr(args, 'search', None)
|
393
|
+
|
394
|
+
return list_installed_apps(format_type, language_filter, search_term)
|
395
|
+
|
396
|
+
if __name__ == "__main__":
|
397
|
+
# Test için örnek kullanım
|
398
|
+
print("CLI Commands Test")
|
399
|
+
print("=" * 30)
|
400
|
+
|
401
|
+
# Sistem sağlığını kontrol et
|
402
|
+
check_system_health()
|
403
|
+
|
404
|
+
print("\nTest tamamlandı.")
|
@@ -0,0 +1,272 @@
|
|
1
|
+
import os
|
2
|
+
from package_registry import get_manifest, app_exists
|
3
|
+
|
4
|
+
def check_dependencies(manifest):
|
5
|
+
"""
|
6
|
+
Manifest'te belirtilen bağımlılıkları kontrol eder.
|
7
|
+
|
8
|
+
Args:
|
9
|
+
manifest (dict): Kontrol edilecek manifest
|
10
|
+
|
11
|
+
Returns:
|
12
|
+
list: Eksik bağımlılıkların listesi
|
13
|
+
"""
|
14
|
+
missing_dependencies = []
|
15
|
+
|
16
|
+
# Bağımlılık listesini al
|
17
|
+
dependencies = manifest.get('dependencies', [])
|
18
|
+
|
19
|
+
if not dependencies:
|
20
|
+
return missing_dependencies
|
21
|
+
|
22
|
+
# Her bağımlılığı kontrol et
|
23
|
+
for dependency in dependencies:
|
24
|
+
if not app_exists(dependency):
|
25
|
+
missing_dependencies.append(dependency)
|
26
|
+
|
27
|
+
return missing_dependencies
|
28
|
+
|
29
|
+
def check_app_dependencies(app_name):
|
30
|
+
"""
|
31
|
+
Belirtilen uygulamanın bağımlılıklarını kontrol eder.
|
32
|
+
|
33
|
+
Args:
|
34
|
+
app_name (str): Kontrol edilecek uygulama adı
|
35
|
+
|
36
|
+
Returns:
|
37
|
+
tuple: (missing_dependencies: list, dependency_info: dict)
|
38
|
+
"""
|
39
|
+
# Uygulama manifest'ini al
|
40
|
+
manifest = get_manifest(app_name)
|
41
|
+
|
42
|
+
if not manifest:
|
43
|
+
return [], {"error": f"Uygulama '{app_name}' bulunamadı"}
|
44
|
+
|
45
|
+
# Bağımlılıkları kontrol et
|
46
|
+
missing_dependencies = check_dependencies(manifest)
|
47
|
+
|
48
|
+
# Bağımlılık bilgilerini topla
|
49
|
+
dependency_info = {
|
50
|
+
"app_name": app_name,
|
51
|
+
"total_dependencies": len(manifest.get('dependencies', [])),
|
52
|
+
"missing_count": len(missing_dependencies),
|
53
|
+
"satisfied_count": len(manifest.get('dependencies', [])) - len(missing_dependencies),
|
54
|
+
"dependencies": manifest.get('dependencies', []),
|
55
|
+
"missing_dependencies": missing_dependencies
|
56
|
+
}
|
57
|
+
|
58
|
+
return missing_dependencies, dependency_info
|
59
|
+
|
60
|
+
def get_dependency_tree(app_name, visited=None):
|
61
|
+
"""
|
62
|
+
Uygulamanın bağımlılık ağacını oluşturur.
|
63
|
+
|
64
|
+
Args:
|
65
|
+
app_name (str): Uygulama adı
|
66
|
+
visited (set): Ziyaret edilen uygulamalar (döngüsel bağımlılık kontrolü için)
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
dict: Bağımlılık ağacı
|
70
|
+
"""
|
71
|
+
if visited is None:
|
72
|
+
visited = set()
|
73
|
+
|
74
|
+
# Döngüsel bağımlılık kontrolü
|
75
|
+
if app_name in visited:
|
76
|
+
return {"error": f"Döngüsel bağımlılık tespit edildi: {app_name}"}
|
77
|
+
|
78
|
+
visited.add(app_name)
|
79
|
+
|
80
|
+
# Uygulama manifest'ini al
|
81
|
+
manifest = get_manifest(app_name)
|
82
|
+
|
83
|
+
if not manifest:
|
84
|
+
return {"error": f"Uygulama '{app_name}' bulunamadı"}
|
85
|
+
|
86
|
+
# Bağımlılık ağacını oluştur
|
87
|
+
tree = {
|
88
|
+
"name": app_name,
|
89
|
+
"version": manifest.get('version', '0.0.0'),
|
90
|
+
"language": manifest.get('language', 'unknown'),
|
91
|
+
"dependencies": [],
|
92
|
+
"missing_dependencies": []
|
93
|
+
}
|
94
|
+
|
95
|
+
dependencies = manifest.get('dependencies', [])
|
96
|
+
|
97
|
+
for dep in dependencies:
|
98
|
+
if app_exists(dep):
|
99
|
+
# Bağımlılığın kendi ağacını al
|
100
|
+
dep_tree = get_dependency_tree(dep, visited.copy())
|
101
|
+
tree["dependencies"].append(dep_tree)
|
102
|
+
else:
|
103
|
+
tree["missing_dependencies"].append(dep)
|
104
|
+
|
105
|
+
return tree
|
106
|
+
|
107
|
+
def resolve_all_dependencies(app_name):
|
108
|
+
"""
|
109
|
+
Uygulamanın tüm bağımlılıklarını çözümler (derin analiz).
|
110
|
+
|
111
|
+
Args:
|
112
|
+
app_name (str): Uygulama adı
|
113
|
+
|
114
|
+
Returns:
|
115
|
+
dict: Çözümleme sonuçları
|
116
|
+
"""
|
117
|
+
result = {
|
118
|
+
"app_name": app_name,
|
119
|
+
"status": "unknown",
|
120
|
+
"all_dependencies": set(),
|
121
|
+
"missing_dependencies": set(),
|
122
|
+
"dependency_tree": None,
|
123
|
+
"circular_dependencies": [],
|
124
|
+
"resolution_order": []
|
125
|
+
}
|
126
|
+
|
127
|
+
# Bağımlılık ağacını al
|
128
|
+
tree = get_dependency_tree(app_name)
|
129
|
+
result["dependency_tree"] = tree
|
130
|
+
|
131
|
+
if "error" in tree:
|
132
|
+
result["status"] = "error"
|
133
|
+
return result
|
134
|
+
|
135
|
+
# Tüm bağımlılıkları topla
|
136
|
+
def collect_dependencies(node, all_deps, missing_deps):
|
137
|
+
if "dependencies" in node:
|
138
|
+
for dep in node["dependencies"]:
|
139
|
+
all_deps.add(dep["name"])
|
140
|
+
collect_dependencies(dep, all_deps, missing_deps)
|
141
|
+
|
142
|
+
if "missing_dependencies" in node:
|
143
|
+
for missing in node["missing_dependencies"]:
|
144
|
+
missing_deps.add(missing)
|
145
|
+
|
146
|
+
collect_dependencies(tree, result["all_dependencies"], result["missing_dependencies"])
|
147
|
+
|
148
|
+
# Durum belirleme
|
149
|
+
if result["missing_dependencies"]:
|
150
|
+
result["status"] = "missing_dependencies"
|
151
|
+
else:
|
152
|
+
result["status"] = "resolved"
|
153
|
+
|
154
|
+
# Çözümleme sırası (topological sort benzeri)
|
155
|
+
result["resolution_order"] = list(result["all_dependencies"])
|
156
|
+
|
157
|
+
return result
|
158
|
+
|
159
|
+
def get_dependency_report(app_name):
|
160
|
+
"""
|
161
|
+
Bağımlılık raporu oluşturur.
|
162
|
+
|
163
|
+
Args:
|
164
|
+
app_name (str): Uygulama adı
|
165
|
+
|
166
|
+
Returns:
|
167
|
+
str: Formatlanmış bağımlılık raporu
|
168
|
+
"""
|
169
|
+
missing_deps, dep_info = check_app_dependencies(app_name)
|
170
|
+
|
171
|
+
if "error" in dep_info:
|
172
|
+
return f"❌ Hata: {dep_info['error']}"
|
173
|
+
|
174
|
+
report = f"📦 {app_name} Bağımlılık Raporu\n"
|
175
|
+
report += "=" * 40 + "\n"
|
176
|
+
|
177
|
+
if dep_info["total_dependencies"] == 0:
|
178
|
+
report += "✅ Bu uygulama hiçbir bağımlılığa sahip değil.\n"
|
179
|
+
return report
|
180
|
+
|
181
|
+
report += f"📊 Toplam Bağımlılık: {dep_info['total_dependencies']}\n"
|
182
|
+
report += f"✅ Karşılanan: {dep_info['satisfied_count']}\n"
|
183
|
+
report += f"❌ Eksik: {dep_info['missing_count']}\n\n"
|
184
|
+
|
185
|
+
if missing_deps:
|
186
|
+
report += "🚨 Eksik Bağımlılıklar:\n"
|
187
|
+
for dep in missing_deps:
|
188
|
+
report += f" - {dep}\n"
|
189
|
+
report += "\n"
|
190
|
+
|
191
|
+
if dep_info["satisfied_count"] > 0:
|
192
|
+
satisfied_deps = [dep for dep in dep_info["dependencies"] if dep not in missing_deps]
|
193
|
+
report += "✅ Karşılanan Bağımlılıklar:\n"
|
194
|
+
for dep in satisfied_deps:
|
195
|
+
dep_manifest = get_manifest(dep)
|
196
|
+
version = dep_manifest.get('version', '0.0.0') if dep_manifest else 'bilinmiyor'
|
197
|
+
report += f" - {dep} (v{version})\n"
|
198
|
+
report += "\n"
|
199
|
+
|
200
|
+
return report
|
201
|
+
|
202
|
+
def check_system_dependencies():
|
203
|
+
"""
|
204
|
+
Sistemdeki tüm uygulamaların bağımlılıklarını kontrol eder.
|
205
|
+
|
206
|
+
Returns:
|
207
|
+
dict: Sistem geneli bağımlılık durumu
|
208
|
+
"""
|
209
|
+
from package_registry import list_packages
|
210
|
+
|
211
|
+
packages = list_packages()
|
212
|
+
system_report = {
|
213
|
+
"total_apps": len(packages),
|
214
|
+
"apps_with_dependencies": 0,
|
215
|
+
"apps_with_missing_dependencies": 0,
|
216
|
+
"total_dependencies": 0,
|
217
|
+
"total_missing": 0,
|
218
|
+
"problematic_apps": []
|
219
|
+
}
|
220
|
+
|
221
|
+
for package in packages:
|
222
|
+
app_name = package['name']
|
223
|
+
missing_deps, dep_info = check_app_dependencies(app_name)
|
224
|
+
|
225
|
+
if dep_info["total_dependencies"] > 0:
|
226
|
+
system_report["apps_with_dependencies"] += 1
|
227
|
+
system_report["total_dependencies"] += dep_info["total_dependencies"]
|
228
|
+
|
229
|
+
if missing_deps:
|
230
|
+
system_report["apps_with_missing_dependencies"] += 1
|
231
|
+
system_report["total_missing"] += len(missing_deps)
|
232
|
+
system_report["problematic_apps"].append({
|
233
|
+
"name": app_name,
|
234
|
+
"missing_dependencies": missing_deps
|
235
|
+
})
|
236
|
+
|
237
|
+
return system_report
|
238
|
+
|
239
|
+
def get_system_dependency_report():
|
240
|
+
"""
|
241
|
+
Sistem geneli bağımlılık raporu oluşturur.
|
242
|
+
|
243
|
+
Returns:
|
244
|
+
str: Formatlanmış sistem raporu
|
245
|
+
"""
|
246
|
+
report_data = check_system_dependencies()
|
247
|
+
|
248
|
+
report = "🏢 Sistem Bağımlılık Raporu\n"
|
249
|
+
report += "=" * 40 + "\n"
|
250
|
+
|
251
|
+
report += f"📱 Toplam Uygulama: {report_data['total_apps']}\n"
|
252
|
+
report += f"🔗 Bağımlılığa Sahip: {report_data['apps_with_dependencies']}\n"
|
253
|
+
report += f"⚠️ Eksik Bağımlılığa Sahip: {report_data['apps_with_missing_dependencies']}\n"
|
254
|
+
report += f"📊 Toplam Bağımlılık: {report_data['total_dependencies']}\n"
|
255
|
+
report += f"❌ Toplam Eksik: {report_data['total_missing']}\n\n"
|
256
|
+
|
257
|
+
if report_data['problematic_apps']:
|
258
|
+
report += "🚨 Sorunlu Uygulamalar:\n"
|
259
|
+
for app in report_data['problematic_apps']:
|
260
|
+
report += f" 📦 {app['name']}:\n"
|
261
|
+
for dep in app['missing_dependencies']:
|
262
|
+
report += f" - {dep}\n"
|
263
|
+
report += "\n"
|
264
|
+
else:
|
265
|
+
report += "✅ Tüm bağımlılıklar karşılanmış!\n"
|
266
|
+
|
267
|
+
return report
|
268
|
+
|
269
|
+
if __name__ == "__main__":
|
270
|
+
# Test için örnek kullanım
|
271
|
+
print("Sistem bağımlılık raporu:")
|
272
|
+
print(get_system_dependency_report())
|