Skip to content

Commit

Permalink
Add Cruft and link to latest Cookiecutter commit
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Jul 7, 2024
1 parent 4491d92 commit 6db09ba
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"commit": "b4b9b4f83b624cfd7728a3f1527d272be28ee916",
"checkout": null,
"context": {
"cookiecutter": {
"plugin_name": "Avatar",
"repo_name": "avatar",
"package_name": "avatar",
"distribution_name": "pelican-avatar",
"version": "1.0.9",
"description": "Libravatar/Gravatar plugin for Pelican",
"authors": "{name = \"Rafael Laboissière\", email = \"[email protected]\"}",
"keywords": "\"pelican\", \"plugin\", \"libravatar\", \"gravatar\"",
"readme": "README.md",
"contributing": "CONTRIBUTING.md",
"license": "GNU Affero General Public License v3|AGPL-3.0",
"repo_url": "https://github.com/pelican-plugins/avatar",
"dev_status": "5 - Production/Stable",
"tests_exist": true,
"python_version": ">=3.8.1,<4.0",
"pelican_version": ">=4.5",
"_template": "https://github.com/getpelican/cookiecutter-pelican-plugin"
}
},
"directory": null
}
14 changes: 13 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
BIN_DIR = "bin" if os.name != "nt" else "Scripts"
VENV_BIN = Path(VENV) / Path(BIN_DIR)

TOOLS = ("pdm", "pre-commit")
TOOLS = ("cruft", "pdm", "pre-commit")
PDM = which("pdm") if which("pdm") else (VENV_BIN / "pdm")
CMD_PREFIX = f"{VENV_BIN}/" if ACTIVE_VENV else f"{PDM} run "
CRUFT = which("cruft") if which("cruft") else f"{CMD_PREFIX}cruft"
PRECOMMIT = which("pre-commit") if which("pre-commit") else f"{CMD_PREFIX}pre-commit"
PTY = os.name != "nt"

Expand Down Expand Up @@ -79,6 +80,17 @@ def precommit(c):
c.run(f"{PRECOMMIT} install")


@task
def update(c, check=False):
"""Apply upstream plugin template changes to this project."""
if check:
logger.info("** Checking for upstream template changes **")
c.run(f"{CRUFT} check", pty=PTY)
else:
logger.info("** Updating project from upstream template **")
c.run(f"{CRUFT} update", pty=PTY)


@task
def setup(c):
"""Set up the development environment."""
Expand Down

0 comments on commit 6db09ba

Please sign in to comment.