Added post_get hooks to clean up unnecessary package managment files and updated README.rst

master
dasDachs 7 years ago
parent 26a30c6f01
commit 6ecc22bd3d
  1. 3
      cookiecutter.json
  2. 35
      hooks/post_gen_project.py
  3. 0
      {{cookiecutter.app_name}}/Pipfile
  4. 8
      {{cookiecutter.app_name}}/README.rst

@ -4,5 +4,6 @@
"github_username": "sloria",
"project_name": "My Flask App",
"app_name": "myflaskapp",
"project_short_description": "A flasky app."
"project_short_description": "A flasky app.",
"use_pipenv": ["yes", "no"]
}

@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Post gen hook to ensure that the generated project
hase only one package managment, either pipenv or pip."""
import os
import shutil
import sys
def clean_extra_package_managment_files():
"""Removes either requirements files and folderor the Pipfile."""
use_pipenv = '{{cookiecutter.use_pipenv}}'
to_delete = []
if use_pipenv == 'yes':
to_delete = to_delete + ['requirements.txt', 'requirements']
else:
to_delete.append('Pipfile')
try:
for file_or_dir in to_delete:
if os.path.isfile(file_or_dir):
os.remove(file_or_dir)
else:
shutil.rmtree(file_or_dir)
sys.exit(0)
except OSError as e:
sys.stdout.write(
'While attempting to remove file(s) an error occurred'
)
sys.stdout.write('Error: {}'.format(e))
if __name__ == '__main__':
clean_extra_package_managment_files()

@ -19,11 +19,11 @@ Run the following commands to bootstrap your environment ::
git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.app_name}}
cd {{cookiecutter.app_name}}
pip install -r requirements/dev.txt
# or use Pipenv
{%- if cookiecutter.use_pipenv == "yes" %}
pipenv install --dev
{%- else %}
pip install -r requirements/dev.txt
{%- endif %}
npm install
npm start # run the webpack dev server and flask server using concurrently

Loading…
Cancel
Save