Skip to content

Commit

Permalink
phonegap build tool (see wq/wq-django-template#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Jan 5, 2017
1 parent eb29daf commit a40ee66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion django_project
27 changes: 23 additions & 4 deletions projects.py
Expand Up @@ -3,6 +3,7 @@
import os
import shutil
from django.core.management import call_command
from django.core.management.commands import startproject
from pkg_resources import resource_filename
from wq.core.info import print_versions

Expand All @@ -14,10 +15,23 @@
template = wq_module.__path__[0] + os.sep + template


class StartProjectCommand(startproject.Command):
def add_arguments(self, parser):
super(StartProjectCommand, self).add_arguments(parser)
parser.add_argument('--domain', help="Web Domain")
parser.add_argument('--app-id', help="App Identifier")


@wq.command()
@click.argument("project_name", required=True)
@click.argument("destination", required=False)
def start(project_name, destination):
@click.option(
"-d", "--domain", required=True, help='Web domain (e.g. example.wq.io)'
)
@click.option(
"-i", "--app-id", help="Application ID (e.g. io.wq.example)"
)
def start(project_name, destination, domain=None, app_id=None):
"""
Start a new project with wq.app and wq.db. A new Django project will be
created from a wq-specific template. After running this command, you may
Expand All @@ -30,16 +44,21 @@ def start(project_name, destination):
See https://wq.io/docs/setup for more tips on getting started with wq.
"""

if app_id is None:
app_id = '.'.join(reversed(domain.split('.')))

args = [project_name]
if destination:
args.append(destination)

kwargs = dict(
template=template,
extensions=["py", "yml", "conf", "html", "sh", "js", "css", "json"],
extensions="py,yml,conf,html,sh,js,css,json,xml".split(","),
domain=domain,
app_id=app_id,
)
call_command(StartProjectCommand(), *args, **kwargs)

call_command('startproject', *args, **kwargs)
path = destination or project_name
txt = os.path.join(path, 'requirements.txt')
print_versions(txt, [
Expand Down
2 changes: 1 addition & 1 deletion tests/test-deploy.sh
Expand Up @@ -11,7 +11,7 @@ psql -Upostgres test_project -c "CREATE EXTENSION postgis";

# wq start: Create new project and verify empty config
rm -rf test_project
wq start test_project
wq start test_project -d test.wq.io
if [ `python -c 'import sys; print(sys.version_info[0])'` == "2" ]
then
sed -i "s/python3/python/" test_project/db/manage.py
Expand Down

0 comments on commit a40ee66

Please sign in to comment.