diff --git a/cookiecutter.json b/cookiecutter.json index 1cec89a..fcde0fe 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -7,5 +7,7 @@ "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", "version": "0.0.1", "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"], - "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" + "include_web_directory_for_custom_javascript": false, + "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}", + "__include_web": "{{ cookiecutter.include_web_directory_for_custom_javascript }}" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index a431983..844f316 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,7 +1,11 @@ #!/usr/bin/env python -import pathlib +from pathlib import Path as Pth +import shutil -if __name__ == '__main__': - if 'Not open source' == '{{ cookiecutter.open_source_license }}': - pathlib.Path('LICENSE').unlink() +if __name__ == "__main__": + if "{{cookiecutter.open_source_license}}" == "Not open source": + Pth("LICENSE").unlink() + + if "{{cookiecutter.__include_web}}" == "False": + shutil.rmtree("src/{{cookiecutter.project_slug}}/web") diff --git a/{{cookiecutter.project_name}}/MANIFEST.in b/{{cookiecutter.project_name}}/MANIFEST.in index fa01dd8..c0cb69a 100644 --- a/{{cookiecutter.project_name}}/MANIFEST.in +++ b/{{cookiecutter.project_name}}/MANIFEST.in @@ -1,8 +1,13 @@ include LICENSE include README.md -recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif + +{% if cookiecutter.__include_web -%} + +graft src/{{cookiecutter.project_slug}}/web + +{%- endif %} diff --git a/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/__init__.py index 32d1322..1a4d94d 100644 --- a/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/__init__.py +++ b/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/__init__.py @@ -3,6 +3,9 @@ __all__ = [ "NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", + {% if cookiecutter.__include_web -%} + "WEB_DIRECTORY", + {%- endif %} ] __author__ = """{{cookiecutter.full_name}}""" @@ -11,3 +14,7 @@ from .nodes import NODE_CLASS_MAPPINGS from .nodes import NODE_DISPLAY_NAME_MAPPINGS + +{% if cookiecutter.__include_web -%} +WEB_DIRECTORY = "web" +{%- endif %} diff --git a/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/web/js/example.js b/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/web/js/example.js new file mode 100644 index 0000000..ffe779f --- /dev/null +++ b/{{cookiecutter.project_name}}/src/{{cookiecutter.project_slug}}/web/js/example.js @@ -0,0 +1,3 @@ +import { app } from "../../../scripts/app.js"; + +console.log(app)