Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(templates): Simplify tap template file names with post_gen_project.py hook #2060

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ repos:
exclude: |
(?x)^(
cookiecutter/.*/meltano.yml|
cookiecutter/.*/.pre-commit-config.yaml
cookiecutter/.*/.pre-commit-config.yaml|
cookiecutter/.*/dependabot.yml|
cookiecutter/.*/test.yml
)$
- id: end-of-file-fixer
exclude: |
Expand Down
4 changes: 2 additions & 2 deletions cookiecutter/tap-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"JWT",
"Custom or N/A"
],
"include_ci_files": ["GitHub", "None (Skip)"],
"license": ["Apache-2.0"],
"include_ci_files": ["GitHub", "None"],
"license": ["Apache-2.0", "None"],
"__prompts__": {
"source_name": "The name of the source, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
Expand Down
27 changes: 27 additions & 0 deletions cookiecutter/tap-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
from pathlib import Path
import shutil


BASE_PATH = Path('{{cookiecutter.library_name}}')


if __name__ == '__main__':

# Rename stream type client and delete others
target = Path(BASE_PATH, 'client.py')
Path(BASE_PATH, '{{cookiecutter.stream_type|lower}}-client.py').rename(target)
[c.unlink() for c in Path(BASE_PATH).rglob("*-client.py")]

if '{{ cookiecutter.auth_method }}' not in ('OAuth2', 'JWT'):
Path(BASE_PATH, 'auth.py').unlink()

if '{{ cookiecutter.stream_type }}' == 'SQL':
Path(BASE_PATH, 'streams.py').unlink()

if '{{ cookiecutter.license }}' != 'Apache-2.0':
Path('LICENSE').unlink()

if '{{ cookiecutter.include_ci_files }}' != 'GitHub':
shutil.rmtree(Path('.github'))

Loading