Skip to content

Commit

Permalink
Update project template structure to .toml file
Browse files Browse the repository at this point in the history
This commit also fixes issues with `new` shell command with accepting
data on the CLI.
  • Loading branch information
subhashb committed May 28, 2024
1 parent 2274033 commit 5c73456
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 363 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ tag = True

[bumpversion:file:src/protean/__init__.py]

[bumpversion:file:src/protean/template/{{package_name}}/setup.py.jinja]
[bumpversion:file:src/protean/template/domain_template/pyproject.toml]

[bumpversion:file:docs-sphinx/user/installation.rst]
22 changes: 11 additions & 11 deletions src/protean/cli/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import shutil

from typing import Optional, Tuple
from typing import List, Optional

import typer

Expand All @@ -17,11 +17,10 @@ def new(
output_folder: Annotated[
str, typer.Option("--output-dir", "-o", show_default=False)
] = ".",
data: Annotated[
Tuple[str, str], typer.Option("--data", "-d", show_default=False)
] = (None, None),
data: Annotated[List[str], typer.Option("--data", "-d", show_default=False)] = None,
pretend: Annotated[Optional[bool], typer.Option("--pretend", "-p")] = False,
force: Annotated[Optional[bool], typer.Option("--force", "-f")] = False,
defaults: Annotated[Optional[bool], typer.Option("--defaults")] = False,
):
def is_valid_project_name(project_name):
"""
Expand Down Expand Up @@ -71,19 +70,20 @@ def clear_directory_contents(dir_path):
clear_directory_contents(project_directory)

# Convert data tuples to a dictionary, if provided
data = (
{value[0]: value[1] for value in data} if len(data) != data.count(None) else {}
)
data_dict = {}
for value in data:
k, v = value.split("=", 1)
data_dict[k] = v

# Add the project name to answers
data["project_name"] = project_name
data_dict["project_name"] = project_name

# Create project from the cookiecutter-protean.git repo template
run_copy(
f"{protean.__path__[0]}/template",
project_directory or ".",
data=data,
unsafe=True, # Trust our own template implicitly
defaults=True, # Use default values for all prompts
data=data_dict,
unsafe=True, # Trust our own template implicitly,
defaults=defaults,
pretend=pretend,
)
6 changes: 6 additions & 0 deletions src/protean/template/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ short_description:
type: str
default: "{{ project_name }} - A Protean Application"

author_name:
type: str

author_email:
type: str

package_name:
type: str
default: "{{ project_name|lower|replace(' ','_')|replace('-','_') }}"
Expand Down
100 changes: 60 additions & 40 deletions src/protean/template/domain_template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
wheelhouse

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -39,15 +39,17 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
htmlcov
cover/

# Translations
*.mo
Expand All @@ -57,6 +59,7 @@ htmlcov
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -69,16 +72,51 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version
# IPython
profile_default/
ipython_config.py

# celery beat schedule file
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py
Expand All @@ -104,39 +142,21 @@ venv.bak/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea
*.iml
*.komodoproject

# Complexity
output/*.html
output/*/index.html

.DS_Store
*~
.*.sw[po]
.build
.ve
.env
.cache
.pytest
.bootstrap
.appveyor.token
*.bak
.testmondata

# VS Code
.vscode

# Sphinx
docs/.doctrees

# TODOs
TODO
*.todo
todos
# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
Empty file.
6 changes: 6 additions & 0 deletions src/protean/template/domain_template/README.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# {{ project_name }}

**Version 0.1.0**

{{ description }}

17 changes: 0 additions & 17 deletions src/protean/template/domain_template/README.rst.jinja

This file was deleted.

Loading

0 comments on commit 5c73456

Please sign in to comment.