Skip to content

Commit

Permalink
Merge pull request #4 from hypothesis/update-cookiecutter
Browse files Browse the repository at this point in the history
Updates from cookiecutter
  • Loading branch information
seanh authored Jul 11, 2022
2 parents 2df7d77 + eb41727 commit e4dce91
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"python_versions": "3.10.4, 3.9.12, 3.8.13",
"github_owner": "hypothesis",
"copyright_holder": "Hypothesis",
"public": "no",
"visibility": "private",
"console_script": "yes",
"__dependabot_interval": "weekly",
"dependabot_interval": "monthly",
"__entry_point": "cookiecutter-pypackage-test",
"__github_url": "https://github.com/hypothesis/cookiecutter-pypackage-test",
"__pypi_url": "https://pypi.org/project/cookiecutter-pypackage-test"
}
}
}
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
day: "sunday"
time: "00:00"
timezone: "Europe/London"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI
on:
pull_request:
push:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sure:
.PHONY: template
$(call help,make template,"update from the latest cookiecutter template")
template: python
@pyenv exec tox -e template -- $(cookiecutter)
@pyenv exec tox -e template -- $$(if [ -n "$${template+x}" ]; then echo "--template $$template"; fi) $$(if [ -n "$${checkout+x}" ]; then echo "--checkout $$checkout"; fi) $$(if [ -n "$${directory+x}" ]; then echo "--directory $$directory"; fi)

.PHONY: clean
$(call help,make clean,"delete temporary files etc")
Expand Down
13 changes: 10 additions & 3 deletions bin/make_template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import argparse
import json
import os
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

Expand All @@ -14,10 +14,17 @@ extra_context = config.get("extra_context", {})
extra_context["__ignore__"] = config.get("ignore", [])
extra_context["__target_dir__"] = Path(os.getcwd())

parser = argparse.ArgumentParser(description="Update the project from the cookiecutter template")
parser.add_argument("--template", help="the cookiecutter template to use (default: what's in cookiecutter.json)")
parser.add_argument("--checkout", help="the branch, tag or commit of the cookiecutter template to use (default: what's in cookiecutter.json)")
parser.add_argument("--directory", help="the directory within the cookiecutter repo to use to use (default: what's in cookiecutter.json)")
args = parser.parse_args()

with TemporaryDirectory() as tmpdirname:
cookiecutter(
template=sys.argv[1] if len(sys.argv) >= 2 else config["template"],
directory=config["directory"],
template=args.template or config.get("template"),
checkout=args.checkout or config.get("checkout"),
directory=args.directory or config.get("directory"),
extra_context=extra_context,
no_input=True,
overwrite_if_exists=True,
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/cli_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from subprocess import run


def test_help():
"""Test the cookiecutter-pypackage-test --help command."""
run(["cookiecutter-pypackage-test", "--help"], check=True)


def test_version():
"""Test the cookiecutter-pypackage-test --version command."""
run(["cookiecutter-pypackage-test", "--version"], check=True)

0 comments on commit e4dce91

Please sign in to comment.