Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Gulp is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
valerymelou committed May 6, 2016
1 parent e6b5307 commit cc9e5a9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ It prompts you for questions. Answer them::
year [2015]:
windows [n]: n
use_python2 [n]: y
use_gulp [n]: n
Select open_source_license:
1 - MIT
2 - BSD
Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"year": "{{ cookiecutter.now[:4] }}",
"windows": "n",
"use_python2": "n",
"use_gulp": "n",
"open_source_license": ["MIT", "BSD", "Not open source"]
}
3 changes: 3 additions & 0 deletions docs/project-generation-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ windows [n]
use_python2 [n]
By default, the Python code generated will be for Python 3.x. But if you
answer `y` here, it will be legacy Python 2.7 code.

use_gulp [n]
Wheter you'll use gulp as your frontend task manager.
24 changes: 14 additions & 10 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Does the following:
1. Generates and saves random secret key
2. Removes unused files
A portion of this code was adopted from Django's standard crypto functions and
utilities, specifically:
Expand Down Expand Up @@ -87,15 +88,18 @@ def make_secret_key(project_directory):
set_secret_key(env_file)


def remove_task_app(project_directory):
"""Removes the taskapp if celery isn't going to be used"""
# Determine the local_setting_file_location
task_app_location = os.path.join(
PROJECT_DIRECTORY,
'{{ cookiecutter.project_slug }}/taskapp'
)
shutil.rmtree(task_app_location)


# 1. Generates and saves random secret key
make_secret_key(PROJECT_DIRECTORY)

def remove_gulp_files():
"""
Removes files needed for gulp if it isn't going to be used.
"""
for filename in ['gulpfile.js', 'package.json']:
os.remove(os.path.join(
PROJECT_DIRECTORY, filename
))

# 2. Removes all gulp files if it isn't going to be used
if '{{ cookiecutter.use_gulp }}'.lower() != 'y':
remove_gulp_files()
3 changes: 1 addition & 2 deletions {{cookiecutter.project_slug}}/config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
str(APPS_DIR.path('static')), # Put your assets here
str(ROOT_DIR('build')), # Optimized assets are generated here
)
{% if cookiecutter.use_gulp == 'y' -%}str(ROOT_DIR('build')), # Optimized assets are generated here{%- endif %})

# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = (
Expand Down

0 comments on commit cc9e5a9

Please sign in to comment.