Commit e6c5808f authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski

Install and compress JS/CSS dependencies in release script

parent bf08b255
......@@ -47,9 +47,17 @@ class RoboFile extends \Robo\Tasks
* @return void
*/
public function minifyCSS() {
$css_dir = __DIR__ . '/../css';
$css_dirs = [
__DIR__ . '/../css',
__DIR__ . '/../lib',
__DIR__ . '/../public/lib',
];
foreach ($css_dirs as $css_dir) {
if (!is_dir($css_dir)) {
continue;
}
if (is_dir($css_dir)) {
$it = new RegexIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($css_dir)
......@@ -60,7 +68,7 @@ class RoboFile extends \Robo\Tasks
foreach ($it as $css_file) {
if (!$this->endsWith($css_file->getFilename(), 'min.css')) {
$this->taskMinify($css_file->getRealpath())
->to(str_replace('.css', '.min.css', $css_file->getRealpath()))
->to(preg_replace('/\.css$/', '.min.css', $css_file->getRealpath()))
->type('css')
->run();
}
......@@ -70,14 +78,22 @@ class RoboFile extends \Robo\Tasks
}
/**
* Minify JavaScript files stylesheets
* Minify JavaScript files
*
* @return void
*/
public function minifyJS() {
$js_dir = __DIR__ . '/../js';
$js_dirs = [
__DIR__ . '/../js',
__DIR__ . '/../lib',
__DIR__ . '/../public/lib',
];
foreach ($js_dirs as $js_dir) {
if (!is_dir($js_dir)) {
continue;
}
if (is_dir($js_dir)) {
$it = new RegexIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($js_dir)
......@@ -88,7 +104,7 @@ class RoboFile extends \Robo\Tasks
foreach ($it as $js_file) {
if (!$this->endsWith($js_file->getFilename(), 'min.js')) {
$this->taskMinify($js_file->getRealpath())
->to(str_replace('.js', '.min.js', $js_file->getRealpath()))
->to(preg_replace('/\.js$/', '.min.js', $js_file->getRealpath()))
->type('js')
->run();
}
......
......@@ -83,6 +83,10 @@ echo "Clean PHP vendor"
\find vendor/ -type d -name "example*" -prune -exec rm -rf {} \;
\find vendor/ -type d -name "design" -prune -exec rm -rf {} \;
echo "Retrieve and build JS/CSS dependencies"
npm install
npm run-script build
echo "Minify stylesheets and javascripts"
$INIT_PWD/vendor/bin/robo minify --load-from tools
......@@ -108,6 +112,9 @@ echo "Delete various scripts and directories"
\rm -rf PULL_REQUEST_TEMPLATE.md;
\rm -rf .tx;
\find pics/ -type f -name "*.eps" -exec rm -rf {} \;
\rm -rf nodes_modules;
\rm -rf package.json;
\rm -rf package-lock.json;
echo "Creating tarball";
cd ..;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment