52 lines
3.4 KiB
Python
52 lines
3.4 KiB
Python
from pathlib import Path
|
|
import re
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
for directory in ('lib', 'test', 'android', 'ios', 'macos', 'linux', 'windows'):
|
|
for path in (root / directory).rglob('*'):
|
|
if not path.is_file() or path.suffix not in ('.dart', '.kt', '.java', '.xml', '.plist', '.pbxproj', '.entitlements', '.cc', '.cpp', '.h', '.rc', '.kts', '.txt'):
|
|
continue
|
|
if any(part in ('build', '.gradle', '.cxx', 'Pods', '.symlinks', 'ephemeral') for part in path.parts):
|
|
continue
|
|
text = path.read_text(encoding='utf-8')
|
|
changed = text.replace('package:qlyra/', 'package:ikar/').replace('ru.qlyra.app', 'ru.ikar.app')
|
|
changed = re.sub(r'\bQlyra\b', 'ИКАР', changed)
|
|
if changed != text:
|
|
path.write_text(changed, encoding='utf-8')
|
|
pubspec = root / 'pubspec.yaml'
|
|
text = pubspec.read_text(encoding='utf-8').replace('name: qlyra', 'name: ikar').replace('"Qlyra messenger client."', '"ИКАР — независимый мессенджер."')
|
|
text = re.sub(r'^version: .*$', 'version: 1.0.0+1', text, flags=re.M)
|
|
text = text.replace('assets/qlyra_icon.png', 'assets/ikar_icon.png').replace('assets/qlyra.png', 'assets/ikar.png')
|
|
pubspec.write_text(text, encoding='utf-8')
|
|
gradle = root / 'android/app/build.gradle.kts'
|
|
text = gradle.read_text(encoding='utf-8').replace('id("com.google.gms.google-services")', 'id("com.google.gms.google-services") apply false')
|
|
text = text.replace('val keystoreProperties = Properties()', 'if (file("google-services.json").exists()) { apply(plugin = "com.google.gms.google-services") }\n\nval keystoreProperties = Properties()')
|
|
start = text.index(' productFlavors {')
|
|
end = text.index(' signingConfigs {', start)
|
|
text = text[:start] + ''' productFlavors {
|
|
create("ikar") {
|
|
dimension = "distribution"
|
|
isDefault = true
|
|
applicationId = "ru.ikar.app"
|
|
}
|
|
}
|
|
|
|
''' + text[end:]
|
|
gradle.write_text(text, encoding='utf-8')
|
|
activity = root / 'android/app/src/main/kotlin/ru/qlyra/app/MainActivity.kt'
|
|
text = activity.read_text(encoding='utf-8').replace('super.configureFlutterEngine(flutterEngine)', 'super.configureFlutterEngine(flutterEngine)\n IkarDeviceAuth.register(flutterEngine)')
|
|
activity.write_text(text, encoding='utf-8')
|
|
config = root / 'lib/core/config/config.dart'
|
|
text = config.read_text(encoding='utf-8').replace("'api2.oneme.ru'", "'ikar.kusoft.xyz'")
|
|
text = re.sub(r'static const List<String> presetHosts = \[.*?\];', 'static const List<String> presetHosts = [defaultHost];', text, flags=re.S)
|
|
text = text.replace('defaultTrustMincifryCa = true', 'defaultTrustMincifryCa = false')
|
|
text = text.replace('BuildProfile.devTools ? prefs.getString(prefHostKey) : null', 'prefs.getString(prefHostKey)').replace('BuildProfile.devTools ? prefs.getInt(prefPortKey) : null', 'prefs.getInt(prefPortKey)')
|
|
text = text.replace("import 'build_profile.dart';\n", '')
|
|
text = re.sub(r'trustMincifryCa:\s*prefs.getBool\(prefTrustMincifryKey\) \?\? defaultTrustMincifryCa', 'trustMincifryCa: false', text)
|
|
config.write_text(text, encoding='utf-8')
|
|
for file in ('lib/core/config/app_icon.dart', 'lib/frontend/screens/auth/login_screen.dart'):
|
|
path = root / file
|
|
text = path.read_text(encoding='utf-8').replace('assets/qlyra_icon.png', 'assets/ikar_icon.png').replace('assets/qlyra.png', 'assets/ikar.png')
|
|
path.write_text(text, encoding='utf-8')
|
|
print('ИКАР: package ru.ikar.app, endpoint ikar.kusoft.xyz, independent branding')
|