forked from afup/haphpy-birthday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboFile.php
156 lines (129 loc) · 4.34 KB
/
RoboFile.php
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
class RoboFile extends \Robo\Tasks
{
use Agallou\RoboHash\loadTasks;
private $appBundleAssetsPath = 'src/AFUP/HaphpyBirthdayBundle/Resources/assets/';
public function watch()
{
$this->build();
$buildCss = function () {
$this->_cleanBase();
$this->_cleanCss();
$this->_buildCss();
};
$this
->taskWatch()
->monitor(array($this->appBundleAssetsPath.'sass/'), $buildCss)
->run()
;
}
public function install()
{
$this->getDeps();
$this->build();
}
protected function getDeps()
{
$this->_mkdir('bower_components/');
$this->_cleanDir('bower_components/');
$this->taskBowerInstall('./bin/bowerphp')->run();
//Il n'y a pas de tag d'Elaostrap contenant les fichiers dist
//on clone donc le repo. Une fois qu'il y en aura un il faudra passer
//par le fichier bower.json
$this->taskGitStack()
->cloneRepo('https://github.com/JeremyFagis/ElaoStrap.git', 'bower_components/ElaoStrap')
->run()
;
}
public function build()
{
$this->_clean();
$this->_buildCss();
$this->_buildJs();
$this->_buildOtherAssets();
}
protected function _buildCss()
{
$this
->taskScss([$this->appBundleAssetsPath.'sass/main.scss' => 'app/cache/assets/sass/main_sass.css'])
->addImportPath($this->appBundleAssetsPath.'sass')
->addImportPath('bower_components/compass-mixins/lib/')
->run();
$this
->taskConcat([
'bower_components/ElaoStrap/dist/css/style.css',
'app/cache/assets/sass/main_sass.css',
])
->to('app/cache/main.css')
->run()
;
$this
->taskMinify('app/cache/main.css')
->to('web/assets/css/main.css')
->run()
;
$this->taskHash('web/assets/css/main.css')->to('web/assets/css/')->run();
}
protected function _buildJs()
{
$this
->taskConcat([
'bower_components/ElaoStrap/dist/js/main.js',
])
->to('app/cache/assets/main.js')
->run()
;
$this
->taskMinify('app/cache/assets/main.js')
->to('web/assets/js/main.js')
->run()
;
$this->taskHash('web/assets/js/main.js')->to('web/assets/js/')->run();
}
protected function _clean()
{
$this->_mkdir('app/cache/assets/');
$this->_cleanBase();
$this->_cleanCss();
$this->_cleanJs();
$this->_cleanOtherAssets();
}
protected function _cleanBase()
{
$this->_cleanDir('app/cache/assets/');
}
protected function _cleanCss()
{
$this->_mkdir('web/assets/css');
$this->_cleanDir('web/assets/css');
$this->_mkdir('app/cache/assets/sass');
$this->_cleanDir('app/cache/assets/sass');
}
protected function _cleanJs()
{
$this->_mkdir('web/assets/js');
$this->_cleanDir('web/assets/js');
}
protected function _cleanOtherAssets()
{
$this->_mkdir('web/assets/icons');
$this->_mkdir('web/assets/images');
$this->_mkdir('web/assets/videos');
$this->_mkdir('web/assets/fonts');
$this->_cleanDir('web/assets/icons');
$this->_cleanDir('web/assets/images');
$this->_cleanDir('web/assets/videos');
$this->_cleanDir('web/assets/fonts');
}
protected function _buildOtherAssets()
{
$this->_copyDir($this->appBundleAssetsPath.'icons', 'web/assets/icons');
$this->_copyDir($this->appBundleAssetsPath.'images', 'web/assets/images');
$this->_copyDir($this->appBundleAssetsPath.'php-user-group', 'web/assets/images/php-user-group');
$this->_copyDir('bower_components/ElaoStrap/dist/images', 'web/assets/images');
$this->_copyDir($this->appBundleAssetsPath.'videos', 'web/assets/videos');
$this->_copyDir('bower_components/ElaoStrap/dist/fonts/elaostrap', 'web/assets/fonts/elaostrap');
$this->_copyDir('bower_components/fontawesome/fonts', 'web/assets/fonts/font-awesome');
$this->_copyDir('bower_components/dropify/dist/fonts', 'web/assets/fonts/dropify');
}
}