From a22d9c9f2eaa625e43468822f9405cbce4dd5e68 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sun, 3 May 2026 12:11:54 -0500 Subject: [PATCH] Make chore targets non-fatal during generation Resolves #30 --- hooks/post_gen_project.py | 18 +++++++++++++++++- {{cookiecutter.__package_slug}}/makefile | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index e2b67a2..bcab1f2 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -130,6 +130,22 @@ def run_command(command): sys.exit(returncode) +def run_command_loose(command): + print(f"Running '{command}'") + process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) + for c in iter(lambda: process.stdout.read(1), b""): + sys.stdout.buffer.write(c) + + returncode = process.wait() + if returncode != 0: + print(f"Warning: '{command}' failed with exit code {returncode}") + + run_command('make all') run_command('make lock') -run_command('make chores') + +chore_targets = ['ruff_fixes', 'black_fixes', 'prettier_fixes', 'tomlsort_fixes'] +if INCLUDE_SQLALCHEMY: + chore_targets.append('document_schema') +for target in chore_targets: + run_command_loose(f'make {target}') diff --git a/{{cookiecutter.__package_slug}}/makefile b/{{cookiecutter.__package_slug}}/makefile index 64de5ca..1156fcd 100644 --- a/{{cookiecutter.__package_slug}}/makefile +++ b/{{cookiecutter.__package_slug}}/makefile @@ -74,6 +74,7 @@ black_fixes: .PHONY: prettier_fixes prettier_fixes: + @command -v npx >/dev/null 2>&1 || { echo >&2 "Error: npx is not installed. Please install Node.js (https://nodejs.org/) to use prettier."; exit 1; } npx --yes prettier --write . --log-level warn .PHONY: tomlsort_fixes @@ -114,6 +115,7 @@ mypy_check: .PHONY: prettier_check prettier_check: + @command -v npx >/dev/null 2>&1 || { echo >&2 "Error: npx is not installed. Please install Node.js (https://nodejs.org/) to use prettier."; exit 1; } npx --yes prettier --check . --log-level warn .PHONY: tomlsort_check