Skip to content

Commit

Permalink
Merge pull request #96 from jedie/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie authored Oct 8, 2023
2 parents 7144fe2 + c18c0bc commit a72d9e7
Show file tree
Hide file tree
Showing 7 changed files with 553 additions and 382 deletions.
131 changes: 131 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,137 @@ Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...
```
[comment]: <> (✂✂✂ auto generated dev help end ✂✂✂)

## History

See also git tags: https://github.com/jedie/manageprojects/tags

[comment]: <> (✂✂✂ auto generated history start ✂✂✂)

* [**dev**](https://github.com/jedie/manageprojects/compare/v0.15.0...main)
* 2023-10-08 - Update for CookieCutter v2.4.0 changes
* 2023-10-08 - Autogenerate history via https://github.com/jedie/cli-base-utilities
* 2023-09-24 - apply migrations
* 2023-09-24 - Update requirements
* [v0.15.0](https://github.com/jedie/manageprojects/compare/v0.14.1...v0.15.0)
* 2023-08-17 - Deprecate Git
* 2023-08-17 - Deprecate print_version() (moved to cli_base)
* [v0.14.1](https://github.com/jedie/manageprojects/compare/v0.14.0...v0.14.1)
* 2023-08-17 - apply project template updates and update requirements
* 2023-08-15 - Update requirements
* [v0.14.0](https://github.com/jedie/manageprojects/compare/v0.13.0...v0.14.0)
* 2023-08-09 - Use https://github.com/jedie/cli-base-utilities
* [v0.13.0](https://github.com/jedie/manageprojects/compare/v0.12.1...v0.13.0)
* 2023-08-05 - publish: Support "dynamic metadata" from setuptools for the version
* 2023-08-05 - Split CLI
* [v0.12.1](https://github.com/jedie/manageprojects/compare/v0.12.0...v0.12.1)
* 2023-06-11 - Ehance git.push() by adding `get_output` to method
* [v0.12.0](https://github.com/jedie/manageprojects/compare/v0.11.0...v0.12.0)
* 2023-06-11 - New: git.get_remote_url() and git.get_github_username()
* [v0.11.0](https://github.com/jedie/manageprojects/compare/v0.10.0...v0.11.0)
* 2023-06-11 - Update requirements and relase as v0.11.0
* 2023-06-11 - Enhance Git()
* 2023-05-12 - Use "--remove-all-unused-imports" as default for autoflake
* [v0.10.0](https://github.com/jedie/manageprojects/compare/v0.9.10...v0.10.0)
* 2023-05-11 - Enhance "format-file" and add "autoflake" to remove unused imports
* 2023-04-10 - Update requirements
* 2023-04-10 - apply manageprojects updates
* 2023-04-08 - Apply project updates
* [v0.9.10](https://github.com/jedie/manageprojects/compare/v0.9.9...v0.9.10)
* 2023-04-08 - Add helper to find and get the "pyproject.toml" file
* [v0.9.9](https://github.com/jedie/manageprojects/compare/v0.9.8...v0.9.9)
* 2023-04-04 - Set --overwrite as default in update-project command
* 2023-04-04 - Cleanup requirements
* 2023-04-04 - project updates
* [v0.9.8](https://github.com/jedie/manageprojects/compare/v0.9.7...v0.9.8)
* 2023-04-04 - Add `--overwrite` option to `reverse` command
* [v0.9.7](https://github.com/jedie/manageprojects/compare/v0.9.6...v0.9.7)
* 2023-04-03 - Bugfix reverse command: Optimize replacements
* 2023-03-17 - apply code migrations
* [v0.9.6](https://github.com/jedie/manageprojects/compare/v0.9.4...v0.9.6)
* 2023-03-12 - Speedup: Install as editable with '--no-deps'
* 2023-03-12 - Fix #68 Handle if there are no git tags while publishing
* 2023-03-11 - Bugfix reverse command and binary files
* [v0.9.4](https://github.com/jedie/manageprojects/compare/v0.9.3...v0.9.4)
* 2023-03-09 - Support "poerty" in publish_package(), too.
* [v0.9.3](https://github.com/jedie/manageprojects/compare/v0.9.2...v0.9.3)
* 2023-03-07 - Fix publish
* 2023-03-07 - Update project
* 2023-03-06 - coverage xml report + CLI
* 2023-03-06 - Update README.md
* 2023-03-06 - Fix CI / coverage run
* 2023-03-06 - Remove "python_version < 3.11" for "tomli"
* 2023-03-06 - merge cookie cutter template updates
* [v0.9.2](https://github.com/jedie/manageprojects/compare/v0.9.1...v0.9.2)
* 2023-02-26 - Make the Result available on an error
* 2023-02-26 - update requirements
* 2023-02-26 - invoke_click(): Raise exception if exists
* 2023-02-23 - Add: "E301 - expected 1 blank line" to "format-file"
* [v0.9.1](https://github.com/jedie/manageprojects/compare/v0.9.0...v0.9.1)
* 2023-02-22 - Bugfix publish a poetry package and get the version string from pyproject.toml
* [v0.9.0](https://github.com/jedie/manageprojects/compare/v0.8.3...v0.9.0)
* 2023-02-21 - README
* 2023-02-21 - Refactor publish command and make is useable for external packages, too.
* 2023-02-21 - Enhance verbose_check_output: Display output on errors and exit
* 2023-02-20 - Enhance SubprocessCallMock: Mock subprocess.run(), too.
* [v0.8.3](https://github.com/jedie/manageprojects/compare/v0.8.2...v0.8.3)
* 2023-02-20 - Bugfix packaging: remove "tox" from normal, non-dev dependencies
* [v0.8.2](https://github.com/jedie/manageprojects/compare/v0.8.0...v0.8.2)
* 2023-02-20 - Path(sys.executable).parent -> PY_BIN_PATH
* 2023-02-20 - Add "E305" to darker prefixes
* 2023-02-20 - Add tox config via manageprojects
* 2023-02-19 - Add "W391 blank line at end of file" to darker pre fixes
* 2023-02-19 - Add check_editor_config()
* 2023-02-19 - CLI: Add "version" back as pseudo command.
* 2023-02-19 - Better subprocess_utils API
* [v0.8.0](https://github.com/jedie/manageprojects/compare/v0.7.3...v0.8.0)
* 2023-02-19 - Split "test_cli" and add "format-file" into README
* 2023-02-18 - Add reuseable helper: print_version()
* 2023-02-18 - NEW: "format-file"
* 2023-02-18 - add Safety check
* 2023-02-18 - apply manageprojects
* [v0.7.3](https://github.com/jedie/manageprojects/compare/v0.7.1...v0.7.3)
* 2023-01-25 - Bugfix "--overwrite" if there are new directories in template
* 2023-01-25 - Bugfix "overwrite" if there are new files
* [v0.7.1](https://github.com/jedie/manageprojects/compare/v0.7.0...v0.7.1)
* 2023-01-25 - Add cli help pages into README using helper in bx_py_utils
* [v0.7.0](https://github.com/jedie/manageprojects/compare/v0.6.0...v0.7.0)
* 2023-01-15 - Fix #41 Add "--overwrite" to "update-project" command
* [v0.6.0](https://github.com/jedie/manageprojects/compare/v0.5.0...v0.6.0)
* 2023-01-14 - bugfix publish command
* 2023-01-14 - NEW: "update-test-snapshot-files" command
* 2023-01-14 - Fix tests
* 2023-01-13 - Replace typer with the origin click
* 2023-01-12 - apply migration
* 2023-01-12 - Enhance CLI argument documentation
* 2023-01-11 - update requirements
* 2023-01-09 - Better code style test + fix via unittests
* 2023-01-09 - Use RedirectOut from bx_py_utils v73
* 2023-01-09 - Bugfix "./cli.py install" and wrong path to req. file
* 2023-01-09 - reverse command: Use "git ls-files" instead of pathspec
* [v0.5.0](https://github.com/jedie/manageprojects/compare/v0.4.0...v0.5.0)
* 2023-01-08 - NEW: Reverse a project into a Cookiecutter template
* [v0.4.0](https://github.com/jedie/manageprojects/compare/v0.3.3...v0.4.0)
* 2022-12-30 - Refactor "dependencies" definition
* 2022-12-30 - Bugfix Git(): Pass environment, but set "en_US" als language
* 2022-12-30 - update requirements
* 2022-12-30 - include all packages
* 2022-12-30 - Capture and check log output in tests
* 2022-12-30 - cleanup editorconfig
* 2022-12-30 - enhance test run
* 2022-12-30 - Bugfix wrong "hint"
* [v0.3.3](https://github.com/jedie/manageprojects/compare/v0.3.2...v0.3.3)
* 2022-12-21 - Update requirements
* 2022-12-21 - Use new pip-compile resolver
* 2022-12-21 - Bugfix if git output will be translated.
* 2022-11-30 - Fix help by adding './cli.py' and add basic CLI tests
* 2022-11-30 - Enhance "start-project" and "update-project" CLI help pages
* 2022-11-30 - Update README.md
* 2022-11-22 - update reqirements
* 2022-11-20 - SELF MANAGE !!!
* 2022-11-20 - fix typo
* 2022-11-20 - rename: "./mp.py" -> "./cli.py"

[comment]: <> (✂✂✂ auto generated history end ✂✂✂)

## Links

Expand Down
9 changes: 4 additions & 5 deletions manageprojects/cookiecutter_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

from bx_py_utils.path import assert_is_dir
from cli_base.cli_tools.git import Git
from cookiecutter import generate
from cookiecutter.config import get_user_config
from cookiecutter.main import cookiecutter
from cookiecutter.repository import determine_repo_dir

from manageprojects.utilities.cookiecutter_utils import CookieCutterHookHandler
from manageprojects.utilities.cookiecutter_utils import GenerateFilesWrapper
from manageprojects.utilities.log_utils import log_func_call


Expand Down Expand Up @@ -87,8 +86,8 @@ def execute_cookiecutter(
password=password,
config_file=config_file,
)
run_hook = CookieCutterHookHandler(origin_run_hook=generate.run_hook)
with patch.object(generate, 'run_hook', run_hook):
generate_files_wrapper = GenerateFilesWrapper()
with patch('cookiecutter.main.generate_files', generate_files_wrapper):
destination = log_func_call(
logger=logger,
func=cookiecutter,
Expand All @@ -102,7 +101,7 @@ def execute_cookiecutter(
password=password,
config_file=config_file,
)
cookiecutter_context = run_hook.context
cookiecutter_context = generate_files_wrapper.context
logger.info('Cookiecutter context: %r', cookiecutter_context)
destination_path = Path(destination)
assert_is_dir(destination_path)
Expand Down
22 changes: 22 additions & 0 deletions manageprojects/tests/test_readme_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from unittest import TestCase

from bx_py_utils.auto_doc import assert_readme_block
from cli_base.cli_tools.git_history import get_git_history

import manageprojects
from manageprojects.cli.dev import PACKAGE_ROOT


class ReadmeHistoryTestCase(TestCase):
def test_readme_history(self):
git_history = get_git_history(
current_version=manageprojects.__version__,
add_author=False,
)
history = '\n'.join(git_history)
assert_readme_block(
readme_path=PACKAGE_ROOT / 'README.md',
text_block=f'\n{history}\n',
start_marker_line='[comment]: <> (✂✂✂ auto generated history start ✂✂✂)',
end_marker_line='[comment]: <> (✂✂✂ auto generated history end ✂✂✂)',
)
20 changes: 10 additions & 10 deletions manageprojects/utilities/cookiecutter_utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import logging

from cookiecutter.generate import generate_files


logger = logging.getLogger(__name__)


class CookieCutterHookHandler:
class GenerateFilesWrapper:
"""
Capture the effective Cookiecutter Template Context via injecting the Cookiecutter hooks.
Capture the effective Cookiecutter Template Context
"""

def __init__(self, origin_run_hook):
self.origin_run_hook = origin_run_hook
self.context = {}
def __init__(self):
self.context = None

def __call__(self, hook_name, project_dir, context):
logger.debug('Hook %r for %r context: %r', hook_name, project_dir, context)
origin_hook_result = self.origin_run_hook(hook_name, project_dir, context)
self.context.update(context)
return origin_hook_result
def __call__(self, **kwargs):
logger.debug('GenerateFilesWrapper called with: %s', kwargs)
self.context = kwargs['context']
return generate_files(**kwargs)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
requires-python = ">=3.9,<4"
dependencies = [
"cookiecutter", # https://github.com/cookiecutter/cookiecutter
"cookiecutter>=2.4.0", # https://github.com/cookiecutter/cookiecutter
"tomlkit",
"EditorConfig", # https://github.com/editorconfig/editorconfig-core-py

Expand All @@ -27,7 +27,7 @@ dependencies = [
"codespell", # https://github.com/codespell-project/codespell
"mypy", # https://github.com/python/mypy

"cli-base-utilities>=0.3.0", # https://github.com/jedie/cli-base-utilities
"cli-base-utilities", # https://github.com/jedie/cli-base-utilities
"click", # https://github.com/pallets/click/
"rich-click", # https://github.com/ewels/rich-click
"rich", # https://github.com/Textualize/rich
Expand Down
Loading

0 comments on commit a72d9e7

Please sign in to comment.