1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00
Tims-Chat/contrib/build.php

139 lines
4.1 KiB
PHP
Raw Normal View History

2011-12-26 14:49:33 +00:00
#!/usr/bin/env php
<?php
2013-04-29 14:56:20 +00:00
namespace be\bastelstu\chat;
2014-02-28 16:06:50 +00:00
2012-01-06 15:28:42 +00:00
/**
* Builds the Chat
2014-02-28 16:06:50 +00:00
*
2012-01-06 15:28:42 +00:00
* @author Tim Düsterhus
2014-02-27 22:05:09 +00:00
* @copyright 2010-2014 Tim Düsterhus
2012-01-06 15:28:42 +00:00
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
2012-01-06 15:28:42 +00:00
*/
2012-04-15 10:55:22 +00:00
$packageXML = file_get_contents('package.xml');
preg_match('/<version>(.*?)<\/version>/', $packageXML, $matches);
echo "Building Tims Chat $matches[1]\n";
echo str_repeat("=", strlen("Building Tims Chat $matches[1]"))."\n";
2012-01-06 15:15:40 +00:00
echo <<<EOT
Cleaning up
-----------
EOT;
if (file_exists('package.xml.old')) {
file_put_contents('package.xml', file_get_contents('package.xml.old'));
unlink('package.xml.old');
}
2012-01-06 15:15:40 +00:00
if (file_exists('file.tar')) unlink('file.tar');
if (file_exists('template.tar')) unlink('template.tar');
2012-02-04 19:50:18 +00:00
if (file_exists('acptemplate.tar')) unlink('acptemplate.tar');
2013-01-19 19:36:40 +00:00
foreach (glob('file/acp/be.bastelstu.chat.nodePush/lib/*.js') as $nodeFile) unlink($nodeFile);
2012-01-06 15:15:40 +00:00
foreach (glob('file/js/*.js') as $jsFile) unlink($jsFile);
2013-09-08 18:57:11 +00:00
foreach (glob('file/acp/js/*.js') as $jsFile) unlink($jsFile);
2013-01-19 19:36:40 +00:00
if (file_exists('be.bastelstu.chat.tar')) unlink('be.bastelstu.chat.tar');
2012-01-06 15:15:40 +00:00
echo <<<EOT
Building JavaScript
-------------------
EOT;
foreach (glob('file/js/*.{litcoffee,coffee}', GLOB_BRACE) as $coffeeFile) {
2012-01-06 15:15:40 +00:00
echo $coffeeFile."\n";
2013-04-29 14:56:20 +00:00
passthru('coffee -c '.escapeshellarg($coffeeFile), $code);
2012-01-06 15:32:12 +00:00
if ($code != 0) exit($code);
2012-01-06 15:15:40 +00:00
}
echo <<<EOT
2013-09-08 18:57:11 +00:00
Building ACP-JavaScript
-----------------------
EOT;
foreach (glob('file/acp/js/*.{litcoffee,coffee}', GLOB_BRACE) as $coffeeFile) {
echo $coffeeFile."\n";
passthru('coffee -c '.escapeshellarg($coffeeFile), $code);
if ($code != 0) exit($code);
}
echo <<<EOT
2013-05-14 18:29:44 +00:00
Compressing JavaScript
----------------------
EOT;
foreach (glob('file/js/*.js', GLOB_BRACE) as $jsFile) {
echo $jsFile."\n";
passthru('uglifyjs '.escapeshellarg($jsFile).' --screw-ie8 -m -c --verbose --comments -d production=true -o '.escapeshellarg(substr($jsFile, 0, -3).'.min.js'), $code);
2013-05-14 18:29:44 +00:00
if ($code != 0) exit($code);
}
echo <<<EOT
2012-03-09 20:23:17 +00:00
Checking PHP for Syntax Errors
------------------------------
EOT;
chdir('file');
$check = null;
$check = function ($folder) use (&$check) {
if (is_file($folder)) {
if (substr($folder, -4) === '.php') {
passthru('php -l '.escapeshellarg($folder), $code);
if ($code != 0) exit($code);
}
return;
}
$files = glob($folder.'/*');
foreach ($files as $file) {
$check($file);
}
};
$check('.');
echo <<<EOT
2012-01-06 15:15:40 +00:00
Building file.tar
-----------------
EOT;
passthru('tar cvf ../file.tar --exclude=*coffee --exclude-vcs -- *', $code);
2012-01-06 15:32:12 +00:00
if ($code != 0) exit($code);
2012-01-06 15:15:40 +00:00
echo <<<EOT
Building template.tar
---------------------
EOT;
chdir('../template');
2012-01-06 15:32:12 +00:00
passthru('tar cvf ../template.tar *', $code);
if ($code != 0) exit($code);
2012-01-06 15:15:40 +00:00
echo <<<EOT
2012-02-04 19:50:18 +00:00
Building acptemplate.tar
2012-04-09 15:50:07 +00:00
------------------------
2012-02-04 19:50:18 +00:00
EOT;
chdir('../acptemplate');
passthru('tar cvf ../acptemplate.tar *', $code);
if ($code != 0) exit($code);
echo <<<EOT
2013-01-19 19:36:40 +00:00
Building be.bastelstu.chat.tar
2013-02-02 21:07:28 +00:00
------------------------------
2012-01-06 15:15:40 +00:00
EOT;
chdir('..');
2012-04-04 10:29:22 +00:00
file_put_contents('package.xml.old', file_get_contents('package.xml'));
file_put_contents('package.xml', preg_replace('~<date>\d{4}-\d{2}-\d{2}</date>~', '<date>'.date('Y-m-d').'</date>', file_get_contents('package.xml')));
2013-02-15 15:39:44 +00:00
file_put_contents('package.xml', str_replace('</version>', '</version><!-- git id '.trim(shell_exec('git describe --always')).' -->', file_get_contents('package.xml')));
passthru('tar cvf be.bastelstu.chat.tar --exclude=*.old --exclude=file --exclude-vcs --exclude=template --exclude=acptemplate --exclude=contrib -- *', $code);
2012-04-04 10:29:22 +00:00
if (file_exists('package.xml.old')) {
file_put_contents('package.xml', file_get_contents('package.xml.old'));
unlink('package.xml.old');
}
2012-01-06 15:32:12 +00:00
if ($code != 0) exit($code);
2012-01-06 15:15:40 +00:00
if (file_exists('file.tar')) unlink('file.tar');
if (file_exists('template.tar')) unlink('template.tar');
2012-02-04 19:50:18 +00:00
if (file_exists('acptemplate.tar')) unlink('acptemplate.tar');
2013-01-19 19:36:40 +00:00
foreach (glob('file/acp/be.bastelstu.chat.nodePush/lib/*.js') as $nodeFile) unlink($nodeFile);
2012-01-06 15:15:40 +00:00
foreach (glob('file/js/*.js') as $jsFile) unlink($jsFile);
2013-09-08 18:57:11 +00:00
foreach (glob('file/acp/js/*.js') as $jsFile) unlink($jsFile);