2014-01-21 12:56:43 -04:00
|
|
|
#!/usr/bin/env php
|
2013-11-22 16:20:49 -04:00
|
|
|
<?php
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
/*
|
|
|
|
|
* Script o build vendors that requires make some builds and copy some files to a determined path
|
|
|
|
|
*
|
|
|
|
|
* @license Colosa Inc.
|
|
|
|
|
* @author Erik Amaru Ortiz
|
|
|
|
|
*/
|
|
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
2014-01-21 12:56:43 -04:00
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
// --no-ansi wins over --ansi
|
|
|
|
|
if (in_array('--no-ansi', $argv)) {
|
|
|
|
|
define('USE_ANSI', false);
|
|
|
|
|
} elseif (in_array('--ansi', $argv)) {
|
|
|
|
|
define('USE_ANSI', true);
|
|
|
|
|
} else {
|
|
|
|
|
// On Windows, default to no ANSI, except in ANSICON and ConEmu.
|
|
|
|
|
// Everywhere else, default to ANSI if stdout is a terminal.
|
|
|
|
|
define('USE_ANSI',
|
2014-01-24 11:33:25 -04:00
|
|
|
(DIRECTORY_SEPARATOR == '\\')
|
|
|
|
|
? (false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'))
|
|
|
|
|
: (function_exists('posix_isatty') && posix_isatty(1))
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$vendorDir = dirname(__FILE__) . DS . 'vendor';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (! is_dir($vendorDir )) {
|
|
|
|
|
echo "Vendor directory is missing!" . PHP_EOL;
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$projects = array(
|
2014-01-23 17:41:52 -04:00
|
|
|
'colosa/MichelangeloFE',
|
|
|
|
|
'colosa/pmUI'
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
echo PHP_EOL;
|
2014-01-21 12:56:43 -04:00
|
|
|
out("Building JS Projects ", 'info');
|
|
|
|
|
out("--------------------", 'info');
|
2013-11-22 16:20:49 -04:00
|
|
|
|
|
|
|
|
foreach ($projects as $project) {
|
|
|
|
|
echo PHP_EOL;
|
2014-01-21 12:56:43 -04:00
|
|
|
out("=> Building project: ", 'info', false);
|
|
|
|
|
echo $project.' '.PHP_EOL;
|
2013-11-22 16:20:49 -04:00
|
|
|
chdir($vendorDir.DS.$project);
|
2014-01-21 12:56:43 -04:00
|
|
|
echo `rake`;
|
|
|
|
|
out("Completed!", 'success');
|
2013-11-22 16:20:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
out("Copying project files to its destination", 'info', true);
|
|
|
|
|
out("----------------------------------------", 'info', true);
|
2013-11-22 16:20:49 -04:00
|
|
|
|
|
|
|
|
$destinationDir = dirname(__FILE__) . DS . 'workflow/public_html/lib';
|
|
|
|
|
|
|
|
|
|
if (! is_dir($destinationDir)) {
|
|
|
|
|
mkdir($destinationDir, 0777);
|
|
|
|
|
}
|
|
|
|
|
if (! is_dir($destinationDir.'/js')) {
|
|
|
|
|
mkdir($destinationDir.'/js', 0777);
|
|
|
|
|
}
|
2013-11-27 16:24:40 -04:00
|
|
|
if (! is_dir($destinationDir.'/css')) {
|
|
|
|
|
mkdir($destinationDir.'/css', 0777);
|
|
|
|
|
}
|
2013-11-28 11:17:21 -04:00
|
|
|
if (! is_dir($destinationDir.'/img')) {
|
|
|
|
|
mkdir($destinationDir.'/img', 0777);
|
|
|
|
|
}
|
2013-11-22 16:20:49 -04:00
|
|
|
if (! is_dir($destinationDir.'/mafe')) {
|
|
|
|
|
mkdir($destinationDir.'/mafe', 0777);
|
|
|
|
|
}
|
|
|
|
|
if (! is_dir($destinationDir.'/pmUI')) {
|
|
|
|
|
mkdir($destinationDir.'/pmUI', 0777);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$filesCollection = array(
|
2014-01-23 17:41:52 -04:00
|
|
|
// Libs
|
2013-11-22 16:20:49 -04:00
|
|
|
"jquery/jquery/jquery-1.10.2.min.js" => "js/jquery-1.10.2.min.js",
|
|
|
|
|
"underscore/underscore/underscore-min.js" => "js/underscore-min.js",
|
2014-01-23 17:41:52 -04:00
|
|
|
"colosa/pmUI/libraries/restclient/restclient-min.js" => "js/restclient-min.js",
|
2014-01-24 11:33:25 -04:00
|
|
|
|
2014-01-23 17:41:52 -04:00
|
|
|
// MichelangeloFE
|
|
|
|
|
"colosa/MichelangeloFE/lib/wz_jsgraphics/wz_jsgraphics.js" => "js/wz_jsgraphics.js",
|
|
|
|
|
"colosa/MichelangeloFE/build/js/designer.js" => "mafe/designer.js",
|
|
|
|
|
"colosa/MichelangeloFE/build/js/mafe.min.js" => "mafe/mafe.min.js",
|
|
|
|
|
"colosa/MichelangeloFE/build/css/mafe.css" => "mafe/mafe.css",
|
|
|
|
|
"colosa/MichelangeloFE/build/img/*" => "img/",
|
|
|
|
|
// pmUI
|
|
|
|
|
"colosa/pmUI/libraries/jquery.layout/LayoutPanel.css" => "css/jquery.layout.css",
|
|
|
|
|
"colosa/pmUI/libraries/jquery-ui/css/css-customized/jquery-ui-1.10.3.custom.css" => "css/jquery-ui-1.10.3.custom.min.css",
|
|
|
|
|
"colosa/pmUI/libraries/dataTables/css/jquery.dataTables.css" => "css/jquery.dataTables.css",
|
|
|
|
|
"colosa/pmUI/libraries/jquery.layout/jquery.layout.min.js" => "js/jquery.layout.min.js",
|
|
|
|
|
"colosa/pmUI/libraries/jquery-ui/js/jquery-ui-1.10.3.custom.min.js" => "js/jquery-ui-1.10.3.custom.min.js",
|
|
|
|
|
"colosa/pmUI/libraries/dataTables/js/jquery.dataTables.min.js" => "js/jquery.dataTables.min.js",
|
2013-11-27 16:24:40 -04:00
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
array(
|
2014-01-24 11:33:25 -04:00
|
|
|
"try_files" => array("colosa/pmUI/build/js/min/pmui-1.0.0.min.js", "colosa/pmUI/build/js/pmui-1.0.0.js"),
|
|
|
|
|
"to_file" => "pmUI/pmui-1.0.0.js"
|
2014-01-21 12:56:43 -04:00
|
|
|
),
|
2014-01-24 11:33:25 -04:00
|
|
|
"colosa/pmUI/build/css/pmui-1.0.0.css" => "pmUI/pmui-1.0.0.css",
|
2014-01-23 17:41:52 -04:00
|
|
|
"colosa/pmUI/build/img/*" => "img/",
|
2013-11-22 16:20:49 -04:00
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
out("* Destination dir: ", 'info', false);
|
|
|
|
|
echo $destinationDir . PHP_EOL.PHP_EOL;
|
|
|
|
|
|
|
|
|
|
$successCount = 0;
|
2013-11-22 16:20:49 -04:00
|
|
|
|
|
|
|
|
foreach ($filesCollection as $source => $target) {
|
2014-01-21 12:56:43 -04:00
|
|
|
if (! is_array($target)) {
|
|
|
|
|
if (strpos($source, '*') !== false) {
|
|
|
|
|
out("Create dir: ", 'info', false);
|
|
|
|
|
echo $target;
|
|
|
|
|
out(" from source: ", 'info', false);
|
|
|
|
|
echo $source;
|
|
|
|
|
out(" [DONE]", "success", true) . PHP_EOL;
|
|
|
|
|
echo `cp -Rf $vendorDir/$source $destinationDir/$target`;
|
|
|
|
|
$successCount++;
|
|
|
|
|
} else {
|
|
|
|
|
out("Create file: ", 'info', false);
|
|
|
|
|
echo $target;
|
|
|
|
|
out(" from source: ", 'info', false);
|
|
|
|
|
echo $source;
|
|
|
|
|
|
|
|
|
|
if (file_exists("$vendorDir/$source")) {
|
|
|
|
|
out(" [DONE]", "success", true) . PHP_EOL;
|
|
|
|
|
echo `cp -Rf $vendorDir/$source $destinationDir/$target`;
|
|
|
|
|
$successCount++;
|
|
|
|
|
} else {
|
|
|
|
|
out(" [FAILED]", "error", true) . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
out("Create file: ", 'info', false);
|
|
|
|
|
echo $target['to_file'];
|
|
|
|
|
out(" from source: ", 'info', false);
|
|
|
|
|
|
|
|
|
|
$sw = true;
|
|
|
|
|
$files = $target['try_files'];
|
|
|
|
|
$target = $target['to_file'];
|
|
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
|
if (file_exists("$vendorDir/$file")) {
|
|
|
|
|
echo $file;
|
|
|
|
|
out(" [DONE]", "success", true) . PHP_EOL;
|
|
|
|
|
echo `cp -Rf $vendorDir/$file $destinationDir/$target`;
|
|
|
|
|
$successCount++;
|
|
|
|
|
$sw = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($sw) {
|
2014-01-24 11:33:25 -04:00
|
|
|
echo '('.implode(', ', $files).')';
|
2014-01-21 12:56:43 -04:00
|
|
|
out(" [FAILED]", "error", true) . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-22 16:20:49 -04:00
|
|
|
}
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
$n = count($filesCollection);
|
2013-11-22 16:20:49 -04:00
|
|
|
echo PHP_EOL;
|
2014-01-21 12:56:43 -04:00
|
|
|
echo sprintf("- Finished, Copied [%s/%s] files.", $successCount, $n).PHP_EOL;
|
2013-11-22 16:20:49 -04:00
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
if ($successCount == count($filesCollection)) {
|
|
|
|
|
out(sprintf("- All files copied successfully!", $successCount, $n), "success", true);
|
|
|
|
|
} else {
|
|
|
|
|
out("- Finished but with errors while copying!", "error", true);
|
|
|
|
|
}
|
2013-11-22 16:20:49 -04:00
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
echo PHP_EOL;
|
2013-11-22 16:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
/**
|
|
|
|
|
* colorize output
|
|
|
|
|
*/
|
|
|
|
|
function out($text, $color = null, $newLine = true)
|
|
|
|
|
{
|
|
|
|
|
$styles = array(
|
2014-01-21 12:56:43 -04:00
|
|
|
'success' => "\033[0;35;32m%s\033[0m",
|
|
|
|
|
'error' => "\033[0;35;31m%s\033[0m",
|
|
|
|
|
'info' => "\033[1;33;34m%s\033[0m"
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$format = '%s';
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
if (isset($styles[$color])) {
|
2013-11-22 16:20:49 -04:00
|
|
|
$format = $styles[$color];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($newLine) {
|
|
|
|
|
$format .= PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf($format, $text);
|
|
|
|
|
}
|