Commit c640592e2468dcee6e72a95d8b54944a2cc1d885
1 parent
9eef7283
Exists in
master
Modificando forma de compilar/teste
Showing
10 changed files
with
94 additions
and
53 deletions
Show diff stats
.gitignore
README.md
... | ... | @@ -27,15 +27,6 @@ Altere o arquivo 'app/profile' para apontar para o novo profile. Exemplo: |
27 | 27 | |
28 | 28 | Esses são comandos exemplos, por favor verifique no seu sistema como deve ser instalado. |
29 | 29 | |
30 | - * flask | |
31 | - pip install flask | |
32 | - * assetgen | |
33 | - pip install assetgen | |
34 | - * config | |
35 | - pip install config | |
36 | - * tavutil | |
37 | - pip install tavutil | |
38 | - | |
39 | 30 | * node.js |
40 | 31 | apt-get install python-software-properties python g++ make |
41 | 32 | add-apt-repository ppa:chris-lea/node.js |
... | ... | @@ -43,44 +34,25 @@ Esses são comandos exemplos, por favor verifique no seu sistema como deve ser i |
43 | 34 | apt-get install nodejs |
44 | 35 | apt-get install npm |
45 | 36 | |
46 | - * coffeescript | |
47 | - npm install -g coffee-script | |
48 | - | |
49 | 37 | * sass |
50 | 38 | apt-get install ruby-full build-essential |
51 | 39 | apt-get install rubygems |
52 | 40 | gem install sass |
53 | 41 | sass -v |
54 | 42 | |
55 | - * uglifyjs | |
56 | - npm install -g uglify-js | |
57 | - (Debian ou Ubuntu: apt-get install node-uglify) | |
58 | 43 | * zlib |
59 | 44 | |
45 | +## Para criar o ambiente de desenvolvimento execute: | |
60 | 46 | |
61 | -Para profiling é necessário além dos acima: | |
62 | - | |
63 | - * werkzeug | |
64 | - | |
65 | -Para testes headless é necessário também: | |
66 | - | |
67 | - * mocha | |
68 | - npm install mocha | |
69 | - | |
70 | - * chai | |
71 | - npm install chai | |
47 | +> make venv | |
72 | 48 | |
73 | - * chai-jq | |
74 | - npm install chai-jq | |
49 | +## Para profiling é necessário além dos acima: | |
75 | 50 | |
76 | - * ejs | |
77 | - npm install ejs | |
51 | + * werkzeug | |
78 | 52 | |
79 | - * express | |
80 | - npm install express | |
53 | +E execute o | |
81 | 54 | |
82 | - * zombie | |
83 | - npm install zombie | |
55 | +> make profile | |
84 | 56 | |
85 | 57 | ## Usando vagrant: |
86 | 58 | |
... | ... | @@ -94,15 +66,19 @@ cd /vagrant/ |
94 | 66 | |
95 | 67 | Execute o comando: |
96 | 68 | |
97 | -> ./build.sh _profile_ | |
69 | +> make run | |
98 | 70 | |
99 | -Se não for especificado nenhum _profile_ o profile _default_ será selecionado. | |
71 | +O profile selecionado será o contido em _app/profile_ | |
100 | 72 | |
101 | 73 | ## Testes da barra |
102 | 74 | |
103 | 75 | Execute o comando: |
104 | 76 | |
105 | -> mocha | |
77 | +> make teste | |
78 | + | |
79 | +Para gerar um teste em XUNIT execute | |
80 | + | |
81 | +> make testReport | |
106 | 82 | |
107 | 83 | # Requisitos da Barra |
108 | 84 | ---- | ... | ... |
app/barrabrasil.py
... | ... | @@ -58,10 +58,10 @@ def barra(): |
58 | 58 | resposta.headers['Last-Modified'] = data |
59 | 59 | return resposta |
60 | 60 | |
61 | -#if __name__ == '__main__': | |
62 | -# import webbrowser | |
63 | -# webbrowser.open("http://127.0.0.1:5000/",new=1) | |
64 | -# app.run(host='0.0.0.0', debug=True) | |
61 | +if __name__ == '__main__': | |
62 | + import webbrowser | |
63 | + webbrowser.open("http://127.0.0.1:5000/",new=1) | |
64 | + app.run(host='0.0.0.0', debug=True) | |
65 | 65 | #webbrowser.open("https://127.0.0.1:5000/",new=2) |
66 | 66 | #app.run(debug=False,ssl_context=ctx) |
67 | 67 | ... | ... |
app/profile.py
... | ... | @@ -4,4 +4,6 @@ from barrabrasil import app |
4 | 4 | |
5 | 5 | app.config['PROFILE'] = True |
6 | 6 | app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30]) #30 que mais demoraram |
7 | -app.run(debug = True) | |
7 | +import webbrowser | |
8 | +webbrowser.open("http://127.0.0.1:5000/",new=1) | |
9 | +app.run(host='0.0.0.0', debug=True) | ... | ... |
build.sh
... | ... | @@ -4,7 +4,7 @@ if [ -n "$1" ] |
4 | 4 | then |
5 | 5 | profile=$1 |
6 | 6 | else |
7 | - profile='default' | |
7 | + profile=$(cat app/profile | awk 'FNR == 1 {print $3}') | |
8 | 8 | fi |
9 | 9 | |
10 | 10 | if test -d "recipes/$profile" |
... | ... | @@ -15,9 +15,11 @@ then |
15 | 15 | touch profile |
16 | 16 | echo 'profile :' $profile > profile |
17 | 17 | echo 'date : "'$(date -R)'"'>> profile |
18 | - mkdir templates/$profile | |
18 | + if test ! -d "templates/$profile" | |
19 | + then | |
20 | + mkdir templates/$profile | |
21 | + fi | |
19 | 22 | cp templates/$profile/* static/ #Copiando enquanto a barra é estática. |
20 | - python barrabrasil.py | |
21 | 23 | else |
22 | - echo "Error. Profile $1 does not exist." | |
24 | + echo "Erro. O profile '$profile' não existe." | |
23 | 25 | fi | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +# Makefile | |
2 | +run: build | |
3 | + venv/bin/python app/barrabrasil.py | |
4 | + | |
5 | + | |
6 | +profile: build | |
7 | + venv/bin/python app/profile.py | |
8 | + | |
9 | +build: venv | |
10 | + sh ./build.sh | |
11 | + | |
12 | +venv: venv/bin/activate | |
13 | +venv/bin/activate: requirements.txt package.json | |
14 | + test -d .env || virtualenv --no-site-packages venv | |
15 | + venv/bin/pip install -Ur requirements.txt | |
16 | + touch venv/bin/activate | |
17 | + npm install | |
18 | + | |
19 | +testReport: | |
20 | + npm run testReport | |
21 | + | |
22 | +teste: | |
23 | + npm test | |
24 | + | |
25 | + | |
26 | + | |
27 | + | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +{ | |
2 | +"name": "BarraBrasil", | |
3 | +"description": "Barra oficial do governo federal brasileiro", | |
4 | +"version": "2.1.3", | |
5 | +"engines": { | |
6 | +"node": "~0.10" | |
7 | +}, | |
8 | +"dependencies": { | |
9 | +"jsdom": "3.1.2", | |
10 | +"uglifyjs": "*", | |
11 | +"coffee-script": "*", | |
12 | +"express": "*", | |
13 | +"chai": "*", | |
14 | +"chai-jq": "*", | |
15 | +"mocha": "*", | |
16 | +"zombie": "*", | |
17 | +"ejs": "*" | |
18 | +}, | |
19 | +"optionalDependencies": {}, | |
20 | +"scripts": { | |
21 | +"testReport": "./node_modules/.bin/mocha --timeout 30000 --recursive -R xunit test/ > test-reports.xml", | |
22 | +"test": "./node_modules/.bin/mocha --timeout 30000 --recursive test/" | |
23 | +} | |
24 | +} | |
25 | + | ... | ... |
recipes/default/assets.json
recipes/default/compile.sh
1 | 1 | #!/bin/sh |
2 | -assetgen ./barra-brasil-1.yaml | |
3 | -assetgen ./barra-brasil-2.yaml | |
4 | -assetgen ./footer-brasil-1.yaml | |
5 | -assetgen ./footer-brasil-2.yaml | |
6 | -assetgen ./barra-brasil-final.yaml | |
2 | +export PATH=$PATH:../../node_modules/.bin/ | |
3 | +../../venv/bin/assetgen ./barra-brasil-1.yaml | |
4 | +../../venv/bin/assetgen ./barra-brasil-2.yaml | |
5 | +../../venv/bin/assetgen ./footer-brasil-1.yaml | |
6 | +../../venv/bin/assetgen ./footer-brasil-2.yaml | |
7 | +../../venv/bin/assetgen ./barra-brasil-final.yaml | |
7 | 8 | ... | ... |