import os def export_minimalist_project(): output_filename = "project_source_code_light.txt" # 1. الملفات المسموح بها بالاسم الكامل (حساسة لحالة الأحرف) strictly_allowed_names = {'style.json', 'style_mobile.json', '.env', 'env'} # 2. الامتدادات البرمجية المسموح بها (الكود المصدري فقط) allowed_logic_extensions = {'.ts', '.sh'} # 3. مجلدات يتم تجاوزها فوراً لتسريع العملية ignore_dirs = {'node_modules', 'dist', '.git', 'coverage', 'build', '.idea', '.vscode'} file_counter = 0 print("جاري استخراج الملفات المطلوبة فقط (Light Mode)...") with open(output_filename, 'w', encoding='utf-8') as outfile: outfile.write("=" * 60 + "\n") outfile.write("ملفات المشروع المختارة (Style JSON + Source Code)\n") outfile.write("=" * 60 + "\n\n") for root, dirs, files in os.walk('.'): # استثناء المجلدات الثقيلة dirs[:] = [d for d in dirs if d not in ignore_dirs] for file in files: name_lower = file.lower() ext = os.path.splitext(name_lower)[1] # شرط القبول المنطقي: # - إما أن يكون الاسم مطابقاً تماماً لملفات الستايل أو env # - أو أن يكون امتداد ملف كود (ts, sh) if file in strictly_allowed_names or ext in allowed_logic_extensions: # استثناء إضافي لملفات الاختبار أو التكوين الفرعية لتقليل الحجم if '.spec.ts' in name_lower or 'test.ts' in name_lower: continue filepath = os.path.join(root, file) try: with open(filepath, 'r', encoding='utf-8') as f: lines = f.readlines() file_counter += 1 outfile.write("-" * 60 + "\n") outfile.write(f"[{file_counter}] اسم الملف: {file}\n") outfile.write(f"المسار: {filepath}\n") outfile.write("-" * 60 + "\n") for line_number, line in enumerate(lines, 1): # كتابة رقم السطر مع الكود outfile.write(f"{line_number:04d} | {line.rstrip()}\n") outfile.write("\n\n") print(f"تمت الإضافة: {filepath}") except Exception: # تجاوز أي ملف يسبب خطأ في القراءة continue print(f"\n✅ اكتملت العملية بنجاح.") print(f"إجمالي الملفات المضافة: {file_counter}") print(f"الملف الناتج: {output_filename}") if __name__ == "__main__": export_minimalist_project()