Skip to content

Commit ab7570c

Browse files
committed
feat(jinja): Large update for Makefile build. Moved nutri-matic hooks into project to make this easier to manage.
1 parent 29c7df2 commit ab7570c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1792
-134
lines changed

changelogs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,4 @@ Feat 032 (#81)
447447
- *(jinja)* Major registry update. Almost able to build makefile for any tool/env.
448448
- *(jinja)* Jinja registry fixes. Am now mostly able to build command variables and command actions for Makefile.
449449
- *(jinja2)* Makefile template built from registry almost working.
450+
- *(jinja2)* Makefile template upgrade.

changelogs/releases/v0.1.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Changelog:
33
# --------------------------------------------------
44

5-
## [0.1.0] - 2026-02-16
5+
## [0.1.0] - 2026-02-19
66

77
### ⚙️ Miscellaneous
88

@@ -447,3 +447,4 @@ Feat 032 (#81)
447447
- *(jinja)* Major registry update. Almost able to build makefile for any tool/env.
448448
- *(jinja)* Jinja registry fixes. Am now mostly able to build command variables and command actions for Makefile.
449449
- *(jinja2)* Makefile template built from registry almost working.
450+
- *(jinja2)* Makefile template upgrade.

cookiecutter.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@
5757
"bump_my_version": true,
5858
"codespell": true,
5959
"cookiecutter": true,
60+
"cookiecutter_project_upgrader": true,
6061
"deptry": true,
6162
"djlint": true,
6263
"jinja2_cli": false,
6364
"mypy": true,
6465
"nameisok": true,
66+
"nutrimatic": false,
6567
"pip_audit": true,
6668
"pipdeptree": true,
6769
"pre_commit": true,
@@ -74,13 +76,22 @@
7476
"yamllint": true
7577
},
7678
"__rust": {
77-
79+
"built_in": false,
80+
"git_cliff": true
7881
},
7982
"__typescript": {
80-
83+
"built_in": false,
84+
"eslint": false,
85+
"npm": false,
86+
"prettier": false,
87+
"storybook": false,
88+
"tsc": false,
89+
"typedoc": false,
90+
"vitest": false
8191
},
8292
"__tools": {
83-
93+
"github": true,
94+
"git": true
8495
},
8596
"ga_tracking": "G-C7PWLWSHB9",
8697
"github_org": null,
@@ -107,6 +118,7 @@
107118
"__meta": {
108119
"is_python": "{{ 'python' in cookiecutter.template_type }}",
109120
"is_ansible": "{{ 'ansible' in cookiecutter.template_type }}",
121+
"is_cookiecutter": "{{'cookiecutter' in cookiecutter.template_type }}",
110122
"needs_pypi": "{{ 'python' in cookiecutter.template_type and cookiecutter.license != 'none' }}"
111123
},
112124
"_hooks": {

hooks/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# __init__.py for cookiecutter-cookiecutter
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, Jared Cook
4+
# SPDX-License-Identifier: AGPL-3.0-or-later
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.

hooks/post_gen_project.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@
1818

1919
import json
2020
import os
21+
import sys
2122

22-
from nutrimatic.core import make
23-
from nutrimatic.hooks.post_gen_logic import (
23+
PROJECT_ROOT = os.path.abspath(os.curdir)
24+
INCLUDES_PATH = os.path.join(PROJECT_ROOT, ".cookiecutter_includes", "hooks")
25+
26+
if INCLUDES_PATH not in sys.path:
27+
sys.path.insert(0, INCLUDES_PATH)
28+
29+
from core import make # noqa: E402
30+
from post_gen_logic import ( # noqa: E402
2431
generate_cliff_changelog_dirs,
2532
generate_docs_templates,
2633
get_make_cmds,

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ license = "AGPL-3.0-or-later"
3737
license-files = ["LICENSE.md"]
3838
requires-python = ">=3.11"
3939
dependencies = [
40+
"Deprecated>=1.3",
41+
"GitPython>=3.1",
42+
"Jinja2>=3.1",
43+
"pydantic>=2.12",
44+
"PyYAML>=6.0",
4045
"nutri-matic>=0.1",
46+
"toml>=0.10",
47+
"requests>=2.32",
48+
"typer>=0.20",
4149
]
4250
keywords = ["python3", "cookiecutter", "template", "automation"]
4351
classifiers = [
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{#
2+
# hooks/__init__.j2 for cookiecutter-cookiecutter
3+
#
4+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, Jared Cook
5+
# SPDX-License-Identifier: AGPL-3.0-or-later
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as
9+
# published by the Free Software Foundation, either version 3 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Affero General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
#}
20+
21+
{% import '.cookiecutter_includes/hooks/post_gen_project.j2' as _post_gen_project with context %}
22+
{% import '.cookiecutter_includes/hooks/pre_gen_project.j2' as _pre_gen_project with context %}
23+
24+
{% set post_gen_project = _post_gen_project %}
25+
{% set pre_gen_project = _pre_gen_project %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# __init__.py for cookiecutter-cookiecutter
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, Jared Cook
4+
# SPDX-License-Identifier: AGPL-3.0-or-later
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# core/__init__.py for cookiecutter-cookiecutter
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, Jared Cook
4+
# SPDX-License-Identifier: AGPL-3.0-or-later
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
from .bash import (
20+
clean,
21+
make,
22+
tree,
23+
)
24+
from .config import ensure_config
25+
from .github import fetch_namespace
26+
from .logger import setup_logging
27+
from .utils import make_dirs
28+
29+
__all__ = [
30+
"clean",
31+
"ensure_config",
32+
"fetch_namespace",
33+
"make",
34+
"make_dirs",
35+
"setup_logging",
36+
"tree",
37+
]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# core/bash.py for cookiecutter-cookiecutter
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, Jared Cook
4+
# SPDX-License-Identifier: AGPL-3.0-or-later
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
import os
20+
import shutil
21+
import subprocess
22+
import sys
23+
from pathlib import Path
24+
25+
from core.config import ensure_config
26+
from core.logger import setup_logging
27+
28+
cfg = ensure_config() # loads singleton config
29+
logger = setup_logging(cfg) # loads singleton logger
30+
31+
32+
def clean() -> None:
33+
"""Remove _shared_hooks directory."""
34+
_shared_hooks = Path.cwd() / "_shared_hooks"
35+
logger.info(f"hooks directory: {_shared_hooks}")
36+
if _shared_hooks.exists() and _shared_hooks.is_dir():
37+
shutil.rmtree(_shared_hooks)
38+
logger.info(f"Removed {_shared_hooks} directory.")
39+
else:
40+
logger.info("_shared_hooks directory does not exist, nothing to remove.")
41+
42+
43+
def make(cmd: str, *, verbose: bool = False) -> None:
44+
"""Run a make target inside post-gen, exiting on failure."""
45+
logger.info(f"▶ Running: make {cmd}")
46+
try:
47+
result = subprocess.run(
48+
["make", cmd],
49+
check=True,
50+
capture_output=True,
51+
text=True,
52+
)
53+
if verbose and result.stdout:
54+
logger.info(result.stdout.rstrip())
55+
logger.info(f"✅ Command succeeded: make {cmd}")
56+
except subprocess.CalledProcessError as e:
57+
logger.error(f"❌ Command failed: make {cmd}")
58+
# Optionally log stdout/stderr captured from the failed command
59+
if e.stdout:
60+
logger.error(f"STDOUT: {e.stdout}")
61+
if e.stderr:
62+
logger.error(f"STDERR: {e.stderr}")
63+
sys.exit(e.returncode)
64+
65+
66+
def tree() -> None:
67+
"""Run tree cmd inside the post-gen."""
68+
logger.info(f"Current working directory: {os.getcwd()}")
69+
subprocess.run(["tree", "-a", "."], check=False)

0 commit comments

Comments
 (0)