Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit a8f7f3a

Browse files
author
cstrap
committed
Vue.js wrapper via vue-cli provided by click
1 parent 88a83b7 commit a8f7f3a

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

python_vuejs/django.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import click
4+
5+
6+
@click.command()
7+
def djan(args=None):
8+
"""Console script for python_vuejs"""
9+
click.echo("Replace this message by putting your code into "
10+
"python_vuejs.cli.main")
11+
click.echo("See click documentation at http://click.pocoo.org/")

python_vuejs/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, division, print_function, unicode_literals
3+
4+
import contextlib
5+
import os
6+
7+
8+
@contextlib.contextmanager
9+
def cd(path):
10+
"""
11+
A context manager which changes the working directory to the given
12+
path, and then changes it back to its previous value on exit.
13+
"""
14+
prev_cwd = os.getcwd()
15+
os.chdir(path)
16+
yield
17+
os.chdir(prev_cwd)

python_vuejs/vuejs.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, division, print_function
3+
4+
import click
5+
6+
from .utils import cd
7+
8+
from subprocess import check_output
9+
10+
try:
11+
from subprocess import call as run
12+
except ImportError:
13+
from subprocess import run
14+
15+
16+
@click.command()
17+
def check_env():
18+
"""
19+
Check if node > 5 and npm > 3 are installed
20+
"""
21+
out = all([check_output(['node -v'.split()]) > 'v5.0.0', check_output(['npm -v'.split()]) >= '4.0.0'])
22+
if out:
23+
click.echo(click.style('Found node and npm', fg='green'))
24+
else:
25+
click.echo(click.style('Missing node and npm installation', fg='red'))
26+
return out
27+
28+
29+
@click.command()
30+
def install_vue_cli():
31+
"""
32+
Install vue-cli
33+
"""
34+
out = check_output(['vue -V'.split()])
35+
if out >= '2.0.0.':
36+
click.echo(click.style('Found valid vue-cli', fg='green'))
37+
else:
38+
run(['npm install -g vue-cli'.split()])
39+
click.echo(click.style('Installed vue-cli globally', fg='green'))
40+
41+
42+
@click.command()
43+
@click.argument('project')
44+
def startvueapp(project):
45+
run('vue init webpack {project}'.format(project=project).split())
46+
with cd(project):
47+
run(['npm install'.split()])
48+
49+
50+
@click.command()
51+
def vuedev():
52+
run(['npm run dev'.split()])

setup.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from setuptools import setup
5+
6+
with open('README.rst') as readme_file:
7+
readme = readme_file.read()
8+
9+
with open('HISTORY.rst') as history_file:
10+
history = history_file.read()
11+
12+
requirements = [
13+
'Click>=6.0',
14+
'colorama',
15+
]
16+
17+
test_requirements = [
18+
# TODO: put package test requirements here
19+
]
20+
21+
setup(
22+
name='python_vuejs',
23+
version='0.0.1',
24+
description="Gluing Python and Vue.js with a set of scripts",
25+
long_description=readme + '\n\n' + history,
26+
author="Christian Strappazzon",
27+
author_email='lab@strap.it',
28+
url='https://github.com/cstrap/python-vuejs',
29+
packages=[
30+
'python_vuejs',
31+
],
32+
package_dir={'python_vuejs':
33+
'python_vuejs'},
34+
entry_points={
35+
'console_scripts': [
36+
'checkenv=python_vuejs.vuejs:check_env',
37+
'vuecli=python_vuejs.vuejs:install_vue_cli',
38+
'startvueapp=python_vuejs.vuejs:startvueapp',
39+
'startvueapp=python_vuejs.vuejs:vuedev',
40+
]
41+
},
42+
include_package_data=True,
43+
install_requires=requirements,
44+
license="MIT license",
45+
zip_safe=False,
46+
keywords='python_vuejs',
47+
classifiers=[
48+
'Development Status :: 2 - Pre-Alpha',
49+
'Intended Audience :: Developers',
50+
'License :: OSI Approved :: MIT License',
51+
'Natural Language :: English',
52+
"Programming Language :: Python :: 2",
53+
'Programming Language :: Python :: 2.7',
54+
'Programming Language :: Python :: 3',
55+
'Programming Language :: Python :: 3.3',
56+
'Programming Language :: Python :: 3.4',
57+
'Programming Language :: Python :: 3.5',
58+
],
59+
test_suite='tests',
60+
tests_require=test_requirements
61+
)

0 commit comments

Comments
 (0)