Skip to content

Commit

Permalink
Print results of sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Nov 1, 2024
1 parent 6e8c38d commit 4342764
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
18 changes: 13 additions & 5 deletions backend_addon/hooks/pre_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]


def sanity_check() -> bool:
def sanity_check() -> data.SanityCheckResults:
"""Run sanity checks on the system."""
checks = [
data.SanityCheck(
Expand All @@ -31,8 +31,7 @@ def sanity_check() -> bool:
),
data.SanityCheck("git", commands.check_command_is_available, ["git"], "error"),
]
result = sanity.run_sanity_checks(checks)
return result.status
return sanity.run_sanity_checks(checks)


def main():
Expand All @@ -41,8 +40,17 @@ def main():
print("This template should be run with cookieplone")
sys.exit(1)

console.panel(title="Plone Addon", msg="Creating a new Plone Addon")
if not sanity_check():
msg = """
Creating a new Plone Addon
Sanity check results:
"""
check_results = sanity_check()
for check in check_results.checks:
label = "green" if check.status else "red"
msg = f"{msg}\n - {check.name}: [{label}]{check.message}[/{label}]"
console.panel(title="Plone Addon", msg=f"{msg}\n")
if not check_results.status:
sys.exit(1)


Expand Down
18 changes: 13 additions & 5 deletions project/hooks/pre_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
]


def sanity_check() -> bool:
def sanity_check() -> data.SanityCheckResults:
"""Run sanity checks on the system."""
checks = [
data.SanityCheck(
Expand All @@ -36,8 +36,7 @@ def sanity_check() -> bool:
"Docker", commands.check_docker_version, ["docker"], "warning"
),
]
result = sanity.run_sanity_checks(checks)
return result.status
return sanity.run_sanity_checks(checks)


def main():
Expand All @@ -46,8 +45,17 @@ def main():
print("This template should be run with cookieplone")
sys.exit(1)

console.panel(title="Plone Project", msg="Creating a new Plone Project")
if not sanity_check():
msg = """
Creating a new Plone Project
Sanity check results:
"""
check_results = sanity_check()
for check in check_results.checks:
label = "green" if check.status else "red"
msg = f"{msg}\n - {check.name}: [{label}]{check.message}[/{label}]"
console.panel(title="Plone Project", msg=f"{msg}\n")
if not check_results.status:
sys.exit(1)


Expand Down

0 comments on commit 4342764

Please sign in to comment.