forked from erdem/django-map-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
111 lines (80 loc) · 3.2 KB
/
fabfile.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import os
from fabric.api import local
JS_FILE_MAPPING = {
"GooglePointFieldWidget": {
"input_files": [
"mapwidgets/static/mapwidgets/js/jquery_class.js",
"mapwidgets/static/mapwidgets/js/django_mw_base.js",
"mapwidgets/static/mapwidgets/js/mw_google_point_field.js",
],
"output_file": "mapwidgets/static/mapwidgets/js/mw_google_point_field.min.js"
},
"GooglePointFieldInlineWidget": {
"input_files": [
"mapwidgets/static/mapwidgets/js/jquery_class.js",
"mapwidgets/static/mapwidgets/js/django_mw_base.js",
"mapwidgets/static/mapwidgets/js/mw_google_point_field.js",
"mapwidgets/static/mapwidgets/js/mw_google_point_field_generater.js",
],
"output_file": "mapwidgets/static/mapwidgets/js/mw_google_point_inline_field.min.js"
}
}
CSS_FILE_MAPPING = {
"GooglePointFieldWidget": {
"input_files": [
"mapwidgets/static/mapwidgets/css/map_widgets.css",
],
"output_file": "mapwidgets/static/mapwidgets/css/map_widgets.min.css"
},
"GoogleStaticOverlayMapWidget": {
"input_files": [
"mapwidgets/static/mapwidgets/css/magnific-popup.css",
],
"output_file": "mapwidgets/static/mapwidgets/css/magnific-popup.min.css",
}
}
DJANGO_MAPWIDGETS_CONTAINER_NAME = os.environ.get('DJANGO_MAPWIDGETS_CONTAINER_NAME', 'django_mapwidgets')
POSTGRES_CONTAINER_NAME = os.environ.get('DJANGO_MAPWIDGETS_CONTAINER_NAME', 'mapwidget_postgres')
def minify_js_files():
"""
This command minified js files with UglifyJS
"""
for k, v in JS_FILE_MAPPING.items():
input_files = " ".join(v["input_files"])
output_file = v["output_file"]
uglifyjs_command = "uglifyjs {input_files} -o {output_file}".format(
input_files=input_files,
output_file=output_file
)
local(uglifyjs_command)
def minify_css_files():
"""
This command minified js files with UglifyCSS
"""
for k, v in CSS_FILE_MAPPING.items():
input_files = " ".join(v["input_files"])
output_file = v["output_file"]
uglifyjs_command = "uglifycss {input_files} > {output_file}".format(
input_files=input_files,
output_file=output_file
)
local(uglifyjs_command)
def minify_files():
minify_js_files()
minify_css_files()
def docker_build():
local('docker-compose up --build --force-recreate')
def docker_up():
local('docker-compose up')
def docker_shell():
local('docker exec -it {} /bin/bash'.format(DJANGO_MAPWIDGETS_CONTAINER_NAME))
def run_on_docker(command):
local('docker exec -it {} /bin/bash -c "{}"'.format(DJANGO_MAPWIDGETS_CONTAINER_NAME, command))
def docker_runserver():
run_on_docker("cd tests/testapp/; python manage.py runserver 0:8000")
def docker_run_unit_tests():
run_on_docker("cd tests/testapp/; python manage.py test")
def docker_postgres_shell():
local('docker exec -it {} /bin/bash -c "su postgres"'.format(POSTGRES_CONTAINER_NAME))
def docker_covarage_tests():
run_on_docker('cd tests/testapp;coverage run --source="../../mapwidgets" manage.py test;coverage report')