Post hook cleanup

This commit is contained in:
Daniel Roy Greenfeld 2016-09-22 17:56:17 -07:00
parent ce8a711cf6
commit fb65b03a45
4 changed files with 27 additions and 7 deletions

View File

@ -22,5 +22,5 @@
"js_task_runner": ["Gulp", "Grunt", "None"], "js_task_runner": ["Gulp", "Grunt", "None"],
"use_lets_encrypt": "n", "use_lets_encrypt": "n",
"open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"], "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"],
"use_elasticbeanstalk": "y" "use_elasticbeanstalk_experimental": "y"
} }

View File

@ -115,7 +115,10 @@ def remove_heroku_files():
""" """
Removes files needed for heroku if it isn't going to be used Removes files needed for heroku if it isn't going to be used
""" """
for filename in ["app.json", "Procfile", "requirements.txt", "runtime.txt"]: filenames = ["app.json", "Procfile", "runtime.txt"]
if '{{ cookiecutter.use_elasticbeanstalk_experimental }}'.lower() != 'y':
filenames.append("requirements.txt")
for filename in ["app.json", "Procfile", "runtime.txt"]:
file_name = os.path.join(PROJECT_DIRECTORY, filename) file_name = os.path.join(PROJECT_DIRECTORY, filename)
remove_file(file_name) remove_file(file_name)
@ -179,6 +182,22 @@ def remove_copying_files():
PROJECT_DIRECTORY, filename PROJECT_DIRECTORY, filename
)) ))
def remove_elasticbeanstalk():
"""
Removes elastic beanstalk components
"""
docs_dir_location = os.path.join(PROJECT_DIRECTORY, '.ebextensions')
if os.path.exists(docs_dir_location):
shutil.rmtree(docs_dir_location)
filenames = ["ebsetenv.py", ]
if '{{ cookiecutter.use_heroku }}'.lower() != 'y':
filenames.append("requirements.txt")
for filename in filenames:
os.remove(os.path.join(
PROJECT_DIRECTORY, filename
))
# IN PROGRESS # IN PROGRESS
# def copy_doc_files(project_directory): # def copy_doc_files(project_directory):
# cookiecutters_dir = DEFAULT_CONFIG['cookiecutters_dir'] # cookiecutters_dir = DEFAULT_CONFIG['cookiecutters_dir']
@ -258,5 +277,6 @@ if '{{ cookiecutter.use_lets_encrypt }}'.lower() == 'y' and '{{ cookiecutter.use
if '{{ cookiecutter.open_source_license}}' != 'GPLv3': if '{{ cookiecutter.open_source_license}}' != 'GPLv3':
remove_copying_files() remove_copying_files()
# 4. Copy files from /docs/ to {{ cookiecutter.project_slug }}/docs/ # 12. Remove Elastic Beanstalk files
# copy_doc_files(PROJECT_DIRECTORY) if '{{ cookiecutter.use_elasticbeanstalk_experimental }}'.lower() != 'y':
remove_elasticbeanstalk()

View File

@ -138,7 +138,7 @@ See detailed `cookiecutter-django Docker documentation`_.
.. _`cookiecutter-django Docker documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html .. _`cookiecutter-django Docker documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html
{% endif %} {% endif %}
{% if cookiecutter.use_elasticbeanstalk %} {% if cookiecutter.use_elasticbeanstalk_experimental %}
Elastic Beanstalk Elastic Beanstalk
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@ -177,7 +177,7 @@ TEMPLATES[0]['OPTIONS']['loaders'] = [
# DATABASE CONFIGURATION # DATABASE CONFIGURATION
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
{% if cookiecutter.use_elasticbeanstalk -%} {% if cookiecutter.use_elasticbeanstalk_experimental -%}
# Uses Amazon RDS for database hosting, which doesn't follow the Heroku-style spec # Uses Amazon RDS for database hosting, which doesn't follow the Heroku-style spec
DATABASES = { DATABASES = {
'default': { 'default': {
@ -197,7 +197,7 @@ DATABASES['default'] = env.db('DATABASE_URL')
# CACHING # CACHING
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
{% if cookiecutter.use_elasticbeanstalk -%} {% if cookiecutter.use_elasticbeanstalk_experimental -%}
REDIS_LOCATION = "redis://{}:{}/0".format( REDIS_LOCATION = "redis://{}:{}/0".format(
env('REDIS_ENDPOINT_ADDRESS'), env('REDIS_ENDPOINT_ADDRESS'),
env('REDIS_PORT') env('REDIS_PORT')