new features
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
import sys
|
||||
|
||||
source = (
|
||||
Path.home()
|
||||
/ "Developer/Applications/AppleContainerCompose"
|
||||
/ "Sources/ComposeCore.swift"
|
||||
)
|
||||
|
||||
if not source.exists():
|
||||
sys.exit(f"ERROR: File not found: {source}")
|
||||
|
||||
original = source.read_text(encoding="utf-8")
|
||||
|
||||
old = ''' self.services = try rawServices.keys.sorted().map { key in'''
|
||||
|
||||
new = ''' let projectName = self.name
|
||||
self.services = try rawServices.keys.sorted().map { key in'''
|
||||
|
||||
old_image = '''"\\(self.name)-\\(key):latest"'''
|
||||
new_image = '''"\\(projectName)-\\(key):latest"'''
|
||||
|
||||
if original.count(old) != 1:
|
||||
sys.exit("ERROR: Expected services initializer not found exactly once.")
|
||||
|
||||
if original.count(old_image) != 1:
|
||||
sys.exit("ERROR: Expected image expression not found exactly once.")
|
||||
|
||||
updated = original.replace(old, new, 1)
|
||||
updated = updated.replace(old_image, new_image, 1)
|
||||
|
||||
backup = source.with_name(
|
||||
source.name + ".bak-" + datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
)
|
||||
|
||||
backup.write_text(original, encoding="utf-8")
|
||||
source.write_text(updated, encoding="utf-8")
|
||||
|
||||
print(f"Backup: {backup}")
|
||||
print(f"Updated: {source}")
|
||||
print("Fixed self.name capture during services initialization.")
|
||||
print("Rebuild both Xcode targets.")
|
||||
|
||||
Reference in New Issue
Block a user