diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af1cfb2..19fddbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,9 +8,9 @@ repos: # formatters and linters are available in the virtualenv so they can be run from the makefile & vscode - repo: local hooks: - - id: snapshot - name: snapshot - entry: make snapshot + - id: snapshots + name: snapshots + entry: make snapshots # run on all files pass_filenames: false language: system diff --git a/Makefile b/Makefile index d043dfd..757186d 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,12 @@ MAKEFLAGS += --warn-undefined-variables SHELL = /bin/bash -o pipefail .DEFAULT_GOAL := help -.PHONY: help snapshot test outdated pc-update +.PHONY: help test outdated pc-update ## display help message help: @awk '/^##.*$$/,/^[~\/\.0-9a-zA-Z_-]+:/' $(MAKEFILE_LIST) | awk '!(NR%2){print $$0p}{p=$$0}' | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | sort -snapshot := snapshot/cookie venv := .venv cookiecutter := $(venv)/bin/cookiecutter @@ -18,25 +17,24 @@ $(venv): ## create venv and install cookiecutter and hooks install: $(venv) $(if $(value CI),,install-hooks) -## make the snapshot cookie -snapshot: $(snapshot) -## run hooks on snapshot cookie -test: $(snapshot) - cd $(snapshot) && git init && git add . && make hooks +## run hooks on default snapshot +test: snapshots + cd snapshots/default && git init && git add . && make hooks -$(snapshot): $(shell find {{cookiecutter.repo_name}}) cookiecutter* | $(venv) - rm -rf $(snapshot) - $(cookiecutter) -o $(snapshot)/../ -f --no-input --config-file cookiecutter-config.yaml . - touch $(snapshot) +## make the snapshots +snapshots: $(shell find {{cookiecutter.repo_name}}) snapshots/*.yaml | $(venv) + rm -rf snapshots/*/ + for file in snapshots/*.yaml; do $(cookiecutter) -o snapshots -f --no-input --config-file $$file .; done + touch snapshots -$(snapshot)/.venv: $(snapshot) - cd $(snapshot) && make install +snapshots/default/.venv: snapshots + cd snapshots/default && make install ## list outdated packages -outdated: $(snapshot)/.venv - $(snapshot)/.venv/bin/pip list --outdated - cd $(snapshot) && npm outdated +outdated: snapshots/default/.venv + snapshots/default/.venv/bin/pip list --outdated + cd snapshots/default && npm outdated ## update pre-commit hooks pc-update: $(snapshot)/.venv diff --git a/snapshot/cookie/.gitignore b/snapshot/cookie/.gitignore deleted file mode 100644 index 7829ca5..0000000 --- a/snapshot/cookie/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -.eggs/ -.idea/ -.vscode/ -*.code-workspace -*.iml -.pytest_cache/ -__pycache__/ -.mypy_cache/ -*.egg-info -build/ -dist/ -.DS_Store -typings/ -.tox/ -pip-wheel-metadata/ -node_modules/ -.venv/ -.env diff --git a/snapshot/cookie/.pre-commit-config.yaml b/snapshot/cookie/.pre-commit-config.yaml deleted file mode 100644 index dc5cf09..0000000 --- a/snapshot/cookie/.pre-commit-config.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# unless otherwise specified, hooks run on push only -default_stages: [push] -repos: - - repo: https://github.com/crate-ci/typos - rev: v1.23.2 - hooks: - - id: typos - # formatters and linters are available in the virtualenv so they can be run from the makefile & vscode - - repo: local - hooks: - - id: ruff - name: ruff - entry: .venv/bin/ruff check --force-exclude - language: system - types: [python] - require_serial: true - - id: ruff-format - name: ruff-format - entry: .venv/bin/ruff format - language: system - types: [python] - require_serial: true - - id: pyright - name: pyright - entry: node_modules/.bin/pyright - # run on all files to catch type errors that affect unchanged files - pass_filenames: false - language: system - types: [python] - - id: test - name: test - entry: .venv/bin/pytest - # run on all files - pass_filenames: false - language: system - types: [python] diff --git a/snapshot/cookie/.python-version b/snapshot/cookie/.python-version deleted file mode 100644 index 2c07333..0000000 --- a/snapshot/cookie/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.11 diff --git a/snapshot/cookie/CONTRIBUTING.md b/snapshot/cookie/CONTRIBUTING.md deleted file mode 100644 index a5ccf05..0000000 --- a/snapshot/cookie/CONTRIBUTING.md +++ /dev/null @@ -1,23 +0,0 @@ -# Contributing 🌳 - -## Prerequisites - -- make -- node (required for pyright) -- python >= 3.11 - -## Getting started - -`make install` creates the dev environment with: - -- a virtualenv in _.venv/_ -- pyright in _node_modules/_ -- git hooks for formatting & linting on git push - -`. .venv/bin/activate` activates the virtualenv. - -The make targets will update the virtualenv when _pyproject.toml_ changes. - -## Usage - -Run `make` to see the options for running tests, linting, formatting etc. diff --git a/snapshot/cookie/Makefile b/snapshot/cookie/Makefile deleted file mode 100644 index bda312d..0000000 --- a/snapshot/cookie/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -include *.mk - -# add additional targets here diff --git a/snapshot/cookie/Makefile-common.mk b/snapshot/cookie/Makefile-common.mk deleted file mode 100644 index a45f169..0000000 --- a/snapshot/cookie/Makefile-common.mk +++ /dev/null @@ -1,67 +0,0 @@ -MAKEFLAGS += --warn-undefined-variables -SHELL = /bin/bash -o pipefail -.DEFAULT_GOAL := help -.PHONY: help clean install format check pyright test dist hooks install-hooks - -## display help message -help: - @awk '/^##.*$$/,/^[~\/\.0-9a-zA-Z_-]+:/' $(MAKEFILE_LIST) | awk '!(NR%2){print $$0p}{p=$$0}' | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | sort - -venv ?= .venv -pip := $(venv)/bin/pip - -$(pip): $(if $(value CI),|,) .python-version -# create venv using system python even when another venv is active - PATH=$${PATH#$${VIRTUAL_ENV}/bin:} python3 -m venv --clear $(venv) - $(venv)/bin/python --version - $(pip) install --upgrade pip~=24.0 - -$(venv): $(if $(value CI),|,) pyproject.toml $(pip) - $(pip) install -e '.[dev]' - touch $(venv) - -node_modules: package.json - npm install --no-save - touch node_modules - -# delete the venv -clean: - rm -rf $(venv) - -## create venv and install this package and hooks -install: $(venv) node_modules $(if $(value CI),,install-hooks) - -## format, lint and type check -check: export SKIP=test -check: hooks - -## format and lint -format: export SKIP=pyright,test -format: hooks - -## pyright type check -pyright: node_modules $(venv) - node_modules/.bin/pyright - -## run tests -test: $(venv) - $(venv)/bin/pytest - -## build python distribution -dist: $(venv) - # start with a clean slate (see setuptools/#2347) - rm -rf dist *.egg-info - $(venv)/bin/python -m build --sdist --wheel - -## publish to pypi -publish: $(venv) - $(venv)/bin/twine upload dist/* - -## run pre-commit git hooks on all files -hooks: node_modules $(venv) - $(venv)/bin/pre-commit run --color=always --all-files --hook-stage push - -install-hooks: .git/hooks/pre-push - -.git/hooks/pre-push: $(venv) - $(venv)/bin/pre-commit install --install-hooks -t pre-push diff --git a/snapshot/cookie/README.md b/snapshot/cookie/README.md deleted file mode 100644 index e578688..0000000 --- a/snapshot/cookie/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# my-project - -[![ci](../../actions/workflows/ci.yml/badge.svg)](../../actions/workflows/ci.yml) - -example cookie rendered from the template - -## Contributing - -See [CONTRIBUTING.md](CONTRIBUTING.md) to get started and develop in this repo. diff --git a/snapshot/cookie/mypackage/__init__.py b/snapshot/cookie/mypackage/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/snapshot/cookie/mypackage/main.py b/snapshot/cookie/mypackage/main.py deleted file mode 100644 index 0928088..0000000 --- a/snapshot/cookie/mypackage/main.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys - - -def main(args: list[str] = sys.argv[1:]) -> None: - print(f"hello {args[0]}!") - - -if __name__ == "__main__": - main() diff --git a/snapshot/cookie/mypackage/py.typed b/snapshot/cookie/mypackage/py.typed deleted file mode 100644 index 1031418..0000000 --- a/snapshot/cookie/mypackage/py.typed +++ /dev/null @@ -1 +0,0 @@ -# when type checking dependents, tell type checkers to use this package's types diff --git a/snapshot/cookie/package.json b/snapshot/cookie/package.json deleted file mode 100644 index 923913b..0000000 --- a/snapshot/cookie/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "pyright": "1.1.369" - } -} diff --git a/snapshot/cookie/pyproject.toml b/snapshot/cookie/pyproject.toml deleted file mode 100644 index 83a52ee..0000000 --- a/snapshot/cookie/pyproject.toml +++ /dev/null @@ -1,87 +0,0 @@ -[project] -name = "my-project" -description = "example cookie rendered from the template" -dynamic = ["version"] -readme = "README.md" -requires-python = ">=3.11" -dependencies = [] - -[project.optional-dependencies] -dev = [ - "build~=1.0", - "pre-commit~=3.4", - "pytest~=8.0", - "ruff~=0.5.1", - "twine~=5.0", -] - -[build-system] -requires = ["setuptools~=69.1", "setuptools_scm~=8.0", "wheel~=0.42"] - -[tool.setuptools.packages.find] -where = ["."] -exclude = ["tests*", "node_modules*", "build*"] - -# enable setuptools_scm to set the version based on git tags -[tool.setuptools_scm] -fallback_version = "0.0.0" - -[tool.pyright] -venvPath = "." -venv = ".venv" -exclude = ["**/node_modules", "**/__pycache__", "**/.*", "build"] -strictListInference = true -strictDictionaryInference = true -strictParameterNoneValue = true -reportTypedDictNotRequiredAccess = false -reportIncompatibleVariableOverride = true -reportIncompatibleMethodOverride = true -reportMatchNotExhaustive = true -reportUnnecessaryTypeIgnoreComment = true - -[tool.ruff] -line-length = 120 -# first-party imports for sorting -src = ["."] -fix = true -show-fixes = true - -[tool.ruff.lint] -# rules to enable/ignore -select = [ - "F", # pyflakes - "E", # pycodestyle - "W", # pycodestyle - "ANN", # type annotations - "N", # pep8-naming - "B", # bugbear - "I", # isort - "ARG", # flake8-unused-arguments - "SLF", # flake8-self - "UP", # pyupgrade - "PERF", # perflint - "RUF", # ruff-specific - "SIM", # flake8-simplify - "S113", # request-without-timeout -] -ignore = [ - # allow untyped self and cls args - "ANN101", - "ANN102", - # allow no return type from dunder methods - "ANN204", - # allow == True because pandas dataframes overload equality - "E712", -] - -[tool.ruff.lint.isort] -combine-as-imports = true -force-wrap-aliases = true - -[tool.ruff.lint.per-file-ignores] -# test functions don't need return types -"tests/*" = ["ANN201", "ANN202"] - -[tool.ruff.lint.flake8-annotations] -# allow *args: Any, **kwargs: Any -allow-star-arg-any = true diff --git a/snapshot/cookie/tests/__init__.py b/snapshot/cookie/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/snapshot/cookie/tests/test_example.py b/snapshot/cookie/tests/test_example.py deleted file mode 100644 index 21b7c4f..0000000 --- a/snapshot/cookie/tests/test_example.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_example(): - assert 1 == 1 diff --git a/cookiecutter-config.yaml b/snapshots/default.yaml similarity index 100% rename from cookiecutter-config.yaml rename to snapshots/default.yaml