From c40fa0106de72ad6023806116b83aa31337d60f2 Mon Sep 17 00:00:00 2001
From: Justin Mayer <entroP@gmail.com>
Date: Tue, 20 Aug 2024 09:44:09 +0200
Subject: [PATCH] Add Cruft and link to latest Cookiecutter commit

---
 .cruft.json | 27 +++++++++++++++++++++++++++
 tasks.py    | 14 +++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 .cruft.json

diff --git a/.cruft.json b/.cruft.json
new file mode 100644
index 0000000..76d0e2f
--- /dev/null
+++ b/.cruft.json
@@ -0,0 +1,27 @@
+{
+  "template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
+  "commit": "94970ab900aed538f451686a2eb51188dbfd1a28",
+  "checkout": null,
+  "context": {
+    "cookiecutter": {
+      "plugin_name": "Minify",
+      "repo_name": "minify",
+      "package_name": "minify",
+      "distribution_name": "pelican-minify",
+      "version": "2.0.0",
+      "description": "Pelican plugin to minify HTML, CSS and Javascript",
+      "authors": "[{name = \"Alexander Herrmann\", email = \"106409+dArignac@users.noreply.github.com\"}, {name = \"Justin Mayer\", email = \"entroP@gmail.com\"}, {name = \"Ysard\", email = \"ysard@users.noreply.github.com\"},]",
+      "keywords": "\"pelican\", \"plugin\", \"minify\", \"minification\", \"html\", \"css\", \"javascript\"",
+      "readme": "README.md",
+      "contributing": "CONTRIBUTING.md",
+      "license": "MIT License|MIT",
+      "repo_url": "https://github.com/pelican-plugins/minify",
+      "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
+}
diff --git a/tasks.py b/tasks.py
index c6e1803..e4e3790 100644
--- a/tasks.py
+++ b/tasks.py
@@ -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"
 
@@ -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."""