diff --git a/docs/CHANGELOG/index.html b/docs/CHANGELOG/index.html index 467baab..3b114b5 100644 --- a/docs/CHANGELOG/index.html +++ b/docs/CHANGELOG/index.html @@ -352,6 +352,21 @@ + +
git init
on Windows (#35)copier_template_tester/main.py
Generated on: 2024-11-17
+Generated on: 2024-11-19
diff --git a/search/search_index.json b/search/search_index.json index 01eb65e..8412ad2 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"copier-template-tester","text":"Parametrize copier templates to test for syntax errors, check the expected output, and to check against copier versions.
Note that ctt
only tests the copier copy
operation and doesn\u2019t check the update
behavior and any version-specific logic that your template may contain because of how quickly those tests become complex.
When creating a copier template repository, I recommend following the nested \u201csubdirectory\u201d approach so that the directory looks like this:
\u2514\u2500\u2500 template_dir\n\u2502 \u2514\u2500\u2500 {{ _copier_conf.answers_file }}.jinja\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 copier.yml\n\u2514\u2500\u2500 ctt.toml\n
Create a new ctt.toml
file in the top-level directory of your copier repository. Populate the file to look like the below example.
# Specify shared data across all 'output' destinations\n# Note that the copier.yml defaults are used whenever the key is not set in this file\n[defaults]\nproject_name = \"placeholder\"\ncopyright_year = 2022\n\n# Parametrize each output with a relative path and optionally any values to override\n[output.\".ctt/defaults\"]\n\n[output.\".ctt/no_all\"]\npackage_name = \"testing-no-all\"\ninclude_all = false\n
"},{"location":"#pre-commit-hook","title":"Pre-Commit Hook","text":"First, add this section to your .pre-commit-config.yml
file:
repos:\n - repo: https://github.com/KyleKing/copier-template-tester\n rev: main\n hooks:\n - id: copier-template-tester\n
Install and update to the latest revision:
pre-commit autoupdate\n
The run with pre-commit
:
pre-commit run --all-files copier-template-tester\n
"},{"location":"#pipx","title":"pipx","text":"You can also try ctt
as a CLI tool by installing with pipx
:
pipx install copier-template-tester\n\ncd ~/your/copier/project\nctt\n
"},{"location":"#more-examples","title":"More Examples","text":"For more example code, see the scripts directory or the tests.
"},{"location":"#project-status","title":"Project Status","text":"See the Open Issues
and/or the CODE_TAG_SUMMARY. For release history, see the CHANGELOG.
We welcome pull requests! For your pull request to be accepted smoothly, we suggest that you first open a GitHub issue to discuss your idea. For resources on getting started with the code base, see the below documentation:
We follow the Contributor Covenant Code of Conduct.
"},{"location":"#open-source-status","title":"Open Source Status","text":"We try to reasonably meet most aspects of the \u201cOpenSSF scorecard\u201d from Open Source Insights
"},{"location":"#responsible-disclosure","title":"Responsible Disclosure","text":"If you have any security issue to report, please contact the project maintainers privately. You can reach us at dev.act.kyle@gmail.com.
"},{"location":"#license","title":"License","text":"LICENSE
"},{"location":"docs/CHANGELOG/","title":"CHANGELOG","text":""},{"location":"docs/CHANGELOG/#unreleased","title":"Unreleased","text":""},{"location":"docs/CHANGELOG/#213-2024-07-08","title":"2.1.3 (2024-07-08)","text":""},{"location":"docs/CHANGELOG/#fix","title":"Fix","text":"use literal to try to fix pyright errors
pending pydantic v2 support
Found code tags for PLANNED (4)
"},{"location":"docs/DEVELOPER_GUIDE/","title":"Developer Notes","text":""},{"location":"docs/DEVELOPER_GUIDE/#local-development","title":"Local Development","text":"git clone https://github.com/kyleking/copier-template-tester.git\ncd copier-template-tester\npoetry install --sync\npoetry run calcipy-pack pack.install-extras\n\n# See the available tasks\npoetry run calcipy\n# Or use a local 'run' file (so that 'calcipy' can be extended)\n./run\n\n# Run the default task list (lint, auto-format, test coverage, etc.)\n./run main\n\n# Make code changes and run specific tasks as needed:\n./run lint.fix test\n
"},{"location":"docs/DEVELOPER_GUIDE/#publishing","title":"Publishing","text":"For testing, create an account on TestPyPi. Replace ...
with the API token generated on TestPyPi or PyPi respectively
poetry config repositories.testpypi https://test.pypi.org/legacy/\npoetry config pypi-token.testpypi ...\n\n./run main pack.publish --to-test-pypi\n# If you didn't configure a token, you will need to provide your username and password to publish\n
To publish to the real PyPi
poetry config pypi-token.pypi ...\n./run release\n\n# Or for a pre-release\n./run release --suffix=rc\n
"},{"location":"docs/DEVELOPER_GUIDE/#current-status","title":"Current Status","text":"File Statements Missing Excluded Coverage copier_template_tester/__init__.py
4 0 0 100.0% copier_template_tester/_config.py
14 0 3 100.0% copier_template_tester/_pre_commit_support.py
13 0 0 93.3% copier_template_tester/_runtime_type_check_setup.py
13 0 37 100.0% copier_template_tester/_write_output.py
76 0 13 100.0% copier_template_tester/main.py
30 4 20 86.7% Totals 150 4 73 97.0% Generated on: 2024-11-17
"},{"location":"docs/STYLE_GUIDE/","title":"Personal Style Guides","text":""},{"location":"docs/STYLE_GUIDE/#git","title":"Git","text":"We use Commitizen to manage both an auto-generated Changelog and incrementing the release version following semver. For both of these automated outputs to work well, please follow the Conventional Commits style, which is described in more detail below.
"},{"location":"docs/STYLE_GUIDE/#commitizen-types-and-scopes","title":"Commitizen Types and Scopes","text":"type(scope): description
!
can be used to indicate a breaking change (refactor!: drop support for Node 6
)fix : PATCH // feat : MINOR // BREAKING CHANGE : MAJOR
build(poetry): bump requests to v3
or style(#32): add missing type annotations
git rebase -i
to fix commit names prior to merging if incorrect types/scopes are usedfix(roles): bug in admin role permissions
feat(ui): implement new button design
build(pip): upgrade package to remove vulnerabilities
refactor: file structure to improve code readability
perf(cli): rewrite methods
feat(api): endpoints to implement new customer dashboard
Personal Guide
<\u2013 Links \u2013>
"},{"location":"reference/copier_template_tester/main/","title":"Main","text":"Copier Template Tester.
Based on: https://github.com/copier-org/copier/blob/ccfbc9a923f4228af7ca2bf067493665aa15d07c/tests/helpers.py#L20-L81
"},{"location":"reference/copier_template_tester/main/#copier_template_tester.main-attributes","title":"Attributes","text":""},{"location":"reference/copier_template_tester/main/#copier_template_tester.main-functions","title":"Functions","text":""},{"location":"reference/copier_template_tester/main/#copier_template_tester.main.run","title":"run","text":"run(*, base_dir=None, check_untracked=False)\n
Entry point.
Source code incopier_template_tester/main.py
def run(*, base_dir: Path | None = None, check_untracked: bool = False) -> None:\n \"\"\"Entry point.\"\"\"\n base_dir = base_dir or Path.cwd()\n try:\n read_copier_template(base_dir=base_dir)\n except FileNotFoundError:\n message = f\"Please add a '{DEFAULT_TEMPLATE_FILE_NAME}' file to '{base_dir}'\"\n logger.warning(message)\n return\n\n logger.text(f'Starting Copier Template Tester for {base_dir}')\n logger.text('\\tNote: If files were modified, pre-commit will report a failure.')\n logger.text('')\n config = load_config(base_dir)\n defaults = config.get('defaults', {})\n\n input_path = base_dir\n paths = set()\n for key, data in config['output'].items():\n output_path = base_dir / key\n paths.add(output_path)\n logger.text(f'Using `copier` to create: {key}')\n write_output(src_path=input_path, dst_path=base_dir / output_path, data=defaults | data)\n\n if check_untracked: # pragma: no cover\n check_for_untracked(base_dir)\n
"},{"location":"reference/copier_template_tester/main/#copier_template_tester.main.run_cli","title":"run_cli","text":"run_cli()\n
Accept CLI configuration for running ctt.
Source code incopier_template_tester/main.py
def run_cli() -> None: # pragma: no cover\n \"\"\"Accept CLI configuration for running ctt.\"\"\"\n def dir_path(pth: str | None) -> Path:\n if pth and Path(pth).is_dir():\n return Path(pth).resolve()\n msg = f'Expected a path to a directory. Received: `{pth}`'\n raise ArgumentTypeError(msg)\n\n cli = ArgumentParser()\n cli.add_argument(\n '-b',\n '--base-dir',\n help='Specify the path to the directory that contains the configuration file',\n type=dir_path)\n cli.add_argument('--check-untracked', help='Only used for pre-commit', action='store_true')\n\n args = cli.parse_args()\n run(base_dir=args.base_dir, check_untracked=args.check_untracked)\n
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"copier-template-tester","text":"Parametrize copier templates to test for syntax errors, check the expected output, and to check against copier versions.
Note that ctt
only tests the copier copy
operation and doesn\u2019t check the update
behavior and any version-specific logic that your template may contain because of how quickly those tests become complex.
When creating a copier template repository, I recommend following the nested \u201csubdirectory\u201d approach so that the directory looks like this:
\u2514\u2500\u2500 template_dir\n\u2502 \u2514\u2500\u2500 {{ _copier_conf.answers_file }}.jinja\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 copier.yml\n\u2514\u2500\u2500 ctt.toml\n
Create a new ctt.toml
file in the top-level directory of your copier repository. Populate the file to look like the below example.
# Specify shared data across all 'output' destinations\n# Note that the copier.yml defaults are used whenever the key is not set in this file\n[defaults]\nproject_name = \"placeholder\"\ncopyright_year = 2022\n\n# Parametrize each output with a relative path and optionally any values to override\n[output.\".ctt/defaults\"]\n\n[output.\".ctt/no_all\"]\npackage_name = \"testing-no-all\"\ninclude_all = false\n
"},{"location":"#pre-commit-hook","title":"Pre-Commit Hook","text":"First, add this section to your .pre-commit-config.yml
file:
repos:\n - repo: https://github.com/KyleKing/copier-template-tester\n rev: main\n hooks:\n - id: copier-template-tester\n
Install and update to the latest revision:
pre-commit autoupdate\n
The run with pre-commit
:
pre-commit run --all-files copier-template-tester\n
"},{"location":"#pipx","title":"pipx","text":"You can also try ctt
as a CLI tool by installing with pipx
:
pipx install copier-template-tester\n\ncd ~/your/copier/project\nctt\n
"},{"location":"#more-examples","title":"More Examples","text":"For more example code, see the scripts directory or the tests.
"},{"location":"#project-status","title":"Project Status","text":"See the Open Issues
and/or the CODE_TAG_SUMMARY. For release history, see the CHANGELOG.
We welcome pull requests! For your pull request to be accepted smoothly, we suggest that you first open a GitHub issue to discuss your idea. For resources on getting started with the code base, see the below documentation:
We follow the Contributor Covenant Code of Conduct.
"},{"location":"#open-source-status","title":"Open Source Status","text":"We try to reasonably meet most aspects of the \u201cOpenSSF scorecard\u201d from Open Source Insights
"},{"location":"#responsible-disclosure","title":"Responsible Disclosure","text":"If you have any security issue to report, please contact the project maintainers privately. You can reach us at dev.act.kyle@gmail.com.
"},{"location":"#license","title":"License","text":"LICENSE
"},{"location":"docs/CHANGELOG/","title":"CHANGELOG","text":""},{"location":"docs/CHANGELOG/#unreleased","title":"Unreleased","text":""},{"location":"docs/CHANGELOG/#fix","title":"Fix","text":"git init
on Windows (#35)use literal to try to fix pyright errors
pending pydantic v2 support
Found code tags for PLANNED (4)
"},{"location":"docs/DEVELOPER_GUIDE/","title":"Developer Notes","text":""},{"location":"docs/DEVELOPER_GUIDE/#local-development","title":"Local Development","text":"git clone https://github.com/kyleking/copier-template-tester.git\ncd copier-template-tester\npoetry install --sync\npoetry run calcipy-pack pack.install-extras\n\n# See the available tasks\npoetry run calcipy\n# Or use a local 'run' file (so that 'calcipy' can be extended)\n./run\n\n# Run the default task list (lint, auto-format, test coverage, etc.)\n./run main\n\n# Make code changes and run specific tasks as needed:\n./run lint.fix test\n
"},{"location":"docs/DEVELOPER_GUIDE/#publishing","title":"Publishing","text":"For testing, create an account on TestPyPi. Replace ...
with the API token generated on TestPyPi or PyPi respectively
poetry config repositories.testpypi https://test.pypi.org/legacy/\npoetry config pypi-token.testpypi ...\n\n./run main pack.publish --to-test-pypi\n# If you didn't configure a token, you will need to provide your username and password to publish\n
To publish to the real PyPi
poetry config pypi-token.pypi ...\n./run release\n\n# Or for a pre-release\n./run release --suffix=rc\n
"},{"location":"docs/DEVELOPER_GUIDE/#current-status","title":"Current Status","text":"File Statements Missing Excluded Coverage copier_template_tester/__init__.py
4 0 0 100.0% copier_template_tester/_config.py
14 0 3 100.0% copier_template_tester/_pre_commit_support.py
13 0 0 93.3% copier_template_tester/_runtime_type_check_setup.py
13 0 37 100.0% copier_template_tester/_write_output.py
81 1 16 98.9% copier_template_tester/main.py
30 4 20 86.7% Totals 155 5 76 96.4% Generated on: 2024-11-19
"},{"location":"docs/STYLE_GUIDE/","title":"Personal Style Guides","text":""},{"location":"docs/STYLE_GUIDE/#git","title":"Git","text":"We use Commitizen to manage both an auto-generated Changelog and incrementing the release version following semver. For both of these automated outputs to work well, please follow the Conventional Commits style, which is described in more detail below.
"},{"location":"docs/STYLE_GUIDE/#commitizen-types-and-scopes","title":"Commitizen Types and Scopes","text":"type(scope): description
!
can be used to indicate a breaking change (refactor!: drop support for Node 6
)fix : PATCH // feat : MINOR // BREAKING CHANGE : MAJOR
build(poetry): bump requests to v3
or style(#32): add missing type annotations
git rebase -i
to fix commit names prior to merging if incorrect types/scopes are usedfix(roles): bug in admin role permissions
feat(ui): implement new button design
build(pip): upgrade package to remove vulnerabilities
refactor: file structure to improve code readability
perf(cli): rewrite methods
feat(api): endpoints to implement new customer dashboard
Personal Guide
<\u2013 Links \u2013>
"},{"location":"reference/copier_template_tester/main/","title":"Main","text":"Copier Template Tester.
Based on: https://github.com/copier-org/copier/blob/ccfbc9a923f4228af7ca2bf067493665aa15d07c/tests/helpers.py#L20-L81
"},{"location":"reference/copier_template_tester/main/#copier_template_tester.main-attributes","title":"Attributes","text":""},{"location":"reference/copier_template_tester/main/#copier_template_tester.main-functions","title":"Functions","text":""},{"location":"reference/copier_template_tester/main/#copier_template_tester.main.run","title":"run","text":"run(*, base_dir=None, check_untracked=False)\n
Entry point.
Source code incopier_template_tester/main.py
def run(*, base_dir: Path | None = None, check_untracked: bool = False) -> None:\n \"\"\"Entry point.\"\"\"\n base_dir = base_dir or Path.cwd()\n try:\n read_copier_template(base_dir=base_dir)\n except FileNotFoundError:\n message = f\"Please add a '{DEFAULT_TEMPLATE_FILE_NAME}' file to '{base_dir}'\"\n logger.warning(message)\n return\n\n logger.text(f'Starting Copier Template Tester for {base_dir}')\n logger.text('\\tNote: If files were modified, pre-commit will report a failure.')\n logger.text('')\n config = load_config(base_dir)\n defaults = config.get('defaults', {})\n\n input_path = base_dir\n paths = set()\n for key, data in config['output'].items():\n output_path = base_dir / key\n paths.add(output_path)\n logger.text(f'Using `copier` to create: {key}')\n write_output(src_path=input_path, dst_path=base_dir / output_path, data=defaults | data)\n\n if check_untracked: # pragma: no cover\n check_for_untracked(base_dir)\n
"},{"location":"reference/copier_template_tester/main/#copier_template_tester.main.run_cli","title":"run_cli","text":"run_cli()\n
Accept CLI configuration for running ctt.
Source code incopier_template_tester/main.py
def run_cli() -> None: # pragma: no cover\n \"\"\"Accept CLI configuration for running ctt.\"\"\"\n def dir_path(pth: str | None) -> Path:\n if pth and Path(pth).is_dir():\n return Path(pth).resolve()\n msg = f'Expected a path to a directory. Received: `{pth}`'\n raise ArgumentTypeError(msg)\n\n cli = ArgumentParser()\n cli.add_argument(\n '-b',\n '--base-dir',\n help='Specify the path to the directory that contains the configuration file',\n type=dir_path)\n cli.add_argument('--check-untracked', help='Only used for pre-commit', action='store_true')\n\n args = cli.parse_args()\n run(base_dir=args.base_dir, check_untracked=args.check_untracked)\n
"}]}
\ No newline at end of file