-
Notifications
You must be signed in to change notification settings - Fork 6
/
RoboFile.php
135 lines (120 loc) · 3.55 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
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
/**
* @var string $projectRoot
*/
protected $projectRoot;
/**
* @var string $cssRoot
*/
protected $cssRoot;
/**
* @var string $jsRoot
*/
protected $jsRoot;
public function __construct()
{
$this->projectRoot = __DIR__ . '/';
$this->cssRoot = $this->projectRoot . 'www/css/';
$this->jsRoot = $this->projectRoot . 'www/js/';
}
/**
* Generates projects minified css file.
*/
public function cssProject()
{
$this->taskConcat([
$this->cssRoot.'src/*.css'
])
->to($this->cssRoot.'project.css')
->run();
$this->taskMinify($this->cssRoot . 'project.css')
->to($this->cssRoot . 'project.min.css')
->run();
unlink($this->cssRoot . 'project.css');
}
/**
* Generates css file containing all vendor css libs.
*/
public function cssVendor()
{
$this->taskConcat([
$this->cssRoot . 'vendor/bootstrap.min.css',
$this->cssRoot . 'vendor/font-awesome.min.css',
$this->cssRoot . 'vendor/AdminLTE.min.css',
$this->cssRoot . 'vendor/skin-blue.min.css',
$this->cssRoot . 'vendor/diff2html.min.css',
$this->projectRoot . 'www/fonts/source-code-pro.css',
$this->projectRoot . 'www/fonts/source-sans-pro.css'
])
->to($this->cssRoot.'vendor.css')
->run();
$this->taskMinify($this->cssRoot . 'vendor.css')
->to($this->cssRoot . 'vendor.min.css')
->run();
unlink($this->cssRoot . 'vendor.css');
}
/**
* Generates minified project js file.
*/
public function jsProject()
{
$this->taskConcat([
$this->jsRoot . 'app/app.js',
$this->jsRoot . 'app/*/*.js',
$this->jsRoot . 'app/*/*/*.js'
])
->to($this->jsRoot . 'project.js')
->run();
$this->taskMinify($this->jsRoot . 'project.js')
->to($this->jsRoot . 'project.min.js')
->run();
unlink($this->jsRoot . 'project.js');
}
/**
* Generates file containing all vendor js libs.
*/
public function jsVendor()
{
$this->taskConcat([
$this->jsRoot . 'vendor/angular.min.js',
$this->jsRoot . 'vendor/angular-route.min.js',
$this->jsRoot . 'vendor/angular-jwt.min.js',
$this->jsRoot . 'vendor/jquery.min.js',
$this->jsRoot . 'vendor/jquery.nanoscroller.min.js',
$this->jsRoot . 'vendor/bootstrap.min.js',
$this->jsRoot . 'vendor/template.min.js',
$this->jsRoot . 'vendor/autobahn.min.js',
$this->jsRoot . 'vendor/diff2html.min.js'
])
->to($this->jsRoot . 'vendor.min.js')
->run();
}
/**
* Rebuilds all assets.
*/
public function assets()
{
$this->cssProject();
$this->cssVendor();
$this->jsProject();
$this->jsVendor();
}
/**
* Watches project JS and CSS folders for changes and regenerates assets if required.
*/
public function watch()
{
$this->taskWatch()->monitor([$this->cssRoot . 'src/'], function () {
$this->cssProject();
})->monitor([$this->jsRoot . 'app/'], function () {
$this->jsProject();
})->run();
}
}