From ea772de29b1c34d51143a828fb48d613ea7f1033 Mon Sep 17 00:00:00 2001 From: Juan Alberto Jimenez Angel Date: Wed, 20 May 2015 12:43:14 -0500 Subject: [PATCH] (md:94865) Stylus and coverage added to luke --- .gitignore | 3 +++ fabfile.py | 50 ++++++++++++++++++++++++++++++++++++++ provision/provision.sh | 7 +++++- src/assets/css/custom.styl | 1 + src/requirements/devel.txt | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/assets/css/custom.styl diff --git a/.gitignore b/.gitignore index bee1f27..ff20011 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .vagrant/ +src/htmlcov +.coverage *.pyc +src/assets/css/custom.css \ No newline at end of file diff --git a/fabfile.py b/fabfile.py index de96905..2e6d438 100644 --- a/fabfile.py +++ b/fabfile.py @@ -11,6 +11,11 @@ from fabutils.text import SUCCESS_ART +project_tools = { + 'is_using_stylus': False +} + + @contextmanager def virtualenv(): """ @@ -103,15 +108,57 @@ def collectstatic(): run('python manage.py collectstatic --noinput') +@task +def createsuperuser(): + """ + Creates super user + """ + with virtualenv(): + run('python manage.py createsuperuser') + + +@task +def runtests(app=""): + """ + Runs django tests + """ + with virtualenv(): + run("coverage run --source='.' manage.py test %s" % app) + run("coverage html \ + --omit=luke/settings/*,luke/wsgi.py") + + @task def runserver(): """ Starts the development server inside the Vagrant VM. """ + + # Check if stylus compilation is needed + checkstylus() + with virtualenv(): run('python manage.py runserver_plus 0.0.0.0:8000') +@task +def styluscompile(watch=False): + """ + Compiles custom.styl file to css. + """ + watch_config = "" + if watch: + watch_config = "-w" + + with virtualenv(): + run('stylus -c %s assets/css/custom.styl' % watch_config) + + +def checkstylus(): + if project_tools['is_using_stylus']: + styluscompile() + + @task def deploy(git_ref, upgrade=False): """ @@ -122,6 +169,9 @@ def deploy(git_ref, upgrade=False): """ require('hosts', 'user', 'group', 'site_dir', 'django_settings') + # Check if stylus compilation is needed + checkstylus() + # Retrives git reference metadata and creates a temp directory with the # contents resulting of applying a ``git archive`` command. message = white('Creating git archive from {0}'.format(git_ref), bold=True) diff --git a/provision/provision.sh b/provision/provision.sh index 71a4214..7f366ca 100644 --- a/provision/provision.sh +++ b/provision/provision.sh @@ -1,11 +1,12 @@ #!/bin/bash echo "Updating apt repositories..." +add-apt-repository ppa:chris-lea/node.js apt-get update echo "Installing base packages..." PACKAGES="build-essential zsh git vim-nox tree htop libjpeg-dev libfreetype6-dev graphviz gettext" -PACKAGES="$PACKAGES python python-setuptools python-pip python-dev" +PACKAGES="$PACKAGES python python-setuptools python-pip python-dev nodejs" PACKAGES="$PACKAGES postgresql-9.3 postgresql-server-dev-9.3" apt-get install -y $PACKAGES @@ -56,6 +57,10 @@ if [ -f "$REQUIREMENTS_FILE" ]; then fi +echo "Installing Stylus css precompiler..." +npm install stylus -g + + echo "Creating Django project..." PROJECT_NAME=luke PROJECT_DIR=/home/vagrant/src/$PROJECT_NAME diff --git a/src/assets/css/custom.styl b/src/assets/css/custom.styl new file mode 100644 index 0000000..25eef5b --- /dev/null +++ b/src/assets/css/custom.styl @@ -0,0 +1 @@ +//project's stylus code \ No newline at end of file diff --git a/src/requirements/devel.txt b/src/requirements/devel.txt index 2895f9d..eb1b572 100644 --- a/src/requirements/devel.txt +++ b/src/requirements/devel.txt @@ -2,3 +2,4 @@ # Development tools django-debug-toolbar +coverage==3.7.1