Skip to content

Commit

Permalink
chore: Link to upstream plugin template via Cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Jan 15, 2025
1 parent 4d3c46c commit e71419d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"commit": "8a4f543e999c7a2b4ab49c724bf84ff4192f4c94",
"checkout": null,
"context": {
"cookiecutter": {
"plugin_name": "SEO",
"repo_name": "seo",
"package_name": "seo",
"distribution_name": "pelican-seo",
"version": "1.2.2",
"description": "Pelican plugin to improve search engine optimization (SEO)",
"authors": "{name = \"Maëva Brunelles\", email = \"[email protected]\"}, {name = \"Justin Mayer\", email = \"[email protected]\"}",
"keywords": "\"pelican\", \"plugin\", \"seo\", \"search\", \"optimization\"",
"readme": "README.md",
"contributing": "CONTRIBUTING.md",
"license": "GNU Affero General Public License v3|AGPL-3.0",
"repo_url": "https://github.com/pelican-plugins/seo",
"dev_status": "5 - Production/Stable",
"tests_exist": true,
"python_version": "~=3.9",
"pelican_version": ">=4.5",
"_template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"_commit": "f51b3c4a5160fc8f36cff3baf9da7e2b5f59e8d7"
}
},
"directory": null
}
19 changes: 14 additions & 5 deletions 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 @@ -55,10 +56,7 @@ def ruff(c, concise=False, fix=False, diff=False):
fix_flag = "--fix"
if diff:
diff_flag = "--diff"
c.run(
f"{CMD_PREFIX}ruff check {concise_flag} {diff_flag} {fix_flag} {PKG_PATH}",
pty=PTY,
)
c.run(f"{CMD_PREFIX}ruff check {concise_flag} {diff_flag} {fix_flag} .", pty=PTY)


@task
Expand All @@ -84,6 +82,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 e71419d

Please sign in to comment.