mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-07 18:14:35 +00:00
Add javascript builder
This commit is contained in:
@@ -10,14 +10,15 @@ before_script:
|
|||||||
- cp -f hudson/_GV.php config/
|
- cp -f hudson/_GV.php config/
|
||||||
- node --version
|
- node --version
|
||||||
- npm --version
|
- npm --version
|
||||||
- npm install bower mocha-phantomjs karma recess@">=1.1.0 <1.1.7" -g
|
- npm install bower mocha-phantomjs karma recess@">=1.1.0 <1.1.7" uglify-js -g
|
||||||
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
|
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
|
||||||
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
|
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
|
||||||
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then pecl install redis; fi;'
|
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then pecl install redis; fi;'
|
||||||
- bower install
|
- bower install
|
||||||
- composer self-update
|
- composer self-update
|
||||||
- composer install --dev --prefer-source
|
- composer install --dev --prefer-source
|
||||||
- bin/setup less:compile
|
- bin/setup assets:compile-less
|
||||||
|
- bin/setup assets:build-javascript
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get install -y -qq xpdf ffmpeg libavcodec-extra-53 openoffice.org-writer unoconv ghostscript gsfonts dcraw ufraw graphicsmagick libgraphicsmagick1-dev libfreetype6-dev libjpeg-dev libgif-dev libtiff-dev libdjvulibre-dev libwmf-dev libmagickcore-dev libmagickwand-dev libpng-dev gettext zlib1g-dev build-essential libfaac-dev libmp3lame0 libx264-dev libvpx-dev libtheora-dev libvorbis-dev gpac
|
- sudo apt-get install -y -qq xpdf ffmpeg libavcodec-extra-53 openoffice.org-writer unoconv ghostscript gsfonts dcraw ufraw graphicsmagick libgraphicsmagick1-dev libfreetype6-dev libjpeg-dev libgif-dev libtiff-dev libdjvulibre-dev libwmf-dev libmagickcore-dev libmagickwand-dev libpng-dev gettext zlib1g-dev build-essential libfaac-dev libmp3lame0 libx264-dev libvpx-dev libtheora-dev libvorbis-dev gpac
|
||||||
- sudo apt-get clean
|
- sudo apt-get clean
|
||||||
|
@@ -19,7 +19,8 @@ namespace KonsoleKommander;
|
|||||||
use Alchemy\Phrasea\Core\Version;
|
use Alchemy\Phrasea\Core\Version;
|
||||||
use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
||||||
use Alchemy\Phrasea\Command\Setup\Install;
|
use Alchemy\Phrasea\Command\Setup\Install;
|
||||||
use Alchemy\Phrasea\Command\Setup\LessCompile;
|
use Alchemy\Phrasea\Command\Setup\LessCompiler;
|
||||||
|
use Alchemy\Phrasea\Command\Setup\JavascriptBuilder;
|
||||||
use Alchemy\Phrasea\CLI;
|
use Alchemy\Phrasea\CLI;
|
||||||
use Alchemy\Phrasea\Command\Setup\CheckEnvironment;
|
use Alchemy\Phrasea\Command\Setup\CheckEnvironment;
|
||||||
|
|
||||||
@@ -63,7 +64,8 @@ try {
|
|||||||
|
|
||||||
$app->command(new CheckEnvironment('check:system'));
|
$app->command(new CheckEnvironment('check:system'));
|
||||||
$app->command(new Install('system:install'));
|
$app->command(new Install('system:install'));
|
||||||
$app->command(new LessCompile('less:compile'));
|
$app->command(new LessCompiler());
|
||||||
|
$app->command(new JavascriptBuilder());
|
||||||
|
|
||||||
$result_code = is_int($app->run()) ? : 1;
|
$result_code = is_int($app->run()) ? : 1;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@@ -15,13 +15,20 @@ require __DIR__ . '/vendor/autoload.php';
|
|||||||
|
|
||||||
chdir(__DIR__);
|
chdir(__DIR__);
|
||||||
|
|
||||||
system('bin/setup less:compile', $code);
|
system('bin/setup assets:compile-less', $code);
|
||||||
|
|
||||||
if (0 !== $code) {
|
if (0 !== $code) {
|
||||||
echo "Failed to build less files\n";
|
echo "Failed to build less files\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
system('bin/setup assets:build-javascript', $code);
|
||||||
|
|
||||||
|
if (0 !== $code) {
|
||||||
|
echo "Failed to build javascript files\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
printf('Remove files ...' . PHP_EOL);
|
printf('Remove files ...' . PHP_EOL);
|
||||||
|
99
lib/Alchemy/Phrasea/Command/Setup/JavascriptBuilder.php
Normal file
99
lib/Alchemy/Phrasea/Command/Setup/JavascriptBuilder.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Process\ProcessBuilder;
|
||||||
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This command builds less file
|
||||||
|
*/
|
||||||
|
class JavascriptBuilder extends Command
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct('assets:build-javascript');
|
||||||
|
|
||||||
|
$this->setDescription('Compile less files');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$files = array(
|
||||||
|
$this->container['root.path'] . '/www/skins/build/bootstrap/js/bootstrap.js' => array(
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-transition.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-alert.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-button.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-carousel.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-collapse.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-dropdown.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-modal.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-tooltip.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-popover.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-scrollspy.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-tab.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-typeahead.js',
|
||||||
|
$this->container['root.path'] . '/www/assets/bootstrap/js/bootstrap-affix.js',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($files as $target => $sources) {
|
||||||
|
$this->buildJavascript($input, $output, $target, $sources);
|
||||||
|
|
||||||
|
$minifiedTarget = substr($target, 0, -3) . '.min.js';
|
||||||
|
$this->buildMinifiedJavascript($input, $output, $minifiedTarget, $target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildJavascript(InputInterface $input, OutputInterface $output, $target, $sources)
|
||||||
|
{
|
||||||
|
$output->writeln("Building <info>".basename($target)."</info>");
|
||||||
|
$this->container['filesystem']->remove($target);
|
||||||
|
|
||||||
|
$process = ProcessBuilder::create(array_merge(array('cat'), $sources))->getProcess();
|
||||||
|
if ($input->getOption('verbose')) {
|
||||||
|
$output->writeln("Executing ".$process->getCommandLine()."\n");
|
||||||
|
}
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
if (!$process->isSuccessFul()) {
|
||||||
|
throw new RuntimeException(sprintf('Failed to generate %s', $target));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->container['filesystem']->mkdir(dirname($target));
|
||||||
|
file_put_contents($target, $process->getOutput());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildMinifiedJavascript(InputInterface $input, OutputInterface $output, $target, $source)
|
||||||
|
{
|
||||||
|
$output->writeln("Building <info>".basename($target)."</info>");
|
||||||
|
$this->container['filesystem']->remove($target);
|
||||||
|
|
||||||
|
$process = ProcessBuilder::create(array('uglifyjs', $source, '-nc'))->getProcess();
|
||||||
|
if ($input->getOption('verbose')) {
|
||||||
|
$output->writeln("Executing ".$process->getCommandLine()."\n");
|
||||||
|
}
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
if (!$process->isSuccessFul()) {
|
||||||
|
throw new RuntimeException(sprintf('Failed to generate %s', $target));
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($target, $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
@@ -19,11 +19,11 @@ use Symfony\Component\Process\ProcessBuilder;
|
|||||||
/**
|
/**
|
||||||
* This command builds less file
|
* This command builds less file
|
||||||
*/
|
*/
|
||||||
class LessCompile extends Command
|
class LessCompiler extends Command
|
||||||
{
|
{
|
||||||
public function __construct($name = null)
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct('assets:compile-less');
|
||||||
|
|
||||||
$this->setDescription('Compile less files');
|
$this->setDescription('Compile less files');
|
||||||
}
|
}
|
||||||
@@ -34,17 +34,17 @@ class LessCompile extends Command
|
|||||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$files = array(
|
$files = array(
|
||||||
$this->container['root.path'] . '/www/skins/build/login.css' => realpath($this->container['root.path'] . '/www/skins/login/less/login.less'),
|
$this->container['root.path'] . '/www/skins/login/less/login.less' => $this->container['root.path'] . '/www/skins/build/login.css',
|
||||||
$this->container['root.path'] . '/www/skins/build/account.css' => realpath($this->container['root.path'] . '/www/skins/account/account.less'),
|
$this->container['root.path'] . '/www/skins/account/account.less' => $this->container['root.path'] . '/www/skins/build/account.css',
|
||||||
$this->container['root.path'] . '/www/skins/build/bootstrap/css/bootstrap.css' => realpath($this->container['root.path'] . '/www/assets/bootstrap/less/bootstrap.less'),
|
$this->container['root.path'] . '/www/assets/bootstrap/less/bootstrap.less' => $this->container['root.path'] . '/www/skins/build/bootstrap/css/bootstrap.css',
|
||||||
$this->container['root.path'] . '/www/skins/build/bootstrap/css/bootstrap-responsive.css' => realpath($this->container['root.path'] . '/www/assets/bootstrap/less/responsive.less'),
|
$this->container['root.path'] . '/www/assets/bootstrap/less/responsive.less' => $this->container['root.path'] . '/www/skins/build/bootstrap/css/bootstrap-responsive.css',
|
||||||
);
|
);
|
||||||
|
|
||||||
$output->writeln('Building Assets...');
|
$output->writeln('Building Assets...');
|
||||||
|
|
||||||
$failures = 0;
|
$failures = 0;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
foreach ($files as $buildFile => $lessFile) {
|
foreach ($files as $lessFile => $buildFile) {
|
||||||
$this->container['filesystem']->mkdir(dirname($buildFile));
|
$this->container['filesystem']->mkdir(dirname($buildFile));
|
||||||
$output->writeln(sprintf('Building %s', basename($lessFile)));
|
$output->writeln(sprintf('Building %s', basename($lessFile)));
|
||||||
$builder = ProcessBuilder::create(array(
|
$builder = ProcessBuilder::create(array(
|
17
vendors.php
17
vendors.php
@@ -20,6 +20,7 @@ set_time_limit(0);
|
|||||||
$bower = 'bower';
|
$bower = 'bower';
|
||||||
$node = 'node';
|
$node = 'node';
|
||||||
$recess = 'recess';
|
$recess = 'recess';
|
||||||
|
$uglifyjs = 'uglifyjs';
|
||||||
$npm = 'npm';
|
$npm = 'npm';
|
||||||
|
|
||||||
// Test if node exists
|
// Test if node exists
|
||||||
@@ -62,6 +63,18 @@ if (0 !== $code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests if recess exists else install it
|
||||||
|
exec('uglifyjs --version', $output, $code);
|
||||||
|
|
||||||
|
if (0 !== $code) {
|
||||||
|
exec(sprintf('sudo %s install uglify-js -g', $npm), $output, $code);
|
||||||
|
|
||||||
|
if (0 !== $code) {
|
||||||
|
echo 'Failed to install uglifyjs';
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Install asset dependencies with bower
|
// Install asset dependencies with bower
|
||||||
system(sprintf('%s install', $bower), $code);
|
system(sprintf('%s install', $bower), $code);
|
||||||
|
|
||||||
@@ -100,5 +113,5 @@ if (isset($argv[1]) && $argv[1] == '--no-dev') {
|
|||||||
system($composer . ' install --dev --optimize-autoloader');
|
system($composer . ' install --dev --optimize-autoloader');
|
||||||
}
|
}
|
||||||
|
|
||||||
system('bin/setup less:compile');
|
system('bin/setup assets:compile-less');
|
||||||
|
system('bin/setup assets:build-javascript');
|
||||||
|
Reference in New Issue
Block a user