in solutions_builder/cli/update.py [0:0]
def solution(solution_path: Annotated[Optional[str],
typer.Argument()] = ".",
template_path=None):
"""
Update an existing solution folder.
"""
if not solution_path:
solution_path = "."
validate_solution_folder(solution_path)
if not os.path.exists(solution_path):
raise FileNotFoundError(f"Solution folder {solution_path} does not exist.")
confirm_msg = "This will update the current solution folder. Continue?"
if solution_path != ".":
confirm_msg = "This will update solution root folder at " \
"'{solution_path}'. Continue?"
confirm(confirm_msg)
# Copy template_root to destination, excluding skaffold.yaml.
orig_sb_yaml = read_yaml(f"{solution_path}/sb.yaml")
if not template_path:
current_dir = os.path.dirname(__file__)
template_path = f"{current_dir}/../template_root"
if not os.path.exists(template_path):
raise FileNotFoundError(f"{template_path} does not exist.")
worker = run_copy(template_path,
solution_path,
exclude=["skaffold.yaml", "sb.yaml"],
unsafe=True)
answers = worker.answers.last
# Restore some fields in sb.yaml.
sb_yaml = read_yaml(f"{solution_path}/sb.yaml")
sb_yaml["created_at"] = orig_sb_yaml["created_at"]
sb_yaml["components"] = orig_sb_yaml["components"]
write_yaml(f"{solution_path}/sb.yaml", sb_yaml)
print_success(f"Complete. Solution folder updated at {solution_path}.\n")