#!/usr/bin/env python3 """Extract unchanged FUC UI libraries; exclude original business code and duplicate Pace.""" from pathlib import Path import hashlib import json source = Path('/Users/hellcat/Documents/GemCodes/fuc-new.loc/public') out = Path(__file__).resolve().parents[2] / 'theme/Fuc/assets/native' vendor = (source / 'theme/cool/assets/vendors/js/vendors.min.js').read_text() widgets = vendor[:vendor.index('/* Unison JS */')] start = vendor.index('// Waves') widgets += vendor[start:vendor.index('// Promises - for IE11', start)] files = { 'widgets.min.js': widgets.encode(), 'sweetalert2.min.js': (source / 'theme/cool/assets/js/scripts/sweetalert2.min.js').read_bytes(), 'smooth-scroll.min.js': (source / 'assets/cool/smooth-scroll.polyfills.min.js').read_bytes(), 'landing-bootstrap5.min.js': (source / 'assets/cool/bootstrap.bundle.min.js').read_bytes(), } for name, content in files.items(): (out / name).write_bytes(content) (out / 'widgets-provenance.json').write_text(json.dumps({ 'source': 'fuc-new.loc/public', 'widgets': ['jQuery 3.4.1', 'Popper', 'Bootstrap 4.3.1', 'Bootstrap 5.0.0-beta1 for original landing page', 'PerfectScrollbar 1.4.0', 'Hammer 2.0.8', 'Waves', 'SweetAlert2', 'SmoothScroll'], 'sha256': {name: hashlib.sha256(content).hexdigest() for name, content in files.items()}, 'excludes': ['duplicate Pace', 'FUC business scripts', 'remote requests'], }, indent=2) + '\n') print('FUC original UI libraries extracted with hashes; no business scripts included')