clapp-pm 1.0.10__py3-none-any.whl → 1.0.13__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.10.data → clapp_pm-1.0.13.data}/data/version.json +1 -1
- {clapp_pm-1.0.10.dist-info → clapp_pm-1.0.13.dist-info}/METADATA +1 -1
- clapp_pm-1.0.13.dist-info/RECORD +71 -0
- {clapp_pm-1.0.10.dist-info → clapp_pm-1.0.13.dist-info}/top_level.txt +1 -0
- doctor_command.py +0 -1
- install_command.py +3 -0
- version.py +1 -1
- clapp_pm-1.0.10.dist-info/RECORD +0 -45
- {clapp_pm-1.0.10.dist-info → clapp_pm-1.0.13.dist-info}/WHEEL +0 -0
- {clapp_pm-1.0.10.dist-info → clapp_pm-1.0.13.dist-info}/entry_points.txt +0 -0
- {clapp_pm-1.0.10.dist-info → clapp_pm-1.0.13.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
from manifest_schema import validate_manifest
|
4
|
+
|
5
|
+
def list_packages():
|
6
|
+
"""
|
7
|
+
Yüklü paketlerin listesini döndürür.
|
8
|
+
|
9
|
+
Returns:
|
10
|
+
list: Yüklü paketlerin listesi (dict formatında)
|
11
|
+
"""
|
12
|
+
packages = []
|
13
|
+
apps_dir = "apps"
|
14
|
+
|
15
|
+
# apps dizini yoksa oluştur
|
16
|
+
if not os.path.exists(apps_dir):
|
17
|
+
os.makedirs(apps_dir)
|
18
|
+
return packages
|
19
|
+
|
20
|
+
# apps dizinindeki her klasörü kontrol et
|
21
|
+
for app_name in os.listdir(apps_dir):
|
22
|
+
app_path = os.path.join(apps_dir, app_name)
|
23
|
+
|
24
|
+
# Sadece dizinleri kontrol et
|
25
|
+
if os.path.isdir(app_path):
|
26
|
+
manifest_path = os.path.join(app_path, "manifest.json")
|
27
|
+
|
28
|
+
# Manifest dosyası varsa
|
29
|
+
if os.path.exists(manifest_path):
|
30
|
+
try:
|
31
|
+
with open(manifest_path, 'r', encoding='utf-8') as f:
|
32
|
+
manifest = json.load(f)
|
33
|
+
|
34
|
+
# Manifest geçerliyse listeye ekle
|
35
|
+
if validate_manifest(manifest):
|
36
|
+
packages.append({
|
37
|
+
'name': manifest['name'],
|
38
|
+
'version': manifest.get('version', '0.0.0'),
|
39
|
+
'language': manifest.get('language', 'unknown'),
|
40
|
+
'description': manifest.get('description', 'Açıklama yok'),
|
41
|
+
'entry': manifest.get('entry', 'main.py'),
|
42
|
+
'dependencies': manifest.get('dependencies', [])
|
43
|
+
})
|
44
|
+
except (json.JSONDecodeError, KeyError):
|
45
|
+
# Geçersiz manifest dosyası, atla
|
46
|
+
continue
|
47
|
+
|
48
|
+
return packages
|
49
|
+
|
50
|
+
def get_manifest(app_name):
|
51
|
+
"""
|
52
|
+
Belirtilen uygulamanın manifest bilgilerini döndürür.
|
53
|
+
|
54
|
+
Args:
|
55
|
+
app_name (str): Uygulama adı
|
56
|
+
|
57
|
+
Returns:
|
58
|
+
dict or None: Manifest bilgileri veya None (bulunamazsa)
|
59
|
+
"""
|
60
|
+
app_path = os.path.join("apps", app_name)
|
61
|
+
manifest_path = os.path.join(app_path, "manifest.json")
|
62
|
+
|
63
|
+
if not os.path.exists(manifest_path):
|
64
|
+
return None
|
65
|
+
|
66
|
+
try:
|
67
|
+
with open(manifest_path, 'r', encoding='utf-8') as f:
|
68
|
+
manifest = json.load(f)
|
69
|
+
|
70
|
+
# Manifest geçerliyse döndür
|
71
|
+
if validate_manifest(manifest):
|
72
|
+
return manifest
|
73
|
+
else:
|
74
|
+
return None
|
75
|
+
|
76
|
+
except (json.JSONDecodeError, FileNotFoundError):
|
77
|
+
return None
|
78
|
+
|
79
|
+
def app_exists(app_name):
|
80
|
+
"""
|
81
|
+
Belirtilen uygulamanın yüklü olup olmadığını kontrol eder.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
app_name (str): Uygulama adı
|
85
|
+
|
86
|
+
Returns:
|
87
|
+
bool: Uygulama yüklüyse True, değilse False
|
88
|
+
"""
|
89
|
+
return get_manifest(app_name) is not None
|
90
|
+
|
91
|
+
def list_app_names():
|
92
|
+
"""
|
93
|
+
Yüklü uygulamaların sadece isimlerini döndürür.
|
94
|
+
|
95
|
+
Returns:
|
96
|
+
list: Uygulama isimlerinin listesi (string formatında)
|
97
|
+
"""
|
98
|
+
app_names = []
|
99
|
+
apps_dir = "apps"
|
100
|
+
|
101
|
+
# apps dizini yoksa oluştur
|
102
|
+
if not os.path.exists(apps_dir):
|
103
|
+
os.makedirs(apps_dir)
|
104
|
+
return app_names
|
105
|
+
|
106
|
+
# apps dizinindeki her klasörü kontrol et
|
107
|
+
for app_name in os.listdir(apps_dir):
|
108
|
+
app_path = os.path.join(apps_dir, app_name)
|
109
|
+
|
110
|
+
# Sadece dizinleri kontrol et
|
111
|
+
if os.path.isdir(app_path):
|
112
|
+
manifest_path = os.path.join(app_path, "manifest.json")
|
113
|
+
|
114
|
+
# Manifest dosyası varsa
|
115
|
+
if os.path.exists(manifest_path):
|
116
|
+
try:
|
117
|
+
with open(manifest_path, 'r', encoding='utf-8') as f:
|
118
|
+
manifest = json.load(f)
|
119
|
+
|
120
|
+
# Manifest geçerliyse listeye ekle
|
121
|
+
if validate_manifest(manifest):
|
122
|
+
app_names.append(app_name)
|
123
|
+
except (json.JSONDecodeError, KeyError):
|
124
|
+
# Geçersiz manifest dosyası, atla
|
125
|
+
continue
|
126
|
+
|
127
|
+
return app_names
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
import subprocess
|
4
|
+
from package_registry import get_manifest
|
5
|
+
|
6
|
+
def run_app(app_name):
|
7
|
+
"""
|
8
|
+
Belirtilen uygulamayı çalıştırır.
|
9
|
+
|
10
|
+
Args:
|
11
|
+
app_name (str): Çalıştırılacak uygulamanın adı
|
12
|
+
|
13
|
+
Returns:
|
14
|
+
bool: Uygulama başarıyla çalıştırıldıysa True, değilse False
|
15
|
+
"""
|
16
|
+
# Manifest bilgilerini al
|
17
|
+
manifest = get_manifest(app_name)
|
18
|
+
|
19
|
+
if not manifest:
|
20
|
+
print(f"Hata: '{app_name}' uygulaması bulunamadı veya geçersiz manifest dosyası.")
|
21
|
+
return False
|
22
|
+
|
23
|
+
# Uygulama dizini ve giriş dosyası
|
24
|
+
app_path = os.path.join("apps", app_name)
|
25
|
+
entry_file = manifest['entry']
|
26
|
+
entry_path = os.path.join(app_path, entry_file)
|
27
|
+
|
28
|
+
# Giriş dosyasının varlığını kontrol et
|
29
|
+
if not os.path.exists(entry_path):
|
30
|
+
print(f"Hata: Giriş dosyası '{entry_file}' bulunamadı.")
|
31
|
+
return False
|
32
|
+
|
33
|
+
# Dile göre çalıştır
|
34
|
+
language = manifest['language'].lower()
|
35
|
+
|
36
|
+
try:
|
37
|
+
if language == 'python':
|
38
|
+
# Python uygulamasını çalıştır
|
39
|
+
result = subprocess.run(['python', entry_file],
|
40
|
+
cwd=app_path,
|
41
|
+
capture_output=False)
|
42
|
+
return result.returncode == 0
|
43
|
+
|
44
|
+
elif language == 'lua':
|
45
|
+
# Lua uygulamasını çalıştır
|
46
|
+
result = subprocess.run(['lua', entry_file],
|
47
|
+
cwd=app_path,
|
48
|
+
capture_output=False)
|
49
|
+
return result.returncode == 0
|
50
|
+
|
51
|
+
else:
|
52
|
+
print(f"Hata: Desteklenmeyen dil '{language}'. Desteklenen diller: python, lua")
|
53
|
+
return False
|
54
|
+
|
55
|
+
except FileNotFoundError as e:
|
56
|
+
if language == 'python':
|
57
|
+
print("Hata: Python yüklü değil veya PATH'te bulunamadı.")
|
58
|
+
elif language == 'lua':
|
59
|
+
print("Hata: Lua yüklü değil veya PATH'te bulunamadı.")
|
60
|
+
return False
|
61
|
+
|
62
|
+
except Exception as e:
|
63
|
+
print(f"Hata: Uygulama çalıştırılırken bir hata oluştu: {e}")
|
64
|
+
return False
|
65
|
+
|
66
|
+
def get_supported_languages():
|
67
|
+
"""
|
68
|
+
Desteklenen programlama dillerinin listesini döndürür.
|
69
|
+
|
70
|
+
Returns:
|
71
|
+
list: Desteklenen diller listesi
|
72
|
+
"""
|
73
|
+
return ['python', 'lua']
|
74
|
+
|
75
|
+
def check_language_support(language):
|
76
|
+
"""
|
77
|
+
Belirtilen dilin desteklenip desteklenmediğini kontrol eder.
|
78
|
+
|
79
|
+
Args:
|
80
|
+
language (str): Kontrol edilecek dil
|
81
|
+
|
82
|
+
Returns:
|
83
|
+
bool: Dil destekleniyorsa True, değilse False
|
84
|
+
"""
|
85
|
+
return language.lower() in get_supported_languages()
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
post_install_hint.py - Kurulum sonrası yardım ipuçları
|
4
|
+
|
5
|
+
Bu modül kullanıcıya clapp kurulumu sonrasında PATH ve ortam
|
6
|
+
sorunları hakkında bilgi verir.
|
7
|
+
"""
|
8
|
+
|
9
|
+
import os
|
10
|
+
import sys
|
11
|
+
import shutil
|
12
|
+
import platform
|
13
|
+
from pathlib import Path
|
14
|
+
|
15
|
+
def get_platform_type():
|
16
|
+
"""Platform türünü döndürür"""
|
17
|
+
system = platform.system().lower()
|
18
|
+
if system == "windows":
|
19
|
+
return "windows"
|
20
|
+
elif system == "darwin":
|
21
|
+
return "macos"
|
22
|
+
else:
|
23
|
+
return "linux"
|
24
|
+
|
25
|
+
def get_onboarded_flag_path():
|
26
|
+
"""Onboarding flag dosyasının yolunu döndürür"""
|
27
|
+
home = Path.home()
|
28
|
+
clapp_dir = home / ".clapp"
|
29
|
+
return clapp_dir / ".onboarded"
|
30
|
+
|
31
|
+
def is_onboarded():
|
32
|
+
"""Kullanıcının daha önce onboarding gördüğünü kontrol eder"""
|
33
|
+
return get_onboarded_flag_path().exists()
|
34
|
+
|
35
|
+
def mark_as_onboarded():
|
36
|
+
"""Kullanıcıyı onboarded olarak işaretler"""
|
37
|
+
flag_path = get_onboarded_flag_path()
|
38
|
+
flag_path.parent.mkdir(exist_ok=True)
|
39
|
+
flag_path.write_text("onboarded")
|
40
|
+
|
41
|
+
def get_path_suggestions():
|
42
|
+
"""Platform'a göre PATH önerilerini döndürür"""
|
43
|
+
platform_type = get_platform_type()
|
44
|
+
|
45
|
+
if platform_type == "windows":
|
46
|
+
return [
|
47
|
+
"Windows PATH'e eklemek için:",
|
48
|
+
"1. Sistem Özellikleri > Gelişmiş > Ortam Değişkenleri",
|
49
|
+
"2. PATH değişkenine Python Scripts klasörünü ekleyin",
|
50
|
+
"3. Örnek: C:\\Python39\\Scripts",
|
51
|
+
"",
|
52
|
+
"Veya PowerShell'de:",
|
53
|
+
'$env:PATH += ";C:\\Python39\\Scripts"'
|
54
|
+
]
|
55
|
+
elif platform_type == "macos":
|
56
|
+
return [
|
57
|
+
"macOS PATH'e eklemek için:",
|
58
|
+
"~/.zshrc veya ~/.bash_profile dosyasına ekleyin:",
|
59
|
+
'export PATH="$PATH:$HOME/.local/bin"',
|
60
|
+
"",
|
61
|
+
"Sonra terminali yeniden başlatın veya:",
|
62
|
+
"source ~/.zshrc"
|
63
|
+
]
|
64
|
+
else: # linux
|
65
|
+
return [
|
66
|
+
"Linux PATH'e eklemek için:",
|
67
|
+
"~/.bashrc veya ~/.profile dosyasına ekleyin:",
|
68
|
+
'export PATH="$PATH:$HOME/.local/bin"',
|
69
|
+
"",
|
70
|
+
"Sonra terminali yeniden başlatın veya:",
|
71
|
+
"source ~/.bashrc"
|
72
|
+
]
|
73
|
+
|
74
|
+
def show_post_install_hint():
|
75
|
+
"""Kurulum sonrası ipuçlarını gösterir"""
|
76
|
+
# Eğer zaten onboarded ise gösterme
|
77
|
+
if is_onboarded():
|
78
|
+
return
|
79
|
+
|
80
|
+
# clapp PATH'te var mı kontrol et
|
81
|
+
clapp_in_path = shutil.which("clapp") is not None
|
82
|
+
|
83
|
+
if not clapp_in_path:
|
84
|
+
print("🚀 clapp'e Hoş Geldiniz!")
|
85
|
+
print("=" * 50)
|
86
|
+
print("⚠️ clapp komutu sistem PATH'inde bulunamadı.")
|
87
|
+
print("Bu, 'clapp' komutunu her yerden çalıştıramamanız anlamına gelir.")
|
88
|
+
print()
|
89
|
+
|
90
|
+
# Platform'a göre öneriler
|
91
|
+
suggestions = get_path_suggestions()
|
92
|
+
for suggestion in suggestions:
|
93
|
+
print(suggestion)
|
94
|
+
|
95
|
+
print()
|
96
|
+
print("🔧 Alternatif olarak:")
|
97
|
+
print("• Python -m clapp [komut] şeklinde çalıştırabilirsiniz")
|
98
|
+
print("• Veya python main.py [komut] şeklinde çalıştırabilirsiniz")
|
99
|
+
print()
|
100
|
+
print("📋 Sistem kontrolü için: clapp check-env")
|
101
|
+
print("🩺 Detaylı tanılama için: clapp doctor")
|
102
|
+
print()
|
103
|
+
print("Bu mesajı bir daha görmek istemiyorsanız:")
|
104
|
+
print("clapp doctor komutunu çalıştırın ve sorunları düzeltin.")
|
105
|
+
print("=" * 50)
|
106
|
+
else:
|
107
|
+
print("✅ clapp başarıyla kuruldu ve PATH'te mevcut!")
|
108
|
+
print("🎉 Başlamak için: clapp list")
|
109
|
+
|
110
|
+
# Onboarded olarak işaretle
|
111
|
+
mark_as_onboarded()
|
112
|
+
|
113
|
+
def show_welcome_message():
|
114
|
+
"""Hoş geldin mesajını gösterir"""
|
115
|
+
print("🎉 clapp - Hafif Çoklu Dil Uygulama Yöneticisi")
|
116
|
+
print()
|
117
|
+
print("📚 Temel komutlar:")
|
118
|
+
print(" clapp list - Yüklü uygulamaları listele")
|
119
|
+
print(" clapp run <app> - Uygulama çalıştır")
|
120
|
+
print(" clapp info <app> - Uygulama bilgilerini göster")
|
121
|
+
print(" clapp gui - Grafik arayüzü başlat")
|
122
|
+
print(" clapp check-env - Sistem kontrolü")
|
123
|
+
print(" clapp doctor - Detaylı tanılama")
|
124
|
+
print()
|
125
|
+
print("🔧 Yönetim komutları:")
|
126
|
+
print(" clapp install <source> - Uygulama yükle")
|
127
|
+
print(" clapp uninstall <app> - Uygulama kaldır")
|
128
|
+
print(" clapp upgrade <app> - Uygulama güncelle")
|
129
|
+
print(" clapp validate <folder> - Uygulama klasörünü doğrula")
|
130
|
+
print(" clapp clean - Geçici dosyaları temizle")
|
131
|
+
print()
|
132
|
+
print("📖 Daha fazla yardım için: clapp --help")
|
133
|
+
|
134
|
+
def check_first_run():
|
135
|
+
"""İlk çalıştırma kontrolü yapar"""
|
136
|
+
if not is_onboarded():
|
137
|
+
show_welcome_message()
|
138
|
+
print()
|
139
|
+
show_post_install_hint()
|
140
|
+
return True
|
141
|
+
return False
|
142
|
+
|
143
|
+
if __name__ == "__main__":
|
144
|
+
show_post_install_hint()
|
@@ -0,0 +1,253 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
publish_command.py - clapp Publish Command
|
4
|
+
|
5
|
+
Bu modül 'clapp publish <folder>' komutunu uygular.
|
6
|
+
Bir uygulama klasörünü validate edip packages/ klasörüne kopyalar
|
7
|
+
ve index.json'u günceller. Opsiyonel olarak clapp-packages reposuna push eder.
|
8
|
+
"""
|
9
|
+
|
10
|
+
import os
|
11
|
+
import shutil
|
12
|
+
import subprocess
|
13
|
+
import sys
|
14
|
+
from pathlib import Path
|
15
|
+
from typing import Tuple, Optional
|
16
|
+
|
17
|
+
from manifest_validator import validate_manifest_verbose
|
18
|
+
from manifest_schema import load_manifest
|
19
|
+
|
20
|
+
def validate_app_folder(folder_path: str) -> Tuple[bool, str, Optional[dict]]:
|
21
|
+
"""
|
22
|
+
Uygulama klasörünü doğrular
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
(success, message, manifest_data)
|
26
|
+
"""
|
27
|
+
if not os.path.exists(folder_path):
|
28
|
+
return False, f"Klasör bulunamadı: {folder_path}", None
|
29
|
+
|
30
|
+
if not os.path.isdir(folder_path):
|
31
|
+
return False, f"Geçerli bir klasör değil: {folder_path}", None
|
32
|
+
|
33
|
+
# manifest.json kontrolü
|
34
|
+
manifest_path = os.path.join(folder_path, "manifest.json")
|
35
|
+
if not os.path.exists(manifest_path):
|
36
|
+
return False, "manifest.json dosyası bulunamadı", None
|
37
|
+
|
38
|
+
try:
|
39
|
+
manifest = load_manifest(manifest_path)
|
40
|
+
except Exception as e:
|
41
|
+
return False, f"manifest.json okunamadı: {e}", None
|
42
|
+
|
43
|
+
# Manifest doğrulama
|
44
|
+
is_valid, errors = validate_manifest_verbose(manifest)
|
45
|
+
if not is_valid:
|
46
|
+
error_msg = "Manifest doğrulama hatası:\n" + "\n".join(f" - {error}" for error in errors)
|
47
|
+
return False, error_msg, None
|
48
|
+
|
49
|
+
# Entry file kontrolü
|
50
|
+
entry_file = manifest.get('entry')
|
51
|
+
if entry_file:
|
52
|
+
entry_path = os.path.join(folder_path, entry_file)
|
53
|
+
if not os.path.exists(entry_path):
|
54
|
+
return False, f"Entry dosyası bulunamadı: {entry_file}", None
|
55
|
+
|
56
|
+
return True, "Doğrulama başarılı", manifest
|
57
|
+
|
58
|
+
def copy_app_to_packages(source_folder: str, app_name: str) -> Tuple[bool, str]:
|
59
|
+
"""
|
60
|
+
Uygulama klasörünü packages/ altına kopyalar
|
61
|
+
|
62
|
+
Returns:
|
63
|
+
(success, message)
|
64
|
+
"""
|
65
|
+
try:
|
66
|
+
packages_dir = "./packages"
|
67
|
+
target_path = os.path.join(packages_dir, app_name)
|
68
|
+
|
69
|
+
# packages klasörünü oluştur
|
70
|
+
os.makedirs(packages_dir, exist_ok=True)
|
71
|
+
|
72
|
+
# Eğer hedef klasör varsa, sil
|
73
|
+
if os.path.exists(target_path):
|
74
|
+
shutil.rmtree(target_path)
|
75
|
+
print(f"⚠️ Mevcut {app_name} klasörü silindi")
|
76
|
+
|
77
|
+
# Kopyala
|
78
|
+
shutil.copytree(source_folder, target_path)
|
79
|
+
print(f"✅ {app_name} -> packages/{app_name} kopyalandı")
|
80
|
+
|
81
|
+
return True, f"Uygulama başarıyla kopyalandı: packages/{app_name}"
|
82
|
+
|
83
|
+
except Exception as e:
|
84
|
+
return False, f"Kopyalama hatası: {e}"
|
85
|
+
|
86
|
+
def update_index() -> Tuple[bool, str]:
|
87
|
+
"""
|
88
|
+
build_index.py script'ini çalıştırarak index.json'u günceller
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
(success, message)
|
92
|
+
"""
|
93
|
+
try:
|
94
|
+
# build_index.py'yi çalıştır
|
95
|
+
result = subprocess.run([
|
96
|
+
sys.executable, "build_index.py"
|
97
|
+
], capture_output=True, text=True, cwd=".")
|
98
|
+
|
99
|
+
if result.returncode == 0:
|
100
|
+
return True, "Index başarıyla güncellendi"
|
101
|
+
else:
|
102
|
+
return False, f"Index güncelleme hatası: {result.stderr}"
|
103
|
+
|
104
|
+
except Exception as e:
|
105
|
+
return False, f"Index script çalıştırılamadı: {e}"
|
106
|
+
|
107
|
+
def push_to_clapp_packages_repo(app_name: str, app_version: str) -> Tuple[bool, str]:
|
108
|
+
"""
|
109
|
+
Değişiklikleri clapp-packages reposuna push eder
|
110
|
+
|
111
|
+
Returns:
|
112
|
+
(success, message)
|
113
|
+
"""
|
114
|
+
try:
|
115
|
+
print("4️⃣ clapp-packages reposuna push ediliyor...")
|
116
|
+
|
117
|
+
# clapp-packages reposunu kontrol et
|
118
|
+
packages_repo_path = "./clapp-packages-repo"
|
119
|
+
|
120
|
+
# Eğer clapp-packages repo klonlanmamışsa, klonla
|
121
|
+
if not os.path.exists(packages_repo_path):
|
122
|
+
print("📥 clapp-packages reposu klonlanıyor...")
|
123
|
+
subprocess.run([
|
124
|
+
'git', 'clone', 'https://github.com/mburakmmm/clapp-packages.git',
|
125
|
+
packages_repo_path
|
126
|
+
], check=True, cwd=".")
|
127
|
+
|
128
|
+
# packages/ klasörünü clapp-packages reposuna kopyala
|
129
|
+
source_packages = "./packages"
|
130
|
+
target_packages = os.path.join(packages_repo_path, "packages")
|
131
|
+
|
132
|
+
if os.path.exists(target_packages):
|
133
|
+
shutil.rmtree(target_packages)
|
134
|
+
|
135
|
+
shutil.copytree(source_packages, target_packages)
|
136
|
+
print(f"✅ packages/ klasörü clapp-packages reposuna kopyalandı")
|
137
|
+
|
138
|
+
# index.json'u da kopyala
|
139
|
+
if os.path.exists("index.json"):
|
140
|
+
shutil.copy("index.json", os.path.join(packages_repo_path, "index.json"))
|
141
|
+
print("✅ index.json clapp-packages reposuna kopyalandı")
|
142
|
+
|
143
|
+
# clapp-packages reposuna git işlemleri
|
144
|
+
os.chdir(packages_repo_path)
|
145
|
+
|
146
|
+
# Git durumunu kontrol et
|
147
|
+
result = subprocess.run(['git', 'status', '--porcelain'],
|
148
|
+
capture_output=True, text=True)
|
149
|
+
|
150
|
+
if not result.stdout.strip():
|
151
|
+
os.chdir("..")
|
152
|
+
return True, "Değişiklik yok, push gerekmiyor"
|
153
|
+
|
154
|
+
# Değişiklikleri ekle
|
155
|
+
subprocess.run(['git', 'add', '.'], check=True)
|
156
|
+
|
157
|
+
# Commit oluştur
|
158
|
+
commit_message = f"📦 Publish {app_name} v{app_version}\n\n- {app_name} uygulaması packages/ klasörüne eklendi\n- index.json güncellendi\n- Otomatik publish işlemi"
|
159
|
+
|
160
|
+
subprocess.run(['git', 'commit', '-m', commit_message], check=True)
|
161
|
+
|
162
|
+
# Push et
|
163
|
+
subprocess.run(['git', 'push', 'origin', 'main'], check=True)
|
164
|
+
|
165
|
+
# Ana dizine geri dön
|
166
|
+
os.chdir("..")
|
167
|
+
|
168
|
+
return True, "clapp-packages reposuna başarıyla push edildi"
|
169
|
+
|
170
|
+
except subprocess.CalledProcessError as e:
|
171
|
+
# Ana dizine geri dön
|
172
|
+
if os.getcwd() != os.path.abspath("."):
|
173
|
+
os.chdir("..")
|
174
|
+
return False, f"Git işlemi hatası: {e}"
|
175
|
+
except Exception as e:
|
176
|
+
# Ana dizine geri dön
|
177
|
+
if os.getcwd() != os.path.abspath("."):
|
178
|
+
os.chdir("..")
|
179
|
+
return False, f"Push hatası: {e}"
|
180
|
+
|
181
|
+
def publish_app(folder_path: str, force: bool = False, push_to_github: bool = False) -> Tuple[bool, str]:
|
182
|
+
"""
|
183
|
+
Ana publish fonksiyonu
|
184
|
+
|
185
|
+
Args:
|
186
|
+
folder_path: Publish edilecek uygulama klasörü
|
187
|
+
force: Zorla üzerine yaz
|
188
|
+
push_to_github: clapp-packages reposuna push et
|
189
|
+
|
190
|
+
Returns:
|
191
|
+
(success, message)
|
192
|
+
"""
|
193
|
+
print(f"🚀 Publish başlatılıyor: {folder_path}")
|
194
|
+
print("=" * 50)
|
195
|
+
|
196
|
+
# 1. Klasörü doğrula
|
197
|
+
print("1️⃣ Uygulama doğrulanıyor...")
|
198
|
+
is_valid, message, manifest = validate_app_folder(folder_path)
|
199
|
+
|
200
|
+
if not is_valid:
|
201
|
+
return False, f"Doğrulama hatası: {message}"
|
202
|
+
|
203
|
+
app_name = manifest['name']
|
204
|
+
app_version = manifest['version']
|
205
|
+
print(f"✅ {app_name} v{app_version} doğrulandı")
|
206
|
+
|
207
|
+
# 2. Packages klasörüne kopyala
|
208
|
+
print("2️⃣ Uygulama kopyalanıyor...")
|
209
|
+
copy_success, copy_message = copy_app_to_packages(folder_path, app_name)
|
210
|
+
|
211
|
+
if not copy_success:
|
212
|
+
return False, copy_message
|
213
|
+
|
214
|
+
# 3. Index'i güncelle
|
215
|
+
print("3️⃣ Index güncelleniyor...")
|
216
|
+
index_success, index_message = update_index()
|
217
|
+
|
218
|
+
if not index_success:
|
219
|
+
return False, index_message
|
220
|
+
|
221
|
+
# 4. clapp-packages reposuna push (opsiyonel)
|
222
|
+
if push_to_github:
|
223
|
+
push_success, push_message = push_to_clapp_packages_repo(app_name, app_version)
|
224
|
+
if not push_success:
|
225
|
+
print(f"⚠️ {push_message}")
|
226
|
+
return True, f"🎉 '{app_name}' yerel olarak publish edildi! clapp-packages push başarısız."
|
227
|
+
|
228
|
+
return True, f"🎉 '{app_name}' başarıyla publish edildi! Index güncellendi."
|
229
|
+
|
230
|
+
def main():
|
231
|
+
"""CLI entry point"""
|
232
|
+
if len(sys.argv) < 2:
|
233
|
+
print("Kullanım: python publish_command.py <folder_path> [--push]")
|
234
|
+
print("Örnek: python publish_command.py ./my-app")
|
235
|
+
print("Örnek: python publish_command.py ./my-app --push")
|
236
|
+
sys.exit(1)
|
237
|
+
|
238
|
+
folder_path = sys.argv[1]
|
239
|
+
force = "--force" in sys.argv
|
240
|
+
push_to_github = "--push" in sys.argv
|
241
|
+
|
242
|
+
success, message = publish_app(folder_path, force, push_to_github)
|
243
|
+
|
244
|
+
print("\n" + "=" * 50)
|
245
|
+
if success:
|
246
|
+
print(f"✅ {message}")
|
247
|
+
sys.exit(0)
|
248
|
+
else:
|
249
|
+
print(f"❌ {message}")
|
250
|
+
sys.exit(1)
|
251
|
+
|
252
|
+
if __name__ == "__main__":
|
253
|
+
main()
|