diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..454acf5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +python: + - 2.7 + - 3.3 + - 3.4 +install: + - pip install invoke==0.9.0 +script: + - invoke test diff --git a/README.rst b/README.rst index 7f33508..4c648f1 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,11 @@ A Flask template for cookiecutter_. .. _cookiecutter: https://github.com/audreyr/cookiecutter +.. image:: https://travis-ci.org/sloria/cookiecutter-flask.svg + :target: https://travis-ci.org/sloria/cookiecutter-flask + :alt: Build Status + + Use it now ---------- :: diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..0ff1a87 --- /dev/null +++ b/tasks.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import shutil + +from invoke import task, run + +HERE = os.path.abspath(os.path.dirname(__file__)) +# Match default value of app_name from cookiecutter.json +COOKIE = os.path.join(HERE, 'myflaskapp') +REQUIREMENTS = os.path.join(COOKIE, 'requirements', 'dev.txt') + +@task +def build(): + run('cookiecutter {0} --no-input'.format(HERE)) + +@task +def clean(): + if os.path.exists(COOKIE): + shutil.rmtree(COOKIE) + print('Removed {0}'.format(COOKIE)) + else: + print('App directory does not exist. Skipping.') + +@task(pre=[clean, build]) +def test(): + run('pip install -r {0}'.format(REQUIREMENTS), echo=True) + run('python {0} test'.format(os.path.join(COOKIE, 'manage.py')), echo=True) diff --git a/{{cookiecutter.app_name}}/manage.py b/{{cookiecutter.app_name}}/manage.py index 1ce37b7..f5cc479 100644 --- a/{{cookiecutter.app_name}}/manage.py +++ b/{{cookiecutter.app_name}}/manage.py @@ -16,8 +16,10 @@ if os.environ.get("{{cookiecutter.app_name | upper}}_ENV") == 'prod': else: app = create_app(DevConfig) +HERE = os.path.abspath(os.path.dirname(__file__)) +TEST_PATH = os.path.join(HERE, 'tests') + manager = Manager(app) -TEST_CMD = "py.test tests" def _make_context(): """Return context dict for a shell session so you can access @@ -29,7 +31,7 @@ def _make_context(): def test(): """Run the tests.""" import pytest - exit_code = pytest.main(['tests', '--verbose']) + exit_code = pytest.main([TEST_PATH, '--verbose']) return exit_code manager.add_command('server', Server()) diff --git a/{{cookiecutter.app_name}}/requirements/dev.txt b/{{cookiecutter.app_name}}/requirements/dev.txt index d4c113d..8a668fc 100644 --- a/{{cookiecutter.app_name}}/requirements/dev.txt +++ b/{{cookiecutter.app_name}}/requirements/dev.txt @@ -2,7 +2,7 @@ -r prod.txt # Testing -pytest +pytest>=2.6.3 webtest factory-boy==2.4.1 diff --git a/{{cookiecutter.app_name}}/requirements/prod.txt b/{{cookiecutter.app_name}}/requirements/prod.txt index 4682759..ea1ce94 100644 --- a/{{cookiecutter.app_name}}/requirements/prod.txt +++ b/{{cookiecutter.app_name}}/requirements/prod.txt @@ -9,7 +9,7 @@ itsdangerous==0.24 # Database Flask-SQLAlchemy==2.0 -SQLAlchemy==0.9.7 +SQLAlchemy==0.9.8 # Migrations Flask-Migrate==1.2.0 @@ -19,16 +19,16 @@ Flask-WTF==0.10.2 WTForms==2.0.1 # Deployment -gunicorn>=17.5 +gunicorn>=19.1.1 # Assets Flask-Assets==0.10 -cssmin>=0.1.4 -jsmin>=2.0.4 +cssmin>=0.2.0 +jsmin>=2.0.11 # Auth Flask-Login==0.2.11 Flask-Bcrypt==0.6.0 # Caching -Flask-Cache>=0.12 +Flask-Cache>=0.13.1