Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print results of sanity checks #94

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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