From 22c20f11a01ab6d6927af5e46c554359a14c0db1 Mon Sep 17 00:00:00 2001 From: Christian Strappazzon Date: Tue, 3 Oct 2017 15:00:49 +0200 Subject: [PATCH 1/2] Added some logging --- python_vuejs/vuejs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python_vuejs/vuejs.py b/python_vuejs/vuejs.py index 7908410..ff2c0f1 100644 --- a/python_vuejs/vuejs.py +++ b/python_vuejs/vuejs.py @@ -43,19 +43,23 @@ def install_cli(): @staticmethod def project_setup(project): + click.echo(click.style('running `vue init webpack {project}`'.format(project=project), fg='yellow')) run('vue init webpack {project}'.format(project=project).split()) @staticmethod def install_dependencies(project): with cd(project): + click.echo(click.style('running `npm install`', fg='yellow')) run('npm install'.split()) @staticmethod def dev(): + click.echo(click.style('running `npm run dev`', fg='yellow')) run('npm run dev'.split()) @staticmethod def build(): + click.echo(click.style('running `npm run build`', fg='yellow')) run('npm run build'.split()) From af1a6a3a9bd72552e1b0de4551dcde34a37b1bff Mon Sep 17 00:00:00 2001 From: Christian Strappazzon Date: Tue, 3 Oct 2017 15:01:42 +0200 Subject: [PATCH 2/2] Passing context and invoking command --- python_vuejs/django.py | 6 ++++-- tests/test_django_cli.py | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python_vuejs/django.py b/python_vuejs/django.py index ea1b541..aa5b5b0 100644 --- a/python_vuejs/django.py +++ b/python_vuejs/django.py @@ -90,12 +90,14 @@ def djangofy(project): @cli.command() @click.argument('project') -def djstartvueapp(project): +@click.pass_context +def djstartvueapp(ctx, project): """ Run click commands on bash. """ click.echo(click.style('Creating {project}'.format(project=project), fg='green')) if os.path.isfile('manage.py') and VueJsBuilder.startproject(project).status: - djangofy() + ctx.forward(djangofy) + ctx.invoke(djangofy, project=project) else: click.echo(click.style('Invalid django project directory', fg='red')) diff --git a/tests/test_django_cli.py b/tests/test_django_cli.py index 0f52bb2..0f61475 100644 --- a/tests/test_django_cli.py +++ b/tests/test_django_cli.py @@ -119,8 +119,7 @@ def test_djangofy_already_executed(self): # Then self.assertEqual('Making Vue.js myapp into django app\nCommand already executed\n', result.output) - @patch('python_vuejs.django.djangofy') - def test_djstartvueapp_django_ok(self, mock_djangofy): + def test_djstartvueapp_django_ok(self): with self.runner.isolated_filesystem(): # Given open('manage.py', 'a').close() @@ -132,8 +131,7 @@ def test_djstartvueapp_django_ok(self, mock_djangofy): result = self.runner.invoke(cli.cli, ['djstartvueapp', 'myapp']) # Then mock_vuejsbuilder.assert_called_once() - mock_djangofy.assert_called_once() - self.assertEqual('Creating myapp\n', result.output) + self.assertEqual('Creating myapp\nMaking Vue.js myapp into django app\n', result.output) def test_djstartvueapp_django_ko(self): result = self.runner.invoke(cli.cli, ['djstartvueapp', 'myapp'])