31 lines
2.1 KiB
Python
Executable File
31 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Create an isolated simulator project using the real UI and local fictitious data."""
|
|
from pathlib import Path
|
|
import shutil, sys
|
|
root = Path(__file__).resolve().parents[2]
|
|
dest = Path(sys.argv[1]).resolve()
|
|
if dest == root or root in dest.parents:
|
|
raise SystemExit('Capture project must be outside the production project, in Scratch.')
|
|
dest.mkdir(parents=True, exist_ok=True)
|
|
for name in ['Tarnax', 'Tarnax.xcodeproj']:
|
|
shutil.copytree(root/name, dest/name, dirs_exist_ok=True)
|
|
p = dest/'Tarnax/App.swift'
|
|
s = p.read_text().replace('@StateObject private var model = AppModel()', '@StateObject private var model = StoreCapture.model()', 1)
|
|
s = s.replace('@SceneStorage("selectedSection") private var selected = "Home"', '@State private var selected = StoreCapture.section\n @State private var capturePath = StoreCapture.path', 1)
|
|
s = s.replace('@State private var add = false', '@State private var add = StoreCapture.screen == "add"', 1)
|
|
s = s.replace('NavigationStack { section(page) }', 'NavigationStack(path: $capturePath) { section(page) }')
|
|
s = s.replace('NavigationStack { section(selected) }', 'NavigationStack(path: $capturePath) { section(selected) }')
|
|
s = s.replace('guard phase == .active, model.connected, !model.locked else { return }', 'guard false else { return }', 1)
|
|
s += '\n' + (root/'appstore/tools/CaptureFixture.swift').read_text()
|
|
p.write_text(s)
|
|
p = dest/'Tarnax/Core.swift'
|
|
s = p.read_text().replace('@Published private(set) var transferHistory = TransferHistory()', '@Published private(set) var transferHistory = StoreCapture.history', 1)
|
|
s = s.replace('@Published private(set) var preferences: [String: Any] = [:]', '@Published private(set) var preferences: [String: Any] = StoreCapture.preferences', 1)
|
|
p.write_text(s)
|
|
p = dest/'Tarnax/Details.swift'
|
|
s = p.read_text().replace('@State private var tab = "Overview"', '@State private var tab = StoreCapture.screen == "files" ? "Files" : "Overview"', 1)
|
|
p.write_text(s)
|
|
p = dest/'Tarnax.xcodeproj/project.pbxproj'
|
|
p.write_text(p.read_text().replace('net.absdev.Tarnax', 'net.absdev.TarnaxStoreCapture'))
|
|
print(dest/'Tarnax.xcodeproj')
|