-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
72 lines (55 loc) · 1.53 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
import sys
import os
import shutil
from pynt import task
client_dir_name = 'confessions-client'
rest_dir_name = 'confessions-rest'
root_dir = os.path.abspath(os.path.dirname(__file__))
client_dir = os.path.join(root_dir, client_dir_name)
rest_dir = os.path.join(root_dir, rest_dir_name)
def system_command(command):
returncode = os.system(' '.join(command))
if returncode:
raise Exception()
@task()
def build_client():
"""Build the client code"""
os.chdir(client_dir)
command = [
'ng', 'build', '--prod', '--output-path', os.path.join(rest_dir, 'static', 'ang'), '--output-hashing', 'none'
]
system_command(command)
@task()
def clean():
"""Clean the client node_modules installation"""
os.chdir(client_dir)
node_modules = os.path.join(client_dir, 'node_modules')
if os.path.isdir(node_modules):
shutil.rmtree(node_modules)
@task()
def _install():
"""Install node dependencies"""
os.chdir(client_dir)
command = ['npm', 'install']
system_command(command)
@task(clean, _install)
def clean_install():
"""Clean install node modules"""
pass
@task()
def run_client():
"""Run client service"""
os.chdir(client_dir)
command = ['ng', 'serve']
system_command(command)
@task()
def run_rest_service():
"""Run rest service"""
os.chdir(rest_dir)
command = [sys.executable, 'manage.py', 'runserver']
system_command(command)
@task(clean_install, build_client, run_rest_service)
def run():
"""Run the application"""
pass