Skip to content

Commit

Permalink
added support for optional web directory for custom javascript
Browse files Browse the repository at this point in the history
- when `web` is included, `WEB_DIRECTORY` is also set to `web`
  • Loading branch information
telamonian committed Jun 21, 2024
1 parent f44084b commit 4a38aa9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
}
12 changes: 8 additions & 4 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 6 additions & 1 deletion {{cookiecutter.project_name}}/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
__all__ = [
"NODE_CLASS_MAPPINGS",
"NODE_DISPLAY_NAME_MAPPINGS",
{% if cookiecutter.__include_web -%}
"WEB_DIRECTORY",
{%- endif %}
]

__author__ = """{{cookiecutter.full_name}}"""
Expand All @@ -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 %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { app } from "../../../scripts/app.js";

console.log(app)

0 comments on commit 4a38aa9

Please sign in to comment.